blob: fc5a66514bdc3726311fa42754f8012ad7bc851d (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
|
<?php
class User
{
protected $level = 0;
protected $password;
public function __construct($datas = []) {
if(!empty($datas)) {
$this->hydrate($datas);
}
}
public function hydrate(array $datas = [])
{
foreach ($datas as $key => $value) {
$method = 'set' . $key;
if (method_exists($this, $method)) {
$this->$method($value);
}
}
}
public function setlevel($level)
{
$this->level = $level;
}
public function level()
{
return $this->level;
}
public function isvisitor()
{
return $this->level === Modeluser::FREE;
}
public function iseditor()
{
return $this->level >= Modeluser::EDITOR;
}
public function isinvite()
{
return $this->level >= Modeluser::INVITE;
}
public function isadmin()
{
return $this->level === Modeluser::ADMIN;
}
}
?>
|