Source

lorea_production / elgg / actions / user / requestnewpassword.php

Full commit
<?php
/**
 * Action to request a new password.
 *
 * @package Elgg
 * @subpackage Core
 */

global $CONFIG;

$username = get_input('username');
$email = get_input('email');

$access_status = access_get_show_hidden_status();
access_show_hidden_entities(true);

if($username){
	$user = get_user_by_username($username);
}else if($email){
	$user = get_user_by_email($email);
	$user = $user[0];
	$mail = true;
}

if ($user) {
	if ($user->validated) {
		if (send_new_password_request($user->guid)) {
			system_message(elgg_echo('user:password:resetreq:success'));
		} else {
			register_error(elgg_echo('user:password:resetreq:fail'));
		}
	} else if (!trigger_plugin_hook('unvalidated_requestnewpassword','user',array('entity'=>$user))) {
		// if plugins have not registered an action, the default action is to
		// trigger the validation event again and assume that the validation
		// event will display an appropriate message
		trigger_elgg_event('validate', 'user', $user);
	}
} else{
	if($mail){
		register_error(sprintf(elgg_echo('user:email:notfound'),$email));	
	}else{
		register_error(sprintf(elgg_echo('user:username:notfound'), $username));
	}
}

access_show_hidden_entities($access_status);
forward();
exit;