Ejemplo n.º 1
0
 protected function printFirst($options)
 {
     if (!$options['list_id']) {
         echo "you need a list id\r";
         die;
     }
     $databaseManager = new sfDatabaseManager($this->configuration);
     $databaseManager->initialize($this->configuration);
     $db = Doctrine_Manager::connection();
     //CREATE NEW PRIMARY ALIASES
     $q = Doctrine_Query::create()->from('Entity e')->leftJoin('e.LsListEntity le')->leftJoin('e.Person p')->where('le.list_id = ? and le.is_deleted = 0', $options['list_id'])->orderBy('le.created_at ASC');
     $entities = $q->execute();
     foreach ($entities as $e) {
         echo $e->name . "\t\t" . EntityTable::getUri($e) . '/editContact' . "\t" . EntityTable::getUri($e) . "\t\t\t\t\t\t\t" . $e->Person->name_last . "\t" . $e->id . "\n";
     }
 }
Ejemplo n.º 2
0
 protected function execute($arguments = array(), $options = array())
 {
     if (!$options['list_id'] && !$options['entity_ids']) {
         echo "you need a list id or entity ids\r";
         die;
     }
     $databaseManager = new sfDatabaseManager($this->configuration);
     $databaseManager->initialize($this->configuration);
     $db = Doctrine_Manager::connection();
     //entity ids
     if ($options['entity_ids']) {
         $sql = 'SELECT p.name_first,p.name_last,e.blurb,GROUP_CONCAT(distinct(e2.name) separator "; ") as orgs, e.name, e.id
   FROM entity e
   LEFT JOIN person p on p.entity_id = e.id
   LEFT JOIN relationship r on r.entity1_id = e.id and r.category_id in (1,3) and (r.is_current = 1 or (r.is_current is null and r.end_date is null)) and r.is_deleted = 0
   LEFT JOIN entity e2 on e2.id = r.entity2_id 
   WHERE e.id in (' . $options['entity_ids'] . ')
   GROUP BY e.id';
         $stmt = $db->execute($sql);
     } else {
         if ($options['list_id']) {
             $sql = 'SELECT p.name_first,p.name_last,e.blurb,GROUP_CONCAT(distinct(e2.name) separator "; ") as orgs, e.name, e.id
   FROM ls_list_entity le 
   LEFT JOIN entity e ON e.id = le.entity_id 
   LEFT JOIN person p on p.entity_id = e.id
   LEFT JOIN relationship r on r.entity1_id = e.id and r.category_id in (1,3) and (r.is_current = 1 or (r.is_current is null and r.end_date is null)) and r.is_deleted = 0
   LEFT JOIN entity e2 on e2.id = r.entity2_id 
   WHERE le.list_id = ? and le.is_deleted = 0
   GROUP BY e.id';
             $stmt = $db->execute($sql, array($options['list_id']));
         }
     }
     $rows = $stmt->fetchAll(PDO::FETCH_CLASS);
     foreach ($rows as $row) {
         $row = (array) $row;
         $str1 = implode("\t", array_slice($row, 0, 3));
         $str2 = implode("\t", array_slice($row, 3));
         echo $str1 . "\t";
         $e = Doctrine::getTable('Entity')->find($row['id']);
         echo EntityTable::getUri($e) . "\t";
         echo $str2 . "\n";
     }
 }
Ejemplo n.º 3
0
 static function getSearchData($id)
 {
     $db = Doctrine_Manager::connection();
     $sql = "SELECT e.id, e.name, e.blurb AS description, e.primary_ext AS primary_type, GROUP_CONCAT(DISTINCT a.name SEPARATOR ';') AS aliases FROM ls_list_entity le " . 'JOIN entity e ON (le.entity_id = e.id) ' . 'LEFT JOIN alias a ON (a.entity_id = e.id) ' . 'WHERE le.list_id = ? AND le.is_deleted = 0 AND e.is_deleted = 0 ' . 'GROUP BY e.id';
     $stmt = $db->execute($sql, array($id));
     $rows = $stmt->fetchAll(PDO::FETCH_ASSOC);
     return array_map(function ($row) {
         $row['aliases'] = explode(';', $row['aliases']);
         $row['url'] = EntityTable::getUri($row);
         return $row;
     }, $rows);
 }
Ejemplo n.º 4
0
 static function addUris($entity)
 {
     if ($entity['id'] && $entity['primary_type'] && $entity['name']) {
         $entity['uri'] = EntityTable::getUri($entity);
         $entity['api_uri'] = self::getUri($entity['id']);
     } else {
         $entity['uri'] = null;
         $entity['api_uri'] = null;
     }
     return $entity;
 }