Created
September 13, 2012 00:47
-
-
Save Swader/3711059 to your computer and use it in GitHub Desktop.
Contacts List Function
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public function listAction() | |
{ | |
$oPagination = null; | |
$oSearchForm = new \Manager\Form\ContactSearch(); | |
$oSearchForm->setAttribute('action', '/manager/contacts/list'); | |
$oSearchForm->setData($_GET); | |
$bSearchMode = false; | |
// Display the search toolbar | |
$aOptions = $this->getListOptions(); | |
$aParams = $this->getParams(array( | |
'q', 'search', 'validity', 'deleted', 'activated' | |
)); | |
$aResult = array(); | |
if ($this->getRequest()->isGet() && $this->getParam('search') == 'yes') { | |
// Search mode | |
$bSearchMode = true; | |
$aResult = $this->oUserService->fetchContacts($aParams, $aOptions); | |
// If something was found, convert rows into user objects and pass to view | |
if (!empty($aResult['rowSet'])) { | |
foreach ($aResult['rowSet'] as &$aRow) { | |
$iId = $aRow['id']; | |
$aRow = new Contact($this->oRegistry->get('ContactMapper')); | |
$aRow->setId($iId); | |
unset($iId); | |
} | |
$oPagination = new \INTECH\Common\IntechPaginationControl(array( | |
'limit' => $aOptions['limit'], | |
'rowCount' => $aResult['rowCount'], | |
'currentPage' => $aOptions['page'], | |
'urlPrefix' => '/manager/contacts/list', | |
'urlParams' => array_merge($aParams, $aOptions) | |
)); | |
} | |
} | |
return array( | |
'result' => $aResult, | |
'params' => $aParams, | |
'search' => $bSearchMode, | |
'pagination' => $oPagination, | |
'searchForm' => $oSearchForm | |
); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment