summaryrefslogtreecommitdiffstats
path: root/inc/configmodule.inc.php
diff options
context:
space:
mode:
authorSimon Rettberg2014-06-27 21:15:35 +0200
committerSimon Rettberg2014-06-27 21:15:35 +0200
commit16aacada0f64240b7ec35026f0e207b7d0fd37df (patch)
tree26f4b434cd8eb7d3cd0c8eaba6cff6d096213761 /inc/configmodule.inc.php
parentAdded doxygen comments to Taskmanager class (diff)
downloadslx-admin-16aacada0f64240b7ec35026f0e207b7d0fd37df.tar.gz
slx-admin-16aacada0f64240b7ec35026f0e207b7d0fd37df.tar.xz
slx-admin-16aacada0f64240b7ec35026f0e207b7d0fd37df.zip
New SysConfig module for adding a logo
Diffstat (limited to 'inc/configmodule.inc.php')
-rw-r--r--inc/configmodule.inc.php34
1 files changed, 31 insertions, 3 deletions
diff --git a/inc/configmodule.inc.php b/inc/configmodule.inc.php
index 5c789275..c0838b5c 100644
--- a/inc/configmodule.inc.php
+++ b/inc/configmodule.inc.php
@@ -36,16 +36,44 @@ class ConfigModule
);
$data = json_encode($ownEntry);
if ($data === false) Util::traceError('Serializing the AD data failed.');
- $name = CONFIG_TGZ_LIST_DIR . '/modules/AD_AUTH_id_' . $id . '.' . mt_rand() . '.tgz';
+ $moduleTgz = CONFIG_TGZ_LIST_DIR . '/modules/AD_AUTH_id_' . $id . '.' . mt_rand() . '.tgz';
Database::exec("UPDATE configtgz_module SET filepath = :filename, contents = :contents WHERE moduleid = :id LIMIT 1", array(
'id' => $id,
- 'filename' => $name,
+ 'filename' => $moduleTgz,
'contents' => $data
));
// Add archive file name to array before returning it
$ownEntry['moduleid'] = $id;
- $ownEntry['filename'] = $name;
+ $ownEntry['filename'] = $moduleTgz;
return $ownEntry;
}
+ public static function insertBrandingModule($title, $archive)
+ {
+ Database::exec("INSERT INTO configtgz_module (title, moduletype, filepath, contents) "
+ . " VALUES (:title, 'BRANDING', '', '')", array('title' => $title));
+ $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;
+ }
+
}