1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
namespace Nicklas\Comment\Modules; |
4
|
|
|
|
5
|
|
|
/** |
6
|
|
|
* A database driven model. |
7
|
|
|
*/ |
8
|
|
|
class User extends ActiveRecordModelExtender |
9
|
|
|
{ |
10
|
|
|
|
11
|
|
|
/** |
12
|
|
|
* @var string $tableName name of the database table. |
13
|
|
|
*/ |
14
|
|
|
protected $tableName = "ramverk1_users"; |
15
|
|
|
|
16
|
|
|
/** |
17
|
|
|
* Columns in the table. |
18
|
|
|
* |
19
|
|
|
* @var integer $id primary key auto incremented. |
20
|
|
|
*/ |
21
|
|
|
public $id; |
22
|
|
|
public $name; |
23
|
|
|
public $email; |
24
|
|
|
public $pass; |
25
|
|
|
public $authority = "user"; |
26
|
|
|
public $question; |
27
|
|
|
|
28
|
|
|
|
29
|
|
|
/** |
30
|
|
|
* Check if user exists |
31
|
|
|
* |
32
|
|
|
* @param string $name |
33
|
|
|
* |
34
|
|
|
* @return boolean true if user exists in database else false |
35
|
|
|
*/ |
36
|
|
|
public function userExists($name) |
37
|
|
|
{ |
38
|
|
|
$user = $this->find("name", $name); |
39
|
|
|
return !$user ? false : true; |
40
|
|
|
} |
41
|
|
|
/** |
42
|
|
|
* Returns gravatar link |
43
|
|
|
* |
44
|
|
|
* @param string $email |
|
|
|
|
45
|
|
|
* |
46
|
|
|
* @return string as gravatar link |
47
|
|
|
*/ |
48
|
|
|
public function setGravatar() |
49
|
|
|
{ |
50
|
|
|
$this->img = $this->gravatar($this->email); |
|
|
|
|
51
|
|
|
} |
52
|
|
|
|
53
|
|
|
|
54
|
|
|
/** |
55
|
|
|
* Set the pass. |
56
|
|
|
* |
57
|
|
|
* @param string $pass the pass to use. |
58
|
|
|
* |
59
|
|
|
* @return void |
60
|
|
|
*/ |
61
|
|
|
public function setPassword($pass) |
62
|
|
|
{ |
63
|
|
|
$this->pass = password_hash($pass, PASSWORD_DEFAULT); |
64
|
|
|
} |
65
|
|
|
|
66
|
|
|
/** |
67
|
|
|
* Verify the name and the pass, if successful the object contains |
68
|
|
|
* all details from the database row. |
69
|
|
|
* |
70
|
|
|
* @param string $name name to check. |
71
|
|
|
* @param string $pass the pass to use. |
72
|
|
|
* |
73
|
|
|
* @return boolean true if name and pass matches, else false. |
74
|
|
|
*/ |
75
|
|
|
public function verifyPassword($name, $pass) |
76
|
|
|
{ |
77
|
|
|
$this->find("name", $name); |
78
|
|
|
return password_verify($pass, $this->pass); |
79
|
|
|
} |
80
|
|
|
|
81
|
|
|
/** |
82
|
|
|
* Verify the name and the anaswer, if successful the object contains |
83
|
|
|
* all details from the database row. |
84
|
|
|
* |
85
|
|
|
* @param string $name name to check. |
86
|
|
|
* @param string $answer the answer. |
87
|
|
|
* |
88
|
|
|
* @return boolean true if name and pass matches, else false. |
89
|
|
|
*/ |
90
|
|
|
public function verifyQuestion($name, $answer) |
91
|
|
|
{ |
92
|
|
|
$this->find("name", $name); |
93
|
|
|
return ($this->question == $answer); |
94
|
|
|
} |
95
|
|
|
} |
96
|
|
|
|
This check looks for PHPDoc comments describing methods or function parameters that do not exist on the corresponding method or function.
Consider the following example. The parameter
$italy
is not defined by the methodfinale(...)
.The most likely cause is that the parameter was removed, but the annotation was not.