"Fossies" - the Fresh Open Source Software Archive

Member "ispconfig3_install/interface/web/client/reseller_edit.php" (8 Jun 2021, 21128 Bytes) of package /linux/privat/ISPConfig-3.2.5.tar.gz:


As a special service "Fossies" has tried to format the requested source page into HTML format using (guessed) PHP source code syntax highlighting (style: standard) with prefixed line numbers and code folding option. Alternatively you can here view or download the uninterpreted source code file. For more information about "reseller_edit.php" see the Fossies "Dox" file reference documentation and the latest Fossies "Diffs" side-by-side code changes report: 3.2.4_vs_3.2.5.

    1 <?php
    2 /*
    3 Copyright (c) 2005 - 2009, Till Brehm, projektfarm Gmbh
    4 All rights reserved.
    5 
    6 Redistribution and use in source and binary forms, with or without modification,
    7 are permitted provided that the following conditions are met:
    8 
    9     * Redistributions of source code must retain the above copyright notice,
   10       this list of conditions and the following disclaimer.
   11     * Redistributions in binary form must reproduce the above copyright notice,
   12       this list of conditions and the following disclaimer in the documentation
   13       and/or other materials provided with the distribution.
   14     * Neither the name of ISPConfig nor the names of its contributors
   15       may be used to endorse or promote products derived from this software without
   16       specific prior written permission.
   17 
   18 THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
   19 ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
   20 WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
   21 IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT,
   22 INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
   23 BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
   24 DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
   25 OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
   26 NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
   27 EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
   28 */
   29 
   30 
   31 /******************************************
   32 * Begin Form configuration
   33 ******************************************/
   34 
   35 $tform_def_file = "form/reseller.tform.php";
   36 
   37 /******************************************
   38 * End Form configuration
   39 ******************************************/
   40 
   41 require_once '../../lib/config.inc.php';
   42 require_once '../../lib/app.inc.php';
   43 
   44 //* Check permissions for module
   45 $app->auth->check_module_permissions('client');
   46 
   47 if($_SESSION["s"]["user"]["typ"] != 'admin') die('Access only for administrators.');
   48 
   49 // Loading classes
   50 $app->uses('tpl,tform,tform_actions');
   51 $app->load('tform_actions');
   52 
   53 class page_action extends tform_actions {
   54 
   55 
   56     function onShowNew() {
   57         global $app, $conf;
   58 
   59         // we will check only users, not admins
   60         if($_SESSION["s"]["user"]["typ"] == 'user') {
   61 
   62             // Get the limits of the client
   63             $client_group_id = $app->functions->intval($_SESSION["s"]["user"]["default_group"]);
   64             $client = $app->db->queryOneRecord("SELECT limit_client FROM sys_group, client WHERE sys_group.client_id = client.client_id and sys_group.groupid = ?", $client_group_id);
   65 
   66             // Check if the user may add another website.
   67             if($client["limit_client"] >= 0) {
   68                 $tmp = $app->db->queryOneRecord("SELECT count(client_id) as number FROM client WHERE sys_groupid = ?", $client_group_id);
   69                 if($tmp["number"] >= $client["limit_client"]) {
   70                     $app->error($app->tform->wordbook["limit_client_txt"]);
   71                 }
   72             }
   73         }
   74 
   75         parent::onShowNew();
   76     }
   77 
   78 
   79     function onSubmit() {
   80         global $app, $conf;
   81 
   82         // we will check only users, not admins
   83         if($_SESSION["s"]["user"]["typ"] == 'user' && $this->id == 0) {
   84 
   85             // Get the limits of the client
   86             $client_group_id = $app->functions->intval($_SESSION["s"]["user"]["default_group"]);
   87             $client = $app->db->queryOneRecord("SELECT limit_client FROM sys_group, client WHERE sys_group.client_id = client.client_id and sys_group.groupid = ?", $client_group_id);
   88 
   89             // Check if the user may add another website.
   90             if($client["limit_client"] >= 0) {
   91                 $tmp = $app->db->queryOneRecord("SELECT count(client_id) as number FROM client WHERE sys_groupid = ?", $client_group_id);
   92                 if($tmp["number"] >= $client["limit_client"]) {
   93                     $app->error($app->tform->wordbook["limit_client_txt"]);
   94                 }
   95             }
   96         }
   97 
   98         if($this->id != 0) {
   99             $this->oldTemplatesAssigned = $app->db->queryAllRecords('SELECT * FROM `client_template_assigned` WHERE `client_id` = ?', $this->id);
  100             if(!is_array($this->oldTemplatesAssigned) || count($this->oldTemplatesAssigned) < 1) {
  101                 // check previous type of storing templates
  102                 $tpls = explode('/', $this->oldDataRecord['template_additional']);
  103                 $this->oldTemplatesAssigned = array();
  104                 foreach($tpls as $item) {
  105                     $item = trim($item);
  106                     if(!$item) continue;
  107                     $this->oldTemplatesAssigned[] = array('assigned_template_id' => 0, 'client_template_id' => $item, 'client_id' => $this->id);
  108                 }
  109                 unset($tpls);
  110             }
  111         } else {
  112             $this->oldTemplatesAssigned = array();
  113         }
  114 
  115         $this->_template_additional = explode('/', $this->dataRecord['template_additional']);
  116         $this->dataRecord['template_additional'] = '';
  117 
  118         parent::onSubmit();
  119     }
  120 
  121 
  122     function onShowEnd() {
  123 
  124         global $app;
  125 
  126         $sql = "SELECT template_id,template_name FROM client_template WHERE template_type = 'a' ORDER BY template_name ASC";
  127         $tpls = $app->db->queryAllRecords($sql);
  128         $option = '';
  129         $tpl = array();
  130         $tpls = $app->functions->htmlentities($tpls);
  131         foreach($tpls as $item){
  132             $option .= '<option value="' . $item['template_id'] . '|' .  $item['template_name'] . '">' . $item['template_name'] . '</option>';
  133             $tpl[$item['template_id']] = $item['template_name'];
  134         }
  135         $app->tpl->setVar('tpl_add_select', $option);
  136 
  137         // check for new-style records
  138         $result = $app->db->queryAllRecords('SELECT assigned_template_id, client_template_id FROM client_template_assigned WHERE client_id = ?', $this->id);
  139         if($result && count($result) > 0) {
  140             // new style
  141             $items = array();
  142             $text = '';
  143             foreach($result as $item){
  144                 if (trim($item['client_template_id']) != ''){
  145                     if ($text != '') $text .= '';
  146                     $text .= '<li rel="' . $item['assigned_template_id'] . '">' . $tpl[$item['client_template_id']];
  147                     $text .= '&nbsp;<a href="#" class="btn btn-danger btn-xs"><span class="glyphicon glyphicon-remove-circle" aria-hidden="true"></a>';
  148                     $tmp = new stdClass();
  149                     $tmp->id = $item['assigned_template_id'];
  150                     $tmp->data = '';
  151                     $app->plugin->raiseEvent('get_client_template_details', $tmp);
  152                     if($tmp->data != '') $text .= '<br /><em>' . $app->functions->htmlentities($tmp->data) . '</em>';
  153 
  154                     $text .= '</li>';
  155                     $items[] = $item['assigned_template_id'] . ':' . $item['client_template_id'];
  156                 }
  157             }
  158 
  159             $tmprec = $app->tform->getHTML(array('template_additional' => implode('/', $items)), $this->active_tab, 'EDIT');
  160             $app->tpl->setVar('template_additional', $tmprec['template_additional']);
  161             unset($tmprec);
  162         } else {
  163             // old style
  164             $sql = "SELECT template_additional FROM client WHERE client_id = ?";
  165             $result = $app->db->queryOneRecord($sql, $this->id);
  166             $tplAdd = explode("/", $result['template_additional']);
  167             $text = '';
  168             foreach($tplAdd as $item){
  169                 if (trim($item) != ''){
  170                     if ($text != '') $text .= '';
  171                     $text .= '<li>' . $tpl[$item]. '&nbsp;<a href="#" class="btn btn-danger btn-xs"><span class="glyphicon glyphicon-remove-circle" aria-hidden="true"></a></li>';
  172                 }
  173             }
  174         }
  175 
  176         $app->tpl->setVar('template_additional_list', $text);
  177         $app->tpl->setVar('app_module', 'client');
  178 
  179         // Check wether per domain relaying is enabled or not
  180         $global_config = $app->getconf->get_global_config('mail');
  181         if($global_config['show_per_domain_relay_options'] == 'y') {
  182             $app->tpl->setVar("show_per_domain_relay_options", 1);
  183         } else {
  184             $app->tpl->setVar("show_per_domain_relay_options", 0);
  185         }
  186 
  187         // APS is enabled or not
  188         $global_config = $app->getconf->get_global_config('sites');
  189         if($global_config['show_aps_menu'] == 'y') {
  190             $app->tpl->setVar("show_aps_menu", 1);
  191         } else {
  192             $app->tpl->setVar("show_aps_menu", 0);
  193         }
  194 
  195         //* Set the 'customer no' default value
  196         if($this->id == 0) {
  197             //* get the system config
  198             $app->uses('getconf');
  199             $system_config = $app->getconf->get_global_config();
  200             if($system_config['misc']['customer_no_template'] != '') {
  201 
  202                 //* Set customer no default
  203                 $customer_no = $app->functions->intval($system_config['misc']['customer_no_start']+$system_config['misc']['customer_no_counter']);
  204                 $customer_no_string = str_replace('[CUSTOMER_NO]',$customer_no,$system_config['misc']['customer_no_template']);
  205                 $app->tpl->setVar('customer_no',$customer_no_string);
  206             }
  207         }
  208 
  209         parent::onShowEnd();
  210 
  211     }
  212 
  213     /*
  214      This function is called automatically right after
  215      the data was successful inserted in the database.
  216     */
  217     function onAfterInsert() {
  218         global $app, $conf;
  219 
  220         $app->uses('auth');
  221 
  222         // Create the group for the reseller
  223         $groupid = $app->db->datalogInsert('sys_group', array("name" => $this->dataRecord["username"], "description" => '', "client_id" => $this->id), 'groupid');
  224         $groups = $groupid;
  225 
  226         $username = $this->dataRecord["username"];
  227         $password = $this->dataRecord["password"];
  228         $modules = $conf['interface_modules_enabled'] . ',client';
  229         $startmodule = (stristr($modules, 'dashboard'))?'dashboard':'client';
  230         $usertheme = $this->dataRecord["usertheme"];
  231         $type = 'user';
  232         $active = 1;
  233         $language = $this->dataRecord["language"];
  234 
  235         $password = $app->auth->crypt_password(stripslashes($password));
  236 
  237         // Create the controlpaneluser for the reseller
  238         $sql = "INSERT INTO sys_user (`username`,`passwort`,`modules`,`startmodule`,`app_theme`,`typ`, `active`,`language`,`groups`,`default_group`,`client_id`)
  239         VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)";
  240         $app->db->query($sql, $username, $password, $modules, $startmodule, $usertheme, $type, $active, $language, $groups, $groupid, $this->id);
  241 
  242         //* set the number of clients to 1
  243         $app->db->query("UPDATE client SET limit_client = 1 WHERE client_id = ?", $this->id);
  244 
  245         //* Set the default servers
  246         $tmp = $app->db->queryOneRecord('SELECT server_id FROM server WHERE mail_server = 1 LIMIT 0,1');
  247         $default_mailserver = $app->functions->intval($tmp['server_id']);
  248         $tmp = $app->db->queryOneRecord('SELECT server_id FROM server WHERE web_server = 1 LIMIT 0,1');
  249         $default_webserver = $app->functions->intval($tmp['server_id']);
  250         $tmp = $app->db->queryOneRecord('SELECT server_id FROM server WHERE dns_server = 1 LIMIT 0,1');
  251         $default_dnsserver = $app->functions->intval($tmp['server_id']);
  252         $tmp = $app->db->queryOneRecord('SELECT server_id FROM server WHERE db_server = 1 LIMIT 0,1');
  253         $default_dbserver = $app->functions->intval($tmp['server_id']);
  254 
  255         $sql = "UPDATE client SET default_mailserver = ?, default_webserver = ?, default_dnsserver = ?, default_slave_dnsserver = ?, default_dbserver = ? WHERE client_id = ?";
  256         $app->db->query($sql, $default_mailserver, $default_webserver, $default_dnsserver, $default_dnsserver, $default_dbserver, $this->id);
  257 
  258         if(isset($this->dataRecord['template_master'])) {
  259             $app->uses('client_templates');
  260             $app->client_templates->update_client_templates($this->id, $this->_template_additional);
  261         }
  262 
  263         if($this->dataRecord['customer_no'] == $this->dataRecord['customer_no_org']) {
  264             //* get the system config
  265             $app->uses('getconf');
  266             $system_config = $app->getconf->get_global_config();
  267             if($system_config['misc']['customer_no_template'] != '') {
  268 
  269                 //* save new counter value
  270                 $system_config['misc']['customer_no_counter']++;
  271                 $system_config_str = $app->ini_parser->get_ini_string($system_config);
  272                 $app->db->datalogUpdate('sys_ini', array("config" => $system_config_str), 'sysini_id', 1);
  273 
  274             }
  275         }
  276 
  277         //* Send welcome email
  278         $client_group_id = $app->functions->intval($_SESSION["s"]["user"]["default_group"]);
  279         $sql = "SELECT * FROM client_message_template WHERE template_type = 'welcome' AND sys_groupid = ?";
  280         $email_template = $app->db->queryOneRecord($sql, $client_group_id);
  281         $client = $app->tform->getDataRecord($this->id);
  282 
  283         if(is_array($email_template) && $client['email'] != '') {
  284             //* Parse client details into message
  285             $message = $email_template['message'];
  286             $subject = $email_template['subject'];
  287             foreach($client as $key => $val) {
  288                 switch ($key) {
  289                 case 'password':
  290                     $message = str_replace('{password}', $this->dataRecord['password'], $message);
  291                     $subject = str_replace('{password}', $this->dataRecord['password'], $subject);
  292                     break;
  293                 case 'gender':
  294                     $message = str_replace('{salutation}', $wb['gender_'.$val.'_txt'], $message);
  295                     $subject = str_replace('{salutation}', $wb['gender_'.$val.'_txt'], $subject);
  296                     break;
  297                 default:
  298                     $message = str_replace('{'.$key.'}', $val, $message);
  299                     $subject = str_replace('{'.$key.'}', $val, $subject);
  300                 }
  301             }
  302 
  303             //* Get sender address
  304             if($app->auth->is_admin()) {
  305                 $app->uses('getconf');
  306                 $system_config = $app->getconf->get_global_config();
  307                 $from = $system_config['admin_mail'];
  308             } else {
  309                 $client_group_id = $app->functions->intval($_SESSION["s"]["user"]["default_group"]);
  310                 $reseller = $app->db->queryOneRecord("SELECT client.email FROM sys_group,client WHERE client.client_id = sys_group.client_id and sys_group.groupid = ?", $client_group_id);
  311                 $from = $reseller["email"];
  312             }
  313 
  314             //* Send the email
  315             $app->functions->mail($client['email'], $subject, $message, $from);
  316         }
  317 
  318         parent::onAfterInsert();
  319     }
  320 
  321 
  322     /*
  323      This function is called automatically right after
  324      the data was successful updated in the database.
  325     */
  326     function onAfterUpdate() {
  327         global $app, $conf;
  328 
  329         $app->uses('auth');
  330 
  331         // username changed
  332         if(isset($conf['demo_mode']) && $conf['demo_mode'] != true && isset($this->dataRecord['username']) && $this->dataRecord['username'] != '' && $this->oldDataRecord['username'] != $this->dataRecord['username']) {
  333             $username = $this->dataRecord["username"];
  334             $client_id = $this->id;
  335             $sql = "UPDATE sys_user SET username = ? WHERE client_id = ?";
  336             $app->db->query($sql, $username, $client_id);
  337 
  338             $tmp = $app->db->queryOneRecord("SELECT * FROM sys_group WHERE client_id = ?", $client_id);
  339             $app->db->datalogUpdate("sys_group", array("name" => $username), 'groupid', $tmp['groupid']);
  340             unset($tmp);
  341         }
  342 
  343         // password changed
  344         if(isset($conf['demo_mode']) && $conf['demo_mode'] != true && isset($this->dataRecord["password"]) && $this->dataRecord["password"] != '') {
  345             $password = $this->dataRecord["password"];
  346             $client_id = $this->id;
  347 
  348             $password = $app->auth->crypt_password(stripslashes($password));
  349             $sql = "UPDATE sys_user SET passwort = ? WHERE client_id = ?";
  350             $app->db->query($sql, $password, $client_id);
  351         }
  352 
  353         // language changed
  354         if(isset($conf['demo_mode']) && $conf['demo_mode'] != true && isset($this->dataRecord['language']) && $this->dataRecord['language'] != '' && $this->oldDataRecord['language'] != $this->dataRecord['language']) {
  355             $language = $this->dataRecord["language"];
  356             $client_id = $this->id;
  357             $sql = "UPDATE sys_user SET language = ? WHERE client_id = ?";
  358             $app->db->query($sql, $language, $client_id);
  359         }
  360 
  361         // ensure that a reseller is not converted to a client in demo mode when client_id <= 2
  362         if(isset($conf['demo_mode']) && $conf['demo_mode'] == true && $this->id <= 2) {
  363             if(isset($this->dataRecord["limit_client"]) && $this->dataRecord["limit_client"] != -1) {
  364                 $app->db->query('UPDATE client set limit_client = -1 WHERE client_id = ?', $this->id);
  365             }
  366         }
  367 
  368         // reseller status changed
  369         if(isset($this->dataRecord["limit_client"]) && $this->dataRecord["limit_client"] != $this->oldDataRecord["limit_client"]) {
  370             $modules = $conf['interface_modules_enabled'] . ',client';
  371             $modules = $modules;
  372             $client_id = $this->id;
  373             $sql = "UPDATE sys_user SET modules = ? WHERE client_id = ?";
  374             $app->db->query($sql, $modules, $client_id);
  375         }
  376 
  377         if(isset($this->dataRecord['template_master'])) {
  378             $app->uses('client_templates');
  379             $app->client_templates->update_client_templates($this->id, $this->_template_additional);
  380         }
  381 
  382         if(!isset($this->dataRecord['locked'])) $this->dataRecord['locked'] = 'n';
  383         if(isset($conf['demo_mode']) && $conf['demo_mode'] != true && $this->dataRecord["locked"] != $this->oldDataRecord['locked']) {
  384             /** lock all the things like web, mail etc. - easy to extend */
  385 
  386 
  387             // get tmp_data of client
  388             $client_data = $app->db->queryOneRecord('SELECT `tmp_data` FROM `client` WHERE `client_id` = ?', $this->id);
  389 
  390             if($client_data['tmp_data'] == '') $tmp_data = array();
  391             else $tmp_data = unserialize($client_data['tmp_data']);
  392 
  393             if(!is_array($tmp_data)) $tmp_data = array();
  394 
  395             // database tables with their primary key columns
  396             $to_disable = array('cron' => 'id',
  397                 'ftp_user' => 'ftp_user_id',
  398                 'mail_domain' => 'domain_id',
  399                 'mail_user' => 'mailuser_id',
  400                 'mail_user_smtp' => 'mailuser_id',
  401                 'mail_forwarding' => 'forwarding_id',
  402                 'mail_get' => 'mailget_id',
  403                 'openvz_vm' => 'vm_id',
  404                 'shell_user' => 'shell_user_id',
  405                 'webdav_user' => 'webdav_user_id',
  406                 'web_database' => 'database_id',
  407                 'web_domain' => 'domain_id',
  408                 'web_folder' => 'web_folder_id',
  409                 'web_folder_user' => 'web_folder_user_id'
  410             );
  411 
  412             $udata = $app->db->queryOneRecord('SELECT `userid` FROM `sys_user` WHERE `client_id` = ?', $this->id);
  413             $gdata = $app->db->queryOneRecord('SELECT `groupid` FROM `sys_group` WHERE `client_id` = ?', $this->id);
  414             $sys_groupid = $gdata['groupid'];
  415             $sys_userid = $udata['userid'];
  416 
  417             $entries = array();
  418             if($this->dataRecord['locked'] == 'y') {
  419                 $prev_active = array();
  420                 $prev_sysuser = array();
  421                 foreach($to_disable as $current => $keycolumn) {
  422                     $active_col = 'active';
  423                     $reverse = false;
  424                     if($current == 'mail_user') {
  425                         $active_col = 'postfix';
  426                     } elseif($current == 'mail_user_smtp') {
  427                         $current = 'mail_user';
  428                         $active_col = 'disablesmtp';
  429                         $reverse = true;
  430                     }
  431 
  432                     if(!isset($prev_active[$current])) $prev_active[$current] = array();
  433                     if(!isset($prev_sysuser[$current])) $prev_sysuser[$current] = array();
  434 
  435                     $entries = $app->db->queryAllRecords('SELECT ?? as `id`, `sys_userid`, ?? FROM ?? WHERE `sys_groupid` = ?', $keycolumn, $active_col, $current, $sys_groupid);
  436                     foreach($entries as $item) {
  437 
  438                         if($item[$active_col] != 'y' && $reverse == false) $prev_active[$current][$item['id']][$active_col] = 'n';
  439                         elseif($item[$active_col] == 'y' && $reverse == true) $prev_active[$current][$item['id']][$active_col] = 'y';
  440                         if($item['sys_userid'] != $sys_userid) $prev_sysuser[$current][$item['id']] = $item['sys_userid'];
  441                         // we don't have to store these if y, as everything without previous state gets enabled later
  442 
  443                         $app->db->datalogUpdate($current, array($active_col => ($reverse == true ? 'y' : 'n'), 'sys_userid' => $_SESSION["s"]["user"]["userid"]), $keycolumn, $item['id']);
  444                     }
  445                 }
  446 
  447                 $tmp_data['prev_active'] = $prev_active;
  448                 $tmp_data['prev_sys_userid'] = $prev_sysuser;
  449                 $app->db->query("UPDATE `client` SET `tmp_data` = ? WHERE `client_id` = ?", serialize($tmp_data), $this->id);
  450                 unset($prev_active);
  451                 unset($prev_sysuser);
  452             } elseif($this->dataRecord['locked'] == 'n') {
  453                 foreach($to_disable as $current => $keycolumn) {
  454                     $active_col = 'active';
  455                     $reverse = false;
  456                     if($current == 'mail_user') {
  457                         $active_col = 'postfix';
  458                     } elseif($current == 'mail_user_smtp') {
  459                         $current = 'mail_user';
  460                         $active_col = 'disablesmtp';
  461                         $reverse = true;
  462                     }
  463 
  464                     $entries = $app->db->queryAllRecords('SELECT ?? as `id` FROM ?? WHERE `sys_groupid` = ?', $keycolumn, $current, $sys_groupid);
  465                     foreach($entries as $item) {
  466                         $set_active = ($reverse == true ? 'n' : 'y');
  467                         $set_inactive = ($reverse == true ? 'y' : 'n');
  468                         $set_sysuser = $sys_userid;
  469                         if(array_key_exists('prev_active', $tmp_data) == true
  470                             && array_key_exists($current, $tmp_data['prev_active']) == true
  471                             && array_key_exists($item['id'], $tmp_data['prev_active'][$current]) == true
  472                             && $tmp_data['prev_active'][$current][$item['id']][$active_col] == $set_inactive) $set_active = $set_inactive;
  473                         if(array_key_exists('prev_sysuser', $tmp_data) == true
  474                             && array_key_exists($current, $tmp_data['prev_sysuser']) == true
  475                             && array_key_exists($item['id'], $tmp_data['prev_sysuser'][$current]) == true
  476                             && $tmp_data['prev_sysuser'][$current][$item['id']] != $sys_userid) $set_sysuser = $tmp_data['prev_sysuser'][$current][$item['id']];
  477 
  478                         $app->db->datalogUpdate($current, array($active_col => $set_active, 'sys_userid' => $set_sysuser), $keycolumn, $item['id']);
  479                     }
  480                 }
  481                 if(array_key_exists('prev_active', $tmp_data)) unset($tmp_data['prev_active']);
  482                 $app->db->query("UPDATE `client` SET `tmp_data` = ? WHERE `client_id` = ?", serialize($tmp_data), $this->id);
  483             }
  484             unset($tmp_data);
  485             unset($entries);
  486             unset($to_disable);
  487         }
  488 
  489         if(!isset($this->dataRecord['canceled'])) $this->dataRecord['canceled'] = 'n';
  490         if(isset($conf['demo_mode']) && $conf['demo_mode'] != true && $this->dataRecord["canceled"] != $this->oldDataRecord['canceled']) {
  491             if($this->dataRecord['canceled'] == 'y') {
  492                 $sql = "UPDATE sys_user SET active = '0' WHERE client_id = ?";
  493                 $app->db->query($sql, $this->id);
  494             } elseif($this->dataRecord['canceled'] == 'n') {
  495                 $sql = "UPDATE sys_user SET active = '1' WHERE client_id = ?";
  496                 $app->db->query($sql, $this->id);
  497             }
  498         }
  499 
  500         parent::onAfterUpdate();
  501     }
  502 
  503 }
  504 
  505 $page = new page_action;
  506 $page->onLoad();
  507 
  508 ?>