Esempio n. 1
0
 /**
  * Get log object based on given time and the person
  *
  * @return org_routamc_positioning_log_dba
  */
 function seek_log($time = null)
 {
     if (is_null($this->_person) || !$this->_person->id) {
         return null;
     }
     if (is_null($time)) {
         $time = time();
     }
     $qb = org_routamc_positioning_log_dba::new_query_builder();
     $qb->add_constraint('person', '=', (int) $this->_person->id);
     $qb->add_constraint('date', '<=', (int) $time);
     $qb->add_order('date', 'DESC');
     $qb->set_limit(1);
     $matches = $qb->execute_unchecked();
     if (count($matches) > 0) {
         return $matches[0];
     }
     return null;
 }
Esempio n. 2
0
 /**
  * Get log object based on creation time and creator of the object
  *
  * @return org_routamc_positioning_log_dba
  */
 function seek_log_object($person = null, $time = null)
 {
     if (is_integer($person) || is_string($person)) {
         $person_guid = $person;
     } elseif (is_null($person)) {
         if (isset($this->_object->metadata->authors) && $this->_object->metadata->authors) {
             $authors = explode('|', substr($this->_object->metadata->authors, 1, -1));
             if (!$authors) {
                 return null;
             }
             $person_guid = $authors[0];
         } elseif (isset($this->_object->metadata->creator) && $this->_object->metadata->creator) {
             $person_guid = $this->_object->metadata->creator;
         } elseif (isset($this->_object->author) && $this->_object->author) {
             $person_guid = $this->_object->author;
         } else {
             return null;
         }
     } else {
         $person_guid = $person->guid;
     }
     if (!$person_guid) {
         return null;
     }
     if (is_null($time)) {
         $time = $this->_object->metadata->published;
     }
     try {
         $person = new midcom_db_person($person_guid);
     } catch (midcom_error $e) {
         return null;
     }
     $qb = org_routamc_positioning_log_dba::new_query_builder();
     $qb->add_constraint('person', '=', $person->id);
     $qb->add_constraint('date', '<=', $time);
     $qb->add_order('date', 'DESC');
     $qb->set_limit(1);
     $matches = $qb->execute_unchecked();
     if (count($matches) > 0) {
         return $matches[0];
     }
     return null;
 }
Esempio n. 3
0
 /**
  * Returns the next log entry by the person
  *
  * @return org_routamc_positioning_log_dba Next log entry
  */
 function get_next()
 {
     if (!$this->person) {
         return null;
     }
     $qb = org_routamc_positioning_log_dba::new_query_builder();
     $qb->add_constraint('person', '=', (int) $this->person);
     $qb->add_constraint('date', '>', (int) $this->date);
     $qb->add_order('date', 'ASC');
     $qb->set_limit(1);
     $matches = $qb->execute_unchecked();
     if (count($matches) > 0) {
         return $matches[0];
     }
     return null;
 }
Esempio n. 4
0
 private function _list_positions_between(&$data_array, $person, $from, $to)
 {
     if (!$GLOBALS['midcom_config']['positioning_enable']) {
         return false;
     }
     midcom::get('componentloader')->load_library('org.openpsa.positioning');
     // List user's position reports
     $qb = org_routamc_positioning_log_dba::new_query_builder();
     $qb->add_constraint('date', '>=', $from);
     $qb->add_constraint('date', '<=', $to);
     $qb->add_constraint('person', '=', $person);
     $positions = $qb->execute();
     foreach ($positions as $position) {
         $time = $position->date;
         $date = date('Y-m-d', $time);
         if (!array_key_exists($date, $data_array)) {
             $data_array[$date] = array();
         }
         if (!array_key_exists($time, $data_array[$date])) {
             $data_array[$date][$time] = array();
         }
         $data_array[$date][$time][$position->guid] = $position;
     }
 }