blob: 77d6ba2695d09fc1974aca19ed2e4e053e6d5e47 (
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;
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 canedit()
{
// a modifier en prenant compte du code invitation de l'article
return $this->level >= Modeluser::EDITOR;
}
public function cancreate()
{
return $this->level >=Modeluser::EDITOR;
}
public function isadmin()
{
return $this->level === Modeluser::ADMIN;
}
}
?>
|