Skip to content

Instantly share code, notes, and snippets.

@Swader
Created September 13, 2012 00:47
Show Gist options
  • Save Swader/3711059 to your computer and use it in GitHub Desktop.
Save Swader/3711059 to your computer and use it in GitHub Desktop.
Contacts List Function
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