Example #1
0
 /**
  * Logs a user's location.
  *
  * @param WP $wp Wordpress object.
  * @return boolean True if the request was handled.
  */
 private static function location($wp)
 {
     if (isset($wp->query_vars['lat']) && isset($wp->query_vars['lon']) && isset($wp->query_vars['acc']) && isset($wp->query_vars['user-id']) && isset($wp->query_vars['collection-id'])) {
         $collection = get_post($wp->query_vars['collection-id']);
         if (!$collection) {
             return false;
         }
         $user = XMapsUser::get_user_by_api_key($wp->query_vars['key']);
         if ($user->id != $wp->query_vars['user-id']) {
             return false;
         }
         $geom = new Point($wp->query_vars['lon'], $wp->query_vars['lat']);
         $geom->setSRID(XMAPS_SRID);
         $wkt = new WKT();
         $location = $wkt->write($geom);
         XMapsDatabase::log_location($user->id, $wp->query_vars['key'], $wp->query_vars['collection-id'], $location, floatval($wp->query_vars['acc']));
         return true;
     }
     return false;
 }