summaryrefslogtreecommitdiffstats
path: root/inc/configmodule/branding.inc.php
diff options
context:
space:
mode:
authorSimon Rettberg2015-01-20 18:07:24 +0100
committerSimon Rettberg2015-01-20 18:07:24 +0100
commit1ff2bc4f3c694b7c76df8e57056c51ca39a23a34 (patch)
tree0eb19164af66b3d4e8bf639a710f323b631d23ee /inc/configmodule/branding.inc.php
parentRework config module class structure. Still some TODOs though.... (diff)
downloadslx-admin-1ff2bc4f3c694b7c76df8e57056c51ca39a23a34.tar.gz
slx-admin-1ff2bc4f3c694b7c76df8e57056c51ca39a23a34.tar.xz
slx-admin-1ff2bc4f3c694b7c76df8e57056c51ca39a23a34.zip
config module structure completed. Many other fixes. Hidden pw field support.
Diffstat (limited to 'inc/configmodule/branding.inc.php')
-rw-r--r--inc/configmodule/branding.inc.php58
1 files changed, 33 insertions, 25 deletions
diff --git a/inc/configmodule/branding.inc.php b/inc/configmodule/branding.inc.php
index f293fda6..e8bd1da7 100644
--- a/inc/configmodule/branding.inc.php
+++ b/inc/configmodule/branding.inc.php
@@ -1,6 +1,6 @@
<?php
-ConfigModules::registerModule(
+ConfigModule::registerModule(
ConfigModule_Branding::MODID, // ID
Dictionary::translate('config-module', 'branding_title'), // Title
Dictionary::translate('config-module', 'branding_description'), // Description
@@ -10,35 +10,43 @@ ConfigModules::registerModule(
class ConfigModule_Branding extends ConfigModule
{
+
const MODID = 'Branding';
+ const VERSION = 1;
+
+ private $tmpFile = false;
- public static function insert($title, $archive)
+ protected function generateInternal($tgz, $parent)
{
- 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
- ));
+ if (!$this->validateConfig()) {
+ if ($this->archive() !== false && file_exists($this->archive()))
+ return true; // No new temp file given, old archive still exists, pretend it worked...
return false;
}
- // Update with path
- Database::exec("UPDATE configtgz_module SET filepath = :filename WHERE moduleid = :id LIMIT 1", array(
- 'id' => $id,
- 'filename' => $moduleTgz
+ $task = Taskmanager::submit('MoveFile', array(
+ 'source' => $this->tmpFile,
+ 'destination' => $tgz,
+ 'parentTask' => $parent,
+ 'failOnParentFail' => false
));
- return true;
+ return $task;
}
-
+
+ protected function moduleVersion()
+ {
+ return self::VERSION;
+ }
+
+ protected function validateConfig()
+ {
+ return $this->tmpFile !== false && file_exists($this->tmpFile);
+ }
+
+ public function setData($key, $value)
+ {
+ if ($key !== 'tmpFile' || !file_exists($value))
+ return false;
+ $this->tmpFile = $value;
+ }
+
}