/**
  * Lists all organizations matching a criteria
  */
 public function indexAction()
 {
     $type = $this->_getParam('type');
     if ($parentId = $this->_getParam('parentId')) {
         $parentOrg = $this->_orgSrv->load($parentId);
         if (empty($parentOrg)) {
             throw new InvalidArgumentException('Invalid parent organization');
         }
         $this->_helper->allowed('read', $parentOrg);
         if (empty($type)) {
             $this->getRequest()->setParam('type', $parentOrg::CHILDREN_ORG_TYPE);
             $type = $parentOrg::CHILDREN_ORG_TYPE;
         }
     }
     if (empty($type)) {
         throw new InvalidArgumentException('No organization type given');
     }
     $fakeOrg = OrgModelFactory::factory(array('type' => $type));
     $this->_helper->allowed('list', $fakeOrg);
     $params = array();
     if ($data = $this->_getParam('page')) {
         $params['page'] = $data;
     }
     if ($data = $this->_getParam('count')) {
         $params['count'] = $data;
     }
     if ($data = $this->_getParam('parentId')) {
         $params['parentId'] = $data;
     }
     $filterList = $this->_orgSrv->buildFilterList($this->getRequest()->getParams());
     if ($filterList !== null) {
         $this->_helper->filterNotAllowedFilters('filter_by', $filterList);
         $params['filterList'] = $filterList;
     }
     $orgs = $this->_orgSrv->listAll($type, $params);
     $this->view->data = $orgs->getItems();
     $this->view->count = $orgs->getCount();
     foreach ($this->view->data as $key => $item) {
         try {
             $this->_helper->filterNotAllowedFields('read_field', $item);
         } catch (Exception $e) {
             $this->view->count--;
             unset($this->view->data[$key]);
         }
     }
     $this->view->data = array_values($this->view->data);
 }