"User Preferences", "version" => "0.1", "author" => "Starbeamrainbowlabs", "description" => "Adds a user preferences page, letting pople do things like change their email address and password.", "id" => "feature-user-preferences", "code" => function() { global $env, $settings; /** * @api {get} ?action=user-preferences Get a user preferences configuration page. * @apiName UserPreferences * @apiGroup Settings * @apiPermission User */ /* * ██ ██ ███████ ███████ ██████ * ██ ██ ██ ██ ██ ██ * ██ ██ ███████ █████ ██████ █████ * ██ ██ ██ ██ ██ ██ * ██████ ███████ ███████ ██ ██ * * ██████ ██████ ███████ ███████ ███████ * ██ ██ ██ ██ ██ ██ ██ * ██████ ██████ █████ █████ ███████ * ██ ██ ██ ██ ██ ██ * ██ ██ ██ ███████ ██ ███████ */ add_action("user-preferences", function() { global $env, $settings; if(!$env->is_logged_in) { exit(page_renderer::render_main("Error - $settings->sitename", "
Since you aren't logged in, you can't change your preferences. This is because stored preferences are tied to each registered user account. You can login here.
")); } $statusMessages = [ "change-password" => "Password changed successfully!" ]; $content = "The new password you typed twice didn't match! Go back.
")); } // Check the current password if(hash_password($_POST["current-pass"]) !== $env->user_data->password) { exit(page_renderer::render_main("Password mismatch - $settings->sitename", "Error: You typed your current password incorrectly! Go back.
")); } // All's good! Go ahead and change the password. $env->user_data->password = hash_password($_POST["new-pass"]); // Save the userdata back to disk save_userdata(); http_response_code(307); header("location: ?action=user-preferences&success=yes&operation=change-password"); exit(page_renderer::render_main("Password Changed Successfully", "You password was changed successfully. Go back to the user preferences page.
")); }); // 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", "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 preferences page, which can be accessed at any time by clicking the cog icon (it looks something like this: $settings->user_preferences_button_text), though the administrator of $settings->sitename ($settings->admindetails_name) may have changed its appearance.
"); } } ]); ?>