/** * Display a list of all users in the system. * */ public function allAction() { $this->view->acl = array('add' => $this->_helper->hasAccess('add'), 'edit' => $this->_helper->hasAccess('edit'), 'delete' => $this->_helper->hasAccess('delete')); $filterUsername = $this->_getParam('username'); $filterFirstName = $this->_getParam('firstName'); $filterLastName = $this->_getParam('lastName'); $filterRole = $this->_getParam('role', 'any'); $filterSort = $this->_getParam('sort', 'username'); $filterDirection = $this->_getParam('direction', 'asc'); $form = new Ot_Form_UserSearch(); $form->populate($this->getAllParams()); $account = new Ot_Model_DbTable_Account(); $accountTbl = $account->info('name'); $select = new Zend_Db_Table_Select($account); $select->from($accountTbl); if ($filterUsername != '') { $select->where($accountTbl . '.username LIKE ?', '%' . $filterUsername . '%'); } if ($filterFirstName != '') { $select->where($accountTbl . '.firstName LIKE ?', '%' . $filterFirstName . '%'); } if ($filterLastName != '') { $select->where($accountTbl . '.lastName LIKE ?', '%' . $filterLastName . '%'); } if ($filterRole != '' && $filterRole != 'any') { $otRole = new Ot_Model_DbTable_AccountRoles(); $roleTbl = $otRole->info('name'); $select->join($roleTbl, $accountTbl . '.accountId = ' . $roleTbl . '.accountId', array()); $select->where($roleTbl . '.roleId = ?', $filterRole); $select->distinct(); } if ($filterSort == 'name') { $select->order('firstName ' . $filterDirection); $select->order('lastName ' . $filterDirection); } else { $select->order($filterSort . ' ' . $filterDirection); } $filterOptions = array('username' => $filterUsername, 'lastname' => $filterLastName, 'firstname' => $filterFirstName, 'direction' => $filterDirection, 'role' => $filterRole, 'sort' => $filterSort); foreach ($filterOptions as $key => $value) { if (!$value) { unset($filterOptions[$key]); } } $adapter = new Zend_Paginator_Adapter_DbSelect($select); $paginator = new Zend_Paginator($adapter); $paginator->setCurrentPageNumber($this->_getParam('page', 1)); $aa = new Ot_Model_DbTable_AuthAdapter(); $adapters = $aa->fetchAll(); $adapterMap = array(); foreach ($adapters as $a) { $adapterMap[$a->adapterKey] = $a; } $this->_helper->pageTitle('ot-account-all:title'); $this->view->assign(array('paginator' => $paginator, 'form' => $form, 'interface' => true, 'sort' => $filterSort, 'direction' => $filterDirection, 'adapters' => $adapterMap, 'filterOptions' => array('urlParams' => $filterOptions))); }
public function addRule(Zend_Db_Table_Select &$select) { $select->join(array("acc" => "account"), "acc.id = account_id"); }
public function addRule(Zend_Db_Table_Select &$select) { $select->join(array("tr" => "trader"), "tr.id = trader_id"); }