fix removing last user/group from valid-for in mail-account did not work

add a strong warning that selecting a user/group for a mail account for all users effectively deletes it for all other users
This commit is contained in:
ralf 2023-09-15 09:27:22 +02:00
parent 1d1b3f5947
commit 1fb543cb93
5 changed files with 29 additions and 2 deletions

View File

@ -20,6 +20,7 @@ import {egwAction, egwActionObject} from '../../api/js/egw_action/egw_action';
import {LitElement} from "@lion/core";
import {et2_nextmatch} from "../../api/js/etemplate/et2_extension_nextmatch";
import {et2_DOMWidget} from "../../api/js/etemplate/et2_core_DOMWidget";
import {Et2SelectAccount} from "../../api/js/etemplate/Et2Select/Et2SelectAccount";
/**
* UI for Admin
@ -1367,6 +1368,28 @@ class AdminApp extends EgwApp
if (use_default) use_default.set_value(false);
}
/**
* onchange callback for mail account account_id (valid for)
*
* @param {object} _event
* @param {et2_widget} _widget
*/
warnMailAccountForAllChanged(_event : Event, _widget : Et2SelectAccount)
{
const account_id = _widget.value;
const old_account_id = this.et2.getArrayMgr('content').getEntry('account_id');
// this is (no longer) an account for all
if ((Array.isArray(account_id) ? account_id.length : account_id) &&
// but this was an account for all
!(Array.isArray(old_account_id) ? old_account_id.length : old_account_id))
{
_widget.blur();
Et2Dialog.alert(this.egw.lang('By selecting a user or group you effectively delete the mail account for all other users!\n\nAre you really sure you want to do that?'),
this.egw.lang('This is a mail account for ALL users!'), Et2Dialog.WARNING_MESSAGE);
}
}
/**
* default onExecute for admin actions
*

View File

@ -188,6 +188,7 @@ blocking after wrong password admin de Blockierung nach falschem Passwort
bottom admin de unten
bulk password reset admin de Rücksetzen mehrerer Passwörter
by admin de Von
by selecting a user or group you effectively delete the mail account for all other users!\n\nare you really sure you want to do that? admin de Durch die Auswahl eines Benutzer oder Gruppe löschen Sie das Mailkonto für alle anderen Benutzer!\n\nSind Sie wirklich sicher, dass Sie das wollen?
calculate next run admin de nächste Ausführung berechnen
calendar recurrence horizont in days (default 1000) admin de Kalender Wiederholungs-Bereich in Tagen (Vorgabe sind 1000)
can be used by application admin de Kann von folgender Anwendung verwendet werden
@ -920,6 +921,7 @@ this application is current admin de Diese Anwendung ist aktuell
this application requires an upgrade admin de Diese Anwendung benötigt ein Upgrade
this category is currently being used by applications as a parent category admin de Diese Kategorie wird gegenwärtig als übergeordnete Kategorie benutzt.
this controls exports and merging. admin de Steuert den Export und den Merge Print von Dokumenten
this is a mail account for all users! admin de Das ist ein Mailkonto für ALLE Benutzer!
this is not a personal mail account!\n\naccount will be deleted for all users!\n\nare you really sure you want to do that? admin de Das ist KEIN persönliches Mail-Konto!\n\nDas Konto wird für ALLE Benutzer gelöscht!\n\nSind Sie wirklich sicher, dass Sie das wollen?
this key used in the html code your site serves to users. admin de Dieser Schlüssel steht im HTML Code den Ihre Website ausliefert.
this php has no imap support compiled in!! admin de Dieses PHP hat keine IMAP Unterstützung!!!

View File

@ -188,6 +188,7 @@ blocking after wrong password admin en Blocking after wrong password
bottom admin en Bottom
bulk password reset admin en Bulk password reset
by admin en By
by selecting a user or group you effectively delete the mail account for all other users!\n\nare you really sure you want to do that? admin en By selecting a user or group you effectively delete the mail account for all other users!\n\nAre you really sure you want to do that?
calculate next run admin en Calculate next run
calendar recurrence horizont in days (default 1000) admin en Calendar recurrence horizon in days. Default = 1000.
can be used by application admin en Can be used by application
@ -923,6 +924,7 @@ this application is current admin en This application is current.
this application requires an upgrade admin en This application requires an upgrade.
this category is currently being used by applications as a parent category admin en This category is currently being used by applications as a parent category.
this controls exports and merging. admin en This controls exports and merge prints.
this is a mail account for all users! admin en This is a mail account for ALL users!
this is not a personal mail account!\n\naccount will be deleted for all users!\n\nare you really sure you want to do that? admin en This is NOT a personal mail account!\n\nAccount will be deleted for ALL users!\n\nAre you really sure you want to do that?
this key used in the html code your site serves to users. admin en This key used in the HTML code your site serves to users.
this php has no imap support compiled in!! admin en This PHP has no IMAP support compiled in!!

View File

@ -341,7 +341,7 @@
<row class="emailadmin_no_user dialogHeader2">
<et2-description for="account_id" value="Valid for"></et2-description>
<et2-hbox span="all">
<et2-select-account id="account_id" placeholder="Everyone" multiple="true" accountType="both" rows="1"></et2-select-account>
<et2-select-account id="account_id" placeholder="Everyone" multiple="true" accountType="both" rows="1" onchange="app.admin.warnMailAccountForAllChanged"></et2-select-account>
<et2-checkbox label="account editable by user" id="acc_user_editable"></et2-checkbox>
</et2-hbox>
</row>

View File

@ -1300,7 +1300,7 @@ class Account implements \ArrayAccess
{
$old_account_ids[] = $row['account_id'];
}
if ($data['account_id'] && ($ids_to_remove = array_diff($old_account_ids, (array)$data['account_id'])))
if (($ids_to_remove = array_diff($old_account_ids, (array)$data['account_id'])))
{
self::$db->delete(self::VALID_TABLE, $where+array(
'account_id' => $ids_to_remove,