summaryrefslogtreecommitdiffstats
path: root/modules-available/statistics/hooks
diff options
context:
space:
mode:
Diffstat (limited to 'modules-available/statistics/hooks')
-rw-r--r--modules-available/statistics/hooks/config-tgz.inc.php32
1 files changed, 32 insertions, 0 deletions
diff --git a/modules-available/statistics/hooks/config-tgz.inc.php b/modules-available/statistics/hooks/config-tgz.inc.php
new file mode 100644
index 00000000..1272a94f
--- /dev/null
+++ b/modules-available/statistics/hooks/config-tgz.inc.php
@@ -0,0 +1,32 @@
+<?php
+
+$res = Database::simpleQuery('SELECT h.hwname FROM statistic_hw h'
+ . " INNER JOIN statistic_hw_prop p ON (h.hwid = p.hwid AND p.prop = :projector)"
+ . " WHERE h.hwtype = :screen ORDER BY h.hwname ASC", array(
+ 'projector' => 'projector',
+ 'screen' => DeviceType::SCREEN,
+));
+
+$content = '';
+while ($row = $res->fetch(PDO::FETCH_ASSOC)) {
+ $content .= $row['hwname'] . "=beamer\n";
+}
+
+if (!empty($content)) {
+ $tmpfile = '/tmp/bwlp-' . md5($content) . '.tar';
+ if (!is_file($tmpfile) || !is_readable($tmpfile) || filemtime($tmpfile) + 86400 < time()) {
+ if (file_exists($tmpfile)) {
+ unlink($tmpfile);
+ }
+ try {
+ $a = new PharData($tmpfile);
+ $a->addFromString("/opt/openslx/beamergui/beamer.conf", $content);
+ $file = $tmpfile;
+ } catch (Exception $e) {
+ EventLog::failure('Could not include beamer.conf in config.tgz', (string)$e);
+ unlink($tmpfile);
+ }
+ } elseif (is_file($tmpfile) && is_readable($tmpfile)) {
+ $file = $tmpfile;
+ }
+}