diff --git a/actions/amap_maps_api/nearby_search.php b/actions/amap_maps_api/nearby_search.php
new file mode 100644
index 0000000..e80d5e6
--- /dev/null
+++ b/actions/amap_maps_api/nearby_search.php
@@ -0,0 +1,211 @@
+ 0)
+ $search_radius_txt = amap_ma_get_radius_string($s_radius);
+else
+ $search_radius_txt = amap_ma_get_default_radius_search_string();
+
+$s_radius = amap_ma_get_default_radius_search($s_radius);
+
+// retrieve coords of location asked, if any
+$coords = amap_ma_geocode_location($s_location);
+
+$title = elgg_echo('groupsmap:all');
+
+
+$options = array(
+ "type" => "group",
+ "full_view" => FALSE,
+ 'limit' => get_input('limit', 0),
+ 'offset' => get_input('proximity_offset', 0),
+ 'count' => false
+);
+
+
+$options['metadata_name_value_pairs'][] = array('name' => 'location', 'value' => '', 'operand' => '!=');
+$options['metadata_name_value_pairs'][] = array('name' => 'country', 'value' => '', 'operand' => '!=');
+$options['metadata_name_value_pairs_operator'] = 'OR';
+
+if ($initial_load) {
+ if ($initial_load == 'newest') {
+ $options['limit'] = amap_ma_get_initial_limit('groupsmap');
+ $title = elgg_echo('groupsmap:groups:newest', array($options['limit']));
+ } else if ($initial_load == 'location') {
+ // retrieve coords of location asked, if any
+ $user = elgg_get_logged_in_user_entity();
+ if ($user->location) {
+ $s_lat = $user->getLatitude();
+ $s_long = $user->getLongitude();
+
+ if ($s_lat && $s_long) {
+ $s_radius = amap_ma_get_initial_radius('groupsmap');
+ $search_radius_txt = $s_radius;
+ $s_radius = amap_ma_get_default_radius_search($s_radius);
+ $options = add_order_by_proximity_clauses($options, $s_lat, $s_long);
+ $options = add_distance_constraint_clauses($options, $s_lat, $s_long, $s_radius);
+
+ $title = elgg_echo('groupsmap:groups:nearby:search', array($user->location));
+ }
+ }
+ }
+} else {
+ if ($s_keyword) {
+ $db_prefix = elgg_get_config("dbprefix");
+ $query = sanitise_string($s_keyword);
+
+ $options["joins"] = array("JOIN {$db_prefix}groups_entity ge ON e.guid = ge.guid");
+ $where = "(ge.name LIKE '%$query%' OR ge.description LIKE '%$query%')";
+ $options["wheres"] = array($where);
+ }
+
+ if ($coords) {
+ $search_location_txt = $s_location;
+ $s_lat = $coords['lat'];
+ $s_long = $coords['long'];
+
+ if ($s_lat && $s_long) {
+ $options = add_order_by_proximity_clauses($options, $s_lat, $s_long);
+ $options = add_distance_constraint_clauses($options, $s_lat, $s_long, $s_radius);
+ }
+ $title = elgg_echo('groupsmap:groups:nearby:search', array($search_location_txt));
+ }
+}
+
+$groups = elgg_get_entities_from_metadata($options);
+
+$users = array();
+if (amap_ma_check_if_membersmap_gm_enabled()) {
+ $options1 = array('type' => 'user', 'full_view' => false);
+ $options1['limit'] =0;
+ $options1['metadata_name_value_pairs'] = array(array('name' => 'location', 'value' => '', 'operand' => '!='));
+ $users = elgg_get_entities_from_metadata($options1);
+ $indextable .= elgg_view('input/checkbox', array(
+ 'name' => 'chbx_user',
+ 'id' => 'chbx_user',
+ 'checked' => true,
+ )).'';
+
+ if ($users) {
+ foreach ($users as $entity) {
+ $entity = amap_ma_set_entity_additional_info($entity, 'name', 'description', $entity->location);
+ }
+ }
+}
+
+$pages = array();
+if (amap_ma_check_if_pagesmap_gm_enabled()) {
+ $array4 = array();
+ $options4 = array(
+ 'type' => 'object',
+ 'subtype' => array('page','page_top'),
+ 'full_view' => false,
+ 'limit' => 0,
+ );
+ $pages = elgg_get_entities($options4);
+
+ if ($pages) {
+ foreach ($pages as $entity) {
+ $entity = amap_ma_set_entity_additional_info($entity, 'title', 'description', $entity->location);
+ }
+ }
+
+ $indextable .= elgg_view('input/checkbox', array(
+ 'name' => 'chbx_pages',
+ 'id' => 'chbx_pages',
+ 'checked' => true,
+ )).'';
+}
+
+
+$entities1 = array_merge($users, $groups);
+$entities = array_merge($entities1, $pages);
+
+
+$map_objects = array();
+if ($entities) {
+
+ foreach ($entities as $entity) {
+ $entity = amap_ma_set_entity_additional_info($entity, 'name', 'briefdescription', groupsmap_get_group_location_str($entity));
+ }
+
+
+ foreach ($entities as $e) {
+ if ($e->getLatitude() && $e->getLongitude()) {
+ $object_x = array();
+ $object_x['guid'] = $e->getGUID();
+ $object_x['title'] = amap_ma_remove_shits($e->getVolatileData('m_title'));;
+ $object_x['description'] = amap_ma_get_entity_description($e->getVolatileData('m_description'));
+ $object_x['location'] = elgg_echo('amap_maps_api:location', array(amap_ma_remove_shits($e->getVolatileData('m_location'))));
+ $object_x['lat'] = $e->getLatitude();
+ $object_x['lng'] = $e->getLongitude();
+ $object_x['icon'] = $e->getVolatileData('m_icon');
+ $object_x['type'] = $e->getType().$e->getSubtype();
+ $object_x['other_info'] = $e->getVolatileData('m_other_info');
+ $object_x['map_icon'] = $e->getVolatileData('m_map_icon');
+ $object_x['info_window'] = $object_x['icon'].' '.$object_x['title'];
+ $object_x['info_window'] .= ($object_x['location']?'
'.$object_x['location']:'');
+ $object_x['info_window'] .= ($object_x['other_info']?'
'.$object_x['other_info']:'');
+ $object_x['info_window'] .= ($object_x['description']?'
'.$object_x['description']:'');
+ array_push($map_objects, $object_x);
+ }
+ }
+
+ $sidebar = '';
+ if (amap_ma_check_if_add_sidebar_list('groupsmap')) {
+ $box_color_flag = true;
+ foreach ($entities as $entity) {
+ $sidebar .= elgg_view('groupsmap/sidebar', array('entity' => $entity, 'box_color' => ($box_color_flag ? 'box_even' : 'box_odd')));
+ $box_color_flag = !$box_color_flag;
+ }
+ }
+}
+else {
+ $content = elgg_echo('amap_maps_api:search:personalized:empty');
+}
+
+$result = array(
+ 'error' => false,
+ 'title' => $title,
+ 'location' => $search_location_txt,
+ 'radius' => $search_radius_txt,
+ 's_radius' => amap_ma_get_default_radius_search($s_radius, true),
+ 's_radius_no' => $s_radius,
+ 'content' => $content,
+ 'map_objects' => json_encode($map_objects),
+ 's_location_lat' => ($s_lat? $s_lat: ''),
+ 's_location_lng' => ($s_long? $s_long: ''),
+ 's_location_txt' => $search_location_txt,
+ 'sidebar' => $sidebar,
+);
+
+// release variables
+unset($entities);
+unset($map_objects);
+
+echo json_encode($result);
+exit;
diff --git a/lib/amap_maps_api.php b/lib/amap_maps_api.php
index 9bca36f..9aadf88 100644
--- a/lib/amap_maps_api.php
+++ b/lib/amap_maps_api.php
@@ -1,10 +1,10 @@
600,
- ), $options);
+ ), $options);
$objects = find_active_users($options, 0, 0);
return $objects;
@@ -349,7 +349,7 @@ function amap_ma_not_permit_public_access() {
return false;
}
-// Check if membersmap is enabled for global map
+// Check if membersmap is enabled for global map
function amap_ma_check_if_membersmap_gm_enabled() {
$gm_membersmap = trim(elgg_get_plugin_setting('gm_membersmap', AMAP_MA_PLUGIN_ID));
@@ -360,7 +360,7 @@ function amap_ma_check_if_membersmap_gm_enabled() {
return false;
}
-// Check if groupsmap is enabled for global map
+// Check if groupsmap is enabled for global map
function amap_ma_check_if_groupsmap_gm_enabled() {
$gm_groupsmap = trim(elgg_get_plugin_setting('gm_groupsmap', AMAP_MA_PLUGIN_ID));
@@ -371,7 +371,7 @@ function amap_ma_check_if_groupsmap_gm_enabled() {
return false;
}
-// Check if agora is enabled for global map
+// Check if agora is enabled for global map
function amap_ma_check_if_agora_gm_enabled() {
$gm_agora = trim(elgg_get_plugin_setting('gm_agora', AMAP_MA_PLUGIN_ID));
@@ -382,7 +382,7 @@ function amap_ma_check_if_agora_gm_enabled() {
return false;
}
-// Check if pagesmap is enabled for global map
+// Check if pagesmap is enabled for global map
function amap_ma_check_if_pagesmap_gm_enabled() {
$gm_pagesmap = trim(elgg_get_plugin_setting('gm_pagesmap', AMAP_MA_PLUGIN_ID));
@@ -406,7 +406,7 @@ function amap_ma_get_entity_description($desc) {
$entity_description = preg_replace('/[^(\x20-\x7F)]*/', '', $desc);
$entity_description = amap_ma_remove_shits($entity_description);
- // code below replace the " with " from href of a tag.
+ // code below replace the " with " from href of a tag.
// The Regular Expression filter
$reg_exUrl = "/(http|https|ftp|ftps)\:\/\/[a-zA-Z0-9\-\.]+\.[a-zA-Z]{2,3}(\/\S*)?/";
// Check if there is a url in the text
@@ -450,10 +450,10 @@ function amap_ma_get_entity_icon($u) {
$user_icon = amap_ma_get_marker_icon('membersmap');
if ($user_icon == 'user_icon_tiny.png') {
$entity_icon = $u->getIconURL('tiny');
- }
+ }
else if ($user_icon == 'user_icon_small.png') {
$entity_icon = $u->getIconURL('small');
- }
+ }
else {
$entity_icon = elgg_get_site_url() . "mod/membersmap/graphics/{$user_icon}";
}
@@ -469,12 +469,12 @@ function amap_ma_get_entity_icon($u) {
}
else if (elgg_instanceof($u, 'object', 'lcourt')) {
$entity_icon = elgg_get_simplecache_url('leaguemanager/icon/icons/stadium.png');
- }
+ }
else if (elgg_instanceof($u, 'object', 'page') || elgg_instanceof($u, 'object', 'page_top')) {
//$entity_icon = elgg_get_site_url() . 'mod/pagesmap/graphics/' . amap_ma_get_marker_icon('pagesmap');
$entity_icon = elgg_get_simplecache_url('pagesmap/icon/' . amap_ma_get_marker_icon('pagesmap'));
}
-
+
return $entity_icon;
}
@@ -544,7 +544,7 @@ function amap_ma_get_initial_radius($pluginname) {
/**
* Assign to entity additional information for showing on map
- *
+ *
* @param type $entity
* @param type $etitle
* @param type $edescription
@@ -552,7 +552,7 @@ function amap_ma_get_initial_radius($pluginname) {
* @param type $eotherinfo
* @param type $m_icon_light: if need to give entity map icon opacity, set this to true
* @param type $eurl: if need to use other URL than standard entity URL, set this to true
- *
+ *
* @return Elgg Entity as given
*/
function amap_ma_set_entity_additional_info($entity, $etitle, $edescription, $elocation = null, $eotherinfo = null, $m_icon_light = false, $eurl = false) {
@@ -611,7 +611,7 @@ function amap_ma_set_entity_additional_info($entity, $etitle, $edescription, $el
$entity->setVolatileData('m_other_info', $eotherinfo);
}
$entity->setVolatileData('m_icon_light', $m_icon_light);
-
+
/* hide at the moment as the distance displayed is not well calculated
if ($user->getLatitude() && $user->getLongitude()) {
$distance = get_distance($entity->getLatitude(), $entity->getLongitude(), $user->getLatitude(), $user->getLongitude()); // distance in metres
diff --git a/pages/amap_maps_api/global.php b/pages/amap_maps_api/global.php
index c423eaa..dfb56b0 100644
--- a/pages/amap_maps_api/global.php
+++ b/pages/amap_maps_api/global.php
@@ -1,10 +1,10 @@
'location', 'value' => '', 'operand' => '!='));
$users = elgg_get_entities_from_metadata($options1);
$indextable .= elgg_view('input/checkbox', array(
- 'name' => 'chbx_user',
- 'id' => 'chbx_user',
+ 'name' => 'chbx_user',
+ 'id' => 'chbx_user',
'checked' => true,
- )).'';
-
+ )).'';
+
if ($users) {
foreach ($users as $entity) {
$entity = amap_ma_set_entity_additional_info($entity, 'name', 'description', $entity->location);
@@ -54,17 +55,17 @@
$groups = array();
if (amap_ma_check_if_groupsmap_gm_enabled()) {
- elgg_load_library('elgg:groupsmap');
+ elgg_load_library('elgg:groupsmap');
$options2 = array('type' => 'group', 'full_view' => false);
$options2['limit'] = 0;
$options2['metadata_name_value_pairs'] = array(array('name' => 'location', 'value' => '', 'operand' => '!='));
$groups = elgg_get_entities_from_metadata($options2);
$indextable .= elgg_view('input/checkbox', array(
- 'name' => 'chbx_group',
- 'id' => 'chbx_group',
+ 'name' => 'chbx_group',
+ 'id' => 'chbx_group',
'checked' => true,
- )).'';
-
+ )).'';
+
if ($groups) {
foreach ($groups as $entity) {
$entity = amap_ma_set_entity_additional_info($entity, 'name', 'briefdescription', groupsmap_get_group_location_str($entity));
@@ -79,16 +80,16 @@
'subtype' => 'agora',
'limit' => 0,
'full_view' => false,
- 'view_toggle_type' => false
+ 'view_toggle_type' => false
);
$options3['metadata_name_value_pairs'] = array(array('name' => 'location', 'value' => '', 'operand' => '!='));
$ads = elgg_get_entities_from_metadata($options3);
$indextable .= elgg_view('input/checkbox', array(
- 'name' => 'chbx_agora',
- 'id' => 'chbx_agora',
+ 'name' => 'chbx_agora',
+ 'id' => 'chbx_agora',
'checked' => true,
- )).'';
-
+ )).'';
+
if ($ads) {
foreach ($ads as $entity) {
$entity = amap_ma_set_entity_additional_info($entity, 'title', 'description');
@@ -102,66 +103,101 @@
$options4 = array(
'type' => 'object',
'subtype' => array('page','page_top'),
- 'full_view' => false,
+ 'full_view' => false,
'limit' => 0,
);
$pages = elgg_get_entities($options4);
-
+
if ($pages) {
foreach ($pages as $entity) {
$entity = amap_ma_set_entity_additional_info($entity, 'title', 'description', $entity->location);
}
- }
-
+ }
+
$indextable .= elgg_view('input/checkbox', array(
- 'name' => 'chbx_pages',
- 'id' => 'chbx_pages',
+ 'name' => 'chbx_pages',
+ 'id' => 'chbx_pages',
'checked' => true,
- )).'';
+ )).'';
}
if (!empty($indextable)) {
- $indextable = '