From: Florent Bruneau Date: Thu, 30 Sep 2010 12:15:09 +0000 (+0200) Subject: AX enabled version of the first page of the profile edition. X-Git-Tag: xorg/1.0.1~133 X-Git-Url: http://git.polytechnique.org/?a=commitdiff_plain;h=42ec0fe2dd9e21554460f71ec886eda546ef9cbe;p=platal.git AX enabled version of the first page of the profile edition. If the profile editor does not have directory_private privileges, hide private informations. Note: use to hide some informations without breaking the code of the backend. I know this does not hide anything to somebody who knows html, but remember: this is for the secretaries of the AX... We can certainly do better in the future, but this requires some hacking in the php code for phones, networking, addresses, jobs and I'm too lazy for it. Signed-off-by: Florent Bruneau --- diff --git a/classes/phone.php b/classes/phone.php index 46c1a9a..32eb168 100644 --- a/classes/phone.php +++ b/classes/phone.php @@ -340,7 +340,7 @@ class Phone $phones = array(); foreach ($data as $item) { $phone = new Phone($item); - $success = (($phone->isEmpty() || $phone->format()) && $success); + $success = (!$phone->error && ($phone->format() || $phone->isEmpty()) && $success); if (!$phone->isEmpty()) { $phones[] = call_user_func(array($phone, $function)); } diff --git a/modules/profile/general.inc.php b/modules/profile/general.inc.php index 7e2bfff..66d94b3 100644 --- a/modules/profile/general.inc.php +++ b/modules/profile/general.inc.php @@ -523,17 +523,9 @@ class ProfilePageGeneral extends ProfilePage $this->settings['search_names'] = new ProfileSettingSearchNames(); $this->settings['birthdate'] = new ProfileSettingDate(); - if (!S::user()->isMe($this->owner)) { - $this->settings['deathdate'] = new ProfileSettingDate(); - } - $this->settings['freetext_pub'] - = $this->settings['photo_pub'] - = new ProfileSettingPub(); - $this->settings['freetext'] - = $this->settings['nationality1'] + $this->settings['nationality1'] = $this->settings['nationality2'] = $this->settings['nationality3'] - = $this->settings['yourself'] = $this->settings['promo_display'] = null; $this->settings['email_directory'] @@ -544,10 +536,26 @@ class ProfilePageGeneral extends ProfilePage $this->settings['tels'] = new ProfileSettingPhones(); $this->settings['edus'] = new ProfileSettingEdu(); $this->settings['promo'] = new ProfileSettingPromo(); - $this->watched= array('freetext' => true, 'tels' => true, + $this->watched= array('tels' => true, 'networking' => true, 'edus' => true, 'nationality1' => true, 'nationality2' => true, 'nationality3' => true, 'search_names' => true); + + /* Some fields editable under condition */ + if (!S::user()->isMe($this->owner)) { + $this->settings['deathdate'] = new ProfileSettingDate(true); + } + if (S::user()->checkPerms('directory_private') + || S::user()->isMyProfile($this->owner)) { + $this->settings['yourself'] + = $this->settings['freetext'] + = null; + $this->settings['freetext_pub'] + = $this->settings['photo_pub'] + = new ProfileSettingPub(); + $this->watched['freetext'] = true; + } + } protected function _fetchData() diff --git a/modules/profile/page.inc.php b/modules/profile/page.inc.php index 1d9b728..d8c89de 100644 --- a/modules/profile/page.inc.php +++ b/modules/profile/page.inc.php @@ -123,7 +123,7 @@ class ProfileSettingPhones implements ProfileSetting if (!$success) { Platal::page()->trigError('Numéro de téléphone invalide'); } - return $phone; + return $phones; } } @@ -174,12 +174,23 @@ class ProfileSettingBool extends ProfileNoSave class ProfileSettingDate extends ProfileNoSave { + private $allowEmpty; + + public function __construct($allowEmpty = false) + { + $this->allowEmpty = $allowEmpty; + } + public function value(ProfilePage &$page, $field, $value, &$success) { $success = true; if (is_null($value)) { $value = preg_replace('/(\d{4})-(\d{2})-(\d{2})/', '\3/\2/\1', @$page->values[$field]); } else { + $value = trim($value); + if (empty($value) && $this->allowEmpty) { + return null; + } $success = preg_match('@(\d{2})/(\d{2})/(\d{4})@', $value, $matches); if (!$success) { Platal::page()->trigError("Les dates doivent être au format jj/mm/aaaa"); @@ -378,14 +389,20 @@ abstract class ProfilePage implements PlWizardPage } return Post::has('next_page') ? PlWizard::NEXT_PAGE : PlWizard::CURRENT_PAGE; } - Platal::page()->trigError("Certains champs n'ont pas pu être validés, merci de corriger les informations " - . "de ton profil et de revalider ta demande."); + $text = "Certains champs n'ont pas pu être validés, merci de corriger les informations " + . (S::user()->isMe($this->owner) ? "de ton profil et de revalider ta demande." + : "du profil et de revalider ta demande."); + Platal::page()->trigError($text); return PlWizard::CURRENT_PAGE; } public function success() { - return 'Ton profil a bien été mis à jour.'; + if (S::user()->isMe($this->owner)) { + return 'Ton profil a bien été mis à jour.'; + } else { + return 'Le profil a bien été mis à jour.'; + } } } diff --git a/templates/include/flags.radio.tpl b/templates/include/flags.radio.tpl index 2c2019a..4ea1998 100644 --- a/templates/include/flags.radio.tpl +++ b/templates/include/flags.radio.tpl @@ -31,7 +31,7 @@ {if t($disabled)}disabled="disabled"{/if} /> {icon name="flag_orange" title="transmis à l'AX"} {if t($withtext)}transmis à l'AX{/if} - diff --git a/templates/profile/base.tpl b/templates/profile/base.tpl index 286e8b2..53ba85e 100644 --- a/templates/profile/base.tpl +++ b/templates/profile/base.tpl @@ -20,16 +20,22 @@ {* *} {**************************************************************************} +{assign var=isMe value=$smarty.session.user->isMyProfile($profile)} +{if hasPerm('directory_private')} +{assign var=viewPrivate value=true} +{/if} +
{xsrf_token_field}
- {icon name=information title="Voir ma fiche"} Tu peux consulter ta fiche telle que la + {icon name=information title="Voir ma fiche"} Tu peux consulter + {if $smarty.session.user->isMyProfile($profile)}ta{else}cette{/if} fiche telle que la voient n'importe quel internaute, - l'AX ou - les X. + l'AX{if hasPerm('directory_private')}ou + les X{/if}.
- {include file="include/flags.radio.tpl" disabled=true withtext=true name="profile_ex_pub"} + {include file="include/flags.radio.tpl" disabled=true withtext=true val="novalue" name="profile_ex_pub"}
{include file=$profile_page} diff --git a/templates/profile/general.networking.tpl b/templates/profile/general.networking.tpl index 6e5ed93..7636aee 100644 --- a/templates/profile/general.networking.tpl +++ b/templates/profile/general.networking.tpl @@ -20,12 +20,19 @@ {* *} {**************************************************************************} +{if !hasPerm('directory_private') && ($nw.pub eq 'private') && !empty($nw.address|smarty:nodefaults)} +{assign var=hiddennw value=true} +{else} +{assign var=hiddennw value=false} +{/if} +
  @@ -35,9 +42,14 @@ {$nw.name}
+ {if $hiddennw} + + (masqué) + {else} + {/if} {icon name=cross title="Supprimer cet élément"} diff --git a/templates/profile/general.tpl b/templates/profile/general.tpl index fbe27db..f38066b 100644 --- a/templates/profile/general.tpl +++ b/templates/profile/general.tpl @@ -31,12 +31,13 @@ {$public_name} - + {icon name="page_edit" title="Plus de détail"} + {if $viewPrivate} {icon name="flag_red" title="site privé"} Affichage privé @@ -44,7 +45,10 @@ {$private_name} + + {/if} + {if $isMe} Comment t'appeller
@@ -55,10 +59,12 @@ + {/if} - Gestion de tes noms, prénoms, surnoms... - Ils déterminent la façon dont ton nom apparaît sur les annuaires + Gestion des noms, prénoms, surnoms... + Ils déterminent la façon dont + {if $isMe}ton{else}son{/if} nom apparaît sur les annuaires en ligne et papier et ta fiche apparaitra quand on cherche un de ces noms. Pour plus d'explications sur l'icône suivante {icon name="information" title="Plus d'infos"}.
@@ -112,8 +118,13 @@ - Afin de pouvoir être considéré{if $profile->isFemale()}e{/if} à la fois dans ta promotion d'origine et ta + {if $isMe} + Afin de pouvoir être considéré{""|sex:"e":$profile} à la fois dans ta promotion d'origine et ta ou tes promotions d'adoption tu peux entrer ici ta promotion d'adoption. + {else} + Afin que ce{""|sex:"tte":$profile} camarade soit considé{""|sex:"e":$profile} à la fois dans sa + promotion d'origine et sa promotion d'adoption, tu peux enterr ici sa promotion d'adoption. + {/if}
Attention : cette modification ne sera prise en compte qu'après validation par les administrateurs du site. @@ -131,7 +142,7 @@ - {if !$smarty.session.user->isMe($owner)} + {if !$isMe} Date de décès @@ -197,12 +208,13 @@ - Si ta formation ne figure pas dans la liste, + Si la formation que tu cherches ne figure pas dans la liste, contacte-nous. +{if $viewPrivate || $isMe} @@ -216,7 +228,7 @@ {if $nouvellephoto} @@ -242,6 +254,7 @@
-
Ta photo actuelle
+
Photo actuelle
 [ PHOTO ]
+{/if} @@ -300,6 +313,7 @@ + {if $viewPrivate || $isMe} + {/if}
@@ -325,6 +339,7 @@ id="freetext" rows="8" cols="50" >{$freetext}
{* vim:set et sw=2 sts=2 sws=2 enc=utf-8: *} diff --git a/templates/profile/phone.tpl b/templates/profile/phone.tpl index db5d919..c378102 100644 --- a/templates/profile/phone.tpl +++ b/templates/profile/phone.tpl @@ -22,23 +22,35 @@ {assign var=telpref value="`$prefname`[`$telid`]"} {assign var=id value="`$prefid`_`$telid`"} +{if !hasPerm('directory_private') && ($tel.pub eq 'private') && !empty($tel.display)} +{assign var=hiddentel value=true} +{else} +{assign var=hiddentel value=false} +{/if}
N°{$telid+1}
+ {if $hiddentel} + Numéro {if $tel.type eq 'fixed'}fixe{elseif $tel.type eq 'mobile'}de mobile{else}de fax{/if} (masqué) + + + {else} - - {icon name=cross title="Supprimer ce numéro de téléphone"} - {icon name=comments title="Ajouter un commentaire"} + {/if} + + {icon name=cross title="Supprimer ce numéro de téléphone"} +
- {include file="include/flags.radio.tpl" name="`$telpref`[pub]" val=$tel.pub} + {include file="include/flags.radio.tpl" name="`$telpref`[pub]" + val=$tel.pub disabled=$hiddentel}
Commentaire :