1
0
mirror of https://github.com/mailcow/mailcow-dockerized.git synced 2025-12-13 09:56:01 +00:00

[Web] rename goto in alias table

This commit is contained in:
FreddleSpl0it
2024-08-27 10:07:07 +02:00
parent 8e7b27aae4
commit 822d9a7de6
4 changed files with 20 additions and 13 deletions

View File

@@ -3271,6 +3271,7 @@ function mailbox($_action, $_type, $_data = null, $_extra = null) {
$pdo->beginTransaction();
$pdo->exec('SET FOREIGN_KEY_CHECKS = 0');
// Update username in mailbox table
$pdo->prepare('UPDATE mailbox SET username = :new_username, local_part = :new_local_part WHERE username = :old_username')
->execute([
':new_username' => $new_username,
@@ -3278,6 +3279,13 @@ function mailbox($_action, $_type, $_data = null, $_extra = null) {
':old_username' => $old_username
]);
$pdo->prepare("UPDATE alias SET address = :new_username, goto = :new_username2 WHERE address = :old_username")
->execute([
':new_username' => $new_username,
':new_username2' => $new_username,
':old_username' => $old_username
]);
// Update the username in all related tables
$tables = [
'tags_mailbox' => 'username',
@@ -3287,9 +3295,9 @@ function mailbox($_action, $_type, $_data = null, $_extra = null) {
'da_acl' => 'username',
'quota2' => 'username',
'quota2replica' => 'username',
'pushover' => 'username'
'pushover' => 'username',
'alias' => 'goto'
];
foreach ($tables as $table => $column) {
$pdo->prepare("UPDATE $table SET $column = :new_username WHERE $column = :old_username")
->execute([
@@ -3298,6 +3306,7 @@ function mailbox($_action, $_type, $_data = null, $_extra = null) {
]);
}
// Update c_uid, c_name and mail in _sogo_static_view table
$pdo->prepare("UPDATE _sogo_static_view SET c_uid = :new_username, c_name = :new_username2, mail = :new_username3 WHERE c_uid = :old_username")
->execute([
':new_username' => $new_username,
@@ -3306,14 +3315,6 @@ function mailbox($_action, $_type, $_data = null, $_extra = null) {
':old_username' => $old_username
]);
$pdo->prepare("UPDATE alias SET address = :new_username, goto = :new_username2 WHERE address = :old_username")
->execute([
':new_username' => $new_username,
':new_username2' => $new_username,
':old_username' => $old_username
]);
// Re-enable foreign key checks
$pdo->exec('SET FOREIGN_KEY_CHECKS = 1');
$pdo->commit();
@@ -3325,6 +3326,7 @@ function mailbox($_action, $_type, $_data = null, $_extra = null) {
'log' => array(__FUNCTION__, $_action, $_type, $_data_log, $_attr),
'msg' => $e->getMessage()
);
return false;
}
// move maildir

View File

@@ -645,6 +645,7 @@
"mailbox_rename_agree": "Ich habe ein Backup erstellt.",
"mailbox_rename_warning": "WICHTIG! Vor dem Umbenennen der Mailbox ein Backup erstellen.",
"mailbox_rename_alias": "Alias automatisch erstellen",
"mailbox_rename_title": "Neuer Lokaler Mailbox Name",
"max_aliases": "Max. Aliasse",
"max_mailboxes": "Max. Mailboxanzahl",
"max_quota": "Max. Größe per Mailbox (MiB)",

View File

@@ -645,6 +645,7 @@
"mailbox_rename_agree": "I have created a backup.",
"mailbox_rename_warning": "IMPORTANT! Create a backup before renaming the mailbox.",
"mailbox_rename_alias": "Create alias automatically",
"mailbox_rename_title": "New local mailbox name",
"max_aliases": "Max. aliases",
"max_mailboxes": "Max. possible mailboxes",
"max_quota": "Max. quota per mailbox (MiB)",

View File

@@ -504,7 +504,10 @@
<input name="domain" type="hidden" value="{{ result.domain }}">
<input name="old_local_part" type="hidden" value="{{ result.local_part }}">
<div class="row mb-2">
<div class="offset-sm-2 col-sm-10 col-md-8 col-xl-6">
<div class="col-sm-12 col-md-2">
<span>{{ lang.edit.mailbox_rename_title }}</span>
</div>
<div class="col-sm-12 col-md-10 col-xl-8">
<div class="input-group mb-2">
<input type="text" class="form-control" name="new_local_part" autocomplete="off" value="{{ result.local_part }}">
<span class="input-group-text">@{{ result.domain }}</span>
@@ -512,12 +515,12 @@
</div>
</div>
<div class="row mb-4">
<div class="offset-sm-2 col-sm-10">
<div class="col-sm-12 offset-md-2 col-md-10 col-xl-8">
<label><input type="checkbox" class="form-check-input" value="1" name="create_alias" checked> {{ lang.edit.mailbox_rename_alias }}</label>
</div>
</div>
<div class="row mb-2">
<div class="offset-sm-2 col-sm-10">
<div class="col-sm-12 offset-md-2 col-md-10 col-xl-8">
<button class="btn btn-xs-lg d-block d-sm-inline btn-secondary" data-action="edit_selected" data-id="mboxrename" data-item="{{ mailbox }}" data-api-url='edit/rename-mbox' data-api-attr='{}' data-api-reload-location="/mailbox" href="#">{{ lang.edit.save }}</button>
</div>
</div>