mirror of
https://github.com/EGroupware/egroupware.git
synced 2024-12-22 14:41:29 +01:00
Implement geolocation option for contacts in addressbook
This commit is contained in:
parent
154ccb70c8
commit
5ef5cacd62
@ -526,7 +526,11 @@ class addressbook_hooks
|
|||||||
$repositories['ldap'] = 'LDAP';
|
$repositories['ldap'] = 'LDAP';
|
||||||
$repositories['sql-ldap'] = 'SQL --> LDAP ('.lang('read only').')';
|
$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(
|
$ret = array(
|
||||||
'sel_options' => array(
|
'sel_options' => array(
|
||||||
'own_account_acl' => $own_account_acl,
|
'own_account_acl' => $own_account_acl,
|
||||||
@ -534,6 +538,7 @@ class addressbook_hooks
|
|||||||
'copy_fields' => $copy_fields,
|
'copy_fields' => $copy_fields,
|
||||||
'fileas' => $bocontacts->fileas_options(),
|
'fileas' => $bocontacts->fileas_options(),
|
||||||
'contact_repository' => $repositories,
|
'contact_repository' => $repositories,
|
||||||
|
'geolocation_url' => $geoLocation
|
||||||
),
|
),
|
||||||
);
|
);
|
||||||
return $ret;
|
return $ret;
|
||||||
|
@ -682,6 +682,25 @@ class addressbook_ui extends addressbook_bo
|
|||||||
'hideOnMobile' => true
|
'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)
|
// 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();
|
$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'])
|
if ((isset($GLOBALS['egw_info']['user']['apps']['admin']) || $exception) || !$this->config['contact_export_limit'] || (int)$this->config['contact_export_limit'])
|
||||||
|
@ -912,5 +912,74 @@ app.classes.addressbook = AppJS.extend(
|
|||||||
{
|
{
|
||||||
var widget = this.et2.getWidgetById('n_fn');
|
var widget = this.et2.getWidgetById('n_fn');
|
||||||
if(widget) return widget.options.value;
|
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');
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
@ -16,6 +16,13 @@
|
|||||||
<description value="URL to link telephone numbers to (use %1 = number to call, %u = account name, %t = account phone)" label="%s:"/>
|
<description value="URL to link telephone numbers to (use %1 = number to call, %u = account name, %t = account phone)" label="%s:"/>
|
||||||
<textbox id="newsettings[call_link]" size="40"/>
|
<textbox id="newsettings[call_link]" size="40"/>
|
||||||
</row>
|
</row>
|
||||||
|
<row>
|
||||||
|
<description value="GeoLocation integration" span="all" class="subHeader"/>
|
||||||
|
</row>
|
||||||
|
<row>
|
||||||
|
<description value="Choose pre-defined map source or use custom URL (use %s = street, %t = town, %c = country, %z = zipcode)"/>
|
||||||
|
<taglist id="newsettings[geolocation_url]" maxSelection="1" empty_label="Select a map or write an URL"/>
|
||||||
|
</row>
|
||||||
<row>
|
<row>
|
||||||
<description value="Size of popup (WxH, eg.400x300, if a popup should be used)" label="%s:"/>
|
<description value="Size of popup (WxH, eg.400x300, if a popup should be used)" label="%s:"/>
|
||||||
<textbox id="newsettings[call_popup]" size="10"/>
|
<textbox id="newsettings[call_popup]" size="10"/>
|
||||||
|
@ -262,7 +262,7 @@ class Config
|
|||||||
'checkfornewversion','checkappversions','email_address_format', // admin >> site config
|
'checkfornewversion','checkappversions','email_address_format', // admin >> site config
|
||||||
'site_title','login_logo_file','login_logo_url','login_logo_title','favicon_file',
|
'site_title','login_logo_file','login_logo_url','login_logo_title','favicon_file',
|
||||||
'markuntranslated','link_list_thumbnail','enabled_spellcheck','debug_minify',
|
'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
|
'hide_birthdays','calview_no_consolidate', 'egw_tutorial_disable','fw_mobile_app_list'), // calendar
|
||||||
'projectmanager' => array('hours_per_workday', 'duration_units'),
|
'projectmanager' => array('hours_per_workday', 'duration_units'),
|
||||||
'manual' => array('manual_remote_egw_url'),
|
'manual' => array('manual_remote_egw_url'),
|
||||||
|
Loading…
Reference in New Issue
Block a user