protected function _searchWhere(Surfnet_Search_Parameters $params)
 {
     $searchParams = $params->getSearchParams();
     if (!isset($searchParams['vo_id'])) {
         throw new EngineBlock_Exception("Invalid VO id!");
     }
     // select VO Attribute record(s)
     $statement = $this->dbConnection->prepare("SELECT voa.* FROM virtual_organisation_attribute voa WHERE voa.vo_id = ?");
     $statement->execute(array($searchParams['vo_id']));
     $rows = $statement->fetchAll(PDO::FETCH_ASSOC);
     foreach ($rows as &$row) {
         $row = $this->jsonDecodeColumn($row, 'attribute_value');
     }
     return new Surfnet_Search_Results($params, $rows, count($rows));
 }
 /**
  * List view of user attributes
  */
 public function indexAction($dispatch = TRUE)
 {
     //var_dump($this->_getRequest()->getPostParameters());
     // VO selected?
     $this->getSelectedVO();
     // dispatch
     if ($dispatch) {
         $this->dispatchAction($this->_getRequest()->getPostParameters());
     }
     // index action
     $params = Surfnet_Search_Parameters::create();
     $params->addSearchParam('vo_id', $this->m_vo_id);
     $service = new VoManage_Service_VirtualOrganisationAttribute();
     $results = $service->listSearch($params);
     $resultSet = $results->getResults();
     $this->vo_id = $this->m_vo_id;
     $spList = $this->getServiceProviders();
     foreach ($resultSet as $key => &$record) {
         $record['sp_entity_id_display'] = isset($spList[$record['sp_entity_id']]) ? $spList[$record['sp_entity_id']]['id_display'] : '- unknown -';
     }
     // sort
     $resultSet = $this->sortByColumn($resultSet, 'sp_entity_id_display');
     // assign to view
     $this->resultSet = $resultSet;
 }
 public function searchUsage(Surfnet_Search_Parameters $params)
 {
     if (!$params->getSortByField()) {
         $params->setSortByField('num');
         $params->setSortDirection('desc');
     }
     $dao = new Portal_Model_DbTable_Gadget();
     $query = $dao->select()->setIntegrityCheck(false)->from($dao, array('definition'))->join(array('gd' => 'gadgetdefinition'), 'gadget.definition = gd.id', array('num' => 'count(gd.id)', 'title' => 'gd.title', 'author' => 'gd.author'))->join(array('t' => 'tab'), 'gadget.tab_id = t.id')->group('gadget.definition');
     if ($params->getLimit()) {
         $query->limit($params->getLimit(), $params->getOffset());
     }
     $query->order($params->getSortByField() . ' ' . $params->getSortDirection());
     $results = $dao->fetchAll($query)->toArray();
     $totalCount = $dao->fetchRow($query->reset(Zend_Db_Select::LIMIT_COUNT)->reset(Zend_Db_Select::LIMIT_OFFSET)->columns(array('count' => 'COUNT(*)')))->offsetGet('count');
     return new Surfnet_Search_Results($params, $results, $totalCount);
 }
 public function init()
 {
     $action = $this->getRequest()->getActionName();
     $this->view->identity = $this->_helper->Authenticate();
     $this->_helper->ContextSwitch()->addActionContext($action, array('json', 'json-export', 'csv-export'))->initContext();
     $this->_inputFilter = $this->_helper->FilterLoader();
     $this->_searchParams = Surfnet_Search_Parameters::create($this->_inputFilter);
     $this->_initExportParameters();
     $this->view->gridConfig = $this->_helper->gridSetup($this->_inputFilter);
     $this->_helper->ContextSwitch()->setGridConfig($this->view->gridConfig);
 }
 public function showByCapabilityAction()
 {
     if ($this->getRequest()->getParam('download', false)) {
         $this->getResponse()->setHeader('Content-disposition', 'attachment; filename=json.txt');
     }
     $inputFilter = $this->_helper->FilterLoader();
     $params = Surfnet_Search_Parameters::create()->setLimit($inputFilter->results)->setOffset($inputFilter->startIndex)->setSortByField($inputFilter->sort)->setSortDirection($inputFilter->dir);
     $service = new Portal_Service_GadgetDefinition();
     $results = $service->searchCountByCapabililty($params);
     $this->view->gridConfig = $this->_helper->gridSetup($inputFilter);
     $this->view->ResultSet = $results->getResults();
     $this->view->startIndex = $results->getParameters()->getOffset();
     $this->view->recordsReturned = $results->getResultCount();
     $this->view->totalRecords = $results->getTotalCount();
 }
 protected function _searchWhere(Surfnet_Search_Parameters $params, $where)
 {
     $dao = new Portal_Model_DbTable_GadgetDefinition();
     $query = $dao->select()->from($dao)->where($where);
     if ($params->getLimit()) {
         $query->limit($params->getLimit(), $params->getOffset());
     }
     if ($params->getSortByField()) {
         $query->order('gadgetdefinition.' . $params->getSortByField() . ' ' . $params->getSortDirection());
     }
     $results = $dao->fetchAll($query)->toArray();
     $totalCount = $dao->fetchRow($query->reset(Zend_Db_Select::LIMIT_COUNT)->reset(Zend_Db_Select::LIMIT_OFFSET)->columns(array('count' => 'COUNT(*)')))->offsetGet('count');
     return new Surfnet_Search_Results($params, $results, $totalCount);
 }
 /**
  * 
  *
  * SELECT COUNT(id) AS num, status
  * FROM portal.invite
  * GROUP BY status
  *
  * @param Surfnet_Search_Parameters $params
  * @return Surfnet_Search_Results
  */
 public function searchCountByStatus(Surfnet_Search_Parameters $params)
 {
     $dao = new Portal_Model_DbTable_Invite();
     $select = $dao->select()->from($dao)->group('status');
     $select = $select->columns(array("num" => "COUNT(id)", "status" => "status"));
     if ($params->getLimit()) {
         $select->limit($params->getLimit(), $params->getOffset());
     }
     if ($params->getSortByField() != '') {
         $select->order($params->getSortByField() . ' ' . $params->getSortDirection());
     }
     $results = $dao->fetchAll($select)->toArray();
     $totalCount = $dao->fetchRow($select->reset(Zend_Db_Select::LIMIT_COUNT)->reset(Zend_Db_Select::LIMIT_OFFSET)->columns(array('count' => 'COUNT(*)')))->offsetGet('count');
     return new Surfnet_Search_Results($params, $results, $totalCount);
 }
 public function listAction()
 {
     if ($this->getRequest()->getParam('download', false)) {
         $this->getResponse()->setHeader('Content-disposition', 'attachment; filename=json.txt');
     }
     $inputFilter = $this->_helper->FilterLoader();
     $params = Surfnet_Search_Parameters::create()->setLimit($inputFilter->results)->setOffset($inputFilter->startIndex)->setSortByField($inputFilter->sort)->setSortDirection($inputFilter->dir);
     $service = new EngineBlock_Service_GroupProvider();
     $results = $service->listSearch($params);
     $this->view->gridConfig = $this->_helper->gridSetup($inputFilter);
     $this->view->ResultSet = $results->getResults();
     $this->view->startIndex = $results->getParameters()->getOffset();
     $this->view->recordsReturned = $results->getResultCount();
     $this->view->totalRecords = $results->getTotalCount();
     $this->view->addUrl = $this->view->url(array('action' => 'add'));
     $this->view->editUrl = $this->view->url(array('action' => 'edit'));
 }
 /**
  * Get logins grouped by type (IDP or SP)
  *
  * @param String $groupByField
  * @param Surfnet_Search_Parameters $params
  * @return Surfnet_Search_Results
  */
 protected function _searchCountGrouped($groupByField, Surfnet_Search_Parameters $params)
 {
     $dao = new EngineBlock_Model_DbTable_LogLogin();
     $select = $dao->select()->from($dao, array('num' => 'COUNT(*)', 'grouped' => $groupByField))->group($groupByField);
     if ($params->getLimit()) {
         $select->limit($params->getLimit(), $params->getOffset());
     }
     if ($params->getSortByField() != '') {
         $select->order($params->getSortByField() . ' ' . $params->getSortDirection());
     }
     $searchParams = $params->getSearchParams();
     if ($params->searchByDate()) {
         $select->where($this->_getLoginDateWhere($searchParams['year'], $searchParams['month']));
     }
     if (isset($searchParams['entity_field']) && !empty($searchParams['entity_field'])) {
         $select->where($this->_getEntityWhere($searchParams['entity_field'], $searchParams['entity_id']));
     }
     $rows = $dao->fetchAll($select)->toArray();
     $select->reset(Zend_Db_Select::LIMIT_COUNT)->reset(Zend_Db_Select::LIMIT_OFFSET);
     $countSelect = $dao->getAdapter()->select()->from($select)->columns(array('count' => 'COUNT(*)'));
     $totalCount = $countSelect->query()->fetchObject()->count;
     return new Surfnet_Search_Results($params, $rows, $totalCount);
 }
 public function listAction()
 {
     $inputFilter = $this->_helper->FilterLoader();
     $params = Surfnet_Search_Parameters::create()->setLimit($inputFilter->results)->setOffset($inputFilter->startIndex)->setSortByField($inputFilter->sort)->setSortDirection($inputFilter->dir);
     $searchParams = $this->_getParam('search');
     if (!empty($searchParams)) {
         foreach ($searchParams as $searchKey => $searchParam) {
             $params->addSearchParam($searchKey, $searchParam);
         }
     }
     $service = new Portal_Service_Gadget();
     $results = $service->search($params);
     $this->view->gridConfig = $this->_helper->gridSetup($inputFilter);
     $this->view->ResultSet = $results->getResults();
     $this->view->startIndex = $results->getParameters()->getOffset();
     $this->view->recordsReturned = $results->getResultCount();
     $this->view->totalRecords = $results->getTotalCount();
 }
 public function showSpByGroupproviderAction()
 {
     $service = new EngineBlock_Service_ServiceProviderGroupAcl();
     $groupProviderId = (int) $this->_getParam('id');
     $groupProviderAbr = $this->_getParam('abr');
     $groupProviderName = $this->_getParam('name');
     $spsAclFromDb = $service->findByGroupProviderId($groupProviderId);
     $janus = new ServiceRegistry_Service_JanusEntity();
     /*
      * An array of arrays where we want the key 'entityid' of the value array
      */
     $spsFromJanus = $janus->searchSps(Surfnet_Search_Parameters::create())->getResults();
     $results = array();
     /*
      * now delete those spAcl's that have no corresponding Janus SP entry
      */
     foreach ($spsAclFromDb as $spAcl) {
         if (!$this->_hasExistingJanusSP($spsFromJanus, $spAcl)) {
             $service->delete($spAcl->id);
         } else {
             $results[] = $spAcl;
         }
     }
     /*
      * now create an Acl if there is a Janus entry but no corresponding ServiceProviderGroupAcl
      */
     $mapper = new EngineBlock_Model_Mapper_ServiceProviderGroupAcl(new EngineBlock_Model_DbTable_ServiceProviderGroupAcl());
     foreach ($spsFromJanus as $spJanus) {
         $spEntityId = $this->_getMissingSpAclEntityId($spsAclFromDb, $spJanus);
         if ($spEntityId) {
             $model = new EngineBlock_Model_ServiceProviderGroupAcl();
             $model->allow_groups = false;
             $model->allow_members = false;
             $model->groupProviderId = $groupProviderId;
             $model->spentityid = $spEntityId;
             $model->id = $mapper->save($model);
             $results[] = $model;
         }
     }
     $this->view->serviceProviderAcls = $results;
     $this->view->groupProvider = array('id' => $groupProviderId, 'abr' => $groupProviderAbr, 'name' => $groupProviderName);
     $this->render('edit');
 }
 public function search(Surfnet_Search_Parameters $params)
 {
     $dao = new EngineBlock_Model_DbTable_EmailConfiguration();
     $query = $dao->select()->from($dao)->columns();
     $searchParams = $params->getSearchParams();
     foreach ($searchParams as $key => $value) {
         if (!$value) {
             continue;
         }
         $query->where($key . ' LIKE ' . $dao->getAdapter()->quote('%' . $value . '%'));
     }
     if ($params->getLimit()) {
         $query->limit($params->getLimit(), $params->getOffset());
     }
     if ($params->getSortByField()) {
         $query->order($params->getSortByField() . ' ' . $params->getSortDirection());
     }
     $results = $dao->fetchAll($query)->toArray();
     $totalCount = $dao->fetchRow($query->reset(Zend_Db_Select::LIMIT_COUNT)->reset(Zend_Db_Select::LIMIT_OFFSET)->columns(array('count' => 'COUNT(*)')))->offsetGet('count');
     return new Surfnet_Search_Results($params, $results, $totalCount);
 }
 protected function _searchWhere(Surfnet_Search_Parameters $params, $where = '')
 {
     // select VO record(s)
     $dao = new EngineBlock_Model_DbTable_VirtualOrganisationGroup();
     $query = $dao->select()->from($dao);
     if (strlen(trim($where)) > 0) {
         $query->where($where);
     }
     if ($params->getLimit()) {
         $query->limit($params->getLimit(), $params->getOffset());
     }
     if ($params->getSortByField()) {
         $query->order('virtual_organisation_group.' . $params->getSortByField() . ' ' . $params->getSortDirection());
     }
     $groupRecords = $dao->fetchAll($query);
     $totalCount = $dao->fetchRow($query->reset(Zend_Db_Select::LIMIT_COUNT)->reset(Zend_Db_Select::LIMIT_OFFSET)->columns(array('count' => 'COUNT(*)')))->offsetGet('count');
     return new Surfnet_Search_Results($params, $groupRecords, $totalCount);
 }
 public function listAction()
 {
     $inputFilter = $this->_helper->FilterLoader();
     $params = Surfnet_Search_Parameters::create()->setLimit($inputFilter->results)->setOffset($inputFilter->startIndex)->setSortDirection($inputFilter->dir);
     $searchParams = $this->_getParam('search');
     if (!empty($searchParams)) {
         foreach ($searchParams as $searchKey => $searchParam) {
             $params->addSearchParam($searchKey, $searchParam);
         }
     }
     $service = new EngineBlock_Service_EmailConfiguration();
     $results = $service->search($params);
     $this->view->gridConfig = $this->_helper->gridSetup($inputFilter);
     $this->view->ResultSet = $results->getResults();
     $this->view->startIndex = $results->getParameters()->getOffset();
     $this->view->recordsReturned = $results->getResultCount();
     $this->view->totalRecords = $results->getTotalCount();
     $this->view->addUrl = $this->view->url(array('action' => 'add'));
     $this->view->editUrl = $this->view->url(array('action' => 'edit'));
 }
 protected function _searchWhere(Surfnet_Search_Parameters $params, $where = '')
 {
     // Select Group Provider Records
     $dao = new EngineBlock_Model_DbTable_GroupProvider();
     $query = $dao->select()->from($dao);
     if (strlen(trim($where)) > 0) {
         $query->where($where);
     }
     if ($params->getLimit()) {
         $query->limit($params->getLimit(), $params->getOffset());
     }
     if ($params->getSortByField()) {
         $query->order('group_provider.' . $params->getSortByField() . ' ' . $params->getSortDirection());
     }
     $gpRecords = $dao->fetchAll($query);
     $gpRecords = $gpRecords->toArray();
     // get full classnames
     foreach ($gpRecords as &$record) {
         $record['fullClassname'] = $record['classname'];
         $record['classname'] = EngineBlock_Model_GroupProvider::getClassnameDisplayValue($record['classname']);
     }
     $totalCount = $dao->fetchRow($query->reset(Zend_Db_Select::LIMIT_COUNT)->reset(Zend_Db_Select::LIMIT_OFFSET)->columns(array('count' => 'COUNT(*)')))->offsetGet('count');
     return new Surfnet_Search_Results($params, $gpRecords, $totalCount);
 }
 public function editAction()
 {
     $this->view->vo_id = htmlentities($this->_getParam('vo_id'));
     $service = new EngineBlock_Service_VirtualOrganisation();
     $this->view->virtualOrganisation = $service->fetchById($this->view->vo_id);
     // rebuild clean urls to prevent "/vo_id/..." in the urls when returning from group editing:
     $this->view->saveUrl = $this->view->url(array('module' => 'engineblock', 'controller' => 'virtual-organisation', 'action' => 'save'), null, true);
     $this->view->listUrl = $this->view->url(array('module' => 'engineblock', 'controller' => 'virtual-organisation', 'action' => 'list'), null, true);
     $this->view->gridData = array();
     $voType = $this->view->virtualOrganisation->vo_type;
     if (in_array($voType, array('GROUP', 'MIXED'))) {
         // groups grid
         $inputFilter = $this->_helper->FilterLoader('groups');
         $params = Surfnet_Search_Parameters::create()->setLimit($inputFilter->results)->setOffset($inputFilter->startIndex)->setSortByField($inputFilter->sort)->setSortDirection($inputFilter->dir);
         $service = new EngineBlock_Service_VirtualOrganisationGroup();
         $groupRecords = $service->listSearch($params, $this->view->vo_id);
         $this->view->gridData['groups'] = array('gridConfig' => $this->_helper->gridSetup($inputFilter, 'groups'));
     }
     if (in_array($voType, array('STEM'))) {
         $config = $this->getFrontController()->getParam('bootstrap')->getApplication()->getOptions();
         $voPrefix = $config['engineBlock']['vo']['stemPrefix'];
         $this->view->voStem = $voPrefix . $this->view->virtualOrganisation->vo_id;
         // Do nothing, since we only have to display the stem name
     }
     if (in_array($voType, array('IDP', 'MIXED'))) {
         // idps grid
         $inputFilter = $this->_helper->FilterLoader('idps');
         $params = Surfnet_Search_Parameters::create()->setLimit($inputFilter->results)->setOffset($inputFilter->startIndex)->setSortByField($inputFilter->sort)->setSortDirection($inputFilter->dir);
         $service = new EngineBlock_Service_VirtualOrganisationIdp();
         $idpRecords = $service->listSearch($params, $this->view->vo_id);
         $this->view->gridData['idps'] = array('gridConfig' => $this->_helper->gridSetup($inputFilter, 'idps'));
     }
     // json context dependent variables
     if ($this->_getParam('format') == 'json') {
         $this->view->gridid = $this->_getParam('gridid');
         switch ($this->view->gridid) {
             case 'groups':
                 $this->view->ResultSet = $this->view->virtualOrganisation->groups;
                 //$results->getResults();
                 $this->view->startIndex = $groupRecords->getParameters()->getOffset();
                 $this->view->recordsReturned = $groupRecords->getResultCount();
                 $this->view->totalRecords = $groupRecords->getTotalCount();
                 $this->view->addUrl = $this->view->url(array('action' => 'groupadd'));
                 $this->view->editUrl = $this->view->url(array('action' => 'groupedit'));
                 break;
             case 'idps':
                 $this->view->ResultSet = $this->view->virtualOrganisation->idps;
                 //$results->getResults();
                 $this->view->startIndex = $idpRecords->getParameters()->getOffset();
                 $this->view->recordsReturned = $idpRecords->getResultCount();
                 $this->view->totalRecords = $idpRecords->getTotalCount();
                 $this->view->addUrl = $this->view->url(array('action' => 'idpadd'));
                 $this->view->editUrl = $this->view->url(array('action' => 'idpedit'));
                 break;
             default:
                 break;
         }
     } else {
         $this->view->ResultSet = array();
     }
 }
 /**
  * Tabs with a team connected to it.
  *
  * @param Integer $timestamp timestamp to determine the month
  *                this KPI covers.
  * @return Integer
  */
 public function getTeamTabs($timestamp)
 {
     /**
      * Teamtabs KPI per month
      * The timestamps are in milliseconds.
      */
     $date = getdate($timestamp);
     $searchFields = array('year' => $date['year'], 'month' => $date['mon']);
     $params = Surfnet_Search_Parameters::create()->setSearchParams($searchFields);
     $service = new Portal_Service_Tab();
     $results = $service->searchTeams($params)->getResults();
     return $results[0]['num'];
 }
 public function setUp()
 {
     $this->_params = Surfnet_Search_Parameters::create();
 }
 protected function _searchWhere(Surfnet_Search_Parameters $params, $where = '')
 {
     // select VO record(s)
     $dao = new EngineBlock_Model_DbTable_VirtualOrganisation();
     $query = $dao->select()->from($dao);
     if (strlen(trim($where)) > 0) {
         $query->where($where);
     }
     if ($params->getLimit()) {
         $query->limit($params->getLimit(), $params->getOffset());
     }
     if ($params->getSortByField()) {
         $query->order('virtual_organisation.' . $params->getSortByField() . ' ' . $params->getSortDirection());
     }
     $voRecords = $dao->fetchAll($query);
     // get corresponding groups
     $groupRecords = array();
     foreach ($voRecords as $row) {
         /* @var $row Zend_Db_Table_Row */
         $groupRecords[$row->vo_id] = $row->findDependentRowset('EngineBlock_Model_DbTable_VirtualOrganisationGroup')->toArray();
         // remove FK's
         foreach ($groupRecords[$row['vo_id']] as &$groupRow) {
             unset($groupRow['vo_id']);
         }
     }
     unset($row);
     // get corresponding idps
     $idpRecords = array();
     foreach ($voRecords as $row) {
         /* @var $row Zend_Db_Table_Row */
         $idpRecords[$row->vo_id] = $row->findDependentRowset('EngineBlock_Model_DbTable_VirtualOrganisationIdp')->toArray();
         // remove FK's
         foreach ($idpRecords[$row['vo_id']] as &$idpRow) {
             unset($idpRow['vo_id']);
         }
     }
     unset($row);
     // get corresponding stem
     $stemRecords = array();
     foreach ($voRecords as $row) {
         if ($row->vo_type === 'STEM') {
             /* @var $config Zend_Config */
             $config = Zend_Registry::get('config');
             $stemPrefix = $config->engineBlock->vo->stemPrefix;
             $stemRecords[$row['vo_id']] = $stemPrefix . $row->vo_id;
         }
     }
     unset($row);
     // merge groups into VOs
     $voRecords = $voRecords->toArray();
     foreach ($voRecords as &$row) {
         $row['groups'] = $groupRecords[$row['vo_id']];
     }
     unset($row);
     // merge idps into VOs
     foreach ($voRecords as &$row) {
         $row['idps'] = $idpRecords[$row['vo_id']];
     }
     unset($row);
     // merge stems into VOs
     foreach ($voRecords as &$row) {
         if ($row['vo_type'] === 'STEM') {
             $row['stem'] = $stemRecords[$row['vo_id']];
         }
     }
     unset($row);
     $totalCount = $dao->fetchRow($query->reset(Zend_Db_Select::LIMIT_COUNT)->reset(Zend_Db_Select::LIMIT_OFFSET)->columns(array('count' => 'COUNT(*)')))->offsetGet('count');
     return new Surfnet_Search_Results($params, $voRecords, $totalCount);
 }
 public function searchTeams(Surfnet_Search_Parameters $params)
 {
     if (!$params->getSortByField()) {
         $params->setSortByField('num');
         $params->setSortDirection('desc');
     }
     $dao = new Portal_Model_DbTable_Tab();
     /**
      * $qry = "SELECT COUNT(id) AS num, 'Total Tabs' as type FROM `coin_portal`.`tab`
      *  UNION
      * SELECT COUNT(id) AS num, 'Shared Team Tabs' as type FROM `coin_portal`.`tab` where team IS NOT NULL
      *  UNION
      * SELECT COUNT(id) AS num, 'Not Shared' as type FROM `coin_portal`.`tab` where team IS NULL";
      */
     $selectTotal = $dao->select()->from($dao, array("num" => "COUNT(id)", 'type' => new Zend_Db_Expr("'Total'")));
     $selectShared = $dao->select()->from($dao, array("num" => "COUNT(id)", 'type' => new Zend_Db_Expr("'Shared'")))->where('team IS NOT NULL');
     $selectNotShared = $dao->select();
     $selectNotShared->from($dao, array("num" => "COUNT(id)", 'type' => new Zend_Db_Expr("'Not shared'")))->where('team IS NULL');
     $searchParams = $params->getSearchParams();
     if ($params->searchByDate()) {
         $dateWhere = $this->_getTeamTabsDateWhere($searchParams['year'], $searchParams['month']);
         $selectTotal->where($dateWhere);
         $selectShared->where($dateWhere);
         $selectNotShared->where($dateWhere);
     }
     $select = $dao->select()->union(array($selectTotal, $selectShared, $selectNotShared));
     if ($params->getLimit()) {
         $select->limit($params->getLimit(), $params->getOffset());
     }
     $select->order($params->getSortByField() . ' ' . $params->getSortDirection());
     $rows = $dao->fetchAll($select)->toArray();
     return new Surfnet_Search_Results($params, $rows, 3);
 }
 public function getAllowedConnections($entityId)
 {
     $service = new ServiceRegistry_Service_JanusEntity();
     $fromEntity = $service->fetchByEntityId($entityId);
     $entities = array();
     // get all entities from other type
     if ($fromEntity['type'] === "saml20-idp") {
         $results = $service->searchSps(Surfnet_Search_Parameters::create());
         $entities = $results->getResults();
     } else {
         $results = $service->searchIdps(Surfnet_Search_Parameters::create());
         $entities = $results->getResults();
     }
     $entitiesResult = array();
     foreach ($entities as $entity) {
         if ($service->isConnectionAllowed($fromEntity, $entity) && $service->isConnectionAllowed($entity, $fromEntity)) {
             $entitiesResult[] = $entity;
         }
     }
     return $entitiesResult;
 }