ILIAS  trunk Revision v12.0_alpha-1540-g00f839d5fa1
class.ilObjWebDAVGUI.php
Go to the documentation of this file.
1<?php
2
19declare(strict_types=1);
20
22
31{
32 protected const SETTING_COMMANDS = [
33 'edit' => 'editSettings',
34 'save' => 'saveSettings'
35 ];
36
39
40 public function __construct(?array $a_data, int $a_id, bool $a_call_by_reference)
41 {
42 global $DIC;
43 $this->webdav_dic = new ilWebDAVDIC();
44 $this->webdav_dic->init($DIC);
45
46 $this->type = "wbdv";
47 parent::__construct($a_data, $a_id, $a_call_by_reference, false);
48 }
49
50 #[\Override]
51 public function executeCommand(): void
52 {
53 $next_class = $this->ctrl->getNextClass($this);
54 $cmd = $this->ctrl->getCmd();
55
56 $this->prepareOutput();
57
58 if (!$this->access->checkAccess('read', '', $this->object->getRefId())) {
59 $this->error_handling->raiseError(
60 $this->lng->txt('no_permission'),
61 $this->error_handling->MESSAGE
62 );
63 }
64
65 switch ($next_class) {
66 case strtolower(UploadGUI::class):
67 $document_gui = $this->webdav_dic->mountinstructions_upload();
68 $document_gui->setRefId($this->object->getRefId());
69 $this->tabs_gui->activateTab('webdav_upload_instructions');
70 $this->ctrl->forwardCommand($document_gui);
71 break;
72
73 default:
74 if (!$cmd || $cmd === 'view' || !in_array($cmd, self::SETTING_COMMANDS)) {
75 $cmd = self::SETTING_COMMANDS['edit'];
76 }
77 $this->$cmd();
78 break;
79 }
80 }
81
82 #[\Override]
83 public function getAdminTabs(): void
84 {
85 if ($this->rbac_system->checkAccess("read", $this->object->getRefId())) {
86 $this->tabs_gui->addTab(
87 'webdav_general_settings',
88 $this->lng->txt("webdav_general_settings"),
89 $this->ctrl->getLinkTarget($this, self::SETTING_COMMANDS['edit'])
90 );
91 $this->tabs_gui->addTab(
92 'webdav_upload_instructions',
93 $this->lng->txt("webdav_upload_instructions"),
94 $this->ctrl->getLinkTargetByClass(UploadGUI::class)
95 );
96 }
97 }
98
99 #[\Override]
100 public function setTitleAndDescription(): void
101 {
102 parent::setTitleAndDescription();
103 $this->tpl->setDescription($this->object->getDescription());
104 }
105
107 {
108 $form = new ilPropertyFormGUI();
109 $form->setFormAction($this->ctrl->getFormAction($this));
110 $form->setTitle($this->lng->txt("settings"));
111
112 $cb_prop = new ilCheckboxInputGUI($this->lng->txt("enable_webdav"), "enable_webdav");
113 $cb_prop->setInfo($this->lng->txt("enable_webdav_info"));
114 $cb_prop->setValue('1');
115 $cb_prop->setChecked($this->object->isWebdavEnabled());
116 $form->addItem($cb_prop);
117
118 $cb_prop = new ilCheckboxInputGUI($this->lng->txt("webdav_enable_versioning"), "enable_versioning_webdav");
119 $cb_prop->setValue('1');
120 $cb_prop->setInfo($this->lng->txt("webdav_versioning_info"));
121 $cb_prop->setChecked($this->object->isWebdavVersioningEnabled());
122 $form->addItem($cb_prop);
123
124 $form->addCommandButton(self::SETTING_COMMANDS['save'], $this->lng->txt('save'));
125
126 return $form;
127 }
128
129 public function editSettings(): void
130 {
131 $this->tabs_gui->activateTab('webdav_general_settings');
132
133 if (!$this->rbac_system->checkAccess("read", $this->object->getRefId())) {
134 $this->error_handling->raiseError(
135 $this->lng->txt("no_permission"),
136 $this->error_handling->WARNING
137 );
138 }
139
140 $form = $this->initSettingsForm();
141
142 $this->tpl->setContent($form->getHTML());
143 }
144
145 public function saveSettings(): void
146 {
147 if (!$this->rbac_system->checkAccess("write", $this->object->getRefId())) {
148 $this->tpl->setOnScreenMessage('failure', $this->lng->txt('no_permission'), true);
149 $this->ctrl->redirect($this, self::SETTING_COMMANDS['edit']);
150 }
151
152 $form = $this->initSettingsForm();
153 if ($form->checkInput()) {
154 $this->object->setWebdavEnabled(($form->getInput('enable_webdav') === '1'));
155 $this->object->setWebdavVersioningEnabled(($form->getInput('enable_versioning_webdav') === '1'));
156 $this->object->update();
157 $this->tpl->setOnScreenMessage('success', $this->lng->txt('settings_saved'), true);
158 $this->ctrl->redirect($this, self::SETTING_COMMANDS['edit']);
159 } else {
160 $form->setValuesByPost();
161 $this->tpl->setContent($form->getHTML());
162 }
163 }
164}
@ilCtrl_isCalledBy ILIAS\WebDAV\Mount\UploadGUI: ilObjWebDAVGUI
Definition: UploadGUI.php:43
This class represents a checkbox property in a property form.
Error Handling & global info handling.
getAdminTabs()
administration tabs show only permissions and trash folder
ilErrorHandling $error_handling
__construct(?array $a_data, int $a_id, bool $a_call_by_reference)
Class ilObjectGUI Basic methods of all Output classes.
prepareOutput(bool $show_sub_objects=true)
This class represents a property form user interface.
__construct(Container $dic, ilPlugin $plugin)
@inheritDoc
global $DIC
Definition: shib_login.php:26