From: x2003bruneau Date: Tue, 14 Aug 2007 22:58:48 +0000 (+0000) Subject: - Refresh user index at registration X-Git-Tag: xorg/0.9.15~212 X-Git-Url: http://git.polytechnique.org/?a=commitdiff_plain;h=2a54eb4d037d42b90c09fe7c40053d9ab98fbafa;p=platal.git - Refresh user index at registration - Add a new PlWizard structure designed to build multipage forms or multistep forms. I aim at using this for: * registration * profile edition * xnet events creation and subscription register.php | 3 +++ 1 file changed, 3 insertions(+) git-svn-id: svn+ssh://murphy/home/svn/platal/trunk@1912 839d8a87-29fc-0310-9880-83ba4fa771e5 --- diff --git a/classes/plwizard.php b/classes/plwizard.php new file mode 100644 index 0000000..26381e4 --- /dev/null +++ b/classes/plwizard.php @@ -0,0 +1,170 @@ +name = 'wiz_' . $name; + $this->layout = $layout; + $this->stateless = $stateless; + $this->pages = array(); + $this->lookup = array(); + if (!isset($_SESSION[$this->name])) { + $_SESSION[$this->name] = array(); + } + $_SESSION[$this->name . '_page'] = null; + } + + public function addPage($class, $id = null) + { + if ($id != null) { + $this->lookup[$id] = count($this->pages); + } + $this->pages[] = $class; + } + + public function set($varname, $value) + { + $_SESSION[$this->name][$varname] = $value; + } + + public function get($varname, $default = null) + { + return isset($_SESSION[$this->name][$varname]) ? + $_SESSION[$this->name][$varname] : $default; + } + + public function v($varname, $default = "") + { + return $this->get($varname, $default); + } + + public function i($varname, $default = 0) + { + return (int)$this->get($varname, $default); + } + + public function clear($varname = null) + { + if (is_null($varname)) { + $_SESSION[$this->name] = array(); + } else { + unset($_SESSION[$this->name][$varname]); + } + $_SESSION[$this->name . '_page'] = null; + } + + private function &getPage($id) + { + $page = $this->pages[$id]; + return new $page($this); + } + + public function apply(PlatalPage &$smarty, $baseurl) + { + $curpage =& $_SESSION[$this->name . '_page']; + + // Process the previous page + if (!is_null($curpage)) { + $page = $this->getPage($curpage); + $next = $page->process(); + switch ($next) { + case PlWizard::FIRST_PAGE: + $curpage = 0; + break; + case PlWizard::PREVIOUS_PAGE: + $curpage--; + break; + case PlWizard::NEXT_PAGE: + $curpage++; + break; + case PlWizard::LAST_PAGE: + $curpage = count($this->pages) - 1; + break; + case PlWizard::CURRENT_PAGE: break; // don't change the page + default: + $curpage = is_numeric($next) ? $next : $this->lookup[$curpage]; + break; + } + } else { + $curpage = 0; + } + + // Prepare the page + $page = $this->getPage($curpage); + $smarty->assign('wiz_page', $page->template()); + $page->prepare($smarty); + } +} + +// vim:set et sw=4 sts=4 sws=4 foldmethod=marker enc=utf-8: +?> diff --git a/modules/register.php b/modules/register.php index 7074f41..19b1b25 100644 --- a/modules/register.php +++ b/modules/register.php @@ -308,6 +308,9 @@ class RegisterModule extends PLModule $mymail->assign('prenom', $prenom); $mymail->send(); + require_once('user.func.inc.php'); + user_reindex($uid); + if (!start_connexion($uid, false)) { return PL_FORBIDDEN; }