summaryrefslogtreecommitdiffstats
path: root/modules-available/statistics/hooks
diff options
context:
space:
mode:
authorSimon Rettberg2017-05-10 12:26:29 +0200
committerSimon Rettberg2017-05-10 12:26:29 +0200
commit32f9eeabbf8bcf7f4e9c8224ff3d31b30aa3ed41 (patch)
tree04c3c5d0c80c085920017feeb1ed0cb6b3e2e29e /modules-available/statistics/hooks
parent[statistics] Fix typo in install.inc.php (diff)
downloadslx-admin-32f9eeabbf8bcf7f4e9c8224ff3d31b30aa3ed41.tar.gz
slx-admin-32f9eeabbf8bcf7f4e9c8224ff3d31b30aa3ed41.tar.xz
slx-admin-32f9eeabbf8bcf7f4e9c8224ff3d31b30aa3ed41.zip
[statistics] Compat to old DB in conftgz hook
Diffstat (limited to 'modules-available/statistics/hooks')
-rw-r--r--modules-available/statistics/hooks/config-tgz.inc.php40
1 files changed, 21 insertions, 19 deletions
diff --git a/modules-available/statistics/hooks/config-tgz.inc.php b/modules-available/statistics/hooks/config-tgz.inc.php
index 1272a94f..8dffbff6 100644
--- a/modules-available/statistics/hooks/config-tgz.inc.php
+++ b/modules-available/statistics/hooks/config-tgz.inc.php
@@ -7,26 +7,28 @@ $res = Database::simpleQuery('SELECT h.hwname FROM statistic_hw h'
'screen' => DeviceType::SCREEN,
));
-$content = '';
-while ($row = $res->fetch(PDO::FETCH_ASSOC)) {
- $content .= $row['hwname'] . "=beamer\n";
-}
+if ($res !== false) { // CHeck this in case we're running on old DB during update
+ $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);
+ 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;
- } 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;
}
-}
+} \ No newline at end of file