コード例 #1
0
 protected function _searchType($type, Surfnet_Search_Parameters $params)
 {
     $searchParams = $params->getSearchParams();
     $dao = new ServiceRegistry_Model_DbTable_JanusEntity();
     $rev_fields = array('eid' => 'eid', 'maxrev' => 'max(revisionid)');
     $rev_select = $dao->select()->from(array('janus__entity'), $rev_fields)->group('eid');
     $fields = array('entityid' => 'entityid', 'state' => 'state', 'metadataurl' => 'metadataurl', 'created' => 'created', 'user' => 'user', 'display_name' => "IFNULL(\n    (SELECT `value` FROM `janus__metadata` `jm` WHERE `key`='name:en' AND jm.eid = ent.eid AND jm.revisionid = maxrev),\n    ent.entityid\n    )");
     $entityType = $type === 'saml20-sp' ? 'sp' : 'idp';
     $entityType = 'idp';
     if ($type === 'saml20-sp') {
         $entityType = 'sp';
     }
     $select = $dao->select()->setIntegrityCheck(false)->from(array('ent' => 'janus__entity'))->columns($fields)->joinInner(array('entgrp' => $rev_select), 'ent.eid = entgrp.eid and ent.revisionid = entgrp.maxrev')->join(array('ju' => 'janus__user'), '(ent.user=ju.uid)', array('userid' => 'userid'))->where('ent.type= ?', $type);
     if ($params->searchByDate()) {
         $select->where($this->_getCountTypesWhereForDate('ent', $searchParams['year'], $searchParams['month']));
     }
     if ($params->getLimit()) {
         $select->limit($params->getLimit(), $params->getOffset());
     }
     if ($params->getSortByField() != '') {
         $select->order($params->getSortByField() . ' ' . $params->getSortDirection());
     }
     $rows = $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, $rows, $totalCount);
 }
コード例 #2
0
 protected function _fetchAllowedEntities($eid)
 {
     $dao = new ServiceRegistry_Model_DbTable_JanusEntity();
     $rev_fields = array('eid' => 'eid', 'maxrev' => 'max(revisionid)');
     $rev_select = $dao->select()->from(array('janus__entity'), $rev_fields)->where('eid = ?', $eid)->group('eid');
     $fields = array('eid' => 'eid', 'revisionid' => 'revisionid', 'remoteentityid' => 'remoteentityid', 'created' => 'created', 'ip' => 'ip');
     $rev_id = $dao->fetchRow($rev_select)->toArray();
     $select = $dao->select()->setIntegrityCheck(false)->from('janus__allowedEntity')->columns($fields)->where('eid = ?', $eid)->where('revisionid = ?', $rev_id['maxrev']);
     $rows = $dao->fetchAll($select)->toArray();
     $result = array();
     foreach ($rows as $value) {
         $result[$value['remoteentityid']] = $value;
     }
     return $result;
 }