diff --git a/interface/lib/classes/remote.d/sites.inc.php b/interface/lib/classes/remote.d/sites.inc.php index a2f15d6f9d4f73c5bcd67c21ca407c20dfde052c..b311298103dc06bea1f22bf79e78579b84638e7b 100644 --- a/interface/lib/classes/remote.d/sites.inc.php +++ b/interface/lib/classes/remote.d/sites.inc.php @@ -435,7 +435,15 @@ class remoting_sites extends remoting { if($params['pm_min_spare_servers'] == '') $params['pm_min_spare_servers'] = 1; if($params['pm_max_spare_servers'] == '') $params['pm_max_spare_servers'] = 1; - $domain_id = $this->insertQuery('../sites/form/web_vhost_domain.tform.php', $client_id, $params, 'sites:web_vhost_domain:on_after_insert'); +// $domain_id = $this->insertQuery('../sites/form/web_vhost_domain.tform.php', $client_id, $params, 'sites:web_vhost_domain:on_after_insert', ['domain_id'=>'295']); + $sql = $this->insertQueryPrepare('../sites/form/web_vhost_domain.tform.php', $client_id, $params); + if($sql !== false) { + $force_domain_id = array_key_exists('domain_id', $params) ? $params['domain_id'] : 0 ; + $domain_id = $this->insertQueryExecuteWebDomainAdd($sql, $params, 'sites:web_vhost_domain:on_after_insert', $force_domain_id); + } else { + $domain_id = false ; + } + if ($readonly === true) $app->db->query("UPDATE web_domain SET `sys_userid` = '1' WHERE domain_id = ?", $domain_id); return $domain_id; @@ -1017,7 +1025,44 @@ class remoting_sites extends remoting { return $app->quota_lib->get_databasequota_data($client_id, false); } + + // This will execute the query, but optionally force the domain id to be something else before + // the event callers. + protected function insertQueryExecuteWebDomainAdd($sql, $params, $event_identifier = '', $force_domain_id = 0) + { + global $app; + + $app->uses('remoting_lib'); + + $app->db->query($sql); + + if($app->db->errorMessage != '') { + throw new SoapFault('database_error', $app->db->errorMessage . ' '.$sql); + return false; + } + + $insert_id = $app->db->insertID(); + + // set a few values for compatibility with tform actions, mostly used by plugins + $this->id = $insert_id; + $this->dataRecord = $params; + + if ( $force_domain_id >0) { + $res = $app->db->query("UPDATE web_domain set domain_id = ? where domain_id = ?", $force_domain_id, $this->id); + $this->id = $insert_id = $force_domain_id ; + } + + $app->log('Executed insertQueryExecute, raising events now if any: ' . $event_identifier, LOGLEVEL_DEBUG); + if($event_identifier != '') + $app->plugin->raiseEvent($event_identifier, $this); + + if($app->remoting_lib->formDef["db_history"] == 'yes') { + $new_rec = $app->remoting_lib->getDataRecord($insert_id); + $app->remoting_lib->datalogSave('INSERT', $primary_id, array(), $new_rec); + } + return $insert_id; + } } -?> +?> \ No newline at end of file