X-Git-Url: http://git.polytechnique.org/?a=blobdiff_plain;f=modules%2Fprofile.php;h=e3239d28a59d05636759c9cc36e39317fa9c77f5;hb=9006db5d9e2b5d636b631fb51a834977a067d6bb;hp=f055c30eaaaa238dbd885a2b516832b0cb273b73;hpb=e12ab28529594b7814568ca282974b620cde3eb1;p=platal.git diff --git a/modules/profile.php b/modules/profile.php index f055c30..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,13 +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(); - if (S::logged() && !is_null($owner) && $owner->state == 'pending') { - pl_redirect('marketing/public/' . $profile->hrid()); + $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()) {