From: Florent Bruneau Date: Mon, 11 Oct 2010 13:10:47 +0000 (+0200) Subject: Fix profile/{alias} (that is required for backward compatibility). X-Git-Tag: xorg/1.0.1~64 X-Git-Url: http://git.polytechnique.org/?a=commitdiff_plain;h=4ac2e2ba8b9569fcb9511ce63216f3046b9866ec;p=platal.git Fix profile/{alias} (that is required for backward compatibility). BTW, this also fix the links for profile/{alias}@polytechnique.org Signed-off-by: Florent Bruneau --- diff --git a/classes/user.php b/classes/user.php index 4d4a28a..854c848 100644 --- a/classes/user.php +++ b/classes/user.php @@ -327,11 +327,11 @@ class User extends PlUser /** Return the main profile attached with this account if any. */ - public function profile($forceFetch = false) + public function profile($forceFetch = false, $fields = 0x0000, $visibility = null) { if (!$this->_profile_fetched || $forceFetch) { $this->_profile_fetched = true; - $this->_profile = Profile::get($this); + $this->_profile = Profile::get($this, $fields, $visibility); } return $this->_profile; } diff --git a/modules/profile.php b/modules/profile.php index b737ac6..e3239d2 100644 --- a/modules/profile.php +++ b/modules/profile.php @@ -232,17 +232,6 @@ class ProfileModule extends PLModule if (is_null($id)) { return PL_NOT_FOUND; } - $pid = (!is_numeric($id) || S::admin()) ? Profile::getPID($id) : null; - if (is_null($pid)) { - if (S::logged()) { - $page->trigError($id . " inconnu dans l'annuaire."); - } - return PL_NOT_FOUND; - } - - // Now that we know this is an existing profile, we can switch to the - // appropriate template. - $page->changeTpl('profile/profile.tpl', SIMPLE); // Determines the access level at which the profile will be displayed. if (!S::logged() || !S::user()->checkPerms('directory_ax') || Env::v('view') == 'public') { @@ -258,10 +247,30 @@ class ProfileModule extends PLModule $page->assign('with_pending_pic', true); } - // Fetches profile's and profile's owner information and redirects to - // marketing if the owner has not subscribed and the requirer has logged in. - $profile = Profile::get($pid, Profile::FETCH_ALL, $view); - $owner = $profile->owner(); + $pid = (!is_numeric($id) || S::admin()) ? Profile::getPID($id) : null; + if (is_null($pid)) { + $owner = User::getSilent($id); + if ($owner) { + $profile = $owner->profile(true, Profile::FETCH_ALL, $view); + if ($profile) { + $pid = $profile->id(); + } + } + } else { + // Fetches profile's and profile's owner information and redirects to + // marketing if the owner has not subscribed and the requirer has logged in. + $profile = Profile::get($pid, Profile::FETCH_ALL, $view); + $owner = $profile->owner(); + } + if (is_null($pid)) { + if (S::logged()) { + $page->kill($id . " inconnu dans l'annuaire."); + } + return PL_NOT_FOUND; + } + // Now that we know this is an existing profile, we can switch to the + // appropriate template. + $page->changeTpl('profile/profile.tpl', SIMPLE); // Profile view are logged. if (S::logged()) {