Skip to content

Commit bb37295

Browse files
author
Till Brehm
committed
Merge branch '6865-ispconfig-3-3-the-max-number-of-databases-is-reached' into 'develop'
Resolve "ISPConfig 3.3 - The max. number of databases is reached." Closes #6865 See merge request ispconfig/ispconfig3!2015
2 parents 63eedc4 + 0d860a3 commit bb37295

File tree

1 file changed

+11
-7
lines changed

1 file changed

+11
-7
lines changed

interface/web/sites/database_edit.php

Lines changed: 11 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -182,7 +182,7 @@ function onSubmit() {
182182
if($_SESSION["s"]["user"]["typ"] != 'admin') {
183183
// Get the limits of the client
184184
$client_group_id = $_SESSION["s"]["user"]["default_group"];
185-
$client = $app->db->queryOneRecord("SELECT db_servers, limit_database, limit_database_quota, parent_client_id FROM sys_group, client WHERE sys_group.client_id = client.client_id AND sys_group.groupid = ?", $client_group_id);
185+
$client = $app->db->queryOneRecord("SELECT db_servers, limit_database, limit_database_postgresql, limit_database_quota, parent_client_id FROM sys_group, client WHERE sys_group.client_id = client.client_id AND sys_group.groupid = ?", $client_group_id);
186186

187187
// When the record is updated
188188
if($this->id > 0) {
@@ -254,15 +254,15 @@ function onSubmit() {
254254
}
255255

256256
// Check if the user may add another MySQL database
257-
if($client["limit_database"] >= 0) {
257+
if($this->dataRecord["type"] == 'mysql' && $client["limit_database"] >= 0) {
258258
$tmp = $app->db->queryOneRecord("SELECT count(`database_id`) as `number` FROM `web_database` WHERE `type` = 'mysql' AND `sys_groupid` = ?", $client_group_id);
259259
if($tmp["number"] >= $client["limit_database"]) {
260260
$app->error($app->tform->wordbook["limit_database_txt"]);
261261
}
262262
}
263263

264264
// Check if the user may add another PostgreSQL database
265-
if($client["limit_database_postgresql"] >= 0) {
265+
if($this->dataRecord["type"] == 'postgresql' && $client["limit_database_postgresql"] >= 0) {
266266
$tmp = $app->db->queryOneRecord("SELECT count(`database_id`) as `number` FROM `web_database` WHERE `type` = 'postgresql' AND `sys_groupid` = ?", $client_group_id);
267267
if($tmp["number"] >= $client["limit_database_postgresql"]) {
268268
$app->error($app->tform->wordbook["limit_database_txt"]);
@@ -372,8 +372,10 @@ function onBeforeUpdate() {
372372
$tmp = $app->db->queryOneRecord('SELECT `database_id` FROM `web_database` WHERE `type` = "postgresql" AND `server_id` = ? AND (`database_user_id` = ? OR `database_ro_user_id` = ?) AND `database_id` != ?', $this->dataRecord['server_id'],$this->dataRecord['database_user_id'],$this->dataRecord['database_user_id'], $this->id);
373373
if(!empty($tmp)) $app->tform->errorMessage .= $app->tform->lng('error_db_user_in_use_txt').'<br />';
374374
// Check that database ro user is not used by any other postgres database
375-
$tmp = $app->db->queryOneRecord('SELECT `database_id` FROM `web_database` WHERE `type` = "postgresql" AND `server_id` = ? AND (`database_user_id` = ? OR `database_ro_user_id` = ?) AND `database_id` != ?', $this->dataRecord['server_id'],$this->dataRecord['database_ro_user_id'],$this->dataRecord['database_ro_user_id'], $this->id);
376-
if(!empty($tmp)) $app->tform->errorMessage .= $app->tform->lng('error_db_ro_user_in_use_txt').'<br />';
375+
if(!empty($this->dataRecord['database_ro_user_id']) && $this->dataRecord['database_ro_user_id'] != $this->dataRecord['database_user_id']) {
376+
$tmp = $app->db->queryOneRecord('SELECT `database_id` FROM `web_database` WHERE `type` = "postgresql" AND `server_id` = ? AND (`database_user_id` = ? OR `database_ro_user_id` = ?) AND `database_id` != ?', $this->dataRecord['server_id'],$this->dataRecord['database_ro_user_id'],$this->dataRecord['database_ro_user_id'], $this->id);
377+
if(!empty($tmp)) $app->tform->errorMessage .= $app->tform->lng('error_db_ro_user_in_use_txt').'<br />';
378+
}
377379
}
378380

379381
// get the web server ip (parent domain)
@@ -489,8 +491,10 @@ function onBeforeInsert() {
489491
$tmp = $app->db->queryOneRecord('SELECT `database_id` FROM `web_database` WHERE `type` = "postgresql" AND `server_id` = ? AND (`database_user_id` = ? OR `database_ro_user_id` = ?)', $this->dataRecord['server_id'],$this->dataRecord['database_user_id'],$this->dataRecord['database_user_id']);
490492
if(!empty($tmp)) $app->tform->errorMessage .= $app->tform->lng('error_db_user_in_use_txt').'<br />';
491493
// Check that database ro user is not used by any other postgres database
492-
$tmp = $app->db->queryOneRecord('SELECT `database_id` FROM `web_database` WHERE `type` = "postgresql" AND `server_id` = ? AND (`database_user_id` = ? OR `database_ro_user_id` = ?)', $this->dataRecord['server_id'],$this->dataRecord['database_ro_user_id'],$this->dataRecord['database_ro_user_id']);
493-
if(!empty($tmp)) $app->tform->errorMessage .= $app->tform->lng('error_db_ro_user_in_use_txt').'<br />';
494+
if(!empty($this->dataRecord['database_ro_user_id']) && $this->dataRecord['database_ro_user_id'] != $this->dataRecord['database_user_id']) {
495+
$tmp = $app->db->queryOneRecord('SELECT `database_id` FROM `web_database` WHERE `type` = "postgresql" AND `server_id` = ? AND (`database_user_id` = ? OR `database_ro_user_id` = ?)', $this->dataRecord['server_id'],$this->dataRecord['database_ro_user_id'],$this->dataRecord['database_ro_user_id']);
496+
if(!empty($tmp)) $app->tform->errorMessage .= $app->tform->lng('error_db_ro_user_in_use_txt').'<br />';
497+
}
494498
}
495499

496500
// get the web server ip (parent domain)

0 commit comments

Comments
 (0)