From a56e3487dd09740996e3648173a550d368bdb10d Mon Sep 17 00:00:00 2001 From: Simon Rettberg Date: Mon, 16 Jul 2018 15:17:35 +0200 Subject: [roomplanner] Fix search feature: load user in ajax call --- modules-available/roomplanner/page.inc.php | 1 + 1 file changed, 1 insertion(+) (limited to 'modules-available') diff --git a/modules-available/roomplanner/page.inc.php b/modules-available/roomplanner/page.inc.php index 023cef73..8b75499b 100644 --- a/modules-available/roomplanner/page.inc.php +++ b/modules-available/roomplanner/page.inc.php @@ -108,6 +108,7 @@ class Page_Roomplanner extends Page if ($this->action === 'getmachines') { + User::load(); $locations = User::getAllowedLocations('edit'); if (empty($locations)) { die('{"machines":[]}'); -- cgit v1.2.3-55-g7522 From f37c95a560f0d2bac96e4b0e650d12691181b876 Mon Sep 17 00:00:00 2001 From: Simon Rettberg Date: Tue, 7 Aug 2018 16:48:13 +0200 Subject: [syslog] Add user export feature This will export all rows from tables that log user related content, data, events, helping administrators to conform to DSGVO information requests. Closes #3401 --- modules-available/syslog/api.inc.php | 39 ++++++++++++++++++++++ .../syslog/lang/de/template-tags.json | 4 +++ .../syslog/lang/en/template-tags.json | 4 +++ modules-available/syslog/page.inc.php | 2 +- .../syslog/permissions/permissions.json | 3 ++ modules-available/syslog/templates/heading.html | 39 ++++++++++++++++++++-- 6 files changed, 87 insertions(+), 4 deletions(-) (limited to 'modules-available') diff --git a/modules-available/syslog/api.inc.php b/modules-available/syslog/api.inc.php index 18c42c31..945f9d09 100644 --- a/modules-available/syslog/api.inc.php +++ b/modules-available/syslog/api.inc.php @@ -1,5 +1,44 @@ Database::simpleQuery("SELECT dateline, logtypeid AS typeid, clientip, description FROM clientlog + WHERE description REGEXP :exp + ORDER BY dateline ASC", ['exp' => $exp])]; + if (Module::get('statistics') !== false) { + $srcs[] = ['res' => Database::simpleQuery("SELECT dateline, typeid, clientip, data AS description FROM statistic + WHERE username = :user + ORDER BY dateline ASC", ['user' => $user])]; + } + echo "# Begin log\n"; + for (;;) { + unset($best); + foreach ($srcs as &$src) { + if (!isset($src['row'])) { + $src['row'] = $src['res']->fetch(PDO::FETCH_ASSOC); + } + if ($src['row'] !== false && (!isset($best) || $src['row']['dateline'] < $best['dateline'])) { + $best =& $src['row']; + } + } + if (!isset($best)) + break; + echo date('Y-m-d H:i:s', $best['dateline']), "\t", $best['typeid'], "\t", $best['clientip'], "\t", $best['description'], "\n"; + $best = null; // so we repopulate on next iteration + } + die("# End log\n"); +} + if (empty($_POST['type'])) die('Missing options.'); $type = mb_strtolower($_POST['type']); diff --git a/modules-available/syslog/lang/de/template-tags.json b/modules-available/syslog/lang/de/template-tags.json index b5c6f8c7..c00d619a 100644 --- a/modules-available/syslog/lang/de/template-tags.json +++ b/modules-available/syslog/lang/de/template-tags.json @@ -5,8 +5,12 @@ "lang_clientLog": "Client Log", "lang_details": "Details", "lang_event": "Ereignis", + "lang_export": "Exportieren", + "lang_exportUserDesc": "Mit dieser Funktion k\u00f6nnen Sie alle in der Datenbank vorhandenen Datens\u00e4tze zu einem bestimmten Benutzer exportieren. Bitte geben Sie den Benutzernamen genau so ein, wie ihn der Nutzer beim Login am Client angeben muss.", "lang_filter": "Filter", "lang_not": "not", "lang_settings": "Einstellungen", + "lang_userExport": "Nutzer-Export", + "lang_userLogin": "Benutzer-Login", "lang_when": "Wann" } \ No newline at end of file diff --git a/modules-available/syslog/lang/en/template-tags.json b/modules-available/syslog/lang/en/template-tags.json index 1aae1fe9..24e9aaa1 100644 --- a/modules-available/syslog/lang/en/template-tags.json +++ b/modules-available/syslog/lang/en/template-tags.json @@ -5,8 +5,12 @@ "lang_clientLog": "Client Log", "lang_details": "Details", "lang_event": "Event", + "lang_export": "Export", + "lang_exportUserDesc": "This exports all data from the database relating to the given user login. Please specify the user name exactly the way they would provide it when logging in on a client.", "lang_filter": "Filter", "lang_not": "not", "lang_settings": "Settings", + "lang_userExport": "User export", + "lang_userLogin": "User login", "lang_when": "When" } \ No newline at end of file diff --git a/modules-available/syslog/page.inc.php b/modules-available/syslog/page.inc.php index 00c55a3f..6c1a0a16 100644 --- a/modules-available/syslog/page.inc.php +++ b/modules-available/syslog/page.inc.php @@ -31,7 +31,7 @@ class Page_SysLog extends Page protected function doRender() { $data = ['anondays' => Property::get(self::PROP_ANON_DAYS, 0)]; - Permission::addGlobalTags($data['perms'], NULL, ['configure-anonymization']); + Permission::addGlobalTags($data['perms'], NULL, ['configure-anonymization', 'export-user-data']); Render::addTemplate("heading", $data); if (!User::hasPermission("view")) { diff --git a/modules-available/syslog/permissions/permissions.json b/modules-available/syslog/permissions/permissions.json index cabf82f9..1f2373d4 100644 --- a/modules-available/syslog/permissions/permissions.json +++ b/modules-available/syslog/permissions/permissions.json @@ -4,5 +4,8 @@ }, "configure-anonymization": { "location-aware": false + }, + "export-user-data": { + "location-aware": false } } \ No newline at end of file diff --git a/modules-available/syslog/templates/heading.html b/modules-available/syslog/templates/heading.html index 2ab1a848..8dd3d440 100644 --- a/modules-available/syslog/templates/heading.html +++ b/modules-available/syslog/templates/heading.html @@ -1,7 +1,13 @@ \ No newline at end of file -- cgit v1.2.3-55-g7522 From cd092274b88599449902f480f35291768be6e99e Mon Sep 17 00:00:00 2001 From: Simon Rettberg Date: Tue, 7 Aug 2018 16:54:01 +0200 Subject: [inc/User] Fix access to Page if class is not loaded --- inc/user.inc.php | 11 ++++- lang/pt/flag.png | Bin 1115 -> 0 bytes lang/pt/name.txt | 1 - modules-available/exams/lang/de/template-tags.json | 2 +- modules-available/exams/lang/en/template-tags.json | 2 +- .../coursebackend/coursebackend_hisinone.inc.php | 48 +++++++++++++-------- .../locationinfo/lang/de/template-tags.json | 2 +- .../locationinfo/lang/en/template-tags.json | 2 +- 8 files changed, 43 insertions(+), 25 deletions(-) delete mode 100644 lang/pt/flag.png delete mode 100644 lang/pt/name.txt (limited to 'modules-available') diff --git a/inc/user.inc.php b/inc/user.inc.php index 2571c61c..20e8cd3d 100644 --- a/inc/user.inc.php +++ b/inc/user.inc.php @@ -34,8 +34,15 @@ class User if ($permission{0} === '.') { $permission = substr($permission, 1); } else { - $module = Page::getModule(); - $permission = $module ? $module->getIdentifier() . "." . $permission : $permission; + if (class_exists('Page')) { + $module = Page::getModule(); + if ($module !== false) { + $module = $module->getIdentifier(); + } + } else { + $module = strtolower(Request::any('do')); + } + $permission = $module ? $module . "." . $permission : $permission; } return PermissionUtil::userHasPermission(self::$user['userid'], $permission, $locationid); } diff --git a/lang/pt/flag.png b/lang/pt/flag.png deleted file mode 100644 index 78c57dea..00000000 Binary files a/lang/pt/flag.png and /dev/null differ diff --git a/lang/pt/name.txt b/lang/pt/name.txt deleted file mode 100644 index 811b10b4..00000000 --- a/lang/pt/name.txt +++ /dev/null @@ -1 +0,0 @@ -Português \ No newline at end of file diff --git a/modules-available/exams/lang/de/template-tags.json b/modules-available/exams/lang/de/template-tags.json index 8bf37143..1dd51374 100644 --- a/modules-available/exams/lang/de/template-tags.json +++ b/modules-available/exams/lang/de/template-tags.json @@ -29,7 +29,7 @@ "lang_headingMain": "bwLehrpool Pr\u00fcfungsmodus", "lang_id": "ID", "lang_lectureName": "Veranstaltungsname", - "lang_lectureOutOfRange": "Achtung: Start- bzw. Endzeitpunkt der Veranstaltung liegen au\u00dferhalb des oben angegebenen Zeitraums", + "lang_lectureOutOfRange": "Achtung: Der oben angegebene Zeitraum ist k\u00fcrzer als die Dauer der Veranstaltung", "lang_location": "Raum\/Ort", "lang_locationInfo": "W\u00e4hlen Sie hier die R\u00e4ume und Orte aus, die w\u00e4hrend des unten ausgew\u00e4hlten Zeitraums in den Pr\u00fcfungsmodus versetzt werden. Wenn sie hier keine Auswahl treffen, werden alle R\u00e4ume in den Pr\u00fcfungsmodus versetzt.", "lang_locations": "R\u00e4ume\/Orte", diff --git a/modules-available/exams/lang/en/template-tags.json b/modules-available/exams/lang/en/template-tags.json index af87bb01..23266154 100644 --- a/modules-available/exams/lang/en/template-tags.json +++ b/modules-available/exams/lang/en/template-tags.json @@ -29,7 +29,7 @@ "lang_headingMain": "bwLehrpool Exam Mode", "lang_id": "ID", "lang_lectureName": "Lecture name", - "lang_lectureOutOfRange": "Hint: Start or end date of given lecture lies outside of exam period given above", + "lang_lectureOutOfRange": "Hint: The exam period given above is shorter than the duration of the given lecture", "lang_location": "Room\/Location", "lang_locationInfo": "Select the rooms and locations you want to enable the exam mode in. Selecting nothing at all means that all clients will boot into exam mode during the given time period.", "lang_locations": "Rooms\/Locations", diff --git a/modules-available/locationinfo/inc/coursebackend/coursebackend_hisinone.inc.php b/modules-available/locationinfo/inc/coursebackend/coursebackend_hisinone.inc.php index 558f5cd0..3b26e625 100644 --- a/modules-available/locationinfo/inc/coursebackend/coursebackend_hisinone.inc.php +++ b/modules-available/locationinfo/inc/coursebackend/coursebackend_hisinone.inc.php @@ -274,8 +274,7 @@ class CourseBackend_HisInOne extends CourseBackend foreach ($eventDetails as $event) { foreach (array('/hisdefaulttext', '/hisshorttext', - '/hisshortcomment', - '/hisplanelements/hisplanelement/hisdefaulttext') as $path) { + '/hisshortcomment') as $path) { $name = $this->getArrayPath($event, $path); if (!empty($name) && !empty($name[0])) break; @@ -284,25 +283,38 @@ class CourseBackend_HisInOne extends CourseBackend if ($name === false) { $name = ['???']; } - $unitPlannedDates = $this->getArrayPath($event, - '/hisplanelements/hisplanelement/hisplannedDates/hisplannedDate/hisindividualDates/hisindividualDate'); - if ($unitPlannedDates === false) { - $this->error = 'Cannot find ./hisplanelements/hisplanelement/hisplannedDates/hisplannedDate/hisindividualDates/hisindividualDate'; - error_log('Cannot find ./hisplanelements/hisplanelement/hisplannedDates/hisplannedDate/hisindividualDates/hisindividualDate'); + $planElements = $this->getArrayPath($event, '/hisplanelements/hisplanelement'); + if ($planElements === false) { + $this->error = 'Cannot find ./hisplanelements/hisplanelement'; + error_log('Cannot find ./hisplanelements/hisplanelement'); error_log(print_r($event, true)); continue; } - foreach ($unitPlannedDates as $plannedDate) { - $eventRoomId = $this->getArrayPath($plannedDate, '/hisroomId')[0]; - $eventDate = $this->getArrayPath($plannedDate, '/hisexecutiondate')[0]; - if (in_array($eventRoomId, $requestedRoomIds) && in_array($eventDate, $currentWeek)) { - $startTime = $this->getArrayPath($plannedDate, '/hisstarttime')[0]; - $endTime = $this->getArrayPath($plannedDate, '/hisendtime')[0]; - $tTables[$eventRoomId][] = array( - 'title' => $name[0], - 'start' => $eventDate . "T" . $startTime, - 'end' => $eventDate . "T" . $endTime - ); + foreach ($planElements as $planElement) { + $unitPlannedDates = $this->getArrayPath($planElement, + '/hisplannedDates/hisplannedDate/hisindividualDates/hisindividualDate'); + if ($unitPlannedDates === false) { + $this->error = 'Cannot find ./hisplannedDates/hisplannedDate/hisindividualDates/hisindividualDate'; + error_log('Cannot find ./hisplannedDates/hisplannedDate/hisindividualDates/hisindividualDate'); + error_log(print_r($planElement, true)); + continue; + } + $localName = $this->getArrayPath($planElement, '/hisdefaulttext'); + if ($localName === false || empty($localName[0])) { + $localName = $name; + } + foreach ($unitPlannedDates as $plannedDate) { + $eventRoomId = $this->getArrayPath($plannedDate, '/hisroomId')[0]; + $eventDate = $this->getArrayPath($plannedDate, '/hisexecutiondate')[0]; + if (in_array($eventRoomId, $requestedRoomIds) && in_array($eventDate, $currentWeek)) { + $startTime = $this->getArrayPath($plannedDate, '/hisstarttime')[0]; + $endTime = $this->getArrayPath($plannedDate, '/hisendtime')[0]; + $tTables[$eventRoomId][] = array( + 'title' => $localName[0], + 'start' => $eventDate . "T" . $startTime, + 'end' => $eventDate . "T" . $endTime + ); + } } } } diff --git a/modules-available/locationinfo/lang/de/template-tags.json b/modules-available/locationinfo/lang/de/template-tags.json index bcdf7148..b51c420b 100644 --- a/modules-available/locationinfo/lang/de/template-tags.json +++ b/modules-available/locationinfo/lang/de/template-tags.json @@ -76,7 +76,7 @@ "lang_remoteSchedule": "Abruf Belegungsplan", "lang_room": "Raum", "lang_roomId": "Raum ID", - "lang_roomIdTooltip": "Die Raum ID, die der Server ben\u00f6tigt, um Kalenderdaten abzurufen", + "lang_roomIdTooltip": "Die Raum ID, die der Server ben\u00f6tigt, um Kalenderdaten abzurufen (bei Exchange die Postfachadresse)", "lang_roomupdateTooltip": "Zeit nach der die PCs aktualisiert werden (in Sekunden)", "lang_rotation": "Rotation", "lang_rotation0": "0\u00b0", diff --git a/modules-available/locationinfo/lang/en/template-tags.json b/modules-available/locationinfo/lang/en/template-tags.json index 558ddff0..f041dc0a 100644 --- a/modules-available/locationinfo/lang/en/template-tags.json +++ b/modules-available/locationinfo/lang/en/template-tags.json @@ -76,7 +76,7 @@ "lang_remoteSchedule": "Time table retrieval", "lang_room": "Room", "lang_roomId": "Room ID", - "lang_roomIdTooltip": "The ID of the room the server needs, for querying the calendar data", + "lang_roomIdTooltip": "The ID of the room the server needs, for querying the calendar data (when using exchange the room mailbox)", "lang_roomupdateTooltip": "Time the PCs in the room gets updated (in seconds)", "lang_rotation": "Rotation", "lang_rotation0": "0\u00b0", -- cgit v1.2.3-55-g7522 From 13ce0399b010241ecc136eb35196cffdd503b73f Mon Sep 17 00:00:00 2001 From: Christian Hofmaier Date: Thu, 11 Oct 2018 15:25:20 +0200 Subject: [locationinfo] disable add location when 4 rooms in list in default-panel-config - don't close dropdown selection when room selected - if 4 rooms selected disable the add button - if 4 rooms selected, close the dropdown selection - re enable the button when a room gets removed --- .../templates/page-config-panel-default.html | 25 +++++++++++++++++----- 1 file changed, 20 insertions(+), 5 deletions(-) (limited to 'modules-available') diff --git a/modules-available/locationinfo/templates/page-config-panel-default.html b/modules-available/locationinfo/templates/page-config-panel-default.html index ba493579..f7009764 100644 --- a/modules-available/locationinfo/templates/page-config-panel-default.html +++ b/modules-available/locationinfo/templates/page-config-panel-default.html @@ -293,7 +293,7 @@ - {{lang_cancel}} - +
+ {{lang_cancel}} + +
- {{lang_cancel}} - +
+ {{lang_cancel}} + +
- - {{lang_cancel}} - +
+ {{lang_cancel}} + +
\ No newline at end of file -- cgit v1.2.3-55-g7522 From baf1cd9fb75b620e80a2eb411ac2b627af292823 Mon Sep 17 00:00:00 2001 From: Simon Rettberg Date: Sat, 1 Dec 2018 15:37:54 +0100 Subject: [dozmod] ldapfilter: Update table scheme, fix minor bugs * Editing filter showed wrong success message * Made all methods static * Fix listing existing filters --- modules-available/dozmod/pages/ldapfilters.inc.php | 32 +++++++++++----------- .../dozmod/templates/ldapfilter-add.html | 4 +-- 2 files changed, 18 insertions(+), 18 deletions(-) (limited to 'modules-available') diff --git a/modules-available/dozmod/pages/ldapfilters.inc.php b/modules-available/dozmod/pages/ldapfilters.inc.php index 6b5ce2dc..d0ae41b8 100644 --- a/modules-available/dozmod/pages/ldapfilters.inc.php +++ b/modules-available/dozmod/pages/ldapfilters.inc.php @@ -23,7 +23,8 @@ class SubPage { if (self::$show === false) { // Get all ldapfilters from the sat db. - $ldapfilters = Database::simpleQuery("SELECT * FROM sat.ldapfilter"); + $ldapfilters = Database::queryAll("SELECT filterid, filtername, filterkey, filtervalue FROM sat.presetlecturefilter + WHERE filtertype ='LDAP' ORDER BY filtername ASC"); $data = array( 'ldapfilters' => $ldapfilters, @@ -39,27 +40,23 @@ class SubPage 'filterid' => 0 )); } else { - $ldapfilter = Database::queryFirst("SELECT * FROM sat.ldapfilter WHERE filterid=:id", array( 'id' => $filterid)); - - $data = array( - 'filterid' => $filterid, - 'filtername' => $ldapfilter['filtername'], - 'attribute' => $ldapfilter['attribute'], - 'value' => $ldapfilter['value'] - ); - Render::addTemplate('ldapfilter-add', $data); + $ldapfilter = Database::queryFirst("SELECT filterid, filtername, filterkey, filtervalue FROM sat.presetlecturefilter + WHERE filterid = :id AND filtertype = 'LDAP'", array( 'id' => $filterid)); + // TODO: Show error if not exists + + Render::addTemplate('ldapfilter-add', $ldapfilter); } } } - private function deleteLdapFilter() { + private static function deleteLdapFilter() { User::assertPermission('ldapfilters.save'); $filterid = Request::post('filterid', false, 'int'); if ($filterid === false) { Message::addError('ldap-filter-id-missing'); return; } - $res = Database::exec("DELETE FROM sat.ldapfilter WHERE filterid=:id", array('id' => $filterid)); + $res = Database::exec("DELETE FROM sat.presetlecturefilter WHERE filterid = :id AND filtertype = 'LDAP'", array('id' => $filterid)); if ($res !== 1) { Message::addWarning('ldap-invalid-filter-id', $filterid); } else { @@ -67,7 +64,7 @@ class SubPage } } - private function saveLdapFilter() { + private static function saveLdapFilter() { $filterid = Request::post('filterid', '', 'int'); $filtername = Request::post('filtername', false, 'string'); $filterattribute = Request::post('attribute', false, 'string'); @@ -80,7 +77,8 @@ class SubPage if ($filterid === 0) { // Insert filter in the db. - $res = Database::exec("INSERT INTO sat.ldapfilter (filtername, attribute, value) VALUES (:filtername, :attribute, :value)", array( + $res = Database::exec("INSERT INTO sat.presetlecturefilter (filtertype, filtername, filterkey, filtervalue) + VALUES ('LDAP', :filtername, :attribute, :value)", array( 'filtername' => $filtername, 'attribute' => $filterattribute, 'value' => $filtervalue @@ -94,7 +92,9 @@ class SubPage } else { // Update filter in the db. - $res = Database::exec("UPDATE sat.ldapfilter SET filtername=:filtername, attribute=:attribute, value=:value WHERE filterid=:filterid", array( + $res = Database::exec("UPDATE sat.presetlecturefilter SET + filtername = :filtername, filterkey = :attribute, filtervalue = :value + WHERE filterid = :filterid AND filtertype = 'LDAP'", array( 'filterid' => $filterid, 'filtername' => $filtername, 'attribute' => $filterattribute, @@ -104,7 +104,7 @@ class SubPage if ($res !== 1) { Message::addError('ldap-filter-insert-failed'); } else { - Message::addSuccess('ldap-filter-created'); + Message::addSuccess('ldap-filter-saved'); } } diff --git a/modules-available/dozmod/templates/ldapfilter-add.html b/modules-available/dozmod/templates/ldapfilter-add.html index c74fbcda..f66972d1 100644 --- a/modules-available/dozmod/templates/ldapfilter-add.html +++ b/modules-available/dozmod/templates/ldapfilter-add.html @@ -17,11 +17,11 @@
- +
- +
-- cgit v1.2.3-55-g7522 From acd0f96696dc5c7d581902186f913fb3dff5302d Mon Sep 17 00:00:00 2001 From: Simon Rettberg Date: Mon, 3 Dec 2018 11:55:51 +0100 Subject: [locationinfo] HiS: Check if event has any planned dates --- .../locationinfo/inc/coursebackend/coursebackend_hisinone.inc.php | 2 ++ 1 file changed, 2 insertions(+) (limited to 'modules-available') diff --git a/modules-available/locationinfo/inc/coursebackend/coursebackend_hisinone.inc.php b/modules-available/locationinfo/inc/coursebackend/coursebackend_hisinone.inc.php index 3b26e625..22b1d8fb 100644 --- a/modules-available/locationinfo/inc/coursebackend/coursebackend_hisinone.inc.php +++ b/modules-available/locationinfo/inc/coursebackend/coursebackend_hisinone.inc.php @@ -291,6 +291,8 @@ class CourseBackend_HisInOne extends CourseBackend continue; } foreach ($planElements as $planElement) { + if (empty($planElement['hisplannedDates'])) + continue; $unitPlannedDates = $this->getArrayPath($planElement, '/hisplannedDates/hisplannedDate/hisindividualDates/hisindividualDate'); if ($unitPlannedDates === false) { -- cgit v1.2.3-55-g7522 From 3104f69bd48bd7241a5ae1077f9f8f8720572bb3 Mon Sep 17 00:00:00 2001 From: Simon Rettberg Date: Mon, 3 Dec 2018 14:58:25 +0100 Subject: [dozmod] Networkshares: New DB scheme, error checks --- .../dozmod/pages/networkshares.inc.php | 89 ++++++++++++++++------ .../dozmod/templates/ldapfilters.html | 5 ++ .../dozmod/templates/networkshares-edit.html | 21 +++-- .../dozmod/templates/networkshares.html | 32 ++++++-- 4 files changed, 107 insertions(+), 40 deletions(-) (limited to 'modules-available') diff --git a/modules-available/dozmod/pages/networkshares.inc.php b/modules-available/dozmod/pages/networkshares.inc.php index d0bbe03a..659321b4 100644 --- a/modules-available/dozmod/pages/networkshares.inc.php +++ b/modules-available/dozmod/pages/networkshares.inc.php @@ -10,32 +10,51 @@ class SubPage if ($action === 'delete') { User::assertPermission('networkshares.save'); $shareid = Request::post('shareid', false, 'int'); - if ($shareid) { + if ($shareid !== false) { $res = Database::exec('DELETE FROM sat.presetnetworkshare WHERE shareid = :shareid', ['shareid' => $shareid]); - if ($res) Message::addSuccess('networkshare-deleted'); + if ($res !== false) { + Message::addSuccess('networkshare-deleted'); + } } } else if ($action === 'save') { User::assertPermission('networkshares.save'); - $shareid = Request::post('shareid', false, 'int'); - $sharename = Request::post('sharename', false, 'string'); + $shareid = Request::post('shareid', 0, 'int'); + $sharename = Request::post('sharename', '', 'string'); $path = Request::post('path', false, 'string'); - $target = Request::post('target', null, 'string'); - $username = Request::post('username', null, 'string'); - $password = Request::post('password', null, 'string'); - if ($sharename && $path) { - if ($shareid) { - Database::exec('UPDATE sat.presetnetworkshare SET sharename = :sharename, path = :path, target = :target, username = :username, password = :password' - .' WHERE shareid = :shareid', compact('shareid', 'sharename', 'path', 'target', 'username', 'password')); + $target = Request::post('target', '', 'string'); + $authType = Request::post('auth', '', 'string'); + $username = Request::post('username', '', 'string'); + $password = Request::post('password', '', 'string'); + if (!in_array($authType, ['LOGIN_USER', 'OTHER_USER'], true)) { + Message::addError('networkshare-invalid-auth-type', $authType); + } elseif (empty($path)) { + Message::addError('networkshare-missing-path'); + } else { + $data = json_encode([ + 'auth' => $authType, + 'path' => $path, + 'displayname' => $sharename, + 'mountpoint' => $target, + 'username' => $username, + 'password' => $password, + ]); + if ($shareid !== 0) { + Database::exec('UPDATE sat.presetnetworkshare SET sharename = :sharename, sharedata = :data' + .' WHERE shareid = :shareid', compact('shareid', 'sharename', 'data')); } else { - Database::exec('INSERT INTO sat.presetnetworkshare (sharename, path, target, username, password, active)' - .' VALUES (:sharename, :path, :target, :username, :password, 0)', compact('sharename', 'path', 'target', 'username', 'password')); + Database::exec('INSERT INTO sat.presetnetworkshare (sharename, sharedata, active)' + .' VALUES (:sharename, :data, 1)', compact('sharename', 'data')); } Message::addSuccess('networkshare-saved'); } - } else if ($action === 'toggleActive') { + } else if ($action === 'activate' || $action === 'deactivate') { User::assertPermission('networkshares.save'); $shareid = Request::post('shareid', false, 'int'); - Database::exec('UPDATE sat.presetnetworkshare SET active = !active WHERE shareid = :shareid', compact('shareid')); + $active = ($action === 'activate' ? 1 : 0); + Database::exec('UPDATE sat.presetnetworkshare SET active = :active WHERE shareid = :shareid', compact('active', 'shareid')); + } + if (Request::isPost()) { + Util::redirect('?do=dozmod§ion=networkshares'); } User::assertPermission('networkshares.view'); } @@ -44,18 +63,44 @@ class SubPage { $show = Request::get('show', 'list', 'string'); if ($show === 'list') { - $res = Database::simpleQuery('SELECT * FROM sat.presetnetworkshare;'); + $res = Database::simpleQuery('SELECT shareid, sharename, sharedata, active + FROM sat.presetnetworkshare ORDER BY sharename ASC'); $rows = array(); while ($row = $res->fetch(PDO::FETCH_ASSOC)) { - $row['specificUser'] = $row['username'] && $row['password']; - $rows[] = $row; + $dec = json_decode($row['sharedata'], true); + if (!is_array($dec)) { + $dec = []; + } + if ($dec['auth'] === 'LOGIN_USER') { + $row['loginAsUser'] = true; + } + $rows[] = $row + $dec; } - Render::addTemplate('networkshares', ['networkshares' => $rows, 'hasEditPermissions' => User::hasPermission('networkshares.save')]); + Render::addTemplate('networkshares', [ + 'networkshares' => $rows, + 'hasEditPermissions' => User::hasPermission('networkshares.save') + ]); } else if ($show === 'edit') { $shareid = Request::get('shareid', 0, 'int'); - $data = Database::queryFirst('SELECT * FROM sat.presetnetworkshare WHERE shareid = :shareid', ['shareid' => $shareid]); - if ($data['username'] && $data['password']) $data['specificUser'] = 'selected'; - else $data['loggedInUser'] = 'selected'; + if ($shareid === 0) { + $data = []; + } else { + $data = Database::queryFirst('SELECT shareid, sharename, sharedata + FROM sat.presetnetworkshare WHERE shareid = :shareid', ['shareid' => $shareid]); + if ($data === false) { + Message::addError('networkshare-invalid-shareid', $shareid); + Util::redirect('?do=dozmod§ion=networkshares'); + } + $dec = json_decode($data['sharedata'], true); + if (is_array($dec)) { + $data += $dec; + } + if ($data['auth'] === 'LOGIN_USER') { + $data['loggedInUser_selected'] = 'selected'; + } else { + $data['specificUser_selected'] = 'selected'; + } + } Render::addTemplate('networkshares-edit', $data); } } diff --git a/modules-available/dozmod/templates/ldapfilters.html b/modules-available/dozmod/templates/ldapfilters.html index 49ecc222..06be33a5 100644 --- a/modules-available/dozmod/templates/ldapfilters.html +++ b/modules-available/dozmod/templates/ldapfilters.html @@ -1,4 +1,9 @@

{{lang_ldapfilters}}

+ +

+ {{lang_ldapfiltersIntro}} +

+ diff --git a/modules-available/dozmod/templates/networkshares-edit.html b/modules-available/dozmod/templates/networkshares-edit.html index 32aa902f..cc89dbcc 100644 --- a/modules-available/dozmod/templates/networkshares-edit.html +++ b/modules-available/dozmod/templates/networkshares-edit.html @@ -21,7 +21,7 @@
- + +
- +
- +
@@ -64,21 +65,19 @@ document.addEventListener("DOMContentLoaded", function () { - $('#target').val('{{target}}'); + $('#target').val('{{mountpoint}}'); $('#auth').change(function () { var username = $('#username'); var password = $('#password'); - if ($(this).val() === 'specificUser') { + if ($(this).val() === 'OTHER_USER') { username.prop('disabled', false); password.prop('disabled', false); } else { username.prop('disabled', true); password.prop('disabled', true); - username.val(''); - password.val(''); } - }); + }).change(); }) diff --git a/modules-available/dozmod/templates/networkshares.html b/modules-available/dozmod/templates/networkshares.html index 48506b4e..aaafa256 100644 --- a/modules-available/dozmod/templates/networkshares.html +++ b/modules-available/dozmod/templates/networkshares.html @@ -1,5 +1,9 @@

{{lang_networkshares}}

+

+ {{lang_networksharesIntro}} +

+
@@ -20,18 +24,32 @@ - - - + + + {{#hasEditPermissions}} -
{{sharename}} {{path}}{{#target}}{{.}}:{{/target}}{{#specificUser}}{{lang_specificUser}}{{/specificUser}}{{^specificUser}}{{lang_loggedInUser}}{{/specificUser}}{{#specificUser}}{{username}}{{/specificUser}}{{mountpoint}} + {{#loginAsUser}}{{lang_loggedInUser}}{{/loginAsUser}} + {{^loginAsUser}}{{lang_specificUser}}{{/loginAsUser}} + + {{^loginAsUser}}{{username}}{{/loginAsUser}} + +
- + {{#active}} + + + {{/active}} + {{^active}} + + + {{/active}}
-- cgit v1.2.3-55-g7522 From ed899338534f68dd6ba62fd2f1c207858d20aa3b Mon Sep 17 00:00:00 2001 From: Simon Rettberg Date: Mon, 3 Dec 2018 15:00:53 +0100 Subject: [dozmod] Update translations --- modules-available/dozmod/lang/de/messages.json | 5 ++++- modules-available/dozmod/lang/de/template-tags.json | 10 +++++++--- modules-available/dozmod/lang/en/messages.json | 8 ++++++-- modules-available/dozmod/lang/en/template-tags.json | 6 +++++- 4 files changed, 22 insertions(+), 7 deletions(-) (limited to 'modules-available') diff --git a/modules-available/dozmod/lang/de/messages.json b/modules-available/dozmod/lang/de/messages.json index 29d40619..f74c3eab 100644 --- a/modules-available/dozmod/lang/de/messages.json +++ b/modules-available/dozmod/lang/de/messages.json @@ -5,13 +5,16 @@ "images-pending-delete-exist": "Zur L\u00f6schung markierte VM-Versionen: {{0}}", "ldap-filter-created": "LDAP Filter wurde erfolgreich erstellt", "ldap-filter-deleted": "LDAP Filter wurde erfolgreich gel\u00f6scht", - "ldap-invalid-filter-id": "Ung\u00fcltige LDAP Filter ID", "ldap-filter-id-missing": "Fehlende LDAP Filter ID", "ldap-filter-insert-failed": "LDAP filter konnte der Datenbank nicht hinzugef\u00fcgt werden", "ldap-filter-save-missing-information": "Es fehlen LDAP Filter Informationen", "ldap-filter-saved": "LDAP Filter wurde erfolgreich gespeichert", + "ldap-invalid-filter-id": "Ung\u00fcltige LDAP Filter ID", "mail-config-saved": "Mail-Konfiguration gespeichert", "networkshare-deleted": "Netzlaufwerk gel\u00f6scht", + "networkshare-invalid-auth-type": "Ung\u00fcltiger Authentifizierungs-Typ: {{0}}", + "networkshare-invalid-shareid": "Nicht-existierender Share: {{0}}", + "networkshare-missing-path": "Fehlende Pfadangabe", "networkshare-saved": "Netzlaufwerk gespeichert", "no-expired-images": "Keine Abgelaufenen VM-Versionen", "nothing-submitted": "Es wurde nichts \u00fcbermittelt", diff --git a/modules-available/dozmod/lang/de/template-tags.json b/modules-available/dozmod/lang/de/template-tags.json index a7ee9833..99756995 100644 --- a/modules-available/dozmod/lang/de/template-tags.json +++ b/modules-available/dozmod/lang/de/template-tags.json @@ -1,7 +1,7 @@ { "lang_actionTarget": "Aktionsziel", "lang_active": "Aktiv", - "lang_addShare": "Netzlaufwerk hinzufügen", + "lang_addShare": "Netzlaufwerk hinzuf\u00fcgen", "lang_allowLoginByDefault": "Login standardm\u00e4\u00dfig erlauben", "lang_allowLoginDescription": "Wenn diese Option aktiviert ist, k\u00f6nnen sich alle Mitarbeiter der Einrichtung \u00fcber die bwLehrpool-Suite anmelden und VMs\/Veranstaltungen verwalten. Wenn Sie diese Option deaktivieren, m\u00fcssen Sie in der Untersektion \"Benutzer und Berechtigungen\" jeden Benutzer nach dem ersten Loginversuch manuell freischalten.", "lang_asteriskRequired": "Felder mit (*) sind erforderlich", @@ -45,8 +45,9 @@ "lang_ldapFilterDescription": "Dies sind die Filter, die ein Benutzer in der bwLehrpool-Suite Veranstaltungen hinzuf\u00fcgen kann.", "lang_ldapFilterEdit": "LDAP Filter bearbeiten", "lang_ldapFilterName": "Filtername", - "lang_ldapfilters": "LDAP Filter", "lang_ldapFilterValue": "Wert", + "lang_ldapfilters": "LDAP Filter", + "lang_ldapfiltersIntro": "Hier k\u00f6nnen Sie Vorgaben f\u00fcr die Veranstaltungsspezifischen LDAP-Filter machen. LDAP-Filter sind einfache Attributsfilter, die clientseitig Anwendung finden. Die hier definierten Filter werden in der bwLehrpool-Suite als Vorschl\u00e4ge aufgelistet und k\u00f6nnen mittels Checkbox aktiviert werden. Alternativ k\u00f6nnen in der bwLehrpool-Suite auch eigene Filter angelegt werden.", "lang_lecture": "Veranstaltung", "lang_lecturePermissionAdmin": "Administration", "lang_lecturePermissionEdit": "Bearbeiten", @@ -63,6 +64,8 @@ "lang_modified": "Modifiziert", "lang_name": "Name", "lang_networkshares": "Netzlaufwerke", + "lang_networksharesIntro": "Hier k\u00f6nnen Sie vordefinierte Netzlaufwerke anlegen, die den Nutzern der bwLehrpool-Suite zur Auswahl gestellt werden. Es ist den Nutzern der bwLehrpool-Suite weiterhin m\u00f6glich, komplett eigene Netzwerkfreigaben zu definieren. Die Angaben hier sollen lediglich das Hinzuf\u00fcgen h\u00e4ufig genutzter Laufwerke vereinfachen, bzw. das \u00c4ndern eines Netzwerkpfades vereinfachen, da in diesem Fall nur der Zentrale Eintrag hier angepasst werden muss, und nicht mehr wie zuvor jede Veranstaltung einzeln.", + "lang_none": "(Keiner)", "lang_organization": "Einrichtung", "lang_organizationListHeader": "Nutzungsrechte f\u00fcr den Satelliten festlegen", "lang_os": "Betriebssystem", @@ -71,14 +74,15 @@ "lang_path": "Pfad", "lang_placeholders": "Platzhalter", "lang_port": "Port", + "lang_printer": "Drucker", "lang_reallyResetTemplates": "Sind Sie sicher, dass Sie alle Texte l\u00f6schen und auf die Standardwerte zur\u00fccksetzen wollen?", "lang_replaceWithOriginal": "Originaltext in Textbox laden", "lang_replyTo": "Reply-To Adresse", "lang_runtimeConfig": "Laufzeit-Konfiguration", "lang_runtimeConfigLimits": "Beschr\u00e4nkungen", "lang_senderAddress": "Absenderadresse", - "lang_shareDeleteConfirm": "Willst du dieses Netzlaufwerk wirklich l\u00f6schen?", "lang_senderName": "Absender Anzeigename", + "lang_shareDeleteConfirm": "Willst du dieses Netzlaufwerk wirklich l\u00f6schen?", "lang_size": "Gr\u00f6\u00dfe", "lang_spaceWastedDuplication": "Potentiell durch mehrfach vorkommende Bl\u00f6cke belegter Speicherplatz", "lang_specificUser": "Spezifischer Nutzer", diff --git a/modules-available/dozmod/lang/en/messages.json b/modules-available/dozmod/lang/en/messages.json index a76fc67c..d09ff279 100644 --- a/modules-available/dozmod/lang/en/messages.json +++ b/modules-available/dozmod/lang/en/messages.json @@ -5,12 +5,16 @@ "images-pending-delete-exist": "VMs marked for deletion: {{0}}", "ldap-filter-created": "LDAP filter was successfully created", "ldap-filter-deleted": "LDAP filter successfully deleted", - "ldap-invalid-filter-id": "Invalid LDAP filter id", "ldap-filter-id-missing": "LDAP filter id was missing", "ldap-filter-insert-failed": "LDAP filter could not be inserted into the database", - "ldap-filter-save-missing-information": "LDAP filter informations were missing", + "ldap-filter-save-missing-information": "LDAP filter information is missing", + "ldap-filter-saved": "Successfully modified LDAP filter", + "ldap-invalid-filter-id": "Invalid LDAP filter id", "mail-config-saved": "Mail config saved", "networkshare-deleted": "Network share deleted", + "networkshare-invalid-auth-type": "Invalid auth type: {{0}}", + "networkshare-invalid-shareid": "Invalid share id: {{0}}", + "networkshare-missing-path": "Missing network path", "networkshare-saved": "Network share saved", "no-expired-images": "No expired VMs", "nothing-submitted": "There was nothing submitted", diff --git a/modules-available/dozmod/lang/en/template-tags.json b/modules-available/dozmod/lang/en/template-tags.json index 2fd3e91b..ddc89284 100644 --- a/modules-available/dozmod/lang/en/template-tags.json +++ b/modules-available/dozmod/lang/en/template-tags.json @@ -45,8 +45,9 @@ "lang_ldapFilterDescription": "These are the LDAP filters that can be applied to lectures in the bwLehrpool-Suite.", "lang_ldapFilterEdit": "Edit LDAP filter", "lang_ldapFilterName": "Filter name", - "lang_ldapfilters": "LDAP filters", "lang_ldapFilterValue": "Value", + "lang_ldapfilters": "LDAP filters", + "lang_ldapfiltersIntro": "This is the list of predefined lecture filters, based on LDAP attributes. These filters can be applied client side to only show lectures to specific user groups. These predefined filters are shown in the bwLehrpool-Suite when editing a lecture, and can be activated by a simple check box. Users of the bwLehrpool-Suite can either make use of these predefined filters, or add custom ones if desired.", "lang_lecture": "Lecture", "lang_lecturePermissionAdmin": "Administrate", "lang_lecturePermissionEdit": "Edit", @@ -63,6 +64,8 @@ "lang_modified": "modified", "lang_name": "Name", "lang_networkshares": "Network Shares", + "lang_networksharesIntro": "This is the list of predefined network shares. bwLehrpool-Suite users can still add custom network shares to their lectures, however having commonly used network shares as predefined entries should be much more convenient. Another advantage is that changing the path of a network share centrally avoids having to edit a dozen lectures' configuration manually.", + "lang_none": "(none)", "lang_organization": "Organization", "lang_organizationListHeader": "Set access permissions for organizations", "lang_os": "Operating System", @@ -71,6 +74,7 @@ "lang_path": "Path", "lang_placeholders": "Placeholders", "lang_port": "Port", + "lang_printer": "Printer", "lang_reallyResetTemplates": "Are you sure you want to reset all texts to their default values?", "lang_replaceWithOriginal": "load original text into text box", "lang_replyTo": "Reply-To address", -- cgit v1.2.3-55-g7522 From 62cd429deec4f8c3ba5a673a6fbf0b77e754520c Mon Sep 17 00:00:00 2001 From: Simon Rettberg Date: Mon, 3 Dec 2018 15:04:10 +0100 Subject: [dozmod] networkshares: Use {{password_type}} for password field --- modules-available/dozmod/templates/networkshares-edit.html | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'modules-available') diff --git a/modules-available/dozmod/templates/networkshares-edit.html b/modules-available/dozmod/templates/networkshares-edit.html index cc89dbcc..f0b43837 100644 --- a/modules-available/dozmod/templates/networkshares-edit.html +++ b/modules-available/dozmod/templates/networkshares-edit.html @@ -42,11 +42,11 @@
- +
- +
-- cgit v1.2.3-55-g7522 From f57731abf206bf3030a7a95a9019aa398c3dea2e Mon Sep 17 00:00:00 2001 From: Christian Hofmaier Date: Mon, 3 Dec 2018 19:03:24 +0100 Subject: [locationinfo] add new settings for panels (counter, updaterate) - setting: consider only clients in roomplaner, instead of ip range - add option to set update rate in summary panels - directly initialize when mode is "only calendar" - Set counter to "-" if room has ongoing event - fix some spelling / unused code --- modules-available/locationinfo/api.inc.php | 23 +++++-- .../locationinfo/inc/locationinfo.inc.php | 7 +- .../locationinfo/lang/de/template-tags.json | 2 + .../locationinfo/lang/en/template-tags.json | 2 + modules-available/locationinfo/page.inc.php | 18 +++++- .../locationinfo/templates/frontend-default.html | 25 ++++++-- .../locationinfo/templates/frontend-summary.html | 74 ++++++---------------- .../templates/page-config-panel-default.html | 16 +++++ .../templates/page-config-panel-summary.html | 44 +++++++++++++ 9 files changed, 139 insertions(+), 72 deletions(-) (limited to 'modules-available') diff --git a/modules-available/locationinfo/api.inc.php b/modules-available/locationinfo/api.inc.php index ad71de8b..c33c528e 100644 --- a/modules-available/locationinfo/api.inc.php +++ b/modules-available/locationinfo/api.inc.php @@ -7,7 +7,7 @@ HandleParameters(); /** - * Handles the API paramenters. + * Handles the API parameters. */ function HandleParameters() { @@ -20,7 +20,7 @@ function HandleParameters() } elseif ($get === "machines") { $locationIds = LocationInfo::getLocationsOr404($uuid); $output = array(); - InfoPanel::appendMachineData($output, $locationIds, false); + InfoPanel::appendMachineData($output, $locationIds, true); $output = array_values($output); } elseif ($get === "config") { $type = InfoPanel::getConfig($uuid, $output); @@ -30,7 +30,7 @@ function HandleParameters() } } elseif ($get === "pcstates") { $locationIds = LocationInfo::getLocationsOr404($uuid); - $output = getPcStates($locationIds); + $output = getPcStates($locationIds, $uuid); } elseif ($get === "locationtree") { $locationIds = LocationInfo::getLocationsOr404($uuid); $output = getLocationTree($locationIds); @@ -84,7 +84,7 @@ function getLastChangeTs($paneluuid) * @param int[] $idList list of the location ids. * @return array aggregated PC states */ -function getPcStates($idList) +function getPcStates($idList, $paneluuid) { $pcStates = array(); foreach ($idList as $id) { @@ -99,13 +99,24 @@ function getPcStates($idList) } $locationInfoList = array(); - InfoPanel::appendMachineData($locationInfoList, $idList); + InfoPanel::appendMachineData($locationInfoList, $idList, true); + + $panel = Database::queryFirst('SELECT paneluuid, panelconfig FROM locationinfo_panel WHERE paneluuid = :paneluuid', + compact('paneluuid')); + $config = json_decode($panel['panelconfig'], true); + foreach ($locationInfoList as $locationInfo) { $id = $locationInfo['id']; foreach ($locationInfo['machines'] as $pc) { $key = strtolower($pc['pcState']); if (isset($pcStates[$id][$key])) { - $pcStates[$id][$key]++; + if ($config['roomplaner']) { + if (isset($pc['x']) && isset($pc['y'])) { + $pcStates[$id][$key]++; + } + } else { + $pcStates[$id][$key]++; + } } } } diff --git a/modules-available/locationinfo/inc/locationinfo.inc.php b/modules-available/locationinfo/inc/locationinfo.inc.php index c51be666..88f96d29 100644 --- a/modules-available/locationinfo/inc/locationinfo.inc.php +++ b/modules-available/locationinfo/inc/locationinfo.inc.php @@ -80,6 +80,7 @@ class LocationInfo 'vertical' => false, 'eco' => false, 'prettytime' => true, + 'roomplaner' => true, 'scaledaysauto' => true, 'daystoshow' => 7, 'rotation' => 0, @@ -93,9 +94,9 @@ class LocationInfo if ($type === 'SUMMARY') { return array( 'language' => defined('LANG') ? LANG : 'en', - 'calupdate' => 30, - 'roomupdate' => 15, - 'configupdate' => 180, + 'roomplaner' => true, + 'eco' => false, + 'panelupdate' => 60, ); } return array(); diff --git a/modules-available/locationinfo/lang/de/template-tags.json b/modules-available/locationinfo/lang/de/template-tags.json index 7862297c..e93d83a9 100644 --- a/modules-available/locationinfo/lang/de/template-tags.json +++ b/modules-available/locationinfo/lang/de/template-tags.json @@ -78,6 +78,7 @@ "lang_room": "Raum", "lang_roomId": "Raum ID", "lang_roomIdTooltip": "Die Raum ID, die der Server ben\u00f6tigt, um Kalenderdaten abzurufen (bei Exchange die Postfachadresse)", + "lang_roomplanerTooltip": "Nur PCs berücksichtigen, die im Raumplaner gesetzt wurden", "lang_roomupdateTooltip": "Zeit nach der die PCs aktualisiert werden (in Sekunden)", "lang_rotation": "Rotation", "lang_rotation0": "0\u00b0", @@ -119,6 +120,7 @@ "lang_url": "URL", "lang_urlPanel": "URL-Panel", "lang_urlTooltip": "URL die aufgerufen wird", + "lang_useRoomplaner": "Raumplaner benutzen", "lang_vertical": "Vertikaler Modus", "lang_verticalTooltip": "Legt fest, ob Kalender und Raum \u00fcbereinander angezeigt werden sollen" } \ No newline at end of file diff --git a/modules-available/locationinfo/lang/en/template-tags.json b/modules-available/locationinfo/lang/en/template-tags.json index 2a191379..8a6e0724 100644 --- a/modules-available/locationinfo/lang/en/template-tags.json +++ b/modules-available/locationinfo/lang/en/template-tags.json @@ -78,6 +78,7 @@ "lang_room": "Room", "lang_roomId": "Room ID", "lang_roomIdTooltip": "The ID of the room the server needs, for querying the calendar data (when using exchange the room mailbox)", + "lang_roomplanerTooltip": "Only consider PCs which were set in the roomplaner", "lang_roomupdateTooltip": "Time the PCs in the room gets updated (in seconds)", "lang_rotation": "Rotation", "lang_rotation0": "0\u00b0", @@ -119,6 +120,7 @@ "lang_url": "URL", "lang_urlPanel": "URL panel", "lang_urlTooltip": "URL which is shown by the panel", + "lang_useRoomplaner": "Use roomplans", "lang_vertical": "Vertical mode", "lang_verticalTooltip": "Defines whether the room and calendar are shown above each other" } \ No newline at end of file diff --git a/modules-available/locationinfo/page.inc.php b/modules-available/locationinfo/page.inc.php index 3ff80927..26fa6c4e 100644 --- a/modules-available/locationinfo/page.inc.php +++ b/modules-available/locationinfo/page.inc.php @@ -359,6 +359,7 @@ class Page_LocationInfo extends Page 'vertical' => Request::post('vertical', false, 'bool'), 'eco' => Request::post('eco', false, 'bool'), 'prettytime' => Request::post('prettytime', false, 'bool'), + 'roomplaner' => Request::post('roomplaner', false, 'bool'), 'scaledaysauto' => Request::post('scaledaysauto', false, 'bool'), 'daystoshow' => Request::post('daystoshow', 7, 'int'), 'rotation' => Request::post('rotation', 0, 'int'), @@ -388,9 +389,19 @@ class Page_LocationInfo extends Page private function preparePanelConfigSummary() { + // Build json structure + $conf = array( + 'language' => Request::post('language', 'en', 'string'), + 'eco' => Request::post('eco', false, 'bool'), + 'roomplaner' => Request::post('roomplaner', false, 'bool'), + 'panelupdate' => Request::post('panelupdate', 30, 'int') + ); + if ($conf['panelupdate'] < 15) { + $conf['panelupdate'] = 15; + } // Check locations $locationids = self::getLocationIdsFromRequest(true); - return array('locationids' => $locationids); + return array('config' => $conf, 'locationids' => $locationids); } /** @@ -922,6 +933,7 @@ class Page_LocationInfo extends Page 'vertical_checked' => $config['vertical'] ? 'checked' : '', 'eco_checked' => $config['eco'] ? 'checked' : '', 'prettytime_checked' => $config['prettytime'] ? 'checked' : '', + 'roomplaner_checked' => $config['roomplaner'] ? 'checked' : '', 'scaledaysauto_checked' => $config['scaledaysauto'] ? 'checked' : '', 'daystoshow' => $config['daystoshow'], 'rotation' => $config['rotation'], @@ -947,9 +959,11 @@ class Page_LocationInfo extends Page 'uuid' => $id, 'panelname' => $panel['panelname'], 'languages' => $langs, - 'roomupdate' => $config['roomupdate'], + 'panelupdate' => $config['panelupdate'], + 'roomplaner_checked' => $config['roomplaner'] ? 'checked' : '', 'locations' => Location::getLocations(), 'locationids' => $panel['locationids'], + 'eco_checked' => $config['eco'] ? 'checked' : '', )); } } diff --git a/modules-available/locationinfo/templates/frontend-default.html b/modules-available/locationinfo/templates/frontend-default.html index d1ecaae8..7317f8e2 100755 --- a/modules-available/locationinfo/templates/frontend-default.html +++ b/modules-available/locationinfo/templates/frontend-default.html @@ -619,6 +619,11 @@ optional: generateProgressBar(); } + // Manually initialize mode 2, as initRoomLayout isn't called for this mode + if (room.config.mode === 2) { + queryCalendars(); + queryRooms(); + } mainUpdateLoop(); setInterval(mainUpdateLoop, 10000); setInterval(updateHeaders, globalConfig.eco ? 10000 : 1000); @@ -1116,12 +1121,11 @@ optional: * @param room Room */ function SetFreeSeats(room) { - room.$.seatsCounter.text(room.freePcs >= 0 ? room.freePcs : ''); + // if room has no allowed value, set text in the box to - + room.$.seatsCounter.text(room.freePcs >= 0 ? room.freePcs : '-'); room.$.seatsCounter.data('state', JSON.stringify(room.state)); if (room.freePcs > 0 && room.state && room.state.free) { - room.$.seatsBackground.css('background-color', '#250'); - } else if (room.freePcs === -1) { - room.$.seatsBackground.css('background-color', 'red'); + room.$.seatsBackground.css('background-color', '#250'); } else { room.$.seatsBackground.css('background-color', 'red'); } @@ -1148,7 +1152,8 @@ optional: if (!same) newText = t("closed"); } else if (tmp.state === "CalendarEvent") { if (!same) newText = tmp.title; - seats = -1; + // whilst event is running set freePcs to -, hopefully not breaking anything else with this + room.freePcs = "-"; } else if (tmp.state === "Free") { if (!same) newText = t("free"); } else if (tmp.state === "FreeNoEnd") { @@ -1496,8 +1501,14 @@ optional: for (var i = 0; i < update.length; i++) { var $div = $("#pc_" + room.id + "_" + update[i].id); // Pc free - if (update[i].pcState === "IDLE" || update[i].pcState === "OFFLINE" || update[i].pcState === "STANDBY") { - freePcs++; + if (room.config.roomplaner === true) { + if ((update[i].pcState === "IDLE" || update[i].pcState === "OFFLINE" || update[i].pcState === "STANDBY") && !isNaN(update[i].x) && !isNaN(update[i].y)) { + freePcs++; + } + } else { + if ((update[i].pcState === "IDLE" || update[i].pcState === "OFFLINE" || update[i].pcState === "STANDBY")) { + freePcs++; + } } $div.removeClass('BROKEN OFFLINE IDLE OCCUPIED STANDBY'.replace(update[i].pcState, '')).addClass(update[i].pcState); diff --git a/modules-available/locationinfo/templates/frontend-summary.html b/modules-available/locationinfo/templates/frontend-summary.html index 4105dd16..0053d1ff 100644 --- a/modules-available/locationinfo/templates/frontend-summary.html +++ b/modules-available/locationinfo/templates/frontend-summary.html @@ -116,6 +116,7 @@ var startdate; var roomidsString = ""; var config = {{{config}}}; + var lastPanelUpdate = 0; $(document).ready(function () { init(); @@ -139,6 +140,7 @@ SetUpDate(time); generateLayout(config.tree); update(); + setInterval(update, 10000); } function SetUpDate(d) { @@ -165,7 +167,7 @@ */ function generateObject(json, myParent, outermost) { var obj; - if (!json.children || json.children.length == 0) { + if (!json.children || json.children.length === 0) { obj = generateChild(myParent, json.locationid, json.locationname, outermost); } else { obj = generateParent(myParent, json.locationid, json.locationname, outermost); @@ -178,59 +180,24 @@ } /** - * Helper function to generate id string used in query functions - * @param list A string, wicht contains ids or not(for now) - * @param id An ID which should be added to the list + * Main Update loop, this loop runs every 10 seconds */ - function addIdToUpdateList(list, id) { - if (list == "") { - list += id; - } else { - list += ("," + id); - } - return list; - } - - - const ROOMUPDATE_MS = 2*60*1000; - const CALUPDATE_MS = 20*60*1000; - var timeout = null; - function update() { - var calendarUpdateIds = ""; - var rommUpdateIds = ""; - var count = 0; - var nextUpdate = 15000; - var property; - // TODO: Only query a few rooms is not possible with the new api stuff ... - for (property in rooms) { - if (rooms[property].lastCalendarUpdate === null || rooms[property].lastCalendarUpdate + CALUPDATE_MS < MyDate().getTime()) { - // TODO: NOT NECESSARY ANYMORE?! - calendarUpdateIds = addIdToUpdateList(calendarUpdateIds, rooms[property].id); - count++; - rooms[property].lastCalendarUpdate = MyDate().getTime(); - } - if (rooms[property].lastRoomUpdate === null || rooms[property].lastRoomUpdate + ROOMUPDATE_MS < MyDate().getTime()) { - // TODO: NOT NECESSARY ANYMORE?! - rommUpdateIds = addIdToUpdateList(rommUpdateIds, rooms[property].id); - count++; - rooms[property].lastRoomUpdate = MyDate().getTime(); - } - // TODO if (count > 7) break; - } - if (calendarUpdateIds !== "") { - queryCalendars(); - nextUpdate = 1000; - } - if (rommUpdateIds !== "") { + var date = MyDate(); + var now = date.getTime(); + if (lastPanelUpdate + (config.panelupdate * 1000) < now) { + // Set Roomupdate Interval has passed, update. queryRooms(); - nextUpdate = 1000; - } - if (nextUpdate !== 1000) { + queryCalendars(); + lastPanelUpdate = now; + for (var property in rooms) { + rooms[property].lastCalendarUpdate = now; + rooms[property].lastRoomUpdate = now; + } + } else { + // Set Roomupdate Interval has NOT passed, check if panel was changed since last call and reload if true. queryPanelChange(); } - clearTimeout(timeout); - setTimeout(update, nextUpdate); } function cleanDate(d) { @@ -283,7 +250,6 @@ cache: false, timeout: 30000, success: function (result) { - var l = result.length; if (result[0] == null) { console.log("Error: Backend reported null back for RoomUpdate, this might happend if the room isn't" + "configurated."); @@ -331,7 +297,7 @@ function updatePcStates(json) { var l = json.length; for (var i = 0; i < l; i++) { - updateRoomUsage(json[i].id, json[i].idle, json[i].occupied, json[i].offline, json[i].broken, json[i].standby) + updateRoomUsage(json[i].id, json[i].idle, json[i].occupied, json[i].offline, json[i].broken, json[i].standby); } } @@ -428,8 +394,8 @@ /** * computes state of a room, states are: - * closed, FreeNoEnd, Free, ClaendarEvent. - * @param Room Object + * closed, FreeNoEnd, Free, CalendarEvent. + * @param room Object */ function ComputeCurrentState(room) { if (room.lastRoomUpdate === null) { @@ -479,7 +445,7 @@ /** * checks if a room is open * @param room Room object - * @returns bool for open or not + * @returns boolean for open or not */ function IsOpenNow(room) { var now = new MyDate(); diff --git a/modules-available/locationinfo/templates/page-config-panel-default.html b/modules-available/locationinfo/templates/page-config-panel-default.html index f7009764..c2915298 100644 --- a/modules-available/locationinfo/templates/page-config-panel-default.html +++ b/modules-available/locationinfo/templates/page-config-panel-default.html @@ -107,6 +107,22 @@
+ +
+
+
+ +
+
+ +
+
+

+ +

+
+
+
diff --git a/modules-available/locationinfo/templates/page-config-panel-summary.html b/modules-available/locationinfo/templates/page-config-panel-summary.html index 11f0dc65..737eef1f 100644 --- a/modules-available/locationinfo/templates/page-config-panel-summary.html +++ b/modules-available/locationinfo/templates/page-config-panel-summary.html @@ -70,6 +70,22 @@ + +
+
+
+ +
+
+ +
+
+

+ +

+
+
+