| @@ -410,13 +410,13 @@ class page_action extends tform_actions { | |||
| //IMPORTANTE. PARA QUE EL PLUGING FUNCIONE HAY QUE CARGAR ANTES EL FORMULARIO | |||
| //DE LO QUE SE QUIERE CREAR EN ESTE CASO SITIO WEB | |||
| //$tform_def_file = "../sites/form/database_user.tform.php"; | |||
| //$app->tform->loadFormDef($tform_def_file); | |||
| $tform_def_file = "../sites/form/database_user.tform.php"; | |||
| $app->tform->loadFormDef($tform_def_file); | |||
| $db_user_id = $remoto->insert_query('../sites/form/database_user.tform.php', | |||
| $this->cli_grupo_id, $db_user_params, 'sites:web_database_user:on_after_insert'); | |||
| $this->cli_id, $db_user_params, 'sites:web_database_user:on_after_insert'); | |||
| //echo('El id ' . $this->id); | |||
| $remoto2 = new remote_actions; | |||
| //$remoto2 = new remote_actions; | |||
| $remoto->sites_database_user_after_add($this->cli_grupo_id, $db_user_params); | |||
| //echo(' El cliente en webdns ' . $this->cli_id); | |||
| @@ -439,7 +439,7 @@ class page_action extends tform_actions { | |||
| $this->nombre_db_txt = $paramsBD['database_name']; | |||
| //IMPORTANTE. COMPROBAR EL VALOR QUE HAY QUE ENVIAR, SI ES CLI GRUPO Ó CLI ID | |||
| $db_id = $remoto->sites_database_add($this->cli_grupo_id, /*$this->cli_id,/*$fields['client_group_id'],*/ $paramsBD); | |||
| $db_id = $remoto->sites_database_add($this->cli_id, /*$this->cli_id,/*$fields['client_group_id'],*/ $paramsBD); | |||
| $this->urlBBDD($db_id, $this->bbdd_serv); | |||
| //echo('Id de la BBDD ' . $db_id); | |||
| @@ -474,8 +474,17 @@ class page_action extends tform_actions { | |||
| //print "<pre> FTP "; print_r($ftp_params); print "</pre>\n"; | |||
| //print "<pre>"; print_r($site_data); print "</pre>\n"; | |||
| //echo('El grupo del usuario es ' . $this->cli_grupo_id); | |||
| $tform_def_file = "../sites/form/ftp_user.tform.php"; | |||
| $app->tform->loadFormDef($tform_def_file); | |||
| $remoto->insert_query('../sites/form/ftp_user.tform.php', $this->cli_id,/*$fields['client_group_id'],*/ $ftp_params); | |||
| // $remoto->sites_ftp_user_after_insert(); | |||
| $app->uses('sites_ftp_user_plugin'); | |||
| global $app; | |||
| //Register for the events | |||
| $app->plugin->registerEvent('sites:ftp_user:on_after_insert'); | |||
| //Lo lanzo yo. | |||
| $remoto->sites_ftp_user_after_insert(); | |||
| echo '<br><div class="alert alert-success"><br> | |||
| Altas de BBDD y FTP, ¡Correctas!<br><br> | |||
| Usuario BBDD: <b>'. $this->usuario_db_txt .'</b><br>Contraseña: <b>' . $this->pass_db_txt . ' | |||
| @@ -727,7 +736,7 @@ class page_action extends tform_actions { | |||
| //Inserto en bbdd usando la clase remoto que se la he pasado en parámetros de la función | |||
| //$resultado = $remoto->insert_query('../dns/form/dns_a.tform.php', $fields['client_id'], $paramSubDominios); | |||
| $resultado = $remoto->insert_query('form/dns_a_webdns.tform.php', $this->cli_id, /*$fields['client_group_id'],*/ $paramSubDominios); | |||
| //$remoto->dns_registro_tipo_a_after_insert(); | |||
| $remoto->dns_registro_tipo_a_after_insert($this->cli_grupo_id); | |||
| echo '<br><div class="alert alert-success"><br> | |||
| Se ha dado de alta Web y Subdominio, <b>'.$this->subdominio.'</b>, ¡Correctamente! | |||
| <br><br></div></br>'; | |||
| @@ -1724,24 +1733,43 @@ class remote_actions extends remoting { | |||
| $app->db->datalogUpdate('dns_rr', array("sys_userid" => $cliente_grupo_id, | |||
| "sys_groupid" => $cliente_grupo_id), 'id', $dns_rr_id); | |||
| } | |||
| if($_SESSION["s"]["user"]["typ"] == 'admin') { | |||
| $app->db->datalogUpdate('dns_rr', array("sys_userid" => 1, //$cliente_grupo_id, | |||
| "sys_groupid" => $cliente_grupo_id), 'id', $dns_rr_id); | |||
| } | |||
| } | |||
| function dns_soa_after_insert($dns_soa_id, $cliente_grupo_id) { | |||
| global $app, $conf; | |||
| //echo(' el cliente grupo id ' . $cliente_grupo_id . ' el id tupla en dns_rr ' . $dns_rr_id); | |||
| //echo(' el cliente grupo id ' . $cliente_grupo_id . ' el id tupla en dns_rr ' . $dns_soa_id . ' sys usuario ' . $sys_usuario_id); | |||
| if($_SESSION["s"]["user"]["typ"] == 'user') { | |||
| $app->db->datalogUpdate('dns_soa', array("sys_userid" => $cliente_grupo_id, | |||
| "sys_groupid" => $cliente_grupo_id), 'id', $dns_soa_id); | |||
| } | |||
| if($_SESSION["s"]["user"]["typ"] == 'admin') { | |||
| $app->db->datalogUpdate('dns_soa', array("sys_userid" => 1, //$cliente_grupo_id, | |||
| "sys_groupid" => $cliente_grupo_id), 'id', $dns_soa_id); | |||
| } | |||
| } | |||
| function dns_registro_tipo_a_after_insert() { | |||
| function dns_registro_tipo_a_after_insert($cli_grupo_id) { | |||
| global $app, $conf; | |||
| //echo(' el valor zone ' . $this->dataRecord["zone"]); | |||
| //* Set the sys_groupid of the rr record to be the same then the sys_groupid of the soa record | |||
| $soa = $app->db->queryOneRecord("SELECT * FROM dns_soa WHERE id = ? AND " . $this->getAuthSQLWebDNS('r'), $this->dataRecord["zone"]); | |||
| $app->db->datalogUpdate('dns_rr', array("sys_groupid" => $soa['sys_groupid']), 'id', $this->id); | |||
| if($_SESSION["s"]["user"]["typ"] == 'user') { | |||
| $soa = $app->db->queryOneRecord("SELECT * FROM dns_soa WHERE id = ? AND " . $this->getAuthSQLWebDNS('r'), $this->dataRecord["zone"]); | |||
| $app->db->datalogUpdate('dns_rr', array("sys_groupid" => $soa['sys_groupid']), 'id', $this->id); | |||
| } | |||
| /*if($_SESSION["s"]["user"]["typ"] == 'admin') { | |||
| $soa = $app->db->queryOneRecord("SELECT * FROM dns_soa WHERE id = ? AND " . $this->getAuthSQLWebDNS('r'), $this->dataRecord["zone"]); | |||
| $app->db->datalogUpdate('dns_rr', array("sys_groupid" => $soa['sys_groupid']), 'id', $this->id); | |||
| }*/ | |||
| if($app->auth->has_clients($_SESSION['s']['user']['userid'])) { | |||
| $soa = $app->db->queryOneRecord("SELECT * FROM dns_soa WHERE id = ? AND " . $this->getAuthSQLWebDNS('r'), $this->dataRecord["zone"]); | |||
| $app->db->datalogUpdate('dns_rr', array("sys_groupid" => $cli_grupo_id), 'id', $this->id); | |||
| } | |||
| //* Update the serial number of the SOA record | |||
| /*$soa_id = $app->functions->intval($_POST["zone"]); | |||
| $serial = $app->validate_dns->increase_serial($soa["serial"]); | |||
| @@ -1751,18 +1779,18 @@ class remote_actions extends remoting { | |||
| public function sites_database_user_after_add($client_id, $params){ | |||
| global $app, $conf; | |||
| //echo('Plugeando'); | |||
| if($_SESSION["s"]["user"]["typ"] == 'user' /*&& isset($this->dataRecord["client_group_id"])*/) { | |||
| // if($_SESSION["s"]["user"]["typ"] == 'user' /*&& isset($this->dataRecord["client_group_id"])*/) { | |||
| //$client_group_id = $app->functions->intval($this->dataRecord["client_group_id"]); | |||
| $app->db->query("UPDATE web_database_user SET sys_groupid = ?, sys_perm_group = 'riud' WHERE database_user_id = ?", $client_id, $this->id); | |||
| } | |||
| if($_SESSION["s"]["user"]["typ"] == 'admin'/* && isset($this->dataRecord["client_group_id"])*/) { | |||
| /* } | |||
| if($_SESSION["s"]["user"]["typ"] == 'admin'/* && isset($this->dataRecord["client_group_id"])*///) { | |||
| //echo('Plugeando ' .$app->functions->intval($this->dataRecord["client_group_id"]) . ' y ' . $client_id . ' id ' . $this->id); | |||
| //$client_group_id = $app->functions->intval($this->dataRecord["client_group_id"]); | |||
| $app->db->query("UPDATE web_database_user SET sys_groupid = ?, sys_perm_group = 'riud' WHERE database_user_id = ?", $client_id, $this->id); | |||
| /* $app->db->query("UPDATE web_database_user SET sys_groupid = ?, sys_perm_group = 'riud' WHERE database_user_id = ?", $client_id, $this->id); | |||
| } | |||
| if($app->auth->has_clients($_SESSION['s']['user']['userid'])/* && isset($this->dataRecord["client_group_id"])*/) { | |||
| if($app->auth->has_clients($_SESSION['s']['user']['userid'])/* && isset($this->dataRecord["client_group_id"])*///) { | |||
| //$client_group_id = $app->functions->intval($this->dataRecord["client_group_id"]); | |||
| $app->db->query("UPDATE web_database_user SET sys_groupid = ?, sys_perm_group = 'riud' WHERE database_user_id = ?", $client_id, $this->id); | |||
| /* $app->db->query("UPDATE web_database_user SET sys_groupid = ?, sys_perm_group = 'riud' WHERE database_user_id = ?", $client_id, $this->id); | |||
| } | |||
| $app->uses('sites_web_database_user_plugin'); | |||
| @@ -1770,7 +1798,7 @@ class remote_actions extends remoting { | |||
| //Register for the events | |||
| $app->plugin->registerEvent('sites:web_database_user:on_after_update', 'sites_web_database_user_plugin', 'sites_web_database_user_edit'); | |||
| $app->plugin->registerEvent('sites:web_database_user:on_after_insert', 'sites_web_database_user_plugin', 'sites_web_database_user_edit'); | |||
| */ | |||
| } | |||
| public function sites_database_user_add($session_id, $client_id, $params, $event_identifier = '') { | |||
| @@ -1858,7 +1886,12 @@ class remote_actions extends remoting { | |||
| public function sites_database_add($client_id, $params){ | |||
| global $app, $conf; | |||
| //$app->remoting_lib->loadFormDef('../sites/form/database.tform.php'); | |||
| //IMPORTANTE. PARA QUE EL PLUGING FUNCIONE HAY QUE CARGAR ANTES EL FORMULARIO | |||
| //DE LO QUE SE QUIERE CREAR EN ESTE CASO SITIO WEB | |||
| $tform_def_file = "../sites/form/database.tform.php"; | |||
| $app->tform->loadFormDef($tform_def_file); | |||
| $app->remoting_lib->loadFormDef('../sites/form/database.tform.php'); | |||
| //$app->tform->formDef('../sites/form/database.tform.php'); | |||
| //$sql = $app->remoting->insertQueryPrepare('../sites/form/database.tform.php', $client_id, $params); | |||
| $sql = $this->insertQueryPrepareWebDNS('../sites/form/database.tform.php', $client_id, $params); | |||
| @@ -1871,10 +1904,11 @@ class remote_actions extends remoting { | |||
| //$app->uses('sites_database_plugin'); | |||
| $app->sites_database_plugin->processDatabaseInsert($this); | |||
| //$app->sites_database_plugin->processDatabaseInsert($this); | |||
| //$retval = $this->insertQueryExecute($sql, $params); | |||
| $retval = $this->insertQueryExecuteWebDNS($sql, $params); | |||
| $app->sites_database_plugin->processDatabaseInsert($this); | |||
| //$app->plugin->raiseEvent('sites:web_database:on_after_insert', $this); | |||
| // set correct values for backup_interval and backup_copies | |||
| /*if(isset($params['backup_interval']) || isset($params['backup_copies'])){ | |||
| $sql_set = array(); | |||