From e01f8d98528f07678c3bffc7f0941835dfc72463 Mon Sep 17 00:00:00 2001
From: Starbeamrainbowlabs <sbrl@starbeamrainbowlabs.com>
Date: Sun, 18 Jun 2017 15:29:25 +0100
Subject: [PATCH] Add help section on avatars

---
 build/index.php                      | 11 ++++++++++-
 module_index.json                    |  6 +++---
 modules/feature-user-preferences.php |  8 +++++++-
 3 files changed, 20 insertions(+), 5 deletions(-)

diff --git a/build/index.php b/build/index.php
index c8a9f18..0b4c940 100644
--- a/build/index.php
+++ b/build/index.php
@@ -4112,6 +4112,7 @@ register_module([
 			$shortFilename = substr($filepath, 1 + (strrpos($filepath, '/') !== false ? strrpos($filepath, '/') : -1));
 			
 			header("content-disposition: inline; filename=\"$shortFilename\"");
+			header("last-modified: " . gmdate('D, d M Y H:i:s T', $pageindex->{$env->page}->lastmodified));
 			
 			// If the size is set or original, then send (or redirect to) the original image
 			// Also do the same for SVGs if svg rendering is disabled.
@@ -4607,7 +4608,7 @@ register_module([
  		 * @apiGroup		Upload
  		 * @apiPermission	Anonymous
  		 *
- 		 * @apiParam	{string}	username		The username to fetch the avatar for
+ 		 * @apiParam	{string}	user			The username to fetch the avatar for
  		 * @apiParam	{string}	size			The preferred size of the avatar
  		 */
 		add_action("avatar", function() {
@@ -4650,6 +4651,12 @@ register_module([
 		{
 			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>");
 		}
+		
+		if($settings->avatars_show)
+		{
+			add_help_section("915-avatars", "Avatars", "<p>$settings->sitename allows you to upload an avatar and have it displayed next to your name. If you don't have an avatar uploaded yet, then $settings->sitename will take a <a href='https://www.techopedia.com/definition/19744/hash-function'>hash</a> of your email address and ask <a href='https://gravatar.com'>Gravatar</a> for for your Gravatar instead. If you haven't told $settings->sitename what your email address is either, a hash of your username is used instead. If you don't have a gravatar, then $settings->sitename asks Gravatar for an identicon instead.</p>
+			<p>Your avatar on $settings->sitename currently looks like this: <img class='avatar' src='?action=avatar&user=" . urlencode($env->user) . "' />" . ($settings->upload_enabled ? " - you can upload a new one by going to your <a href='?action=user-preferences'>preferences</a>, or <a href='?action=upload&avatar=yes' />clicking here</a>." : ", but $settings->sitename currently has uploads disabled, so you can't upload a new one directly to $settings->sitename. You can, however, set your email address in your <a href='?action=user-preferences'>preferences</a> and <a href='https://en.gravatar.com/'>create a Gravatar</a>, and then it should show up here on $settings->sitename shortly.") . "</p>");
+		}
 	}
 ]);
 
@@ -6281,6 +6288,8 @@ register_module([
 				}
 			}
 			
+			header("last-modified: " . gmdate('D, d M Y H:i:s T', $pageindex->{$env->page}->lastmodified));
+			
 			// Perform a redirect if the requested page is a redirect page
 			if(isset($pageindex->$page->redirect) &&
 			   $pageindex->$page->redirect === true)
diff --git a/module_index.json b/module_index.json
index 625d565..9c98b28 100755
--- a/module_index.json
+++ b/module_index.json
@@ -104,7 +104,7 @@
         "author": "Starbeamrainbowlabs",
         "description": "Adds the ability to upload files to Pepperminty Wiki. Uploaded files act as pages and have the special 'File\/' prefix.",
         "id": "feature-upload",
-        "lastupdate": 1497791727,
+        "lastupdate": 1497793903,
         "optional": false
     },
     {
@@ -113,7 +113,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": 1497791119,
+        "lastupdate": 1497796098,
         "optional": false
     },
     {
@@ -230,7 +230,7 @@
         "author": "Starbeamrainbowlabs",
         "description": "Allows you to view pages. You really should include this one.",
         "id": "page-view",
-        "lastupdate": 1495291771,
+        "lastupdate": 1497794006,
         "optional": false
     },
     {
diff --git a/modules/feature-user-preferences.php b/modules/feature-user-preferences.php
index 54e37c1..b14fc50 100644
--- a/modules/feature-user-preferences.php
+++ b/modules/feature-user-preferences.php
@@ -176,7 +176,7 @@ register_module([
  		 * @apiGroup		Upload
  		 * @apiPermission	Anonymous
  		 *
- 		 * @apiParam	{string}	username		The username to fetch the avatar for
+ 		 * @apiParam	{string}	user			The username to fetch the avatar for
  		 * @apiParam	{string}	size			The preferred size of the avatar
  		 */
 		add_action("avatar", function() {
@@ -219,6 +219,12 @@ register_module([
 		{
 			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>");
 		}
+		
+		if($settings->avatars_show)
+		{
+			add_help_section("915-avatars", "Avatars", "<p>$settings->sitename allows you to upload an avatar and have it displayed next to your name. If you don't have an avatar uploaded yet, then $settings->sitename will take a <a href='https://www.techopedia.com/definition/19744/hash-function'>hash</a> of your email address and ask <a href='https://gravatar.com'>Gravatar</a> for for your Gravatar instead. If you haven't told $settings->sitename what your email address is either, a hash of your username is used instead. If you don't have a gravatar, then $settings->sitename asks Gravatar for an identicon instead.</p>
+			<p>Your avatar on $settings->sitename currently looks like this: <img class='avatar' src='?action=avatar&user=" . urlencode($env->user) . "' />" . ($settings->upload_enabled ? " - you can upload a new one by going to your <a href='?action=user-preferences'>preferences</a>, or <a href='?action=upload&avatar=yes' />clicking here</a>." : ", but $settings->sitename currently has uploads disabled, so you can't upload a new one directly to $settings->sitename. You can, however, set your email address in your <a href='?action=user-preferences'>preferences</a> and <a href='https://en.gravatar.com/'>create a Gravatar</a>, and then it should show up here on $settings->sitename shortly.") . "</p>");
+		}
 	}
 ]);
 
