Proyectos de Subversion Moodle

Rev

| Ultima modificación | Ver Log |

Rev Autor Línea Nro. Línea
1 efrain 1
<?php
2
// This file is part of Moodle - http://moodle.org/
3
//
4
// Moodle is free software: you can redistribute it and/or modify
5
// it under the terms of the GNU General Public License as published by
6
// the Free Software Foundation, either version 3 of the License, or
7
// (at your option) any later version.
8
//
9
// Moodle is distributed in the hope that it will be useful,
10
// but WITHOUT ANY WARRANTY; without even the implied warranty of
11
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
12
// GNU General Public License for more details.
13
//
14
// You should have received a copy of the GNU General Public License
15
// along with Moodle.  If not, see <http://www.gnu.org/licenses/>.
16
 
17
/**
18
 * Reset Password
19
 *
20
 * @package    local
21
 * @subpackage resetpassword
22
 * @copyright  2014 Aaron Leggett
23
 * @license    http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
24
 */
25
 
26
 
27
 
28
	/**
29
	* 	Function local_resetpassword_valid_key
30
	* 	Checks stored private key and email against the key sent
31
	* 	@param k - Key sent in post
32
	* 	@param e - Email requesting password reset
33
	*	@param pk - Stored private key from moodle
34
	*	@return bool - true if k is valid
35
	*/
36
function local_resetpassword_valid_key($k, $e, $pk){
37
	$tempKey = $e . $pk;
38
	$tempKey = md5($tempKey);
39
 
40
	if($tempKey != $k){
41
		return false;
42
	}
43
 
44
	return true;
45
}
46
 
47
	/**
48
	* 	Function local_resetpassword_get_user_id
49
	* 	Checks stored private key and email against the key sent
50
	*	Also checks mnethostid of the user to make sure the user is
51
	* 	from this moodle. Only really applies when Moodle Networking is setup
52
	*
53
	* 	@param email - Email requesting password reset
54
	*	@return user - user account or false
55
	*/
56
function local_resetpassword_get_user_id($email){
57
	global $DB, $CFG;
58
 
59
	$user = $DB->get_record('user', array('email'=>$email, 'mnethostid'=>$CFG->mnet_localhost_id));
60
	if($user == false){
61
		return false;
62
	}
63
 
64
	return $user;
65
 
66
	// checks mnethostid of the user to make sure the user is
67
	// from this moodle. Only really applies when Moodle Networking is setup
68
}