public function indexAction() { $userGateway = new Users_Model_UserGateway(); $this->view->userList = Zend_Paginator::factory($userGateway->fetchUsers()); $request = Zend_Controller_Front::getInstance()->getRequest(); $this->view->module = $request->getModuleName(); $this->view->controller = $request->getControllerName(); $this->view->userList->setCurrentPageNumber($this->_getParam('page')); }
public function processAction() { if (!$this->_request->isXmlHttpRequest() || !$this->_request->isPost()) { $this->_redirector->gotoRoute(array('controller' => 'index', 'module' => 'users'), 'admin'); } $return = array(); $userGateway = new Users_Model_UserGateway(); $form = $userGateway->getForm('CreateUser'); $validForm = $form->isValid($this->_request->getParams()); // Check the form for validity if (!$validForm) { $return['formErrors'] = $form->getMessages(); } else { $form->removeElement('password_confirm'); $form->removeElement('submit'); $user = $userGateway->create($form->getValues()); $user->save(); $flashMessenger = $this->_helper->getHelper('FlashMessenger'); $flashMessenger->setNamespace('notifications')->addMessage('User Created.'); $return['redirect']['location'] = '/admin/users/'; } $this->_helper->json->sendJson($return); }
public function indexAction() { // Get an Auth instance and check to see if the // user is already authenticated $auth = Zend_Auth::getInstance(); if ($auth->hasIdentity()) { $this->_redirect('/admin/dashboard/'); // Navigate away } $userGateway = new Users_Model_UserGateway(); $form = $userGateway->getForm(); // Check for a post action if ($this->_request->isPost()) { $validForm = $form->isValid($this->_request->getParams()); if ($this->_request->isXmlHttpRequest()) { // Check the form for validity if (!$validForm) { $return['formErrors'] = $form->getMessages(); $return['formResult'] = FALSE; } else { $user = $userGateway->create($form->getValues()); if ($userGateway->authenticate($user)->isValid()) { $originalRequest = new Zend_Session_Namespace('originalRequest'); $return['redirect']['location'] = '/admin/dashboard/'; $flashMessenger = $this->_helper->getHelper('FlashMessenger'); $flashMessenger->setNamespace('informational')->addMessage('Welcome to Fear Free Retirement!'); } else { $return['append']['target'] = '#usersSignInForm'; $return['append']['content'] = '' . '<div class="response-msg error errors">' . 'Incorrect email/password combination.<br />' . 'Passwords are case sensitive.</div>'; } } $this->_helper->json->sendJson($return); } } // Set the form in the view $this->view->signInForm = $form; }