function process() { $this->tpl->assign("action", $this->request->getActionName()); switch ($this->request->getActionName()) { case 'add': $form = new FormUser($this->tpl); $done = $form->process(); if ($done) { $this->setMessage(); } break; case 'mod': case 'modCur': if ($this->request->getActionName() === 'modCur') { $o_user =& User::getInstance(); $userLogin = $o_user->getLogin(); } else { $userLogin = $this->needAUserSelected(); } if ($userLogin) { $this->tpl->assign('user_selected', $userLogin); $form = new FormUser($this->tpl, $userLogin); $done = $form->process(); if ($done) { $this->setMessage(); } } // else needASiteAdminSelected display the site selection form break; case 'del': $login = $this->needAUserSelected(); if ($login && $login != 'anonymous') { $confirmed = $this->needConfirmation('user', $login); if ($confirmed) { $confUser = new UserConfigDb(); $confUser->delUser($login); $this->setMessage(); } } break; } // case no site installed, do not generate if (is_a($this->site, "Site")) { $this->site->generateFiles(); } }
public function userAddAction() { $form = new FormUser(null, 'add'); $table = new Wbusers(); if ($this->_request->isPost() && $this->_request->getParam('action_id') == 'add') { // validate form if ($form->isValid($this->_getAllParams())) { // insert data to table $data = array('login' => $this->_request->getParam('login'), 'name' => $this->_request->getParam('name'), 'pwd' => trim($this->_request->getParam('pwd')), 'email' => $this->_request->getParam('email'), 'active' => intval($this->_request->getParam('active')), 'role_id' => $this->_request->getParam('role_id')); try { $user_id = $table->insert($data); } catch (Zend_Exception $e) { $this->view->exception = $this->view->translate->_('Exception') . ' : ' . $e->getMessage(); } // clear all cache $this->cache_helper->clearAllCache(); // render $this->_forward('user-index', 'admin'); // action, controller return; } } $form->populate(array('action_id' => 'add')); $form->submit->setLabel($this->view->translate->_('Add')); $form->setAction($this->view->baseUrl . '/admin/user-add'); $this->view->form = $form; $this->view->title = 'Webacula :: ' . $this->view->translate->_('User add'); $this->renderScript('admin/form-user.phtml'); }
<!DOCTYPE html> <?php include_once 'user.php'; include_once 'bd2.php'; include_once 'FormUser.php'; include_once 'Affichage.php'; $mabd = new bd(); $monform = new FormUser(); if (isset($_POST['ajout'])) { if ($_POST['id'] == '' || !$mabd->Ajout(new user($_POST['id'], $_POST['nom'], $_POST['prenom'], $_POST['date']))) { exit('Ajout impossible'); } } if (isset($_GET['aeffacer'])) { if (!$mabd->Efface($_GET['aeffacer'])) { exit('Suppression impossible'); } } if (isset($_POST['modif'])) { $u = new user($_POST['id'], $_POST['nom'], $_POST['prenom'], $_POST['date']); if (!$mabd->Update($u)) { exit('Modification impossible'); } } ?> <html> <head> <meta http-equiv="Content-Type" content="text/html; charset=UTF-8"> <link href="default.css" rel="stylesheet" type="text/css" media="screen" /> <title>Liste des user avec Class</title> </head>