diff --git a/addressbook/inc/class.addressbook_hooks.inc.php b/addressbook/inc/class.addressbook_hooks.inc.php
index 81cb356522..b6aa7ad822 100644
--- a/addressbook/inc/class.addressbook_hooks.inc.php
+++ b/addressbook/inc/class.addressbook_hooks.inc.php
@@ -526,7 +526,11 @@ class addressbook_hooks
$repositories['ldap'] = 'LDAP';
$repositories['sql-ldap'] = 'SQL --> LDAP ('.lang('read only').')';
}
-
+ // geolocation pre-defined maps
+ $geoLocation = array(
+ array('id' => 'http://maps.google.com/?q=%s+%t+%z+%c', 'label' => 'Google Maps'),
+ array('id' => 'https://www.bing.com/maps/?q=%s+%t+%z+%c', 'label' => 'Bing Maps')
+ );
$ret = array(
'sel_options' => array(
'own_account_acl' => $own_account_acl,
@@ -534,6 +538,7 @@ class addressbook_hooks
'copy_fields' => $copy_fields,
'fileas' => $bocontacts->fileas_options(),
'contact_repository' => $repositories,
+ 'geolocation_url' => $geoLocation
),
);
return $ret;
diff --git a/addressbook/inc/class.addressbook_ui.inc.php b/addressbook/inc/class.addressbook_ui.inc.php
index d878afcb19..bbc0ac7bf8 100644
--- a/addressbook/inc/class.addressbook_ui.inc.php
+++ b/addressbook/inc/class.addressbook_ui.inc.php
@@ -682,6 +682,25 @@ class addressbook_ui extends addressbook_bo
'hideOnMobile' => true
);
}
+
+ $actions['geolocation'] = array(
+ 'caption' => 'GeoLocation',
+ 'icon' => 'map',
+ //'enabled' => 'javaScript:app.addressbook.geoLocation',
+ 'group' => ++$group,
+ 'children' => array (
+ 'private' => array(
+ 'caption' => 'Private Address',
+ 'enabled' => 'javaScript:app.addressbook.geoLocation_enabled',
+ 'onExecute' => 'javaScript:app.addressbook.geoLocationExec'
+ ),
+ 'business' => array(
+ 'caption' => 'Buisness Address',
+ 'enabled' => 'javaScript:app.addressbook.geoLocation_enabled',
+ 'onExecute' => 'javaScript:app.addressbook.geoLocationExec'
+ )
+ )
+ );
// check if user is an admin or the export is not generally turned off (contact_export_limit is non-numerical, eg. no)
$exception = Api\Storage\Merge::is_export_limit_excepted();
if ((isset($GLOBALS['egw_info']['user']['apps']['admin']) || $exception) || !$this->config['contact_export_limit'] || (int)$this->config['contact_export_limit'])
diff --git a/addressbook/js/app.js b/addressbook/js/app.js
index 88b8a9ff4a..1e949208b1 100644
--- a/addressbook/js/app.js
+++ b/addressbook/js/app.js
@@ -912,5 +912,74 @@ app.classes.addressbook = AppJS.extend(
{
var widget = this.et2.getWidgetById('n_fn');
if(widget) return widget.options.value;
+ },
+
+ /**
+ * Enable/Disable geolocation action items in contextmenu base on address availabilty
+ *
+ * @param {action object} egw action
+ * @param {object} selected action row
+ *
+ * @returns {boolean} return false if no address found
+ */
+ geoLocation_enabled: function(_action, _selected)
+ {
+ var content = egw.dataGetUIDdata(_selected[0].id);
+ return this.geoLocationUrl(content.data,_action.id === 'business'?'one':'two');
+ },
+
+ /**
+ * Generate a geo location URL based on geolocation_url in
+ * site configuration
+ *
+ * @param {object} _data
+ * @param {string} _type type of address, it can be either 'one' as business
+ * or 'two' as private address.
+ *
+ * @returns {Boolean|string} return url and return false if no address
+ */
+ geoLocationUrl: function (_data, _type)
+ {
+ var type = _type || 'one';
+ var url = egw.config('geolocation_url');
+ if (url) url = url[0];
+
+ // exit if no url or invalide url given
+ if (!url || typeof url === 'undefined' || typeof url !== 'string')
+ {
+ egw.debug('warn','no url or invalid url given as geoLocationUrl');
+ return false;
+ }
+
+ // array of placeholders with their representing values
+ var ph = [
+ {id:'s',val:_data['adr_'+type+'_street']},
+ {id:'t',val:_data['adr_'+type+'_locality']},
+ {id:'c',val:_data['adr_'+type+'_countrycode']},
+ {id:'z',val:_data['adr_'+type+'_postalcode']}
+ ];
+ var empty = true;
+
+ // Replcae placeholders with acctual values
+ for (var i=0;i < ph.length; i++)
+ {
+ empty = ph[i]['val']? false : true;
+ url = url.replace('%'+ph[i]['id'], ph[i]['val']? ph[i]['val'] : "");
+ }
+
+ return (url !== '' && !empty ? url:false);
+ },
+
+ /**
+ * Open a popup base on selected address in provided map
+ *
+ * @param {object} _action
+ * @param {object} _selected
+ */
+ geoLocationExec: function (_action, _selected)
+ {
+ var content = egw.dataGetUIDdata(_selected[0].id);
+ var url = this.geoLocationUrl(content.data,_action.id === 'business'?'one':'two');
+ window.open(url,'_blank');
}
});
diff --git a/addressbook/templates/default/config.xet b/addressbook/templates/default/config.xet
index 0412ba728e..283522ecf3 100644
--- a/addressbook/templates/default/config.xet
+++ b/addressbook/templates/default/config.xet
@@ -16,6 +16,13 @@
+
+
+
+
+
+
+
diff --git a/api/src/Config.php b/api/src/Config.php
index 7e68d600d3..efcb5c38cc 100755
--- a/api/src/Config.php
+++ b/api/src/Config.php
@@ -262,7 +262,7 @@ class Config
'checkfornewversion','checkappversions','email_address_format', // admin >> site config
'site_title','login_logo_file','login_logo_url','login_logo_title','favicon_file',
'markuntranslated','link_list_thumbnail','enabled_spellcheck','debug_minify',
- 'call_link','call_popup', // addressbook
+ 'call_link','call_popup','geolocation_url', // addressbook
'hide_birthdays','calview_no_consolidate', 'egw_tutorial_disable','fw_mobile_app_list'), // calendar
'projectmanager' => array('hours_per_workday', 'duration_units'),
'manual' => array('manual_remote_egw_url'),