diff --git a/RELEASE-NOTES.md b/RELEASE-NOTES.md index 9ac30a3ac3f77341c6b2874ffd995a3e0a802165..d30f9295f045298fa345aba0e9b690487a1593f4 100644 --- a/RELEASE-NOTES.md +++ b/RELEASE-NOTES.md @@ -41,6 +41,20 @@ Sollte ein Plugin manuell Flexi einbinden, so wird dies zu einem Fehler führen. Jegliches Einbinden von Dateien unterhalb von `vendor/flexi` muss ersatzlos entfernt werden. +- Die folgenden Funktionen wurden entfernt ([Issue #4179](https://gitlab.studip.de/studip/studip/-/issues/4179)) + - `getWeekdays($short = true)` + - `veranstaltung_beginn($seminar_id = '', $return_mode = '')` + - `veranstaltung_beginn_from_metadata($reg_irreg, $sem_begin, $start_woche, $start_termin,$turnus_data, $return_mode='int')` + - `get_sem_name ($time)` + - `get_sem_num ($time)` + - `get_sem_num_sem_browse ()` + - `get_semester($seminar_id)` + - `delete_date($termin_id, $topic_delete = TRUE, $folder_move = TRUE, $sem_id=0)` + - `delete_range_of_dates($range_id, $topics = FALSE)` + - `isSchedule ($sem_id, $presence_dates_only = TRUE, $clearcache = FALSE)` + - `isMetadateCorrespondingDate ($termin_id, $begin = '', $end = '', $seminar_id='')` + - `getPresenceTypes()` + ## Security related issues diff --git a/lib/dates.inc.php b/lib/dates.inc.php index 851ee92975466a9f595c802dd8af053ca376b82f..497a5d167a4ee4265de91c97c61467e171d67b64 100644 --- a/lib/dates.inc.php +++ b/lib/dates.inc.php @@ -1,86 +1,48 @@ <?php -# Lifter002: TODO -# Lifter003: TEST -# Lifter007: TODO -# Lifter010: DONE - no forms - -/* -dates.inc.php - basale Routinen zur Terminveraltung. -Copyright (C) 2001 Stefan Suchi <suchi@gmx.de>, André Noack <anoack@mcis.de> - -This program is free software; you can redistribute it and/or -modify it under the terms of the GNU General Public License -as published by the Free Software Foundation; either version 2 -of the License, or (at your option) any later version. - -This program is distributed in the hope that it will be useful, -but WITHOUT ANY WARRANTY; without even the implied warranty of -MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -GNU General Public License for more details. - -You should have received a copy of the GNU General Public License -along with this program; if not, write to the Free Software -Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. -*/ +/** + * dates.inc.php - basale Routinen zur Terminveraltung. + * Copyright (C) 2001 Stefan Suchi <suchi@gmx.de>, André Noack <anoack@mcis.de> + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. + **/ require_once 'lib/calendar_functions.inc.php'; -require_once 'lib/raumzeit/raumzeit_functions.inc.php'; // Helper-Funktionen +require_once 'lib/raumzeit/raumzeit_functions.inc.php'; -/* +/** * getWeekday liefert einen String mit einem Tagesnamen. * - * day_num integer PHP-konformer Tag (0-6) - * short boolean Wenn gesetzt wird der Tag verkürzt zurückgegeben. + * @param int $day_num integer PHP-konformer Tag (0-6) + * @param bool $short boolean Wenn gesetzt wird der Tag verkürzt zurückgegeben. + * + * @throws Exception */ -function getWeekday($day_num, $short = true): string +function getWeekday(int $day_num, bool $short = true): string { if ($day_num < 0 || $day_num > 6) { throw new Exception('Invalid day number'); } - switch ($day_num) { - case 0: - $day = $short ? _("So") : _("Sonntag"); - break; - case 1: - $day = $short ? _("Mo") : _("Montag"); - break; - case 2: - $day = $short ? _("Di") : _("Dienstag"); - break; - case 3: - $day = $short ? _("Mi") : _("Mittwoch"); - break; - case 4: - $day = $short ? _("Do") : _("Donnerstag"); - break; - case 5: - $day = $short ? _("Fr") : _("Freitag"); - break; - case 6: - $day = $short ? _("Sa") : _("Samstag"); - break; - } - return $day; -} - - -/** - * Returns an array with strings of all weekdays, starting on monday. - * - * @param bool $short If this parameter is set to true, a short - * version of the day is returned. Defaults to true. - */ -function getWeekdays($short = true) -{ - return [ - getWeekday(1, $short), //Monday - getWeekday(2, $short), //Tuesday - getWeekday(3, $short), //Wednesday - getWeekday(4, $short), //Thursday - getWeekday(5, $short), //Friday - getWeekday(6, $short), //Saturday - getWeekday(0, $short) //Sunday - ]; + return match($day_num) { + 0 => $short ? _('So') : _('Sonntag'), + 1 => $short ? _('Mo') : _('Montag'), + 2 => $short ? _('Di') : _('Dienstag'), + 3 => $short ? _('Mi') : _('Mittwoch'), + 4 => $short ? _('Do') : _('Donnerstag'), + 5 => $short ? _('Fr') : _('Freitag'), + 6 => $short ? _('Sa') : _('Samstag'), + }; } @@ -88,28 +50,29 @@ function getWeekdays($short = true) * getMonthName returns the localized name of a certain month in * either the abbreviated form (default) or as the actual name. * - * @param int $month Month number + * @param string $month Month number * @param bool $short Display the abbreviated version or the actual * name of the month (defaults to abbreviated) - * @return String Month name + * @return string Month name * @throws Exception when passed an invalid month number */ -function getMonthName($month, $short = true) { +function getMonthName(string $month, bool $short = true): string +{ $month = (int)$month; $months = [ - 1 => [_('Januar'), _('Jan.')], - 2 => [_('Februar'), _('Feb.')], - 3 => [_('März'), _('März')], - 4 => [_('April'), _('Apr.')], - 5 => [_('Mai'), _('Mai')], - 6 => [_('Juni'), _('Juni')], - 7 => [_('Juli'), _('Juli')], - 8 => [_('August'), _('Aug.')], - 9 => [_('September'), _('Sep.')], - 10 => [_('Oktober'), _('Okt.')], - 11 => [_('November'), _('Nov.')], - 12 => [_('Dezember'), _('Dez.')], + 1 => [_('Januar'), _('Jan.')], + 2 => [_('Februar'), _('Feb.')], + 3 => [_('März'), _('März')], + 4 => [_('April'), _('Apr.')], + 5 => [_('Mai'), _('Mai')], + 6 => [_('Juni'), _('Juni')], + 7 => [_('Juli'), _('Juli')], + 8 => [_('August'), _('Aug.')], + 9 => [_('September'), _('Sep.')], + 10 => [_('Oktober'), _('Okt.')], + 11 => [_('November'), _('Nov.')], + 12 => [_('Dezember'), _('Dez.')], ]; if (!isset($months[$month])) { throw new Exception("Invalid month '{$month}'"); @@ -117,81 +80,41 @@ function getMonthName($month, $short = true) { return $months[$month][(int)$short]; } -function leadingZero($num) { +function leadingZero(string $num): string +{ if ($num == '') return '00'; if (mb_strlen($num) < 2) { - return '0'.$num; + return '0' . $num; } else { return $num; } } -/* veranstaltung_beginn liefert den tatsächlichen ersten Termin einer Veranstaltung */ -function veranstaltung_beginn($seminar_id = '', $return_mode = '') { - if ($seminar_id == '') return 'dates.inc.php:veranstaltung_beginn - Fehlerhafter Aufruf!'; - $sem = new Seminar($seminar_id); - return $sem->getFirstDate($return_mode); -} -/* -Die Funktion veranstaltung_beginn_from_metadata errechnet den ersten Seminartermin aus dem Turnus Daten. -Zurueckgegeben wird ausschließlich ein Timestamp -Diese Funktion arbeitet im 'ad hoc' Modus und erwartet die einzelnen Variabeln des Metadaten-Arrays als Uebergabe. -Konkrete Termine werde dabei NICHT mit beruecksichtigt! -*/ -function veranstaltung_beginn_from_metadata($reg_irreg, $sem_begin, $start_woche, $start_termin,$turnus_data, $return_mode='int') { - $ret_time = 0; - if( $return_mode != 'int'){ - echo "<br>Fehler in dates.inc.php: veranstaltung_beginn_from_metadata() unterstuetzt nur den return mode 'int'."; - die(); - } - $semester = Semester::findByTimestamp($sem_begin); - $dow = date("w", $semester['vorles_beginn']); - if ($dow <= 5) - $corr = ($dow -1) * -1; - elseif ($dow == 6) - $corr = 2; - elseif ($dow == 0) - $corr = 1; - else - $corr = 0; - - if(is_array($turnus_data)){ - foreach ($turnus_data as $key => $val) { - $start_time = mktime ((int)$val['start_stunde'], (int)$val['start_minute'], 0, date("n", $semester['vorles_beginn']), (date("j", $semester['vorles_beginn'])+$corr) + ($val['day'] -1) + ($start_woche * 7), date("Y", $semester['vorles_beginn'])); - if (($start_time < $ret_time) || ($ret_time == 0)) { - $ret_time = $start_time; - } - } - } - - return $ret_time; -} - - -/* +/** * The function shrink_dates expects an array of dates where the start_time and the end_time is noted * and creates a compressed version (spanning f.e. multiple dates). * - * Returns an array, where each element is one condensed entry. (f.e. 10.6 - 14.6 8:00 - 12:00,) + * Returns an array, where each element is one condensed entry. (f.e. 10.6 - 14.6 8:00 - 12:00) */ -function shrink_dates($dates) { +function shrink_dates(array $dates): array +{ $ret = []; // First step: Clean out all duplicate dates (the dates are sorted) foreach ($dates as $key => $date) { if (isset($dates[$key + 1])) { - if ($dates[$key + 1]['start_time'] == $date['start_time'] - && $dates[$key + 1]['end_time'] == $date['end_time']) { + if ($dates[$key + 1]['start_time'] === $date['start_time'] + && $dates[$key + 1]['end_time'] === $date['end_time']) { unset($dates[$key]); } } } // Second step: Make sure the dates are still ordered by start- and end-time without any holes - usort($dates, function($a, $b) { - if ($a['start_time'] == $b['start_time']) { - if ($a['end_time'] == $b['end_time']) return 0; + usort($dates, function ($a, $b) { + if ($a['start_time'] === $b['start_time']) { + if ($a['end_time'] === $b['end_time']) return 0; return ($a['end_time'] > $b['end_time']) ? 1 : -1; } @@ -199,18 +122,18 @@ function shrink_dates($dates) { }); // Third step: Check which dates are follow-ups - for ($i=1; $i < sizeof($dates); $i++) { - if (((date("G", $dates[$i-1]["start_time"])) == date("G", $dates[$i]["start_time"])) - && ((date("i", $dates[$i-1]["start_time"])) == date("i", $dates[$i]["start_time"])) - && ((date("G", $dates[$i-1]["end_time"])) == date("G", $dates[$i]["end_time"])) - && ((date("i", $dates[$i-1]["end_time"])) == date("i", $dates[$i]["end_time"]))) { - $dates[$i]["time_match"] = true; + for ($i = 1; $i < sizeof($dates); $i++) { + if (((date('G', $dates[$i - 1]['start_time'])) === date('G', $dates[$i]['start_time'])) + && ((date('i', $dates[$i - 1]['start_time'])) === date('i', $dates[$i]['start_time'])) + && ((date('G', $dates[$i - 1]['end_time'])) === date('G', $dates[$i]['end_time'])) + && ((date('i', $dates[$i - 1]['end_time'])) === date('i', $dates[$i]['end_time']))) { + $dates[$i]['time_match'] = true; } - if (((date ("z", $dates[$i]["start_time"])-1) == date ("z", $dates[$i-1]["start_time"])) - || ((date ("z", $dates[$i]["start_time"]) == 0) && (date ("j", $dates[$i-1]["start_time"]) == 0))) { - if (!empty($dates[$i]["time_match"])) { - $dates[$i]["conjuncted"] = true; + if (((date('z', $dates[$i]['start_time']) - 1) === date('z', $dates[$i - 1]['start_time'])) + || ((date('z', $dates[$i]['start_time']) == 0) && (date('j', $dates[$i - 1]['start_time']) == 0))) { + if (!empty($dates[$i]['time_match'])) { + $dates[$i]['conjuncted'] = true; } } } @@ -218,37 +141,37 @@ function shrink_dates($dates) { // Fourth step: aggregate the dates with follow-ups $return_string = ''; // create text-output - for ($i=0; $i < sizeof($dates); $i++) { + for ($i = 0; $i < count($dates); $i++) { $conjuncted = true; - if (empty($dates[$i]["conjuncted"])) { + if (empty($dates[$i]['conjuncted'])) { $conjuncted = false; } - if (empty($dates[$i]["conjuncted"]) || empty($dates[$i+1]["conjuncted"])) { + if (empty($dates[$i]['conjuncted']) || empty($dates[$i + 1]['conjuncted'])) { $return_string .= strftime(' %A, %d.%m.%Y', $dates[$i]['start_time']); } - if (!$conjuncted && !empty($dates[$i+1]["conjuncted"])) { + if (!$conjuncted && !empty($dates[$i + 1]['conjuncted'])) { $return_string .= ' -'; - $conjuncted = true; - } else if (empty($dates[$i+1]["conjuncted"]) && !empty($dates[$i+1]["time_match"])) { + $conjuncted = true; + } else if (empty($dates[$i + 1]['conjuncted']) && !empty($dates[$i + 1]['time_match'])) { $return_string .= ','; } - if (empty($dates[$i+1]["time_match"])) { + if (empty($dates[$i + 1]['time_match'])) { // check if the current date is for a whole day - if ((($dates[$i]["end_time"] - $dates[$i]["start_time"]) / 60 / 60) > 23) { - $return_string .= ' ('. _('ganztägig') . ')'; + if ((($dates[$i]['end_time'] - $dates[$i]['start_time']) / 60 / 60) > 23) { + $return_string .= ' (' . _('ganztägig') . ')'; } else { - $return_string .= ' ' . date("H:i", $dates[$i]["start_time"]); - if (date("H:i", $dates[$i]["start_time"]) != date("H:i", $dates[$i]["end_time"])) { - $return_string .= ' - ' . date("H:i", $dates[$i]["end_time"]); + $return_string .= ' ' . date('H:i', $dates[$i]['start_time']); + if (date('H:i', $dates[$i]['start_time']) != date('H:i', $dates[$i]['end_time'])) { + $return_string .= ' - ' . date('H:i', $dates[$i]['end_time']); } } } - if ($return_string != '' && empty($dates[$i+1]['conjuncted']) && empty($dates[$i+1]['time_match'])) { - $ret[] = $return_string; + if ($return_string != '' && empty($dates[$i + 1]['conjuncted']) && empty($dates[$i + 1]['time_match'])) { + $ret[] = $return_string; $return_string = ''; } } @@ -256,39 +179,40 @@ function shrink_dates($dates) { return $ret; } -/* -Die Funktion Vorbesprechung ueberpueft, ob es eine Vorbesprechung gibt und gibt in diesem -Falle den entsprechenden Timestamp zurueck. Ansonsten wird FALSE zurueckgegeben. -*/ +/** + * The preliminary meeting function checks whether there is a preliminary meeting and in this case, + * returns the corresponding preliminary meeting location. Otherwise FALSE is returned. + * + * @param string $seminar_id + * @param string $type + * @return false|string|null + */ -function vorbesprechung ($seminar_id, $type = 'standard') +function vorbesprechung(string $seminar_id, string $type = 'standard'): false|string|null { - $query = "SELECT termin_id - FROM termine - WHERE range_id = ? AND date_typ = '2' - ORDER BY date"; - $statement = DBManager::get()->prepare($query); - $statement->execute([$seminar_id]); - $termin_id = $statement->fetchColumn(); + $termin_id = DBManager::get()->fetchColumn( + "SELECT termin_id FROM termine WHERE range_id = ? AND date_typ = '2' ORDER BY date", + [$seminar_id] + ); if (!$termin_id) { return false; } $termin = new SingleDate($termin_id); - $ret = $termin->toString(); + $ret = $termin->toString(); if ($termin->getResourceID()) { - $ret .= ', '._("Ort:").' '; + $ret .= ', ' . _("Ort:") . ' '; switch ($type) { case 'export': $room = Room::find($termin->getResourceID()); - $ret .= $room->name; + $ret .= $room->name; break; case 'standard': default: $resource = Resource::find($termin->getResourceID()); - $ret .= '<a href="' . $resource->getActionLink('show') . '" data-dialog="1">' + $ret .= '<a href="' . $resource->getActionLink('show') . '" data-dialog="1">' . htmlReady($resource->name) . '</a>'; break; } @@ -296,180 +220,25 @@ function vorbesprechung ($seminar_id, $type = 'standard') return $ret; } -/* -Die Funktion get_sem_name gibt den Namen eines Semester, in dem ein uebergebener Timestamp liegt, zurueck -*/ - -function get_sem_name ($time) { - $semester = Semester::findByTimestamp($time); - return $semester->name; -} - -/* -Die Funktion get_sem_num gibt die Nummer eines Semester, in dem ein uebergebener Timestamp liegt, zurueck -*/ - -function get_sem_num ($time) { - $all_semester = Semester::findAllVisible(false); - foreach ($all_semester as $key=>$val) - if (($time >= $val["beginn"]) AND ($time <= $val["ende"])) - return $key; - -} - -function get_sem_num_sem_browse () { - $all_semester = Semester::findAllVisible(false); - $time = time(); - $ret = false; - foreach ($all_semester as $key=>$val){ - if ($ret && ($val["vorles_ende"] >= $time)){ - $ret = $key; - break; - } - if ($time >= $val["vorles_ende"]){ - $ret = true; - } - } - return $ret; -} /** - * Die Funktion get_semester gibt den oder die Semester einer speziellen Veranstaltung aus. - * @deprecated + * a small helper funktion to get the type query for "Sitzungstermine" + * (this dates are important to get the regularly, presence dates + * for a seminar + * + * @return string the SQL-clause to select only the "Sitzungstermine" + * */ -function get_semester($seminar_id) -{ - $course = Course::find($seminar_id); - return $course->semester_text; -} - -/* -Die function delete_date löscht einen Termin und verschiebt daran haegende -Ordner in den allgemeinen Ordner. -Der erste Parameter ist die termin_id des zu löschenden Termins. -Der zweite Parameter topic_id gibt an, ob auch die zu diesem Termin gehoerenden -Postings im Forensystem geloescht werden sollen. -0 bzw. FALSE : keine Topics loeschen -> 0 : rekursives loeschen von topic_id -Der dritte Parameter gibt analog an, ob auch die zu diesem Terminen gehoerenden -Folder im Ordnersystem geloescht werden sollen. -Der Rückgabewert der Funktion ist die Anzahl der insgesamt gelöschten Items. --1 bedeutet einen Fehler beim Loeschen des Termins. -Ausgabe wird keine produziert. -Es erfolgt keine Überprüfung der Berechtigung innerhalb der Funktion, -dies muss das aufrufende Script sicherstellen. -*/ - -function delete_date($termin_id, $topic_delete = TRUE, $folder_move = TRUE, $sem_id=0) -{ - //Deleting folders was removed since folders can't be assigned to - //single dates, only to topics. - - ## Und den Termin selbst loeschen - $query = "DELETE FROM termine WHERE termin_id = ?"; - $statement = DBManager::get()->prepare($query); - $statement->execute([$termin_id]); - - if ($statement->rowCount() && Config::get()->RESOURCES_ENABLE) { - //The date has been successfully deleted: - //Now we must delete all resource bookings which are - //attached to it: - ResourceBooking::deleteBySql( - 'assign_user_id = :range_id', - [ - 'range_id' => $termin_id - ] - ); - } -} - -/* -Die function delete_range_of_dates löscht Termine mit allen daran haengenden Items. -Der erste Parameter ist die range_id der zu löschenden Termine. -Es koennen also mit einem Aufruf alle Termine eines Seminares, -eines Institutes oder persoenliche Termine eines Benutzers aus der Datenbank entfernt werden. -Dokumente und Literatur an diesen Terminen werden auf jeden Fall gelöscht. -Der zweite Parameter topics gibt an, ob auch die zu diesen Terminen gehoerenden -Postings im Forensystem geloescht werden sollen. -0 bzw. FALSE : keine Topics loeschen -1 bzw. TURE : rekursives Loeschen der Postings -Der Rückgabewert der Funktion ist die Anzahl der gelöschten Termine. -Ausgabe wird keine produziert. -Es erfolgt keine Überprüfung der Berechtigung innerhalb der Funktion, -dies muss das aufrufende Script sicherstellen. -*/ - -function delete_range_of_dates($range_id, $topics = FALSE) -{ - $count = 0; - - ## Termine finden... - $query = "SELECT termin_id FROM termine WHERE range_id = ?"; - $statement = DBManager::get()->prepare($query); - $statement->execute([$range_id]); - - while ($termin_id = $statement->fetchColumn()) { // ...und nacheinander... - delete_date($termin_id, $topics, true, $range_id); - $count++; - } - - return $count; -} - - -//Checkt, ob Ablaufplantermine zu gespeicherten Metadaten vorliegen -function isSchedule ($sem_id, $presence_dates_only = TRUE, $clearcache = FALSE) +function getPresenceTypeClause(): string { - $query = "SELECT COUNT(*) - FROM termine - WHERE range_id = ? AND metadate_id != '' AND metadate_id IS NOT NULL"; - if ($presence_dates_only) { - $query .= " AND date_typ IN " . getPresenceTypeClause(); - } - - $statement = DBManager::get()->prepare($query); - $statement->execute([$sem_id]); - - return $statement->fetchColumn(); -} - - -/** -* this functions checks, if a date corresponds with a metadate -* -* @param string termin_id -* @return boolean TRUE, if the date corresponds to a metadate -* -*/ -function isMetadateCorrespondingDate ($termin_id, $begin = '', $end = '', $seminar_id='') -{ - $termin = new SingleDate($termin_id); - if ($termin->getMetaDateID()) { - return $termin->getRangeId(); - } - - return false; -} - - -/** -* a small helper funktion to get the type query for "Sitzungstermine" -* (this dates are important to get the regularly, presence dates -* for a seminar -* -* @return string the SQL-clause to select only the "Sitzungstermine" -* -*/ -function getPresenceTypeClause() { - global $TERMIN_TYP; - - $i=0; + $i = 0; $typ_clause = "("; - foreach ($TERMIN_TYP as $key=>$val) { - if ($val["sitzung"]) { - if ($i) + foreach ($GLOBALS['TERMIN_TYP'] as $key => $val) { + if ($val['sitzung']) { + if ($i) { $typ_clause .= ", "; - $typ_clause .= "'".$key."' "; + } + $typ_clause .= "'" . $key . "' "; $i++; } } @@ -478,40 +247,26 @@ function getPresenceTypeClause() { return $typ_clause; } -function getPresenceTypes() { - global $TERMIN_TYP; - - foreach ($TERMIN_TYP as $key=>$val) { - if ($val["sitzung"]) { - $types[] = $key; - } - } - - return $types; -} - /** * Return an array of room snippets, possibly linked * - * @param array $rooms an associative array of rooms - * @param bool $html true if you want links, otherwise false + * @param array $rooms an associative array of rooms + * @param bool $html true if you want links, otherwise false * * @return array an array of (formatted) room snippets */ -function getFormattedRooms($rooms, $link = false) +function getFormattedRooms(array $rooms, bool $link = false): array { $room_list = []; - if (is_array($rooms)) { - foreach ($rooms as $room_id => $count) { - if ($room_id && Config::get()->RESOURCES_ENABLE) { - $room = Room::find($room_id); - if ($link) { - $room_list[] = '<a href="' . $room->getActionLink('show') . '" data-dialog="1">' - . htmlReady($room->name) . '</a>'; - } else { - $room_list[] = htmlReady($room->name); - } + foreach ($rooms as $room_id => $count) { + if ($room_id && Config::get()->RESOURCES_ENABLE) { + $room = Room::find($room_id); + if ($link) { + $room_list[] = '<a href="' . $room->getActionLink() . '" data-dialog="1">' + . htmlReady($room->name) . '</a>'; + } else { + $room_list[] = htmlReady($room->name); } } } @@ -522,19 +277,18 @@ function getFormattedRooms($rooms, $link = false) /** * Return an array of room snippets without any formatting * - * @param array $rooms an associative array of rooms + * @param array $rooms an associative array of rooms * * @return array an array of room snippets */ -function getPlainRooms($rooms) { +function getPlainRooms(array $rooms): array +{ $room_list = []; - if (is_array($rooms)) { - foreach ($rooms as $room_id => $count) { - if ($room_id) { - $room = Room::find($room_id); - $room_list[] = $room->name; - } + foreach ($rooms as $room_id => $count) { + if ($room_id) { + $room = Room::find($room_id); + $room_list[] = $room->name; } }