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.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.inc.php')
| -rw-r--r-- | inc/configmodule.inc.php | 99 |
1 files changed, 0 insertions, 99 deletions
diff --git a/inc/configmodule.inc.php b/inc/configmodule.inc.php deleted file mode 100644 index 1788a53a..00000000 --- a/inc/configmodule.inc.php +++ /dev/null @@ -1,99 +0,0 @@ -<?php - -class ConfigModule -{ - - public static function insertAdConfig($title, $server, $searchbase, $binddn, $bindpw, $home) - { - Database::exec("LOCK TABLE configtgz_module WRITE"); - Database::exec("INSERT INTO configtgz_module (title, moduletype, filepath, contents) " - . " VALUES (:title, 'AD_AUTH', '', '')", array('title' => $title)); - $id = Database::lastInsertId(); - if (!is_numeric($id)) Util::traceError('Inserting new AD config to DB did not yield a numeric insert id'); - // Entry created, now try to get a free port for the proxy - $res = Database::simpleQuery("SELECT moduleid, contents FROM configtgz_module WHERE moduletype = 'AD_AUTH'"); - $ports = array(); - while ($row = $res->fetch(PDO::FETCH_ASSOC)) { - if ($row['moduleid'] == $id) { - // ... - } else { - $data = json_decode($row['contents'], true); - if (isset($data['proxyport'])) $ports[] = $data['proxyport']; - } - } - $port = 3300; - while (in_array($port, $ports)) { - $port++; - } - // Port determined, carry on... - $ownEntry = array( - 'server' => $server, - 'searchbase' => $searchbase, - 'binddn' => $binddn, - 'bindpw' => $bindpw, - 'home' => $home, - 'proxyport' => $port - ); - $data = json_encode($ownEntry); - if ($data === false) Util::traceError('Serializing the AD data failed.'); - $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' => $moduleTgz, - 'contents' => $data - )); - Database::exec("UNLOCK TABLES"); - // Add archive file name to array before returning it - $ownEntry['moduleid'] = $id; - $ownEntry['filename'] = $moduleTgz; - return $ownEntry; - } - - /** - * Get all existing AD proxy configs. - * - * @return array array of ad configs in DB with fields: - * moduleid, filename, server, searchbase, binddn, bindpw, home, proxyport - */ - public static function getAdConfigs() - { - $res = Database::simpleQuery("SELECT moduleid, filepath, contents FROM configtgz_module WHERE moduletype = 'AD_AUTH'"); - $mods = array(); - while ($row = $res->fetch(PDO::FETCH_ASSOC)) { - $data = json_decode($row['contents'], true); - $data['moduleid'] = $row['moduleid']; - $data['filename'] = $row['filepath']; - $mods[] = $data; - } - return $mods; - } - - 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; - } - -} |
