mcramer
2012-12-11 ff6c40cc8fb9fa87e0dd28a8656e1ab9a02d8476
Updated: Changed meaning of '#' and '' for stored prefixes

6 files modified
1 files added
35 ■■■■■ changed files
install/sql/incremental/upd_0046.sql 11 ●●●●● patch | view | raw | blame | history
interface/lib/classes/tools_sites.inc.php 6 ●●●● patch | view | raw | blame | history
interface/web/sites/database_edit.php 4 ●●●● patch | view | raw | blame | history
interface/web/sites/database_user_edit.php 4 ●●●● patch | view | raw | blame | history
interface/web/sites/ftp_user_edit.php 4 ●●●● patch | view | raw | blame | history
interface/web/sites/shell_user_edit.php 4 ●●●● patch | view | raw | blame | history
interface/web/sites/webdav_user_edit.php 2 ●●● patch | view | raw | blame | history
install/sql/incremental/upd_0046.sql
New file
@@ -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;
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;
        
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 />';
        
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 />';
        
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 == '') {
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'];
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'];