/**
  * Lists all sims matching a criteria
  */
 public function indexAction()
 {
     $dumpSim = new SimModel();
     $this->_helper->allowed('list', $dumpSim);
     $filters = $this->_getFilterParams();
     if (isset($filters['subscriptionID'])) {
         $filters['id'] = $filters['subscriptionID'];
     }
     $this->_checkFilterParams($filters, SimFilterFields::getWhiteList());
     if (isset($filters[SimFilterFields::CURRENT_IP]) && App_Util_Ip::getIpVersion($filters[SimFilterFields::CURRENT_IP]) == App_Util_Ip::v6) {
         $filters[SimFilterFields::CURRENT_IP] = App_Util_Ip::ipv6Expand($filters[SimFilterFields::CURRENT_IP]);
     }
     if (isset($filters[SimFilterFields::STATIC_IP]) && App_Util_Ip::getIpVersion($filters[SimFilterFields::STATIC_IP]) == App_Util_Ip::v6) {
         $filters[SimFilterFields::STATIC_IP] = App_Util_Ip::ipv6Expand($filters[SimFilterFields::STATIC_IP]);
     }
     $filterList = $this->_simSrv->buildFilterList($filters);
     $filterHelper = $this->_helper->getHelper('filterNotAllowedFilters');
     $filterHelper->setThrowExOnNotAllowed(true);
     $filterHelper->direct('filter_by', $filterList);
     $params = $this->_getPaginatorParams();
     $simList = $this->_simSrv->listAll($filterList, $params, null, \App::getOrgUserLogged());
     if ($simList instanceof Application\Model\Stream\StreamResultModel) {
         $this->view->subscriptionData = array();
         $simList->getIterator()->addPlugin(new Stream\Plugin\Sim\Permissions());
         foreach ($simList as $value) {
             $subscriptionData = $value->exportData();
             $subscriptionData = $this->_mapToSdp($subscriptionData);
             // Make the data available on the view
             $this->view->subscriptionData[] = $subscriptionData;
         }
         //$this->view->count = $simList->getCount();
     } else {
         if ($simList instanceof Application\Model\GroupListModel) {
             $groups = $simList->getGroups();
             $this->view->data = $simList;
         }
     }
 }
示例#2
0
 /**
  * Builds a filter list based on params.
  * @param  array          $params
  * @return App_ListFilter | null
  */
 public function buildFilterList(array $params)
 {
     $factory = new \App_ListFilter_FilterFactory();
     $fields = SimFilterFields::getWhiteList();
     $factory->setWhiteList($fields);
     $sortingFields = SimSortingFields::getWhiteList();
     $factory->setSortingWhiteList($sortingFields);
     $factory->setGroupingWhiteList(SimGroups::getWhiteList());
     $factory->setAllowEmpty(true);
     //Black list for no monetary users
     $user = \App::getUserLogged();
     if (!$user->monetaryDataAccess) {
         $factory->setBlackList(SimFilterFields::getNoMonetaryUserBlackList());
         $factory->setSortingBlackList(SimSortingFields::getNoMonetaryUserBlackList());
         $factory->setGroupingBlackList(SimGroups::getNoMonetaryUserBlackList());
     }
     $filterList = $factory->constructFilter($params);
     $filterList->setValidators(SimFilterFields::getValidatorSpec());
     if (!$filterList->isValid()) {
         $filterList = $factory->constructFilter(array());
     }
     $filterList->setResourceId(SimFilterFields::getResourceId());
     $filterList->addExtraData('filterType', 'sims');
     \App::log()->debug('Unused filters [' . implode(',', $factory->getUnusedList()) . ']');
     return $filterList;
 }
 /**
  * Lists all sims matching a criteria
  */
 public function indexAction()
 {
     $dumpSim = new SimModel();
     $this->_helper->allowed('list', $dumpSim);
     $filters = $this->_mapToFilter($this->_getFilterParams());
     foreach (array(SimFilterFields::PROVISION_DATE, SimFilterFields::ACTIVATION_DATE) as $key) {
         if (isset($filters[$key])) {
             $filters[$key] = "!<" . $filters[$key];
         }
     }
     try {
         if (isset($filters[SimFilterFields::CURRENT_IP]) && App_Util_Ip::getIpVersion($filters[SimFilterFields::CURRENT_IP]) == App_Util_Ip::v6) {
             $filters[SimFilterFields::CURRENT_IP] = App_Util_Ip::ipv6Expand($filters[SimFilterFields::CURRENT_IP]);
         }
     } catch (InvalidArgumentException $ex) {
         throw new InvalidArgumentException("Invalid parameter value: ip.");
     }
     try {
         if (isset($filters[SimFilterFields::STATIC_IP]) && App_Util_Ip::getIpVersion($filters[SimFilterFields::STATIC_IP]) == App_Util_Ip::v6) {
             $filters[SimFilterFields::STATIC_IP] = App_Util_Ip::ipv6Expand($filters[SimFilterFields::STATIC_IP]);
         }
     } catch (InvalidArgumentException $ex) {
         throw new InvalidArgumentException("Invalid parameter value: staticIp.");
     }
     $this->_checkFilterParams($filters, SimFilterFields::getWhiteList());
     $filterList = $this->_simSrv->buildFilterList($filters);
     $filterHelper = $this->_helper->getHelper('filterNotAllowedFilters');
     $filterHelper->setThrowExOnNotAllowed(true);
     $filterHelper->direct('filter_by', $filterList);
     $params = $this->_getPaginatorParams();
     $simList = $this->_simSrv->listAll($filterList, $params, null, \App::getOrgUserLogged());
     if ($simList instanceof Application\Model\Stream\StreamResultModel) {
         $this->view->subscriptionData = array();
         $simList->getIterator()->addPlugin(new Stream\Plugin\Sim\Permissions());
         foreach ($simList as $value) {
             $subscriptionData = $value->exportData();
             $subscriptionData = $this->_mapToSdp($subscriptionData);
             // Make the data available on the view
             $this->view->subscriptionData[] = $subscriptionData;
         }
         //$this->view->count = $simList->getCount();
         if (empty($this->view->subscriptionData)) {
             $this->getResponse()->setHttpResponseCode(204);
             $this->_helper->viewRenderer->setNoRender(TRUE);
         }
     }
 }