public function getUser($username = null) { $user = new TUser($this); $user->setIsGuest(true); if ($username !== null && $this->existeUsuario($username)) { $user->setIsGuest(false); $user->setName($username); $user->setRoles(array('normal')); } return $user; }
/** * returns a user instance given the username * @param string username, null if it is a guest * @return TUser the user instance, null if the specified username is not the user database * */ public function getUser($username = null) { if ($username === null) { $user = new TUser($this); $user->setIsGuest(true); return $user; } else { $user = new TUser($this); $um = new UserManager(); $um->setUser($username); $datauser = $um->getDataUser(); $bool = true; switch ($datauser['page']) { case 'sa': $roles = 'superadmin'; $bool = false; break; case 'ad': $roles = 'adminpuskesmas'; $bool = false; break; case 'sp': $roles = 'staffpuskesmas'; $bool = false; break; case 'd': $roles = 'pejabatdinas'; $bool = false; break; } $user->setIsGuest($bool); $user->setRoles($roles); $user->setName($datauser); return $user; } }
/** * Returns a user instance given the user name. * @param string user name, null if it is a guest. * @return TUser the user instance, null if the specified username is not in the user database. */ public function getUser($username = null) { if ($username === null) { $user = new TUser($this); $user->setIsGuest(true); return $user; } else { $username = strtolower($username); if (isset($this->_users[$username])) { $user = new TUser($this); $user->setName($username); $user->setIsGuest(false); if (isset($this->_roles[$username])) { $user->setRoles($this->_roles[$username]); } return $user; } else { return null; } } }
public function testStateChanged() { $user = new TUser(self::$mgr); $user->setName('John'); self::assertTrue($user->getStateChanged()); $user->setStateChanged(false); self::assertFalse($user->getStateChanged()); }