ILIAS  release_5-2 Revision v5.2.25-18-g3f80b828510
class.ilDclTableViewEditGUI.php
Go to the documentation of this file.
1<?php
2require_once("./Modules/DataCollection/classes/TableView/class.ilDclTableViewFieldsTableGUI.php");
3require_once("./Modules/DataCollection/classes/TableView/class.ilDclTableViewEditFormGUI.php");
4require_once("./Services/AccessControl/classes/class.ilObjRole.php");
14{
18 protected $parent_obj;
19
23 protected $ctrl;
24
28 protected $lng;
29
33 protected $tpl;
34
38 public $tableview;
39
43 protected $form;
44
48 protected $table_gui;
49
53 protected $tabs_gui;
54
58 public $table;
59
60
67 {
68 global $DIC;
69 $lng = $DIC['lng'];
70 $ilCtrl = $DIC['ilCtrl'];
71 $tpl = $DIC['tpl'];
72 $ilTabs = $DIC['ilTabs'];
73 $locator = $DIC['ilLocator'];
74 $this->table = $table;
75 $this->tpl = $tpl;
76 $this->lng = $lng;
77 $this->ctrl = $ilCtrl;
78 $this->parent_obj = $parent_obj;
79 $this->tableview = $tableview;
80 $this->tabs_gui = $ilTabs;
81
82 $this->ctrl->saveParameterByClass('ilDclTableEditGUI', 'table_id');
83 $this->ctrl->saveParameter($this, 'tableview_id');
84 $locator->addItem($this->tableview->getTitle(), $this->ctrl->getLinkTarget($this, 'show'));
85 $this->tpl->setLocator();
86 }
87
88
92 public function executeCommand()
93 {
94 $cmd = $this->ctrl->getCmd('show');
95 $next_class = $this->ctrl->getNextClass($this);
96
97 if (!$this->checkAccess($cmd)) {
98 $this->permissionDenied();
99 }
100
101 $this->tabs_gui->clearTargets();
102 $this->tabs_gui->clearSubTabs();
103 $this->tabs_gui->setBackTarget($this->lng->txt('dcl_tableviews'), $this->ctrl->getLinkTarget($this->parent_obj));
104 $this->tabs_gui->setBack2Target($this->lng->txt('dcl_tables'), $this->ctrl->getLinkTarget($this->parent_obj->parent_obj));
105
106
107
108 switch($next_class)
109 {
110 case 'ildcldetailedviewdefinitiongui':
111 $this->setTabs('detailed_view');
112 require_once('./Modules/DataCollection/classes/DetailedView/class.ilDclDetailedViewDefinitionGUI.php');
113 $recordedit_gui = new ilDclDetailedViewDefinitionGUI($this->tableview->getId());
114 $ret = $this->ctrl->forwardCommand($recordedit_gui);
115 if ($ret != "") {
116 $this->tpl->setContent($ret);
117 }
118 global $DIC;
119 $ilTabs = $DIC['ilTabs'];
120 $ilTabs->removeTab('edit');
121 $ilTabs->removeTab('history');
122 $ilTabs->removeTab('clipboard'); // Fixme
123 $ilTabs->removeTab('pg');
124 break;
125 default:
126 switch($cmd) {
127 case 'show':
128 if ($this->tableview->getId()) {
129 $this->ctrl->redirect($this, 'editGeneralSettings');
130 } else {
131 $this->ctrl->redirect($this, 'add');
132 }
133 break;
134 case 'add':
135 $ilDclTableViewEditFormGUI = new ilDclTableViewEditFormGUI($this, $this->tableview);
136 $this->tpl->setContent($ilDclTableViewEditFormGUI->getHTML());
137 break;
138 case 'editGeneralSettings':
139 $this->setTabs('general_settings');
140 $ilDclTableViewEditFormGUI = new ilDclTableViewEditFormGUI($this, $this->tableview);
141 $this->tpl->setContent($ilDclTableViewEditFormGUI->getHTML());
142 break;
143 case 'editFieldSettings':
144 $this->setTabs('field_settings');
145 $this->initTableGUI();
146 $this->tpl->setContent($this->table_gui->getHTML());
147 break;
148 default:
149 $this->$cmd();
150 break;
151 }
152 break;
153 }
154
155 }
156
157 protected function setTabs($active)
158 {
159 $this->tabs_gui->addTab('general_settings', $this->lng->txt('settings'), $this->ctrl->getLinkTarget($this, 'editGeneralSettings'));
160 $this->tabs_gui->addTab('field_settings', $this->lng->txt('dcl_list_visibility_and_filter'), $this->ctrl->getLinkTarget($this, 'editFieldSettings'));
161 $this->tabs_gui->addTab('detailed_view', $this->lng->txt('dcl_detailed_view'), $this->ctrl->getLinkTargetByClass('ilDclDetailedViewDefinitionGUI', 'edit'));
162 $this->tabs_gui->setTabActive($active);
163 }
164
168 public function update()
169 {
170 $ilDclTableViewEditFormGUI = new ilDclTableViewEditFormGUI($this, $this->tableview);
171 $ilDclTableViewEditFormGUI->setValuesByPost();
172 if ($ilDclTableViewEditFormGUI->checkInput()) {
173 $ilDclTableViewEditFormGUI->updateTableView();
174 $this->ctrl->redirect($this, 'editGeneralSettings');
175 } else {
176 $this->setTabs('general_settings');
177 $this->tpl->setContent($ilDclTableViewEditFormGUI->getHTML());
178 }
179 }
180
184 public function create()
185 {
186 $ilDclTableViewEditFormGUI = new ilDclTableViewEditFormGUI($this, $this->tableview, $this->table);
187 $ilDclTableViewEditFormGUI->setValuesByPost();
188 if ($ilDclTableViewEditFormGUI->checkInput()) {
189 $ilDclTableViewEditFormGUI->createTableView();
190 $this->ctrl->redirect($this, 'editGeneralSettings');
191 } else {
192 $this->tpl->setContent($ilDclTableViewEditFormGUI->getHTML());
193 }
194 }
195
199 public function saveTable()
200 {
204 foreach ($this->tableview->getFieldSettings() as $setting)
205 {
206 //Checkboxes
207 foreach (array("Visible", "InFilter", "FilterChangeable") as $attribute)
208 {
209 $key = $attribute . '_' . $setting->getField();
210 $setting->{'set'.$attribute}($_POST[$key] == 'on');
211
212 }
213
214 //Filter Value
215 $key = 'filter_' . $setting->getField();
216 if ($_POST[$key] != null)
217 {
218 $setting->setFilterValue($_POST[$key]);
219 }
220 elseif ($_POST[$key . '_from'] != null && $_POST[$key . '_to'] != null)
221 {
222 $setting->setFilterValue( array( "from" => $_POST[$key . '_from'], "to" => $_POST[$key . '_to'] ) );
223 }
224 else
225 {
226 $setting->setFilterValue(null);
227 }
228
229 $setting->update();
230 }
231 ilUtil::sendSuccess($this->lng->txt('dcl_msg_tableview_updated'), true);
232 $this->ctrl->saveParameter($this->parent_obj, 'tableview_id');
233 $this->ctrl->redirect($this, 'editFieldSettings');
234 }
235
239 protected function initTableGUI()
240 {
241 $table = new ilDclTableViewEditFieldsTableGUI($this);
242 $this->table_gui = $table;
243 }
244
248 protected function cancel()
249 {
250 $this->ctrl->setParameter($this->parent_obj, 'table_id', $this->table->getId());
251 $this->ctrl->redirect($this->parent_obj);
252 }
253
257 public function confirmDelete()
258 {
259 //at least one view must exist
260 $this->parent_obj->checkViewsLeft(1);
261
262 include_once './Services/Utilities/classes/class.ilConfirmationGUI.php';
263 $conf = new ilConfirmationGUI();
264 $conf->setFormAction($this->ctrl->getFormAction($this));
265 $conf->setHeaderText($this->lng->txt('dcl_tableview_confirm_delete'));
266
267 $conf->addItem('tableview_id', (int)$this->tableview->getId(), $this->tableview->getTitle());
268
269 $conf->setConfirm($this->lng->txt('delete'), 'delete');
270 $conf->setCancel($this->lng->txt('cancel'), 'cancel');
271
272 $this->tpl->setContent($conf->getHTML());
273 }
274
275 protected function delete() {
276 $this->tableview->delete();
277 $this->table->sortTableViews();
278 ilUtil::sendSuccess($this->lng->txt('dcl_msg_tableview_deleted'), true);
279 $this->cancel();
280 }
281
282
286 public function permissionDenied() {
287 ilUtil::sendFailure($this->lng->txt('permission_denied'), true);
288 $this->ctrl->redirectByClass([ilObjDataCollectionGUI::class, ilDclRecordListGUI::class], ilDclRecordListGUI::CMD_LIST_RECORDS);
289 }
290
291
297 protected function checkAccess($cmd)
298 {
299 if (in_array($cmd, ['add', 'create'])) {
301 $this->parent_obj->parent_obj->getDataCollectionObject()->getRefId(),
302 $this->table->getId()
303 );
304 } else {
305 return ilObjDataCollectionAccess::hasAccessTo(
306 $this->parent_obj->parent_obj->getDataCollectionObject()->getRefId(),
307 $this->table->getId(),
308 $this->tableview->getId()
309 );
310 }
311 }
312
313}
$_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 sendSuccess($a_info="", $a_keep=false)
Send Success Message to Screen.
static sendFailure($a_info="", $a_keep=false)
Send Failure Message to Screen.
global $ilCtrl
Definition: ilias.php:18
$ret
Definition: parser.php:6
$cmd
Definition: sahs_server.php:35
global $DIC