/** * Get log object based on creation time and creator of the object * * @return midgardmvc_helper_location_log */ function seek_log_object($person = null, $time = null) { if (is_integer($person) || is_string($person)) { $person_guid = $person; } elseif (is_null($person)) { $person_guid = $this->object->metadata->creator; // TODO: Use metadata.authors? } else { $person_guid = $person->guid; } if (is_null($time)) { $time = $this->object->metadata->published; } $person = new midgard_person($person_guid); $qb = midgardmvc_helper_location_log::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(); if (count($matches) > 0) { return $matches[0]; } return null; }
public static function set_location_for_person(midgardmvc_helper_location_spot $spot, midgard_person $person) { // TODO: Check that we don't have a location matching this already from same day $log = new midgardmvc_helper_location_log(); $log->person = $person->id; $log->latitude = $spot->latitude; $log->longitude = $spot->longitude; $log->text = $spot->text; if ($spot->source) { $log->importer = $spot->source; } if ($spot->accuracy) { $log->accuracy = $spot->accuracy; } if (!is_null($spot->when)) { $log->metadata->published = $spot->when; } return $log->create(); }