Skip to content

Commit 28b5263

Browse files
author
Marius Cramer
committed
Merge branch 'display_prefix_on_new' into 'master'
Display prefix on new When a client creates a new database or user which has prefix, prefix is not displayed until is created or error is returned. For clients, it's possible to display real prefix if CLIENTID or CLIENTNAME is used, if DOMAINID is used it will be displayed like [DOMAINID]. For reseller or admins, [CLIENTID], [CLIENTNAME] and [DOMAINID] will be displayed if client or domain is not selected. See merge request !112
2 parents 3f6ee66 + ba18a83 commit 28b5263

File tree

6 files changed

+28
-9
lines changed

6 files changed

+28
-9
lines changed

interface/lib/classes/tools_sites.inc.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@ function replacePrefix($name, $dataRecord) {
4747
$name=str_replace('['.$keyword.']', $this->getClientID($dataRecord), $name);
4848
break;
4949
case 'DOMAINID':
50-
$name=str_replace('['.$keyword.']', $dataRecord['parent_domain_id'], $name);
50+
$name=str_replace('['.$keyword.']', $dataRecord['parent_domain_id'] ? $dataRecord['parent_domain_id'] : '[DOMAINID]', $name);
5151
break;
5252
}
5353
}
@@ -92,7 +92,7 @@ function getClientName($dataRecord) {
9292
} elseif(isset($dataRecord['sys_groupid'])) {
9393
$client_group_id = $dataRecord['sys_groupid'];
9494
} else {
95-
$client_group_id = 0;
95+
return '[CLIENTNAME]';
9696
}
9797
}
9898

@@ -119,7 +119,7 @@ function getClientID($dataRecord) {
119119
} elseif(isset($dataRecord['sys_groupid'])) {
120120
$client_group_id = $dataRecord['sys_groupid'];
121121
} else {
122-
$client_group_id = 0;
122+
return '[CLIENTID]';
123123
}
124124
}
125125
$tmp = $app->db->queryOneRecord("SELECT client_id FROM sys_group WHERE groupid = " . $app->functions->intval($client_group_id));

interface/web/sites/database_edit.php

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -146,7 +146,11 @@ function onShowEnd() {
146146
$app->tpl->setVar("database_name", $app->tools_sites->removePrefix($this->dataRecord['database_name'], $this->dataRecord['database_name_prefix'], $dbname_prefix));
147147
}
148148

149-
$app->tpl->setVar("database_name_prefix", $app->tools_sites->getPrefix($this->dataRecord['database_name_prefix'], $dbname_prefix, $global_config['dbname_prefix']));
149+
if($this->dataRecord['database_name'] == "") {
150+
$app->tpl->setVar("database_name_prefix", $dbname_prefix);
151+
} else {
152+
$app->tpl->setVar("database_name_prefix", $app->tools_sites->getPrefix($this->dataRecord['database_name_prefix'], $dbname_prefix, $global_config['dbname_prefix']));
153+
}
150154

151155
if($this->id > 0) {
152156
//* we are editing a existing record

interface/web/sites/database_user_edit.php

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -103,8 +103,11 @@ function onShowEnd() {
103103
$app->tpl->setVar("database_user", $app->tools_sites->removePrefix($this->dataRecord['database_user'], $this->dataRecord['database_user_prefix'], $dbuser_prefix));
104104
}
105105

106-
107-
$app->tpl->setVar("database_user_prefix", $app->tools_sites->getPrefix($this->dataRecord['database_user_prefix'], $dbuser_prefix, $global_config['dbuser_prefix']));
106+
if($this->dataRecord['database_user'] == "") {
107+
$app->tpl->setVar("database_user_prefix", $dbuser_prefix);
108+
} else {
109+
$app->tpl->setVar("database_user_prefix", $app->tools_sites->getPrefix($this->dataRecord['database_user_prefix'], $dbuser_prefix, $global_config['dbuser_prefix']));
110+
}
108111

109112
parent::onShowEnd();
110113
}

interface/web/sites/ftp_user_edit.php

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -82,7 +82,11 @@ function onShowEnd() {
8282
$app->tpl->setVar("username", $app->tools_sites->removePrefix($this->dataRecord['username'], $this->dataRecord['username_prefix'], $ftpuser_prefix));
8383
}
8484

85-
$app->tpl->setVar("username_prefix", $app->tools_sites->getPrefix($this->dataRecord['username_prefix'], $ftpuser_prefix, $global_config['ftpuser_prefix']));
85+
if($this->dataRecord['username'] == "") {
86+
$app->tpl->setVar("username_prefix", $ftpuser_prefix);
87+
} else {
88+
$app->tpl->setVar("username_prefix", $app->tools_sites->getPrefix($this->dataRecord['username_prefix'], $ftpuser_prefix, $global_config['ftpuser_prefix']));
89+
}
8690

8791
parent::onShowEnd();
8892
}

interface/web/sites/shell_user_edit.php

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -82,7 +82,11 @@ function onShowEnd() {
8282
$app->tpl->setVar("username", $app->tools_sites->removePrefix($this->dataRecord['username'], $this->dataRecord['username_prefix'], $shelluser_prefix));
8383
}
8484

85-
$app->tpl->setVar("username_prefix", $app->tools_sites->getPrefix($this->dataRecord['username_prefix'], $shelluser_prefix, $global_config['shelluser_prefix']));
85+
if($this->dataRecord['username'] == "") {
86+
$app->tpl->setVar("username_prefix", $shelluser_prefix);
87+
} else {
88+
$app->tpl->setVar("username_prefix", $app->tools_sites->getPrefix($this->dataRecord['username_prefix'], $shelluser_prefix, $global_config['shelluser_prefix']));
89+
}
8690

8791
if($this->id > 0) {
8892
//* we are editing a existing record

interface/web/sites/webdav_user_edit.php

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -81,7 +81,11 @@ function onShowEnd() {
8181
$app->tpl->setVar("username", $app->tools_sites->removePrefix($this->dataRecord['username'], $this->dataRecord['username_prefix'], $webdavuser_prefix));
8282
}
8383

84-
$app->tpl->setVar("username_prefix", $app->tools_sites->getPrefix($this->dataRecord['username_prefix'], $webdavuser_prefix, $global_config['webdavuser_prefix']));
84+
if($this->dataRecord['username'] == "") {
85+
$app->tpl->setVar("username_prefix", $webdavuser_prefix);
86+
} else {
87+
$app->tpl->setVar("username_prefix", $app->tools_sites->getPrefix($this->dataRecord['username_prefix'], $webdavuser_prefix, $global_config['webdavuser_prefix']));
88+
}
8589

8690
if($this->id > 0) {
8791
//* we are editing a existing record

0 commit comments

Comments
 (0)