summaryrefslogtreecommitdiffstats
path: root/inc
diff options
context:
space:
mode:
Diffstat (limited to 'inc')
-rw-r--r--inc/database.inc.php14
-rw-r--r--inc/eventlog.inc.php15
-rw-r--r--inc/property.inc.php5
3 files changed, 34 insertions, 0 deletions
diff --git a/inc/database.inc.php b/inc/database.inc.php
index e7a16ba1..a729b7fc 100644
--- a/inc/database.inc.php
+++ b/inc/database.inc.php
@@ -9,6 +9,20 @@ class Database
private static $dbh = false;
private static $statements = array();
+
+ /**
+ * Get database schema version - used for checking for updates
+ * @return int Version of db schema
+ */
+ public static function getExpectedSchemaVersion()
+ {
+ return 5;
+ }
+
+ public static function needSchemaUpdate()
+ {
+ return Property::getCurrentSchemaVersion() < self::getExpectedSchemaVersion();
+ }
/**
* Connect to the DB if not already connected.
diff --git a/inc/eventlog.inc.php b/inc/eventlog.inc.php
new file mode 100644
index 00000000..0d7f6d4a
--- /dev/null
+++ b/inc/eventlog.inc.php
@@ -0,0 +1,15 @@
+<?php
+
+class EventLog
+{
+
+ public static function log($eventId, $message)
+ {
+ Database::exec("INSERT INTO eventlog (dateline, logtypeid, description)"
+ . " VALUES (UNIX_TIMESTAMP(), :eventid, :message)", array(
+ 'eventid' => $eventId,
+ 'message' => $message
+ ));
+ }
+
+}
diff --git a/inc/property.inc.php b/inc/property.inc.php
index 81de137f..605d901d 100644
--- a/inc/property.inc.php
+++ b/inc/property.inc.php
@@ -141,5 +141,10 @@ class Property
{
self::set('dl-' . $name, $taskId, 5);
}
+
+ public static function getCurrentSchemaVersion()
+ {
+ return self::get('webif-version');
+ }
}