X-Git-Url: http://git.polytechnique.org/?a=blobdiff_plain;f=modules%2Fprofile%2Fpage.inc.php;h=d8c89de931cd3b18dbe71d0a9d347a4c5149da72;hb=42ec0fe2dd9e21554460f71ec886eda546ef9cbe;hp=1d9b72827dc08f9ec64b05f21c712c58581eb9bc;hpb=2192fcfccaf971ab6c6d2f78420c16587cc5cd43;p=platal.git 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.'; + } } }