diff options
author | Simon Rettberg | 2014-12-12 18:28:38 +0100 |
---|---|---|
committer | Simon Rettberg | 2014-12-12 18:28:38 +0100 |
commit | 97a0f7dcfdcf4a5263c1cc6c19160a0868abb5f2 (patch) | |
tree | cf735055cfb785ac64e60ab477e215f5f50ad767 /inc/configmodule/branding.inc.php | |
parent | [news] fix xml tags of news api (diff) | |
download | slx-admin-97a0f7dcfdcf4a5263c1cc6c19160a0868abb5f2.tar.gz slx-admin-97a0f7dcfdcf4a5263c1cc6c19160a0868abb5f2.tar.xz slx-admin-97a0f7dcfdcf4a5263c1cc6c19160a0868abb5f2.zip |
Rework config module class structure. Still some TODOs though....
Diffstat (limited to 'inc/configmodule/branding.inc.php')
-rw-r--r-- | inc/configmodule/branding.inc.php | 44 |
1 files changed, 44 insertions, 0 deletions
diff --git a/inc/configmodule/branding.inc.php b/inc/configmodule/branding.inc.php new file mode 100644 index 00000000..f293fda6 --- /dev/null +++ b/inc/configmodule/branding.inc.php @@ -0,0 +1,44 @@ +<?php + +ConfigModules::registerModule( + ConfigModule_Branding::MODID, // ID + Dictionary::translate('config-module', 'branding_title'), // Title + Dictionary::translate('config-module', 'branding_description'), // Description + Dictionary::translate('config-module', 'group_branding'), // Group + true // Only one per config? +); + +class ConfigModule_Branding extends ConfigModule +{ + const MODID = 'Branding'; + + public static function insert($title, $archive) + { + Database::exec("INSERT INTO configtgz_module (title, moduletype, filepath, contents) " + . " VALUES (:title, :modid, '', '')", array('title' => $title, 'modid' => self::MODID)); + $id = Database::lastInsertId(); + if (!is_numeric($id)) + Util::traceError('Inserting new Branding Module into DB did not yield a numeric insert id'); + // Move tgz + $moduleTgz = CONFIG_TGZ_LIST_DIR . '/modules/BRANDING_id_' . $id . '.' . mt_rand() . '.tgz'; + $task = Taskmanager::submit('MoveFile', array( + 'source' => $archive, + 'destination' => $moduleTgz + )); + $task = Taskmanager::waitComplete($task, 3000); + if (Taskmanager::isFailed($task) || $task['statusCode'] !== TASK_FINISHED) { + Taskmanager::addErrorMessage($task); + Database::exec("DELETE FROM configtgz_module WHERE moduleid = :moduleid LIMIT 1", array( + 'moduleid' => $id + )); + return false; + } + // Update with path + Database::exec("UPDATE configtgz_module SET filepath = :filename WHERE moduleid = :id LIMIT 1", array( + 'id' => $id, + 'filename' => $moduleTgz + )); + return true; + } + +} |