public function manageAction() { $userForm = new Application_Form_User(); $userForm->getElement('password')->setRequired(false); if ($this->getRequest()->isPost()) { //if we are updating $userId = $this->getRequest()->getParam('id'); if ($userId) { $userForm->setId($userId); } if ($userForm->isValid($this->getRequest()->getParams())) { $data = $userForm->getValues(); $user = new Application_Model_Models_User($data); Application_Model_Mappers_UserMapper::getInstance()->save($user); $this->_helper->response->success($this->_helper->language->translate('Saved')); exit; } else { $this->_helper->response->fail(Tools_Content_Tools::proccessFormMessages($userForm->getMessages())); exit; } } $pnum = (int) filter_var($this->getParam('pnum'), FILTER_SANITIZE_NUMBER_INT); $offset = 0; if ($pnum) { $offset = 10 * ($pnum - 1); } $select = $this->_zendDbTable->getAdapter()->select()->from('user'); $by = filter_var($this->getParam('by', 'last_login'), FILTER_SANITIZE_STRING); $order = filter_var($this->getParam('order', 'desc'), FILTER_SANITIZE_STRING); $searchKey = filter_var($this->getParam('key'), FILTER_SANITIZE_STRING); if (!in_array($order, array('asc', 'desc'))) { $order = 'desc'; } $select = $select->order($by . ' ' . $order); $paginatorOrderLink = '/by/' . $by . '/order/' . $order; if (!empty($searchKey)) { $select->where('email LIKE ?', '%' . $searchKey . '%')->orWhere('full_name LIKE ?', '%' . $searchKey . '%')->orWhere('role_id LIKE ?', '%' . $searchKey . '%')->orWhere('last_login LIKE ?', '%' . date("Y-m-d", strtotime($searchKey)) . '%')->orWhere('ipaddress LIKE ?', '%' . $searchKey . '%'); $paginatorOrderLink .= '/key/' . $searchKey; } $adapter = new Zend_Paginator_Adapter_DbSelect($select); $users = $adapter->getItems($offset, 10); $userPaginator = new Zend_Paginator($adapter); $userPaginator->setCurrentPageNumber($pnum); $userPaginator->setItemCountPerPage(10); $pager = $this->view->paginationControl($userPaginator, 'Sliding', 'backend/user/pager.phtml', array('urlData' => $this->_websiteUrl . 'backend/backend_user/manage', 'order' => $paginatorOrderLink)); if ($order === 'desc') { $order = 'asc'; } else { $order = 'desc'; } if (!empty($searchKey)) { $this->view->orderParam = $order . '/key/' . $searchKey; } else { $this->view->orderParam = $order; } $this->view->by = $by; $this->view->order = $order; $this->view->key = $searchKey; $this->view->pager = $pager; $this->view->users = $users; $this->view->helpSection = 'users'; $this->view->userForm = $userForm; }