Documentation is available at log.php
- <?php
- /**
- * @package org.routamc.positioning
- * @author The Midgard Project, http://www.midgard-project.org
- * @version $Id: log.php 3757 2006-07-27 14:32:42Z bergie $
- * @copyright The Midgard Project, http://www.midgard-project.org
- * @license http://www.gnu.org/licenses/lgpl.html GNU Lesser General Public License
- */
- /**
- * MidCOM wrapper class for user position log entries
- *
- * @package org.routamc.positioning
- */
- class org_routamc_positioning_log_dba extends __org_routamc_positioning_log_dba
- {
- function org_routamc_positioning_log_dba($id = null)
- {
- return parent::__org_routamc_positioning_log_dba($id);
- }
- /**
- * Returns the person who reported the position
- *
- * @return midcom_db_person Parent person
- */
- function get_parent_guid_uncached()
- {
- if ($this->person)
- {
- $parent = new midcom_db_person($this->person);
- if (! $parent)
- {
- debug_push_class(__CLASS__, __FUNCTION__);
- debug_add("Could not load Person ID {$this->person} from the database, aborting.",
- MIDCOM_LOG_INFO);
- debug_pop();
- return null;
- }
- return $parent->guid;
- }
- return null;
- }
- /**
- * Don't save log if previous log is in same place
- */
- function _on_creating()
- {
- $previous = $this->get_previous();
- if ( round($previous->longitude, 4) == round($this->longitude, 4)
- && round($previous->latitude, 4) == round($this->latitude, 4)
- && $previous->altitude == $this->altitude)
- {
- // We don't need to save duplicate entries
- return false;
- }
- return parent::_on_creating();
- }
- /**
- * Returns the previous log entry by the person
- *
- * @return org_routamc_positioning_log_dba Previous log entry
- */
- function get_previous()
- {
- $qb = org_routamc_positioning_log_dba::new_query_builder();
- $qb->add_constraint('person', '=', $this->person);
- $qb->add_constraint('date', '<', $this->date);
- $qb->add_order('date', 'DESC');
- $qb->set_limit(1);
- $matches = $qb->execute_unchecked();
- if (count($matches) > 0)
- {
- return $matches[0];
- }
- return null;
- }
- /**
- * Returns the next log entry by the person
- *
- * @return org_routamc_positioning_log_dba Next log entry
- */
- function get_next()
- {
- $qb = org_routamc_positioning_log_dba::new_query_builder();
- $qb->add_constraint('person', '=', $this->person);
- $qb->add_constraint('date', '>', $this->date);
- $qb->add_order('date', 'ASC');
- $qb->set_limit(1);
- $matches = $qb->execute_unchecked();
- if (count($matches) > 0)
- {
- return $matches[0];
- }
- return null;
- }
- function _claim_location_entries()
- {
- $previous = $this->get_previous();
- if (is_object($previous))
- {
- $qb = <a href="../org.routamc.positioning/org_routamc_positioning_location_dba.html">org_routamc_positioning_location_dba</a>::new_query_builder();
- // Find locations reported to previous log but after
- // this log's date
- $qb->add_constraint('log', '=', $previous->id);
- $qb->add_constraint('date', '>=', $this->date);
- $matches = $qb->execute();
- if (count($matches) > 0)
- {
- foreach ($matches as $location)
- {
- // Switch the location to point to this log
- $location->log = $this->id;
- $location->latitude = $this->latitude;
- $location->longitude = $this->longitude;
- $location->altitude = $this->altitude;
- $location->update();
- }
- }
- }
- }
- /**
- * Checks after log creation, switch cached location entries of objects
- * made after the previous log entry by the person and before this one.
- */
- function _on_created()
- {
- $this->_claim_location_entries();
- return true;
- }
- }
Documentation generated on Tue, 15 Aug 2006 12:41:25 +0300 by phpDocumentor 1.3.0RC3