Beispiel #1
0
 public function executeView($request)
 {
     $this->relationship = RelationshipApi::get($request->getParameter('id'));
     $this->forward404Unless($this->relationship);
     $this->relationship = array_merge($this->relationship, RelationshipApi::getDetails($this->relationship['id'], $this->relationship['category_id']));
     $this->current = null;
     if ($this->relationship['is_current'] == '1') {
         $this->current = 1;
     } else {
         if ($this->relationship['is_current'] == '0' || !$this->relationship['is_current'] && $this->relationship['end_date']) {
             $this->current = 0;
         }
     }
     $this->relationship['Entity1'] = EntityApi::get($this->relationship['entity1_id']);
     $this->relationship['Entity2'] = EntityApi::get($this->relationship['entity2_id']);
 }
Beispiel #2
0
 public function executeReferences($request)
 {
     $this->references = RelationshipApi::getReferences($this->relationship['id']);
     return 'Xml';
 }
Beispiel #3
0
 static function getRelationships($ids, $options)
 {
     $db = Doctrine_Manager::connection();
     $sql = 'SELECT ' . LsApi::generateSelectQuery(array('r' => 'Relationship')) . ' FROM relationship r WHERE r.id IN (' . implode(',', $ids) . ')';
     $stmt = $db->execute($sql);
     if (@$options['details']) {
         $rels = array();
         if ($catId = @$options['cat_id']) {
             //make Relationships accessible by id
             foreach ($stmt->fetchAll(PDO::FETCH_ASSOC) as $rel) {
                 $rels[$rel['id']] = $rel;
             }
             //get category data
             $categoryName = RelationshipCategoryTable::$categoryNames[$catId];
             $db = Doctrine_Manager::connection();
             $sql = 'SELECT * FROM ' . Doctrine_Inflector::tableize($categoryName) . ' WHERE relationship_id IN (' . implode(',', $ids) . ')';
             $stmt = $db->execute($sql, array($id));
             //merge category data with relationship data
             foreach ($stmt->fetchAll(PDO::FETCH_ASSOC) as $row) {
                 $relId = $row['relationship_id'];
                 unset($row['id'], $row['relationship_id']);
                 $rels[$relId] = array_merge($rels[$relId], $row);
             }
             return array_values($rels);
         } else {
             foreach ($stmt->fetchAll(PDO::FETCH_ASSOC) as $rel) {
                 $rels[] = array_merge($rel, RelationshipApi::getDetails($rel['id'], $rel['category_id']));
             }
             return $rels;
         }
     } else {
         return $stmt->fetchAll(PDO::FETCH_ASSOC);
     }
 }