fix Admin > Mail account to work in master:

- using <et2-select-account multiple="true"
- convert from account_id=0 --> [] and back for saving
- remove TS code switching multiple on and off via previously removed button
--> must not be back-ported to 21.1!
This commit is contained in:
ralf 2022-07-20 19:11:59 +02:00
parent 74ed8380ca
commit 711eac8934
3 changed files with 11 additions and 68 deletions

View File

@ -1199,7 +1199,7 @@ class admin_mail
// admin access to account with no credentials available
if ($this->is_admin && (empty($content['acc_imap_username']) || empty($content['acc_imap_host']) || $content['called_for']))
{
// cant connection to imap --> allow free entries in taglists
// can't connection to imap --> allow free entries in taglists
foreach(array('acc_folder_sent', 'acc_folder_trash', 'acc_folder_draft', 'acc_folder_template', 'acc_folder_junk') as $folder)
{
$tpl->setElementAttribute($folder, 'allowFreeEntries', true);
@ -1335,11 +1335,6 @@ class admin_mail
}
Framework::message($msg ? $msg : (string)$_GET['msg'], $msg_type);
if (is_array($content['account_id']) && count($content['account_id']) > 1)
{
$tpl->setElementAttribute('account_id', 'multiple', true);
$readonlys['button[multiple]'] = true;
}
// when called by admin for existing accounts, display further administrative actions
if ($content['called_for'] && (int)$content['acc_id'] > 0)
{
@ -1411,11 +1406,15 @@ class admin_mail
if (!is_array($account_id))
{
$account_id = explode(',', $account_id);
$account_id = $account_id ? explode(',', $account_id) : [];
}
if (($k = array_search($back?'':'0', $account_id)) !== false)
if ($back && !$account_id)
{
$account_id[$k] = $back ? '0' : '';
$account_id = 0;
}
if (!$back && count($account_id) === 1 && !current($account_id))
{
$account_id = [];
}
}

View File

@ -131,9 +131,6 @@ class AdminApp extends EgwApp
this.cf_type_change(null,widget);
break;
case 'admin.mailaccount':
this.account_hide_not_applying();
break;
case 'admin.cmds':
var selected = this.et2.getWidgetById('nm').getSelection();
if (selected && selected.ids.length == 1)
@ -1293,57 +1290,6 @@ class AdminApp extends EgwApp
this.et2.getWidgetById('acc_sieve_enabled').set_value(1);
}
/**
* Hide not applying fields, used as:
* - onchange handler on account_id
* - called from et2_ready for emailadmin.account template
*
* @param {object} _event event-object or information about event
* @param {et2_baseWidget} _widget widget causing the event
*/
account_hide_not_applying(_event?, _widget?)
{
var account_id = this.et2.getWidgetById('account_id');
var ids = account_id && account_id.get_value ? account_id.get_value() : [];
if (typeof ids == 'string') ids = ids.split(',');
var multiple = ids.length >= 2 || ids[0] === '' || ids[0] < 0;
//alert('multiple='+(multiple?'true':'false')+': '+ids.join(','));
// initial call
if (typeof _widget == 'undefined')
{
if (!multiple)
{
jQuery('.emailadmin_no_single').hide();
}
if (!this.egw.user('apps').admin)
{
jQuery('.emailadmin_no_user,#button\\[multiple\\]').hide();
}
if (ids.length == 1)
{
// switch back to single selectbox
account_id.set_multiple(false);
}
}
// switched to single user
else if (!multiple)
{
jQuery('.emailadmin_no_single').fadeOut();
// switch back to single selectbox
account_id.set_multiple(false);
this.et2.getWidgetById('button[multiple]').set_disabled(false);
}
// switched to multiple user
else
{
jQuery('.emailadmin_no_single').fadeIn();
}
if (_event && _event.stopPropagation) _event.stopPropagation();
return false;
}
/**
* Callback if user changed account selction
*

View File

@ -260,12 +260,12 @@
</row>
<row>
<description for="mailAlternateAddress" value="Alternate email address"/>
<select-email id="mailAlternateAddress" autocomplete_url="" full_email="true"/>
<select-email id="mailAlternateAddress" autocomplete_url="" full_email="true" allowFreeEntries="true"/>
<description/>
</row>
<row disabled="@no_forward_available">
<description for="mailForwardingAddress" value="Forward email's to"/>
<select-email id="mailForwardingAddress" autocomplete_url="" full_email="true"/>
<select-email id="mailForwardingAddress" autocomplete_url="" full_email="true" allowFreeEntries="true"/>
<vbox>
<checkbox label="Forward only" id="deliveryMode" selected_value="forwardOnly" onchange="if (widget.getValue()) et2_dialog.alert('Forward only disables IMAP mailbox / storing of mails and just forwards them to given address.','Forward only');"/>
<checkbox label="Allow users to change forwards" id="acc_user_forward"/>
@ -342,9 +342,7 @@
<row class="emailadmin_no_user dialogHeader2">
<description for="account_id" value="Valid for"/>
<hbox span="all">
<select-account account_type="both" id="account_id"
onchange="app.admin.account_hide_not_applying" empty_label="Everyone"
expand_multiple_rows="4"/>
<select-account account_type="both" id="account_id" placeholder="Everyone" multiple="true"/>
<checkbox label="account editable by user" id="acc_user_editable"/>
</hbox>
</row>