diff options
author | vincent-peugnet <v.peugnet@free.fr> | 2018-11-11 17:19:26 +0100 |
---|---|---|
committer | vincent-peugnet <v.peugnet@free.fr> | 2018-11-11 17:19:26 +0100 |
commit | d7f3313ff4514e38c9f53439cd1a1287e56e45f7 (patch) | |
tree | abff39ab11cb317f5fcd2db558da1c59bdae9239 /app/class/user.php | |
parent | 2f363e8fa26ab849539e64ff7caa21bd164e8979 (diff) | |
download | wcms-d7f3313ff4514e38c9f53439cd1a1287e56e45f7.tar.gz wcms-d7f3313ff4514e38c9f53439cd1a1287e56e45f7.zip |
reboot folder
Diffstat (limited to 'app/class/user.php')
-rw-r--r-- | app/class/user.php | 58 |
1 files changed, 58 insertions, 0 deletions
diff --git a/app/class/user.php b/app/class/user.php new file mode 100644 index 0000000..77d6ba2 --- /dev/null +++ b/app/class/user.php @@ -0,0 +1,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; + } +} + + + +?>
\ No newline at end of file |