X-Git-Url: http://git.polytechnique.org/?a=blobdiff_plain;f=modules%2Fprofile%2Fpage.inc.php;h=64d0bba76362121f6dbc27cdcb8e6b6ba0e891d2;hb=4279d3bc87776ede0e3f3a9789c3836b28f54db6;hp=d1a8d8589027737eb66d5f5fd8275eb5529c40a1;hpb=b71f7275d0abe31614da74e05524ac08033bbe18;p=platal.git diff --git a/modules/profile/page.inc.php b/modules/profile/page.inc.php index d1a8d85..64d0bba 100644 --- a/modules/profile/page.inc.php +++ b/modules/profile/page.inc.php @@ -1,6 +1,6 @@ trig('URL Incorrecte : une url doit commencer par http:// ou https:// ou ftp://' - . ' et ne pas contenir de caractères interdits'); + Platal::page()->trigError('URL Incorrecte : une url doit commencer par http:// ou https:// ou ftp://' + . ' et ne pas contenir de caractères interdits'); } return $value; } @@ -69,11 +68,9 @@ class ProfileEmail extends ProfileNoSave return isset($page->values[$field]) ? $page->values[$field] : S::v($field); } $value = trim($value); - require_once 'xorg.misc.inc.php'; $success = empty($value) || isvalid_email($value); if (!$success) { - global $page; - $page->trig('Adresse Email invalide'); + Platal::page()->trigError('Adresse Email invalide'); } return $value; } @@ -89,8 +86,7 @@ class ProfileTel extends ProfileNoSave } $success = !preg_match('/[<>{}@&#~\/:;?,!§*_`\[\]|%$^=]/', $value, $matches); if (!$success) { - global $page; - $page->trig('Le numéro de téléphone contient un caractère interdit : ' . pl_entities($matches[0][0])); + Platal::page()->trigError('Le numéro de téléphone contient un caractère interdit : ' . pl_entities($matches[0][0])); } return $value; } @@ -135,16 +131,14 @@ class ProfileDate extends ProfileNoSave } else { $success = preg_match('@(\d{2})/(\d{2})/(\d{4})@', $value, $matches); if (!$success) { - global $page; - $page->trig("Les dates doivent être au format jj/mm/aaaa"); + Platal::page()->trigError("Les dates doivent être au format jj/mm/aaaa"); } else { $day = (int)$matches[1]; $month = (int)$matches[2]; $year = (int)$matches[3]; $success = ($day > 0 && $day <= 31) && ($month > 0 && $month <= 12) && ($year > 1900 && $year <= 2020); if (!$success) { - global $page; - $page->trig("La date n'a pas une valeur valide"); + Platal::page()->trigError("La date n'a pas une valeur valide"); } } } @@ -186,6 +180,9 @@ abstract class ProfileGeoloc implements ProfileSetting $address = array_merge($address, cut_address(@$address['text'])); $address['checked'] = true; } + } elseif (@$address['changed'] && !@$address['text']) { + $address = empty_address(); + $address['pub'] = 'private'; } $address['precise_lat'] = rtrim($address['precise_lat'], '.0'); $address['precise_lon'] = rtrim($address['precise_lon'], '.0'); @@ -259,8 +256,7 @@ abstract class ProfilePage implements PlWizardPage register_watch_op(S::i('uid'), WATCH_FICHE); } global $platal; - $log =& $_SESSION['log']; - $log->log('profil', $platal->pl_self(1)); + S::logger()->log('profil', $platal->pl_self(1)); } protected function checkChanges() @@ -290,11 +286,11 @@ abstract class ProfilePage implements PlWizardPage return 'profile/base.tpl'; } - protected function _prepare(PlatalPage &$page, $id) + protected function _prepare(PlPage &$page, $id) { } - public function prepare(PlatalPage &$page, $id) + public function prepare(PlPage &$page, $id) { if (count($this->values) == 0) { $this->fetchData(); @@ -307,7 +303,7 @@ abstract class ProfilePage implements PlWizardPage $page->assign('errors', $this->errors); } - public function process() + public function process(&$global_success) { $global_success = true; $this->fetchData(); @@ -329,11 +325,15 @@ abstract class ProfilePage implements PlWizardPage } return Post::has('next_page') ? PlWizard::NEXT_PAGE : PlWizard::CURRENT_PAGE; } - global $page; - $page->trig("Certains champs n'ont pas pu être validés, merci de corriger les informations " - . "de ton profil et de revalider ta demande"); + 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."); return PlWizard::CURRENT_PAGE; } + + public function success() + { + return 'Ton profil a bien été mis à jour.'; + } } require_once dirname(__FILE__) . '/general.inc.php';