summaryrefslogtreecommitdiffstats
path: root/inc/taskmanagercallback.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/taskmanagercallback.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/taskmanagercallback.inc.php')
-rw-r--r--inc/taskmanagercallback.inc.php49
1 files changed, 40 insertions, 9 deletions
diff --git a/inc/taskmanagercallback.inc.php b/inc/taskmanagercallback.inc.php
index 951a1de3..a42f4819 100644
--- a/inc/taskmanagercallback.inc.php
+++ b/inc/taskmanagercallback.inc.php
@@ -13,7 +13,7 @@ class TaskmanagerCallback
* @param string|array $task Task or Task ID to define callback for
* @param string $callback name of callback function, must be a static method in this class
*/
- public static function addCallback($task, $callback)
+ public static function addCallback($task, $callback, $args = NULL)
{
if (!call_user_func_array('method_exists', array('TaskmanagerCallback', $callback))) {
EventLog::warning("addCallback: Invalid callback function: $callback");
@@ -25,10 +25,16 @@ class TaskmanagerCallback
EventLog::warning("addCallback: Not a valid task id: $task");
return;
}
- Database::exec("INSERT INTO callback (taskid, dateline, cbfunction) VALUES (:task, UNIX_TIMESTAMP(), :callback)", array(
+ if (is_null($args))
+ $args = '';
+ else
+ $args = serialize($args);
+ Database::exec("INSERT INTO callback (taskid, dateline, cbfunction, args) VALUES (:task, UNIX_TIMESTAMP(), :callback, :args)", array(
'task' => $task,
- 'callback' => $callback
+ 'callback' => $callback,
+ 'args' => $args
));
+ Property::setNeedsCallback(1);
}
/**
@@ -39,7 +45,7 @@ class TaskmanagerCallback
public static function getPendingCallbacks()
{
$retval = array();
- $res = Database::simpleQuery("SELECT taskid, cbfunction FROM callback");
+ $res = Database::simpleQuery("SELECT taskid, cbfunction, args FROM callback");
while ($row = $res->fetch(PDO::FETCH_ASSOC)) {
$retval[$row['taskid']][] = $row;
}
@@ -50,7 +56,7 @@ class TaskmanagerCallback
* Handle the given callback. Will delete the entry from the callback
* table if appropriate.
*
- * @param array $callback entry from the callback table (cbfunction + taskid)
+ * @param array $callback entry from the callback table (cbfunction + taskid + args)
* @param array $status status of the task as returned by the taskmanager. If NULL it will be queried.
*/
public static function handleCallback($callback, $status = NULL)
@@ -69,7 +75,10 @@ class TaskmanagerCallback
if (!call_user_func_array('method_exists', $func)) {
Eventlog::warning("handleCallback: Callback {$callback['cbfunction']} doesn't exist.");
} else {
- call_user_func($func, $status);
+ if (empty($callback['args']))
+ call_user_func($func, $status);
+ else
+ call_user_func($func, $status, unserialize($callback['args']));
}
}
}
@@ -85,13 +94,35 @@ class TaskmanagerCallback
EventLog::warning("Could not start/stop LDAP-AD-Proxy instances", $task['data']['messages']);
}
+ /**
+ * Result of restoring the server configuration
+ */
public static function dbRestored($task)
{
- error_log("dbRestored.");
- if (Taskmanager::isFinished($task) && !Taskmanager::isFailed($task)) {
- error_log("LOGGING.");
+ if (!Taskmanager::isFailed($task)) {
EventLog::info('Configuration backup restored.');
}
}
+
+ public static function adConfigCreate($task)
+ {
+ if (Taskmanager::isFailed($task))
+ EventLog::warning("Could not generate Active Directory configuration", $task['data']['error']);
+ }
+
+ /**
+ * Generating a config module has finished.
+ *
+ * @param array $task task obj
+ * @param array $args has keys 'moduleid' and optionally 'deleteOnError' and 'tmpTgz'
+ */
+ public static function cbConfModCreated($task, $args)
+ {
+ if (Taskmanager::isFailed($task)) {
+ ConfigModule::generateFailed($task, $args);
+ } else {
+ ConfigModule::generateSucceeded($args);
+ }
+ }
}