/** * Lists all users matching a criteria */ public function indexAction() { $cg = new CommercialGroupModel(); $params = array(); try { if ($this->_hasParam('customerId')) { $params = array('customerId' => $this->_getParam('customerId')); } // Normal case $this->_helper->allowed('list', $cg); } catch (ForbiddenException $e) { // HACK to allow commercial groups list for service providers $this->_helper->allowed('list_combo', $cg); if (!$this->_hasParam('customerId')) { throw new InvalidArgumentException("Missing customer parameter"); } } if (isset($params['customerId'])) { $customer = \Application\Service\OrgService::getInstance()->load($params['customerId']); if (!$customer) { throw new NotFoundException("Customer not found"); } $this->_helper->allowed('read', $customer); } $filterParams = $this->getRequest()->getQuery(); $filterParams = $this->_mapToFilter($filterParams); $this->_checkFilterParams($filterParams, CommercialGroupFilterFields::getWhiteList()); try { $filterList = $this->_cgSrv->buildFilterList($filterParams, true); } catch (ValidateException $e) { throw $this->_mapException($e, $this->_mapParamToFilter, true); } $this->_helper->filterNotAllowedFilters('filter_by', $filterList); $params['filterList'] = $filterList; $cgList = $this->_cgSrv->listAll($params); if ($cgList) { $items = $cgList->getItems(); foreach ($items as $item) { foreach (array('whiteList', 'blackList', 'roamingList') as $field) { if (isset($item->{$field})) { unset($item->{$field}); } } } $this->view->commercialGroup = $items; } }
public function buildFilterList(array $params, $throwEx = false) { $factory = new \App_ListFilter_FilterFactory(); $factory->setWhiteList(CommercialGroupFilterFields::getWhiteList()); $filterList = $factory->constructFilter($params); $filterList->setThrowExceptionOnValidationFail($throwEx); $filterList->setValidators(CommercialGroupFilterFields::getValidatorSpec()); if (!$filterList->isValid()) { $filterList = new \App_ListFilter(); } $filterList->setResourceId(CommercialGroupFilterFields::getResourceId()); $filterList->addExtraData('filterType', 'commercialGroup'); \App::log()->debug('Unused filters [' . implode(',', $factory->getUnusedList()) . ']'); return $filterList; }