コード例 #1
0
ファイル: user.php プロジェクト: nemein/openpsa
 public static function set_location_for_person(array $location, midcom_db_person $person)
 {
     if (!isset($location['latitude']) || !isset($location['longitude'])) {
         throw new InvalidArgumentException('No coordinates provided');
     }
     $log = new org_routamc_positioning_log_dba();
     $log->person = $person->id;
     $log->latitude = $location['latitude'];
     $log->longitude = $location['longitude'];
     if (isset($location['source'])) {
         $log->importer = $location['source'];
     }
     if (isset($location['accuracy'])) {
         $log->accuracy = $location['accuracy'];
     }
     return $log->create();
 }
コード例 #2
0
ファイル: person.php プロジェクト: nemein/openpsa
 /**
  * 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;
 }
コード例 #3
0
ファイル: metaweblog.php プロジェクト: nemein/openpsa
 function editPost($message)
 {
     $args = $this->_params_to_args($message);
     if (count($args) != 5) {
         return new XML_RPC_Response(0, midcom_connection::get_error(), 'Invalid arguments.');
     }
     if (!midcom::get('auth')->login($args[1], $args[2])) {
         return new XML_RPC_Response(0, midcom_connection::get_error(), 'Authentication failed.');
     }
     midcom::get('auth')->initialize();
     try {
         $article = new midcom_db_article($args[0]);
     } catch (midcom_error $e) {
         return new XML_RPC_Response(0, midcom_connection::get_error(), 'Article not found: ' . $e->getMessage());
     }
     if (!$this->_datamanager->autoset_storage($article)) {
         return new XML_RPC_Response(0, midcom_connection::get_error(), 'Failed to initialize DM2 for article: ' . midgard_connection::get_error_string());
     }
     foreach ($args[3] as $field => $value) {
         switch ($field) {
             case 'title':
                 $this->_datamanager->types['title']->value = html_entity_decode($value, ENT_QUOTES, 'UTF-8');
                 break;
             case 'mt_excerpt':
                 $this->_datamanager->types['abstract']->value = $value;
                 break;
             case 'description':
                 $this->_datamanager->types['content']->value = $value;
                 break;
             case 'link':
                 // TODO: We may have to bulletproof this a bit
                 $this->_datamanager->types['name']->value = str_replace('.html', '', basename($args[3]['link']));
                 break;
             case 'categories':
                 if (array_key_exists('categories', $this->_datamanager->types)) {
                     $this->_datamanager->types['categories']->selection = $value;
                     break;
                 }
             case 'http://www.georss.org/georss/':
                 if ($this->_positioning) {
                     foreach ($value as $feature => $val) {
                         switch ($feature) {
                             case 'point':
                                 $coordinates = explode(' ', $val);
                                 if (count($coordinates) != 2) {
                                     break;
                                 }
                                 $log = new org_routamc_positioning_log_dba();
                                 $log->date = $article->metadata->published;
                                 $log->latitude = (double) $coordinates[0];
                                 $log->longitude = (double) $coordinates[1];
                                 $log->accuracy = ORG_ROUTAMC_POSITIONING_ACCURACY_MANUAL;
                                 $log->create();
                                 break;
                         }
                         // TODO: Handle different relationshiptags as per http://georss.org/simple/
                     }
                 }
                 break;
         }
     }
     if (!$this->_datamanager->save()) {
         return new XML_RPC_Response(0, midcom_connection::get_error(), 'Failed to update article: ' . midgard_connection::get_error_string());
     }
     // TODO: Map the publish property to approval
     // Index the article
     $indexer = midcom::get('indexer');
     net_nehmer_blog_viewer::index($this->_datamanager, $indexer, $this->_content_topic);
     return new XML_RPC_Response(new XML_RPC_Value($article->guid, 'string'));
 }
コード例 #4
0
ファイル: object.php プロジェクト: nemein/openpsa
 /**
  * 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;
 }
コード例 #5
0
ファイル: log.php プロジェクト: nemein/openpsa
 /**
  * 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;
 }
コード例 #6
0
ファイル: weekreview.php プロジェクト: nemein/openpsa
 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;
     }
 }