mirror of
https://github.com/mailcow/mailcow-dockerized.git
synced 2024-11-30 08:59:40 +02:00
[Web] check mailbox before replacing sogo_static_view
This commit is contained in:
parent
04a08a7d69
commit
e1d8df6580
@ -1022,6 +1022,17 @@ function update_sogo_static_view($mailbox = null) {
|
|||||||
global $pdo;
|
global $pdo;
|
||||||
global $lang;
|
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`)
|
$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
|
SELECT
|
||||||
mailbox.username,
|
mailbox.username,
|
||||||
@ -1045,7 +1056,7 @@ function update_sogo_static_view($mailbox = null) {
|
|||||||
WHERE
|
WHERE
|
||||||
mailbox.active = '1'";
|
mailbox.active = '1'";
|
||||||
|
|
||||||
if ($mailbox !== null) {
|
if ($mailbox_exists) {
|
||||||
$query .= " AND mailbox.username = :mailbox";
|
$query .= " AND mailbox.username = :mailbox";
|
||||||
$stmt = $pdo->prepare($query);
|
$stmt = $pdo->prepare($query);
|
||||||
$stmt->execute(array(':mailbox' => $mailbox));
|
$stmt->execute(array(':mailbox' => $mailbox));
|
||||||
|
Loading…
Reference in New Issue
Block a user