+ // Specialization of the buildPerms method
+ // This function build 'generic' permissions for the user. It does not take
+ // into account page specific permissions (e.g X.net group permissions)
+ protected function buildPerms()
+ {
+ if (!is_null($this->perm_flags)) {
+ return;
+ }
+ if ($this->perms === null) {
+ $this->loadMainFields();
+ }
+ $this->perm_flags = self::makePerms($this->perms);
+ }
+
+ // Return the password of the user
+ public function password()
+ {
+ return XDB::fetchOneCell('SELECT u.password
+ FROM auth_user_md5 AS u
+ WHERE u.user_id = {?}', $this->id());
+ }
+
+ // Return permission flags for a given permission level.
+ public static function makePerms($perms)
+ {
+ $flags = new PlFlagSet();
+ if (is_null($flags) || $perms == 'disabled' || $perms == 'ext') {
+ return $flags;
+ }
+ $flags->addFlag(PERMS_USER);
+ if ($perms == 'admin') {
+ $flags->addFlag(PERMS_ADMIN);
+ }
+ return $flags;
+ }
+