X-Git-Url: http://git.polytechnique.org/?a=blobdiff_plain;f=modules%2Fprofile.php;h=5988743027684c40db39517b42d857e1fc9a00f7;hb=285e2fe72d086ae94fc95696a0cefc8755113277;hp=954753ed407144db303ba428942d41f44affba9a;hpb=e22ff176d83e1f4ffd866e6ad928ee247906c6a5;p=platal.git diff --git a/modules/profile.php b/modules/profile.php index 954753e..5988743 100644 --- a/modules/profile.php +++ b/modules/profile.php @@ -25,15 +25,15 @@ class ProfileModule extends PLModule { return array( 'photo' => $this->make_hook('photo', AUTH_PUBLIC), - 'photo/change' => $this->make_hook('photo_change', AUTH_MDP), + 'photo/change' => $this->make_hook('photo_change', AUTH_PASSWD, 'user'), 'fiche.php' => $this->make_hook('fiche', AUTH_PUBLIC), 'profile' => $this->make_hook('profile', AUTH_PUBLIC), - 'profile/private' => $this->make_hook('profile', AUTH_COOKIE), + 'profile/private' => $this->make_hook('profile', AUTH_COOKIE, 'user'), 'profile/ax' => $this->make_hook('ax', AUTH_COOKIE, 'admin,edit_directory'), - 'profile/edit' => $this->make_hook('p_edit', AUTH_MDP), + 'profile/edit' => $this->make_hook('p_edit', AUTH_PASSWD, 'user'), 'profile/ajax/address' => $this->make_hook('ajax_address', AUTH_COOKIE, 'user', NO_AUTH), - 'profile/ajax/address/del' => $this->make_hook('ajax_address_del', AUTH_MDP), + 'profile/ajax/address/del' => $this->make_hook('ajax_address_del', AUTH_PASSWD, 'user'), 'profile/ajax/tel' => $this->make_hook('ajax_tel', AUTH_COOKIE, 'user', NO_AUTH), 'profile/ajax/edu' => $this->make_hook('ajax_edu', AUTH_COOKIE, 'user', NO_AUTH), 'profile/ajax/medal' => $this->make_hook('ajax_medal', AUTH_COOKIE, 'user', NO_AUTH), @@ -45,29 +45,29 @@ class ProfileModule extends PLModule 'profile/ajax/buildnames' => $this->make_hook('ajax_buildnames', AUTH_COOKIE, 'user', NO_AUTH), 'profile/ajax/tree/jobterms' => $this->make_hook('ajax_tree_job_terms', AUTH_COOKIE, 'user', NO_AUTH), 'profile/jobterms' => $this->make_hook('jobterms', AUTH_COOKIE, 'user', NO_AUTH), - 'javascript/education.js' => $this->make_hook('education_js', AUTH_COOKIE), - 'javascript/grades.js' => $this->make_hook('grades_js', AUTH_COOKIE), + 'javascript/education.js' => $this->make_hook('education_js', AUTH_COOKIE, 'user'), + 'javascript/grades.js' => $this->make_hook('grades_js', AUTH_COOKIE, 'user'), 'profile/medal' => $this->make_hook('medal', AUTH_PUBLIC), - 'referent' => $this->make_hook('referent', AUTH_COOKIE), + 'referent' => $this->make_hook('referent', AUTH_COOKIE, 'user'), 'referent/country' => $this->make_hook('ref_country', AUTH_COOKIE, 'user', NO_AUTH), 'referent/autocomplete' => $this->make_hook('ref_autocomplete', AUTH_COOKIE, 'user', NO_AUTH), - 'groupes-x' => $this->make_hook('xnet', AUTH_COOKIE), + 'groupes-x' => $this->make_hook('xnet', AUTH_COOKIE, 'groups'), 'groupes-x/logo' => $this->make_hook('xnetlogo', AUTH_PUBLIC), 'vcard' => $this->make_hook('vcard', AUTH_COOKIE, 'user', NO_HTTPS), - 'admin/binets' => $this->make_hook('admin_binets', AUTH_MDP, 'admin'), - 'admin/medals' => $this->make_hook('admin_medals', AUTH_MDP, 'admin'), - 'admin/education' => $this->make_hook('admin_education', AUTH_MDP, 'admin'), - 'admin/education_field' => $this->make_hook('admin_education_field', AUTH_MDP, 'admin'), - 'admin/education_degree' => $this->make_hook('admin_education_degree', AUTH_MDP, 'admin'), - 'admin/education_degree_set' => $this->make_hook('admin_education_degree_set', AUTH_MDP, 'admin'), - 'admin/sections' => $this->make_hook('admin_sections', AUTH_MDP, 'admin'), - 'admin/networking' => $this->make_hook('admin_networking', AUTH_MDP, 'admin'), - 'admin/trombino' => $this->make_hook('admin_trombino', AUTH_MDP, 'admin'), - 'admin/corps_enum' => $this->make_hook('admin_corps_enum', AUTH_MDP, 'admin'), - 'admin/corps_rank' => $this->make_hook('admin_corps_rank', AUTH_MDP, 'admin'), + 'admin/binets' => $this->make_hook('admin_binets', AUTH_PASSWD, 'admin'), + 'admin/medals' => $this->make_hook('admin_medals', AUTH_PASSWD, 'admin'), + 'admin/education' => $this->make_hook('admin_education', AUTH_PASSWD, 'admin'), + 'admin/education_field' => $this->make_hook('admin_education_field', AUTH_PASSWD, 'admin'), + 'admin/education_degree' => $this->make_hook('admin_education_degree', AUTH_PASSWD, 'admin'), + 'admin/education_degree_set' => $this->make_hook('admin_education_degree_set', AUTH_PASSWD, 'admin'), + 'admin/sections' => $this->make_hook('admin_sections', AUTH_PASSWD, 'admin'), + 'admin/networking' => $this->make_hook('admin_networking', AUTH_PASSWD, 'admin'), + 'admin/trombino' => $this->make_hook('admin_trombino', AUTH_PASSWD, 'admin'), + 'admin/corps_enum' => $this->make_hook('admin_corps_enum', AUTH_PASSWD, 'admin'), + 'admin/corps_rank' => $this->make_hook('admin_corps_rank', AUTH_PASSWD, 'admin'), ); } @@ -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))); @@ -299,7 +301,7 @@ class ProfileModule extends PLModule { global $globals; - if (in_array($hrpid, array('general', 'adresses', 'emploi', 'poly', 'deco', 'skill', 'mentor', 'deltaten'))) { + if (in_array($hrpid, array('general', 'adresses', 'emploi', 'poly', 'deco', 'mentor', 'deltaten'))) { $aux = $opened_tab; $opened_tab = $hrpid; $hrpid = $aux; @@ -331,7 +333,6 @@ class ProfileModule extends PLModule } $wiz->addPage('ProfilePageDecos', 'Décorations - Medailles', 'deco'); if (S::user()->checkPerms(User::PERM_DIRECTORY_PRIVATE)) { - $wiz->addPage('ProfilePageSkills', 'Compétences diverses', 'skill'); $wiz->addPage('ProfilePageMentor', 'Mentoring', 'mentor'); } if (S::user()->checkPerms(User::PERM_DIRECTORY_PRIVATE) && $profile->isDeltatenEnabled(Profile::DELTATEN_OLD)) {