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