X-Git-Url: http://git.polytechnique.org/?a=blobdiff_plain;f=classes%2Fuser.php;h=e380dacde2037f0f7168675f85a0308b645a0228;hb=6c615821baef0daad2d1d8d7ef988be146da58e3;hp=bc9adc5e41b778ab8344a72759008628faef61f4;hpb=ba1cbd51cd218c3a8caf6d9518df9d2367a9ae54;p=platal.git diff --git a/classes/user.php b/classes/user.php index bc9adc5..e380dac 100644 --- a/classes/user.php +++ b/classes/user.php @@ -1,6 +1,6 @@ numRows()) { return $res->fetchOneCell(); } @@ -170,7 +171,7 @@ class User extends PlUser FIND_IN_SET(\'watch\', a.flags) AS watch, a.comment, a.weak_password IS NOT NULL AS weak_access, g.g_account_name IS NOT NULL AS googleapps, a.token IS NOT NULL AS token_access, a.token, a.last_version, - UNIX_TIMESTAMP(s.start) AS lastlogin, s.host, UNIX_TIMESTAMP(fp.last_seen) AS banana_last + s.start AS lastlogin, s.host, fp.last_seen AS banana_last ' . $fields . ' FROM accounts AS a INNER JOIN account_types AS at ON (at.type = a.type) @@ -230,14 +231,14 @@ class User extends PlUser * * Rules are: * - Everyone can view 'public' - * - directory_ax gives access to 'AX' level + * - directory_ax gives access to 'AX' level, ie. the printed directory * - directory_private gives access to 'private' level - * - admin gives access to 'hidden' level + * - admin and directory_hidden gives access to 'hidden' level */ public function readVisibility() { $level = Visibility::VIEW_NONE; - if ($this->is_admin) { + if ($this->is_admin || $this->checkPerms('directory_hidden')) { $level = Visibility::VIEW_ADMIN; } elseif ($this->checkPerms('directory_private')) { $level = Visibility::VIEW_PRIVATE; @@ -363,12 +364,18 @@ class User extends PlUser if (!$this->_profile_fetched || $forceFetch) { $this->_profile_fetched = true; $this->_profile = Profile::get($this, $fields, $visibility); - } else if ($this->_profile !== null && !$this->_profile->visibility->equals($visibility)) { + } else if ($this->_profile !== null && $visibility !== null && !$this->_profile->visibility->equals($visibility)) { return Profile::get($this, $fields, $visibility); } return $this->_profile; } + public function setPrefetchedProfile(Profile $profile) + { + $this->_profile_fetched = true; + $this->_profile = $profile; + } + /** Return true if the user has an associated profile. */ public function hasProfile() @@ -1101,5 +1108,5 @@ class UserIterator implements PlIterator } } -// vim:set et sw=4 sts=4 sws=4 foldmethod=marker enc=utf-8: +// vim:set et sw=4 sts=4 sws=4 foldmethod=marker fenc=utf-8: ?>