diff options
author | vincent-peugnet <v.peugnet@free.fr> | 2018-12-23 18:20:57 +0100 |
---|---|---|
committer | vincent-peugnet <v.peugnet@free.fr> | 2018-12-23 18:20:57 +0100 |
commit | e8566a57cf1b9cc2eed10429f27840d17da945ef (patch) | |
tree | 9902d9f4dc2e871819af21ede642e50aaab1518b /app/class/user.php | |
parent | 532cdf4bb82ab7cc6fa7659d9aec3ce122b2ec52 (diff) | |
download | wcms-e8566a57cf1b9cc2eed10429f27840d17da945ef.tar.gz wcms-e8566a57cf1b9cc2eed10429f27840d17da945ef.zip |
feature users
Diffstat (limited to 'app/class/user.php')
-rw-r--r-- | app/class/user.php | 64 |
1 files changed, 61 insertions, 3 deletions
diff --git a/app/class/user.php b/app/class/user.php index fc5a665..fa6589c 100644 --- a/app/class/user.php +++ b/app/class/user.php @@ -2,7 +2,9 @@ class User { + protected $id; protected $level = 0; + protected $signature = ''; protected $password; public function __construct($datas = []) { @@ -11,7 +13,7 @@ class User } } - public function hydrate(array $datas = []) + public function hydrate($datas = []) { foreach ($datas as $key => $value) { $method = 'set' . $key; @@ -21,10 +23,19 @@ class User } } } + + public function dry() + { + $array = []; + foreach (get_class_vars(__class__) as $var => $value) { + $array[$var] = $this->$var(); + } + return $array; + } - public function setlevel($level) + public function id() { - $this->level = $level; + return $this->id; } public function level() @@ -32,6 +43,53 @@ class User return $this->level; } + public function password($type = 'string') + { + if($type === 'int') { + return strlen($this->password); + } elseif ($type = 'string') { + return $this->password; + } + } + + public function signature() + { + return $this->signature; + } + + public function setid($id) + { + if (strlen($id) < Model::MAX_ID_LENGTH and is_string($id)) { + $this->id = idclean($id); + } + } + + public function setlevel($level) + { + $level = intval($level); + if($level >= 0 && $level <= 10) { + $this->level = $level; + } + } + + public function setpassword(string $password) + { + if(strlen($password) >= 4 && strlen($password) <= 32) { + $this->password = $password; + } + } + + public function setsignature(string $signature) + { + if(strlen($signature) <= 128) { + $this->signature = $signature; + } + } + + + + + public function isvisitor() { return $this->level === Modeluser::FREE; |