From e1dc0d3c99217504de2ac8467156274786efc0bd Mon Sep 17 00:00:00 2001 From: Simon Rettberg Date: Thu, 9 Oct 2014 16:01:11 +0200 Subject: Big load of changes - Added callback functionality for taskmanager tasks. You can launch a task and define a callback function to be run when the task finished. This requires activating the cronjob - Added cron functionality: Add cronjob that calls the cron api every 5 minutes to use it. (See cron.inc.php) - Added eventlog - Added missing translations - Merged main-menu-login and main-menu-logout --- inc/configmodule.inc.php | 24 ++++++++++++++++++++++-- 1 file changed, 22 insertions(+), 2 deletions(-) (limited to 'inc/configmodule.inc.php') diff --git a/inc/configmodule.inc.php b/inc/configmodule.inc.php index c0838b5c..1788a53a 100644 --- a/inc/configmodule.inc.php +++ b/inc/configmodule.inc.php @@ -5,13 +5,13 @@ class ConfigModule public static function insertAdConfig($title, $server, $searchbase, $binddn, $bindpw, $home) { - // TODO: Lock table, race condition if about 500 admins insert a config at the same time + 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"); + $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) { @@ -42,12 +42,32 @@ class ConfigModule '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) " -- cgit v1.2.3-55-g7522