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