From 3e58a7b03d7e6f92b3426f93217d71d08d5a8c3f Mon Sep 17 00:00:00 2001
From: Starbeamrainbowlabs <sbrl@starbeamrainbowlabs.com>
Date: Mon, 2 Jan 2017 20:38:18 +0000
Subject: [PATCH] Add conditional user preferences section to help page.

---
 build/index.php                      | 9 +++++++--
 module_index.json                    | 4 ++--
 modules/feature-user-preferences.php | 9 +++++++--
 3 files changed, 16 insertions(+), 6 deletions(-)

diff --git a/build/index.php b/build/index.php
index 1c41f9f..117b043 100644
--- a/build/index.php
+++ b/build/index.php
@@ -3794,7 +3794,7 @@ register_module([
 	"description" => "Adds a user preferences page, letting pople do things like change their email address and password.",
 	"id" => "feature-user-preferences",
 	"code" => function() {
-		global $settings;
+		global $env, $settings;
 		/**
 		 * @api {get} ?action=user-preferences Get a user preferences configuration page.
 		 * @apiName UserPreferences
@@ -3886,7 +3886,12 @@ register_module([
 			exit(page_renderer::render_main("Password Changed Successfully", "<p>You password was changed successfully. <a href='?action=user-preferences'>Go back to the user preferences page</a>.</p>"));
 		});
 		
-		add_help_section("910-user-preferences", "User Preferences", "<p>(help text coming soon)</p>");
+		// Display a help section on the user preferences, but only if the user
+		// is logged in and so able to access them
+		if($env->is_logged_in)
+		{
+			add_help_section("910-user-preferences", "User Preferences", "<p>As you are logged in, $settings->sitename lets you configure a selection of personal preferences. These can be viewed and tweaked to you liking over on the <a href='?action=user-preferences'>preferences page</a>, which can be accessed at any time by clicking the cog icon (it looks something like this: <a href='?action=user-preferences'>$settings->user_preferences_button_text</a>), though the administrator of $settings->sitename ($settings->admindetails_name) may have changed its appearance.</p>");
+		}
 	}
 ]);
 
diff --git a/module_index.json b/module_index.json
index 1f20ebd..b7ff87e 100755
--- a/module_index.json
+++ b/module_index.json
@@ -104,7 +104,7 @@
         "author": "Starbeamrainbowlabs",
         "description": "Adds a user preferences page, letting pople do things like change their email address and password.",
         "id": "feature-user-preferences",
-        "lastupdate": 1483387687,
+        "lastupdate": 1483389429,
         "optional": false
     },
     {
@@ -230,7 +230,7 @@
         "author": "Emanuil Rusev & Starbeamrainbowlabs",
         "description": "An upgraded (now default!) parser based on Emanuil Rusev's Parsedown Extra PHP library (https:\/\/github.com\/erusev\/parsedown-extra), which is licensed MIT. Please be careful, as this module adds some weight to your installation, and also *requires* write access to the disk on first load.",
         "id": "parser-parsedown",
-        "lastupdate": 1482776954,
+        "lastupdate": 1483388764,
         "optional": false
     }
 ]
\ No newline at end of file
diff --git a/modules/feature-user-preferences.php b/modules/feature-user-preferences.php
index f1c4da8..735dfac 100644
--- a/modules/feature-user-preferences.php
+++ b/modules/feature-user-preferences.php
@@ -6,7 +6,7 @@ register_module([
 	"description" => "Adds a user preferences page, letting pople do things like change their email address and password.",
 	"id" => "feature-user-preferences",
 	"code" => function() {
-		global $settings;
+		global $env, $settings;
 		/**
 		 * @api {get} ?action=user-preferences Get a user preferences configuration page.
 		 * @apiName UserPreferences
@@ -98,7 +98,12 @@ register_module([
 			exit(page_renderer::render_main("Password Changed Successfully", "<p>You password was changed successfully. <a href='?action=user-preferences'>Go back to the user preferences page</a>.</p>"));
 		});
 		
-		add_help_section("910-user-preferences", "User Preferences", "<p>(help text coming soon)</p>");
+		// Display a help section on the user preferences, but only if the user
+		// is logged in and so able to access them
+		if($env->is_logged_in)
+		{
+			add_help_section("910-user-preferences", "User Preferences", "<p>As you are logged in, $settings->sitename lets you configure a selection of personal preferences. These can be viewed and tweaked to you liking over on the <a href='?action=user-preferences'>preferences page</a>, which can be accessed at any time by clicking the cog icon (it looks something like this: <a href='?action=user-preferences'>$settings->user_preferences_button_text</a>), though the administrator of $settings->sitename ($settings->admindetails_name) may have changed its appearance.</p>");
+		}
 	}
 ]);
 
