diff options
-rw-r--r-- | actions/admin/user/resetpassword.php | 42 | ||||
-rw-r--r-- | engine/lib/admin.php | 5 | ||||
-rw-r--r-- | engine/lib/users.php | 11 | ||||
-rw-r--r-- | languages/en.php | 13 | ||||
-rw-r--r-- | mod/profile/views/default/profile/userdetails.php | 2 |
5 files changed, 71 insertions, 2 deletions
diff --git a/actions/admin/user/resetpassword.php b/actions/admin/user/resetpassword.php new file mode 100644 index 000000000..f58ae7fa8 --- /dev/null +++ b/actions/admin/user/resetpassword.php @@ -0,0 +1,42 @@ +<?php + /** + * Admin password reset. + * + * @package Elgg + * @subpackage Core + * @license http://www.gnu.org/licenses/old-licenses/gpl-2.0.html GNU Public License version 2 + * @author Marcus Povey + * @copyright Curverider Ltd 2008 + * @link http://elgg.org/ + */ + + require_once(dirname(dirname(dirname(dirname(__FILE__)))) . "/engine/start.php"); + global $CONFIG; + + // block non-admin users + admin_gatekeeper(); + + // Get the user + $guid = get_input('guid'); + $obj = get_entity($guid); + + if ( ($obj instanceof ElggUser) && ($obj->canEdit())) + { + $password = generate_random_cleartext_password(); + + $obj->password = generate_user_password($obj, $password); + + if ($obj->save()) + { + system_message(elgg_echo('admin:user:resetpassword:yes')); + + notify_user($obj->guid, $CONFIG->site->guid, elgg_echo('email:resetpassword:subject'), sprintf(elgg_echo('email:resetpassword:body'), $obj->username, $password), NULL, 'email'); + } else + system_message(elgg_echo('admin:user:resetpassword:no')); + } + else + system_message(elgg_echo('admin:user:resetpassword:no')); + + forward($_SERVER['HTTP_REFERER']); + exit; +?>
\ No newline at end of file diff --git a/engine/lib/admin.php b/engine/lib/admin.php index 3c34b51c1..47704a4be 100644 --- a/engine/lib/admin.php +++ b/engine/lib/admin.php @@ -45,7 +45,10 @@ extend_elgg_admin_page('admin/main_opt/user', 'admin/main'); extend_elgg_admin_page('admin/main_opt/plugins', 'admin/main', 999); // Always last - + register_action('admin/user/ban', false, "", true); + register_action('admin/user/delete', false, "", true); + register_action('admin/user/resetpassword', false, "", true); + // Register some actions register_action('admin/site/update_basic', false, "", true); // Register basic site admin action } diff --git a/engine/lib/users.php b/engine/lib/users.php index d8fc53f79..554ada22b 100644 --- a/engine/lib/users.php +++ b/engine/lib/users.php @@ -813,6 +813,17 @@ } /** + * Simple function that will generate a random clear text password suitable for feeding into generate_user_password(). + * + * @see generate_user_password + * @return string + */ + function generate_random_cleartext_password() + { + return substr(md5(microtime()), 0, 8); + } + + /** * Generate a password for a user, currently uses MD5. * * Later may introduce salting etc. diff --git a/languages/en.php b/languages/en.php index 7b780eb27..e361eeb4b 100644 --- a/languages/en.php +++ b/languages/en.php @@ -310,7 +310,10 @@ 'admin:user:ban:no' => "Can not ban user", 'admin:user:ban:yes' => "User banned.", 'admin:user:delete:no' => "Can not delete user", - 'admin:user:delete:yes' => "User deleted",
+ 'admin:user:delete:yes' => "User deleted", + + 'admin:user:resetpassword:yes' => "Password reset, user notified.", + 'admin:user:resetpassword:no' => "Password could not be reset.",
/** * User settings @@ -356,6 +359,8 @@ 'enable' => "Enable", 'disable' => "Disable", + 'resetpassword' => "Reset password", + 'yes' => "Yes", 'no' => "No",
@@ -490,6 +495,12 @@ Please confirm your email address by clicking on the link below: Congratulations, you have successfully validated your email address.", + + 'email:resetpassword:subject' => "Password reset!", + 'email:resetpassword:body' => "Hi %s, + +Your password has been reset to: %s", + /** * XML-RPC */ diff --git a/mod/profile/views/default/profile/userdetails.php b/mod/profile/views/default/profile/userdetails.php index aacc17c03..a6f381328 100644 --- a/mod/profile/views/default/profile/userdetails.php +++ b/mod/profile/views/default/profile/userdetails.php @@ -123,6 +123,8 @@ <a href="<?php echo $vars['url']; ?>actions/admin/user/ban?guid=<?php echo $vars['entity']->guid; ?>"><?php echo elgg_echo("ban"); ?></a> <a href="<?php echo $vars['url']; ?>actions/admin/user/delete?guid=<?php echo $vars['entity']->guid; ?>"><?php echo elgg_echo("delete"); ?></a> + + <a href="<?php echo $vars['url']; ?>actions/admin/user/resetpassword?guid=<?php echo $vars['entity']->guid; ?>"><?php echo elgg_echo("resetpassword"); ?></a> <?php } |