From b70bc19f88b21da74ff2c780df39b75cfdb8bd67 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Michaela=20Br=C3=BCckner?= <brueckner@data-quest.de> Date: Mon, 15 Aug 2022 13:45:42 +0200 Subject: [PATCH] first step: looking for room, re #1327 --- app/controllers/admin/courses.php | 1 + app/controllers/course/room_requests.php | 56 +++++++++++ .../_new_request_form_header.php | 0 .../room_requests/_new_request_header.php | 4 + .../course/room_requests/find_by_property.php | 1 + .../course/room_requests/find_by_roomname.php | 92 ++++++++++++++++++ .../course/room_requests/new_request.php | 93 +++++++++++++++++++ .../room_requests/request_first_step.php | 1 + app/views/course/timesrooms/_roomRequest.php | 2 +- lib/modules/CoreAdmin.class.php | 3 + 10 files changed, 252 insertions(+), 1 deletion(-) create mode 100644 app/views/course/room_requests/_new_request_form_header.php create mode 100644 app/views/course/room_requests/_new_request_header.php create mode 100644 app/views/course/room_requests/find_by_property.php create mode 100644 app/views/course/room_requests/find_by_roomname.php create mode 100644 app/views/course/room_requests/new_request.php create mode 100644 app/views/course/room_requests/request_first_step.php diff --git a/app/controllers/admin/courses.php b/app/controllers/admin/courses.php index 711494a4ed0..5a89dbaea87 100644 --- a/app/controllers/admin/courses.php +++ b/app/controllers/admin/courses.php @@ -1070,6 +1070,7 @@ class Admin_CoursesController extends AuthenticatedController 'attributes' => ['data-dialog' => 'size=big'], ]; } + ksort($actions); foreach (PluginManager::getInstance()->getPlugins('AdminCourseAction') as $plugin) { diff --git a/app/controllers/course/room_requests.php b/app/controllers/course/room_requests.php index 8747e9b4ab5..3b8d4c272ce 100644 --- a/app/controllers/course/room_requests.php +++ b/app/controllers/course/room_requests.php @@ -245,6 +245,62 @@ class Course_RoomRequestsController extends AuthenticatedController } + + public function new_request_action($request_id = '') + { + if (!Config::get()->RESOURCES_ALLOW_ROOM_REQUESTS) { + throw new AccessDeniedException( + _('Das Erstellen von Raumanfragen ist nicht erlaubt!') + ); + } + Helpbar::get()->addPlainText( + _('Information'), + _('Hier können Sie Angaben zu gewünschten Raumeigenschaften machen.') + ); + + $this->request_id = $request_id; + if (Request::submitted('request_id')) { + $this->request_id = Request::get('request_id'); + } + if (!$this->request_id) { + $this->request_id = md5(uniqid('RoomRequest')); + } + + $this->request = null; + $this->request = RoomRequest::find(Request::get('request_id')); + $this->available_room_categories = ResourceCategory::findByClass_name( + 'Room' + ); + + } + + public function request_first_step_action($request_id) + { + $this->request_id = $request_id; + + if (Request::isPost()) { + CSRFProtection::verifyUnsafeRequest(); + $this->room_name = Request::get('room_name'); + $this->category_id = Request::get('category_id'); + + if ($this->room_name != null) { + $_SESSION[$request_id]['room_name'] = $this->room_name; + $this->redirect( + 'course/room_requests/find_by_roomname/' . $this->request_id + ); + } + } + + } + + public function find_by_roomname_action($request_id) + { + $this->request_id = $request_id; + + } + + + /************ OLD STUFF *******/ /** * This action is the entry point for adding properties to a room request. */ diff --git a/app/views/course/room_requests/_new_request_form_header.php b/app/views/course/room_requests/_new_request_form_header.php new file mode 100644 index 00000000000..e69de29bb2d diff --git a/app/views/course/room_requests/_new_request_header.php b/app/views/course/room_requests/_new_request_header.php new file mode 100644 index 00000000000..757578635ab --- /dev/null +++ b/app/views/course/room_requests/_new_request_header.php @@ -0,0 +1,4 @@ +<?= MessageBox::info( + _('Geben Sie den gewünschten Raum und/oder Raumeigenschaften an. Ihre Raumanfrage wird von der zuständigen Raumvergabe bearbeitet.'), + [_('<strong>Achtung:</strong> Um später einen passenden Raum für Ihre Veranstaltung zu bekommen, geben Sie bitte immer die gewünschten Eigenschaften mit an!')] +)?> diff --git a/app/views/course/room_requests/find_by_property.php b/app/views/course/room_requests/find_by_property.php new file mode 100644 index 00000000000..b3d9bbc7f37 --- /dev/null +++ b/app/views/course/room_requests/find_by_property.php @@ -0,0 +1 @@ +<?php diff --git a/app/views/course/room_requests/find_by_roomname.php b/app/views/course/room_requests/find_by_roomname.php new file mode 100644 index 00000000000..a28cc3c539b --- /dev/null +++ b/app/views/course/room_requests/find_by_roomname.php @@ -0,0 +1,92 @@ +<form method="post" name="room_request" class="default" + action="<?= $this->controller->link_for('course/room_requests/request_first_step/' . $request_id) ?>" + <?= Request::isXhr() ? 'data-dialog="size=big"' : ''?>> + <input type="hidden" name="request_id" value="<?= htmlReady($request_id) ?>"> + <?= CSRFProtection::tokenTag() ?> + + + <?= $this->render_partial( + 'course/room_requests/_new_request_header') ?> + + <?= $request_id ?> + <?= var_dump($_SESSION[$request_id]) ?> + <section class="resources-grid"> + <div> + <fieldset> + <legend><?= _('Wünschbare Eigenschaften') ?></legend> + + <? if ($available_room_categories): ?> + <label> + <?= _('Raumkategorie') ?> + <span class="flex-row"> + <select name="category_id" <?= $category ? 'disabled' : '' ?>> + <option value=""><?= _('bitte auswählen') ?></option> + <? foreach ($available_room_categories as $rc): ?> + <option value="<?= htmlReady($rc->id) ?>" + <?= ($category_id == $rc->id) + ? 'selected="selected"' + : '' ?>> + <?= htmlReady($rc->name) ?> + </option> + <? endforeach ?> + </select> + <? if ($category) : ?> + <?= Icon::create('refresh', Icon::ROLE_CLICKABLE, ['title' => _('alle Angaben zurücksetzen')])->asInput( + [ + 'type' => 'image', + 'class' => 'text-bottom', + 'name' => 'reset_category', + 'style' => 'margin-left: 0.2em; margin-top: 0.6em;' + ] + ) ?> + <? else : ?> + <?= Icon::create('accept', Icon::ROLE_CLICKABLE, ['title' => _('Raumtyp auswählen')])->asInput( + [ + 'type' => 'image', + 'class' => 'text-bottom', + 'name' => 'select_properties', + 'value' => _('Raumtyp auswählen'), + 'style' => 'margin-left: 0.2em; margin-top: 0.6em;' + ] + ) ?> + <? endif ?> + </span> + </label> + <? endif ?> + <? if (!$embedded) : ?> + </fieldset> + </div> + + <div> + <fieldset> + <legend><?= _('Raumsuche') ?></legend> + <label> + <?= _('Raumname') ?> + <span class="flex-row"> + <input type="text" name="room_name" value="<?= htmlReady($room_name) ?>"> + <?= Icon::create('search', Icon::ROLE_CLICKABLE)->asInput( + [ + 'name' => 'search_by_name', + 'class' => 'text-bottom', + 'style' => 'margin-left: 0.2em; margin-top: 0.6em;' + ] + ) ?> + <? if ($room_name) : ?> + <?= Icon::create('refresh', Icon::ROLE_CLICKABLE, ['title' => _('alle Angaben zurücksetzen')])->asInput( + [ + 'type' => 'image', + 'class' => 'text-bottom', + 'name' => 'reset_category', + 'style' => 'margin-left: 0.2em; margin-top: 0.6em;' + ] + ) ?> + <? endif?> + </span> + </label> + + </fieldset> + + </div> + </section> +<?= $this->render_partial('course/room_requests/_request_form_footer') ?> +<? endif ?> diff --git a/app/views/course/room_requests/new_request.php b/app/views/course/room_requests/new_request.php new file mode 100644 index 00000000000..e1b554d730e --- /dev/null +++ b/app/views/course/room_requests/new_request.php @@ -0,0 +1,93 @@ +<form method="post" name="room_request" class="default" + action="<?= $this->controller->link_for('course/room_requests/request_first_step/' . $request_id) ?>" + <?= Request::isXhr() ? 'data-dialog="size=big"' : ''?>> + <input type="hidden" name="request_id" value="<?= htmlReady($request_id) ?>"> + <?= CSRFProtection::tokenTag() ?> + + +<?= $this->render_partial( + 'course/room_requests/_new_request_header') ?> + +<?= $request_id ?> +<?= var_dump($request) ?> +<?= $room_name ?> +<section class="resources-grid"> + <div> + <fieldset> + <legend><?= _('Wünschbare Eigenschaften') ?></legend> + + <? if ($available_room_categories): ?> + <label> + <?= _('Raumkategorie') ?> + <span class="flex-row"> + <select name="category_id" <?= $category ? 'disabled' : '' ?>> + <option value=""><?= _('bitte auswählen') ?></option> + <? foreach ($available_room_categories as $rc): ?> + <option value="<?= htmlReady($rc->id) ?>" + <?= ($category_id == $rc->id) + ? 'selected="selected"' + : '' ?>> + <?= htmlReady($rc->name) ?> + </option> + <? endforeach ?> + </select> + <? if ($category) : ?> + <?= Icon::create('refresh', Icon::ROLE_CLICKABLE, ['title' => _('alle Angaben zurücksetzen')])->asInput( + [ + 'type' => 'image', + 'class' => 'text-bottom', + 'name' => 'reset_category', + 'style' => 'margin-left: 0.2em; margin-top: 0.6em;' + ] + ) ?> + <? else : ?> + <?= Icon::create('accept', Icon::ROLE_CLICKABLE, ['title' => _('Raumtyp auswählen')])->asInput( + [ + 'type' => 'image', + 'class' => 'text-bottom', + 'name' => 'select_properties', + 'value' => _('Raumtyp auswählen'), + 'style' => 'margin-left: 0.2em; margin-top: 0.6em;' + ] + ) ?> + <? endif ?> + </span> + </label> + <? endif ?> + <? if (!$embedded) : ?> + </fieldset> + </div> + + <div> + <fieldset> + <legend><?= _('Raumsuche') ?></legend> + <label> + <?= _('Raumname') ?> + <span class="flex-row"> + <input type="text" name="room_name" value="<?= htmlReady($room_name) ?>"> + <?= Icon::create('search', Icon::ROLE_CLICKABLE)->asInput( + [ + 'name' => 'search_by_name', + 'class' => 'text-bottom', + 'style' => 'margin-left: 0.2em; margin-top: 0.6em;' + ] + ) ?> + <? if ($room_name) : ?> + <?= Icon::create('refresh', Icon::ROLE_CLICKABLE, ['title' => _('alle Angaben zurücksetzen')])->asInput( + [ + 'type' => 'image', + 'class' => 'text-bottom', + 'name' => 'reset_category', + 'style' => 'margin-left: 0.2em; margin-top: 0.6em;' + ] + ) ?> + <? endif?> + </span> + </label> + + </fieldset> + + </div> +</section> +<?= $this->render_partial('course/room_requests/_request_form_footer') ?> +<? endif ?> diff --git a/app/views/course/room_requests/request_first_step.php b/app/views/course/room_requests/request_first_step.php new file mode 100644 index 00000000000..b3d9bbc7f37 --- /dev/null +++ b/app/views/course/room_requests/request_first_step.php @@ -0,0 +1 @@ +<?php diff --git a/app/views/course/timesrooms/_roomRequest.php b/app/views/course/timesrooms/_roomRequest.php index e8ee82984c9..f83e47e3a2f 100644 --- a/app/views/course/timesrooms/_roomRequest.php +++ b/app/views/course/timesrooms/_roomRequest.php @@ -9,7 +9,7 @@ _('Hier können Sie für die gesamte Veranstaltung, also für alle regelmäßigen und unregelmäßigen Termine, ' . 'eine Raumanfrage erstellen.') ) ?> - <a class="link-add" href="<?= $controller->url_for('course/room_requests/request_start', + <a class="link-add" href="<?= $controller->url_for('course/room_requests/new_request', [ 'cid' => $course->id, 'range_str' => 'course', diff --git a/lib/modules/CoreAdmin.class.php b/lib/modules/CoreAdmin.class.php index b307b6f21bf..46d797cf596 100644 --- a/lib/modules/CoreAdmin.class.php +++ b/lib/modules/CoreAdmin.class.php @@ -63,12 +63,15 @@ class CoreAdmin extends CorePlugin implements StudipModule $item->setDescription(_('Regelmäßige Veranstaltungszeiten, Einzeltermine und Ortsangaben ändern.')); $navigation->addSubNavigation('dates', $item); + // TODO remove whole navigation entry + /* if (Config::get()->RESOURCES_ENABLE && Config::get()->RESOURCES_ALLOW_ROOM_REQUESTS) { $item = new Navigation(_('Raumanfragen'), 'dispatch.php/course/room_requests/index/' . $course_id); $item->setImage(Icon::create('resources')); $item->setDescription(_('Raumanfragen zu Veranstaltungszeiten verwalten.')); $navigation->addSubNavigation('room_requests', $item); } + */ $item = new Navigation(_('Zugangsberechtigungen'), 'dispatch.php/course/admission'); $item->setImage(Icon::create('lock-locked')); -- GitLab