public static function serve()
 {
     $me = new Agm_Bp_Pm_UserPages();
     $me->_add_hooks();
 }
 function json_bp_rebuild_profile_map()
 {
     if (!class_exists('Agm_Bp_Pm_UserPages')) {
         die(-1);
     }
     global $wpdb;
     header('Content-type: application/json');
     $sql = "SELECT DISTINCT ID FROM {$wpdb->users} WHERE ID NOT IN (SELECT DISTINCT ID FROM {$wpdb->users} as user, {$wpdb->usermeta} as meta WHERE user.ID=meta.user_id AND meta_key='agm-bp-profile_maps-location') LIMIT 1";
     $user_id = (int) $wpdb->get_var($sql);
     $model = new AgmMapModel();
     $opts = apply_filters('agm_google_maps-options-bp_profile_maps', get_option('agm_google_maps'));
     $address = bp_get_profile_field_data(array('field' => @$opts['bp_profile_maps-address_field'], 'user_id' => $user_id));
     // Skip this guy
     if (!$address) {
         die(json_encode(array('user_id' => $user_id)));
     }
     $location = $model->_address_to_marker($address);
     if ($location) {
         $location['body'] = Agm_Bp_Pm_UserPages::get_location_body($user_id, $address);
     }
     update_user_meta($user_id, 'agm-bp-profile_maps-location', $location);
     die(json_encode(array('user_id' => $user_id)));
 }
 private function _get_group_map($group_id, $data_overrides = array())
 {
     $data_overrides = wp_parse_args($data_overrides, array('show_members' => true));
     $data = groups_get_groupmeta($group_id, "agm-group_map");
     $model = new AgmMapModel();
     $map_id = get_option("_agm-group_map-for-{$group_id}", false);
     $address = !empty($data["address"]) ? $data["address"] : apply_filters('agm-group_map-default_group_address', false, $group_id, $data);
     $map = false;
     if ($map_id) {
         $map = $model->get_map($map_id);
     } else {
         if (!$map_id && $address) {
             $map_id = $model->autocreate_map(false, false, false, $address);
             if (!$map_id) {
                 return false;
             }
             update_option("_agm-group_map-for-{$group_id}", $map_id);
             $map = $model->get_map($map_id);
         } else {
             $map = $model->get_map_defaults();
             $map['defaults'] = $model->get_map_defaults();
             $map['id'] = $group_id . md5(time() . rand());
             $map['show_map'] = 1;
             $map['show_markers'] = 0;
             $map['markers'] = array();
         }
     }
     if (!empty($data_overrides['group_marker']) && 'avatar' == $data_overrides['group_marker'] && function_exists('bp_core_fetch_avatar')) {
         if (1 != count($map['markers'])) {
             continue;
         }
         if (empty($map['markers'][0])) {
             continue;
         }
         $avatar = bp_core_fetch_avatar(array('object' => 'group', 'item_id' => $group_id, 'width' => 32, 'height' => 32, 'html' => false));
         if (!empty($avatar)) {
             $map['markers'][0]['icon'] = $avatar;
         }
     }
     if (!empty($data['member_locations']) && !empty($data_overrides['show_members']) && class_exists('Agm_Bp_Pm_UserPages')) {
         $profile = new Agm_Bp_Pm_UserPages();
         $markers = $map['markers'];
         $members = groups_get_group_members($group_id);
         if ($members && !empty($members['members'])) {
             foreach ($members['members'] as $member) {
                 $marker = $profile->member_to_marker($member->ID);
                 if ($marker) {
                     $markers[] = $marker;
                 }
             }
         }
         $map['markers'] = $markers;
     }
     if (empty($map['markers'])) {
         return false;
     }
     return $map;
 }