@@ -425,123 +425,16 @@ function onAfterUpdate() {
425425 $ app ->db ->query ($ sql , $ password , $ client_id );
426426 }
427427
428- if (!isset ($ this ->dataRecord ['locked ' ])) $ this ->dataRecord ['locked ' ] = 'n ' ;
429- if (isset ($ conf ['demo_mode ' ]) && $ conf ['demo_mode ' ] != true && $ this ->dataRecord ["locked " ] != $ this ->oldDataRecord ['locked ' ]) {
430- /** lock all the things like web, mail etc. - easy to extend */
431-
432-
433- // get tmp_data of client
434- $ client_data = $ app ->db ->queryOneRecord ('SELECT `tmp_data` FROM `client` WHERE `client_id` = ? ' , $ this ->id );
435-
436- if ($ client_data ['tmp_data ' ] == '' ) $ tmp_data = array ();
437- else $ tmp_data = unserialize ($ client_data ['tmp_data ' ]);
438-
439- if (!is_array ($ tmp_data )) $ tmp_data = array ();
440-
441- // database tables with their primary key columns
442- $ to_disable = array ('cron ' => 'id ' ,
443- 'ftp_user ' => 'ftp_user_id ' ,
444- 'mail_domain ' => 'domain_id ' ,
445- 'mail_user ' => 'mailuser_id ' ,
446- 'mail_user_smtp ' => 'mailuser_id ' ,
447- 'mail_forwarding ' => 'forwarding_id ' ,
448- 'mail_get ' => 'mailget_id ' ,
449- 'openvz_vm ' => 'vm_id ' ,
450- 'shell_user ' => 'shell_user_id ' ,
451- 'webdav_user ' => 'webdav_user_id ' ,
452- 'web_database ' => 'database_id ' ,
453- 'web_domain ' => 'domain_id ' ,
454- 'web_folder ' => 'web_folder_id ' ,
455- 'web_folder_user ' => 'web_folder_user_id '
456- );
457-
458- $ udata = $ app ->db ->queryOneRecord ('SELECT `userid` FROM `sys_user` WHERE `client_id` = ? ' , $ this ->id );
459- $ gdata = $ app ->db ->queryOneRecord ('SELECT `groupid` FROM `sys_group` WHERE `client_id` = ? ' , $ this ->id );
460- $ sys_groupid = $ gdata ['groupid ' ];
461- $ sys_userid = $ udata ['userid ' ];
462-
463- $ entries = array ();
464- if ($ this ->dataRecord ['locked ' ] == 'y ' ) {
465- $ prev_active = array ();
466- $ prev_sysuser = array ();
467- foreach ($ to_disable as $ current => $ keycolumn ) {
468- $ active_col = 'active ' ;
469- $ reverse = false ;
470- if ($ current == 'mail_user ' ) {
471- $ active_col = 'postfix ' ;
472- } elseif ($ current == 'mail_user_smtp ' ) {
473- $ current = 'mail_user ' ;
474- $ active_col = 'disablesmtp ' ;
475- $ reverse = true ;
476- }
477-
478- if (!isset ($ prev_active [$ current ])) $ prev_active [$ current ] = array ();
479- if (!isset ($ prev_sysuser [$ current ])) $ prev_sysuser [$ current ] = array ();
480-
481- $ entries = $ app ->db ->queryAllRecords ('SELECT ?? as `id`, `sys_userid`, ?? FROM ?? WHERE `sys_groupid` = ? ' , $ keycolumn , $ active_col , $ current , $ sys_groupid );
482- foreach ($ entries as $ item ) {
483-
484- if ($ item [$ active_col ] != 'y ' && $ reverse == false ) $ prev_active [$ current ][$ item ['id ' ]][$ active_col ] = 'n ' ;
485- elseif ($ item [$ active_col ] == 'y ' && $ reverse == true ) $ prev_active [$ current ][$ item ['id ' ]][$ active_col ] = 'y ' ;
486- if ($ item ['sys_userid ' ] != $ sys_userid ) $ prev_sysuser [$ current ][$ item ['id ' ]] = $ item ['sys_userid ' ];
487- // we don't have to store these if y, as everything without previous state gets enabled later
488-
489- $ app ->db ->datalogUpdate ($ current , array ($ active_col => ($ reverse == true ? 'y ' : 'n ' ), 'sys_userid ' => $ _SESSION ["s " ]["user " ]["userid " ]), $ keycolumn , $ item ['id ' ]);
490- }
491- }
492-
493- $ tmp_data ['prev_active ' ] = $ prev_active ;
494- $ tmp_data ['prev_sys_userid ' ] = $ prev_sysuser ;
495- $ app ->db ->query ("UPDATE `client` SET `tmp_data` = ? WHERE `client_id` = ? " , serialize ($ tmp_data ), $ this ->id );
496- unset($ prev_active );
497- unset($ prev_sysuser );
498- } elseif ($ this ->dataRecord ['locked ' ] == 'n ' ) {
499- foreach ($ to_disable as $ current => $ keycolumn ) {
500- $ active_col = 'active ' ;
501- $ reverse = false ;
502- if ($ current == 'mail_user ' ) {
503- $ active_col = 'postfix ' ;
504- } elseif ($ current == 'mail_user_smtp ' ) {
505- $ current = 'mail_user ' ;
506- $ active_col = 'disablesmtp ' ;
507- $ reverse = true ;
508- }
509-
510- $ entries = $ app ->db ->queryAllRecords ('SELECT ?? as `id` FROM ?? WHERE `sys_groupid` = ? ' , $ keycolumn , $ current , $ sys_groupid );
511- foreach ($ entries as $ item ) {
512- $ set_active = ($ reverse == true ? 'n ' : 'y ' );
513- $ set_inactive = ($ reverse == true ? 'y ' : 'n ' );
514- $ set_sysuser = $ sys_userid ;
515- if (array_key_exists ('prev_active ' , $ tmp_data ) == true
516- && array_key_exists ($ current , $ tmp_data ['prev_active ' ]) == true
517- && array_key_exists ($ item ['id ' ], $ tmp_data ['prev_active ' ][$ current ]) == true
518- && $ tmp_data ['prev_active ' ][$ current ][$ item ['id ' ]][$ active_col ] == $ set_inactive ) $ set_active = $ set_inactive ;
519- if (array_key_exists ('prev_sysuser ' , $ tmp_data ) == true
520- && array_key_exists ($ current , $ tmp_data ['prev_sysuser ' ]) == true
521- && array_key_exists ($ item ['id ' ], $ tmp_data ['prev_sysuser ' ][$ current ]) == true
522- && $ tmp_data ['prev_sysuser ' ][$ current ][$ item ['id ' ]] != $ sys_userid ) $ set_sysuser = $ tmp_data ['prev_sysuser ' ][$ current ][$ item ['id ' ]];
523-
524- $ app ->db ->datalogUpdate ($ current , array ($ active_col => $ set_active , 'sys_userid ' => $ set_sysuser ), $ keycolumn , $ item ['id ' ]);
525- }
526- }
527- if (array_key_exists ('prev_active ' , $ tmp_data )) unset($ tmp_data ['prev_active ' ]);
528- $ app ->db ->query ("UPDATE `client` SET `tmp_data` = ? WHERE `client_id` = ? " , serialize ($ tmp_data ), $ this ->id );
529- }
530- unset($ tmp_data );
531- unset($ entries );
532- unset($ to_disable );
533- }
534-
535- if (!isset ($ this ->dataRecord ['canceled ' ])) $ this ->dataRecord ['canceled ' ] = 'n ' ;
536- if (isset ($ conf ['demo_mode ' ]) && $ conf ['demo_mode ' ] != true && $ this ->dataRecord ["canceled " ] != $ this ->oldDataRecord ['canceled ' ]) {
537- if ($ this ->dataRecord ['canceled ' ] == 'y ' ) {
538- $ sql = "UPDATE sys_user SET active = '0' WHERE client_id = ? " ;
539- $ app ->db ->query ($ sql , $ this ->id );
540- } elseif ($ this ->dataRecord ['canceled ' ] == 'n ' ) {
541- $ sql = "UPDATE sys_user SET active = '1' WHERE client_id = ? " ;
542- $ app ->db ->query ($ sql , $ this ->id );
543- }
544- }
428+ // lock and cancel
429+ if (!isset ($ this ->dataRecord ['locked ' ])) $ this ->dataRecord ['locked ' ] = 'n ' ;
430+ if (isset ($ conf ['demo_mode ' ]) && $ conf ['demo_mode ' ] != true && $ this ->dataRecord ["locked " ] != $ this ->oldDataRecord ['locked ' ]) {
431+ $ lock = functions::func_client_lock ($ this ->id ,$ this ->dataRecord ["locked " ]);
432+ }
433+
434+ if (!isset ($ this ->dataRecord ['canceled ' ])) $ this ->dataRecord ['canceled ' ] = 'n ' ;
435+ if (isset ($ conf ['demo_mode ' ]) && $ conf ['demo_mode ' ] != true && $ this ->dataRecord ["canceled " ] != $ this ->oldDataRecord ['canceled ' ]) {
436+ $ cancel = functions::func_client_cancel ($ this ->id ,$ this ->dataRecord ["canceled " ]);
437+ }
545438
546439 // language changed
547440 if (isset ($ conf ['demo_mode ' ]) && $ conf ['demo_mode ' ] != true && isset ($ this ->dataRecord ['language ' ]) && $ this ->dataRecord ['language ' ] != '' && $ this ->oldDataRecord ['language ' ] != $ this ->dataRecord ['language ' ]) {
0 commit comments