openrat-cms

# OpenRat Content Management System
git clone http://git.code.weiherhei.de/openrat-cms.git
Log | Files | Refs

commit 470f36b5dcb35d32dc01637b71d0fdc5d6594154
parent 0963f464809c32df128456829155f5cb64489950
Author: Jan Dankert <develop@jandankert.de>
Date:   Sun, 23 Feb 2020 00:30:10 +0100

Refactoring: Namespacing for module 'database-update', now called 'cms\update'.

Diffstat:
modules/cms-core/Dispatcher.class.php | 6+++---
modules/cms-core/action/LoginAction.class.php | 2+-
modules/cms-core/require.php | 1-
modules/cms/update/.htaccess | 3+++
modules/cms/update/Update.class.php | 146+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
modules/cms/update/version/DBVersion000001.class.php | 340+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
modules/cms/update/version/DBVersion000002.class.php | 29+++++++++++++++++++++++++++++
modules/cms/update/version/DBVersion000003.class.php | 20++++++++++++++++++++
modules/cms/update/version/DBVersion000004.class.php | 30++++++++++++++++++++++++++++++
modules/cms/update/version/DBVersion000005.class.php | 37+++++++++++++++++++++++++++++++++++++
modules/cms/update/version/DBVersion000006.class.php | 41+++++++++++++++++++++++++++++++++++++++++
modules/cms/update/version/DBVersion000007.class.php | 43+++++++++++++++++++++++++++++++++++++++++++
modules/cms/update/version/DBVersion000008.class.php | 59+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
modules/cms/update/version/DBVersion000009.class.php | 64++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
modules/cms/update/version/DBVersion000010.class.php | 42++++++++++++++++++++++++++++++++++++++++++
modules/cms/update/version/DBVersion000011.class.php | 62++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
modules/cms/update/version/DBVersion000012.class.php | 28++++++++++++++++++++++++++++
modules/cms/update/version/DBVersion000013.class.php | 26++++++++++++++++++++++++++
modules/cms/update/version/DBVersion000014.class.php | 27+++++++++++++++++++++++++++
modules/cms/update/version/DBVersion000015.class.php | 26++++++++++++++++++++++++++
modules/cms/update/version/DBVersion000016.class.php | 124+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
modules/cms/update/version/DBVersion000017.class.php | 25+++++++++++++++++++++++++
modules/cms/update/version/DBVersion000018.class.php | 36++++++++++++++++++++++++++++++++++++
modules/cms/update/version/DBVersion000019.class.php | 35+++++++++++++++++++++++++++++++++++
modules/cms/update/version/DBVersion000020.class.php | 39+++++++++++++++++++++++++++++++++++++++
modules/cms/update/version/DBVersion000021.class.php | 39+++++++++++++++++++++++++++++++++++++++
modules/database-update/.htaccess | 3---
modules/database-update/DbUpdate.class.php | 152-------------------------------------------------------------------------------
modules/database-update/require.php | 6------
modules/database-update/update/DBVersion000001.class.php | 338-------------------------------------------------------------------------------
modules/database-update/update/DBVersion000002.class.php | 26--------------------------
modules/database-update/update/DBVersion000003.class.php | 17-----------------
modules/database-update/update/DBVersion000004.class.php | 27---------------------------
modules/database-update/update/DBVersion000005.class.php | 34----------------------------------
modules/database-update/update/DBVersion000006.class.php | 38--------------------------------------
modules/database-update/update/DBVersion000007.class.php | 40----------------------------------------
modules/database-update/update/DBVersion000008.class.php | 56--------------------------------------------------------
modules/database-update/update/DBVersion000009.class.php | 61-------------------------------------------------------------
modules/database-update/update/DBVersion000010.class.php | 39---------------------------------------
modules/database-update/update/DBVersion000011.class.php | 59-----------------------------------------------------------
modules/database-update/update/DBVersion000012.class.php | 26--------------------------
modules/database-update/update/DBVersion000013.class.php | 24------------------------
modules/database-update/update/DBVersion000014.class.php | 25-------------------------
modules/database-update/update/DBVersion000015.class.php | 24------------------------
modules/database-update/update/DBVersion000016.class.php | 122-------------------------------------------------------------------------------
modules/database-update/update/DBVersion000017.class.php | 23-----------------------
modules/database-update/update/DBVersion000018.class.php | 34----------------------------------
modules/database-update/update/DBVersion000019.class.php | 33---------------------------------
modules/database-update/update/DBVersion000020.class.php | 37-------------------------------------
modules/database-update/update/DBVersion000021.class.php | 37-------------------------------------
50 files changed, 1325 insertions(+), 1286 deletions(-)

diff --git a/modules/cms-core/Dispatcher.class.php b/modules/cms-core/Dispatcher.class.php @@ -10,7 +10,7 @@ use cms\action\Action; use cms\action\RequestParams; use ConfigurationLoader; use database\Database; -use DbUpdate; +use cms\update\Update; use util\Http; use logger\Logger; use LogicException; @@ -428,14 +428,14 @@ class Dispatcher if ( ! $dbConfig->is('check_version',true)) return; // Check for DB version is disabled. - $updater = new DbUpdate(); + $updater = new Update(); if ( ! $updater->isUpdateRequired( db() ) ) return; if ( ! $dbConfig->is('auto_update',true)) - throw new \LogicException('DB Update required, but auto-update is disabled. '.OR_TITLE." ".OR_VERSION." needs DB-version ".DbUpdate::SUPPORTED_VERSION ); + throw new \LogicException('DB Update required, but auto-update is disabled. '.OR_TITLE." ".OR_VERSION." needs DB-version ".Update::SUPPORTED_VERSION ); try { diff --git a/modules/cms-core/action/LoginAction.class.php b/modules/cms-core/action/LoginAction.class.php @@ -16,7 +16,7 @@ use cms\model\Model; use \database\Database; use \DB; -use \DbUpdate; +use cms\update\Update; use \Exception; use util\Http; use \InternalAuth; diff --git a/modules/cms-core/require.php b/modules/cms-core/require.php @@ -4,7 +4,6 @@ require_once(__DIR__ . '/../cms-macros/require.php'); require_once(__DIR__ . '/../cms-publish/require.php'); require_once(__DIR__ . '/../database/require.php'); -require_once(__DIR__ . '/../database-update/require.php'); require_once(__DIR__ . '/../util/require.php'); require_once(__DIR__ . '/../configuration/require.php'); require_once(__DIR__ . '/../security/require.php'); diff --git a/modules/cms/update/.htaccess b/modules/cms/update/.htaccess @@ -0,0 +1,2 @@ +order deny,allow +deny from all+ \ No newline at end of file diff --git a/modules/cms/update/Update.class.php b/modules/cms/update/Update.class.php @@ -0,0 +1,145 @@ +<?php + +namespace cms\update; + +use database\Database; +use Exception; +use logger\Logger; + + +class Update +{ + // This is the required DB version: + const SUPPORTED_VERSION = 21; + // ----------------------------^^----------------------------- + + const STATUS_UPDATE_PROGRESS = 0; + const STATUS_UPDATE_SUCCESS = 1; + + public function isUpdateRequired(Database $db) + { + $version = $this->getDbVersion($db); + + Logger::debug("Need DB-Version: " . self::SUPPORTED_VERSION . "; Actual DB-Version: " . $version); + + if ($version == self::SUPPORTED_VERSION) + // Cool, der aktuelle DB-Stand passt zu dieser Version. Das ist auch der Normalfall. Weiter so. + return false; + + elseif ($version > self::SUPPORTED_VERSION) + // Oh oh, in der Datenbank ist eine neuere Version, als wir unterstützen. + throw new \LogicException('Actual DB version is not supported. ' . "DB-Version is $version, but " . OR_TITLE . " " . OR_VERSION . " only supports version " . self::SUPPORTED_VERSION); + + else + return true; // Update required. + } + + + /** + * @param Database $db + */ + public function update(Database $db) + { + $version = $this->getDbVersion($db); + + + for ($installVersion = $version + 1; $installVersion <= self::SUPPORTED_VERSION; $installVersion++) { + if ($installVersion > 2) // Up to version 2 there was no table 'version'. + { + $db->start(); + $sql = $db->sql('INSERT INTO {{version}} (id,version,status,installed) VALUES( {id},{version},{status},{time} )', $db->id); + $sql->setInt('id', $installVersion); + $sql->setInt('version', $installVersion); + $sql->setInt('status', self::STATUS_UPDATE_PROGRESS); + $sql->setInt('time', time()); + $sql->query(); + $db->commit(); + } + + $updaterClassName = 'cms\update\version\DBVersion' . str_pad($installVersion, 6, '0', STR_PAD_LEFT); + + $db->start(); + /** @var \database\DbVersion $updater */ + $updater = new $updaterClassName($db); + + $updater->update(); + $db->commit(); + + if ($installVersion > 2) { + $db->start(); + $sql = $db->sql('UPDATE {{version}} SET status={status},installed={time} WHERE version={version}', $db->id); + $sql->setInt('status', self::STATUS_UPDATE_SUCCESS); + $sql->setInt('version', $installVersion); + $sql->setInt('time', time()); + $sql->query(); + $db->commit(); + } + } + } + + + /** + * Ermittelt die Version des Datenbank-Schemas. + * @param Database $db + * @return int + */ + private function getDbVersion(Database $db) + { + $versionTableExists = $this->testQuery($db, 'SELECT 1 FROM {{version}}'); + + if ($versionTableExists) { + // Prüfen, ob die vorherigen Updates fehlerfrei sind. + $sql = $db->sql(<<<SQL + SELECT COUNT(*) FROM {{version}} WHERE STATUS=0 +SQL + , $db->id); + $countErrors = $sql->getOne(); + if ($countErrors > 0) + throw new \LogicException('Database error: There are dirty versions (means: versions with status 0), see table VERSION for details.'); + + // Aktuelle Version ermitteln. + $sql = $db->sql(<<<SQL + SELECT MAX(version) FROM {{version}} +SQL + , $db->id); + $version = $sql->getOne(); + + if (is_numeric($version)) + return $version; // Aktuelle Version.s + else + // Tabelle 'version' ist noch leer. + // Tabelle 'version' wurde in Version 2 angelegt. + return 2; + } else { + $projectTableExists = $this->testQuery($db, 'SELECT 1 FROM {{project}}'); + + if ($projectTableExists) + // Entspricht dem Stand vor Einführung der automatischen Migration. + return 1; + else + // Es gibt gar keine Tabellen, es muss also alles neu angelegt werden. + return 0; + } + } + + + /** + * Stellt fest, ob eine DB-Anfrage funktioniert. + * @param $db Database + * @param $sql + * @return <code>true</code> falls SQL funktioniert. + */ + private function testQuery($db, $sql) + { + try { + $sql = $db->sql($sql, $db->id); + $sql->execute(); + return true; // Bisher alles ok? Dann funktioniert die Query. + } catch (Exception $e) { + // Query funktioniert nicht. + return false; + } + } +} + +?>+ \ No newline at end of file diff --git a/modules/cms/update/version/DBVersion000001.class.php b/modules/cms/update/version/DBVersion000001.class.php @@ -0,0 +1,339 @@ +<?php + +namespace cms\update\version; + +use database\Database; +use database\DbVersion; + + +/** + * Baseline database structure. + * + * @author dankert + * + */ +class DBVersion000001 extends DbVersion +{ + public function update() + { + $not_nullable = false; + $nullable = true; + + $this->addTable('project'); + + $this->addColumn('project','name' ,OR_DB_COLUMN_TYPE_VARCHAR, 128,null,$not_nullable); + $this->addColumn('project','target_dir' ,OR_DB_COLUMN_TYPE_VARCHAR, 255,null,$not_nullable); + $this->addColumn('project','ftp_url' ,OR_DB_COLUMN_TYPE_VARCHAR, 255,null,$not_nullable); + $this->addColumn('project','ftp_passive' ,OR_DB_COLUMN_TYPE_INT ,null,null,$not_nullable); + $this->addColumn('project','cmd_after_publish' ,OR_DB_COLUMN_TYPE_VARCHAR, 255,null,$not_nullable); + $this->addColumn('project','content_negotiation',OR_DB_COLUMN_TYPE_INT , 1, 0,$not_nullable); + $this->addColumn('project','cut_index' ,OR_DB_COLUMN_TYPE_INT , 1, 0,$not_nullable); + + $this->addPrimaryKey('project','id'); + $this->addIndex('project','name'); + + + $this->addTable('user'); + $this->addColumn('user','name',OR_DB_COLUMN_TYPE_VARCHAR,128,null,$not_nullable); + $this->addColumn('user','password',OR_DB_COLUMN_TYPE_VARCHAR,50,null,$not_nullable); + $this->addColumn('user','ldap_dn',OR_DB_COLUMN_TYPE_VARCHAR,255,null,$not_nullable); + $this->addColumn('user','fullname',OR_DB_COLUMN_TYPE_VARCHAR,128,null,$not_nullable); + $this->addColumn('user','tel',OR_DB_COLUMN_TYPE_VARCHAR,128,null,$not_nullable); + $this->addColumn('user','mail',OR_DB_COLUMN_TYPE_VARCHAR,255,null,$not_nullable); + $this->addColumn('user','descr',OR_DB_COLUMN_TYPE_VARCHAR,255,null,$not_nullable); + $this->addColumn('user','style',OR_DB_COLUMN_TYPE_VARCHAR,64,null,$not_nullable); + $this->addColumn('user','is_admin',OR_DB_COLUMN_TYPE_INT,1,0,$not_nullable); + $this->addPrimaryKey('user','id'); + $this->addUniqueIndex('user','name'); + + $this->addTable('group'); + $this->addColumn('group','name',OR_DB_COLUMN_TYPE_VARCHAR,100,null,$not_nullable); + $this->addPrimaryKey('group','id'); + $this->addUniqueIndex('group','name'); + + $this->addTable('object'); + $this->addColumn('object','parentid',OR_DB_COLUMN_TYPE_INT,null,null,$nullable); + $this->addColumn('object','projectid',OR_DB_COLUMN_TYPE_INT,0,0,$not_nullable); + $this->addColumn('object','filename',OR_DB_COLUMN_TYPE_VARCHAR,150,null,$not_nullable); + $this->addColumn('object','orderid',OR_DB_COLUMN_TYPE_INT,0,null,$not_nullable); + $this->addColumn('object','create_date',OR_DB_COLUMN_TYPE_INT,0,null,$not_nullable); + $this->addColumn('object','create_userid',OR_DB_COLUMN_TYPE_INT,0,null,$nullable); + $this->addColumn('object','lastchange_date',OR_DB_COLUMN_TYPE_INT,0,null,$not_nullable); + $this->addColumn('object','lastchange_userid',OR_DB_COLUMN_TYPE_INT,0,null,$nullable); + $this->addColumn('object','is_folder',OR_DB_COLUMN_TYPE_INT,1,null,$not_nullable); + $this->addColumn('object','is_file',OR_DB_COLUMN_TYPE_INT,1,null,$not_nullable); + $this->addColumn('object','is_page',OR_DB_COLUMN_TYPE_INT,1,null,$not_nullable); + $this->addColumn('object','is_link',OR_DB_COLUMN_TYPE_INT,1,null,$not_nullable); + $this->addPrimaryKey('object','id'); + $this->addConstraint('object','projectid','project','id'); + $this->addConstraint('object','lastchange_userid','user','id'); + $this->addConstraint('object','create_userid','user','id'); + + $this->addIndex('object','parentid'); + $this->addIndex('object','projectid'); + $this->addIndex('object','is_folder'); + $this->addIndex('object','is_file'); + $this->addIndex('object','is_page'); + $this->addIndex('object','is_link'); + $this->addIndex('object','orderid'); + $this->addIndex('object','create_userid'); + $this->addIndex('object','lastchange_userid'); + $this->addUniqueIndex('object','parentid,filename'); + + + + + $this->addTable('template'); + $this->addColumn('template','projectid',OR_DB_COLUMN_TYPE_INT,null,null,$not_nullable); + $this->addColumn('template','name',OR_DB_COLUMN_TYPE_VARCHAR,50,null,$not_nullable); + $this->addPrimaryKey('template','id'); + $this->addConstraint('template','projectid','project','id'); + + $this->addIndex('template','projectid'); + $this->addIndex('template','name'); + $this->addUniqueIndex('template','projectid,name'); + + + + $this->addTable('language'); + $this->addColumn('language','projectid',OR_DB_COLUMN_TYPE_INT,0,null,$not_nullable); + $this->addColumn('language','isocode',OR_DB_COLUMN_TYPE_VARCHAR,10,null,$not_nullable); + $this->addColumn('language','name',OR_DB_COLUMN_TYPE_VARCHAR,50,null,$not_nullable); + $this->addColumn('language','is_default',OR_DB_COLUMN_TYPE_INT,1,0,$not_nullable); + $this->addPrimaryKey('language','id'); + $this->addConstraint('language','projectid','project','id'); + $this->addUniqueIndex('language','projectid,isocode'); + + + + + $this->addTable('page'); + $this->addColumn('page','objectid',OR_DB_COLUMN_TYPE_INT,0,null,$not_nullable); + $this->addColumn('page','templateid',OR_DB_COLUMN_TYPE_INT,0,null,$not_nullable); + $this->addPrimaryKey('page','id'); + $this->addConstraint('page','templateid','template','id'); + $this->addConstraint('page','objectid','object','id'); + + $this->addUniqueIndex('page','objectid'); + $this->addIndex('page','templateid'); + + + + + $this->addTable('projectmodel'); + $this->addColumn('projectmodel','projectid',OR_DB_COLUMN_TYPE_INT,0,null,$not_nullable); + $this->addColumn('projectmodel','name',OR_DB_COLUMN_TYPE_VARCHAR,50,null,$not_nullable); + $this->addColumn('projectmodel','extension',OR_DB_COLUMN_TYPE_VARCHAR,10,null,$nullable); + $this->addColumn('projectmodel','is_default',OR_DB_COLUMN_TYPE_INT,1,0,$not_nullable); + $this->addPrimaryKey('projectmodel','id'); + $this->addConstraint('projectmodel','projectid','project','id'); + + $this->addIndex('projectmodel','projectid'); + $this->addUniqueIndex('projectmodel','projectid,name'); + + + $this->addTable('element'); + $this->addColumn('element','templateid',OR_DB_COLUMN_TYPE_INT,0,0,$not_nullable); + $this->addColumn('element','name',OR_DB_COLUMN_TYPE_VARCHAR,50,null,$not_nullable); + $this->addColumn('element','descr',OR_DB_COLUMN_TYPE_VARCHAR,255,null,$not_nullable); + $this->addColumn('element','type',OR_DB_COLUMN_TYPE_VARCHAR,20,null,$not_nullable); + $this->addColumn('element','subtype',OR_DB_COLUMN_TYPE_VARCHAR,20,null,$nullable); + $this->addColumn('element','with_icon',OR_DB_COLUMN_TYPE_INT,1,0,$not_nullable); + $this->addColumn('element','dateformat',OR_DB_COLUMN_TYPE_VARCHAR,100,null,$nullable); + $this->addColumn('element','wiki',OR_DB_COLUMN_TYPE_INT,1,0,$nullable); + $this->addColumn('element','html',OR_DB_COLUMN_TYPE_INT,1,0,$nullable); + $this->addColumn('element','all_languages',OR_DB_COLUMN_TYPE_INT,1,0,$not_nullable); + $this->addColumn('element','writable',OR_DB_COLUMN_TYPE_INT,1,0,$not_nullable); + $this->addColumn('element','decimals',OR_DB_COLUMN_TYPE_INT,0,null,$nullable); + $this->addColumn('element','dec_point',OR_DB_COLUMN_TYPE_VARCHAR,5,null,$nullable); + $this->addColumn('element','thousand_sep',OR_DB_COLUMN_TYPE_VARCHAR,1,null,$nullable); + $this->addColumn('element','code',OR_DB_COLUMN_TYPE_TEXT,null,null,$nullable); + $this->addColumn('element','default_text',OR_DB_COLUMN_TYPE_TEXT,null,null,$nullable); + $this->addColumn('element','folderobjectid',OR_DB_COLUMN_TYPE_INT,null,null,$nullable); + $this->addColumn('element','default_objectid',OR_DB_COLUMN_TYPE_INT,null,null,$nullable); + $this->addPrimaryKey('element','id'); + $this->addConstraint('element','default_objectid','object','id'); + $this->addConstraint('element','folderobjectid','object','id'); + $this->addConstraint('element','templateid','template','id'); + + $this->addIndex('element','templateid'); + $this->addIndex('element','name'); + $this->addUniqueIndex('element','templateid,name'); + + + + + $this->addTable('file'); + $this->addColumn('file','objectid',OR_DB_COLUMN_TYPE_INT,0,null,$not_nullable); + $this->addColumn('file','extension',OR_DB_COLUMN_TYPE_VARCHAR,10,null,$not_nullable); + $this->addColumn('file','size',OR_DB_COLUMN_TYPE_INT,0,null,$not_nullable); + $this->addColumn('file','value',OR_DB_COLUMN_TYPE_BLOB,null,null,$not_nullable); + $this->addPrimaryKey('file','id'); + $this->addConstraint('file','objectid','object','id'); + + $this->addUniqueIndex('file','objectid'); + + + + $this->addTable('folder'); + $this->addColumn('folder','objectid',OR_DB_COLUMN_TYPE_INT,0,null,$not_nullable); + $this->addPrimaryKey('folder','id'); + $this->addConstraint('folder','objectid','object','id'); + + $this->addUniqueIndex('folder','objectid'); + + + + + + $this->addTable('link'); + $this->addColumn('link','objectid',OR_DB_COLUMN_TYPE_INT,0,null,$not_nullable); + $this->addColumn('link','link_objectid',OR_DB_COLUMN_TYPE_INT,null,null,$nullable); + $this->addColumn('link','url',OR_DB_COLUMN_TYPE_VARCHAR,255,null,$nullable); + $this->addPrimaryKey('link','id'); + $this->addConstraint('link','objectid','object','id'); + $this->addConstraint('link','link_objectid','object','id'); + + $this->addUniqueIndex('link','objectid'); + $this->addIndex('link','link_objectid'); + + + + + + $this->addTable('name'); + $this->addColumn('name','objectid',OR_DB_COLUMN_TYPE_INT,0,null,$not_nullable); + $this->addColumn('name','name',OR_DB_COLUMN_TYPE_VARCHAR,255,null,$not_nullable); + $this->addColumn('name','descr',OR_DB_COLUMN_TYPE_VARCHAR,255,null,$not_nullable); + $this->addColumn('name','languageid',OR_DB_COLUMN_TYPE_INT,0,null,$not_nullable); + $this->addPrimaryKey('name','id'); + $this->addConstraint('name','objectid','object','id'); + $this->addConstraint('name','languageid','language','id'); + + $this->addIndex('name','objectid'); + $this->addIndex('name','languageid'); + $this->addUniqueIndex('name','objectid,languageid'); + + + + + + $this->addTable('templatemodel'); + $this->addColumn('templatemodel','templateid',OR_DB_COLUMN_TYPE_INT,0,null,$not_nullable); + $this->addColumn('templatemodel','projectmodelid',OR_DB_COLUMN_TYPE_INT,0,null,$not_nullable); + $this->addColumn('templatemodel','extension',OR_DB_COLUMN_TYPE_VARCHAR,10,null,$nullable); + $this->addColumn('templatemodel','text',OR_DB_COLUMN_TYPE_TEXT,null,null,$not_nullable); + $this->addPrimaryKey('templatemodel','id'); + $this->addConstraint('templatemodel','templateid','template','id'); + $this->addConstraint('templatemodel','projectmodelid','projectmodel','id'); + + $this->addIndex('templatemodel','templateid'); + $this->addUniqueIndex('templatemodel','templateid,extension'); + $this->addUniqueIndex('templatemodel','templateid,projectmodelid'); + + + + + + $this->addTable('usergroup'); + $this->addColumn('usergroup','userid',OR_DB_COLUMN_TYPE_INT,null,null,$not_nullable); + $this->addColumn('usergroup','groupid',OR_DB_COLUMN_TYPE_INT,null,null,$not_nullable); + $this->addPrimaryKey('usergroup','id'); + $this->addConstraint('usergroup','groupid','group','id'); + $this->addConstraint('usergroup','userid','user','id'); + + $this->addIndex('usergroup','groupid'); + $this->addIndex('usergroup','userid'); + $this->addUniqueIndex('usergroup','userid,groupid'); + + + + + $this->addTable('value'); + $this->addColumn('value','pageid',OR_DB_COLUMN_TYPE_INT,0,null,$not_nullable); + $this->addColumn('value','languageid',OR_DB_COLUMN_TYPE_INT,null,null,$not_nullable); + $this->addColumn('value','elementid',OR_DB_COLUMN_TYPE_INT,0,null,$not_nullable); + $this->addColumn('value','linkobjectid',OR_DB_COLUMN_TYPE_INT,null,null,$nullable); + $this->addColumn('value','text',OR_DB_COLUMN_TYPE_TEXT,null,null,$nullable); + $this->addColumn('value','number',OR_DB_COLUMN_TYPE_INT,null,null,$nullable); + $this->addColumn('value','date',OR_DB_COLUMN_TYPE_INT,null,null,$nullable); + $this->addColumn('value','active',OR_DB_COLUMN_TYPE_INT,0,null,$not_nullable); + $this->addColumn('value','lastchange_date',OR_DB_COLUMN_TYPE_INT,0,null,$not_nullable); + $this->addColumn('value','lastchange_userid',OR_DB_COLUMN_TYPE_INT,null,null,$nullable); + $this->addColumn('value','publish',OR_DB_COLUMN_TYPE_INT,null,null,$not_nullable); + $this->addPrimaryKey('value','id'); + $this->addConstraint('value','pageid','page','id'); + $this->addConstraint('value','elementid','element','id'); + $this->addConstraint('value','languageid','language','id'); + $this->addConstraint('value','lastchange_userid','user','id'); + $this->addConstraint('value','linkobjectid','object','id'); + + $this->addIndex('value','pageid'); + $this->addIndex('value','languageid'); + $this->addIndex('value','elementid'); + $this->addIndex('value','active'); + $this->addIndex('value','lastchange_date'); + $this->addIndex('value','publish'); + + + + + + $this->addTable('acl'); + $this->addColumn('acl','userid',OR_DB_COLUMN_TYPE_INT,null,null,$nullable); + $this->addColumn('acl','groupid',OR_DB_COLUMN_TYPE_INT,null,null,$nullable); + $this->addColumn('acl','objectid',OR_DB_COLUMN_TYPE_INT,null,null,$not_nullable); + $this->addColumn('acl','languageid',OR_DB_COLUMN_TYPE_INT,0,null,$nullable); + $this->addColumn('acl','is_write',OR_DB_COLUMN_TYPE_INT,1,0,$not_nullable); + $this->addColumn('acl','is_prop',OR_DB_COLUMN_TYPE_INT,1,0,$not_nullable); + $this->addColumn('acl','is_create_folder',OR_DB_COLUMN_TYPE_INT,1,0,$not_nullable); + $this->addColumn('acl','is_create_file',OR_DB_COLUMN_TYPE_INT,1,0,$not_nullable); + $this->addColumn('acl','is_create_link',OR_DB_COLUMN_TYPE_INT,1,0,$not_nullable); + $this->addColumn('acl','is_create_page',OR_DB_COLUMN_TYPE_INT,1,0,$not_nullable); + $this->addColumn('acl','is_delete',OR_DB_COLUMN_TYPE_INT,1,0,$not_nullable); + $this->addColumn('acl','is_release',OR_DB_COLUMN_TYPE_INT,1,0,$not_nullable); + $this->addColumn('acl','is_publish',OR_DB_COLUMN_TYPE_INT,1,0,$not_nullable); + $this->addColumn('acl','is_grant',OR_DB_COLUMN_TYPE_INT,1,0,$not_nullable); + $this->addColumn('acl','is_transmit',OR_DB_COLUMN_TYPE_INT,1,0,$not_nullable); + $this->addPrimaryKey('acl','id'); + $this->addConstraint('acl','groupid','group','id'); + $this->addConstraint('acl','userid','user','id'); + $this->addConstraint('acl','objectid','object','id'); + $this->addConstraint('acl','languageid','language','id'); + + $this->addIndex('acl','userid'); + $this->addIndex('acl','groupid'); + $this->addIndex('acl','languageid'); + $this->addIndex('acl','objectid'); + $this->addIndex('acl','is_transmit'); + + $this->afterUpdate( $this->getDb() ); + } + + + + /** + * Initialisieren der frisch aktualisierten Datenbank. + * + * @param Database $db + */ + private function afterUpdate( Database $db ) + { + // Benutzer zählen. + $sql = $db->sql('SELECT COUNT(*) From {{user}}',$db->id); + $countUsers = $sql->getOne(); + + // Wenn noch kein Benutzer vorhanden, dann einen anlegen. + if ( $countUsers == 0 ) + { + // Hashing the admin password with MD5. In Version 6 the Algo will be set to 2 (=MD5). + $sql = $db->sql("INSERT INTO {{user}} (id,name,password,ldap_dn,fullname,tel,mail,descr,style,is_admin) VALUES(1,'admin','21232f297a57a5a743894a0e4a801fc3','','Administrator','','','Account for administration tasks.','default',1)",$db->id); + $sql->query(); + $db->commit(); + } + } + + +} + +?>+ \ No newline at end of file diff --git a/modules/cms/update/version/DBVersion000002.class.php b/modules/cms/update/version/DBVersion000002.class.php @@ -0,0 +1,28 @@ +<?php + +namespace cms\update\version; + +use database\DbVersion; +/** + * new table: version. + * + * @author dankert + * + */ +class DBVersion000002 extends DbVersion +{ + public function update() + { + $this->addTable('version'); + + $this->addColumn('version','version' ,OR_DB_COLUMN_TYPE_INT,null,null,false); + $this->addColumn('version','status' ,OR_DB_COLUMN_TYPE_INT,null,null,false); + $this->addColumn('version','installed',OR_DB_COLUMN_TYPE_INT,null,null,false); + + $this->addPrimaryKey ('version','id' ); + $this->addIndex ('version','status' ); + $this->addUniqueIndex('version','version' ); + } +} + +?>+ \ No newline at end of file diff --git a/modules/cms/update/version/DBVersion000003.class.php b/modules/cms/update/version/DBVersion000003.class.php @@ -0,0 +1,19 @@ +<?php + +namespace cms\update\version; + +use database\DbVersion; +/** + * Dummy version. + * @author dankert + * + */ +class DBVersion000003 extends DbVersion +{ + public function update() + { + // Dummy version. + } +} + +?>+ \ No newline at end of file diff --git a/modules/cms/update/version/DBVersion000004.class.php b/modules/cms/update/version/DBVersion000004.class.php @@ -0,0 +1,29 @@ +<?php + +namespace cms\update\version; + +use database\DbVersion; + +/** + * Add Columns for user language and user timezone. + * + * @author dankert + * + */ +class DBVersion000004 extends DbVersion +{ + public function update() + { + $not_nullable = false; + $nullable = true; + + // Add user language + $this->addColumn('user','language',OR_DB_COLUMN_TYPE_VARCHAR, 2,null,$nullable); + + // Add user timezone + $this->addColumn('user','timezone',OR_DB_COLUMN_TYPE_VARCHAR,64,null,$nullable); + + } +} + +?>+ \ No newline at end of file diff --git a/modules/cms/update/version/DBVersion000005.class.php b/modules/cms/update/version/DBVersion000005.class.php @@ -0,0 +1,36 @@ +<?php + +namespace cms\update\version; + +use database\DbVersion; + +/** + * Security enhancements. + * + * @author dankert + * + */ +class DBVersion000005 extends DbVersion +{ + public function update() + { + $not_nullable = false; + $nullable = true; + + // longer Passwords! 50 is not enough. + $this->addColumn('user','password_hash',OR_DB_COLUMN_TYPE_VARCHAR,255,null,$not_nullable); + + $db = $this->getDb(); + $table = $this->getTableName('user'); + $updateStmt = $db->sql('UPDATE '.$table. + ' SET password_hash=password' + ); + $updateStmt->query(); + + $this->dropColumn('user','password'); + + $this->addColumn('user','password_salt',OR_DB_COLUMN_TYPE_VARCHAR,255,null,$not_nullable); + } +} + +?>+ \ No newline at end of file diff --git a/modules/cms/update/version/DBVersion000006.class.php b/modules/cms/update/version/DBVersion000006.class.php @@ -0,0 +1,40 @@ +<?php + +namespace cms\update\version; + +use database\DbVersion; + +/** + * Security enhancements. + * + * @author dankert + * + */ +class DBVersion000006 extends DbVersion +{ + public function update() + { + $not_nullable = false; + $nullable = true; + + $this->addColumn('user','password_expires',OR_DB_COLUMN_TYPE_INT,0,null,$nullable); + + $this->addColumn('user','last_login' ,OR_DB_COLUMN_TYPE_INT,0,null,$nullable); + + $this->addColumn('user','password_algo' ,OR_DB_COLUMN_TYPE_INT,0,2,$not_nullable); + + // Setting Password algo. Passwords beginning with '$' are (old) MD5-hashes. + + // SUBSTR(s,pos,length) is supported by MySql,Postgres,SQLite + // SUBSTRING(s FROM pos FOR length) is NOT supported by SQLite + $table = $this->getTableName('user'); + $db = $this->getDb(); + $updateAlgoStmt = $db->sql('UPDATE '.$table. + ' SET password_algo=1 WHERE SUBSTR(password_hash,1,1) = '."'$'".';' + ); + $updateAlgoStmt->query(); + + } +} + +?>+ \ No newline at end of file diff --git a/modules/cms/update/version/DBVersion000007.class.php b/modules/cms/update/version/DBVersion000007.class.php @@ -0,0 +1,42 @@ +<?php + +namespace cms\update\version; + +use database\DbVersion; +use security\Password; + +/** + * Security enhancements. + * + * @author dankert + * + */ +class DBVersion000007 extends DbVersion +{ + public function update() + { + $not_nullable = false; + $nullable = true; + + $this->addColumn('user','otp_secret' ,OR_DB_COLUMN_TYPE_VARCHAR,255,null,$nullable ); + + $table = $this->getTableName('user'); + $db = $this->getDb(); + $stmt = $db->sql('SELECT id FROM '.$table); + foreach($stmt->getCol() as $userid ) + { + $secret = Password::randomHexString(64); + $stmt = $db->sql('UPDATE '.$table.' SET otp_secret={secret} WHERE id={id}'); + $stmt->setString('secret',$secret); + $stmt->setInt('id',$userid); + $stmt->query(); + } + + $this->addColumn('user','totp' ,OR_DB_COLUMN_TYPE_INT , 1, 0,$not_nullable); + $this->addColumn('user','hotp_counter',OR_DB_COLUMN_TYPE_INT , 0, 0,$not_nullable); + $this->addColumn('user','hotp' ,OR_DB_COLUMN_TYPE_INT , 1, 0,$not_nullable); + + } +} + +?>+ \ No newline at end of file diff --git a/modules/cms/update/version/DBVersion000008.class.php b/modules/cms/update/version/DBVersion000008.class.php @@ -0,0 +1,58 @@ +<?php + +namespace cms\update\version; + +use database\DbVersion; +use security\Password; + +/** + * Creates a type column in table OBJECT. Now added types have no need for new table columns. + * + * @author dankert + * + */ +class DBVersion000008 extends DbVersion +{ + /** + * + */ + public function update() + { + $not_nullable = false; + $nullable = true; + + $this->addColumn('object','typeid',OR_DB_COLUMN_TYPE_INT,2,0,$not_nullable); + $this->addIndex('object','typeid'); + + // Converting old values... + $db = $this->getDb(); + $table = $this->getTableName('object'); + + $updateStmt = $db->sql('UPDATE '.$table. + ' SET typeid=1 WHERE is_folder=1' + ); + $updateStmt->query(); + + $updateStmt = $db->sql('UPDATE '.$table. + ' SET typeid=2 WHERE is_file=1' + ); + $updateStmt->query(); + + $updateStmt = $db->sql('UPDATE '.$table. + ' SET typeid=3 WHERE is_page=1' + ); + $updateStmt->query(); + + $updateStmt = $db->sql('UPDATE '.$table. + ' SET typeid=4 WHERE is_link=1' + ); + $updateStmt->query(); + + $this->dropColumn('object','is_folder'); + $this->dropColumn('object','is_file'); + $this->dropColumn('object','is_page'); + $this->dropColumn('object','is_link'); + } +} + +?>+ \ No newline at end of file diff --git a/modules/cms/update/version/DBVersion000009.class.php b/modules/cms/update/version/DBVersion000009.class.php @@ -0,0 +1,63 @@ +<?php + + +namespace cms\update\version; + +use cms\model\BaseObject; +use database\DbVersion; +use security\Password; + +/** + * New Object type 'url'. + * + * In this Version 9 we are creating a table 'url' and are copying + * the selected entries from table 'link' to 'url'. + * + * @author dankert + * + */ +class DBVersion000009 extends DbVersion +{ + /** + * + */ + public function update() + { + $not_nullable = false; + $nullable = true; + + // Creating new table 'url' + $this->addTable('url'); + $this->addColumn('url','objectid',OR_DB_COLUMN_TYPE_INT,0,null,$not_nullable); + $this->addColumn('url','url',OR_DB_COLUMN_TYPE_VARCHAR,255,null,$not_nullable); + + $this->addPrimaryKey('url','id'); + $this->addConstraint('url','objectid','object','id'); + + $this->addUniqueIndex('url','objectid'); + + // Copying values from table 'link' to new table 'url' + $db = $this->getDb(); + + $insertStmt = $db->sql('INSERT INTO '.$this->getTableName('url'). + ' (id,objectid,url) SELECT id,objectid,url FROM '.$this->getTableName('link').' WHERE url is not null' + ); + $insertStmt->query(); + + // Updating the typeid for URL entrys in table 'object' + $updateStmt = $db->sql('UPDATE '.$this->getTableName('object'). + ' SET typeid='.BaseObject::TYPEID_URL.' WHERE id IN (SELECT objectid FROM '.$this->getTableName('url').')' + ); + $updateStmt->query(); + + // Remove old entrys in table 'link' + $updateStmt = $db->sql('DELETE FROM '.$this->getTableName('link').' WHERE url is not null' + ); + $updateStmt->query(); + + // Cleanup: Drop unused column. + $this->dropColumn('link','url'); + } +} + +?>+ \ No newline at end of file diff --git a/modules/cms/update/version/DBVersion000010.class.php b/modules/cms/update/version/DBVersion000010.class.php @@ -0,0 +1,41 @@ +<?php + +namespace cms\update\version; + +use database\DbVersion; +use security\Password; + +/** + * Filetype 'file' is now devided into 'file' (unchanged), 'image' (new) and OR_DB_COLUMN_TYPE_TEXT (new). + * + * @author dankert + * + */ +class DBVersion000010 extends DbVersion +{ + /** + * + */ + public function update() + { + $db = $this->getDb(); + $tableObject = $this->getTableName('object'); + $tableFile = $this->getTableName('file'); + + $updateStmt = $db->sql('UPDATE '.$tableObject. + ' SET typeid=6 WHERE id IN (SELECT objectid FROM '.$tableFile. + " WHERE extension IN ('gif','png','jpeg','jpg','svg','tiff') )" + ); + $updateStmt->query(); + + $updateStmt = $db->sql('UPDATE '.$tableObject. + ' SET typeid=7 WHERE id IN (SELECT objectid FROM '.$tableFile. + " WHERE extension IN ('css','text','txt','js','html','xml','log','ini','gpx') )" + ); + $updateStmt->query(); + + + } +} + +?>+ \ No newline at end of file diff --git a/modules/cms/update/version/DBVersion000011.class.php b/modules/cms/update/version/DBVersion000011.class.php @@ -0,0 +1,61 @@ +<?php + + +namespace cms\update\version; + +use database\DbVersion; +use security\Password; + +/** + * Project gets new columns. + * + * @author dankert + * + */ +class DBVersion000011 extends DbVersion +{ + /** + * + */ + public function update() + { + $not_nullable = false; + $nullable = true; + + + $this->addColumn('project', 'url', OR_DB_COLUMN_TYPE_VARCHAR, 255, '', $not_nullable); + $this->addColumn('project', 'flags', OR_DB_COLUMN_TYPE_INT, 11, 0, $not_nullable); + + $db = $this->getDb(); + $tableProject = $this->getTableName('project'); + + // Update the url + $updateStmt = $db->sql(<<<SQL +UPDATE $tableProject + SET url= CONCAT('//',name) +SQL + ); + $updateStmt->query(); + + // Update the new flags + $updateStmt = $db->sql(<<<SQL +UPDATE $tableProject + SET flags=flags+1 WHERE cut_index=1 +SQL + ); + $updateStmt->query(); + + $updateStmt = $db->sql(<<<SQL +UPDATE $tableProject + SET flags=flags+2 WHERE content_negotiation=1 +SQL + ); + $updateStmt->query(); + + // now the information is hold in column 'flags', so we can delete the old columns. + $this->dropColumn('project', 'cut_index'); + $this->dropColumn('project', 'content_negotiation'); + } +} + +?>+ \ No newline at end of file diff --git a/modules/cms/update/version/DBVersion000012.class.php b/modules/cms/update/version/DBVersion000012.class.php @@ -0,0 +1,27 @@ +<?php + +namespace cms\update\version; + +use database\DbVersion; +use security\Password; + +/** + * Objects gets new columns for storing the publish date. + * + * @author dankert + * + */ +class DBVersion000012 extends DbVersion +{ + /** + * + */ + public function update() + { + $this->addColumn('object','published_date' ,OR_DB_COLUMN_TYPE_INT,0,null,OR_DB_COLUMN_NULLABLE); + $this->addColumn('object','published_userid',OR_DB_COLUMN_TYPE_INT,0,null,OR_DB_COLUMN_NULLABLE); + $this->addConstraint('object','published_userid','user','id'); + } +} + +?>+ \ No newline at end of file diff --git a/modules/cms/update/version/DBVersion000013.class.php b/modules/cms/update/version/DBVersion000013.class.php @@ -0,0 +1,25 @@ +<?php + +namespace cms\update\version; + +use database\DbVersion; +use security\Password; + +/** + * Textfiles should able to be filtered. + * + * @author dankert + * + */ +class DBVersion000013 extends DbVersion +{ + /** + * + */ + public function update() + { + $this->addColumn('file','filterid' ,OR_DB_COLUMN_TYPE_INT,0,null,OR_DB_COLUMN_NULLABLE); + } +} + +?>+ \ No newline at end of file diff --git a/modules/cms/update/version/DBVersion000014.class.php b/modules/cms/update/version/DBVersion000014.class.php @@ -0,0 +1,26 @@ +<?php + +namespace cms\update\version; + +use database\DbVersion; +use security\Password; + +/** + * Objects gets new columns for storing the publish date. + * + * @author dankert + * + */ +class DBVersion000014 extends DbVersion +{ + /** + * + */ + public function update() + { + $this->addColumn('folder','order_by' ,OR_DB_COLUMN_TYPE_INT,0,null,OR_DB_COLUMN_NULLABLE); + $this->addColumn('folder','order_direction',OR_DB_COLUMN_TYPE_INT,0,null,OR_DB_COLUMN_NULLABLE); + } +} + +?>+ \ No newline at end of file diff --git a/modules/cms/update/version/DBVersion000015.class.php b/modules/cms/update/version/DBVersion000015.class.php @@ -0,0 +1,25 @@ +<?php + +namespace cms\update\version; + +use database\DbVersion; +use security\Password; + +/** + * Local settings for every object. + * + * @author dankert + * + */ +class DBVersion000015 extends DbVersion +{ + /** + * + */ + public function update() + { + $this->addColumn('object','settings',OR_DB_COLUMN_TYPE_TEXT,0,null,OR_DB_COLUMN_NOT_NULLABLE); + } +} + +?>+ \ No newline at end of file diff --git a/modules/cms/update/version/DBVersion000016.class.php b/modules/cms/update/version/DBVersion000016.class.php @@ -0,0 +1,123 @@ +<?php + +namespace cms\update\version; + +use database\DbVersion; +use security\Password; + +/** + * Converting element types from string to number. + * + * @author dankert + * + */ +class DBVersion000016 extends DbVersion +{ + /** + * + */ + public function update() + { + // Type 3 = Text is the default. + $this->addColumn('element','typeid',OR_DB_COLUMN_TYPE_INT,0,3,OR_DB_COLUMN_NOT_NULLABLE); + + $db = $this->getDb(); + $tableProject = $this->getTableName('element'); + + // Update the types + $conversionTable = array( + 1 => 'date', + 2 => 'number', + 3 => 'text', + 4 => 'info' , + 5 => 'infodate', + 6 => 'link' , + 7 => 'longtext', + 8 => 'code' , + 9 => 'dynamic' , + 10 => 'select' , + 11 => 'copy' , + 12 => 'linkinfo', + 13 => 'linkdate', + 14 => 'insert' + ); + + foreach ($conversionTable as $typeid => $typename ) + { + $updateStmt = $db->sql(<<<SQL +UPDATE $tableProject + SET typeid=$typeid WHERE type = '$typename' +SQL + ); + $updateStmt->query(); + } + + $this->dropColumn('element','type'); + + + + $this->addColumn('element','flags',OR_DB_COLUMN_TYPE_INT,0,0,OR_DB_COLUMN_NOT_NULLABLE); + + $updateStmt = $db->sql(<<<SQL +UPDATE $tableProject + SET flags=flags+1 WHERE html = 1 +SQL + ); + $updateStmt->query(); + + $updateStmt = $db->sql(<<<SQL +UPDATE $tableProject + SET flags=flags+2 WHERE all_languages = 1 +SQL + ); + $updateStmt->query(); + + $updateStmt = $db->sql(<<<SQL +UPDATE $tableProject + SET flags=flags+4 WHERE writable = 1 +SQL + ); + $updateStmt->query(); + + $updateStmt = $db->sql(<<<SQL +UPDATE $tableProject + SET flags=flags+8 WHERE with_icon = 1 +SQL + ); + $updateStmt->query(); + + + + $this->addColumn('element','format',OR_DB_COLUMN_TYPE_INT,0,0,OR_DB_COLUMN_NOT_NULLABLE); + + // Format = HTML + $updateStmt = $db->sql(<<<SQL +UPDATE $tableProject + SET format=1 WHERE html = 1 and wiki = 0 +SQL + ); + $updateStmt->query(); + + // Format = Wiki + $updateStmt = $db->sql(<<<SQL +UPDATE $tableProject + SET format=2 WHERE wiki = 1 +SQL + ); + $updateStmt->query(); + + // Other formats were not supported up to this version. + + // Cleanup + $this->dropColumn('element','wiki' ); + $this->dropColumn('element','html' ); + $this->dropColumn('element','all_languages'); + $this->dropColumn('element','writable' ); + $this->dropColumn('element','with_icon' ); + + } + + +} + +?>+ \ No newline at end of file diff --git a/modules/cms/update/version/DBVersion000017.class.php b/modules/cms/update/version/DBVersion000017.class.php @@ -0,0 +1,25 @@ +<?php + +namespace cms\update\version; + +use database\DbVersion; +use security\Password; + +/** + * Objects gets new columns for storing valid-dates. + * + * @author dankert + * + */ +class DBVersion000017 extends DbVersion +{ + /** + * + */ + public function update() + { + $this->addColumn('object','valid_from',OR_DB_COLUMN_TYPE_INT,0,null,OR_DB_COLUMN_NULLABLE); + $this->addColumn('object','valid_to' ,OR_DB_COLUMN_TYPE_INT,0,null,OR_DB_COLUMN_NULLABLE); + } +} + diff --git a/modules/cms/update/version/DBVersion000018.class.php b/modules/cms/update/version/DBVersion000018.class.php @@ -0,0 +1,36 @@ +<?php + +namespace cms\update\version; + +use database\DbVersion; +use security\Password; + +/** + * Elements should have a name and a separate label. + * + * @author dankert + * + */ +class DBVersion000018 extends DbVersion +{ + /** + * + */ + public function update() + { + $this->addColumn('element','label' ,OR_DB_COLUMN_TYPE_VARCHAR,100,'',OR_DB_COLUMN_NOT_NULLABLE); + + // Initial Value for Labels is the element name. + $tableElement = $this->getTableName('element'); + + $updateStmt = $this->getDb()->sql(<<<SQL +UPDATE $tableElement + SET label=name +SQL + ); + $updateStmt->query(); + + $this->addUniqueIndex('element','templateid,label'); + } +} + diff --git a/modules/cms/update/version/DBVersion000019.class.php b/modules/cms/update/version/DBVersion000019.class.php @@ -0,0 +1,35 @@ +<?php + +namespace cms\update\version; + +use database\DbVersion; +use security\Password; + +/** + * The format of a value is stored in the value table, so users can change the format of a value, independent of the element. + * + * @author dankert + * + */ +class DBVersion000019 extends DbVersion +{ + /** + * + */ + public function update() + { + $this->addColumn('value','format' ,OR_DB_COLUMN_TYPE_INT,1,0,OR_DB_COLUMN_NOT_NULLABLE); + + // Initial Value: Copy from element. + $tableValue = $this->getTableName('value'); + $tableElement = $this->getTableName('element'); + + $updateStmt = $this->getDb()->sql(<<<SQL +UPDATE $tableValue + SET format=(select format from $tableElement where $tableValue.elementid=$tableElement.id) +SQL + ); + $updateStmt->query(); + } +} + diff --git a/modules/cms/update/version/DBVersion000020.class.php b/modules/cms/update/version/DBVersion000020.class.php @@ -0,0 +1,39 @@ +<?php + +namespace cms\update\version; + +use database\DbVersion; + +/** + * Aliases for node objects. + * + * @author dankert + * + */ +class DBVersion000020 extends DbVersion +{ + /** + * + */ + public function update() + { + $this->addTable('alias'); + + $this->addColumn('alias','objectid' ,OR_DB_COLUMN_TYPE_INT,null,null,OR_DB_COLUMN_NOT_NULLABLE); + $this->addColumn('alias','languageid' ,OR_DB_COLUMN_TYPE_INT,null,null,OR_DB_COLUMN_NULLABLE); + $this->addColumn('alias','link_objectid',OR_DB_COLUMN_TYPE_INT,null,null,OR_DB_COLUMN_NOT_NULLABLE); + + + $this->addPrimaryKey ('alias','id'); + + $this->addConstraint ('alias','objectid' ,'object' ,'id'); + $this->addConstraint ('alias','languageid' ,'language','id'); + $this->addConstraint ('alias','link_objectid','object' ,'id'); + + $this->addUniqueIndex('alias','objectid' ); + $this->addUniqueIndex('alias','link_objectid,languageid'); + $this->addIndex ('alias','link_objectid' ); + + } +} + diff --git a/modules/cms/update/version/DBVersion000021.class.php b/modules/cms/update/version/DBVersion000021.class.php @@ -0,0 +1,39 @@ +<?php + +namespace cms\update\version; + +use database\DbVersion; + +/** + * Authentication tokens. + * + * @author dankert + * + */ +class DBVersion000021 extends DbVersion +{ + /** + * + */ + public function update() + { + $this->addTable('auth'); + + $this->addColumn('auth','selector' ,OR_DB_COLUMN_TYPE_VARCHAR ,150 ,null,OR_DB_COLUMN_NOT_NULLABLE); + $this->addColumn('auth','userid' ,OR_DB_COLUMN_TYPE_INT ,0 ,null,OR_DB_COLUMN_NOT_NULLABLE); + $this->addColumn('auth','token' ,OR_DB_COLUMN_TYPE_VARCHAR ,150 ,null,OR_DB_COLUMN_NOT_NULLABLE); + $this->addColumn('auth','token_algo' ,OR_DB_COLUMN_TYPE_INT ,0 ,0 ,OR_DB_COLUMN_NOT_NULLABLE); + $this->addColumn('auth','expires' ,OR_DB_COLUMN_TYPE_INT ,0 ,null,OR_DB_COLUMN_NOT_NULLABLE); + $this->addColumn('auth','create_date' ,OR_DB_COLUMN_TYPE_INT ,0 ,null,OR_DB_COLUMN_NOT_NULLABLE); + $this->addColumn('auth','platform' ,OR_DB_COLUMN_TYPE_VARCHAR,255 ,null,OR_DB_COLUMN_NOT_NULLABLE); + $this->addColumn('auth','name' ,OR_DB_COLUMN_TYPE_VARCHAR,255 ,null,OR_DB_COLUMN_NOT_NULLABLE); + + + $this->addPrimaryKey ('auth','id'); + + $this->addConstraint ('auth','userid' ,'user' ,'id'); + + $this->addUniqueIndex('auth','selector' ); + } +} + diff --git a/modules/database-update/.htaccess b/modules/database-update/.htaccess @@ -1,2 +0,0 @@ -order deny,allow -deny from all- \ No newline at end of file diff --git a/modules/database-update/DbUpdate.class.php b/modules/database-update/DbUpdate.class.php @@ -1,151 +0,0 @@ -<?php - -use database\Database; -use logger\Logger; - - -class DbUpdate -{ - // This is the required DB version: - const SUPPORTED_VERSION = 21; - // ----------------------------^^----------------------------- - - const STATUS_UPDATE_PROGRESS = 0; - const STATUS_UPDATE_SUCCESS = 1; - - public function isUpdateRequired( Database $db ) - { - $version = $this->getDbVersion($db); - - Logger::debug("Need DB-Version: ".self::SUPPORTED_VERSION."; Actual DB-Version: ".$version); - - if ( $version == self::SUPPORTED_VERSION ) - // Cool, der aktuelle DB-Stand passt zu dieser Version. Das ist auch der Normalfall. Weiter so. - return false; - - elseif ( $version > self::SUPPORTED_VERSION ) - // Oh oh, in der Datenbank ist eine neuere Version, als wir unterstützen. - throw new \LogicException('Actual DB version is not supported. '."DB-Version is $version, but ".OR_TITLE." ".OR_VERSION." only supports version ".self::SUPPORTED_VERSION ); - - else - return true; // Update required. - } - - - - /** - * @param Database $db - */ - public function update(Database $db ) - { - $version = $this->getDbVersion($db); - - - for( $installVersion = $version + 1; $installVersion <= self::SUPPORTED_VERSION; $installVersion++ ) - { - if ( $installVersion > 2 ) // Up to version 2 there was no table 'version'. - { - $db->start(); - $sql = $db->sql('INSERT INTO {{version}} (id,version,status,installed) VALUES( {id},{version},{status},{time} )',$db->id); - $sql->setInt('id' , $installVersion); - $sql->setInt('version', $installVersion); - $sql->setInt('status' , self::STATUS_UPDATE_PROGRESS); - $sql->setInt('time' , time() ); - $sql->query(); - $db->commit(); - } - - $updaterClassName = 'DBVersion'.str_pad($installVersion, 6, '0', STR_PAD_LEFT); - require(__DIR__.'/update/'.$updaterClassName.'.class.php'); - - $db->start(); - /** @var \database\DbVersion $updater */ - $updater = new $updaterClassName( $db ); - - $updater->update(); - $db->commit(); - - if ( $installVersion > 2 ) - { - $db->start(); - $sql = $db->sql('UPDATE {{version}} SET status={status},installed={time} WHERE version={version}',$db->id); - $sql->setInt('status' , self::STATUS_UPDATE_SUCCESS); - $sql->setInt('version', $installVersion); - $sql->setInt('time' , time() ); - $sql->query(); - $db->commit(); - } - } - } - - - /** - * Ermittelt die Version des Datenbank-Schemas. - * @param Database $db - * @return int - */ - private function getDbVersion( Database $db ) - { - $versionTableExists = $this->testQuery( $db,'SELECT 1 FROM {{version}}' ); - - if ( $versionTableExists ) - { - // Prüfen, ob die vorherigen Updates fehlerfrei sind. - $sql = $db->sql(<<<SQL - SELECT COUNT(*) FROM {{version}} WHERE STATUS=0 -SQL - ,$db->id); - $countErrors = $sql->getOne(); - if ( $countErrors > 0 ) - throw new \LogicException('Database error: There are dirty versions (means: versions with status 0), see table VERSION for details.'); - - // Aktuelle Version ermitteln. - $sql = $db->sql(<<<SQL - SELECT MAX(version) FROM {{version}} -SQL - ,$db->id); - $version = $sql->getOne(); - - if ( is_numeric($version) ) - return $version; // Aktuelle Version.s - else - // Tabelle 'version' ist noch leer. - // Tabelle 'version' wurde in Version 2 angelegt. - return 2; - } - else - { - $projectTableExists = $this->testQuery( $db,'SELECT 1 FROM {{project}}'); - - if ( $projectTableExists ) - // Entspricht dem Stand vor Einführung der automatischen Migration. - return 1; - else - // Es gibt gar keine Tabellen, es muss also alles neu angelegt werden. - return 0; - } - } - - - /** - * Stellt fest, ob eine DB-Anfrage funktioniert. - * @param $db Database - * @param $sql - * @return <code>true</code> falls SQL funktioniert. - */ - private function testQuery( $db,$sql ) - { - try { - $sql = $db->sql($sql,$db->id); - $sql->execute(); - return true; // Bisher alles ok? Dann funktioniert die Query. - } - catch( Exception $e ) - { - // Query funktioniert nicht. - return false; - } - } -} - -?>- \ No newline at end of file diff --git a/modules/database-update/require.php b/modules/database-update/require.php @@ -1,5 +0,0 @@ -<?php - -require_once(__DIR__ . '/DbUpdate.class.php'); - -?>- \ No newline at end of file diff --git a/modules/database-update/update/DBVersion000001.class.php b/modules/database-update/update/DBVersion000001.class.php @@ -1,337 +0,0 @@ -<?php - -use database\Database; -use database\DbVersion; - - -/** - * Baseline database structure. - * - * @author dankert - * - */ -class DBVersion000001 extends DbVersion -{ - public function update() - { - $not_nullable = false; - $nullable = true; - - $this->addTable('project'); - - $this->addColumn('project','name' ,OR_DB_COLUMN_TYPE_VARCHAR, 128,null,$not_nullable); - $this->addColumn('project','target_dir' ,OR_DB_COLUMN_TYPE_VARCHAR, 255,null,$not_nullable); - $this->addColumn('project','ftp_url' ,OR_DB_COLUMN_TYPE_VARCHAR, 255,null,$not_nullable); - $this->addColumn('project','ftp_passive' ,OR_DB_COLUMN_TYPE_INT ,null,null,$not_nullable); - $this->addColumn('project','cmd_after_publish' ,OR_DB_COLUMN_TYPE_VARCHAR, 255,null,$not_nullable); - $this->addColumn('project','content_negotiation',OR_DB_COLUMN_TYPE_INT , 1, 0,$not_nullable); - $this->addColumn('project','cut_index' ,OR_DB_COLUMN_TYPE_INT , 1, 0,$not_nullable); - - $this->addPrimaryKey('project','id'); - $this->addIndex('project','name'); - - - $this->addTable('user'); - $this->addColumn('user','name',OR_DB_COLUMN_TYPE_VARCHAR,128,null,$not_nullable); - $this->addColumn('user','password',OR_DB_COLUMN_TYPE_VARCHAR,50,null,$not_nullable); - $this->addColumn('user','ldap_dn',OR_DB_COLUMN_TYPE_VARCHAR,255,null,$not_nullable); - $this->addColumn('user','fullname',OR_DB_COLUMN_TYPE_VARCHAR,128,null,$not_nullable); - $this->addColumn('user','tel',OR_DB_COLUMN_TYPE_VARCHAR,128,null,$not_nullable); - $this->addColumn('user','mail',OR_DB_COLUMN_TYPE_VARCHAR,255,null,$not_nullable); - $this->addColumn('user','descr',OR_DB_COLUMN_TYPE_VARCHAR,255,null,$not_nullable); - $this->addColumn('user','style',OR_DB_COLUMN_TYPE_VARCHAR,64,null,$not_nullable); - $this->addColumn('user','is_admin',OR_DB_COLUMN_TYPE_INT,1,0,$not_nullable); - $this->addPrimaryKey('user','id'); - $this->addUniqueIndex('user','name'); - - $this->addTable('group'); - $this->addColumn('group','name',OR_DB_COLUMN_TYPE_VARCHAR,100,null,$not_nullable); - $this->addPrimaryKey('group','id'); - $this->addUniqueIndex('group','name'); - - $this->addTable('object'); - $this->addColumn('object','parentid',OR_DB_COLUMN_TYPE_INT,null,null,$nullable); - $this->addColumn('object','projectid',OR_DB_COLUMN_TYPE_INT,0,0,$not_nullable); - $this->addColumn('object','filename',OR_DB_COLUMN_TYPE_VARCHAR,150,null,$not_nullable); - $this->addColumn('object','orderid',OR_DB_COLUMN_TYPE_INT,0,null,$not_nullable); - $this->addColumn('object','create_date',OR_DB_COLUMN_TYPE_INT,0,null,$not_nullable); - $this->addColumn('object','create_userid',OR_DB_COLUMN_TYPE_INT,0,null,$nullable); - $this->addColumn('object','lastchange_date',OR_DB_COLUMN_TYPE_INT,0,null,$not_nullable); - $this->addColumn('object','lastchange_userid',OR_DB_COLUMN_TYPE_INT,0,null,$nullable); - $this->addColumn('object','is_folder',OR_DB_COLUMN_TYPE_INT,1,null,$not_nullable); - $this->addColumn('object','is_file',OR_DB_COLUMN_TYPE_INT,1,null,$not_nullable); - $this->addColumn('object','is_page',OR_DB_COLUMN_TYPE_INT,1,null,$not_nullable); - $this->addColumn('object','is_link',OR_DB_COLUMN_TYPE_INT,1,null,$not_nullable); - $this->addPrimaryKey('object','id'); - $this->addConstraint('object','projectid','project','id'); - $this->addConstraint('object','lastchange_userid','user','id'); - $this->addConstraint('object','create_userid','user','id'); - - $this->addIndex('object','parentid'); - $this->addIndex('object','projectid'); - $this->addIndex('object','is_folder'); - $this->addIndex('object','is_file'); - $this->addIndex('object','is_page'); - $this->addIndex('object','is_link'); - $this->addIndex('object','orderid'); - $this->addIndex('object','create_userid'); - $this->addIndex('object','lastchange_userid'); - $this->addUniqueIndex('object','parentid,filename'); - - - - - $this->addTable('template'); - $this->addColumn('template','projectid',OR_DB_COLUMN_TYPE_INT,null,null,$not_nullable); - $this->addColumn('template','name',OR_DB_COLUMN_TYPE_VARCHAR,50,null,$not_nullable); - $this->addPrimaryKey('template','id'); - $this->addConstraint('template','projectid','project','id'); - - $this->addIndex('template','projectid'); - $this->addIndex('template','name'); - $this->addUniqueIndex('template','projectid,name'); - - - - $this->addTable('language'); - $this->addColumn('language','projectid',OR_DB_COLUMN_TYPE_INT,0,null,$not_nullable); - $this->addColumn('language','isocode',OR_DB_COLUMN_TYPE_VARCHAR,10,null,$not_nullable); - $this->addColumn('language','name',OR_DB_COLUMN_TYPE_VARCHAR,50,null,$not_nullable); - $this->addColumn('language','is_default',OR_DB_COLUMN_TYPE_INT,1,0,$not_nullable); - $this->addPrimaryKey('language','id'); - $this->addConstraint('language','projectid','project','id'); - $this->addUniqueIndex('language','projectid,isocode'); - - - - - $this->addTable('page'); - $this->addColumn('page','objectid',OR_DB_COLUMN_TYPE_INT,0,null,$not_nullable); - $this->addColumn('page','templateid',OR_DB_COLUMN_TYPE_INT,0,null,$not_nullable); - $this->addPrimaryKey('page','id'); - $this->addConstraint('page','templateid','template','id'); - $this->addConstraint('page','objectid','object','id'); - - $this->addUniqueIndex('page','objectid'); - $this->addIndex('page','templateid'); - - - - - $this->addTable('projectmodel'); - $this->addColumn('projectmodel','projectid',OR_DB_COLUMN_TYPE_INT,0,null,$not_nullable); - $this->addColumn('projectmodel','name',OR_DB_COLUMN_TYPE_VARCHAR,50,null,$not_nullable); - $this->addColumn('projectmodel','extension',OR_DB_COLUMN_TYPE_VARCHAR,10,null,$nullable); - $this->addColumn('projectmodel','is_default',OR_DB_COLUMN_TYPE_INT,1,0,$not_nullable); - $this->addPrimaryKey('projectmodel','id'); - $this->addConstraint('projectmodel','projectid','project','id'); - - $this->addIndex('projectmodel','projectid'); - $this->addUniqueIndex('projectmodel','projectid,name'); - - - $this->addTable('element'); - $this->addColumn('element','templateid',OR_DB_COLUMN_TYPE_INT,0,0,$not_nullable); - $this->addColumn('element','name',OR_DB_COLUMN_TYPE_VARCHAR,50,null,$not_nullable); - $this->addColumn('element','descr',OR_DB_COLUMN_TYPE_VARCHAR,255,null,$not_nullable); - $this->addColumn('element','type',OR_DB_COLUMN_TYPE_VARCHAR,20,null,$not_nullable); - $this->addColumn('element','subtype',OR_DB_COLUMN_TYPE_VARCHAR,20,null,$nullable); - $this->addColumn('element','with_icon',OR_DB_COLUMN_TYPE_INT,1,0,$not_nullable); - $this->addColumn('element','dateformat',OR_DB_COLUMN_TYPE_VARCHAR,100,null,$nullable); - $this->addColumn('element','wiki',OR_DB_COLUMN_TYPE_INT,1,0,$nullable); - $this->addColumn('element','html',OR_DB_COLUMN_TYPE_INT,1,0,$nullable); - $this->addColumn('element','all_languages',OR_DB_COLUMN_TYPE_INT,1,0,$not_nullable); - $this->addColumn('element','writable',OR_DB_COLUMN_TYPE_INT,1,0,$not_nullable); - $this->addColumn('element','decimals',OR_DB_COLUMN_TYPE_INT,0,null,$nullable); - $this->addColumn('element','dec_point',OR_DB_COLUMN_TYPE_VARCHAR,5,null,$nullable); - $this->addColumn('element','thousand_sep',OR_DB_COLUMN_TYPE_VARCHAR,1,null,$nullable); - $this->addColumn('element','code',OR_DB_COLUMN_TYPE_TEXT,null,null,$nullable); - $this->addColumn('element','default_text',OR_DB_COLUMN_TYPE_TEXT,null,null,$nullable); - $this->addColumn('element','folderobjectid',OR_DB_COLUMN_TYPE_INT,null,null,$nullable); - $this->addColumn('element','default_objectid',OR_DB_COLUMN_TYPE_INT,null,null,$nullable); - $this->addPrimaryKey('element','id'); - $this->addConstraint('element','default_objectid','object','id'); - $this->addConstraint('element','folderobjectid','object','id'); - $this->addConstraint('element','templateid','template','id'); - - $this->addIndex('element','templateid'); - $this->addIndex('element','name'); - $this->addUniqueIndex('element','templateid,name'); - - - - - $this->addTable('file'); - $this->addColumn('file','objectid',OR_DB_COLUMN_TYPE_INT,0,null,$not_nullable); - $this->addColumn('file','extension',OR_DB_COLUMN_TYPE_VARCHAR,10,null,$not_nullable); - $this->addColumn('file','size',OR_DB_COLUMN_TYPE_INT,0,null,$not_nullable); - $this->addColumn('file','value',OR_DB_COLUMN_TYPE_BLOB,null,null,$not_nullable); - $this->addPrimaryKey('file','id'); - $this->addConstraint('file','objectid','object','id'); - - $this->addUniqueIndex('file','objectid'); - - - - $this->addTable('folder'); - $this->addColumn('folder','objectid',OR_DB_COLUMN_TYPE_INT,0,null,$not_nullable); - $this->addPrimaryKey('folder','id'); - $this->addConstraint('folder','objectid','object','id'); - - $this->addUniqueIndex('folder','objectid'); - - - - - - $this->addTable('link'); - $this->addColumn('link','objectid',OR_DB_COLUMN_TYPE_INT,0,null,$not_nullable); - $this->addColumn('link','link_objectid',OR_DB_COLUMN_TYPE_INT,null,null,$nullable); - $this->addColumn('link','url',OR_DB_COLUMN_TYPE_VARCHAR,255,null,$nullable); - $this->addPrimaryKey('link','id'); - $this->addConstraint('link','objectid','object','id'); - $this->addConstraint('link','link_objectid','object','id'); - - $this->addUniqueIndex('link','objectid'); - $this->addIndex('link','link_objectid'); - - - - - - $this->addTable('name'); - $this->addColumn('name','objectid',OR_DB_COLUMN_TYPE_INT,0,null,$not_nullable); - $this->addColumn('name','name',OR_DB_COLUMN_TYPE_VARCHAR,255,null,$not_nullable); - $this->addColumn('name','descr',OR_DB_COLUMN_TYPE_VARCHAR,255,null,$not_nullable); - $this->addColumn('name','languageid',OR_DB_COLUMN_TYPE_INT,0,null,$not_nullable); - $this->addPrimaryKey('name','id'); - $this->addConstraint('name','objectid','object','id'); - $this->addConstraint('name','languageid','language','id'); - - $this->addIndex('name','objectid'); - $this->addIndex('name','languageid'); - $this->addUniqueIndex('name','objectid,languageid'); - - - - - - $this->addTable('templatemodel'); - $this->addColumn('templatemodel','templateid',OR_DB_COLUMN_TYPE_INT,0,null,$not_nullable); - $this->addColumn('templatemodel','projectmodelid',OR_DB_COLUMN_TYPE_INT,0,null,$not_nullable); - $this->addColumn('templatemodel','extension',OR_DB_COLUMN_TYPE_VARCHAR,10,null,$nullable); - $this->addColumn('templatemodel','text',OR_DB_COLUMN_TYPE_TEXT,null,null,$not_nullable); - $this->addPrimaryKey('templatemodel','id'); - $this->addConstraint('templatemodel','templateid','template','id'); - $this->addConstraint('templatemodel','projectmodelid','projectmodel','id'); - - $this->addIndex('templatemodel','templateid'); - $this->addUniqueIndex('templatemodel','templateid,extension'); - $this->addUniqueIndex('templatemodel','templateid,projectmodelid'); - - - - - - $this->addTable('usergroup'); - $this->addColumn('usergroup','userid',OR_DB_COLUMN_TYPE_INT,null,null,$not_nullable); - $this->addColumn('usergroup','groupid',OR_DB_COLUMN_TYPE_INT,null,null,$not_nullable); - $this->addPrimaryKey('usergroup','id'); - $this->addConstraint('usergroup','groupid','group','id'); - $this->addConstraint('usergroup','userid','user','id'); - - $this->addIndex('usergroup','groupid'); - $this->addIndex('usergroup','userid'); - $this->addUniqueIndex('usergroup','userid,groupid'); - - - - - $this->addTable('value'); - $this->addColumn('value','pageid',OR_DB_COLUMN_TYPE_INT,0,null,$not_nullable); - $this->addColumn('value','languageid',OR_DB_COLUMN_TYPE_INT,null,null,$not_nullable); - $this->addColumn('value','elementid',OR_DB_COLUMN_TYPE_INT,0,null,$not_nullable); - $this->addColumn('value','linkobjectid',OR_DB_COLUMN_TYPE_INT,null,null,$nullable); - $this->addColumn('value','text',OR_DB_COLUMN_TYPE_TEXT,null,null,$nullable); - $this->addColumn('value','number',OR_DB_COLUMN_TYPE_INT,null,null,$nullable); - $this->addColumn('value','date',OR_DB_COLUMN_TYPE_INT,null,null,$nullable); - $this->addColumn('value','active',OR_DB_COLUMN_TYPE_INT,0,null,$not_nullable); - $this->addColumn('value','lastchange_date',OR_DB_COLUMN_TYPE_INT,0,null,$not_nullable); - $this->addColumn('value','lastchange_userid',OR_DB_COLUMN_TYPE_INT,null,null,$nullable); - $this->addColumn('value','publish',OR_DB_COLUMN_TYPE_INT,null,null,$not_nullable); - $this->addPrimaryKey('value','id'); - $this->addConstraint('value','pageid','page','id'); - $this->addConstraint('value','elementid','element','id'); - $this->addConstraint('value','languageid','language','id'); - $this->addConstraint('value','lastchange_userid','user','id'); - $this->addConstraint('value','linkobjectid','object','id'); - - $this->addIndex('value','pageid'); - $this->addIndex('value','languageid'); - $this->addIndex('value','elementid'); - $this->addIndex('value','active'); - $this->addIndex('value','lastchange_date'); - $this->addIndex('value','publish'); - - - - - - $this->addTable('acl'); - $this->addColumn('acl','userid',OR_DB_COLUMN_TYPE_INT,null,null,$nullable); - $this->addColumn('acl','groupid',OR_DB_COLUMN_TYPE_INT,null,null,$nullable); - $this->addColumn('acl','objectid',OR_DB_COLUMN_TYPE_INT,null,null,$not_nullable); - $this->addColumn('acl','languageid',OR_DB_COLUMN_TYPE_INT,0,null,$nullable); - $this->addColumn('acl','is_write',OR_DB_COLUMN_TYPE_INT,1,0,$not_nullable); - $this->addColumn('acl','is_prop',OR_DB_COLUMN_TYPE_INT,1,0,$not_nullable); - $this->addColumn('acl','is_create_folder',OR_DB_COLUMN_TYPE_INT,1,0,$not_nullable); - $this->addColumn('acl','is_create_file',OR_DB_COLUMN_TYPE_INT,1,0,$not_nullable); - $this->addColumn('acl','is_create_link',OR_DB_COLUMN_TYPE_INT,1,0,$not_nullable); - $this->addColumn('acl','is_create_page',OR_DB_COLUMN_TYPE_INT,1,0,$not_nullable); - $this->addColumn('acl','is_delete',OR_DB_COLUMN_TYPE_INT,1,0,$not_nullable); - $this->addColumn('acl','is_release',OR_DB_COLUMN_TYPE_INT,1,0,$not_nullable); - $this->addColumn('acl','is_publish',OR_DB_COLUMN_TYPE_INT,1,0,$not_nullable); - $this->addColumn('acl','is_grant',OR_DB_COLUMN_TYPE_INT,1,0,$not_nullable); - $this->addColumn('acl','is_transmit',OR_DB_COLUMN_TYPE_INT,1,0,$not_nullable); - $this->addPrimaryKey('acl','id'); - $this->addConstraint('acl','groupid','group','id'); - $this->addConstraint('acl','userid','user','id'); - $this->addConstraint('acl','objectid','object','id'); - $this->addConstraint('acl','languageid','language','id'); - - $this->addIndex('acl','userid'); - $this->addIndex('acl','groupid'); - $this->addIndex('acl','languageid'); - $this->addIndex('acl','objectid'); - $this->addIndex('acl','is_transmit'); - - $this->afterUpdate( $this->getDb() ); - } - - - - /** - * Initialisieren der frisch aktualisierten Datenbank. - * - * @param Database $db - */ - private function afterUpdate( Database $db ) - { - // Benutzer zählen. - $sql = $db->sql('SELECT COUNT(*) From {{user}}',$db->id); - $countUsers = $sql->getOne(); - - // Wenn noch kein Benutzer vorhanden, dann einen anlegen. - if ( $countUsers == 0 ) - { - // Hashing the admin password with MD5. In Version 6 the Algo will be set to 2 (=MD5). - $sql = $db->sql("INSERT INTO {{user}} (id,name,password,ldap_dn,fullname,tel,mail,descr,style,is_admin) VALUES(1,'admin','21232f297a57a5a743894a0e4a801fc3','','Administrator','','','Account for administration tasks.','default',1)",$db->id); - $sql->query(); - $db->commit(); - } - } - - -} - -?>- \ No newline at end of file diff --git a/modules/database-update/update/DBVersion000002.class.php b/modules/database-update/update/DBVersion000002.class.php @@ -1,25 +0,0 @@ -<?php -use database\DbVersion; -/** - * new table: version. - * - * @author dankert - * - */ -class DBVersion000002 extends DbVersion -{ - public function update() - { - $this->addTable('version'); - - $this->addColumn('version','version' ,OR_DB_COLUMN_TYPE_INT,null,null,false); - $this->addColumn('version','status' ,OR_DB_COLUMN_TYPE_INT,null,null,false); - $this->addColumn('version','installed',OR_DB_COLUMN_TYPE_INT,null,null,false); - - $this->addPrimaryKey ('version','id' ); - $this->addIndex ('version','status' ); - $this->addUniqueIndex('version','version' ); - } -} - -?>- \ No newline at end of file diff --git a/modules/database-update/update/DBVersion000003.class.php b/modules/database-update/update/DBVersion000003.class.php @@ -1,16 +0,0 @@ -<?php -use database\DbVersion; -/** - * Dummy version. - * @author dankert - * - */ -class DBVersion000003 extends DbVersion -{ - public function update() - { - // Dummy version. - } -} - -?>- \ No newline at end of file diff --git a/modules/database-update/update/DBVersion000004.class.php b/modules/database-update/update/DBVersion000004.class.php @@ -1,26 +0,0 @@ -<?php -use database\DbVersion; - -/** - * Add Columns for user language and user timezone. - * - * @author dankert - * - */ -class DBVersion000004 extends DbVersion -{ - public function update() - { - $not_nullable = false; - $nullable = true; - - // Add user language - $this->addColumn('user','language',OR_DB_COLUMN_TYPE_VARCHAR, 2,null,$nullable); - - // Add user timezone - $this->addColumn('user','timezone',OR_DB_COLUMN_TYPE_VARCHAR,64,null,$nullable); - - } -} - -?>- \ No newline at end of file diff --git a/modules/database-update/update/DBVersion000005.class.php b/modules/database-update/update/DBVersion000005.class.php @@ -1,33 +0,0 @@ -<?php -use database\DbVersion; - -/** - * Security enhancements. - * - * @author dankert - * - */ -class DBVersion000005 extends DbVersion -{ - public function update() - { - $not_nullable = false; - $nullable = true; - - // longer Passwords! 50 is not enough. - $this->addColumn('user','password_hash',OR_DB_COLUMN_TYPE_VARCHAR,255,null,$not_nullable); - - $db = $this->getDb(); - $table = $this->getTableName('user'); - $updateStmt = $db->sql('UPDATE '.$table. - ' SET password_hash=password' - ); - $updateStmt->query(); - - $this->dropColumn('user','password'); - - $this->addColumn('user','password_salt',OR_DB_COLUMN_TYPE_VARCHAR,255,null,$not_nullable); - } -} - -?>- \ No newline at end of file diff --git a/modules/database-update/update/DBVersion000006.class.php b/modules/database-update/update/DBVersion000006.class.php @@ -1,37 +0,0 @@ -<?php -use database\DbVersion; - -/** - * Security enhancements. - * - * @author dankert - * - */ -class DBVersion000006 extends DbVersion -{ - public function update() - { - $not_nullable = false; - $nullable = true; - - $this->addColumn('user','password_expires',OR_DB_COLUMN_TYPE_INT,0,null,$nullable); - - $this->addColumn('user','last_login' ,OR_DB_COLUMN_TYPE_INT,0,null,$nullable); - - $this->addColumn('user','password_algo' ,OR_DB_COLUMN_TYPE_INT,0,2,$not_nullable); - - // Setting Password algo. Passwords beginning with '$' are (old) MD5-hashes. - - // SUBSTR(s,pos,length) is supported by MySql,Postgres,SQLite - // SUBSTRING(s FROM pos FOR length) is NOT supported by SQLite - $table = $this->getTableName('user'); - $db = $this->getDb(); - $updateAlgoStmt = $db->sql('UPDATE '.$table. - ' SET password_algo=1 WHERE SUBSTR(password_hash,1,1) = '."'$'".';' - ); - $updateAlgoStmt->query(); - - } -} - -?>- \ No newline at end of file diff --git a/modules/database-update/update/DBVersion000007.class.php b/modules/database-update/update/DBVersion000007.class.php @@ -1,39 +0,0 @@ -<?php -use database\DbVersion; -use security\Password; - -/** - * Security enhancements. - * - * @author dankert - * - */ -class DBVersion000007 extends DbVersion -{ - public function update() - { - $not_nullable = false; - $nullable = true; - - $this->addColumn('user','otp_secret' ,OR_DB_COLUMN_TYPE_VARCHAR,255,null,$nullable ); - - $table = $this->getTableName('user'); - $db = $this->getDb(); - $stmt = $db->sql('SELECT id FROM '.$table); - foreach($stmt->getCol() as $userid ) - { - $secret = Password::randomHexString(64); - $stmt = $db->sql('UPDATE '.$table.' SET otp_secret={secret} WHERE id={id}'); - $stmt->setString('secret',$secret); - $stmt->setInt('id',$userid); - $stmt->query(); - } - - $this->addColumn('user','totp' ,OR_DB_COLUMN_TYPE_INT , 1, 0,$not_nullable); - $this->addColumn('user','hotp_counter',OR_DB_COLUMN_TYPE_INT , 0, 0,$not_nullable); - $this->addColumn('user','hotp' ,OR_DB_COLUMN_TYPE_INT , 1, 0,$not_nullable); - - } -} - -?>- \ No newline at end of file diff --git a/modules/database-update/update/DBVersion000008.class.php b/modules/database-update/update/DBVersion000008.class.php @@ -1,55 +0,0 @@ -<?php -use database\DbVersion; -use security\Password; - -/** - * Creates a type column in table OBJECT. Now added types have no need for new table columns. - * - * @author dankert - * - */ -class DBVersion000008 extends DbVersion -{ - /** - * - */ - public function update() - { - $not_nullable = false; - $nullable = true; - - $this->addColumn('object','typeid',OR_DB_COLUMN_TYPE_INT,2,0,$not_nullable); - $this->addIndex('object','typeid'); - - // Converting old values... - $db = $this->getDb(); - $table = $this->getTableName('object'); - - $updateStmt = $db->sql('UPDATE '.$table. - ' SET typeid=1 WHERE is_folder=1' - ); - $updateStmt->query(); - - $updateStmt = $db->sql('UPDATE '.$table. - ' SET typeid=2 WHERE is_file=1' - ); - $updateStmt->query(); - - $updateStmt = $db->sql('UPDATE '.$table. - ' SET typeid=3 WHERE is_page=1' - ); - $updateStmt->query(); - - $updateStmt = $db->sql('UPDATE '.$table. - ' SET typeid=4 WHERE is_link=1' - ); - $updateStmt->query(); - - $this->dropColumn('object','is_folder'); - $this->dropColumn('object','is_file'); - $this->dropColumn('object','is_page'); - $this->dropColumn('object','is_link'); - } -} - -?>- \ No newline at end of file diff --git a/modules/database-update/update/DBVersion000009.class.php b/modules/database-update/update/DBVersion000009.class.php @@ -1,60 +0,0 @@ -<?php - -use cms\model\BaseObject; -use database\DbVersion; -use security\Password; - -/** - * New Object type 'url'. - * - * In this Version 9 we are creating a table 'url' and are copying - * the selected entries from table 'link' to 'url'. - * - * @author dankert - * - */ -class DBVersion000009 extends DbVersion -{ - /** - * - */ - public function update() - { - $not_nullable = false; - $nullable = true; - - // Creating new table 'url' - $this->addTable('url'); - $this->addColumn('url','objectid',OR_DB_COLUMN_TYPE_INT,0,null,$not_nullable); - $this->addColumn('url','url',OR_DB_COLUMN_TYPE_VARCHAR,255,null,$not_nullable); - - $this->addPrimaryKey('url','id'); - $this->addConstraint('url','objectid','object','id'); - - $this->addUniqueIndex('url','objectid'); - - // Copying values from table 'link' to new table 'url' - $db = $this->getDb(); - - $insertStmt = $db->sql('INSERT INTO '.$this->getTableName('url'). - ' (id,objectid,url) SELECT id,objectid,url FROM '.$this->getTableName('link').' WHERE url is not null' - ); - $insertStmt->query(); - - // Updating the typeid for URL entrys in table 'object' - $updateStmt = $db->sql('UPDATE '.$this->getTableName('object'). - ' SET typeid='.BaseObject::TYPEID_URL.' WHERE id IN (SELECT objectid FROM '.$this->getTableName('url').')' - ); - $updateStmt->query(); - - // Remove old entrys in table 'link' - $updateStmt = $db->sql('DELETE FROM '.$this->getTableName('link').' WHERE url is not null' - ); - $updateStmt->query(); - - // Cleanup: Drop unused column. - $this->dropColumn('link','url'); - } -} - -?>- \ No newline at end of file diff --git a/modules/database-update/update/DBVersion000010.class.php b/modules/database-update/update/DBVersion000010.class.php @@ -1,38 +0,0 @@ -<?php -use database\DbVersion; -use security\Password; - -/** - * Filetype 'file' is now devided into 'file' (unchanged), 'image' (new) and OR_DB_COLUMN_TYPE_TEXT (new). - * - * @author dankert - * - */ -class DBVersion000010 extends DbVersion -{ - /** - * - */ - public function update() - { - $db = $this->getDb(); - $tableObject = $this->getTableName('object'); - $tableFile = $this->getTableName('file'); - - $updateStmt = $db->sql('UPDATE '.$tableObject. - ' SET typeid=6 WHERE id IN (SELECT objectid FROM '.$tableFile. - " WHERE extension IN ('gif','png','jpeg','jpg','svg','tiff') )" - ); - $updateStmt->query(); - - $updateStmt = $db->sql('UPDATE '.$tableObject. - ' SET typeid=7 WHERE id IN (SELECT objectid FROM '.$tableFile. - " WHERE extension IN ('css','text','txt','js','html','xml','log','ini','gpx') )" - ); - $updateStmt->query(); - - - } -} - -?>- \ No newline at end of file diff --git a/modules/database-update/update/DBVersion000011.class.php b/modules/database-update/update/DBVersion000011.class.php @@ -1,58 +0,0 @@ -<?php - -use database\DbVersion; -use security\Password; - -/** - * Project gets new columns. - * - * @author dankert - * - */ -class DBVersion000011 extends DbVersion -{ - /** - * - */ - public function update() - { - $not_nullable = false; - $nullable = true; - - - $this->addColumn('project', 'url', OR_DB_COLUMN_TYPE_VARCHAR, 255, '', $not_nullable); - $this->addColumn('project', 'flags', OR_DB_COLUMN_TYPE_INT, 11, 0, $not_nullable); - - $db = $this->getDb(); - $tableProject = $this->getTableName('project'); - - // Update the url - $updateStmt = $db->sql(<<<SQL -UPDATE $tableProject - SET url= CONCAT('//',name) -SQL - ); - $updateStmt->query(); - - // Update the new flags - $updateStmt = $db->sql(<<<SQL -UPDATE $tableProject - SET flags=flags+1 WHERE cut_index=1 -SQL - ); - $updateStmt->query(); - - $updateStmt = $db->sql(<<<SQL -UPDATE $tableProject - SET flags=flags+2 WHERE content_negotiation=1 -SQL - ); - $updateStmt->query(); - - // now the information is hold in column 'flags', so we can delete the old columns. - $this->dropColumn('project', 'cut_index'); - $this->dropColumn('project', 'content_negotiation'); - } -} - -?>- \ No newline at end of file diff --git a/modules/database-update/update/DBVersion000012.class.php b/modules/database-update/update/DBVersion000012.class.php @@ -1,25 +0,0 @@ -<?php - -use database\DbVersion; -use security\Password; - -/** - * Objects gets new columns for storing the publish date. - * - * @author dankert - * - */ -class DBVersion000012 extends DbVersion -{ - /** - * - */ - public function update() - { - $this->addColumn('object','published_date' ,OR_DB_COLUMN_TYPE_INT,0,null,OR_DB_COLUMN_NULLABLE); - $this->addColumn('object','published_userid',OR_DB_COLUMN_TYPE_INT,0,null,OR_DB_COLUMN_NULLABLE); - $this->addConstraint('object','published_userid','user','id'); - } -} - -?>- \ No newline at end of file diff --git a/modules/database-update/update/DBVersion000013.class.php b/modules/database-update/update/DBVersion000013.class.php @@ -1,23 +0,0 @@ -<?php - -use database\DbVersion; -use security\Password; - -/** - * Textfiles should able to be filtered. - * - * @author dankert - * - */ -class DBVersion000013 extends DbVersion -{ - /** - * - */ - public function update() - { - $this->addColumn('file','filterid' ,OR_DB_COLUMN_TYPE_INT,0,null,OR_DB_COLUMN_NULLABLE); - } -} - -?>- \ No newline at end of file diff --git a/modules/database-update/update/DBVersion000014.class.php b/modules/database-update/update/DBVersion000014.class.php @@ -1,24 +0,0 @@ -<?php - -use database\DbVersion; -use security\Password; - -/** - * Objects gets new columns for storing the publish date. - * - * @author dankert - * - */ -class DBVersion000014 extends DbVersion -{ - /** - * - */ - public function update() - { - $this->addColumn('folder','order_by' ,OR_DB_COLUMN_TYPE_INT,0,null,OR_DB_COLUMN_NULLABLE); - $this->addColumn('folder','order_direction',OR_DB_COLUMN_TYPE_INT,0,null,OR_DB_COLUMN_NULLABLE); - } -} - -?>- \ No newline at end of file diff --git a/modules/database-update/update/DBVersion000015.class.php b/modules/database-update/update/DBVersion000015.class.php @@ -1,23 +0,0 @@ -<?php - -use database\DbVersion; -use security\Password; - -/** - * Local settings for every object. - * - * @author dankert - * - */ -class DBVersion000015 extends DbVersion -{ - /** - * - */ - public function update() - { - $this->addColumn('object','settings',OR_DB_COLUMN_TYPE_TEXT,0,null,OR_DB_COLUMN_NOT_NULLABLE); - } -} - -?>- \ No newline at end of file diff --git a/modules/database-update/update/DBVersion000016.class.php b/modules/database-update/update/DBVersion000016.class.php @@ -1,121 +0,0 @@ -<?php - -use database\DbVersion; -use security\Password; - -/** - * Converting element types from string to number. - * - * @author dankert - * - */ -class DBVersion000016 extends DbVersion -{ - /** - * - */ - public function update() - { - // Type 3 = Text is the default. - $this->addColumn('element','typeid',OR_DB_COLUMN_TYPE_INT,0,3,OR_DB_COLUMN_NOT_NULLABLE); - - $db = $this->getDb(); - $tableProject = $this->getTableName('element'); - - // Update the types - $conversionTable = array( - 1 => 'date', - 2 => 'number', - 3 => 'text', - 4 => 'info' , - 5 => 'infodate', - 6 => 'link' , - 7 => 'longtext', - 8 => 'code' , - 9 => 'dynamic' , - 10 => 'select' , - 11 => 'copy' , - 12 => 'linkinfo', - 13 => 'linkdate', - 14 => 'insert' - ); - - foreach ($conversionTable as $typeid => $typename ) - { - $updateStmt = $db->sql(<<<SQL -UPDATE $tableProject - SET typeid=$typeid WHERE type = '$typename' -SQL - ); - $updateStmt->query(); - } - - $this->dropColumn('element','type'); - - - - $this->addColumn('element','flags',OR_DB_COLUMN_TYPE_INT,0,0,OR_DB_COLUMN_NOT_NULLABLE); - - $updateStmt = $db->sql(<<<SQL -UPDATE $tableProject - SET flags=flags+1 WHERE html = 1 -SQL - ); - $updateStmt->query(); - - $updateStmt = $db->sql(<<<SQL -UPDATE $tableProject - SET flags=flags+2 WHERE all_languages = 1 -SQL - ); - $updateStmt->query(); - - $updateStmt = $db->sql(<<<SQL -UPDATE $tableProject - SET flags=flags+4 WHERE writable = 1 -SQL - ); - $updateStmt->query(); - - $updateStmt = $db->sql(<<<SQL -UPDATE $tableProject - SET flags=flags+8 WHERE with_icon = 1 -SQL - ); - $updateStmt->query(); - - - - $this->addColumn('element','format',OR_DB_COLUMN_TYPE_INT,0,0,OR_DB_COLUMN_NOT_NULLABLE); - - // Format = HTML - $updateStmt = $db->sql(<<<SQL -UPDATE $tableProject - SET format=1 WHERE html = 1 and wiki = 0 -SQL - ); - $updateStmt->query(); - - // Format = Wiki - $updateStmt = $db->sql(<<<SQL -UPDATE $tableProject - SET format=2 WHERE wiki = 1 -SQL - ); - $updateStmt->query(); - - // Other formats were not supported up to this version. - - // Cleanup - $this->dropColumn('element','wiki' ); - $this->dropColumn('element','html' ); - $this->dropColumn('element','all_languages'); - $this->dropColumn('element','writable' ); - $this->dropColumn('element','with_icon' ); - - } - - -} - -?>- \ No newline at end of file diff --git a/modules/database-update/update/DBVersion000017.class.php b/modules/database-update/update/DBVersion000017.class.php @@ -1,23 +0,0 @@ -<?php - -use database\DbVersion; -use security\Password; - -/** - * Objects gets new columns for storing valid-dates. - * - * @author dankert - * - */ -class DBVersion000017 extends DbVersion -{ - /** - * - */ - public function update() - { - $this->addColumn('object','valid_from',OR_DB_COLUMN_TYPE_INT,0,null,OR_DB_COLUMN_NULLABLE); - $this->addColumn('object','valid_to' ,OR_DB_COLUMN_TYPE_INT,0,null,OR_DB_COLUMN_NULLABLE); - } -} - diff --git a/modules/database-update/update/DBVersion000018.class.php b/modules/database-update/update/DBVersion000018.class.php @@ -1,34 +0,0 @@ -<?php - -use database\DbVersion; -use security\Password; - -/** - * Elements should have a name and a separate label. - * - * @author dankert - * - */ -class DBVersion000018 extends DbVersion -{ - /** - * - */ - public function update() - { - $this->addColumn('element','label' ,OR_DB_COLUMN_TYPE_VARCHAR,100,'',OR_DB_COLUMN_NOT_NULLABLE); - - // Initial Value for Labels is the element name. - $tableElement = $this->getTableName('element'); - - $updateStmt = $this->getDb()->sql(<<<SQL -UPDATE $tableElement - SET label=name -SQL - ); - $updateStmt->query(); - - $this->addUniqueIndex('element','templateid,label'); - } -} - diff --git a/modules/database-update/update/DBVersion000019.class.php b/modules/database-update/update/DBVersion000019.class.php @@ -1,33 +0,0 @@ -<?php - -use database\DbVersion; -use security\Password; - -/** - * The format of a value is stored in the value table, so users can change the format of a value, independent of the element. - * - * @author dankert - * - */ -class DBVersion000019 extends DbVersion -{ - /** - * - */ - public function update() - { - $this->addColumn('value','format' ,OR_DB_COLUMN_TYPE_INT,1,0,OR_DB_COLUMN_NOT_NULLABLE); - - // Initial Value: Copy from element. - $tableValue = $this->getTableName('value'); - $tableElement = $this->getTableName('element'); - - $updateStmt = $this->getDb()->sql(<<<SQL -UPDATE $tableValue - SET format=(select format from $tableElement where $tableValue.elementid=$tableElement.id) -SQL - ); - $updateStmt->query(); - } -} - diff --git a/modules/database-update/update/DBVersion000020.class.php b/modules/database-update/update/DBVersion000020.class.php @@ -1,37 +0,0 @@ -<?php - -use database\DbVersion; - -/** - * Aliases for node objects. - * - * @author dankert - * - */ -class DBVersion000020 extends DbVersion -{ - /** - * - */ - public function update() - { - $this->addTable('alias'); - - $this->addColumn('alias','objectid' ,OR_DB_COLUMN_TYPE_INT,null,null,OR_DB_COLUMN_NOT_NULLABLE); - $this->addColumn('alias','languageid' ,OR_DB_COLUMN_TYPE_INT,null,null,OR_DB_COLUMN_NULLABLE); - $this->addColumn('alias','link_objectid',OR_DB_COLUMN_TYPE_INT,null,null,OR_DB_COLUMN_NOT_NULLABLE); - - - $this->addPrimaryKey ('alias','id'); - - $this->addConstraint ('alias','objectid' ,'object' ,'id'); - $this->addConstraint ('alias','languageid' ,'language','id'); - $this->addConstraint ('alias','link_objectid','object' ,'id'); - - $this->addUniqueIndex('alias','objectid' ); - $this->addUniqueIndex('alias','link_objectid,languageid'); - $this->addIndex ('alias','link_objectid' ); - - } -} - diff --git a/modules/database-update/update/DBVersion000021.class.php b/modules/database-update/update/DBVersion000021.class.php @@ -1,37 +0,0 @@ -<?php - -use database\DbVersion; - -/** - * Authentication tokens. - * - * @author dankert - * - */ -class DBVersion000021 extends DbVersion -{ - /** - * - */ - public function update() - { - $this->addTable('auth'); - - $this->addColumn('auth','selector' ,OR_DB_COLUMN_TYPE_VARCHAR ,150 ,null,OR_DB_COLUMN_NOT_NULLABLE); - $this->addColumn('auth','userid' ,OR_DB_COLUMN_TYPE_INT ,0 ,null,OR_DB_COLUMN_NOT_NULLABLE); - $this->addColumn('auth','token' ,OR_DB_COLUMN_TYPE_VARCHAR ,150 ,null,OR_DB_COLUMN_NOT_NULLABLE); - $this->addColumn('auth','token_algo' ,OR_DB_COLUMN_TYPE_INT ,0 ,0 ,OR_DB_COLUMN_NOT_NULLABLE); - $this->addColumn('auth','expires' ,OR_DB_COLUMN_TYPE_INT ,0 ,null,OR_DB_COLUMN_NOT_NULLABLE); - $this->addColumn('auth','create_date' ,OR_DB_COLUMN_TYPE_INT ,0 ,null,OR_DB_COLUMN_NOT_NULLABLE); - $this->addColumn('auth','platform' ,OR_DB_COLUMN_TYPE_VARCHAR,255 ,null,OR_DB_COLUMN_NOT_NULLABLE); - $this->addColumn('auth','name' ,OR_DB_COLUMN_TYPE_VARCHAR,255 ,null,OR_DB_COLUMN_NOT_NULLABLE); - - - $this->addPrimaryKey ('auth','id'); - - $this->addConstraint ('auth','userid' ,'user' ,'id'); - - $this->addUniqueIndex('auth','selector' ); - } -} -