NobGit
public nobgit read

NobMail

Based on mailcow: dockerized

Languages

Repository composition by tracked source files.

PHP
PHP 49% JavaScript 35% HTML 9% CSS 4% Shell 2% Python 1% Lua 0% Perl 0% Ruby 0% SCSS 0%
Create file Wiki Documentation
Clone
https://nobgit.com/orgs/nobgit/nobmail.git
ssh://[email protected]:2222/orgs/nobgit/nobmail.git

Commit

[Web] rename goto in alias table

822d9a7d
FreddleSpl0it <[email protected]> 1 year, 11 months ago
data/web/inc/functions.mailbox.inc.php | 22 ++++++++++++----------
 data/web/lang/lang.de-de.json          |  1 +
 data/web/lang/lang.en-gb.json          |  1 +
 data/web/templates/edit/mailbox.twig   |  9 ++++++---
 4 files changed, 20 insertions(+), 13 deletions(-)

Diff

diff --git a/data/web/inc/functions.mailbox.inc.php b/data/web/inc/functions.mailbox.inc.php
index baf635dd..6c24c13f 100644
--- a/data/web/inc/functions.mailbox.inc.php
+++ b/data/web/inc/functions.mailbox.inc.php
@@ -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
diff --git a/data/web/lang/lang.de-de.json b/data/web/lang/lang.de-de.json
index 79a6dc38..d22187c6 100644
--- a/data/web/lang/lang.de-de.json
+++ b/data/web/lang/lang.de-de.json
@@ -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)",
diff --git a/data/web/lang/lang.en-gb.json b/data/web/lang/lang.en-gb.json
index 7833d7e4..6e898099 100644
--- a/data/web/lang/lang.en-gb.json
+++ b/data/web/lang/lang.en-gb.json
@@ -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)",
diff --git a/data/web/templates/edit/mailbox.twig b/data/web/templates/edit/mailbox.twig
index b21ff2ee..04be194c 100644
--- a/data/web/templates/edit/mailbox.twig
+++ b/data/web/templates/edit/mailbox.twig
@@ -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>