X-Git-Url: http://git.polytechnique.org/?a=blobdiff_plain;f=modules%2Fprofile.php;h=6e606afa7f0a6f660ac113dcfb08dc01ffff7fd9;hb=6cce7840e69bc0b6647e1bc5ea3437a925cd63a0;hp=4c9f9980f156da8de188a74a6585fb9ee5da2f88;hpb=e5ceaa8c8943660e5995c68c22e6646e85613006;p=platal.git diff --git a/modules/profile.php b/modules/profile.php index 4c9f998..6e606af 100644 --- a/modules/profile.php +++ b/modules/profile.php @@ -224,13 +224,14 @@ class ProfileModule extends PLModule } // Determines the access level at which the profile will be displayed. - if (!S::logged() || !S::user()->checkPerms('directory_ax') || Env::v('view') == 'public') { - $view = 'public'; - } else if (!S::user()->checkPerms('directory_private') || Env::v('view') == 'ax') { - $view = 'ax'; + if (Env::v('view') == 'public') { + $view = Visibility::VIEW_PUBLIC; + } else if (Env::v('view') == 'ax') { + $view = Visibility::VIEW_AX; } else { - $view = 'private'; + $view = Visibility::VIEW_PRIVATE; } + $visibility = Visibility::defaultForRead($view); // Display pending picture if (S::logged() && Env::v('modif') == 'new') { @@ -241,7 +242,7 @@ class ProfileModule extends PLModule if (is_null($pid)) { $owner = User::getSilent($id); if ($owner) { - $profile = $owner->profile(true, Profile::FETCH_ALL, $view); + $profile = $owner->profile(true, Profile::FETCH_ALL, $visibility); if ($profile) { $pid = $profile->id(); } @@ -249,7 +250,7 @@ class ProfileModule extends PLModule } 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); + $profile = Profile::get($pid, Profile::FETCH_ALL, $visibility); $owner = $profile->owner(); } if (is_null($pid)) { @@ -258,6 +259,7 @@ class ProfileModule extends PLModule } 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); @@ -271,13 +273,13 @@ class ProfileModule extends PLModule $page->setTitle($profile->fullName()); // Determines and displays the virtual alias. - if (!is_null($owner) && $profile->alias_pub == 'public') { + if (!is_null($owner) && $profile->isVisible($profile->alias_pub)) { $page->assign('virtualalias', $owner->emailAlias()); } $page->assign_by_ref('profile', $profile); $page->assign_by_ref('owner', $owner); - $page->assign('view', $view); + $page->assign('view', $visibility); $page->assign('logged', S::logged()); header('Last-Modified: ' . date('r', strtotime($profile->last_change)));