diff --git a/app/controllers/room_management/planning.php b/app/controllers/room_management/planning.php index 7aafe68fcf9785a2ddd7befea58c5cf28f148f16..74ea008a159981d80d906612751c0be6a86e6b53 100644 --- a/app/controllers/room_management/planning.php +++ b/app/controllers/room_management/planning.php @@ -44,7 +44,7 @@ class RoomManagement_PlanningController extends AuthenticatedController $sidebar = Sidebar::get(); $views = new ViewsWidget(); - if ($GLOBALS['user']->id && ($GLOBALS['user']->id != 'nobody')) { + if ($GLOBALS['user']->id && ($GLOBALS['user']->id !== 'nobody')) { $views->addLink( _('Standard Zeitfenster'), URLHelper::getURL( @@ -82,7 +82,6 @@ class RoomManagement_PlanningController extends AuthenticatedController //Add clipboard widget: $clipboard_widget = new RoomClipboardWidget(); - $clipboard_widget->setReadonly(true); $clipboard_widget->setApplyButtonTitle( _('Anzeigen') ); @@ -382,7 +381,6 @@ class RoomManagement_PlanningController extends AuthenticatedController //Add clipboard widget: $clipboard_widget = new RoomClipboardWidget(); - $clipboard_widget->setReadonly(true); $clipboard_widget->setApplyButtonTitle( _('Anzeigen') ); @@ -1102,7 +1100,6 @@ class RoomManagement_PlanningController extends AuthenticatedController //Add clipboard widget: $clipboard_widget = new RoomClipboardWidget(); - $clipboard_widget->setReadonly(true); $clipboard_widget->setApplyButtonTitle( _('Anzeigen') ); diff --git a/lib/classes/sidebar/ClipboardWidget.class.php b/lib/classes/sidebar/ClipboardWidget.class.php index 376e47e37c43d4b3a3022d144b02689816510ab3..9de627df0e11620a2b198f1672a01f70b03cacb0 100644 --- a/lib/classes/sidebar/ClipboardWidget.class.php +++ b/lib/classes/sidebar/ClipboardWidget.class.php @@ -10,9 +10,8 @@ */ class ClipboardWidget extends SidebarWidget { - protected $allowed_item_class; protected $draggable_items; - + protected $current_selected_items = []; /** * clipboard_widget_id is required in the case that multiple @@ -49,7 +48,7 @@ class ClipboardWidget extends SidebarWidget //Check if all allowed item classes are SimpleORMap objects //and if the classes implement the StudipItem interface: foreach ($allowed_item_classes as $class) { - if (!is_subclass_of($class, 'StudipItem', true)) { + if (!is_subclass_of($class, 'StudipItem')) { throw new InvalidArgumentException( sprintf( 'The class %s does not implement the StudipItem interface which is required for clipboard items!', @@ -66,17 +65,14 @@ class ClipboardWidget extends SidebarWidget $this->allowed_item_classes = $allowed_item_classes; $this->template = 'sidebar/clipboard-widget'; $this->title = _('Eigene Merkzettel'); - $this->readonly = false; $this->apply_button_title = _('Hauptbereich aktualisieren'); $this->clipboard_widget_id = md5(uniqid('clipboard_widget_id')); - $this->draggable_items = false; $this->updateSessionVariables(); $this->current_clipboard_id = $_SESSION['selected_clipboard_id']; - $this->current_selected_items = $_SESSION['selected_clipboard_items']; - if (!is_array($this->current_selected_items)) { - $this->current_selected_items = []; + if (is_array($_SESSION['selected_clipboard_items'])) { + $this->current_selected_items = $_SESSION['selected_clipboard_items']; } $this->setId("ClipboardWidget_{$this->clipboard_widget_id}"); @@ -84,14 +80,6 @@ class ClipboardWidget extends SidebarWidget $this->addLayoutCSSClass('clipboard-widget'); } - - public function clearSessionVariables() - { - $_SESSION['selected_clipboard_id'] = null; - $_SESSION['selected_clipboard_items'] = []; - } - - /** * Updates session variables if a special POST request is made. */ @@ -109,37 +97,6 @@ class ClipboardWidget extends SidebarWidget } } - - /** - * Enables clipboard items to be dragged to the main area of the page. - */ - public function enableDraggableItems() - { - $this->draggable_items = true; - } - - - /** - * Disables the dragging of clipboard items. - */ - public function disableDraggableItems() - { - $this->draggable_items = false; - } - - - public function setReadonly($readonly = false) - { - $this->readonly = (bool)$readonly; - } - - - public function isReadonly() - { - return $this->readonly; - } - - public function setApplyButtonTitle($title = '') { if ($title) { @@ -147,19 +104,11 @@ class ClipboardWidget extends SidebarWidget } } - - public function getApplyButtonTitle() - { - return $this->apply_button_title; - } - - public function getClipboardWidgetId() { return $this->clipboard_widget_id; } - public function render($variables = []) { $clipboards = Clipboard::getClipboardsForUser( @@ -177,7 +126,6 @@ class ClipboardWidget extends SidebarWidget 'allowed_item_classes' => $this->allowed_item_classes, 'clipboard_widget_id' => $this->clipboard_widget_id, 'draggable_items' => $this->draggable_items, - 'readonly' => $this->readonly, 'apply_button_title' => $this->apply_button_title, 'elements' => $this->elements, 'selected_clipboard_id' => $this->current_clipboard_id, diff --git a/templates/sidebar/clipboard-area.php b/templates/sidebar/clipboard-area.php index d103b5069491513ccd31de98a047de92e344e308..72e79f0fcb68b26c930fad46d22ee8960bc6bc8e 100644 --- a/templates/sidebar/clipboard-area.php +++ b/templates/sidebar/clipboard-area.php @@ -14,8 +14,6 @@ <? endforeach ?> <? endif ?> </select> - <? if (!$readonly): ?> - <input class="clipboard-name invisible" type="text" name="clipboard_name" value=""> <?= Icon::create('edit')->asInput( [ @@ -44,7 +42,6 @@ 'data-confirm-message' => _('Sind Sie sicher?') ] ) ?> - <? endif ?> </div> <div class="clipboard-area-container"> <? if ($clipboards): ?> @@ -74,7 +71,6 @@ [ 'item' => $item, 'draggable_items' => $draggable_items, - 'readonly' => $readonly, 'checkbox_id' => $checkbox_id ] ) ?> @@ -98,17 +94,15 @@ <?= htmlReady($item['name']) ?> </label> </td> - <? if (!$readonly): ?> - <td class="actions"> - <?= Icon::create('trash')->asInput( - [ - 'title' => sprintf(_('%s löschen.'), htmlReady($item['name'])), - 'data-confirm-message' => _('Sind Sie sicher?'), - 'class' => 'text-bottom clipboard-item-remove-button' - ] - ) ?> - </td> - <? endif ?> + <td class="actions"> + <?= Icon::create('trash')->asInput( + [ + 'title' => sprintf(_('%s löschen.'), htmlReady($item['name'])), + 'data-confirm-message' => _('Sind Sie sicher?'), + 'class' => 'text-bottom clipboard-item-remove-button' + ] + ) ?> + </td> </tr> <? endif ?> <? endforeach ?> @@ -138,15 +132,13 @@ value="" class="item-id"> </td> - <? if (!$readonly): ?> - <td class="item-actions"> - <?= Icon::create('trash')->asInput( - [ - 'class' => 'text-bottom clipboard-item-remove-button' - ] - ) ?> - </td> - <? endif ?> + <td class="item-actions"> + <?= Icon::create('trash')->asInput( + [ + 'class' => 'text-bottom clipboard-item-remove-button' + ] + ) ?> + </td> </tr> <? endif ?> </table> @@ -195,13 +187,4 @@ <? endif ?> </table> </div> - <? if ($readonly): ?> - <?= \Studip\Button::create( - $apply_button_title, - 'clipboard_update_session_special_action', - [ - 'class' => 'apply-button' - ] - ) ?> - <? endif ?> </form> diff --git a/templates/sidebar/clipboard-widget.php b/templates/sidebar/clipboard-widget.php index 46015e7a452618f5d103281b95617c32f1d5e3bf..ccb44b23213b7722de092433a145027504d9ae2c 100644 --- a/templates/sidebar/clipboard-widget.php +++ b/templates/sidebar/clipboard-widget.php @@ -19,31 +19,29 @@ <? endforeach; ?> </ul> -<? if (!$readonly): ?> - <form class="default new-clipboard-form" - action="<?= URLHelper::getLink( - 'dispatch.php/clipboard/add' - )?>" - method="post"> - <?= CSRFProtection::tokenTag() ?> - <input type="hidden" name="allowed_item_class" - value="<?= htmlReady($allowed_item_class) ?>"> - <input type="hidden" name="widget_id" - value="<?= htmlReady($clipboard_widget_id) ?>"> - <label> - <?= _('Merkzettel hinzufügen') ?> - <?= tooltipIcon(_('Geben Sie bitte einen Namen ein und klicken Sie auf das Plus-Symbol um einen neuen Merkzettel zu erstellen.')) ?> - <input type="text" name="name" placeholder="<?= _('Name des neuen Merkzettels') ?>" - </label> +<form class="default new-clipboard-form" + action="<?= URLHelper::getLink( + 'dispatch.php/clipboard/add' + )?>" + method="post"> + <?= CSRFProtection::tokenTag() ?> + <input type="hidden" name="allowed_item_class" + value="<?= htmlReady($allowed_item_class) ?>"> + <input type="hidden" name="widget_id" + value="<?= htmlReady($clipboard_widget_id) ?>"> + <label> + <?= _('Merkzettel hinzufügen') ?> + <?= tooltipIcon(_('Geben Sie bitte einen Namen ein und klicken Sie auf das Plus-Symbol um einen neuen Merkzettel zu erstellen.')) ?> + <input type="text" name="name" placeholder="<?= _('Name des neuen Merkzettels') ?>"> + </label> - <?= Icon::create( - 'add', - Icon::ROLE_CLICKABLE, - [ 'title' => _('Hinzufügen')])->asInput([ - 'name' => 'save', - 'id' => 'add-clipboard-button', - 'class' => 'middle', - 'disabled' => 'disabled' - ]) ?> - </form> -<? endif ?> + <?= Icon::create( + 'add', + Icon::ROLE_CLICKABLE, + [ 'title' => _('Hinzufügen')])->asInput([ + 'name' => 'save', + 'id' => 'add-clipboard-button', + 'class' => 'middle', + 'disabled' => 'disabled' + ]) ?> +</form> diff --git a/templates/sidebar/room-clipboard-item.php b/templates/sidebar/room-clipboard-item.php index 2fc220b54f337cdb430ecb97e725da1488be95ab..caccb71b075f8db9edeff8c1568f38f445f6b1e3 100644 --- a/templates/sidebar/room-clipboard-item.php +++ b/templates/sidebar/room-clipboard-item.php @@ -66,13 +66,11 @@ if (!$item) { ] )?> </a> - <? if (!$readonly): ?> - <?= Icon::create('trash')->asInput( - [ - 'data-confirm-message' => _('Sind Sie sicher?'), - 'class' => 'text-bottom clipboard-item-remove-button' - ] - ) ?> - <? endif ?> + <?= Icon::create('trash')->asInput( + [ + 'data-confirm-message' => _('Sind Sie sicher?'), + 'class' => 'text-bottom clipboard-item-remove-button' + ] + ) ?> </td> </tr> diff --git a/templates/sidebar/room-clipboard-widget.php b/templates/sidebar/room-clipboard-widget.php index c6a983002e6fc1db2596e27c03abbd4de158e299..76678dfd554f80570b07c0b684c1cf59d2423b10 100644 --- a/templates/sidebar/room-clipboard-widget.php +++ b/templates/sidebar/room-clipboard-widget.php @@ -20,30 +20,28 @@ <? endforeach; ?> </ul> </div> -<? if (!$readonly): ?> - <form class="default new-clipboard-form" - action="<?= URLHelper::getLink( - 'dispatch.php/clipboard/add' - )?>" - method="post"> - <?= CSRFProtection::tokenTag() ?> - <input type="hidden" name="allowed_item_class" - value="<?= htmlReady($allowed_item_class) ?>"> - <input type="hidden" name="widget_id" - value="<?= htmlReady($clipboard_widget_id) ?>"> - <label> - <?= _('Raumgruppe hinzufügen') ?> - <?= tooltipIcon(_('Geben Sie bitte einen Namen ein und klicken Sie auf das Plus-Symbol um eine neue Raumgruppe zu erstellen.')) ?> - <input type="text" name="name" placeholder="<?= _('Name der neuen Raumgruppe') ?>"> +<form class="default new-clipboard-form" + action="<?= URLHelper::getLink( + 'dispatch.php/clipboard/add' + )?>" + method="post"> + <?= CSRFProtection::tokenTag() ?> + <input type="hidden" name="allowed_item_class" + value="<?= htmlReady($allowed_item_class) ?>"> + <input type="hidden" name="widget_id" + value="<?= htmlReady($clipboard_widget_id) ?>"> + <label> + <?= _('Raumgruppe hinzufügen') ?> + <?= tooltipIcon(_('Geben Sie bitte einen Namen ein und klicken Sie auf das Plus-Symbol um eine neue Raumgruppe zu erstellen.')) ?> + <input type="text" name="name" placeholder="<?= _('Name der neuen Raumgruppe') ?>"> - <?= Icon::create('add', Icon::ROLE_CLICKABLE, - [ 'title' => _('Hinzufügen')])->asInput([ - 'name' => 'save', - 'id' => 'add-clipboard-button', - 'class' => 'middle', - 'disabled' => 'disabled' - ]) ?> - </label> + <?= Icon::create('add', Icon::ROLE_CLICKABLE, + [ 'title' => _('Hinzufügen')])->asInput([ + 'name' => 'save', + 'id' => 'add-clipboard-button', + 'class' => 'middle', + 'disabled' => 'disabled' + ]) ?> + </label> - </form> -<? endif ?> +</form>