/** * 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; } }
/** * Lists all users matching a criteria */ public function indexAction() { $cg = new CommercialGroupModel(); $params = array(); try { if ($this->_hasParam('customer')) { $params = array('customerId' => $this->_getParam('customer')); } // 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('customer')) { 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(); $filterList = $this->_cgSrv->buildFilterList($filterParams); $this->_helper->filterNotAllowedFilters('filter_by', $filterList); $params['filterList'] = $filterList; $cgList = $this->_cgSrv->listAll($params); if ($cgList) { $count = $cgList->getCount(); $list = array(); foreach ($cgList->getItems() as $item) { try { $this->_helper->allowed('read', $item); $list[] = $item; } catch (Exception $e) { $count--; } } $this->view->count = $count; $this->view->data = $list; } }