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] Run _sogo_static_view update when changing sogo_view content
51cb3e1a
data/web/inc/functions.mailbox.inc.php | 27 +++++++++++++++++----------
1 file changed, 17 insertions(+), 10 deletions(-)
Diff
diff --git a/data/web/inc/functions.mailbox.inc.php b/data/web/inc/functions.mailbox.inc.php
index a37f5e78..af3d037e 100644
--- a/data/web/inc/functions.mailbox.inc.php
+++ b/data/web/inc/functions.mailbox.inc.php
@@ -1,8 +1,19 @@
<?php
+function update_sogo_static_view() {
+ global $pdo;
+ global $lang;
+ $stmt = $pdo->query("SELECT 'OK' FROM INFORMATION_SCHEMA.TABLES
+ WHERE TABLE_NAME = 'sogo_view'");
+ $num_results = count($stmt->fetchAll(PDO::FETCH_ASSOC));
+ if ($num_results != 0) {
+ $stmt = $pdo->query("REPLACE INTO _sogo_static_view SELECT * from sogo_view");
+ $stmt = $pdo->query("DELETE FROM _sogo_static_view WHERE `c_uid` NOT IN (SELECT `username` FROM `mailbox` WHERE `active` = '1');");
+ }
+}
function mailbox($_action, $_type, $_data = null, $attr = null) {
- global $pdo;
- global $redis;
- global $lang;
+ global $pdo;
+ global $redis;
+ global $lang;
switch ($_action) {
case 'add':
switch ($_type) {
@@ -180,7 +191,6 @@ function mailbox($_action, $_type, $_data = null, $attr = null) {
'type' => 'success',
'msg' => sprintf($lang['success']['mailbox_modified'], $username)
);
- return true;
break;
case 'syncjob':
if (!isset($_SESSION['acl']['syncjobs']) || $_SESSION['acl']['syncjobs'] != "1" ) {
@@ -327,7 +337,6 @@ function mailbox($_action, $_type, $_data = null, $attr = null) {
'type' => 'success',
'msg' => sprintf($lang['success']['mailbox_modified'], $username)
);
- return true;
break;
case 'domain':
if ($_SESSION['mailcow_cc_role'] != "admin") {
@@ -1577,7 +1586,6 @@ function mailbox($_action, $_type, $_data = null, $attr = null) {
'type' => 'success',
'msg' => sprintf($lang['success']['mailbox_modified'], $username)
);
- return true;
break;
case 'filter':
$sieve = new Sieve\SieveParser();
@@ -1671,7 +1679,6 @@ function mailbox($_action, $_type, $_data = null, $attr = null) {
'type' => 'success',
'msg' => sprintf($lang['success']['mailbox_modified'], $username)
);
- return true;
break;
case 'alias':
if (!is_array($_data['address'])) {
@@ -3219,7 +3226,6 @@ function mailbox($_action, $_type, $_data = null, $attr = null) {
'type' => 'success',
'msg' => 'Deleted syncjob id/s ' . implode(', ', $ids)
);
- return true;
break;
case 'filter':
if (!is_array($_data['id'])) {
@@ -3266,7 +3272,6 @@ function mailbox($_action, $_type, $_data = null, $attr = null) {
'type' => 'success',
'msg' => 'Deleted filter id/s ' . implode(', ', $ids)
);
- return true;
break;
case 'time_limited_alias':
if (!is_array($_data['address'])) {
@@ -3473,7 +3478,6 @@ function mailbox($_action, $_type, $_data = null, $attr = null) {
'type' => 'success',
'msg' => sprintf($lang['success']['domain_removed'], htmlspecialchars(implode(', ', $domains)))
);
- return true;
break;
case 'alias':
if (!is_array($_data['address'])) {
@@ -3787,4 +3791,7 @@ function mailbox($_action, $_type, $_data = null, $attr = null) {
}
break;
}
+ if ($_action != 'get' && in_array($_type, array('domain', 'alias', 'alias_domain', 'mailbox'))) {
+ update_sogo_static_view();
+ }
}