1
0
Fork 0
mirror of https://github.com/sbrl/Pepperminty-Wiki.git synced 2024-11-26 05:32:59 +00:00

Add link to avatar upload to user preferences page

This commit is contained in:
Starbeamrainbowlabs 2017-06-18 14:10:58 +01:00
parent 1d09c22f3a
commit 9abda2f323
4 changed files with 19 additions and 5 deletions

View file

@ -1520,7 +1520,7 @@ class page_renderer
if(module_exists("feature-user-preferences")) { if(module_exists("feature-user-preferences")) {
$result .= "<a href='?action=user-preferences'>$settings->user_preferences_button_text</a>"; $result .= "<a href='?action=user-preferences'>$settings->user_preferences_button_text</a>";
} }
$result .= "<a href='?page=" . rawurlencode("$settings->user_page_prefix/$env->user") . "'>" . self::render_username($env->user) . "</a>"; $result .= " <a href='?page=" . rawurlencode("$settings->user_page_prefix/$env->user") . "'>" . self::render_username($env->user) . "</a>";
$result .= " <small>(<a href='index.php?action=logout'>Logout</a>)</small>"; $result .= " <small>(<a href='index.php?action=logout'>Logout</a>)</small>";
$result .= "</span>"; $result .= "</span>";
//$result .= page_renderer::$nav_divider; //$result .= page_renderer::$nav_divider;
@ -1729,7 +1729,7 @@ function add_action($action_name, $func)
function has_action($action_name) function has_action($action_name)
{ {
global $actions; global $actions;
return !empty($actions->action_name); return !empty($actions->$action_name);
} }
$parsers = [ $parsers = [
@ -4480,6 +4480,13 @@ register_module([
{ {
$content .= "<p class='user-prefs-status-message'><em>" . $statusMessages[$_GET["operation"]] . "</em></p>\n"; $content .= "<p class='user-prefs-status-message'><em>" . $statusMessages[$_GET["operation"]] . "</em></p>\n";
} }
// If avatar support is present, allow the user to upload a new avatar
if(has_action("avatar") && module_exists("feature-upload")) {
$content .= "<a href='?action=upload&avatar=yes' class='preview'><figure>\n";
$content .= "\t<img class='avatar' src='?action=avatar&user=" . urlencode($env->user) . "&size=256' title='Your current avatar - click to upload a new one' />\n";
$content .= "<figcaption>Upload a new avatar</figcaption>\n";
$content .= "</figure></a><br />\n";
}
$content .= "<label for='username'>Username:</label>\n"; $content .= "<label for='username'>Username:</label>\n";
$content .= "<input type='text' name='username' value='$env->user' readonly />\n"; $content .= "<input type='text' name='username' value='$env->user' readonly />\n";
$content .= "<form method='post' action='?action=save-preferences'>\n"; $content .= "<form method='post' action='?action=save-preferences'>\n";

View file

@ -1171,7 +1171,7 @@ class page_renderer
if(module_exists("feature-user-preferences")) { if(module_exists("feature-user-preferences")) {
$result .= "<a href='?action=user-preferences'>$settings->user_preferences_button_text</a>"; $result .= "<a href='?action=user-preferences'>$settings->user_preferences_button_text</a>";
} }
$result .= "<a href='?page=" . rawurlencode("$settings->user_page_prefix/$env->user") . "'>" . self::render_username($env->user) . "</a>"; $result .= " <a href='?page=" . rawurlencode("$settings->user_page_prefix/$env->user") . "'>" . self::render_username($env->user) . "</a>";
$result .= " <small>(<a href='index.php?action=logout'>Logout</a>)</small>"; $result .= " <small>(<a href='index.php?action=logout'>Logout</a>)</small>";
$result .= "</span>"; $result .= "</span>";
//$result .= page_renderer::$nav_divider; //$result .= page_renderer::$nav_divider;
@ -1380,7 +1380,7 @@ function add_action($action_name, $func)
function has_action($action_name) function has_action($action_name)
{ {
global $actions; global $actions;
return !empty($actions->action_name); return !empty($actions->$action_name);
} }
$parsers = [ $parsers = [

View file

@ -113,7 +113,7 @@
"author": "Starbeamrainbowlabs", "author": "Starbeamrainbowlabs",
"description": "Adds a user preferences page, letting pople do things like change their email address and password.", "description": "Adds a user preferences page, letting pople do things like change their email address and password.",
"id": "feature-user-preferences", "id": "feature-user-preferences",
"lastupdate": 1497713836, "lastupdate": 1497791119,
"optional": false "optional": false
}, },
{ {

View file

@ -49,6 +49,13 @@ register_module([
{ {
$content .= "<p class='user-prefs-status-message'><em>" . $statusMessages[$_GET["operation"]] . "</em></p>\n"; $content .= "<p class='user-prefs-status-message'><em>" . $statusMessages[$_GET["operation"]] . "</em></p>\n";
} }
// If avatar support is present, allow the user to upload a new avatar
if(has_action("avatar") && module_exists("feature-upload")) {
$content .= "<a href='?action=upload&avatar=yes' class='preview'><figure>\n";
$content .= "\t<img class='avatar' src='?action=avatar&user=" . urlencode($env->user) . "&size=256' title='Your current avatar - click to upload a new one' />\n";
$content .= "<figcaption>Upload a new avatar</figcaption>\n";
$content .= "</figure></a><br />\n";
}
$content .= "<label for='username'>Username:</label>\n"; $content .= "<label for='username'>Username:</label>\n";
$content .= "<input type='text' name='username' value='$env->user' readonly />\n"; $content .= "<input type='text' name='username' value='$env->user' readonly />\n";
$content .= "<form method='post' action='?action=save-preferences'>\n"; $content .= "<form method='post' action='?action=save-preferences'>\n";