| @@ -22,10 +22,10 @@ class limites { | |||
| public function __construct($cliente_group_id){ | |||
| global $app, $conf; | |||
| $this->cliente = $client = $app->db->queryOneRecord( | |||
| "SELECT limit_dns_zone, limit_web_domain, limit_database, parent_client_id | |||
| FROM sys_group, client | |||
| WHERE sys_group.client_id = client.client_id | |||
| and sys_group.groupid = ?", $cliente_group_id); | |||
| "SELECT limit_dns_zone, limit_web_domain, limit_database, parent_client_id, client.client_id, client.contact_name | |||
| FROM sys_group, client | |||
| WHERE sys_group.client_id = client.client_id | |||
| AND sys_group.groupid = ?", $cliente_group_id); | |||
| $this->cliente_grupo_id = $cliente_group_id; | |||
| } | |||
| @@ -44,7 +44,31 @@ class limites { | |||
| $this->revendedor = $tmpReseller['userid']; | |||
| $this->revendedor_grupos = $tmpReseller['groups']; | |||
| $this->revendedor_grupo_def = $tmpReseller['default_group']; | |||
| $this->revendedor_grupo_def = $tmpReseller['default_group']; | |||
| } | |||
| public $esReventa; | |||
| public $todosLosGrupos; | |||
| //public $gruposDelReventa; | |||
| public function esRevendedor(){ | |||
| global $app, $conf; | |||
| //PARA SABER QUIEN ES UN RESELLER | |||
| //SELECT client_id, company_name, limit_client FROM client WHERE limit_client > 0 OR limit_client = -1 | |||
| $this->esReventa = $app->db->queryOneRecord( | |||
| "SELECT client_id, limit_client, contact_name | |||
| FROM client | |||
| WHERE limit_client > 0 OR limit_client = -1 AND client_id = ?", $this->cliente['client_id']); | |||
| //El campo contact_name es obligatorio. Si viene vacío no es reventa. | |||
| if($this->esReventa['contact_name'] != ''){ | |||
| //Capturo los grupos que tiene este reventa | |||
| $gruposDelReventa = $app->db->queryOneRecord( | |||
| "SELECT client_id, groups FROM sys_user WHERE client_id = ?", $this->cliente['client_id']); | |||
| $this->todosLosGrupos = explode(',', $gruposDelReventa['groups']); | |||
| } | |||
| } | |||
| public function limClienteDns(){ | |||
| @@ -55,11 +79,13 @@ class limites { | |||
| if($this->cliente["limit_dns_zone"] >= 0) { | |||
| $tmp = $app->db->queryOneRecord( | |||
| "SELECT count(id) as number FROM dns_soa WHERE sys_groupid = ?", $this->cliente_grupo_id); | |||
| if($tmp["number"] >= $this->cliente["limit_dns_zone"]) { | |||
| $app->error($app->tform->wordbook["limit_dns_zone_txt"]); | |||
| return true; | |||
| } | |||
| } | |||
| //* If the client belongs to a reseller, we will check against the reseller Limit too | |||
| if($this->cliente['parent_client_id'] != 0) { | |||
| //* first we need to know the groups of this reseller | |||
| @@ -67,7 +93,7 @@ class limites { | |||
| //echo(' Valores '.$this->revendedor . ' otro ' . $this->revendedor_grupos . ' y otro ' .$this->revendedor_grupo_def); | |||
| //echo(' El cliente es ' . $this->cliente['parent_client_id']); | |||
| $reseller = $app->db->queryOneRecord( | |||
| "SELECT limit_dns_zone as number, contact_firstname FROM client WHERE client_id = ?", $this->cliente['parent_client_id']); | |||
| "SELECT limit_dns_zone as number, contact_name FROM client WHERE client_id = ?", $this->cliente['parent_client_id']); | |||
| //echo(' Cliente Reventa limites DNS ' . $reseller['number']); | |||
| // Check if the user may add another item | |||
| if($reseller['number'] >= 0) { | |||
| @@ -78,31 +104,29 @@ class limites { | |||
| "SELECT count(id) as number FROM dns_soa WHERE sys_groupid = ?", $this->revendedor_grupo_def); | |||
| $totalCreado = $tmpCliente['number'] + $tmpReventa['number']; | |||
| //echo(' Total creado ' . $totalCreado . ' el array ' . print_r($reseller). ' Y ' . $reseller['number']); | |||
| if($totalCreado >= $reseller['number']) { | |||
| $app->error($reseller['contact_firstname'] . '. ' . $app->tform->wordbook["limit_dns_zone_txt"]); | |||
| $app->error($reseller['contact_name'] . '. ' . $app->tform->wordbook["limit_dns_zone_txt"]); | |||
| return true; | |||
| } | |||
| /* $tmp = $app->db->queryOneRecord( | |||
| "SELECT count(id) as number FROM dns_soa WHERE sys_groupid = ?", explode(',', $this->revendedor_grupos)); | |||
| echo(' El temp registros en dns_soa usando grupo reseller ' .$tmp['number']);*/ | |||
| /* $sumaTotal = 0; | |||
| $todosLosGrupos = explode(',', $this->revendedor_grupos); | |||
| foreach($todosLosGrupos as $grupos) { | |||
| $tmpReventaALL = $app->db->queryOneRecord( | |||
| "SELECT count(id) as number FROM dns_soa WHERE sys_groupid = ?", $grupos); | |||
| $sql = "SELECT count(id) as number FROM dns_soa WHERE sys_groupid = ". $grupos; | |||
| echo(' Valores ' . $tmpReventaALL['number']); | |||
| $sumaTotal =+ $tmpReventaALL['number']; | |||
| echo($sumaTotal); | |||
| }*/ | |||
| /*if($tmp['number'] >= $reseller['number']) { | |||
| $app->error($app->tform->wordbook["limit_dns_zone_txt"]); | |||
| return true; | |||
| }*/ | |||
| } | |||
| } | |||
| $this->esRevendedor(); | |||
| $sumaTotal = 0; | |||
| foreach($this->todosLosGrupos as $grupos) { | |||
| $tmpReventaALL = $app->db->queryOneRecord( | |||
| "SELECT count(id) as number FROM dns_soa WHERE sys_groupid = ?", $grupos); | |||
| $sumaTotal += $tmpReventaALL['number']; | |||
| } | |||
| if($sumaTotal >= $this->cliente["limit_dns_zone"]) { | |||
| $app->error($this->esReventa['contact_name'] . '. ' . $app->tform->wordbook["limit_dns_zone_txt"]); | |||
| return true; | |||
| } | |||
| return false; | |||
| } | |||
| } | |||
| @@ -127,7 +151,7 @@ class limites { | |||
| $this->getRevendedor(); | |||
| $reseller = $app->db->queryOneRecord( | |||
| "SELECT limit_web_domain as number, contact_firstname FROM client WHERE client_id = ?", $this->cliente['parent_client_id']); | |||
| "SELECT limit_web_domain as number, contact_name FROM client WHERE client_id = ?", $this->cliente['parent_client_id']); | |||
| //echo(' Cliente Reventa limites DNS ' . $reseller['number']); | |||
| // Check if the user may add another item | |||
| if($reseller['number'] >= 0) { | |||
| @@ -142,11 +166,28 @@ class limites { | |||
| $totalCreado = $tmpCliente['number'] + $tmpReventa['number']; | |||
| if($totalCreado >= $reseller['number']) { | |||
| $app->error($reseller['contact_firstname'] . '. ' . $app->tform->wordbook["limit_web_domain_txt"]); | |||
| $app->error($reseller['contact_name'] . '. ' . $app->tform->wordbook["limit_web_domain_txt"]); | |||
| return true; | |||
| } | |||
| } | |||
| } | |||
| $this->esRevendedor(); | |||
| $sumaTotal = 0; | |||
| foreach($this->todosLosGrupos as $grupos) { | |||
| $tmpReventaALL = $app->db->queryOneRecord( | |||
| "SELECT count(domain_id) as number FROM web_domain | |||
| WHERE sys_groupid = ? and type = 'vhost'", $grupos); | |||
| $sumaTotal += $tmpReventaALL['number']; | |||
| } | |||
| if($sumaTotal >= $this->cliente["limit_web_domain"]) { | |||
| $app->error($this->esReventa['contact_name'] . '. ' . $app->tform->wordbook["limit_web_domain_txt"]); | |||
| return true; | |||
| } | |||
| return false; | |||
| } | |||
| } | |||
| @@ -171,7 +212,7 @@ class limites { | |||
| $this->getRevendedor(); | |||
| $reseller = $app->db->queryOneRecord( | |||
| "SELECT limit_database as number, contact_firstname FROM client WHERE client_id = ?", $this->cliente['parent_client_id']); | |||
| "SELECT limit_database as number, contact_name FROM client WHERE client_id = ?", $this->cliente['parent_client_id']); | |||
| //echo(' Cliente Reventa limites DNS ' . $reseller['number']); | |||
| // Check if the user may add another item | |||
| if($reseller['number'] >= 0) { | |||
| @@ -186,11 +227,28 @@ class limites { | |||
| $totalCreado = $tmpCliente['number'] + $tmpReventa['number']; | |||
| if($totalCreado >= $reseller['number']) { | |||
| $app->error($reseller['contact_firstname'] . '. ' . $app->tform->wordbook["limit_database_txt"]); | |||
| $app->error($reseller['contact_name'] . '. ' . $app->tform->wordbook["limit_database_txt"]); | |||
| return true; | |||
| } | |||
| } | |||
| } | |||
| $this->esRevendedor(); | |||
| $sumaTotal = 0; | |||
| foreach($this->todosLosGrupos as $grupos) { | |||
| $tmpReventaALL = $app->db->queryOneRecord( | |||
| "SELECT count(database_id) as number | |||
| FROM web_database WHERE sys_groupid = ?", $grupos); | |||
| $sumaTotal += $tmpReventaALL['number']; | |||
| } | |||
| if($sumaTotal >= $this->cliente["limit_database"]) { | |||
| $app->error($this->esReventa['contact_name'] . '. ' . $app->tform->wordbook["limit_database_txt"]); | |||
| return true; | |||
| } | |||
| return false; | |||
| } | |||
| } | |||