replace ModuleInstaller::$module_name and ModuleInstaller::$schema_version...

replace ModuleInstaller::$module_name and ModuleInstaller::$schema_version with class constants and dropped the getName() and getSchemaVersion() methods
parent 5e71d800
......@@ -26,6 +26,19 @@ abstract class ModuleInstaller {
*/
protected $module_id = null;
/**
* Name des Moduls
*
* @var string
*/
const MODULE_NAME = '';
/**
* Version des Tabellen-Schema für das Modul
* @var integer
*/
const SCHEMA_VERSION = 0;
/**
* Ressourcen, welche vom standardmäßigen Namensschema abweichen
* oder spezielle Berechtigungen benötigen
......@@ -45,7 +58,7 @@ abstract class ModuleInstaller {
* @param mixed $module_id
*/
public function setModuleId() {
$mod_id = Registry::get('Db')->fetchColumn('SELECT id FROM ' . DB_PRE . 'modules WHERE name = ?', array($this->getName()));
$mod_id = Registry::get('Db')->fetchColumn('SELECT id FROM ' . DB_PRE . 'modules WHERE name = ?', array(static::MODULE_NAME));
$this->module_id = !empty($mod_id) ? (int) $mod_id : 0;
}
......@@ -140,7 +153,7 @@ abstract class ModuleInstaller {
* @return boolean
*/
public function addResources($mode = 1) {
$mod_name = $this->getName();
$mod_name = static::MODULE_NAME;
$dir = ucfirst($mod_name);
$path = MODULES_DIR . $dir . '/';
$files = array($dir . 'Admin', $dir . 'Frontend');
......@@ -260,7 +273,7 @@ abstract class ModuleInstaller {
*/
protected function addToModulesTable() {
// Modul in die Modules-SQL-Tabelle eintragen
$bool = Registry::get('Db')->insert(DB_PRE . 'modules', array('id' => '', 'name' => $this->getName(), 'version' => $this->getSchemaVersion(), 'active' => 1));
$bool = Registry::get('Db')->insert(DB_PRE . 'modules', array('id' => '', 'name' => static::MODULE_NAME, 'version' => static::SCHEMA_VERSION, 'active' => 1));
$this->module_id = Registry::get('Db')->lastInsertId();
return (bool) $bool;
......@@ -281,7 +294,7 @@ abstract class ModuleInstaller {
* @return integer
*/
public function updateSchema() {
$module = Registry::get('Db')->fetchAssoc('SELECT version FROM ' . DB_PRE . 'modules WHERE name = ?', array($this->getName()));
$module = Registry::get('Db')->fetchAssoc('SELECT version FROM ' . DB_PRE . 'modules WHERE name = ?', array(static::MODULE_NAME));
$installed_schema_version = isset($module['version']) ? (int) $module['version'] : 0;
$result = -1;
......@@ -340,7 +353,7 @@ abstract class ModuleInstaller {
* @return boolean
*/
public function setNewSchemaVersion($new_version) {
return Registry::get('Db')->update(DB_PRE . 'modules', array('version' => (int) $new_version), array('name' => $this->getName())) >= 0 ? true : false;
return Registry::get('Db')->update(DB_PRE . 'modules', array('version' => (int) $new_version), array('name' => static::MODULE_NAME)) >= 0 ? true : false;
}
/**
......@@ -352,16 +365,6 @@ abstract class ModuleInstaller {
return array();
}
/**
* Liefert den Modulnamen zurück
*/
abstract protected function getName();
/**
* Liefert die DB-Schema-Version des Moduls zurück
*/
abstract protected function getSchemaVersion();
/**
* Liefert ein Array mit den zu erstellenden Datenbanktabellen des Moduls zurück
*/
......
......@@ -3,16 +3,8 @@ namespace ACP3\Modules\Acp;
use ACP3\Core\ModuleInstaller;
class AcpInstaller extends ModuleInstaller {
private $module_name = 'acp';
private $schema_version = 30;
protected function getName() {
return $this->module_name;
}
protected function getSchemaVersion() {
return $this->schema_version;
}
const MODULE_NAME = 'acp';
const SCHEMA_VERSION = 30;
protected function removeResources() {
return true;
......
......@@ -7,28 +7,16 @@ use ACP3\Core\Modules;
class ArticlesInstaller extends ModuleInstaller {
private $module_name = 'articles';
private $schema_version = 33;
const MODULE_NAME = 'articles';
const SCHEMA_VERSION = 33;
public function renameModule()
{
public function renameModule() {
return array(
31 => "UPDATE `{pre}modules` SET name = 'articles' WHERE name = 'static_pages';"
);
}
protected function getName()
{
return $this->module_name;
}
protected function getSchemaVersion()
{
return $this->schema_version;
}
protected function createTables()
{
protected function createTables() {
return array(
"CREATE TABLE `{pre}articles` (
`id` INT(10) UNSIGNED NOT NULL AUTO_INCREMENT,
......@@ -42,18 +30,15 @@ class ArticlesInstaller extends ModuleInstaller {
);
}
protected function removeTables()
{
protected function removeTables() {
return array("DROP TABLE `{pre}articles`;");
}
protected function settings()
{
protected function settings() {
return array();
}
protected function schemaUpdates()
{
protected function schemaUpdates() {
return array(
31 => array(
"RENAME TABLE `{pre}static_pages` TO `{pre}articles`;",
......@@ -70,7 +55,7 @@ class ArticlesInstaller extends ModuleInstaller {
33 => array(
"DELETE FROM `{pre}acl_resources` WHERE `module_id` = " . $this->getModuleId() . " AND page = \"extensions/search\";",
"DELETE FROM `{pre}acl_resources` WHERE `module_id` = " . $this->getModuleId() . " AND page = \"functions\";",
)
)
);
}
......
......@@ -3,16 +3,8 @@ namespace ACP3\Modules\Captcha;
use ACP3\Core\ModuleInstaller;
class CaptchaInstaller extends ModuleInstaller {
private $module_name = 'captcha';
private $schema_version = 31;
protected function getName() {
return $this->module_name;
}
protected function getSchemaVersion() {
return $this->schema_version;
}
const MODULE_NAME = 'captcha';
const SCHEMA_VERSION = 31;
protected function createTables() {
return array();
......
......@@ -6,16 +6,8 @@ use ACP3\Core\ModuleInstaller;
class CategoriesInstaller extends ModuleInstaller {
private $module_name = 'categories';
private $schema_version = 32;
protected function getName() {
return $this->module_name;
}
protected function getSchemaVersion() {
return $this->schema_version;
}
const MODULE_NAME = 'categories';
const SCHEMA_VERSION = 32;
protected function createTables() {
return array(
......
......@@ -6,16 +6,8 @@ use ACP3\Core\ModuleInstaller;
class CommentsInstaller extends ModuleInstaller {
private $module_name = 'comments';
private $schema_version = 32;
protected function getName() {
return $this->module_name;
}
protected function getSchemaVersion() {
return $this->schema_version;
}
const MODULE_NAME = 'comments';
const SCHEMA_VERSION = 32;
protected function createTables() {
return array(
......
......@@ -3,8 +3,8 @@ namespace ACP3\Modules\Contact;
use ACP3\Core\ModuleInstaller;
class ContactInstaller extends ModuleInstaller {
private $module_name = 'contact';
private $schema_version = 32;
const MODULE_NAME = 'contact';
const SCHEMA_VERSION = 32;
public function __construct() {
$this->special_resources = array(
......@@ -12,14 +12,6 @@ class ContactInstaller extends ModuleInstaller {
);
}
protected function getName() {
return $this->module_name;
}
protected function getSchemaVersion() {
return $this->schema_version;
}
protected function createTables() {
return array();
}
......
......@@ -3,16 +3,8 @@ namespace ACP3\Modules\Emoticons;
use ACP3\Core\ModuleInstaller;
class EmoticonsInstaller extends ModuleInstaller {
private $module_name = 'emoticons';
private $schema_version = 31;
protected function getName() {
return $this->module_name;
}
protected function getSchemaVersion() {
return $this->schema_version;
}
const MODULE_NAME = 'emoticons';
const SCHEMA_VERSION = 31;
protected function createTables() {
return array(
......
......@@ -3,16 +3,8 @@ namespace ACP3\Modules\Errors;
use ACP3\Core\ModuleInstaller;
class ErrorsInstaller extends ModuleInstaller {
private $module_name = 'errors';
private $schema_version = 30;
protected function getName() {
return $this->module_name;
}
protected function getSchemaVersion() {
return $this->schema_version;
}
const MODULE_NAME = 'errors';
const SCHEMA_VERSION = 30;
protected function removeResources() {
return true;
......
......@@ -3,8 +3,8 @@ namespace ACP3\Modules\Feeds;
use ACP3\Core\ModuleInstaller;
class FeedsInstaller extends ModuleInstaller {
private $module_name = 'feeds';
private $schema_version = 31;
const MODULE_NAME = 'feeds';
const SCHEMA_VERSION = 31;
public function __construct() {
$this->special_resources = array(
......@@ -12,14 +12,6 @@ class FeedsInstaller extends ModuleInstaller {
);
}
protected function getName() {
return $this->module_name;
}
protected function getSchemaVersion() {
return $this->schema_version;
}
protected function createTables() {
return array();
}
......
......@@ -3,16 +3,8 @@ namespace ACP3\Modules\Files;
use ACP3\Core\ModuleInstaller;
class FilesInstaller extends ModuleInstaller {
private $module_name = 'files';
private $schema_version = 32;
protected function getName() {
return $this->module_name;
}
protected function getSchemaVersion() {
return $this->schema_version;
}
const MODULE_NAME = 'files';
const SCHEMA_VERSION = 32;
protected function createTables() {
return array(
......
......@@ -6,16 +6,8 @@ use ACP3\Core\ModuleInstaller;
class GalleryInstaller extends ModuleInstaller {
private $module_name = 'gallery';
private $schema_version = 32;
protected function getName() {
return $this->module_name;
}
protected function getSchemaVersion() {
return $this->schema_version;
}
const MODULE_NAME = 'gallery';
const SCHEMA_VERSION = 32;
protected function createTables() {
return array(
......
......@@ -3,16 +3,8 @@ namespace ACP3\Modules\Guestbook;
use ACP3\Core\ModuleInstaller;
class GuestbookInstaller extends ModuleInstaller {
private $module_name = 'guestbook';
private $schema_version = 30;
protected function getName() {
return $this->module_name;
}
protected function getSchemaVersion() {
return $this->schema_version;
}
const MODULE_NAME = 'guestbook';
const SCHEMA_VERSION = 30;
protected function createTables() {
return array(
......
......@@ -6,8 +6,8 @@ use ACP3\Core\ModuleInstaller;
class MenusInstaller extends ModuleInstaller {
private $module_name = 'menus';
private $schema_version = 32;
const MODULE_NAME = 'menus';
const SCHEMA_VERSION = 32;
public function renameModule() {
return array(
......@@ -15,14 +15,6 @@ class MenusInstaller extends ModuleInstaller {
);
}
protected function getName() {
return $this->module_name;
}
protected function getSchemaVersion() {
return $this->schema_version;
}
protected function createTables() {
return array(
"CREATE TABLE `{pre}menu_items` (
......
......@@ -6,16 +6,8 @@ use ACP3\Core\ModuleInstaller;
class NewsInstaller extends ModuleInstaller {
private $module_name = 'news';
private $schema_version = 32;
protected function getName() {
return $this->module_name;
}
protected function getSchemaVersion() {
return $this->schema_version;
}
const MODULE_NAME = 'news';
const SCHEMA_VERSION = 32;
protected function createTables() {
return array(
......
......@@ -6,8 +6,8 @@ use ACP3\Core\ModuleInstaller;
class NewsletterInstaller extends ModuleInstaller {
private $module_name = 'newsletter';
private $schema_version = 34;
const MODULE_NAME = 'newsletter';
const SCHEMA_VERSION = 34;
public function __construct() {
$this->special_resources = array(
......@@ -15,14 +15,6 @@ class NewsletterInstaller extends ModuleInstaller {
);
}
protected function getName() {
return $this->module_name;
}
protected function getSchemaVersion() {
return $this->schema_version;
}
protected function createTables() {
return array(
"CREATE TABLE `{pre}newsletter_accounts` (
......
......@@ -3,8 +3,8 @@ namespace ACP3\Modules\Permissions;
use ACP3\Core\ModuleInstaller;
class PermissionsInstaller extends ModuleInstaller {
private $module_name = 'permissions';
private $schema_version = 31;
const MODULE_NAME = 'permissions';
const SCHEMA_VERSION = 31;
public function renameModule() {
return array(
......@@ -12,14 +12,6 @@ class PermissionsInstaller extends ModuleInstaller {
);
}
protected function getName() {
return $this->module_name;
}
protected function getSchemaVersion() {
return $this->schema_version;
}
protected function removeResources() {
return true;
}
......
......@@ -3,16 +3,8 @@ namespace ACP3\Modules\Polls;
use ACP3\Core\ModuleInstaller;
class PollsInstaller extends ModuleInstaller {
private $module_name = 'polls';
private $schema_version = 31;
protected function getName() {
return $this->module_name;
}
protected function getSchemaVersion() {
return $this->schema_version;
}
const MODULE_NAME = 'polls';
const SCHEMA_VERSION = 31;
protected function createTables() {
return array(
......
......@@ -3,16 +3,8 @@ namespace ACP3\Modules\Search;
use ACP3\Core\ModuleInstaller;
class SearchInstaller extends ModuleInstaller {
private $module_name = 'search';
private $schema_version = 31;
protected function getName() {
return $this->module_name;
}
protected function getSchemaVersion() {
return $this->schema_version;
}
const MODULE_NAME = 'search';
const SCHEMA_VERSION = 31;
protected function createTables() {
return array();
......
......@@ -3,8 +3,8 @@ namespace ACP3\Modules\System;
use ACP3\Core\ModuleInstaller;
class SystemInstaller extends ModuleInstaller {
private $module_name = 'system';
private $schema_version = 35;
const MODULE_NAME = 'system';
const SCHEMA_VERSION = 35;
public function __construct() {
$this->special_resources = array(
......@@ -18,14 +18,6 @@ class SystemInstaller extends ModuleInstaller {
);
}
protected function getName() {
return $this->module_name;
}
protected function getSchemaVersion() {
return $this->schema_version;
}
protected function removeResources() {
return true;
}
......
<?php
namespace ACP3\Modules\Users;
use ACP3\Core\ModuleInstaller;
class UsersInstaller extends ModuleInstaller {
private $module_name = 'users';
private $schema_version = 33;
protected function getName() {
return $this->module_name;
}
protected function getSchemaVersion() {
return $this->schema_version;
}
const MODULE_NAME = 'users';
const SCHEMA_VERSION = 33;
protected function removeResources() {
return true;
......@@ -102,7 +97,8 @@ class UsersInstaller extends ModuleInstaller {
),
33 => array(
"DELETE FROM `{pre}acl_resources` WHERE `module_id` = " . $this->getModuleId() . " AND page = \"functions\";",
)
)
);
}
}
\ No newline at end of file
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment