summaryrefslogtreecommitdiffstats
path: root/inc
diff options
context:
space:
mode:
Diffstat (limited to 'inc')
-rw-r--r--inc/dashboard.inc.php5
-rw-r--r--inc/database.inc.php13
-rw-r--r--inc/event.inc.php11
-rw-r--r--inc/trigger.inc.php25
4 files changed, 47 insertions, 7 deletions
diff --git a/inc/dashboard.inc.php b/inc/dashboard.inc.php
index 59d81c2d..d576a8f1 100644
--- a/inc/dashboard.inc.php
+++ b/inc/dashboard.inc.php
@@ -103,5 +103,10 @@ class Dashboard
{
self::$subMenu[] = array('url' => $url, 'name' => $name);
}
+
+ public static function getSubmenus()
+ {
+ return self::$subMenu;
+ }
} \ No newline at end of file
diff --git a/inc/database.inc.php b/inc/database.inc.php
index d5992795..3b2414b5 100644
--- a/inc/database.inc.php
+++ b/inc/database.inc.php
@@ -77,6 +77,19 @@ class Database
}
/**
+ * Fetch the first column of the query as a plain list-of-values array.
+ *
+ * @return array|bool List of values representing first column of query
+ */
+ public static function queryColumnArray($query, $args = array(), $ignoreError = null)
+ {
+ $res = self::simpleQuery($query, $args, $ignoreError);
+ if ($res === false)
+ return false;
+ return $res->fetchAll(PDO::FETCH_COLUMN, 0);
+ }
+
+ /**
* Execute the given query and return the number of rows affected.
* Mostly useful for UPDATEs or INSERTs
*
diff --git a/inc/event.inc.php b/inc/event.inc.php
index b1ee3663..4e68ab6d 100644
--- a/inc/event.inc.php
+++ b/inc/event.inc.php
@@ -24,6 +24,17 @@ class Event
Property::clearList('cron.key.status');
Property::clearList('cron.key.blocked');
+ // Hooks
+ foreach (Hook::load('bootup') as $hook) {
+ // Isolate for local vars
+ $fun = function() use ($hook) {
+ include_once($hook->file);
+ };
+ $fun();
+ }
+
+ // TODO: Modularize (hooks)
+
// Tasks: fire away
$mountStatus = false;
$mountId = Trigger::mount();
diff --git a/inc/trigger.inc.php b/inc/trigger.inc.php
index 93f57236..e89a9a17 100644
--- a/inc/trigger.inc.php
+++ b/inc/trigger.inc.php
@@ -20,13 +20,24 @@ class Trigger
*/
public static function ipxe()
{
- $data = Property::getBootMenu();
- $data['ipaddress'] = Property::getServerIp();
- $task = Taskmanager::submit('CompileIPxe', $data);
- if (!isset($task['id']))
- return false;
- Property::set('ipxe-task-id', $task['id'], 15);
- return $task['id'];
+ $hooks = Hook::load('ipxe-update');
+ $taskId = false;
+ foreach ($hooks as $hook) {
+ $ret = function($taskId) use ($hook) {
+ $ret = include_once($hook->file);
+ if (is_string($ret))
+ return $ret;
+ return isset($taskId) ? $taskId : false;
+ };
+ $ret = $ret($taskId);
+ if (is_string($ret)) {
+ $taskId = $ret;
+ } elseif (is_array($ret) && isset($ret['id'])) {
+ $taskId = $ret['id'];
+ }
+ }
+ Property::set('ipxe-task-id', $taskId, 15);
+ return $taskId;
}
/**