ILIAS  release_6 Revision v6.24-5-g0c8bfefb3b8
ilDclTableEditGUI Class Reference

Class ilDclBaseFieldModel. More...

+ Collaboration diagram for ilDclTableEditGUI:

Public Member Functions

 __construct (ilDclTableListGUI $a_parent_obj)
 Constructor. More...
 
 executeCommand ()
 execute command More...
 
 create ()
 create table add form More...
 
 edit ()
 create field edit form More...
 
 getValues ()
 getFieldValues More...
 
 getStandardValues ()
 getStandardValues More...
 
 cancel ()
 
 initForm ($a_mode="create")
 initEditCustomForm More...
 
 doTableSwitch ()
 
 save ($a_mode="create")
 save More...
 
 accessDenied ()
 
 confirmDelete ()
 confirmDelete More...
 
 cancelDelete ()
 cancelDelete More...
 
 delete ()
 

Protected Member Functions

 checkInput ($a_mode)
 Custom checks for the form input. More...
 
 checkAccess ()
 
 createTableSwitcher ()
 

Protected Attributes

 $lng
 
 $ctrl
 
 $tpl
 
 $toolbar
 
 $form
 

Private Attributes

 $table_id
 
 $table
 

Detailed Description

Constructor & Destructor Documentation

◆ __construct()

ilDclTableEditGUI::__construct ( ilDclTableListGUI  $a_parent_obj)

Constructor.

Parameters
ilDclTableListGUI$a_parent_obj

Definition at line 54 of file class.ilDclTableEditGUI.php.

55 {
56 global $DIC;
57 $ilCtrl = $DIC['ilCtrl'];
58 $lng = $DIC['lng'];
59 $tpl = $DIC['tpl'];
60 $toolbar = $DIC['ilToolbar'];
61 $locator = $DIC['ilLocator'];
62
63 $this->ctrl = $ilCtrl;
64 $this->lng = $lng;
65 $this->tpl = $tpl;
66 $this->toolbar = $toolbar;
67 $this->parent_object = $a_parent_obj;
68 $this->obj_id = $a_parent_obj->obj_id;
69 $this->table_id = $_GET['table_id'];
70 $this->table = ilDclCache::getTableCache($this->table_id);
71
72 $this->ctrl->saveParameter($this, 'table_id');
73 if ($this->table->getTitle()) {
74 $locator->addItem($this->table->getTitle(), $this->ctrl->getLinkTarget($this, 'edit'));
75 }
76 $this->tpl->setLocator();
77
78 if (!$this->checkAccess()) {
79 ilUtil::sendFailure($this->lng->txt('permission_denied'), true);
80 $this->ctrl->redirectByClass('ildclrecordlistgui', 'listRecords');
81 }
82 }
$_GET["client_id"]
static getTableCache($table_id=0)
static sendFailure($a_info="", $a_keep=false)
Send Failure Message to Screen.
global $ilCtrl
Definition: ilias.php:18
$DIC
Definition: xapitoken.php:46

References $_GET, $DIC, $ilCtrl, $lng, $toolbar, $tpl, checkAccess(), ilDclCache\getTableCache(), and ilUtil\sendFailure().

+ Here is the call graph for this function:

Member Function Documentation

◆ accessDenied()

ilDclTableEditGUI::accessDenied ( )

Definition at line 430 of file class.ilDclTableEditGUI.php.

431 {
432 $this->tpl->setContent("Access denied.");
433 }

Referenced by save().

+ Here is the caller graph for this function:

◆ cancel()

ilDclTableEditGUI::cancel ( )

Definition at line 193 of file class.ilDclTableEditGUI.php.

194 {
195 $this->ctrl->redirectByClass("ilDclTableListGUI", "listTables");
196 }

◆ cancelDelete()

ilDclTableEditGUI::cancelDelete ( )

cancelDelete

Definition at line 457 of file class.ilDclTableEditGUI.php.

458 {
459 $this->ctrl->redirectByClass("ilDclTableListGUI", "listTables");
460 }

◆ checkAccess()

ilDclTableEditGUI::checkAccess ( )
protected
Returns
bool

Definition at line 482 of file class.ilDclTableEditGUI.php.

483 {
484 $ref_id = $this->parent_object->getDataCollectionObject()->getRefId();
485
486 return $this->table_id ? ilObjDataCollectionAccess::hasAccessToEditTable($ref_id, $this->table_id) : ilObjDataCollectionAccess::hasWriteAccess($ref_id);
487 }
Class ilObjDataCollectionAccess.
static hasAccessToEditTable($ref_id, $table_id)

References ilObjDataCollectionAccess\hasAccessToEditTable(), and ilObjDataCollectionAccess\hasWriteAccess().

Referenced by __construct().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ checkInput()

ilDclTableEditGUI::checkInput (   $a_mode)
protected

Custom checks for the form input.

Parameters
$a_mode'create' | 'update'
Returns
bool

Definition at line 404 of file class.ilDclTableEditGUI.php.

405 {
406 $return = $this->form->checkInput();
407
408 // Title of table must be unique in one DC
409 if ($a_mode == 'create') {
410 if ($title = $this->form->getInput('title')) {
411 if (ilObjDataCollection::_hasTableByTitle($title, $this->obj_id)) {
412 $inputObj = $this->form->getItemByPostVar('title');
413 $inputObj->setAlert($this->lng->txt("dcl_table_title_unique"));
414 $return = false;
415 }
416 }
417 }
418
419 if (!$return) {
420 ilUtil::sendFailure($this->lng->txt("form_input_not_valid"));
421 }
422
423 return $return;
424 }
static _hasTableByTitle($title, $obj_id)
Checks if a DataCollection has a table with a given title.

References ilObjDataCollection\_hasTableByTitle(), and ilUtil\sendFailure().

Referenced by save().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ confirmDelete()

ilDclTableEditGUI::confirmDelete ( )

confirmDelete

Definition at line 439 of file class.ilDclTableEditGUI.php.

440 {
441 $conf = new ilConfirmationGUI();
442 $conf->setFormAction($this->ctrl->getFormAction($this));
443 $conf->setHeaderText($this->lng->txt('dcl_confirm_delete_table'));
444
445 $conf->addItem('table', (int) $this->table->getId(), $this->table->getTitle());
446
447 $conf->setConfirm($this->lng->txt('delete'), 'delete');
448 $conf->setCancel($this->lng->txt('cancel'), 'cancelDelete');
449
450 $this->tpl->setContent($conf->getHTML());
451 }
Confirmation screen class.

◆ create()

ilDclTableEditGUI::create ( )

create table add form

Definition at line 108 of file class.ilDclTableEditGUI.php.

109 {
110 $this->initForm();
111 $this->getStandardValues();
112 $this->tpl->setContent($this->form->getHTML());
113 }
getStandardValues()
getStandardValues
initForm($a_mode="create")
initEditCustomForm

References getStandardValues(), and initForm().

+ Here is the call graph for this function:

◆ createTableSwitcher()

ilDclTableEditGUI::createTableSwitcher ( )
protected
Parameters
$options
Returns
mixed

Definition at line 495 of file class.ilDclTableEditGUI.php.

496 {
497 // Show tables
498 $tables = $this->parent_object->getDataCollectionObject()->getTables();
499
500 foreach ($tables as $table) {
501 $options[$table->getId()] = $table->getTitle();
502 }
503 $table_selection = new ilSelectInputGUI('', 'table_id');
504 $table_selection->setOptions($options);
505 $table_selection->setValue($this->table->getId());
506
507 $this->toolbar->setFormAction($this->ctrl->getFormActionByClass("ilDclTableEditGUI", "doTableSwitch"));
508 $this->toolbar->addText($this->lng->txt("dcl_select"));
509 $this->toolbar->addInputItem($table_selection);
510 $button = ilSubmitButton::getInstance();
511 $button->setCommand("doTableSwitch");
512 $button->setCaption('change');
513 $this->toolbar->addButtonInstance($button);
514
515 return $options;
516 }
This class represents a selection list property in a property form.
static getInstance()
Factory.

References $table, and ilSubmitButton\getInstance().

Referenced by initForm().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ delete()

ilDclTableEditGUI::delete ( )

Definition at line 466 of file class.ilDclTableEditGUI.php.

467 {
468 if (count($this->table->getCollectionObject()->getTables()) < 2) {
469 ilUtil::sendFailure($this->lng->txt("dcl_cant_delete_last_table"), true); //TODO change lng var
470 $this->table->doDelete(true);
471 } else {
472 $this->table->doDelete(false);
473 }
474
475 $this->ctrl->redirectByClass("ildcltablelistgui", "listtables");
476 }

References ilUtil\sendFailure().

+ Here is the call graph for this function:

◆ doTableSwitch()

ilDclTableEditGUI::doTableSwitch ( )

Definition at line 320 of file class.ilDclTableEditGUI.php.

321 {
322 $this->ctrl->setParameter($this, "table_id", $_POST['table_id']);
323 $this->ctrl->redirect($this, "edit");
324 }
$_POST["username"]

References $_POST.

◆ edit()

ilDclTableEditGUI::edit ( )

create field edit form

Definition at line 119 of file class.ilDclTableEditGUI.php.

120 {
121 if (!$this->table_id) {
122 $this->ctrl->redirectByClass("ildclfieldeditgui", "listFields");
123
124 return;
125 } else {
126 $this->table = ilDclCache::getTableCache($this->table_id);
127 }
128 $this->initForm("edit");
129 $this->getValues();
130 $this->tpl->setContent($this->form->getHTML());
131 }

References ilDclCache\getTableCache(), getValues(), and initForm().

+ Here is the call graph for this function:

◆ executeCommand()

ilDclTableEditGUI::executeCommand ( )

execute command

Definition at line 88 of file class.ilDclTableEditGUI.php.

89 {
90 $cmd = $this->ctrl->getCmd();
91
92 switch ($cmd) {
93 case 'update':
94 $this->save("update");
95 break;
96 default:
97 $this->$cmd();
98 break;
99 }
100
101 return true;
102 }
save($a_mode="create")
save

References save().

+ Here is the call graph for this function:

◆ getStandardValues()

ilDclTableEditGUI::getStandardValues ( )

getStandardValues

Definition at line 170 of file class.ilDclTableEditGUI.php.

171 {
172 $values = array(
173 'title' => "",
174 'add_perm' => 1,
175 'edit_perm' => 1,
176 'edit_perm_mode' => 'own',
177 'delete_perm_mode' => 'own',
178 'delete_perm' => 1,
179 'edit_by_owner' => 1,
180 'export_enabled' => 0,
181 'import_enabled' => 0,
182 'limited' => 0,
183 'limit_start' => null,
184 'limit_end' => null,
185 );
186 $this->form->setValuesByArray($values);
187 }

Referenced by create().

+ Here is the caller graph for this function:

◆ getValues()

ilDclTableEditGUI::getValues ( )

getFieldValues

Definition at line 137 of file class.ilDclTableEditGUI.php.

138 {
139 $values = array(
140 'title' => $this->table->getTitle(),
141 'add_perm' => (int) $this->table->getAddPerm(),
142 'edit_perm' => (int) $this->table->getEditPerm(),
143 'edit_perm_mode' => $this->table->getEditByOwner() ? 'own' : 'all',
144 'delete_perm' => (int) $this->table->getDeletePerm(),
145 'delete_perm_mode' => $this->table->getDeleteByOwner() ? 'own' : 'all',
146 'export_enabled' => $this->table->getExportEnabled(),
147 'import_enabled' => $this->table->getImportEnabled(),
148 'limited' => $this->table->getLimited(),
149 'limit_start' => substr($this->table->getLimitStart(), 0, 10) . " " . substr($this->table->getLimitStart(), -8),
150 'limit_end' => substr($this->table->getLimitEnd(), 0, 10) . " " . substr($this->table->getLimitEnd(), -8),
151 'default_sort_field' => $this->table->getDefaultSortField(),
152 'default_sort_field_order' => $this->table->getDefaultSortFieldOrder(),
153 'description' => $this->table->getDescription(),
154 'view_own_records_perm' => $this->table->getViewOwnRecordsPerm(),
155 'save_confirmation' => $this->table->getSaveConfirmation(),
156 );
157 if (!$this->table->getLimitStart()) {
158 $values['limit_start'] = null;
159 }
160 if (!$this->table->getLimitEnd()) {
161 $values['limit_end'] = null;
162 }
163 $this->form->setValuesByArray($values);
164 }

Referenced by edit().

+ Here is the caller graph for this function:

◆ initForm()

ilDclTableEditGUI::initForm (   $a_mode = "create")

initEditCustomForm

Parameters
string$a_mode

Definition at line 204 of file class.ilDclTableEditGUI.php.

205 {
206 $this->form = new ilPropertyFormGUI();
207
208 $item = new ilTextInputGUI($this->lng->txt('title'), 'title');
209 $item->setRequired(true);
210 $this->form->addItem($item);
211
212 // Show default order field, direction and tableswitcher only in edit mode, because table id is not yet given and there are no fields to select
213 if ($a_mode != 'create') {
214 $this->createTableSwitcher();
215
216 $item = new ilSelectInputGUI($this->lng->txt('dcl_default_sort_field'), 'default_sort_field');
217 $item->setInfo($this->lng->txt('dcl_default_sort_field_desc'));
218 $fields = array_filter($this->table->getFields(), function (ilDclBaseFieldModel $field) {
219 return !is_null($field->getRecordQuerySortObject());
220 });
221 $options = array(0 => $this->lng->txt('dcl_please_select'));
222 foreach ($fields as $field) {
223 if ($field->getId() == 'comments') {
224 continue;
225 }
226 $options[$field->getId()] = $field->getTitle();
227 }
228 $item->setOptions($options);
229 $this->form->addItem($item);
230
231 $item = new ilSelectInputGUI($this->lng->txt('dcl_default_sort_field_order'), 'default_sort_field_order');
232 $options = array('asc' => $this->lng->txt('dcl_asc'), 'desc' => $this->lng->txt('dcl_desc'));
233 $item->setOptions($options);
234 $this->form->addItem($item);
235 }
236
237 $item = new ilTextAreaInputGUI($this->lng->txt('additional_info'), 'description');
238 $item->setUseRte(true);
239 $item->setInfo($this->lng->txt('dcl_additional_info_desc'));
240 // $item->setRTESupport($this->table->getId(), 'dcl', 'table_settings');
241 $item->setRteTagSet('mini');
242 $this->form->addItem($item);
243
245 $section->setTitle($this->lng->txt('dcl_permissions_form'));
246 $this->form->addItem($section);
247
248 $item = new ilCustomInputGUI();
249 $item->setHtml($this->lng->txt('dcl_table_info'));
250 $item->setTitle($this->lng->txt('dcl_table_info_title'));
251 $this->form->addItem($item);
252
253 $item = new ilCheckboxInputGUI($this->lng->txt('dcl_add_perm'), 'add_perm');
254 $item->setInfo($this->lng->txt("dcl_add_perm_desc"));
255 $this->form->addItem($item);
256
257 $item = new ilCheckboxInputGUI($this->lng->txt('dcl_save_confirmation'), 'save_confirmation');
258 $item->setInfo($this->lng->txt('dcl_save_confirmation_desc'));
259 $this->form->addItem($item);
260
261 $item = new ilCheckboxInputGUI($this->lng->txt('dcl_edit_perm'), 'edit_perm');
262 // $item->setInfo($this->lng->txt("dcl_edit_perm_info"));
263 $this->form->addItem($item);
264
265 $radios = new ilRadioGroupInputGUI('', 'edit_perm_mode');
266 $radios->addOption(new ilRadioOption($this->lng->txt('dcl_all_entries'), 'all'));
267 $radios->addOption(new ilRadioOption($this->lng->txt('dcl_own_entries'), 'own'));
268 $item->addSubItem($radios);
269
270 $item = new ilCheckboxInputGUI($this->lng->txt('dcl_delete_perm'), 'delete_perm');
271 // $item->setInfo($this->lng->txt("dcl_delete_perm_info"));
272 $this->form->addItem($item);
273
274 $radios = new ilRadioGroupInputGUI('', 'delete_perm_mode');
275 $radios->addOption(new ilRadioOption($this->lng->txt('dcl_all_entries'), 'all'));
276 $radios->addOption(new ilRadioOption($this->lng->txt('dcl_own_entries'), 'own'));
277 $item->addSubItem($radios);
278
279 $item = new ilCheckboxInputGUI($this->lng->txt('dcl_view_own_records_perm'), 'view_own_records_perm');
280 // $item->setInfo($this->lng->txt("dcl_edit_by_owner_info"));
281 $this->form->addItem($item);
282
283 $item = new ilCheckboxInputGUI($this->lng->txt('dcl_export_enabled'), 'export_enabled');
284 $item->setInfo($this->lng->txt('dcl_export_enabled_desc'));
285 $this->form->addItem($item);
286
287 $item = new ilCheckboxInputGUI($this->lng->txt('dcl_import_enabled'), 'import_enabled');
288 $item->setInfo($this->lng->txt('dcl_import_enabled_desc'));
289 $this->form->addItem($item);
290
291 $item = new ilCheckboxInputGUI($this->lng->txt('dcl_limited'), 'limited');
292 $sitem1 = new ilDateTimeInputGUI($this->lng->txt('dcl_limit_start'), 'limit_start');
293 $sitem1->setShowTime(true);
294 $sitem2 = new ilDateTimeInputGUI($this->lng->txt('dcl_limit_end'), 'limit_end');
295 $sitem2->setShowTime(true);
296 $item->setInfo($this->lng->txt("dcl_limited_desc"));
297 $item->addSubItem($sitem1);
298 $item->addSubItem($sitem2);
299 $this->form->addItem($item);
300
301 if ($a_mode == "edit") {
302 $this->form->addCommandButton('update', $this->lng->txt('dcl_table_' . $a_mode));
303 } else {
304 $this->form->addCommandButton('save', $this->lng->txt('dcl_table_' . $a_mode));
305 }
306
307 $this->form->addCommandButton('cancel', $this->lng->txt('cancel'));
308 $this->form->setFormAction($this->ctrl->getFormAction($this, $a_mode));
309 if ($a_mode == "edit") {
310 $this->form->setTitle($this->lng->txt('dcl_edit_table'));
311 } else {
312 $this->form->setTitle($this->lng->txt('dcl_new_table'));
313 }
314 }
$section
Definition: Utf8Test.php:83
This class represents a checkbox property in a property form.
This class represents a custom property in a property form.
This class represents a date/time property in a property form.
Class ilDclBaseFieldModel.
getRecordQuerySortObject($direction="asc", $sort_by_status=false)
Returns a query-object for building the record-loader-sql-query.
This class represents a section header in a property form.
This class represents a property form user interface.
This class represents a property in a property form.
This class represents an option in a radio group.
This class represents a text area property in a property form.
This class represents a text property in a property form.

References $section, createTableSwitcher(), ilDclBaseFieldModel\getId(), ilDclBaseFieldModel\getRecordQuerySortObject(), and ilDclBaseFieldModel\getTitle().

Referenced by create(), edit(), and save().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ save()

ilDclTableEditGUI::save (   $a_mode = "create")

save

Parameters
string$a_modevalues: create | edit

Definition at line 332 of file class.ilDclTableEditGUI.php.

333 {
334 global $DIC;
335 $ilTabs = $DIC['ilTabs'];
336
337 if (!ilObjDataCollectionAccess::checkActionForObjId('write', $this->obj_id)) {
338 $this->accessDenied();
339
340 return;
341 }
342
343 $ilTabs->activateTab("id_fields");
344 $this->initForm($a_mode);
345
346 if ($this->checkInput($a_mode)) {
347 if ($a_mode != "update") {
348 $this->table = ilDclCache::getTableCache();
349 } elseif ($this->table_id) {
350 $this->table = ilDclCache::getTableCache($this->table_id);
351 } else {
352 $this->ctrl->redirectByClass("ildclfieldeditgui", "listFields");
353 }
354
355 $this->table->setTitle($this->form->getInput("title"));
356 $this->table->setObjId($this->obj_id);
357 $this->table->setSaveConfirmation((bool) $this->form->getInput('save_confirmation'));
358 $this->table->setAddPerm((bool) $this->form->getInput("add_perm"));
359 $this->table->setEditPerm((bool) $this->form->getInput("edit_perm"));
360 if ($this->table->getEditPerm()) {
361 $edit_by_owner = ($this->form->getInput('edit_perm_mode') == 'own');
362 $this->table->setEditByOwner($edit_by_owner);
363 }
364 $this->table->setDeletePerm((bool) $this->form->getInput("delete_perm"));
365 if ($this->table->getDeletePerm()) {
366 $delete_by_owner = ($this->form->getInput('delete_perm_mode') == 'own');
367 $this->table->setDeleteByOwner($delete_by_owner);
368 }
369 $this->table->setViewOwnRecordsPerm($this->form->getInput('view_own_records_perm'));
370 $this->table->setExportEnabled($this->form->getInput("export_enabled"));
371 $this->table->setImportEnabled($this->form->getInput("import_enabled"));
372 $this->table->setDefaultSortField($this->form->getInput("default_sort_field"));
373 $this->table->setDefaultSortFieldOrder($this->form->getInput("default_sort_field_order"));
374 $this->table->setLimited($this->form->getInput("limited"));
375 $this->table->setDescription($this->form->getInput('description'));
376 $limit_start = $this->form->getInput("limit_start");
377 $limit_end = $this->form->getInput("limit_end");
378 $this->table->setLimitStart($limit_start);
379 $this->table->setLimitEnd($limit_end);
380 if ($a_mode == "update") {
381 $this->table->doUpdate();
382 ilUtil::sendSuccess($this->lng->txt("dcl_msg_table_edited"), true);
383 $this->ctrl->redirectByClass("ildcltableeditgui", "edit");
384 } else {
385 $this->table->doCreate();
386 ilUtil::sendSuccess($this->lng->txt("dcl_msg_table_created"), true);
387 $this->ctrl->setParameterByClass("ildclfieldlistgui", "table_id", $this->table->getId());
388 $this->ctrl->redirectByClass("ildclfieldlistgui", "listFields");
389 }
390 } else {
391 $this->form->setValuesByPost();
392 $this->tpl->setContent($this->form->getHTML());
393 }
394 }
checkInput($a_mode)
Custom checks for the form input.
static checkActionForObjId($action, $obj_id)

References $DIC, accessDenied(), ilObjDataCollectionAccess\checkActionForObjId(), checkInput(), ilDclCache\getTableCache(), and initForm().

Referenced by executeCommand().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

Field Documentation

◆ $ctrl

ilDclTableEditGUI::$ctrl
protected

Definition at line 34 of file class.ilDclTableEditGUI.php.

◆ $form

ilDclTableEditGUI::$form
protected

Definition at line 46 of file class.ilDclTableEditGUI.php.

◆ $lng

ilDclTableEditGUI::$lng
protected

Definition at line 30 of file class.ilDclTableEditGUI.php.

Referenced by __construct().

◆ $table

ilDclTableEditGUI::$table
private

Definition at line 26 of file class.ilDclTableEditGUI.php.

Referenced by createTableSwitcher().

◆ $table_id

ilDclTableEditGUI::$table_id
private

Definition at line 22 of file class.ilDclTableEditGUI.php.

◆ $toolbar

ilDclTableEditGUI::$toolbar
protected

Definition at line 42 of file class.ilDclTableEditGUI.php.

Referenced by __construct().

◆ $tpl

ilDclTableEditGUI::$tpl
protected

Definition at line 38 of file class.ilDclTableEditGUI.php.

Referenced by __construct().


The documentation for this class was generated from the following file: