From ff6c40cc8fb9fa87e0dd28a8656e1ab9a02d8476 Mon Sep 17 00:00:00 2001
From: mcramer <m.cramer@pixcept.de>
Date: Tue, 11 Dec 2012 03:18:41 -0500
Subject: [PATCH] Updated: Changed meaning of '#' and '' for stored prefixes
---
interface/lib/classes/tools_sites.inc.php | 6 +++---
interface/web/sites/webdav_user_edit.php | 2 +-
interface/web/sites/shell_user_edit.php | 4 ++--
interface/web/sites/database_user_edit.php | 4 ++--
interface/web/sites/database_edit.php | 4 ++--
install/sql/incremental/upd_0046.sql | 11 +++++++++++
interface/web/sites/ftp_user_edit.php | 4 ++--
7 files changed, 23 insertions(+), 12 deletions(-)
diff --git a/install/sql/incremental/upd_0046.sql b/install/sql/incremental/upd_0046.sql
new file mode 100644
index 0000000..2addef6
--- /dev/null
+++ b/install/sql/incremental/upd_0046.sql
@@ -0,0 +1,11 @@
+
+ALTER TABLE `web_database` ADD `database_name_prefix` VARCHAR( 50 ) NOT NULL AFTER `database_name`;
+UPDATE `web_database` SET `database_name_prefix` = '#' WHERE 1;
+ALTER TABLE `web_database_user` ADD `database_user_prefix` VARCHAR( 50 ) NOT NULL AFTER `database_user`;
+UPDATE `web_database_user` SET `database_user_prefix` = '#' WHERE 1;
+ALTER TABLE `ftp_user` ADD `username_prefix` VARCHAR( 50 ) NOT NULL AFTER `username`;
+UPDATE `ftp_user` SET `username_prefix` = '#' WHERE 1;
+ALTER TABLE `shell_user` ADD `username_prefix` VARCHAR( 50 ) NOT NULL AFTER `username`;
+UPDATE `shell_user` SET `username_prefix` = '#' WHERE 1;
+ALTER TABLE `webdav_user` ADD `username_prefix` VARCHAR( 50 ) NOT NULL AFTER `username`;
+UPDATE `webdav_user` SET `username_prefix` = '#' WHERE 1;
\ No newline at end of file
diff --git a/interface/lib/classes/tools_sites.inc.php b/interface/lib/classes/tools_sites.inc.php
index 403f323..c501173 100644
--- a/interface/lib/classes/tools_sites.inc.php
+++ b/interface/lib/classes/tools_sites.inc.php
@@ -58,8 +58,8 @@
function removePrefix($name, $currentPrefix, $globalPrefix) {
if($name == "") return "";
- if($currentPrefix == '#') return $name; // # = empty prefix, do not change name
- if($currentPrefix === '') $currentPrefix = $globalPrefix; // entry has no prefix set, maybe it was created before this function was introduced
+ if($currentPrefix === '') return $name; // empty prefix, do not change name
+ if($currentPrefix === '#') $currentPrefix = $globalPrefix; // entry has no prefix set, maybe it was created before this function was introduced
if($currentPrefix === '') return $name; // no current prefix and global prefix is empty -> nothing to remove here.
@@ -69,7 +69,7 @@
function getPrefix($currentPrefix, $userPrefix, $adminPrefix = false) {
global $app;
- if($currentPrefix !== '') return ($currentPrefix == '#' ? '' : $currentPrefix); // return the currently set prefix for this entry (# = empty)
+ if($currentPrefix !== '#') return $currentPrefix; // return the currently set prefix for this entry (# = no prefix set yet)
if($adminPrefix === false) $adminPrefix = $userPrefix;
diff --git a/interface/web/sites/database_edit.php b/interface/web/sites/database_edit.php
index ccd6725..e43ec3d 100644
--- a/interface/web/sites/database_edit.php
+++ b/interface/web/sites/database_edit.php
@@ -197,7 +197,7 @@
//* Prevent that the database name and charset is changed
$old_record = $app->tform->getDataRecord($this->id);
$dbname_prefix = $app->tools_sites->getPrefix($old_record['database_name_prefix'], $dbname_prefix);
- $this->dataRecord['database_name_prefix'] = ($dbname_prefix === '' ? '#' : $dbname_prefix);
+ $this->dataRecord['database_name_prefix'] = $dbname_prefix;
if($old_record["database_name"] != $dbname_prefix . $this->dataRecord["database_name"]) {
$app->tform->errorMessage .= $app->tform->wordbook["database_name_change_txt"].'<br />';
@@ -269,7 +269,7 @@
$app->uses('getconf,tools_sites');
$global_config = $app->getconf->get_global_config('sites');
$dbname_prefix = $app->tools_sites->replacePrefix($global_config['dbname_prefix'], $this->dataRecord);
- $this->dataRecord['database_name_prefix'] = ($dbname_prefix === '' ? '#' : $dbname_prefix);
+ $this->dataRecord['database_name_prefix'] = $dbname_prefix;
if(strlen($dbname_prefix . $this->dataRecord['database_name']) > 64) $app->tform->errorMessage .= str_replace('{db}',$dbname_prefix . $this->dataRecord['database_name'],$app->tform->wordbook["database_name_error_len"]).'<br />';
diff --git a/interface/web/sites/database_user_edit.php b/interface/web/sites/database_user_edit.php
index f54362c..3444974 100644
--- a/interface/web/sites/database_user_edit.php
+++ b/interface/web/sites/database_user_edit.php
@@ -128,7 +128,7 @@
$this->oldDataRecord = $app->db->queryOneRecord("SELECT * FROM web_database_user WHERE database_user_id = '".$this->id."'");
$dbuser_prefix = $app->tools_sites->getPrefix($this->oldDataRecord['database_user_prefix'], $dbuser_prefix);
- $this->dataRecord['database_user_prefix'] = ($dbuser_prefix === '' ? '#' : $dbuser_prefix);
+ $this->dataRecord['database_user_prefix'] = $dbuser_prefix;
//* Database username shall not be empty
if($this->dataRecord['database_user'] == '') $app->tform->errorMessage .= $app->tform->wordbook["database_user_error_empty"].'<br />';
@@ -163,7 +163,7 @@
$global_config = $app->getconf->get_global_config('sites');
$dbuser_prefix = $app->tools_sites->replacePrefix($global_config['dbuser_prefix'], $this->dataRecord);
- $this->dataRecord['database_user_prefix'] = ($dbuser_prefix === '' ? '#' : $dbuser_prefix);
+ $this->dataRecord['database_user_prefix'] = $dbuser_prefix;
if(strlen($dbuser_prefix . $this->dataRecord['database_user']) > 16) $app->tform->errorMessage .= str_replace('{user}',$dbuser_prefix . $this->dataRecord['database_user'],$app->tform->wordbook["database_user_error_len"]).'<br />';
diff --git a/interface/web/sites/ftp_user_edit.php b/interface/web/sites/ftp_user_edit.php
index 674178d..455d126 100644
--- a/interface/web/sites/ftp_user_edit.php
+++ b/interface/web/sites/ftp_user_edit.php
@@ -113,7 +113,7 @@
$global_config = $app->getconf->get_global_config('sites');
$ftpuser_prefix = $app->tools_sites->replacePrefix($global_config['ftpuser_prefix'], $this->dataRecord);
- $this->dataRecord['username_prefix'] = ($ftpuser_prefix === '' ? '#' : $ftpuser_prefix);
+ $this->dataRecord['username_prefix'] = $ftpuser_prefix;
if ($app->tform->errorMessage == '') {
$this->dataRecord['username'] = $ftpuser_prefix . $this->dataRecord['username'];
@@ -151,7 +151,7 @@
$old_record = $app->tform->getDataRecord($this->id);
$ftpuser_prefix = $app->tools_sites->getPrefix($old_record['username_prefix'], $ftpuser_prefix);
- $this->dataRecord['username_prefix'] = ($ftpuser_prefix === '' ? '#' : $ftpuser_prefix);
+ $this->dataRecord['username_prefix'] = $ftpuser_prefix;
/* restrict the names */
if ($app->tform->errorMessage == '') {
diff --git a/interface/web/sites/shell_user_edit.php b/interface/web/sites/shell_user_edit.php
index f6b145f..6939d4a 100644
--- a/interface/web/sites/shell_user_edit.php
+++ b/interface/web/sites/shell_user_edit.php
@@ -135,7 +135,7 @@
$global_config = $app->getconf->get_global_config('sites');
$shelluser_prefix = $app->tools_sites->replacePrefix($global_config['shelluser_prefix'], $this->dataRecord);
- $this->dataRecord['username_prefix'] = ($shelluser_prefix === '' ? '#' : $shelluser_prefix);
+ $this->dataRecord['username_prefix'] = $shelluser_prefix;
/* restrict the names */
$this->dataRecord['username'] = $shelluser_prefix . $this->dataRecord['username'];
}
@@ -184,7 +184,7 @@
$old_record = $app->tform->getDataRecord($this->id);
$shelluser_prefix = $app->tools_sites->getPrefix($old_record['username_prefix'], $shelluser_prefix);
- $this->dataRecord['username_prefix'] = ($shelluser_prefix === '' ? '#' : $shelluser_prefix);
+ $this->dataRecord['username_prefix'] = $shelluser_prefix;
/* restrict the names */
$this->dataRecord['username'] = $shelluser_prefix . $this->dataRecord['username'];
diff --git a/interface/web/sites/webdav_user_edit.php b/interface/web/sites/webdav_user_edit.php
index 54261e2..c6eaaf9 100644
--- a/interface/web/sites/webdav_user_edit.php
+++ b/interface/web/sites/webdav_user_edit.php
@@ -128,7 +128,7 @@
$global_config = $app->getconf->get_global_config('sites');
$webdavuser_prefix = $app->tools_sites->replacePrefix($global_config['webdavuser_prefix'], $this->dataRecord);
- $this->dataRecord['username_prefix'] = ($webdavuser_prefix === '' ? '#' : $webdavuser_prefix);
+ $this->dataRecord['username_prefix'] = $webdavuser_prefix;
/* restrict the names */
$this->dataRecord['username'] = $webdavuser_prefix . $this->dataRecord['username'];
--
Gitblit v1.9.1