diff options
Diffstat (limited to 'modules-available/locationinfo')
7 files changed, 69 insertions, 157 deletions
diff --git a/modules-available/locationinfo/inc/infopanel.inc.php b/modules-available/locationinfo/inc/infopanel.inc.php index 001f31ea..af32c1ed 100644 --- a/modules-available/locationinfo/inc/infopanel.inc.php +++ b/modules-available/locationinfo/inc/infopanel.inc.php @@ -169,7 +169,7 @@ class InfoPanel $allIds = self::getLocationsWithParents($idList); if (empty($allIds)) return; - $res = Database::simpleQuery("SELECT locationid, openingtime FROM locationinfo_locationconfig + $res = Database::simpleQuery("SELECT locationid, openingtime FROM location WHERE locationid IN (:lids)", array('lids' => $allIds)); $openingTimes = array(); while ($row = $res->fetch(PDO::FETCH_ASSOC)) { diff --git a/modules-available/locationinfo/install.inc.php b/modules-available/locationinfo/install.inc.php index 7e58315b..42bc8234 100644 --- a/modules-available/locationinfo/install.inc.php +++ b/modules-available/locationinfo/install.inc.php @@ -6,7 +6,6 @@ $t1 = $res[] = tableCreate('locationinfo_locationconfig', ' `locationid` INT(11) NOT NULL, `serverid` INT(10) UNSIGNED, `serverlocationid` VARCHAR(150), - `openingtime` BLOB, `calendar` BLOB, `lastcalendarupdate` INT(10) UNSIGNED NOT NULL DEFAULT 0, `lastuse` INT(10) UNSIGNED NOT NULL DEFAULT 0, @@ -53,7 +52,7 @@ if ($t1 === UPDATE_NOOP) { Database::exec('INSERT INTO locationinfo_panel (paneluuid, panelname, locationids, paneltype, panelconfig, lastchange)' . " SELECT UUID(), Concat('Import: ', l.locationname), o.locationid, 'DEFAULT', o.config, 0 " . " FROM locationinfo_locationconfig o INNER JOIN location l USING (locationid)" - . ' WHERE Length(o.config) > 10 OR Length(o.openingtime) > 10'); + . ' WHERE Length(o.config) > 10'); } Database::exec("ALTER TABLE locationinfo_locationconfig CHANGE `serverid` `serverid` INT(10) UNSIGNED NULL"); tableDropColumn('locationinfo_locationconfig', 'hidden'); diff --git a/modules-available/locationinfo/lang/de/template-tags.json b/modules-available/locationinfo/lang/de/template-tags.json index 2879184e..90a38885 100644 --- a/modules-available/locationinfo/lang/de/template-tags.json +++ b/modules-available/locationinfo/lang/de/template-tags.json @@ -55,7 +55,7 @@ "lang_locationSettings": "Raum-\/Ortsbezogene Einstellungen", "lang_locations": "Orte", "lang_locationsTable": "R\u00e4ume \/ Orte", - "lang_locationsTableHints": "Hier k\u00f6nnen Sie f\u00fcr die R\u00e4ume und Orte Ihrer Einrichtung \u00d6ffnungszeiten hinterlegen, sowie die Verkn\u00fcpfung mit Raum-IDs aus konfigurierten Backends (z.B. HISinOne) vornehmen, damit Belegungspl\u00e4ne abgerufen werden k\u00f6nnen.", + "lang_locationsTableHints": "Hier k\u00f6nnen Sie f\u00fcr die R\u00e4ume und Orte Ihrer Einrichtung die Verkn\u00fcpfung mit Raum-IDs aus konfigurierten Backends (z.B. HISinOne) vornehmen, damit Belegungspl\u00e4ne abgerufen werden k\u00f6nnen.", "lang_locsHint": "Hier k\u00f6nnen Sie die Orte ausw\u00e4hlen, die in diesem Panel angezeigt werden.", "lang_longFri": "Freitag", "lang_longMon": "Montag", diff --git a/modules-available/locationinfo/lang/en/template-tags.json b/modules-available/locationinfo/lang/en/template-tags.json index ba743dfb..64846ab6 100644 --- a/modules-available/locationinfo/lang/en/template-tags.json +++ b/modules-available/locationinfo/lang/en/template-tags.json @@ -55,7 +55,7 @@ "lang_locationSettings": "Location specific settings", "lang_locations": "Locations", "lang_locationsTable": "Rooms \/ Locations", - "lang_locationsTableHints": "Here you can define opening times for your locations and link the location ID to a configured backend (e.g. HISinOne) to show calendar events.", + "lang_locationsTableHints": "Here you can link the location ID to a configured backend (e.g. HISinOne) to show calendar events.", "lang_locsHint": "You can pick up the locations that will be shown in this panel.", "lang_longFri": "Friday", "lang_longMon": "Monday", diff --git a/modules-available/locationinfo/page.inc.php b/modules-available/locationinfo/page.inc.php index ee50bc9c..8032642d 100644 --- a/modules-available/locationinfo/page.inc.php +++ b/modules-available/locationinfo/page.inc.php @@ -167,101 +167,20 @@ class Page_LocationInfo extends Page $ignoreServer = 0; } - // Opening times - $openingtimes = Request::post('openingtimes', '', 'string'); - if ($openingtimes !== '') { - $openingtimes = json_decode($openingtimes, true); - if (!is_array($openingtimes)) { - $openingtimes = ''; - } else { - $mangled = array(); - foreach (array_keys($openingtimes) as $key) { - $entry = $openingtimes[$key]; - if (!isset($entry['days']) || !is_array($entry['days']) || empty($entry['days'])) { - Message::addError('ignored-line-no-days'); - continue; - } - $s = $this->getTime($entry['openingtime']); - $e = $this->getTime($entry['closingtime']); - if ($s === false) { - Message::addError('ignored-invalid-start', $entry['openingtime']); - continue; - } - if ($e === false) { - Message::addError('ignored-invalid-end', $entry['closingtime']); - continue; - } - if ($e <= $s) { - Message::addError('ignored-invalid-range', $entry['openingtime'], $entry['closingtime']); - continue; - } - unset($entry['tag']); - $mangled[] = $entry; - } - if (empty($mangled)) { - $openingtimes = null; - } else { - $openingtimes = json_encode($mangled); - } - } - } $NOW = time(); - // Check if openingtimes changed - $res = Database::queryFirst('SELECT openingtime FROM locationinfo_locationconfig WHERE locationid = :locationid', compact('locationid')); - $otChanged = $res === false || $res['openingtime'] !== $openingtimes; - Database::exec("INSERT INTO `locationinfo_locationconfig` (locationid, serverid, serverlocationid, openingtime, lastcalendarupdate, lastchange) - VALUES (:id, :insertserverid, :serverlocationid, :openingtimes, 0, :now) + Database::exec("INSERT INTO `locationinfo_locationconfig` (locationid, serverid, serverlocationid, lastcalendarupdate, lastchange) + VALUES (:id, :insertserverid, :serverlocationid, 0, :now) ON DUPLICATE KEY UPDATE serverid = IF(:ignore_server AND serverid IS NULL, NULL, :serverid), serverlocationid = VALUES(serverlocationid), - openingtime = VALUES(openingtime), lastcalendarupdate = 0, lastchange = VALUES(lastchange)", array( + lastcalendarupdate = 0, lastchange = VALUES(lastchange)", array( 'id' => $locationid, 'insertserverid' => $insertServerId, 'serverid' => $serverid, - 'openingtimes' => $openingtimes, 'serverlocationid' => $serverlocationid, 'ignore_server' => $ignoreServer, 'now' => $NOW, )); - if ($otChanged) { - $tree = Location::getLocationsAssoc(); - $todo = array(); - $done = array(); - foreach ($tree as $l) { - if ($l['parentlocationid'] == $locationid) { - $todo[] = $l['locationid']; - } - } - while (!empty($todo)) { - $loc = array_pop($todo); - if (in_array($loc, $done)) - continue; - $done[] = $loc; - // See if this one inherits - $res = Database::queryFirst('SELECT openingtime FROM locationinfo_locationconfig WHERE locationid = :loc', compact('loc')); - if ($res === false) { - $res = Database::exec('INSERT INTO locationinfo_locationconfig (locationid, lastchange) - VALUES (:locationid, :now) ON DUPLICATE KEY UPDATE lastchange = :now', - array('locationid' => $loc, 'now' => $NOW)); - } elseif (strlen($res['openingtime']) < 5) { - $res = Database::exec('UPDATE locationinfo_locationconfig SET lastchange = :now, openingtime = NULL - WHERE locationid = :locationid', - array('locationid' => $loc, 'now' => $NOW)); - } else { - $res = 0; - } - if ($res > 0) { - // Row was updated, which means the openingtime column was empty, which means the openingtime is inherited, descend further - $todo = array_merge($todo, $tree[$loc]['children']); - foreach ($tree as $l) { - if ($l['parentlocationid'] == $loc) { - $todo[] = $l['locationid']; - } - } - } - } - } - if ($changeServerRecursive) { // Recursive overwriting of serverid $children = Location::getRecursiveFlat($locationid); @@ -612,9 +531,10 @@ class Page_LocationInfo extends Page $locations = Location::getLocations(0, 0, false, true); // Get hidden state of all locations - $dbquery = Database::simpleQuery("SELECT li.locationid, li.serverid, li.serverlocationid, li.openingtime, li.lastcalendarupdate, cb.servertype, cb.servername + $dbquery = Database::simpleQuery("SELECT li.locationid, li.serverid, li.serverlocationid, loc.openingtime, li.lastcalendarupdate, cb.servertype, cb.servername FROM `locationinfo_locationconfig` AS li - LEFT JOIN `locationinfo_coursebackend` AS cb USING (serverid)"); + LEFT JOIN `locationinfo_coursebackend` AS cb USING (serverid) + LEFT JOIN `location` AS loc USING (locationid)"); while ($row = $dbquery->fetch(PDO::FETCH_ASSOC)) { $locid = (int)$row['locationid']; @@ -780,7 +700,10 @@ class Page_LocationInfo extends Page private function ajaxConfigLocation($id) { User::assertPermission('location.edit', $id); - $locConfig = Database::queryFirst("SELECT serverid, serverlocationid, openingtime FROM `locationinfo_locationconfig` WHERE locationid = :id", array('id' => $id)); + $locConfig = Database::queryFirst("SELECT info.serverid, info.serverlocationid, loc.openingtime + FROM `locationinfo_locationconfig` AS info + LEFT JOIN `location` AS loc USING (locationid) + WHERE locationid = :id", array('id' => $id)); if ($locConfig !== false) { $openingtimes = json_decode($locConfig['openingtime'], true); } else { diff --git a/modules-available/locationinfo/templates/ajax-config-location.html b/modules-available/locationinfo/templates/ajax-config-location.html index 47d4ba8a..f7e96b9d 100644 --- a/modules-available/locationinfo/templates/ajax-config-location.html +++ b/modules-available/locationinfo/templates/ajax-config-location.html @@ -4,11 +4,7 @@ {{^expertMode}} <div id="simple-mode"> - <div align="right"> - <a href="#" class="btn btn-default btn-sm" id="btn-show-expert">{{lang_expertMode}}</a> - </div> <div class="clearfix"></div> - <table class="table table-condensed" style="margin-bottom:0"> <tr> <th>{{lang_day}}</th> @@ -19,57 +15,57 @@ <tr class="tablerow"> <td>{{lang_monTilFr}}</td> <td> - <div class="input-group bootstrap-timepicker"> + <div class="input-group"> <span class="input-group-addon"> <span class="glyphicon glyphicon-time"></span> </span> - <input type="text" class="form-control timepicker2" id="week-open" pattern="[0-9]{1,2}:[0-9]{2}"> + <input disabled type="text" class="form-control timepicker2" id="week-open"> </div> </td> <td> - <div class="input-group bootstrap-timepicker"> + <div class="input-group"> <span class="input-group-addon"> <span class="glyphicon glyphicon-time"></span> </span> - <input type="text" class="form-control timepicker2" id="week-close" pattern="[0-9]{1,2}:[0-9]{2}"> + <input disabled type="text" class="form-control timepicker2" id="week-close"> </div> </td> </tr> <tr class="tablerow"> <td>{{lang_saturday}}</td> <td> - <div class="input-group bootstrap-timepicker"> + <div class="input-group"> <span class="input-group-addon"> <span class="glyphicon glyphicon-time"></span> </span> - <input type="text" class="form-control timepicker2" id="saturday-open" pattern="[0-9]{1,2}:[0-9]{2}"> + <input disabled type="text" class="form-control timepicker2" id="saturday-open"> </div> </td> <td> - <div class="input-group bootstrap-timepicker"> + <div class="input-group"> <span class="input-group-addon"> <span class="glyphicon glyphicon-time"></span> </span> - <input type="text" class="form-control timepicker2" id="saturday-close" pattern="[0-9]{1,2}:[0-9]{2}"> + <input disabled type="text" class="form-control timepicker2" id="saturday-close"> </div> </td> </tr> <tr class="tablerow"> <td>{{lang_sunday}}</td> <td> - <div class="input-group bootstrap-timepicker"> + <div class="input-group"> <span class="input-group-addon"> <span class="glyphicon glyphicon-time"></span> </span> - <input type="text" class="form-control timepicker2" id="sunday-open" pattern="[0-9]{1,2}:[0-9]{2}"> + <input disabled type="text" class="form-control timepicker2" id="sunday-open"> </div> </td> <td> - <div class="input-group bootstrap-timepicker"> + <div class="input-group"> <span class="input-group-addon"> <span class="glyphicon glyphicon-time"></span> </span> - <input type="text" class="form-control timepicker2" id="sunday-close" pattern="[0-9]{1,2}:[0-9]{2}"> + <input disabled type="text" class="form-control timepicker2" id="sunday-close"> </div> </td> </tr> @@ -78,21 +74,15 @@ {{/expertMode}} <div id="expert-mode" style="{{^expertMode}}display:none{{/expertMode}}"> - <div class="pull-right"> - <a class="btn btn-success btn-sm" id="new-openingtime"> - <span class="glyphicon glyphicon-plus-sign"></span> - {{lang_openingTime}} - </a> - </div> <div class="clearfix"></div> <div id="expert-table"> <div class="row"> - <div class="col-xs-9">{{lang_day}}</div> - <div class="col-xs-3 text-right">{{lang_delete}}</div> <div class="col-sm-6">{{lang_openingTime}}</div> - <div class="col-sm-6">{{lang_closingTime}}</div> + <div class="col-sm-4">{{lang_closingTime}}</div> + <div class="col-sm-2 text-right">{{lang_delete}}</div> </div> </div> + <hr> </div> </div> @@ -105,7 +95,7 @@ <select id="backend-select" class="form-control" name="serverid"> <option value="0">{{lang_noServer}}</option> {{#serverlist}} - <option value="{{serverid}}" {{selected}}>{{servername}}</option> + <option value="{{serverid}}" {{selected}}>{{servername}}</option> {{/serverlist}} </select> </div> @@ -143,6 +133,33 @@ </div> </div> +<div class="hidden" id="expert-template"> + <div class="row expert-row"> + <hr> + <div class="col-xs-12 days-box"> + <div class="checkbox checkbox-inline" style="margin-top: 0px;"><input disabled type="checkbox" class="i-Monday"><label>{{lang_shortMonday}}</label></div> + <div class="checkbox checkbox-inline"><input disabled type="checkbox" class="i-Tuesday"><label>{{lang_shortTuesday}}</label></div> + <div class="checkbox checkbox-inline"><input disabled type="checkbox" class="i-Wednesday"><label>{{lang_shortWednesday}}</label></div> + <div class="checkbox checkbox-inline"><input disabled type="checkbox" class="i-Thursday"><label>{{lang_shortThursday}}</label></div> + <div class="checkbox checkbox-inline"><input disabled type="checkbox" class="i-Friday"><label>{{lang_shortFriday}}</label></div> + <div class="checkbox checkbox-inline"><input disabled type="checkbox" class="i-Saturday"><label>{{lang_shortSaturday}}</label></div> + <div class="checkbox checkbox-inline"><input disabled type="checkbox" class="i-Sunday"><label>{{lang_shortSunday}}</label></div> + </div> + <div class="col-sm-6"> + <div class="input-group"> + <span class="input-group-addon"><span class="glyphicon glyphicon-time"></span></span> + <input disabled type="text" class="form-control i-openingtime"> + </div> + </div> + <div class="col-sm-6"> + <div class="input-group"> + <span class="input-group-addon"><span class="glyphicon glyphicon-time"></span></span> + <input disabled type="text" class="form-control i-closingtime"> + </div> + </div> + </div> +</div> + <script type="application/javascript"><!-- (function() { @@ -154,18 +171,18 @@ } {{/expertMode}} {{^expertMode}} - for (var i = 0; i < scheduleData.length; ++i) { - if (scheduleData[i].days.length === 5) { - $('#week-open').val(scheduleData[i]['openingtime']); - $('#week-close').val(scheduleData[i]['closingtime']); - } else if (scheduleData[i].days.length === 1 && scheduleData[i].days[0] === 'Saturday') { - $('#saturday-open').val(scheduleData[i]['openingtime']); - $('#saturday-close').val(scheduleData[i]['closingtime']); - } else if (scheduleData[i].days.length === 1 && scheduleData[i].days[0] === 'Sunday') { - $('#sunday-open').val(scheduleData[i]['openingtime']); - $('#sunday-close').val(scheduleData[i]['closingtime']); - } + for (var i = 0; i < scheduleData.length; ++i) { + if (scheduleData[i].days.length === 5) { + $('#week-open').val(scheduleData[i]['openingtime']); + $('#week-close').val(scheduleData[i]['closingtime']); + } else if (scheduleData[i].days.length === 1 && scheduleData[i].days[0] === 'Saturday') { + $('#saturday-open').val(scheduleData[i]['openingtime']); + $('#saturday-close').val(scheduleData[i]['closingtime']); + } else if (scheduleData[i].days.length === 1 && scheduleData[i].days[0] === 'Sunday') { + $('#sunday-open').val(scheduleData[i]['openingtime']); + $('#sunday-close').val(scheduleData[i]['closingtime']); } + } {{/expertMode}} setTimepicker($('#settings-outer').find('.timepicker2')); @@ -175,7 +192,7 @@ $('#new-openingtime').click(function (e) { e.preventDefault(); setTimepicker(newOpeningTime({}).find('.timepicker2')); - }) + }); $('#btn-show-expert').click(function (e) { e.preventDefault(); diff --git a/modules-available/locationinfo/templates/page-locations.html b/modules-available/locationinfo/templates/page-locations.html index f90a0f35..9635268c 100644 --- a/modules-available/locationinfo/templates/page-locations.html +++ b/modules-available/locationinfo/templates/page-locations.html @@ -65,33 +65,6 @@ </div> </div> -<div class="hidden" id="expert-template"> - <div class="row expert-row" style="margin-top:1em;border-top:1px solid #ddd"> - <div class="col-xs-12 days-box"> - <div class="pull-right checkbox checkbox-inline"><input type="checkbox" class="i-delete"><label><span class="glyphicon glyphicon-trash"></span></label></div> - <div class="checkbox checkbox-inline"><input type="checkbox" class="i-Monday"><label>{{lang_shortMonday}}</label></div> - <div class="checkbox checkbox-inline"><input type="checkbox" class="i-Tuesday"><label>{{lang_shortTuesday}}</label></div> - <div class="checkbox checkbox-inline"><input type="checkbox" class="i-Wednesday"><label>{{lang_shortWednesday}}</label></div> - <div class="checkbox checkbox-inline"><input type="checkbox" class="i-Thursday"><label>{{lang_shortThursday}}</label></div> - <div class="checkbox checkbox-inline"><input type="checkbox" class="i-Friday"><label>{{lang_shortFriday}}</label></div> - <div class="checkbox checkbox-inline"><input type="checkbox" class="i-Saturday"><label>{{lang_shortSaturday}}</label></div> - <div class="checkbox checkbox-inline"><input type="checkbox" class="i-Sunday"><label>{{lang_shortSunday}}</label></div> - </div> - <div class="col-sm-6"> - <div class="input-group bootstrap-timepicker"> - <span class="input-group-addon"><span class="glyphicon glyphicon-time"></span></span> - <input type="text" class="form-control timepicker2 i-openingtime" pattern="[0-9]{1,2}:[0-9]{2}"> - </div> - </div> - <div class="col-sm-6"> - <div class="input-group bootstrap-timepicker"> - <span class="input-group-addon"><span class="glyphicon glyphicon-time"></span></span> - <input type="text" class="form-control timepicker2 i-closingtime" pattern="[0-9]{1,2}:[0-9]{2}"> - </div> - </div> - </div> -</div> - <script type="text/javascript"><!-- document.addEventListener("DOMContentLoaded", function () { |