ILIAS  release_6 Revision v6.24-5-g0c8bfefb3b8
class.ilDclTableViewEditGUI.php
Go to the documentation of this file.
1<?php
2
12{
13
17 protected $parent_obj;
21 protected $ctrl;
25 protected $lng;
29 protected $tpl;
33 public $tableview;
37 protected $form;
41 protected $table_gui;
45 protected $tabs_gui;
49 public $table;
50
51
59 {
60 global $DIC;
61 $lng = $DIC['lng'];
62 $ilCtrl = $DIC['ilCtrl'];
63 $tpl = $DIC['tpl'];
64 $ilTabs = $DIC['ilTabs'];
65 $locator = $DIC['ilLocator'];
66 $this->table = $table;
67 $this->tpl = $tpl;
68 $this->lng = $lng;
69 $this->ctrl = $ilCtrl;
70 $this->parent_obj = $parent_obj;
71 $this->tableview = $tableview;
72 $this->tabs_gui = $ilTabs;
73
74 $this->ctrl->saveParameterByClass('ilDclTableEditGUI', 'table_id');
75 $this->ctrl->saveParameter($this, 'tableview_id');
76 if ($this->tableview->getTitle()) {
77 $locator->addItem($this->tableview->getTitle(), $this->ctrl->getLinkTarget($this, 'show'));
78 }
79 $this->tpl->setLocator();
80 }
81
82
86 public function executeCommand()
87 {
88 $cmd = $this->ctrl->getCmd('show');
89 $next_class = $this->ctrl->getNextClass($this);
90
91 if (!$this->checkAccess($cmd)) {
92 $this->permissionDenied();
93 }
94
95 $this->tabs_gui->clearTargets();
96 $this->tabs_gui->clearSubTabs();
97 $this->tabs_gui->setBackTarget($this->lng->txt('dcl_tableviews'), $this->ctrl->getLinkTarget($this->parent_obj));
98 $this->tabs_gui->setBack2Target($this->lng->txt('dcl_tables'), $this->ctrl->getLinkTarget($this->parent_obj->parent_obj));
99
100 switch ($next_class) {
101 case 'ildcldetailedviewdefinitiongui':
102 $this->setTabs('detailed_view');
103 $recordedit_gui = new ilDclDetailedViewDefinitionGUI($this->tableview->getId());
104 $ret = $this->ctrl->forwardCommand($recordedit_gui);
105 if ($ret != "") {
106 $this->tpl->setContent($ret);
107 }
108 global $DIC;
109 $ilTabs = $DIC['ilTabs'];
110 $ilTabs->removeTab('edit');
111 $ilTabs->removeTab('history');
112 $ilTabs->removeTab('clipboard'); // Fixme
113 $ilTabs->removeTab('pg');
114 break;
115 default:
116 switch ($cmd) {
117 case 'show':
118 if ($this->tableview->getId()) {
119 $this->ctrl->redirect($this, 'editGeneralSettings');
120 } else {
121 $this->ctrl->redirect($this, 'add');
122 }
123 break;
124 case 'add':
125 $ilDclTableViewEditFormGUI = new ilDclTableViewEditFormGUI($this, $this->tableview);
126 $this->tpl->setContent($ilDclTableViewEditFormGUI->getHTML());
127 break;
128 case 'editGeneralSettings':
129 $this->setTabs('general_settings');
130 $ilDclTableViewEditFormGUI = new ilDclTableViewEditFormGUI($this, $this->tableview);
131 $this->tpl->setContent($ilDclTableViewEditFormGUI->getHTML());
132 break;
133 case 'editFieldSettings':
134 $this->setTabs('field_settings');
135 $this->initTableGUI();
136 $this->tpl->setContent($this->table_gui->getHTML());
137 break;
138 default:
139 $this->$cmd();
140 break;
141 }
142 break;
143 }
144 }
145
146
147 protected function setTabs($active)
148 {
149 $this->tabs_gui->addTab('general_settings', $this->lng->txt('settings'), $this->ctrl->getLinkTarget($this, 'editGeneralSettings'));
150 $this->tabs_gui->addTab('field_settings', $this->lng->txt('dcl_list_visibility_and_filter'), $this->ctrl->getLinkTarget($this, 'editFieldSettings'));
151 $this->tabs_gui->addTab('detailed_view', $this->lng->txt('dcl_detailed_view'), $this->ctrl->getLinkTargetByClass('ilDclDetailedViewDefinitionGUI', 'edit'));
152 $this->tabs_gui->setTabActive($active);
153 }
154
155
159 public function update()
160 {
161 $ilDclTableViewEditFormGUI = new ilDclTableViewEditFormGUI($this, $this->tableview);
162 $ilDclTableViewEditFormGUI->setValuesByPost();
163 if ($ilDclTableViewEditFormGUI->checkInput()) {
164 $ilDclTableViewEditFormGUI->updateTableView();
165 $this->ctrl->redirect($this, 'editGeneralSettings');
166 } else {
167 $this->setTabs('general_settings');
168 $this->tpl->setContent($ilDclTableViewEditFormGUI->getHTML());
169 }
170 }
171
172
176 public function create()
177 {
178 $ilDclTableViewEditFormGUI = new ilDclTableViewEditFormGUI($this, $this->tableview, $this->table);
179 $ilDclTableViewEditFormGUI->setValuesByPost();
180 if ($ilDclTableViewEditFormGUI->checkInput()) {
181 $ilDclTableViewEditFormGUI->createTableView();
182 $this->ctrl->redirect($this, 'editGeneralSettings');
183 } else {
184 $this->tpl->setContent($ilDclTableViewEditFormGUI->getHTML());
185 }
186 }
187
188
192 public function saveTable()
193 {
197 foreach ($this->tableview->getFieldSettings() as $setting) {
198 //Checkboxes
199 foreach (array("Visible", "InFilter", "FilterChangeable") as $attribute) {
200 $key = $attribute . '_' . $setting->getField();
201 $setting->{'set' . $attribute}($_POST[$key] == 'on');
202 }
203
204 //Filter Value
205 $key = 'filter_' . $setting->getField();
206 if ($_POST[$key] != null) {
207 $setting->setFilterValue($_POST[$key]);
208 } elseif ($_POST[$key . '_from'] != null && $_POST[$key . '_to'] != null) {
209 $setting->setFilterValue(array("from" => $_POST[$key . '_from'], "to" => $_POST[$key . '_to']));
210 } else {
211 $setting->setFilterValue(null);
212 }
213
214 $setting->update();
215 }
216 ilUtil::sendSuccess($this->lng->txt('dcl_msg_tableview_updated'), true);
217 $this->ctrl->saveParameter($this->parent_obj, 'tableview_id');
218 $this->ctrl->redirect($this, 'editFieldSettings');
219 }
220
221
225 protected function initTableGUI()
226 {
227 $table = new ilDclTableViewEditFieldsTableGUI($this);
228 $this->table_gui = $table;
229 }
230
231
235 protected function cancel()
236 {
237 $this->ctrl->setParameter($this->parent_obj, 'table_id', $this->table->getId());
238 $this->ctrl->redirect($this->parent_obj);
239 }
240
241
245 public function confirmDelete()
246 {
247 //at least one view must exist
248 $this->parent_obj->checkViewsLeft(1);
249
250 $conf = new ilConfirmationGUI();
251 $conf->setFormAction($this->ctrl->getFormAction($this));
252 $conf->setHeaderText($this->lng->txt('dcl_tableview_confirm_delete'));
253
254 $conf->addItem('tableview_id', (int) $this->tableview->getId(), $this->tableview->getTitle());
255
256 $conf->setConfirm($this->lng->txt('delete'), 'delete');
257 $conf->setCancel($this->lng->txt('cancel'), 'cancel');
258
259 $this->tpl->setContent($conf->getHTML());
260 }
261
262
263 protected function delete()
264 {
265 $this->tableview->delete();
266 $this->table->sortTableViews();
267 ilUtil::sendSuccess($this->lng->txt('dcl_msg_tableview_deleted'), true);
268 $this->cancel();
269 }
270
271
275 public function permissionDenied()
276 {
277 ilUtil::sendFailure($this->lng->txt('permission_denied'), true);
278 $this->ctrl->redirectByClass([ilObjDataCollectionGUI::class, ilDclRecordListGUI::class], ilDclRecordListGUI::CMD_LIST_RECORDS);
279 }
280
281
287 protected function checkAccess($cmd)
288 {
289 if (in_array($cmd, ['add', 'create'])) {
291 $this->parent_obj->parent_obj->getDataCollectionObject()->getRefId(),
292 $this->table->getId()
293 );
294 } else {
295 return ilObjDataCollectionAccess::hasAccessTo(
296 $this->parent_obj->parent_obj->getDataCollectionObject()->getRefId(),
297 $this->table->getId(),
298 $this->tableview->getId()
299 );
300 }
301 }
302}
$_POST["username"]
An exception for terminatinating execution or to throw for unit testing.
Confirmation screen class.
Class ilDclDetailedViewDefinitionGUI.
Class ilDclTableViewEditFieldsTableGUI.
Class ilDclTableViewEditFormGUI.
Class ilDclTableViewEditGUI.
__construct(ilDclTableViewGUI $parent_obj, ilDclTable $table, ilDclTableView $tableview)
ilDclTableViewEditGUI constructor.
Class ilDclTableViewGUI.
Class ilDclTableView.
Class ilDclBaseFieldModel.
static hasAccessToEditTable($ref_id, $table_id)
static sendFailure($a_info="", $a_keep=false)
Send Failure Message to Screen.
global $ilCtrl
Definition: ilias.php:18
$ret
Definition: parser.php:6
$DIC
Definition: xapitoken.php:46