public
nobgit
read
NobMail
Based on mailcow: dockerized
Languages
Repository composition by tracked source files.
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] check mailbox before replacing sogo_static_view
e1d8df65
data/web/inc/functions.inc.php | 15 +++++++++++++--
1 file changed, 13 insertions(+), 2 deletions(-)
Diff
diff --git a/data/web/inc/functions.inc.php b/data/web/inc/functions.inc.php
index 8bd55f29..4dc2418c 100644
--- a/data/web/inc/functions.inc.php
+++ b/data/web/inc/functions.inc.php
@@ -1021,7 +1021,18 @@ function update_sogo_static_view($mailbox = null) {
}
global $pdo;
global $lang;
-
+
+ $mailbox_exists = false;
+ if ($mailbox !== null) {
+ // Check if the mailbox exists
+ $stmt = $pdo->prepare("SELECT username FROM mailbox WHERE username = :mailbox AND active = '1'");
+ $stmt->execute(array(':mailbox' => $mailbox));
+ $row = $stmt->fetch(PDO::FETCH_ASSOC);
+ if ($row){
+ $mailbox_exists = true;
+ }
+ }
+
$query = "REPLACE INTO _sogo_static_view (`c_uid`, `domain`, `c_name`, `c_password`, `c_cn`, `mail`, `aliases`, `ad_aliases`, `ext_acl`, `kind`, `multiple_bookings`)
SELECT
mailbox.username,
@@ -1045,7 +1056,7 @@ function update_sogo_static_view($mailbox = null) {
WHERE
mailbox.active = '1'";
- if ($mailbox !== null) {
+ if ($mailbox_exists) {
$query .= " AND mailbox.username = :mailbox";
$stmt = $pdo->prepare($query);
$stmt->execute(array(':mailbox' => $mailbox));