summaryrefslogtreecommitdiffstats
path: root/inc/eventlog.inc.php
diff options
context:
space:
mode:
authorSimon Rettberg2016-05-19 15:44:42 +0200
committerSimon Rettberg2016-05-19 15:44:42 +0200
commit740fb42074b348a2e5d8f231bb48981f90699d5c (patch)
tree2cf7077a449c0f7f0a7df123e2639fe4eff60f05 /inc/eventlog.inc.php
parentMove Validator include to basconfig module (diff)
downloadslx-admin-740fb42074b348a2e5d8f231bb48981f90699d5c.tar.gz
slx-admin-740fb42074b348a2e5d8f231bb48981f90699d5c.tar.xz
slx-admin-740fb42074b348a2e5d8f231bb48981f90699d5c.zip
Add checks for eventlog module existence in global helper class
Diffstat (limited to 'inc/eventlog.inc.php')
-rw-r--r--inc/eventlog.inc.php14
1 files changed, 14 insertions, 0 deletions
diff --git a/inc/eventlog.inc.php b/inc/eventlog.inc.php
index 836b6974..6683986c 100644
--- a/inc/eventlog.inc.php
+++ b/inc/eventlog.inc.php
@@ -1,10 +1,22 @@
<?php
+/**
+ * Class to add entries to the event log. Technically this class belongs to the
+ * eventlog module, but since it is used in so many places, this helper resides
+ * in the general inc directory instead of the eventlog's inc directory, since
+ * that would require to add "if (Module::isAvailable('eventlog')) { ... }"
+ * all over the place. Instead, the availability check was moved here.
+ */
class EventLog
{
private static function log($type, $message, $details)
{
+ if (!Module::isAvailable('eventlog')) {
+ // Eventlog module does not exist; the eventlog table might not exist, so bail out
+ error_log($message);
+ return;
+ }
Database::exec("INSERT INTO eventlog (dateline, logtypeid, description, extra)"
. " VALUES (UNIX_TIMESTAMP(), :type, :message, :details)", array(
'type' => $type,
@@ -35,6 +47,8 @@ class EventLog
*/
public static function clear()
{
+ if (!Module::isAvailable('eventlog'))
+ return;
Database::exec("TRUNCATE eventlog");
}