X-Git-Url: http://git.polytechnique.org/?a=blobdiff_plain;f=classes%2Fplpage.php;h=258a8c3c474ef2deedc0be1436a765af3347c527;hb=f23d33e1b114e9032b4b966baebdeb14b4215313;hp=6fa26ea7b97967231c11161b5fdc8a9a17bcc7fa;hpb=d58e3be00aaeb9f7210e0ff699daaaf8c20b557a;p=platal.git diff --git a/classes/plpage.php b/classes/plpage.php index 6fa26ea..258a8c3 100644 --- a/classes/plpage.php +++ b/classes/plpage.php @@ -246,6 +246,34 @@ abstract class PlPage extends Smarty } // }}} + // {{{ function trigRedirect + + // Acts as trig(), but replaces the template with a simple one displaying + // the error messages and a "continue" link. + private function trigRedirect($msg, $continue, $type = 'errors') + { + $this->trig($msg, $type); + $this->coreTpl('msgredirect.tpl'); + $this->assign('continue', $continue); + $this->run(); + } + + public function trigErrorRedirect($msg, $continue) + { + $this->trigRedirect($msg, $continue, 'errors'); + } + + public function trigWarningRedirect($msg, $continue) + { + $this->trigRedirect($msg, $continue, 'warnings'); + } + + public function trigSuccessRedirect($msg, $continue) + { + $this->trigRedirect($msg, $continue, 'success'); + } + + // }}} // {{{ function kill() public function kill($msg, $type = 'errors') @@ -342,6 +370,10 @@ abstract class PlPage extends Smarty protected function jsonDisplay() { pl_content_headers("text/javascript"); + if (!empty($GLOBALS['pl_errors'])) { + $this->jsonAssign('pl_errors', join("\n", $GLOBALS['pl_errors'])); + $GLOBALS['pl_errors'] = array(); + } array_walk_recursive($this->_jsonVars, "escape_xorgDB"); $jsonbegin = Env::v('jsonBegin'); $jsonend = Env::v('jsonEnd'); @@ -462,13 +494,11 @@ function core_include($source, &$smarty) function if_rewrites($source, &$smarty) { - $perms = 'isset($smarty.session.perms|smarty:nodefaults) && $smarty.session.perms|smarty:nodefaults && $smarty.session.perms'; - return preg_replace(array('/\{if([^}]*) (\!?)hasPerms\(([^)]+)\)([^}]*)\}/', - '/\{if([^}]*) (\!?)hasPerm\(([^)]+)\)([^}]*)\}/', - '/\{if([^}]*) (\!?)t\(([^)]+)\)([^}]*)\}/'), - array('{if\1 \2(' . $perms . '->hasFlagCombination(\3))\4}', - '{if\1 \2(' . $perms . '->hasFlag(\3))\4}', - '{if\1 \2(isset(\3|smarty:nodefaults) && (\3|smarty:nodefaults))\4}'), + $perms = 'isset($smarty.session.user|smarty:nodefaults) && $smarty.session.user'; + return preg_replace(array('/\{(else)?if([^}]*) (\!?)hasPerms?\(([^)]+)\)([^}]*)\}/', + '/\{(else)?if([^}]*) (\!?)t\(([^)]+)\)([^}]*)\}/'), + array('{\1if\2 \3(' . $perms . '->checkPerms(\4))\5}', + '{\1if\2 \3(isset(\4|smarty:nodefaults) && (\4|smarty:nodefaults))\5}'), $source); }