From eb19fa6a076a8d211cd483afb01eeda6172d27e4 Mon Sep 17 00:00:00 2001 From: Jan-Hendrik Willms Date: Mon, 2 Oct 2023 09:26:54 +0000 Subject: fixes #3225 Closes #3225 Merge request studip/studip!2186 --- app/controllers/course/feedback.php | 10 +- app/controllers/course/room_requests.php | 6 +- app/controllers/resources/booking.php | 92 +++++++------ app/controllers/resources/export.php | 28 ++-- app/controllers/resources/print.php | 8 +- app/controllers/resources/resource.php | 9 +- app/controllers/resources/room_planning.php | 16 ++- app/controllers/resources/room_request.php | 2 +- app/controllers/resources/statistics.php | 7 +- app/controllers/room_management/planning.php | 16 ++- app/views/course/feedback/_add_edit_entry_form.php | 4 +- app/views/course/feedback/_entry.php | 2 +- app/views/course/feedback/_feedback_stream.php | 4 +- .../course/feedback/_new_edit_feedback_form.php | 18 +-- app/views/course/feedback/_results.php | 7 +- app/views/course/feedback/index.php | 6 +- app/views/resources/booking/_add_edit_form.php | 50 ++++--- app/views/resources/booking/edit.php | 4 +- app/views/resources/booking/index.php | 4 +- .../resources/print/individual_booking_plan.php | 6 +- app/views/resources/resource/booking_plan.php | 6 +- .../resources/room_planning/semester_plan.php | 6 +- app/views/resources/room_request/planning.php | 7 +- cli/Commands/SORM/DescribeModels.php | 142 +++++++++++++++----- lib/models/Abschluss.php | 21 +++ lib/models/AbschlussKategorie.php | 20 ++- lib/models/AbschlussZuord.php | 11 ++ lib/models/AdmissionApplication.class.php | 35 ++--- lib/models/AdmissionRuleCompatibility.php | 9 +- lib/models/ArchivedCourse.class.php | 42 +++--- lib/models/ArchivedCourseMember.class.php | 12 +- lib/models/Aufbaustudiengang.php | 13 +- lib/models/AuthUserMd5.class.php | 28 ++-- lib/models/AuxLockRule.php | 19 +-- lib/models/Banner.class.php | 29 ++-- lib/models/BannerRoles.class.php | 6 +- lib/models/BlubberComment.php | 13 +- lib/models/BlubberGlobalThread.php | 21 +++ lib/models/BlubberMention.php | 9 ++ lib/models/BlubberStatusgruppeThread.php | 22 +++ lib/models/BlubberThread.php | 20 ++- lib/models/CacheType.php | 11 +- lib/models/CalendarEvent.class.php | 33 +++-- lib/models/CalendarUser.class.php | 11 ++ lib/models/Clipboard.class.php | 46 +++---- lib/models/ClipboardItem.class.php | 27 ++-- lib/models/ColourValue.class.php | 30 ++--- lib/models/ConfigEntry.class.php | 18 +-- lib/models/ConfigValue.php | 17 ++- lib/models/ConsultationBlock.php | 31 +++-- lib/models/ConsultationBooking.php | 21 +-- lib/models/ConsultationEvent.php | 14 +- lib/models/ConsultationResponsibility.php | 11 +- lib/models/ConsultationSlot.php | 27 ++-- lib/models/Contact.class.php | 17 ++- lib/models/ContentTermsOfUse.class.php | 39 +++--- lib/models/Course.class.php | 123 +++++++++-------- lib/models/CourseCancelledEvent.class.php | 38 ++++++ lib/models/CourseDate.class.php | 43 +++--- lib/models/CourseEvent.class.php | 36 +++++ lib/models/CourseExDate.class.php | 41 +++--- lib/models/CourseMarkedEvent.class.php | 36 +++++ lib/models/CourseMember.class.php | 43 +++--- lib/models/CourseMemberNotification.php | 19 ++- lib/models/CourseTopic.class.php | 28 ++-- lib/models/CourseWizardStepRegistry.php | 10 +- lib/models/Courseware/Block.php | 42 +++--- lib/models/Courseware/BlockComment.php | 16 +-- lib/models/Courseware/BlockFeedback.php | 16 +-- lib/models/Courseware/Bookmark.php | 14 +- lib/models/Courseware/Certificate.php | 11 +- lib/models/Courseware/Container.php | 41 +++--- lib/models/Courseware/PublicLink.php | 15 ++- lib/models/Courseware/StructuralElement.php | 90 ++++++------- lib/models/Courseware/StructuralElementComment.php | 16 +-- .../Courseware/StructuralElementFeedback.php | 16 +-- lib/models/Courseware/Task.php | 20 +-- lib/models/Courseware/TaskFeedback.php | 18 +-- lib/models/Courseware/TaskGroup.php | 24 ++-- lib/models/Courseware/Template.php | 15 ++- lib/models/Courseware/Unit.php | 36 ++--- lib/models/Courseware/UserDataField.php | 20 +-- lib/models/Courseware/UserProgress.php | 16 +-- lib/models/CronjobLog.class.php | 18 +-- lib/models/CronjobSchedule.class.php | 44 +++--- lib/models/CronjobTask.class.php | 25 ++-- lib/models/DataField.class.php | 40 +++--- lib/models/DatafieldEntryModel.class.php | 19 +-- lib/models/DatafieldEntryModelI18N.class.php | 19 +-- lib/models/Degree.class.php | 17 ++- lib/models/Deputy.php | 28 ++-- lib/models/EventData.class.php | 32 +++++ lib/models/ExternalUser.php | 14 +- lib/models/Fach.php | 21 +++ lib/models/FachFachbereich.php | 13 +- lib/models/Fachbereich.php | 21 ++- lib/models/FeedbackElement.php | 37 +++-- lib/models/FeedbackEntry.php | 7 +- lib/models/File.php | 31 ++--- lib/models/FileRef.php | 37 ++--- lib/models/Folder.php | 33 +++-- lib/models/ForumCat.php | 6 + lib/models/Freetext.php | 15 +++ lib/models/Grading/Definition.php | 16 +++ lib/models/Grading/Instance.php | 13 ++ lib/models/HelpContent.class.php | 18 +-- lib/models/HelpTour.class.php | 15 ++- lib/models/HelpTourAudience.class.php | 12 +- lib/models/HelpTourSettings.class.php | 12 +- lib/models/HelpTourStep.class.php | 14 +- lib/models/HelpTourUser.class.php | 12 +- lib/models/Institute.class.php | 57 ++++---- lib/models/InstituteMember.class.php | 45 ++++--- lib/models/InstitutePlanColumn.class.php | 14 +- lib/models/Kategorie.class.php | 9 +- lib/models/License.php | 14 ++ lib/models/LikertScale.php | 15 +++ lib/models/LockRule.class.php | 20 +-- lib/models/LogAction.php | 25 ++-- lib/models/LogEvent.php | 23 ++-- lib/models/LoginBackground.class.php | 13 +- lib/models/LtiData.php | 16 ++- lib/models/LtiGrade.php | 9 ++ lib/models/LtiTool.php | 14 ++ lib/models/Lvgruppe.php | 16 +++ lib/models/LvgruppeModulteil.php | 13 ++ lib/models/LvgruppeSeminar.php | 10 ++ lib/models/MailQueueEntry.class.php | 21 +-- lib/models/Message.class.php | 25 ++-- lib/models/MessageUser.class.php | 21 ++- lib/models/Modul.php | 43 ++++++ lib/models/ModulDeskriptor.php | 28 ++++ lib/models/ModulInst.php | 12 ++ lib/models/ModulLanguage.php | 11 ++ lib/models/Modulteil.php | 32 +++++ lib/models/ModulteilDeskriptor.php | 21 +++ lib/models/ModulteilLanguage.php | 11 ++ lib/models/ModulteilStgteilabschnitt.php | 12 ++ lib/models/MvvContact.php | 12 ++ lib/models/MvvContactRange.php | 34 +++-- lib/models/MvvCourse.php | 37 +++++ lib/models/MvvExternContact.php | 13 ++ lib/models/MvvFile.php | 15 +++ lib/models/MvvFileFileref.php | 14 ++ lib/models/MvvFileRange.php | 11 ++ lib/models/MvvOverlappingConflict.class.php | 23 ++++ lib/models/MvvOverlappingExclude.php | 8 ++ lib/models/MvvOverlappingSelection.class.php | 17 +++ lib/models/NewsRange.class.php | 18 +-- lib/models/NewsRoles.class.php | 6 +- lib/models/OERDownloadcounter.php | 10 ++ lib/models/OERHost.php | 17 +++ lib/models/OERHostOERSI.php | 17 +++ lib/models/OERMaterial.php | 64 ++++----- lib/models/OERMaterialUser.php | 13 ++ lib/models/OERPostUpload.php | 13 +- lib/models/OERReview.php | 23 ++++ lib/models/OERTag.php | 7 + lib/models/ObjectUserVisit.php | 15 ++- lib/models/OpenGraphURL.class.php | 27 ++-- lib/models/PersonalNotifications.class.php | 16 ++- lib/models/PersonalNotificationsUser.php | 9 ++ lib/models/Plugin.php | 27 ++-- lib/models/PluginAsset.php | 10 ++ lib/models/Questionnaire.php | 34 ++--- lib/models/QuestionnaireAnonymousAnswer.php | 11 ++ lib/models/QuestionnaireAnswer.php | 15 ++- lib/models/QuestionnaireAssignment.php | 13 ++ lib/models/QuestionnaireInfo.php | 15 +++ lib/models/QuestionnaireQuestion.php | 17 ++- lib/models/RangeScale.php | 15 +++ lib/models/RangeTreeNode.php | 20 +-- lib/models/Semester.class.php | 33 +++-- lib/models/SemesterCourse.class.php | 16 +-- lib/models/SemesterHoliday.class.php | 17 ++- lib/models/SeminarCycleDate.class.php | 46 ++++--- lib/models/StatusgruppeUser.php | 24 ++-- lib/models/Statusgruppen.php | 47 ++++--- lib/models/StgteilAbschnitt.php | 18 +++ lib/models/StgteilBezeichnung.php | 12 ++ lib/models/StgteilVersion.php | 23 ++++ lib/models/StgteilabschnittModul.php | 15 +++ lib/models/StockImage.php | 25 ++-- lib/models/Studiengang.php | 44 ++++++ lib/models/StudiengangStgteil.php | 16 +++ lib/models/StudiengangTeil.php | 20 +++ lib/models/StudipCacheOperation.php | 7 + lib/models/StudipComment.class.php | 16 +-- lib/models/StudipEvaluation.php | 33 ++--- lib/models/StudipNews.class.php | 33 ++--- lib/models/StudipScmEntry.class.php | 22 +-- lib/models/StudipStudyArea.class.php | 24 ++-- lib/models/StudyCourse.class.php | 18 ++- lib/models/StudycourseLanguage.php | 12 ++ lib/models/StudycourseType.php | 9 ++ lib/models/TFASecret.php | 19 ++- lib/models/TFAToken.php | 5 + lib/models/Token.php | 12 +- lib/models/ToolActivation.php | 19 +-- lib/models/User.class.php | 107 ++++++++------- lib/models/UserDomain.php | 9 ++ lib/models/UserInfo.class.php | 46 +++---- lib/models/UserOnline.class.php | 6 +- lib/models/UserStudyCourse.class.php | 23 ++-- lib/models/Vote.php | 15 +++ lib/models/WebserviceAccessRule.class.php | 14 +- lib/models/WikiPage.class.php | 23 ++-- lib/models/WikiPageConfig.php | 10 ++ lib/models/eTask/Assignment.php | 33 ++--- lib/models/eTask/AssignmentRange.php | 17 ++- lib/models/eTask/Attempt.php | 21 +-- lib/models/eTask/ConfigureTrait.php | 14 +- lib/models/eTask/Response.php | 48 +++---- lib/models/eTask/Task.php | 37 ++--- lib/models/eTask/Test.php | 30 +++-- lib/models/eTask/TestTask.php | 22 +-- lib/models/resources/BrokenResource.class.php | 39 ++++-- lib/models/resources/Building.class.php | 43 ++++-- lib/models/resources/GlobalResourceLock.class.php | 17 ++- lib/models/resources/Location.class.php | 30 ++++- lib/models/resources/Resource.class.php | 57 ++++---- lib/models/resources/ResourceBooking.class.php | 96 +++++++------ .../resources/ResourceBookingInterval.class.php | 35 +++-- lib/models/resources/ResourceCategory.class.php | 12 +- .../resources/ResourceCategoryProperty.class.php | 21 +-- lib/models/resources/ResourceLabel.class.php | 41 ++++-- lib/models/resources/ResourcePermission.class.php | 33 +++-- lib/models/resources/ResourceProperty.class.php | 22 +-- .../resources/ResourcePropertyDefinition.class.php | 28 ++-- .../resources/ResourcePropertyGroup.class.php | 11 +- lib/models/resources/ResourceRequest.class.php | 149 +++++++++++---------- .../resources/ResourceRequestAppointment.class.php | 24 ++-- .../resources/ResourceRequestProperty.class.php | 20 +-- .../ResourceTemporaryPermission.class.php | 29 ++-- lib/models/resources/Room.class.php | 39 ++++-- lib/models/resources/RoomRequest.class.php | 46 ++++--- lib/models/resources/SeparableRoom.class.php | 14 +- lib/models/resources/SeparableRoomPart.class.php | 14 +- lib/raumzeit/SingleDate.class.php | 2 +- lib/resources/RoomManager.class.php | 14 +- 240 files changed, 3643 insertions(+), 1994 deletions(-) diff --git a/app/controllers/course/feedback.php b/app/controllers/course/feedback.php index cd970a0..dec2000 100644 --- a/app/controllers/course/feedback.php +++ b/app/controllers/course/feedback.php @@ -71,7 +71,7 @@ class Course_FeedbackController extends AuthenticatedController 'range_type' => $range_type, 'results_visible' => 1, 'commentable' => 1, - 'mode' => 1 + 'mode' => FeedbackElement::MODE_5STAR_RATING, ]); } @@ -83,12 +83,12 @@ class Course_FeedbackController extends AuthenticatedController if (!Feedback::hasRangeAccess($range_id, $range_type)) { throw new AccessDeniedException(); } elseif ($this->create_perm) { - if(Request::get('comment_only') === 1) { - $mode = 0; + if (Request::bool('comment_only')) { + $mode = FeedbackElement::MODE_NO_RATING; $commentable = 1; } else { - $mode = intval(Request::get('mode')); - $commentable = intval(Request::get('commentable')); + $mode = Request::int('mode', FeedbackElement::MODE_NO_RATING); + $commentable = Request::bool('commentable'); } $feedback = FeedbackElement::build([ 'range_id' => $range_id, diff --git a/app/controllers/course/room_requests.php b/app/controllers/course/room_requests.php index 464404f..1f06afe 100644 --- a/app/controllers/course/room_requests.php +++ b/app/controllers/course/room_requests.php @@ -583,7 +583,7 @@ class Course_RoomRequestsController extends AuthenticatedController } $this->preparation_time = intval($this->request->preparation_time / 60); - $this->reply_lecturers = $this->request->reply_recipients === 'lecturer'; + $this->reply_lecturers = $this->request->reply_recipients === ResourceRequest::REPLY_LECTURER; $this->comment = $this->request->comment; $_SESSION[$request_id]['search_by'] = $this->selected_room ? 'roomname' : 'category'; @@ -612,9 +612,9 @@ class Course_RoomRequestsController extends AuthenticatedController $this->request->comment = Request::get('comment'); if (Request::get('reply_lecturers')) { - $this->request->reply_recipients = 'lecturer'; + $this->request->reply_recipients = ResourceRequest::REPLY_LECTURER; } else { - $this->request->reply_recipients = 'requester'; + $this->request->reply_recipients = ResourceRequest::REPLY_REQUESTER; } $this->request->category_id = $_SESSION[$request_id]['room_category_id'] ?: $this->request->category_id; diff --git a/app/controllers/resources/booking.php b/app/controllers/resources/booking.php index 145a885..0e09d8c 100644 --- a/app/controllers/resources/booking.php +++ b/app/controllers/resources/booking.php @@ -209,7 +209,7 @@ class Resources_BookingController extends AuthenticatedController protected function sendLockBookingMail(ResourceBooking $booking) { - if ($booking->booking_type != '2') { + if ($booking->booking_type != ResourceBooking::TYPE_LOCK) { return false; } @@ -306,7 +306,7 @@ class Resources_BookingController extends AuthenticatedController $preparation_time = 0, $description = '', $comment = '', - $booking_type = '0', + $booking_type = ResourceBooking::TYPE_NORMAL, $assigned_user = null, $repetition_interval = null, $notification_enabled = false, @@ -328,7 +328,7 @@ class Resources_BookingController extends AuthenticatedController if ($included_room_parts) { //Check if there are identical bookings in the other room parts: foreach ($included_room_parts as $room_part) { - if (($booking_type == '2') && $overwrite_bookings) { + if ($booking_type == ResourceBooking::TYPE_LOCK && $overwrite_bookings) { //Create a new booking: $room_part->createBooking( $user, @@ -351,7 +351,7 @@ class Resources_BookingController extends AuthenticatedController $comment, $booking_type, ( - $booking_type == '2' + $booking_type == ResourceBooking::TYPE_LOCK ? $overwrite_bookings : false ) @@ -396,7 +396,7 @@ class Resources_BookingController extends AuthenticatedController $comment, $booking_type, ( - $booking_type == '2' + $booking_type == ResourceBooking::TYPE_LOCK ? $overwrite_bookings : false ) @@ -430,7 +430,7 @@ class Resources_BookingController extends AuthenticatedController try { //Enable overwriting of bookings if it is a lock booking: $a->store( - $booking_type == '2' + $booking_type == ResourceBooking::TYPE_LOCK ? $overwrite_bookings : false ); @@ -465,7 +465,7 @@ class Resources_BookingController extends AuthenticatedController $comment, $booking_type, ( - $booking_type == '2' + $booking_type == ResourceBooking::TYPE_LOCK ? $overwrite_bookings : false ) @@ -475,7 +475,11 @@ class Resources_BookingController extends AuthenticatedController $result['errors'] = [$e->getMessage()]; } - if ($booking && ($booking_type == '2') && $notification_enabled) { + if ( + $booking + && $booking_type == ResourceBooking::TYPE_LOCK + && $notification_enabled + ) { $this->sendLockBookingMail($booking); } @@ -509,7 +513,7 @@ class Resources_BookingController extends AuthenticatedController $comment, $booking_type, ( - $booking_type == '2' + $booking_type == ResourceBooking::TYPE_LOCK ? $overwrite_bookings : false ) @@ -536,7 +540,7 @@ class Resources_BookingController extends AuthenticatedController protected function displayAssignResultMessages( - $booking_type = 0, + $booking_type = ResourceBooking::TYPE_NORMAL, $booking_count = 0, $errors = [], $room_part_errors = [] @@ -545,12 +549,12 @@ class Resources_BookingController extends AuthenticatedController if ($booking_count > 0) { if ($errors) { //Bookings could not be saved. - if ($booking_type == '1') { + if ($booking_type == ResourceBooking::TYPE_RESERVATION) { PageLayout::postWarning( _('Es konnten nicht alle Reservierungen gespeichert werden!'), $errors ); - } elseif ($booking_type == '2') { + } elseif ($booking_type == ResourceBooking::TYPE_LOCK) { PageLayout::postWarning( _('Es konnten nicht alle Sperrbuchungen gespeichert werden!'), $errors @@ -563,13 +567,13 @@ class Resources_BookingController extends AuthenticatedController } } elseif ($room_part_errors) { //Room parts could not be assigned. - if ($booking_type == '1') { + if ($booking_type == ResourceBooking::TYPE_RESERVATION) { $text = ngettext( 'Die Reservierung wurde gespeichert, aber es traten Fehler beim Reservieren der anderen Raumteile auf:', 'Die Reservierungen wurden gespeichert, aber es traten Fehler beim Reservieren der anderen Raumteile auf:', $booking_count ); - } elseif ($booking_type == '2') { + } elseif ($booking_type == ResourceBooking::TYPE_LOCK) { $text = ngettext( 'Die Sperrbuchung wurde gespeichert, aber es traten Fehler beim Sperren der anderen Raumteile auf:', 'Die Sperrbuchungen wurden gespeichert, aber es traten Fehler beim Sperren der anderen Raumteile auf:', @@ -589,7 +593,7 @@ class Resources_BookingController extends AuthenticatedController ); } else { //Everything went fine: - if ($booking_type == '1') { + if ($booking_type == ResourceBooking::TYPE_RESERVATION) { PageLayout::postSuccess( ngettext( 'Die Reservierung wurde gespeichert.', @@ -597,7 +601,7 @@ class Resources_BookingController extends AuthenticatedController $booking_count ) ); - } elseif ($booking_type == '2') { + } elseif ($booking_type == ResourceBooking::TYPE_LOCK) { PageLayout::postSuccess( ngettext( 'Die Sperrbuchung wurde gespeichert.', @@ -652,21 +656,21 @@ class Resources_BookingController extends AuthenticatedController $only_one_room = count($this->resources) == 1; if ($only_one_room) { - if ($this->booking_type == 3) { + if ($this->booking_type == ResourceBooking::TYPE_PLANNED) { PageLayout::setTitle( sprintf( _('%s: Neue geplante Buchung'), $this->resources[0]->getFullName() ) ); - } elseif ($this->booking_type == 2) { + } elseif ($this->booking_type == ResourceBooking::TYPE_LOCK) { PageLayout::setTitle( sprintf( '%s: Neue Sperrbuchung', $this->resources[0]->getFullName() ) ); - } elseif ($this->booking_type == 1) { + } elseif ($this->booking_type == ResourceBooking::TYPE_RESERVATION) { PageLayout::setTitle( sprintf( '%s: Neue Reservierung', @@ -682,15 +686,15 @@ class Resources_BookingController extends AuthenticatedController ); } } else { - if ($this->booking_type == 3) { + if ($this->booking_type == ResourceBooking::TYPE_PLANNED) { PageLayout::setTitle( _('Neue geplante Buchung') ); - } elseif ($this->booking_type == 2) { + } elseif ($this->booking_type == ResourceBooking::TYPE_LOCK) { PageLayout::setTitle( _('Neue Sperrbuchung') ); - } elseif ($this->booking_type == 1) { + } elseif ($this->booking_type == ResourceBooking::TYPE_RESERVATION) { PageLayout::setTitle( _('Neue Reservierung') ); @@ -721,7 +725,7 @@ class Resources_BookingController extends AuthenticatedController if ($mode == 'edit') { if (count($this->resources) == 1) { - if ($this->booking_type == 3) { + if ($this->booking_type == ResourceBooking::TYPE_PLANNED) { PageLayout::setTitle( sprintf( _('%1$s: Geplante Buchung am %2$s bearbeiten'), @@ -729,7 +733,7 @@ class Resources_BookingController extends AuthenticatedController $booking_date ) ); - } elseif ($this->booking_type == 2) { + } elseif ($this->booking_type == ResourceBooking::TYPE_LOCK) { PageLayout::setTitle( sprintf( _('%1$s: Sperrbuchung am %2$s bearbeiten'), @@ -737,7 +741,7 @@ class Resources_BookingController extends AuthenticatedController $booking_date ) ); - } elseif ($this->booking_type == 1) { + } elseif ($this->booking_type == ResourceBooking::TYPE_RESERVATION) { PageLayout::setTitle( sprintf( _('%1$s: Reservierung am %2$s bearbeiten'), @@ -755,21 +759,21 @@ class Resources_BookingController extends AuthenticatedController ); } } else { - if ($this->booking_type == 3) { + if ($this->booking_type == ResourceBooking::TYPE_PLANNED) { PageLayout::setTitle( sprintf( _('Geplante Buchung am %s bearbeiten'), $booking_date ) ); - } elseif ($this->booking_type == 2) { + } elseif ($this->booking_type == ResourceBooking::TYPE_LOCK) { PageLayout::setTitle( sprintf( _('Sperrbuchung am %s bearbeiten'), $booking_date ) ); - } elseif ($this->booking_type == 1) { + } elseif ($this->booking_type == ResourceBooking::TYPE_RESERVATION) { PageLayout::setTitle( sprintf( _('Reservierung am %s bearbeiten'), @@ -802,7 +806,7 @@ class Resources_BookingController extends AuthenticatedController //Check permissions: if ($mode == 'add') { - if ($this->booking_type != 2) { + if ($this->booking_type != ResourceBooking::TYPE_LOCK) { foreach ($this->resources as $resource) { if (!$resource->userHasBookingRights($this->current_user)) { //The permissions are insufficient for at least one @@ -1145,7 +1149,11 @@ class Resources_BookingController extends AuthenticatedController //Validation: - if (($this->booking_type < 0) || ($this->booking_type > 2)) { + if (!in_aray($this->booking_type, [ + ResourceBooking::TYPE_NORMAL, + ResourceBooking::TYPE_RESERVATION, + ResourceBooking::TYPE_LOCK, + ])) { PageLayout::postError( _('Es wurde ein ungültiger Buchungstyp gewählt.') ); @@ -1909,9 +1917,9 @@ class Resources_BookingController extends AuthenticatedController return; } - if ($this->booking->booking_type == '0') { + if ($this->booking->booking_type == ResourceBooking::TYPE_NORMAL) { PageLayout::setTitle(_('Buchung in Reservierung umwandeln')); - } elseif ($this->booking->booking_type == '1') { + } elseif ($this->booking->booking_type == ResourceBooking::TYPE_RESERVATION) { PageLayout::setTitle(_('Reservierung in Buchung umwandeln')); } else { PageLayout::postError( @@ -1931,7 +1939,7 @@ class Resources_BookingController extends AuthenticatedController return; } - if ($this->booking->booking_type == '1') { + if ($this->booking->booking_type == ResourceBooking::TYPE_RESERVATION) { $fully_available = true; foreach ($intervals as $interval) { $begin = new DateTime(); @@ -1958,10 +1966,10 @@ class Resources_BookingController extends AuthenticatedController if (Request::submitted('transform')) { CSRFProtection::verifyUnsafeRequest(); - if ($this->booking->booking_type == '0') { - $this->booking->booking_type = '1'; - } elseif ($this->booking->booking_type == '1') { - $this->booking->booking_type = '0'; + if ($this->booking->booking_type == ResourceBooking::TYPE_NORMAL) { + $this->booking->booking_type = ResourceBooking::TYPE_RESERVATION; + } elseif ($this->booking->booking_type == ResourceBooking::TYPE_RESERVATION) { + $this->booking->booking_type = ResourceBooking::TYPE_NORMAL; } $saved = false; @@ -1971,11 +1979,11 @@ class Resources_BookingController extends AuthenticatedController $saved = true; } if ($saved) { - if ($this->booking->booking_type == '0') { + if ($this->booking->booking_type == ResourceBooking::TYPE_NORMAL) { PageLayout::postSuccess( _('Die Buchung wurde gespeichert.') ); - } elseif ($this->booking->booking_type == '1') { + } elseif ($this->booking->booking_type == ResourceBooking::TYPE_RESERVATION) { PageLayout::postSuccess( _('Die Reservierung wurde gespeichert.') ); @@ -1983,18 +1991,18 @@ class Resources_BookingController extends AuthenticatedController $this->response->add_header('X-Dialog-Close', '1'); $this->render_nothing(); } else { - if ($this->booking->booking_type == '0') { + if ($this->booking->booking_type == ResourceBooking::TYPE_NORMAL) { PageLayout::postError( _('Die Buchung konnte nicht gespeichert werden.') ); - } elseif ($this->booking->booking_type == '1') { + } elseif ($this->booking->booking_type == ResourceBooking::TYPE_RESERVATION) { PageLayout::postError( _('Die Reservierung konnte nicht gespeichert werden.') ); } } } else { - if ($this->booking->booking_type == '0') { + if ($this->booking->booking_type == ResourceBooking::TYPE_NORMAL) { PageLayout::postWarning( _('Soll die folgende Buchung wirklich in eine Reservierung umgewandelt werden?') ); diff --git a/app/controllers/resources/export.php b/app/controllers/resources/export.php index a891af2..488cff5 100644 --- a/app/controllers/resources/export.php +++ b/app/controllers/resources/export.php @@ -128,10 +128,10 @@ class Resources_ExportController extends AuthenticatedController // All available booking types. $this->booking_types = [ - 0 => _('Buchung'), - 1 => _('Reservierung'), - 2 => _('Sperrbuchung'), - 3 => _('geplante Buchung') + ResourceBooking::TYPE_NORMAL => _('Buchung'), + ResourceBooking::TYPE_RESERVATION => _('Reservierung'), + ResourceBooking::TYPE_LOCK => _('Sperrbuchung'), + ResourceBooking::TYPE_PLANNED => _('geplante Buchung') ]; $this->selected_booking_types = Request::intArray('bookingtypes') ?: Config::get()->RESOURCES_EXPORT_BOOKINGTYPES_DEFAULT; @@ -236,10 +236,10 @@ class Resources_ExportController extends AuthenticatedController // All available booking types. $this->booking_types = [ - 0 => _('Buchung'), - 1 => _('Reservierung'), - 2 => _('Sperrbuchung'), - 3 => _('geplante Buchung') + ResourceBooking::TYPE_NORMAL => _('Buchung'), + ResourceBooking::TYPE_RESERVATION => _('Reservierung'), + ResourceBooking::TYPE_LOCK => _('Sperrbuchung'), + ResourceBooking::TYPE_PLANNED => _('geplante Buchung') ]; $this->selected_booking_types = Config::get()->RESOURCES_EXPORT_BOOKINGTYPES_DEFAULT; } @@ -384,13 +384,13 @@ class Resources_ExportController extends AuthenticatedController ), $booking->resource->name, ( - $booking->booking_type == '0' + $booking->booking_type == ResourceBooking::TYPE_NORMAL ? _('Buchung') : ( - $booking->booking_type == '1' + $booking->booking_type == ResourceBooking::TYPE_RESERVATION ? _('Reservierung') : ( - $booking->booking_type == '2' + $booking->booking_type == ResourceBooking::TYPE_LOCK ? _('Sperrbuchung') : _('sonstiges') ) @@ -494,11 +494,11 @@ class Resources_ExportController extends AuthenticatedController } $booking_type_string = ''; - if ($interval->booking->booking_type == '0') { + if ($interval->booking->booking_type == ResourceBooking::TYPE_NORMAL) { $booking_type_string = _('Buchung'); - } elseif ($interval->booking->booking_type == '1') { + } elseif ($interval->booking->booking_type == ResourceBooking::TYPE_RESERVATION) { $booking_type_string = _('Reservierung'); - } elseif ($interval->booking->booking_type == '2') { + } elseif ($interval->booking->booking_type == ResourceBooking::TYPE_LOCK) { $booking_type_string = _('Sperrbuchung'); } diff --git a/app/controllers/resources/print.php b/app/controllers/resources/print.php index 3b4c1e5..8674fae 100644 --- a/app/controllers/resources/print.php +++ b/app/controllers/resources/print.php @@ -140,10 +140,10 @@ class Resources_PrintController extends AuthenticatedController // All available booking types. $this->booking_types = [ - 0 => _('Buchung'), - 1 => _('Reservierung'), - 2 => _('Sperrbuchung'), - 3 => _('geplante Buchung') + ResourceBooking::TYPE_NORMAL => _('Buchung'), + ResourceBooking::TYPE_RESERVATION => _('Reservierung'), + ResourceBooking::TYPE_LOCK => _('Sperrbuchung'), + ResourceBooking::TYPE_PLANNED => _('geplante Buchung'), ]; // Get additional text to print diff --git a/app/controllers/resources/resource.php b/app/controllers/resources/resource.php index d7bd0d2..6bec6e2 100644 --- a/app/controllers/resources/resource.php +++ b/app/controllers/resources/resource.php @@ -1203,21 +1203,24 @@ class Resources_ResourceController extends AuthenticatedController $this->show_form = false; $this->booking_type = Request::int('type'); - if (!in_array($this->booking_type, [1, 2])) { + if (!in_array($this->booking_type, [ + ResourceBooking::TYPE_RESERVATION, + ResourceBooking::TYPE_LOCK + ])) { PageLayout::postError( _('Es wurde kein passender Buchungstyp angegeben!') ); return; } - if ($this->booking_type == 1) { + if ($this->booking_type == ResourceBooking::TYPE_RESERVATION) { PageLayout::setTitle( sprintf( _('%s: Reservierung erstellen'), $this->resource->getFullName() ) ); - } elseif ($this->booking_type == 2) { + } elseif ($this->booking_type == ResourceBooking::TYPE_LOCK) { PageLayout::setTitle( sprintf( _('%s: Sperrbuchung erstellen'), diff --git a/app/controllers/resources/room_planning.php b/app/controllers/resources/room_planning.php index 220d7a8..3b550f0 100644 --- a/app/controllers/resources/room_planning.php +++ b/app/controllers/resources/room_planning.php @@ -148,7 +148,11 @@ class Resources_RoomPlanningController extends AuthenticatedController //The booking plan is also visible when the resource is a room //and its booking plan is publicly available. $this->anonymous_view = true; - $this->booking_types = [0, 1, 2]; + $this->booking_types = [ + ResourceBooking::TYPE_NORMAL, + ResourceBooking::TYPE_RESERVATION, + ResourceBooking::TYPE_LOCK, + ]; if ($this->user instanceof User) { if ($this->display_all_requests) { $plan_is_visible = $this->resource->userHasPermission( @@ -160,7 +164,7 @@ class Resources_RoomPlanningController extends AuthenticatedController } $this->anonymous_view = false; if ($this->resource->userHasPermission($this->user, 'admin')) { - $this->booking_types[] = 3; + $this->booking_types[] = ResourceBooking::TYPE_PLANNED; } } else { //If the plan visibility cannot be determined by the user, @@ -551,9 +555,13 @@ class Resources_RoomPlanningController extends AuthenticatedController $this->user_is_global_resource_admin = ResourceManager::userHasGlobalPermission($this->user, 'admin'); $this->show_global_admin_actions = $this->user_is_global_resource_admin; $this->user_has_booking_permissions = $this->resource->userHasBookingRights($this->user); - $this->booking_types = [0, 1, 2]; + $this->booking_types = [ + ResourceBooking::TYPE_NORMAL, + ResourceBooking::TYPE_RESERVATION, + ResourceBooking::TYPE_LOCK, + ]; if ($this->resource->userHasPermission($this->user, 'admin')) { - $this->booking_types[] = 3; + $this->booking_types[] = ResourceBooking::TYPE_PLANNED; } if ($this->user_has_booking_permissions) { URLHelper::addLinkParam('display_single_bookings', Request::get("display_single_bookings")); diff --git a/app/controllers/resources/room_request.php b/app/controllers/resources/room_request.php index db892e0..c6aed3a 100644 --- a/app/controllers/resources/room_request.php +++ b/app/controllers/resources/room_request.php @@ -1458,7 +1458,7 @@ class Resources_RoomRequestController extends AuthenticatedController } $this->notification_settings = 'creator'; - if ($this->request->reply_recipients == 'lecturer') { + if ($this->request->reply_recipients === ResourceRequest::REPLY_LECTURER) { $this->notification_settings = 'creator_and_lecturers'; } $this->reply_comment = $this->request->reply_comment; diff --git a/app/controllers/resources/statistics.php b/app/controllers/resources/statistics.php index 6ae55e1..6738833 100644 --- a/app/controllers/resources/statistics.php +++ b/app/controllers/resources/statistics.php @@ -60,7 +60,10 @@ class Resources_StatisticsController extends AuthenticatedController $sum_stmt->execute( [ - 'types' => [0, 1], + 'types' => [ + ResourceBooking::TYPE_NORMAL, + ResourceBooking::TYPE_RESERVATION, + ], 'begin' => $year_begin->getTimestamp(), 'end' => $year_end->getTimestamp() ] @@ -69,7 +72,7 @@ class Resources_StatisticsController extends AuthenticatedController $sum_stmt->execute( [ - 'types' => [2], + 'types' => [ResourceBooking::TYPE_LOCK], 'begin' => $year_begin->getTimestamp(), 'end' => $year_end->getTimestamp() ] diff --git a/app/controllers/room_management/planning.php b/app/controllers/room_management/planning.php index 81627e2..9bfd00f 100644 --- a/app/controllers/room_management/planning.php +++ b/app/controllers/room_management/planning.php @@ -149,7 +149,11 @@ class RoomManagement_PlanningController extends AuthenticatedController $request_rights_c = 0; $booking_rights_c = 0; $admin_rights_c = 0; - $this->booking_types = [0, 1, 2]; + $this->booking_types = [ + ResourceBooking::TYPE_NORMAL, + ResourceBooking::TYPE_RESERVATION, + ResourceBooking::TYPE_LOCK, + ]; foreach ($rooms as $room) { if ($room->userHasRequestRights($current_user)) { @@ -183,7 +187,7 @@ class RoomManagement_PlanningController extends AuthenticatedController $all_rooms_admin = ($room_c == $admin_rights_c); if ($all_rooms_admin) { //Display planned bookings, too: - $this->booking_types[] = 3; + $this->booking_types[] = ResourceBooking::TYPE_PLANNED; } if (!$this->all_rooms_booking_rights && $this->display_all_requests) { throw new AccessDeniedException( @@ -447,7 +451,11 @@ class RoomManagement_PlanningController extends AuthenticatedController $requestable_rooms_c = 0; $booking_rights_c = 0; $admin_rights_c = 0; - $this->booking_types = [0, 1, 2]; + $this->booking_types = [ + ResourceBooking::TYPE_NORMAL, + ResourceBooking::TYPE_RESERVATION, + ResourceBooking::TYPE_LOCK, + ]; foreach ($rooms as $room) { if ($room->userHasBookingRights($current_user)) { @@ -471,7 +479,7 @@ class RoomManagement_PlanningController extends AuthenticatedController $all_rooms_admin = ($room_c == $admin_rights_c); if ($all_rooms_admin) { //Display planned bookings, too: - $this->booking_types[] = 3; + $this->booking_types[] = ResourceBooking::TYPE_PLANNED; } if (!$all_rooms_booking_rights && $this->display_all_requests) { diff --git a/app/views/course/feedback/_add_edit_entry_form.php b/app/views/course/feedback/_add_edit_entry_form.php index e7442e2..b117b78 100644 --- a/app/views/course/feedback/_add_edit_entry_form.php +++ b/app/views/course/feedback/_add_edit_entry_form.php @@ -4,10 +4,10 @@ * @var FeedbackEntry|null $entry */ ?> -mode != 0) : ?> +mode != FeedbackElement::MODE_NO_RATING) : ?> mode == 2) { + if ($feedback->mode == FeedbackElement::MODE_10STAR_RATING) { $n = 10; } ?> diff --git a/app/views/course/feedback/_entry.php b/app/views/course/feedback/_entry.php index 586743d..29f35fb 100644 --- a/app/views/course/feedback/_entry.php +++ b/app/views/course/feedback/_entry.php @@ -25,7 +25,7 @@ - feedback->mode != 0) : ?> + feedback->mode != FeedbackElement::MODE_NO_RATING) : ?>
feedback->getMaxRating(); $i++) : ?> diff --git a/app/views/course/feedback/_feedback_stream.php b/app/views/course/feedback/_feedback_stream.php index 888b463..af1ffad 100644 --- a/app/views/course/feedback/_feedback_stream.php +++ b/app/views/course/feedback/_feedback_stream.php @@ -2,7 +2,7 @@

- mode != 0 && ((!$feedback->isFeedbackable() && $feedback->results_visible == 1) || $admin_perm) && count($feedback->entries) > 0) : ?> + mode != FeedbackElement::MODE_NO_RATING && ((!$feedback->isFeedbackable() && $feedback->results_visible == 1) || $admin_perm) && count($feedback->entries) > 0) : ?> getMeanOfRating() ?> @@ -33,4 +33,4 @@ - \ No newline at end of file + diff --git a/app/views/course/feedback/_new_edit_feedback_form.php b/app/views/course/feedback/_new_edit_feedback_form.php index e39fed4..b5268c0 100644 --- a/app/views/course/feedback/_new_edit_feedback_form.php +++ b/app/views/course/feedback/_new_edit_feedback_form.php @@ -24,7 +24,7 @@ @@ -34,13 +34,15 @@ - \ No newline at end of file + diff --git a/app/views/course/feedback/_results.php b/app/views/course/feedback/_results.php index 21e5cb1..6720632 100644 --- a/app/views/course/feedback/_results.php +++ b/app/views/course/feedback/_results.php @@ -4,13 +4,12 @@ - mode == 0) { + mode == FeedbackElement::MODE_NO_RATING) { printf(_('Insgesamt wurde %s mal Feedback gegeben.'), $entries_count); } ?> - = 1 && $feedback->mode != 0) : ?> + = 1 && $feedback->mode != FeedbackElement::MODE_NO_RATING) : ?> mode == 2) {$rating_scale = 10;} + $rating_scale = $feedback->mode == FeedbackElement::MODE_5STAR_RATING ? 5 : 10; ?>
diff --git a/app/views/course/feedback/index.php b/app/views/course/feedback/index.php index 4480534..602d445 100644 --- a/app/views/course/feedback/index.php +++ b/app/views/course/feedback/index.php @@ -72,7 +72,7 @@