@@ -431,6 +431,8 @@ function onAfterUpdate() {
431431 $ to_disable = array ('cron ' => 'id ' ,
432432 'ftp_user ' => 'ftp_user_id ' ,
433433 'mail_domain ' => 'domain_id ' ,
434+ 'mail_user ' => 'mailuser_id ' ,
435+ 'mail_user_smtp ' => 'mailuser_id ' ,
434436 'mail_forwarding ' => 'forwarding_id ' ,
435437 'mail_get ' => 'mailget_id ' ,
436438 'openvz_vm ' => 'vm_id ' ,
@@ -452,17 +454,28 @@ function onAfterUpdate() {
452454 $ prev_active = array ();
453455 $ prev_sysuser = array ();
454456 foreach ($ to_disable as $ current => $ keycolumn ) {
455- $ prev_active [$ current ] = array ();
456- $ prev_sysuser [$ current ] = array ();
457+ $ active_col = 'active ' ;
458+ $ reverse = false ;
459+ if ($ current == 'mail_user ' ) {
460+ $ active_col = 'postfix ' ;
461+ } elseif ($ current == 'mail_user_smtp ' ) {
462+ $ current = 'mail_user ' ;
463+ $ active_col = 'disablesmtp ' ;
464+ $ reverse = true ;
465+ }
466+
467+ if (!isset ($ prev_active [$ current ])) $ prev_active [$ current ] = array ();
468+ if (!isset ($ prev_sysuser [$ current ])) $ prev_sysuser [$ current ] = array ();
457469
458- $ entries = $ app ->db ->queryAllRecords ('SELECT ` ' . $ keycolumn . '` as `id`, `sys_userid`, `active ` FROM ` ' . $ current . '` WHERE `sys_groupid` = ' . $ sys_groupid );
470+ $ entries = $ app ->db ->queryAllRecords ('SELECT ` ' . $ keycolumn . '` as `id`, `sys_userid`, ` ' . $ active_col . ' ` FROM ` ' . $ current . '` WHERE `sys_groupid` = ' . $ sys_groupid );
459471 foreach ($ entries as $ item ) {
460472
461- if ($ item ['active ' ] != 'y ' ) $ prev_active [$ current ][$ item ['id ' ]]['active ' ] = 'n ' ;
462- if ($ item ['sys_userid ' ] != $ sys_userid ) $ prev_sysuser [$ current ][$ item ['id ' ]]['active ' ] = $ item ['sys_userid ' ];
473+ if ($ item [$ active_col ] != 'y ' && $ reverse == false ) $ prev_active [$ current ][$ item ['id ' ]][$ active_col ] = 'n ' ;
474+ elseif ($ item [$ active_col ] == 'y ' && $ reverse == true ) $ prev_active [$ current ][$ item ['id ' ]][$ active_col ] = 'y ' ;
475+ if ($ item ['sys_userid ' ] != $ sys_userid ) $ prev_sysuser [$ current ][$ item ['id ' ]] = $ item ['sys_userid ' ];
463476 // we don't have to store these if y, as everything without previous state gets enabled later
464477
465- $ app ->db ->datalogUpdate ($ current , array (' active ' => ' n ' , 'sys_userid ' => $ _SESSION ["s " ]["user " ]["userid " ]), $ keycolumn , $ item ['id ' ]);
478+ $ app ->db ->datalogUpdate ($ current , array ($ active_col => ( $ reverse == true ? ' y ' : ' n ' ) , 'sys_userid ' => $ _SESSION ["s " ]["user " ]["userid " ]), $ keycolumn , $ item ['id ' ]);
466479 }
467480 }
468481
@@ -473,20 +486,31 @@ function onAfterUpdate() {
473486 unset($ prev_sysuser );
474487 } elseif ($ this ->dataRecord ['locked ' ] == 'n ' ) {
475488 foreach ($ to_disable as $ current => $ keycolumn ) {
489+ $ active_col = 'active ' ;
490+ $ reverse = false ;
491+ if ($ current == 'mail_user ' ) {
492+ $ active_col = 'postfix ' ;
493+ } elseif ($ current == 'mail_user_smtp ' ) {
494+ $ current = 'mail_user ' ;
495+ $ active_col = 'disablesmtp ' ;
496+ $ reverse = true ;
497+ }
498+
476499 $ entries = $ app ->db ->queryAllRecords ('SELECT ` ' . $ keycolumn . '` as `id` FROM ` ' . $ current . '` WHERE `sys_groupid` = ' . $ sys_groupid );
477500 foreach ($ entries as $ item ) {
478- $ set_active = 'y ' ;
501+ $ set_active = ($ reverse == true ? 'n ' : 'y ' );
502+ $ set_inactive = ($ reverse == true ? 'y ' : 'n ' );
479503 $ set_sysuser = $ sys_userid ;
480504 if (array_key_exists ('prev_active ' , $ tmp_data ) == true
481505 && array_key_exists ($ current , $ tmp_data ['prev_active ' ]) == true
482506 && array_key_exists ($ item ['id ' ], $ tmp_data ['prev_active ' ][$ current ]) == true
483- && $ tmp_data ['prev_active ' ][$ current ][$ item ['id ' ]] == ' n ' ) $ set_active = ' n ' ;
507+ && $ tmp_data ['prev_active ' ][$ current ][$ item ['id ' ]][ $ active_col ] == $ set_inactive ) $ set_active = $ set_inactive ;
484508 if (array_key_exists ('prev_sysuser ' , $ tmp_data ) == true
485509 && array_key_exists ($ current , $ tmp_data ['prev_sysuser ' ]) == true
486510 && array_key_exists ($ item ['id ' ], $ tmp_data ['prev_sysuser ' ][$ current ]) == true
487511 && $ tmp_data ['prev_sysuser ' ][$ current ][$ item ['id ' ]] != $ sys_userid ) $ set_sysuser = $ tmp_data ['prev_sysuser ' ][$ current ][$ item ['id ' ]];
488512
489- $ app ->db ->datalogUpdate ($ current , array (' active ' => $ set_active , 'sys_userid ' => $ set_sysuser ), $ keycolumn , $ item ['id ' ]);
513+ $ app ->db ->datalogUpdate ($ current , array ($ active_col => $ set_active , 'sys_userid ' => $ set_sysuser ), $ keycolumn , $ item ['id ' ]);
490514 }
491515 }
492516 if (array_key_exists ('prev_active ' , $ tmp_data )) unset($ tmp_data ['prev_active ' ]);
0 commit comments