From b539d596a51ba7b0d18cbf6eb0440f15061004ff Mon Sep 17 00:00:00 2001 From: Florent Bruneau Date: Fri, 17 Sep 2010 16:39:28 +0200 Subject: [PATCH] Hide 'always-private' fields when profile is edited by an AX secretary. Signed-off-by: Florent Bruneau --- modules/profile.php | 12 ++++++++---- modules/profile/jobs.inc.php | 30 ++++++++++++++++++------------ templates/profile/general.tpl | 2 +- templates/profile/jobs.tpl | 2 ++ 4 files changed, 29 insertions(+), 17 deletions(-) diff --git a/modules/profile.php b/modules/profile.php index d7cd55f..fb62e72 100644 --- a/modules/profile.php +++ b/modules/profile.php @@ -329,11 +329,15 @@ class ProfileModule extends PLModule $this->load('page.inc.php'); $wiz->addPage('ProfileSettingGeneral', 'Général', 'general'); $wiz->addPage('ProfileSettingAddresses', 'Adresses personnelles', 'adresses'); - $wiz->addPage('ProfileSettingGroups', 'Groupes X - Binets', 'poly'); - $wiz->addPage('ProfileSettingDecos', 'Décorations - Medailles', 'deco'); $wiz->addPage('ProfileSettingJobs', 'Informations professionnelles', 'emploi'); - $wiz->addPage('ProfileSettingSkills', 'Compétences diverses', 'skill'); - $wiz->addPage('ProfileSettingMentor', 'Mentoring', 'mentor'); + if (S::user()->checkPerms(User::PERM_DIRECTORY_PRIVATE)) { + $wiz->addPage('ProfileSettingGroups', 'Groupes X - Binets', 'poly'); + } + $wiz->addPage('ProfileSettingDecos', 'Décorations - Medailles', 'deco'); + if (S::user()->checkPerms(User::PERM_DIRECTORY_PRIVATE)) { + $wiz->addPage('ProfileSettingSkills', 'Compétences diverses', 'skill'); + $wiz->addPage('ProfileSettingMentor', 'Mentoring', 'mentor'); + } $wiz->apply($page, 'profile/edit/' . $profile->hrid(), $opened_tab, $mode); if (!$profile->birthdate) { diff --git a/modules/profile/jobs.inc.php b/modules/profile/jobs.inc.php index 54e00d1..79b8f41 100644 --- a/modules/profile/jobs.inc.php +++ b/modules/profile/jobs.inc.php @@ -346,7 +346,9 @@ class ProfileSettingJobs extends ProfilePage public function __construct(PlWizard &$wiz) { parent::__construct($wiz); - $this->settings['cv'] = null; + if (S::user()->checkPerms(User::PERM_DIRECTORY_PRIVATE)) { + $this->settings['cv'] = null; + } $this->settings['corps'] = new ProfileSettingCorps(); $this->settings['jobs'] = new ProfileSettingJob(); $this->watched = array('cv' => true, 'jobs' => true, 'corps' => true); @@ -354,12 +356,14 @@ class ProfileSettingJobs extends ProfilePage protected function _fetchData() { - // Checkout the CV - $res = XDB::query("SELECT cv - FROM profiles - WHERE pid = {?}", - $this->pid()); - $this->values['cv'] = $res->fetchOneCell(); + if (S::user()->checkPerms(User::PERM_DIRECTORY_PRIVATE)) { + // Checkout the CV + $res = XDB::query("SELECT cv + FROM profiles + WHERE pid = {?}", + $this->pid()); + $this->values['cv'] = $res->fetchOneCell(); + } // Build the jobs tree $res = XDB::iterRow("SELECT j.id, j.jobid, je.name, j.sectorid, j.subsectorid, j.subsubsectorid, @@ -531,11 +535,13 @@ class ProfileSettingJobs extends ProfilePage protected function _saveData() { - if ($this->changed['cv']) { - XDB::execute("UPDATE profiles - SET cv = {?} - WHERE pid = {?}", - $this->values['cv'], $this->pid()); + if (S::user()->checkPerms(User::PERM_DIRECTORY_PRIVATE)) { + if ($this->changed['cv']) { + XDB::execute("UPDATE profiles + SET cv = {?} + WHERE pid = {?}", + $this->values['cv'], $this->pid()); + } } } diff --git a/templates/profile/general.tpl b/templates/profile/general.tpl index cdac3c3..d7a41e4 100644 --- a/templates/profile/general.tpl +++ b/templates/profile/general.tpl @@ -71,7 +71,7 @@ class="names_advanced" style="display: none" error_name=$errors.search_names} {/foreach} - +