/**
  * 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;
 }
Beispiel #2
0
<?php

if (!is_user_logged_in()) {
    auth_redirect();
}
$api_key = XMapsUser::get_api_key_by_user(wp_get_current_user());
?>
<!DOCTYPE html>
<html>
	<head>
		<meta charset="utf-8">
		<title>Collections</title>
		<?php 
wp_head();
?>
	</head>
	<body>
		<div id="collection-list"></div>
		<script type="text/javascript">
			jQuery( function( $ ) {

				function render_list( d ) {
					var ul = $( document.createElement( "ul" ) );
					$.each( d.data, function( i, e ) {
						var li = $( document.createElement( "li" ) );
						li.html( "<h3><a href=\"collection?id=" + e.term_id 
								+ "\">" + e.name + "</a></h3><p>" 
								+ e.description + "</p>" );
						ul.append( li );
					} );
					$( "#collection-list" ).append( ul );
Beispiel #3
0
		jQuery(function($) {
			XMAPS.CollectionXMap($("#xmap-' . $uuid . '"));
		});
		</script>
		';
});
add_filter('query_vars', function ($vars) {
    $vars[] = 'id';
    $vars[] = 'key';
    $vars[] = 'lat';
    $vars[] = 'lon';
    $vars[] = 'acc';
    $vars[] = 'user-id';
    $vars[] = 'collection-id';
    $vars[] = 'post-id';
    $vars[] = 'period';
    return $vars;
});
add_action('parse_request', function ($wp) {
    if (strpos($wp->request, 'xmaps-api/') === 0) {
        if (XMapsWAAPI::parse_request($wp)) {
            exit;
        }
    }
});
add_action('edit_user_profile', function ($user) {
    XMapsUser::show_profile_fields($user);
});
add_action('show_user_profile', function ($user) {
    XMapsUser::show_profile_fields($user);
});