Run addressbook by et2

This commit is contained in:
Hadi Nategh 2013-09-20 10:50:48 +00:00
parent 552761113b
commit 7481c0a23c
5 changed files with 446 additions and 319 deletions

View File

@ -68,7 +68,7 @@ class addressbook_ui extends addressbook_bo
{
parent::__construct($contact_app);
$this->tmpl = new etemplate();
$this->tmpl = new etemplate_new();
$this->org_views = array(
'org_name' => lang('Organisations'),
@ -76,13 +76,6 @@ class addressbook_ui extends addressbook_bo
'org_name,org_unit' => lang('Organisations by departments'),
);
// our javascript
// to be moved in a seperate file if rewrite is over
if (strpos($GLOBALS['egw_info']['flags']['java_script'],'add_new_list') === false)
{
$GLOBALS['egw_info']['flags']['java_script'].= $this->js();
}
// make sure the hook for export_limit is registered
if (!$GLOBALS['egw']->hooks->hook_exists('export_limit','addressbook')) $GLOBALS['egw']->hooks->register_single_app_hook('addressbook','export_limit');
@ -221,7 +214,7 @@ class addressbook_ui extends addressbook_bo
'lettersearch' => true,
'do_email' => $do_email ? 1 : 0,
'default_cols' => '!cat_id,contact_created_contact_modified,distribution_list,contact_id,owner,legacy_actions',
'filter2_onchange' => "if(this.value=='add') { add_new_list(typeof widget == 'undefined' ? document.getElementById('exec[nm][filter]').value : widget.header.filter.get_value()); this.value='';} else this.form.submit();",
'filter2_onchange' => "app.addressbook.filter2_onchange();",
'manual' => $do_email ? ' ' : false, // space for the manual icon
//'actions' => $this->get_actions(), // set on each request, as it depends on some filters
'row_id' => 'id',
@ -235,9 +228,7 @@ class addressbook_ui extends addressbook_bo
if ($do_email)
{
$content['nm']['filter2_onchange'] = str_replace('this.form.submit();',
"{ if (this.value && confirm('".lang('Add emails of whole distribution list?')."')) add_whole_list(this.value); else this.form.submit(); }",
$content['nm']['filter2_onchange']);
$content['nm']['filter2_onchange'] = 'app.addressbook.filter2_onchange_email();';
}
// use the state of the last session stored in the user prefs
if (($state = @unserialize($this->prefs[$do_email ? 'email_state' : 'index_state'])))
@ -339,7 +330,7 @@ class addressbook_ui extends addressbook_bo
}
$content['nm']['org_view_label'] = $sel_options['org_view'][(string) $content['nm']['org_view']];
$this->tmpl->read(/*$do_email ? 'addressbook.email' :*/ 'addressbook.index');
$this->tmpl->read($do_email ? 'addressbook.email' : 'addressbook.index');
return $this->tmpl->exec($do_email ? 'addressbook.addressbook_ui.emailpopup' : 'addressbook.addressbook_ui.index',
$content,$sel_options,$readonlys,$preserv,$do_email ? 2 : 0);
}
@ -427,11 +418,13 @@ class addressbook_ui extends addressbook_bo
'email' => array(
'caption' => lang('Add %1',lang('business email')),
'no_lang' => true,
'onExecute' => 'javaScript:app.addressbook.addEmail',
'group' => ++$group,
),
'email_home' => array(
'caption' => lang('Add %1',lang('home email')),
'no_lang' => true,
'onExecute' => 'javaScript:app.addressbook.addEmail',
'group' => $group,
),
);
@ -473,7 +466,7 @@ class addressbook_ui extends addressbook_bo
'list_add' => array(
'caption' => 'Add a new list',
'icon' => 'new',
'onExecute' => 'javaScript:add_new_list',
'onExecute' => 'javaScript:app.addressbook.add_new_list',
),
),
'group' => $group,
@ -493,7 +486,7 @@ class addressbook_ui extends addressbook_bo
'caption' => 'Remove from distribution list',
'confirm' => 'Remove selected contacts from distribution list',
'icon' => 'foldertree_nolines_minus',
'enabled' => 'javaScript:nm_compare_field',
'enabled' => 'javaScript:app.addressbook.nm_compare_field',
'fieldId' => 'exec[nm][filter2]',
'fieldValue' => '!', // enable if list != ''
),
@ -501,7 +494,7 @@ class addressbook_ui extends addressbook_bo
'caption' => 'Delete selected distribution list!',
'confirm' => 'Delete selected distribution list!',
'icon' => 'delete',
'enabled' => 'javaScript:nm_compare_field',
'enabled' => 'javaScript:app.addressbook.nm_compare_field',
'fieldId' => 'exec[nm][filter2]',
'fieldValue' => '!', // enable if list != ''
),
@ -556,7 +549,7 @@ class addressbook_ui extends addressbook_bo
'icon' => 'new',
'url' => 'menuaction=infolog.infolog_ui.edit&type=task&action=addressbook&action_id=$id',
'popup' => egw_link::get_registry('infolog', 'add_popup'),
'onExecute' => 'javaScript:add_task', // call server for org-view only
'onExecute' => 'javaScript:app.addressbook.add_task', // call server for org-view only
),
)
);
@ -572,7 +565,7 @@ class addressbook_ui extends addressbook_bo
'caption' => 'Show',
'icon' => 'view',
'url' => 'menuaction=calendar.calendar_uilist.listview&filter=all&owner=0,c$id',
'onExecute' => 'javaScript:add_cal', // call server for org-view only
'onExecute' => 'javaScript:app.addressbook.add_cal', // call server for org-view only
'targetapp' => 'calendar', // open in calendar tab
),
'calendar_add' => array(
@ -580,7 +573,7 @@ class addressbook_ui extends addressbook_bo
'icon' => 'new',
'url' => 'menuaction=calendar.calendar_uiforms.edit&participants=c$id',
'popup' => egw_link::get_registry('calendar', 'add_popup'),
'onExecute' => 'javaScript:add_cal', // call server for org-view only
'onExecute' => 'javaScript:app.addressbook.add_cal', // call server for org-view only
),
),
);
@ -628,7 +621,7 @@ class addressbook_ui extends addressbook_bo
'caption' => lang('Mail VCard'),
'icon' => 'filemanager/mail_post_to',
'group' => $group,
'onExecute' => 'javaScript:adb_mail_vcard',
'onExecute' => 'javaScript:app.addressbook.adb_mail_vcard',
);
}
++$group;
@ -751,7 +744,7 @@ window.egw_LAB.wait(function() {
$query['filter2'] = (int)$list;
$this->action($email_type,array(),true,$success,$failed,$action_msg,$query,$msg);
$response = new xajaxResponse();
$response = egw_json_response::get();
if ($success) $response->addScript(egw_framework::set_onload(''));
@ -771,7 +764,7 @@ window.egw_LAB.wait(function() {
$response->addScript("alert('".addslashes($msg)."')");
$response->addScript('window.close();');
}
return $response->getXML();
}
/**
@ -995,6 +988,7 @@ window.egw_LAB.wait(function() {
case 'email':
case 'email_home':
error_log(__METHOD__. "() email");
$action == 'email' ? $action_fallback = 'email_home' : $action_fallback = 'email';
$action_msg = lang('added');
if($contact = $this->read($id))
@ -1669,24 +1663,28 @@ window.egw_LAB.wait(function() {
{
egw_link::link('addressbook',$content['id'],$links);
}
$content['js'] = "opener.egw_refresh('".str_replace("'","\\'",$content['msg'])."','addressbook','{$content['id']}', '" . ($content['id'] ? 'update' : 'add') . "', opener.egw_getAppName());";
$currentApp = $GLOBALS['egw']->currentapp;
error_log(__METHOD__. "() currentapp:" . $currentApp);
egw_framework::refresh_opener($content['msg'], 'addressbook',$content['id'], ($content['id'] ? 'update' : 'add'));
if ($button == 'save')
{
$content['js'] .= ' window.close();';
echo '<html><body onload="'.$content['js'].'"></body></html>';
common::egw_exit();
egw_framework::window_close();
}
$content['link_to']['to_id'] = $content['id'];
$GLOBALS['egw_info']['flags']['java_script'] .= "<script>{$content['js']}</script>";
break;
case 'delete':
if($this->action('delete',array($content['id']),false,$success,$failed,$action_msg,'',$content['msg']))
{
$js = "opener.egw_refresh('".str_replace("'","\\'",lang('Contact deleted'))."','addressbook','{$content['id']}','delete'); if(opener.egw_getAppName() != 'addressbook') { opener.egw_refresh('".str_replace("'","\\'",lang('Contact deleted'))."','addressbook','{$content['id']}',null,'addressbook');} window.close();";
echo '<html><body onload="'.$js.'"></body></html>';
common::egw_exit();
if ($GLOBALS['egw']->currentapp == 'addressbook')
{
egw_framework::refresh_opener(lang('Contact deleted'), 'addressbook', $content['id'], 'delete' );
}
else
{
egw_framework::refresh_opener(lang('Contact deleted'), 'addressbook', $content['id'], null, 'addressbook');
egw_framework::window_close();
}
}
else
{
@ -1771,7 +1769,7 @@ window.egw_LAB.wait(function() {
{
if (!empty($content[$field]))
{
egw_framework::set_onload("check_value(document.getElementById('exec[$field]'),0);");
egw_framework::set_onload("app.addressbook.check_value(document.getElementById('exec[$field]'),0);");
break;
}
}
@ -1839,8 +1837,6 @@ window.egw_LAB.wait(function() {
// how to display addresses
$content['addr_format'] = $this->addr_format_by_country($content['adr_one_countryname']);
$content['addr_format2'] = $this->addr_format_by_country($content['adr_two_countryname']);
$GLOBALS['egw']->js->set_onload('show_custom_country($j(\'select[id*="adr_one_countrycode"]\').get(0));');
$GLOBALS['egw']->js->set_onload('show_custom_country($j(\'select[id*="adr_two_countrycode"]\').get(0));');
//_debug_array($content);
$readonlys['button[delete]'] = !$content['owner'] || !$this->check_perms(EGW_ACL_DELETE,$content);
@ -1919,7 +1915,7 @@ window.egw_LAB.wait(function() {
if ($content['private']) $content['owner'] .= 'p';
$GLOBALS['egw_info']['flags']['include_xajax'] = true;
//$GLOBALS['egw_info']['flags']['include_xajax'] = true;
if (!$this->tmpl->read($this->content_types[$content['tid']]['options']['template'] ? $this->content_types[$content['tid']]['options']['template'] : 'addressbook.edit'))
{
@ -2219,7 +2215,7 @@ window.egw_LAB.wait(function() {
if(!empty($_content))
{
$do_email = $_content['do_email'];
$response = new xajaxResponse();
$response = egw_json_response::get();
$query = egw_session::appsession($do_email ? 'email' : 'index','addressbook');
@ -2242,23 +2238,16 @@ window.egw_LAB.wait(function() {
// store the advanced search in the session to call it again
egw_session::appsession('advanced_search','addressbook',$query['advanced_search']);
$response->addScript("
var link = this.opener.location.href;
link = link.replace(/#/,'');
this.opener.location.href=link.replace(/\#/,'');
this.xajax_eT_wrapper();
");
if ($_content['button']['cancel']) $response->addScript('this.close();');
return $response->getXML();
error_log(__METHOD__. "() call ADV" );
if ($_content['button']['search']) $response->call("app.addressbook.adv_search");
if ($_content['button']['cancel']) egw_framework::window_close (); //$response->addScript('this.close();');
}
else
{
$do_email = strpos($_SERVER['HTTP_REFERER'],'emailpopup') !== false;
}
$GLOBALS['egw_info']['flags']['include_xajax'] = true;
$GLOBALS['egw_info']['flags']['java_script'] .= "<script>window.egw_LAB.wait(function() {window.focus();});</script>";
//$GLOBALS['egw_info']['flags']['include_xajax'] = true;
//$GLOBALS['egw_info']['flags']['java_script'] .= "<script>window.egw_LAB.wait(function() {window.focus();});</script>";
$GLOBALS['egw_info']['etemplate']['advanced_search'] = true;
// initialize etemplate arrays
@ -2341,68 +2330,6 @@ window.egw_LAB.wait(function() {
}
}
/**
* Dynamic javascript functions
*
* All static stuff should go to addressbook/js/app.js
*
* @return string
*/
function js()
{
list($width,$height) = explode('x',egw_link::get_registry('felamimail','add_popup'));
return '<script LANGUAGE="JavaScript">
window.egw_LAB.wait(function() {
function adb_mail_vcard(_action, _elems)
{
var link = "'.egw::link('/index.php',array('menuaction' => 'felamimail.uicompose.compose')).'";
for (var i = 0; i < _elems.length; i++)
{
link += "&preset[file][]="+encodeURIComponent("vfs://default/apps/addressbook/"+_elems[i].id+"/.entry");
}
'."egw_openWindowCentered2(link, '_blank', $width, $height, 'yes');".'
}
function adb_get_selection(form)
{
var use_all = document.getElementById("exec[use_all]");
var action = document.getElementById("exec[action]");
egw_openWindowCentered(
"'. egw::link('/index.php','menuaction=importexport.uiexport.export_dialog&appname=addressbook').
'&selection="+( use_all.checked ? "use_all" : get_selected(form,"[rows][checked][]")),
"Export",400,400);
action.value="";
use_all.checked = false;
return false;
}
function do_action(selbox)
{
if (selbox.value != "") {
if (selbox.value == "infolog_add" && (ids = get_selected(selbox.form,"[rows][checked][]")) && !document.getElementById("exec[use_all]").checked) {
win=window.open("'.egw::link('/index.php','menuaction=infolog.infolog_ui.edit&type=task&action=addressbook&action_id=').'"+ids,"_blank","width=750,height=550,left=100,top=200");
win.focus();
} else if (selbox.value == "cat_add") {
win=window.open("'.egw::link('/etemplate/process_exec.php','menuaction=addressbook.addressbook_ui.cat_add').'","_blank","width=300,height=400,left=100,top=200");
win.focus();
} else if (selbox.value == "remove_from_list") {
if (confirm("'.lang('Remove selected contacts from distribution list').'")) selbox.form.submit();
} else if (selbox.value == "delete_list") {
if (confirm("'.lang('Delete selected distribution list!').'")) selbox.form.submit();
} else if (selbox.value == "delete") {
if (confirm("'.lang('Delete').'")) selbox.form.submit();
} else {
selbox.form.submit();
}
selbox.value = "";
}
}
});
</script>';
}
/**
* Migrate contacts to or from LDAP (called by Admin >> Addressbook >> Site configuration (Admin only)
*

View File

@ -1,215 +1,415 @@
/**
* EGroupware addressbook static javascript code
* EGroupware - Addressbook - Javascript UI
*
* @license http://opensource.org/licenses/gpl-license.php GPL - GNU General Public License
* @package addressbook
* @link http://www.egroupware.org
* @author Ralf Becker <RalfBecker@outdoor-training.de>
* @version $Id$
* @package addressbook
* @author Hadi Nategh <hn-AT-stylite.de>
* @copyright (c) 2008-13 by Ralf Becker <RalfBecker-AT-outdoor-training.de>
* @license http://opensource.org/licenses/gpl-license.php GPL - GNU General Public License
* @version $id
*/
/**
* Add appointment or show calendar for selected contacts, call default nm_action after some checks
*
* @param _action
* @param _senders
* UI for Addressbook
*
* @augments AppJS
*/
function add_cal(_action, _senders)
app.addressbook = AppJS.extend(
{
if (!_senders[0].id.match(/^[0-9]+$/))
appname: 'addressbook',
/**
* et2 widget container
*/
et2: null,
/**
* path widget
*/
/**
* Constructor
*
* @memberOf app.addressbook
*/
init: function()
{
// send org-view requests to server
_action.data.nm_action = "submit";
}
else
// call parent
this._super.apply(this, arguments);
},
/**
* Destructor
*/
destroy: function()
{
// call nm_action's popup, but already replace id's in url, because they need to be prefix with a "c"
if (_action.data.popup) _action.data.nm_action = "popup";
var ids = "";
for (var i = 0; i < _senders.length; i++)
//delete this.et2;
// call parent
this._super.apply(this, arguments);
},
/**
* This function is called when the etemplate2 object is loaded
* and ready. If you must store a reference to the et2 object,
* make sure to clean it up in destroy().
*
* @param _et2 etemplate2 Newly ready object
*/
et2_ready: function(et2)
{
// call parent
this._super.apply(this, arguments);
if (typeof et2.templates['addressbook.edit'] != 'undefined')
{
ids += "c" + _senders[i].id + ((i < _senders.length - 1) ? "," : "");
this.show_custom_country($j('select[id*="adr_one_countrycode"]').get(0));
this.show_custom_country($j('select[id*="adr_two_countrycode"]').get(0));
}
// we cant just replace $id, as under jdots this can get called multiple times (with already replaced url)!
_action.data.url = _action.data.url.replace(/(owner|participants)=(0%2C)?[^&]+/,"$1=$2"+ids);
}
nm_action(_action, _senders);
}
/**
* Add task for selected contacts, call default nm_action after some checks
*
* @param _action
* @param _senders
*/
function add_task(_action, _senders)
{
if (!_senders[0].id.match(/^(addressbook::)?[0-9]+$/))
jQuery('select[id*="adr_one_countrycode"]').each(function() {
app.addressbook.show_custom_country(this);
});
jQuery('select[id*="adr_two_countrycode"]').each(function() {
app.addressbook.show_custom_country(this);
});
},
/**
* Add appointment or show calendar for selected contacts, call default nm_action after some checks
*
* @param _action
* @param _senders
*/
add_cal: function(_action, _senders)
{
// send org-view requests to server
_action.data.nm_action = "submit";
}
else
{
// call nm_action's popup
_action.data.nm_action = "popup";
}
nm_action(_action, _senders);
}
function showphones(form)
{
if (form) {
copyvalues(form,"tel_home","tel_home2");
copyvalues(form,"tel_work","tel_work2");
copyvalues(form,"tel_cell","tel_cell2");
copyvalues(form,"tel_fax","tel_fax2");
}
}
function hidephones(form)
{
if (form) {
copyvalues(form,"tel_home2","tel_home");
copyvalues(form,"tel_work2","tel_work");
copyvalues(form,"tel_cell2","tel_cell");
copyvalues(form,"tel_fax2","tel_fax");
}
}
function copyvalues(form,src,dst)
{
var srcelement = getElement(form,src); //ById("exec["+src+"]");
var dstelement = getElement(form,dst); //ById("exec["+dst+"]");
if (srcelement && dstelement) {
dstelement.value = srcelement.value;
}
}
function getElement(form,pattern)
{
for (i = 0; i < form.length; i++){
if(form.elements[i].name){
var found = form.elements[i].name.search("\\["+pattern+"\\]");
if (found != -1){
return form.elements[i];
}
}
}
}
function check_value(input, own_id)
{
var values = egw_json_getFormValues(input.form).exec; // todo use eT2 method, if running under et2
if(typeof values == 'undefined' && typeof etemplate2 != 'undefined') {
var template = etemplate2.getByApplication('addressbook')[0];
values = template.getValues(template.widgetContainer);
}
if (input.name.match(/n_/))
{
var value = '';
if (values.n_prefix) value += values.n_prefix+" ";
if (values.n_given) value += values.n_given+" ";
if (values.n_middle) value += values.n_middle+" ";
if (values.n_family) value += values.n_family+" ";
if (values.n_suffix) value += values.n_suffix;
var name = document.getElementById("exec[n_fn]");
if(name == null && template)
if (!_senders[0].id.match(/^[0-9]+$/))
{
name = template.widgetContainer.getWidgetById('n_fn');
name.set_value(value);
// send org-view requests to server
_action.data.nm_action = "submit";
}
else
{
name.value = value;
}
}
var req = new egw_json_request('addressbook.addressbook_ui.ajax_check_values', [values, input.name, own_id]);
req.sendRequest(true, function(data) {
if (data.msg && confirm(data.msg))
{
for(var id in data.doublicates)
// call nm_action's popup, but already replace id's in url, because they need to be prefix with a "c"
if (_action.data.popup) _action.data.nm_action = "popup";
var ids = "";
for (var i = 0; i < _senders.length; i++)
{
egw.open(id, 'addressbook');
//opener.egw_openWindowCentered2(egw_webserverUrl+'/index.php?menuaction=addressbook.addressbook_ui.edit&contact_id='+id, '_blank', 870, 480, 'yes', 'addressbook');
ids += "c" + _senders[i].id + ((i < _senders.length - 1) ? "," : "");
}
// we cant just replace $id, as under jdots this can get called multiple times (with already replaced url)!
_action.data.url = _action.data.url.replace(/(owner|participants)=(0%2C)?[^&]+/,"$1=$2"+ids);
}
if (typeof data.fileas_options == 'object')
nm_action(_action, _senders);
},
/**
* Add task for selected contacts, call default nm_action after some checks
*
* @param _action
* @param _senders
*/
add_task: function(_action, _senders)
{
if (!_senders[0].id.match(/^(addressbook::)?[0-9]+$/))
{
var selbox = document.getElementById("exec[fileas_type]");
if (selbox)
{
for (var i=0; i < data.fileas_options.length; i++)
{
selbox.options[i].text = data.fileas_options[i];
// send org-view requests to server
_action.data.nm_action = "submit";
}
else
{
// call nm_action's popup
_action.data.nm_action = "popup";
}
nm_action(_action, _senders);
},
showphones: function(form)
{
if (form) {
copyvalues(form,"tel_home","tel_home2");
copyvalues(form,"tel_work","tel_work2");
copyvalues(form,"tel_cell","tel_cell2");
copyvalues(form,"tel_fax","tel_fax2");
}
},
hidephones: function(form)
{
if (form) {
copyvalues(form,"tel_home2","tel_home");
copyvalues(form,"tel_work2","tel_work");
copyvalues(form,"tel_cell2","tel_cell");
copyvalues(form,"tel_fax2","tel_fax");
}
},
copyvalues: function(form,src,dst)
{
var srcelement = getElement(form,src); //ById("exec["+src+"]");
var dstelement = getElement(form,dst); //ById("exec["+dst+"]");
if (srcelement && dstelement) {
dstelement.value = srcelement.value;
}
},
getElement: function(form,pattern)
{
for (i = 0; i < form.length; i++){
if(form.elements[i].name){
var found = form.elements[i].name.search("\\["+pattern+"\\]");
if (found != -1){
return form.elements[i];
}
}
else if (template && (selbox = template.widgetContainer.getWidgetById('fileas_type')))
}
},
check_value: function(input, own_id)
{
var values = egw_json_getFormValues(input.form).exec; // todo use eT2 method, if running under et2
if(typeof values == 'undefined' && typeof etemplate2 != 'undefined') {
var template = etemplate2.getByApplication('addressbook')[0];
values = template.getValues(template.widgetContainer);
}
if (input.name.match(/n_/))
{
var value = '';
if (values.n_prefix) value += values.n_prefix+" ";
if (values.n_given) value += values.n_given+" ";
if (values.n_middle) value += values.n_middle+" ";
if (values.n_family) value += values.n_family+" ";
if (values.n_suffix) value += values.n_suffix;
var name = document.getElementById("exec[n_fn]");
if(name == null && template)
{
selbox.set_select_options(data.fileas_sel_options);
name = template.widgetContainer.getWidgetById('n_fn');
name.set_value(value);
}
else
{
name.value = value;
}
}
});
}
egw.json('addressbook.addressbook_ui.ajax_check_values', [values, input.name, own_id]).sendRequest(true, function(data) {
if (data.msg && confirm(data.msg))
{
for(var id in data.doublicates)
{
egw.open(id, 'addressbook');
//opener.egw_openWindowCentered2(egw_webserverUrl+'/index.php?menuaction=addressbook.addressbook_ui.edit&contact_id='+id, '_blank', 870, 480, 'yes', 'addressbook');
}
}
if (typeof data.fileas_options == 'object')
{
var selbox = document.getElementById("exec[fileas_type]");
if (selbox)
{
for (var i=0; i < data.fileas_options.length; i++)
{
selbox.options[i].text = data.fileas_options[i];
}
}
else if (template && (selbox = template.widgetContainer.getWidgetById('fileas_type')))
{
selbox.set_select_options(data.fileas_sel_options);
}
}
});
},
function add_whole_list(list)
{
if (document.getElementById("exec[nm][email_type][email_home]").checked == true)
add_whole_list: function(list)
{
email_type = "email_home";
}
else
{
email_type = "email";
}
xajax_doXMLHTTP("addressbook.addressbook_ui.ajax_add_whole_list",list,email_type);
}
function show_custom_country(selectbox)
{
if(!selectbox) return;
var custom_field_name = selectbox.name.replace("countrycode", "countryname");
var custom_field = document.getElementById(custom_field_name);
if(custom_field && selectbox.value == "-custom-") {
custom_field.style.display = "inline";
}
else if (custom_field)
{
if((selectbox.value == "" || selectbox.value == null) && custom_field.value != "")
if (document.getElementById("exec[nm][email_type][email_home]").checked == true)
{
selectbox.value = "-custom-";
// Chosen needs this to update
$j(selectbox).trigger("liszt:updated");
custom_field.style.display = "inline";
email_type = "email_home";
}
else
{
custom_field.style.display = "none";
email_type = "email";
}
}
}
var request = new egw_json_request("addressbook.addressbook_ui.ajax_add_whole_list",list,email_type);
request.sendRequest(true);
},
function add_new_list(owner)
{
var name = window.prompt(egw.lang('Name for the distribution list'));
if (name)
show_custom_country: function(selectbox)
{
egw.open('','addressbook', 'list', {
'add_list': name,
'owner': owner
},'_self');
}
}
if(!selectbox) return;
var custom_field_name = selectbox.name.replace("countrycode", "countryname");
var custom_field = document.getElementById(custom_field_name);
if(custom_field && selectbox.value == "-custom-") {
custom_field.style.display = "inline";
}
else if (custom_field)
{
if((selectbox.value == "" || selectbox.value == null) && custom_field.value != "")
{
selectbox.value = "-custom-";
// Chosen needs this to update
$j(selectbox).trigger("liszt:updated");
/**
* et2 specific initialization - can be moved to init() when addressbook gets converted to et2
*/
$j('.et2_container').on('load',function() {
$j('select[id*="adr_one_countrycode"]').each(function() {show_custom_country(this);});
$j('select[id*="adr_two_countrycode"]').each(function() {show_custom_country(this);});
});
custom_field.style.display = "inline";
}
else
{
custom_field.style.display = "none";
}
}
},
add_new_list: function(owner)
{
var name = window.prompt(egw.lang('Name for the distribution list'));
if (name)
{
egw.open('','addressbook', 'list', {
'add_list': name,
'owner': owner
},'_self');
}
},
filter2_onchange: function()
{
var filter2 = this.et2.getWidgetById('filter2');
var widget = this.et2.getWidgetById('nm');
if(filter2.get_value()=='add')
{
this.add_new_list(typeof widget == 'undefined' ? this.et2.getWidgetById('filter').value : widget.header.filter.get_value());
this.value='';
}
},
filter2_onchnage_email: function ()
{
this.form.submit();
if (this.value && confirm('Add emails of whole distribution list?'))
{
this.add_whole_list(this.value);
}
else
{
this.form.submit();
}
},
/**
*
*/
nm_compare_field: function()
{
var field = this.et2.getWidgetById('filter2');
if (field) var val = field.get_value();
if (val)
{
return nm_compare_field;
}
else
{
return false;
}
},
/**
*
*/
adv_search: function()
{
var link = opener.location.href;
link = link.replace(/#/,'');
opener.location.href=link.replace(/\#/,'');
},
/**
*
*/
adb_mail_vcard: function(_action, _elems)
{
var app_registry = egw.link_get_registry('felamimail');
var link = egw().link("/index.php","menuaction=felamimail.uicompose.compose");
for (var i = 0; i < _elems.length; i++)
{
link += "&preset[file][]="+encodeURIComponent("vfs://default/apps/addressbook/"+_elems[i].id+"/.entry");
}
if (typeof app_registry['view'] != 'undefined' && typeof app_registry['view_popup'] != 'undefined' )
{
var w_h =app_registry['view_popup'].split('x');
if (w_h[1] == 'egw_getWindowOuterHeight()') w_h[1] = (screen.availHeight>egw_getWindowOuterHeight()?screen.availHeight:egw_getWindowOuterHeight());
egw_openWindowCentered2(link, '_blank', w_h[0], w_h[1], 'yes');
}
},
/**
*
*/
adb_get_selection: function(form)
{
var use_all = document.getElementById("exec[use_all]");
var action = document.getElementById("exec[action]");
egw_openWindowCentered(egw().link("/index.php","menuaction=importexport.uiexport.export_dialog&appname=addressbook")+
"&selection="+( use_all.checked ? "use_all" : get_selected(form,"[rows][checked][]")),"Export",400,400);
action.value="";
use_all.checked = false;
return false;
},
/**
*
*/
do_action: function(selbox)
{
if (selbox.value != "")
{
if (selbox.value == "infolog_add" && (ids = get_selected(selbox.form,"[rows][checked][]")) && !document.getElementById("exec[use_all]").checked)
{
win = window.open(egw().link("/index.php","menuaction=infolog.infolog_ui.edit&type=task&action=addressbook&action_id="+ids),_blank,width=750,height=550,left=100,top=200);
win.focus();
}
else if (selbox.value == "cat_add")
{
win = window.open(egw().link("/etemplate/process_exec.php","menuaction=addressbook.addressbook_ui.cat_add"),_blank,width=300,height=400,left=100,top=200);
win.focus();
}
else if (selbox.value == "remove_from_list")
{
if (confirm(lang('Remove selected contacts from distribution list'))) selbox.form.submit();
}
else if (selbox.value == "delete_list")
{
if (confirm(lang('Delete selected distribution list!'))) selbox.form.submit();
}
else if (selbox.value == "delete")
{
if (confirm(lang('Delete'))) selbox.form.submit();
}
else
{
selbox.form.submit();
}
selbox.value = "";
}
},
n_fn_search: function ()
{
jQuery('table.editname').css('display','inline');
//var focElem = document.getElementById(form::name('n_prefix'));
if (!(typeof(focElem) == 'undefined') && typeof(focElem.focus)=='function')
{
//document.getElementById(form::name('n_prefix')).focus();
}
},
xajax_et: function()
{
this.et2.getInstanceManager().submit(this.et2.getWidgetById('button[search]'));
return false;
},
addEmail: function()
{
//Not implemented
},
});

View File

@ -28,23 +28,23 @@
<rows>
<row>
<description for="n_prefix" value="prefix"/>
<textbox id="n_prefix" onchange="check_value(this,'$cont[id]');" size="35" maxlength="64"/>
<textbox id="n_prefix" onchange="app.addressbook.check_value(this,'$cont[id]');" size="35" maxlength="64"/>
</row>
<row>
<description for="n_given" value="first name"/>
<textbox id="n_given" onchange="check_value(this,'$cont[id]');" size="35" maxlength="64"/>
<textbox id="n_given" onchange="app.addressbook.check_value(this,'$cont[id]');" size="35" maxlength="64"/>
</row>
<row>
<description for="n_middle" value="middle name"/>
<textbox id="n_middle" onchange="check_value(this,'$cont[id]');" size="35" maxlength="64"/>
<textbox id="n_middle" onchange="app.addressbook.check_value(this,'$cont[id]');" size="35" maxlength="64"/>
</row>
<row>
<description for="n_family" value="last name"/>
<textbox id="n_family" onchange="check_value(this,'$cont[id]');" size="35" maxlength="64"/>
<textbox id="n_family" onchange="app.addressbook.check_value(this,'$cont[id]');" size="35" maxlength="64"/>
</row>
<row>
<description for="n_suffix" value="suffix"/>
<textbox id="n_suffix" onchange="check_value(this,'$cont[id]');" size="35" maxlength="64"/>
<textbox id="n_suffix" onchange="app.addressbook.check_value(this,'$cont[id]');" size="35" maxlength="64"/>
</row>
<row>
<description/>
@ -101,12 +101,12 @@
<row>
<image src="home"/>
<description value="Organisation"/>
<textbox id="org_name" onchange="check_value(this,'$cont[id]');" size="45" maxlength="128"/>
<textbox id="org_name" onchange="app.addressbook.check_value(this,'$cont[id]');" size="45" maxlength="128"/>
</row>
<row>
<description/>
<description for="org_unit" value="department"/>
<textbox id="org_unit" onchange="check_value(this,'$cont[id]');" size="45" maxlength="64"/>
<textbox id="org_unit" onchange="app.addressbook.check_value(this,'$cont[id]');" size="45" maxlength="64"/>
</row>
<row>
<image src="gohome"/>
@ -131,7 +131,7 @@
<description for="adr_one_countryname" value="country"/>
<hbox options="0,0">
<menulist>
<menupopup type="select-country" class="countrySelect" id="adr_one_countrycode" onchange="show_custom_country(this);" options="Select one,0,1"/>
<menupopup type="select-country" class="countrySelect" id="adr_one_countrycode" onchange="app.addressbook.show_custom_country(this);" options="Select one,0,1"/>
</menulist>
<textbox id="adr_one_countryname" class="custom_country"/>
<textbox statustext="State" id="adr_one_region" size="19" maxlength="64" class="leftPad5"/>
@ -151,7 +151,7 @@
<description for="adr_one_countryname" value="country"/>
<hbox options="0,0">
<menulist>
<menupopup type="select-country" class="countrySelect" id="adr_one_countrycode" onchange="show_custom_country(this);" options="Select one,0,1"/>
<menupopup type="select-country" class="countrySelect" id="adr_one_countrycode" onchange="app.addressbook.show_custom_country(this);" options="Select one,0,1"/>
</menulist>
<textbox id="adr_one_countryname" class="custom_country"/>
</hbox>
@ -215,7 +215,7 @@
<description for="adr_two_countryname" value="country"/>
<hbox options="0,0">
<menulist>
<menupopup type="select-country" class="countrySelect" id="adr_two_countrycode" onchange="show_custom_country(this);" options="Select one,0,1"/>
<menupopup type="select-country" class="countrySelect" id="adr_two_countrycode" onchange="app.addressbook.show_custom_country(this);" options="Select one,0,1"/>
</menulist>
<textbox id="adr_two_countryname" class="custom_country"/>
<textbox statustext="State" id="adr_two_region" size="19" maxlength="64" class="leftPad5"/>
@ -235,7 +235,7 @@
<description value="Country"/>
<hbox options="0,0">
<menulist>
<menupopup type="select-country" class="countrySelect" id="adr_two_countrycode" onchange="show_custom_country(this);" options="Select one,0,1"/>
<menupopup type="select-country" class="countrySelect" id="adr_two_countrycode" onchange="app.addressbook.show_custom_country(this);" options="Select one,0,1"/>
</menulist>
<textbox id="adr_two_countryname" class="custom_country"/>
</hbox>
@ -611,12 +611,12 @@
<row>
<image src="email.png"/>
<description for="email" value="email"/>
<url-email id="email" onchange="check_value(this,'$cont[id]');" options="28,128"/>
<url-email id="email" onchange="app.addressbook.check_value(this,'$cont[id]');" options="28,128"/>
</row>
<row>
<description/>
<description for="email_home" value="Private"/>
<url-email id="email_home" onchange="check_value(this,'$cont[id]');" options="28,128"/>
<url-email id="email_home" onchange="app.addressbook.check_value(this,'$cont[id]');" options="28,128"/>
</row>
</rows>
</grid>

View File

@ -2,12 +2,12 @@
<!-- $Id$ -->
<overlay>
<template id="addressbook.email.left" template="" lang="" group="0" version="1.5.001">
<hbox no_lang="1" class="bold">
<hbox class="bold" no_lang="1">
<radio statustext="where to add the email address" label="To" id="to" no_lang="1" options="to" class="bold"/>
<radio statustext="where to add the email address" label="Cc" id="to" no_lang="1" options="cc" class="bold"/>
<radio statustext="where to add the email address" label="Bcc" id="to" no_lang="1" options="bcc" class="bold"/>
</hbox>
<hbox no_lang="1" class="bold">
<hbox class="bold" no_lang="1">
<radio statustext="preferred type of email address to add for distribution lists" label="Business email" id="email_type" no_lang="1" options="email" class="bold"/>
<radio statustext="preferred type of email address to add for distribution lists" label="Home email" id="email_type" no_lang="1" options="email_home" class="bold"/>
</hbox>

View File

@ -14,7 +14,7 @@
<file id="upload_photo" class="photo" statustext="Select a portrait format jpeg photo. It will be resized to 60 pixel width."/>
</row>
<row>
<button label="Ok" align="center" onclick="set_style_by_class('table','uploadphoto','display','none'); return false;"/>
<button label="Ok" align="center" onclick="jQuery('table.uploadphoto').css('display','none'); return false;"/>
</row>
</rows>
</grid>
@ -28,27 +28,27 @@
<rows>
<row>
<description options=",,,n_prefix" value="prefix"/>
<textbox id="n_prefix" size="35" maxlength="64" onchange="setName(this);"/>
<textbox id="n_prefix" size="35" maxlength="64" onchange="app.addressbook.check_value(this,'$cont[id]');"/>
</row>
<row>
<description value="first name" options=",,,n_given"/>
<textbox id="n_given" size="35" maxlength="64" onchange="setName(this);"/>
<textbox id="n_given" size="35" maxlength="64" onchange="app.addressbook.check_value(this,'$cont[id]');"/>
</row>
<row>
<description options=",,,n_middle" value="middle name"/>
<textbox id="n_middle" size="35" maxlength="64" onchange="setName(this);"/>
<textbox id="n_middle" size="35" maxlength="64" onchange="app.addressbook.check_value(this,'$cont[id]');"/>
</row>
<row>
<description options=",,,n_family" value="last name"/>
<textbox id="n_family" size="35" maxlength="64" onchange="setName(this);"/>
<textbox id="n_family" size="35" maxlength="64" onchange="app.addressbook.check_value(this,'$cont[id]');"/>
</row>
<row>
<description options=",,,n_suffix" value="suffix"/>
<textbox id="n_suffix" size="35" maxlength="64" onchange="setName(this);"/>
<textbox id="n_suffix" size="35" maxlength="64" onchange="app.addressbook.check_value(this,'$cont[id]');"/>
</row>
<row>
<description/>
<button label="Ok" onclick="set_style_by_class('table','editname','display','none'); if(document.getElementById(form::name('title'))){document.getElementById(form::name('title')).focus();} return false;"/>
<button label="Ok" onclick="jQuery('table.editname').css('display','none'); if(document.getElementById(form::name('title'))){document.getElementById(form::name('title')).focus();} return false;"/>
</row>
</rows>
</grid>
@ -64,7 +64,7 @@
<row valign="top">
<image src="accounts"/>
<vbox>
<image src="photo" class="photo" onclick="set_style_by_class('table','uploadphoto','display','inline'); return false;"/>
<image src="photo" class="photo" onclick="jQuery('table.uploadphoto').css('display','inline'); return false;"/>
<template id="addressbook.edit.upload"/>
</vbox>
<grid>
@ -77,7 +77,7 @@
<rows>
<row>
<description value="Name"/>
<textbox rows="1" cols="3" id="n_fn" no_lang="1" onclick="set_style_by_class('table','editname','display','inline'); document.getElementById(form::name('n_prefix')).focus();" size="-36" span="2" class="cursorHand" readonly="true"/>
<textbox rows="1" id="n_fn" no_lang="1" onclick="jQuery('table.editname').css('display','inline'); var focElem = document.getElementById(form::name('n_prefix')); if (!(typeof(focElem) == 'undefined') &amp;&amp; typeof(focElem.focus)=='function') document.getElementById(form::name('n_prefix')).focus();" size="-36" span="2" class="cursorHand" readonly="true"/>
</row>
<row>
<description/>
@ -132,7 +132,7 @@
<description value="country" options=",,,adr_one_countryname"/>
<hbox options="0,0">
<menulist class="countrySelect">
<menupopup type="select-country" options="Select one,0,1" id="adr_one_countrycode" onchange="show_custom_country(this);"/>
<menupopup type="select-country" options="Select one,0,1" id="adr_one_countrycode" onchange="app.addressbook.show_custom_country(this);"/>
</menulist>
<textbox id="adr_one_countryname" class="custom_country"/>
<textbox class="leftPad5" size="19" maxlength="64" id="adr_one_region" statustext="State"/>
@ -152,7 +152,7 @@
<description value="country" options=",,,adr_one_countryname"/>
<hbox options="0,0">
<menulist class="countrySelect">
<menupopup type="select-country" options="Select one,0,1" id="adr_one_countrycode" onchange="show_custom_country(this);"/>
<menupopup type="select-country" options="Select one,0,1" id="adr_one_countrycode" onchange="app.addressbook.show_custom_country(this);"/>
</menulist>
<textbox id="adr_one_countryname" class="custom_country"/>
</hbox>
@ -216,7 +216,7 @@
<description value="country" options=",,,adr_two_countryname"/>
<hbox options="0,0">
<menulist class="countrySelect">
<menupopup type="select-country" options="Select one,0,1" id="adr_two_countrycode" onchange="show_custom_country(this);"/>
<menupopup type="select-country" options="Select one,0,1" id="adr_two_countrycode" onchange="app.addressbook.show_custom_country(this);"/>
</menulist>
<textbox id="adr_two_countryname" class="custom_country"/>
<textbox class="leftPad5" size="19" maxlength="64" id="adr_two_region" statustext="State"/>
@ -236,7 +236,7 @@
<description value="Country"/>
<hbox options="0,0">
<menulist class="countrySelect">
<menupopup type="select-country" options="Select one,0,1" id="adr_two_countrycode" onchange="show_custom_country(this);"/>
<menupopup type="select-country" options="Select one,0,1" id="adr_two_countrycode" onchange="app.addressbook.show_custom_country(this);"/>
</menulist>
<textbox id="adr_two_countryname" class="custom_country"/>
</hbox>
@ -662,11 +662,11 @@
</row>
<row>
<hbox span="all">
<button label="Search" id="button[search]" onclick="xajax_eT_wrapper(this); return false;"/>
<button label="Cancel" id="button[cancel]" onclick="xajax_eT_wrapper(this); return false;"/>
<button label="Search" id="button[search]"/>
<button label="Cancel" id="button[cancel]"/>
</hbox>
</row>
</rows>
</grid>
</template>
</overlay>
</overlay>