ILIAS  release_5-3 Revision v5.3.23-19-g915713cf615
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 $locator->addItem($this->table->getTitle(), $this->ctrl->getLinkTarget($this, 'edit'));
74 $this->tpl->setLocator();
75
76 if (!$this->checkAccess()) {
77 ilUtil::sendFailure($this->lng->txt('permission_denied'), true);
78 $this->ctrl->redirectByClass('ildclrecordlistgui', 'listRecords');
79 }
80 }
$_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
global $DIC
Definition: saml.php:7

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 424 of file class.ilDclTableEditGUI.php.

425 {
426 $this->tpl->setContent("Access denied.");
427 }

Referenced by save().

+ Here is the caller graph for this function:

◆ cancel()

ilDclTableEditGUI::cancel ( )

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

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

◆ cancelDelete()

ilDclTableEditGUI::cancelDelete ( )

cancelDelete

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

453 {
454 $this->ctrl->redirectByClass("ilDclTableListGUI", "listTables");
455 }

◆ checkAccess()

ilDclTableEditGUI::checkAccess ( )
protected
Returns
bool

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

477 {
478 $ref_id = $this->parent_object->getDataCollectionObject()->getRefId();
479 return $this->table_id ? ilObjDataCollectionAccess::hasAccessToEditTable($ref_id, $this->table_id) : ilObjDataCollectionAccess::hasWriteAccess($ref_id);
480 }
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 398 of file class.ilDclTableEditGUI.php.

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

References $title, 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 433 of file class.ilDclTableEditGUI.php.

434 {
435 include_once './Services/Utilities/classes/class.ilConfirmationGUI.php';
436 $conf = new ilConfirmationGUI();
437 $conf->setFormAction($this->ctrl->getFormAction($this));
438 $conf->setHeaderText($this->lng->txt('dcl_confirm_delete_table'));
439
440 $conf->addItem('table', (int) $this->table->getId(), $this->table->getTitle());
441
442 $conf->setConfirm($this->lng->txt('delete'), 'delete');
443 $conf->setCancel($this->lng->txt('cancel'), 'cancelDelete');
444
445 $this->tpl->setContent($conf->getHTML());
446 }
Confirmation screen class.

◆ create()

ilDclTableEditGUI::create ( )

create table add form

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

107 {
108 $this->initForm();
109 $this->getStandardValues();
110 $this->tpl->setContent($this->form->getHTML());
111 }
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 488 of file class.ilDclTableEditGUI.php.

489 {
490 // Show tables
491 $tables = $this->parent_object->getDataCollectionObject()->getTables();
492
493 foreach ($tables as $table) {
494 $options[$table->getId()] = $table->getTitle();
495 }
496 include_once './Services/Form/classes/class.ilSelectInputGUI.php';
497 $table_selection = new ilSelectInputGUI('', 'table_id');
498 $table_selection->setOptions($options);
499 $table_selection->setValue($this->table->getId());
500
501 $this->toolbar->setFormAction($this->ctrl->getFormActionByClass("ilDclTableEditGUI", "doTableSwitch"));
502 $this->toolbar->addText($this->lng->txt("dcl_select"));
503 $this->toolbar->addInputItem($table_selection);
504 $button = ilSubmitButton::getInstance();
505 $button->setCommand("doTableSwitch");
506 $button->setCaption('change');
507 $this->toolbar->addButtonInstance($button);
508
509 return $options;
510 }
if(!isset( $_REQUEST[ 'ReturnTo'])) if(!isset($_REQUEST['AuthId'])) $options
Definition: as_login.php:20
This class represents a selection list property in a property form.
static getInstance()
Factory.

References $options, $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 460 of file class.ilDclTableEditGUI.php.

461 {
462 if (count($this->table->getCollectionObject()->getTables()) < 2) {
463 ilUtil::sendFailure($this->lng->txt("dcl_cant_delete_last_table"), true); //TODO change lng var
464 $this->table->doDelete(true);
465 } else {
466 $this->table->doDelete(false);
467 }
468
469 $this->ctrl->redirectByClass("ildcltablelistgui", "listtables");
470 }

References ilUtil\sendFailure().

+ Here is the call graph for this function:

◆ doTableSwitch()

ilDclTableEditGUI::doTableSwitch ( )

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

317 {
318 $this->ctrl->setParameter($this, "table_id", $_POST['table_id']);
319 $this->ctrl->redirect($this, "edit");
320 }
$_POST["username"]

References $_POST.

◆ edit()

ilDclTableEditGUI::edit ( )

create field edit form

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

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

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

+ Here is the call graph for this function:

◆ executeCommand()

ilDclTableEditGUI::executeCommand ( )

execute command

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

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

References save().

+ Here is the call graph for this function:

◆ getStandardValues()

ilDclTableEditGUI::getStandardValues ( )

getStandardValues

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

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

Referenced by create().

+ Here is the caller graph for this function:

◆ getValues()

ilDclTableEditGUI::getValues ( )

getFieldValues

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

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

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 202 of file class.ilDclTableEditGUI.php.

203 {
204 include_once("./Services/Form/classes/class.ilPropertyFormGUI.php");
205 $this->form = new ilPropertyFormGUI();
206
207 $item = new ilTextInputGUI($this->lng->txt('title'), 'title');
208 $item->setRequired(true);
209 $this->form->addItem($item);
210
211 // 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
212 if ($a_mode != 'create') {
213 $this->createTableSwitcher();
214
215 $item = new ilSelectInputGUI($this->lng->txt('dcl_default_sort_field'), 'default_sort_field');
216 $item->setInfo($this->lng->txt('dcl_default_sort_field_desc'));
217 $fields = $this->table->getFields();
218 $options = array( 0 => $this->lng->txt('dcl_please_select') );
219 foreach ($fields as $field) {
220 if ($field->getId() == 'comments') {
221 continue;
222 }
223 $options[$field->getId()] = $field->getTitle();
224 }
225 $item->setOptions($options);
226 $this->form->addItem($item);
227
228 $item = new ilSelectInputGUI($this->lng->txt('dcl_default_sort_field_order'), 'default_sort_field_order');
229 $options = array( 'asc' => $this->lng->txt('dcl_asc'), 'desc' => $this->lng->txt('dcl_desc') );
230 $item->setOptions($options);
231 $this->form->addItem($item);
232 }
233
234 $item = new ilTextAreaInputGUI($this->lng->txt('additional_info'), 'description');
235 $item->setUseRte(true);
236 $item->setInfo($this->lng->txt('dcl_additional_info_desc'));
237 // $item->setRTESupport($this->table->getId(), 'dcl', 'table_settings');
238 $item->setRteTagSet('mini');
239 $this->form->addItem($item);
240
242 $section->setTitle($this->lng->txt('dcl_permissions_form'));
243 $this->form->addItem($section);
244
245 $item = new ilCustomInputGUI();
246 $item->setHtml($this->lng->txt('dcl_table_info'));
247 $item->setTitle($this->lng->txt('dcl_table_info_title'));
248 $this->form->addItem($item);
249
250 $item = new ilCheckboxInputGUI($this->lng->txt('dcl_add_perm'), 'add_perm');
251 $item->setInfo($this->lng->txt("dcl_add_perm_desc"));
252 $this->form->addItem($item);
253
254 $item = new ilCheckboxInputGUI($this->lng->txt('dcl_save_confirmation'), 'save_confirmation');
255 $item->setInfo($this->lng->txt('dcl_save_confirmation_desc'));
256 $this->form->addItem($item);
257
258 $item = new ilCheckboxInputGUI($this->lng->txt('dcl_edit_perm'), 'edit_perm');
259 // $item->setInfo($this->lng->txt("dcl_edit_perm_info"));
260 $this->form->addItem($item);
261
262 $radios = new ilRadioGroupInputGUI('', 'edit_perm_mode');
263 $radios->addOption(new ilRadioOption($this->lng->txt('dcl_all_entries'), 'all'));
264 $radios->addOption(new ilRadioOption($this->lng->txt('dcl_own_entries'), 'own'));
265 $item->addSubItem($radios);
266
267 $item = new ilCheckboxInputGUI($this->lng->txt('dcl_delete_perm'), 'delete_perm');
268 // $item->setInfo($this->lng->txt("dcl_delete_perm_info"));
269 $this->form->addItem($item);
270
271 $radios = new ilRadioGroupInputGUI('', 'delete_perm_mode');
272 $radios->addOption(new ilRadioOption($this->lng->txt('dcl_all_entries'), 'all'));
273 $radios->addOption(new ilRadioOption($this->lng->txt('dcl_own_entries'), 'own'));
274 $item->addSubItem($radios);
275
276 $item = new ilCheckboxInputGUI($this->lng->txt('dcl_view_own_records_perm'), 'view_own_records_perm');
277 // $item->setInfo($this->lng->txt("dcl_edit_by_owner_info"));
278 $this->form->addItem($item);
279
280 $item = new ilCheckboxInputGUI($this->lng->txt('dcl_export_enabled'), 'export_enabled');
281 $item->setInfo($this->lng->txt('dcl_export_enabled_desc'));
282 $this->form->addItem($item);
283
284 $item = new ilCheckboxInputGUI($this->lng->txt('dcl_import_enabled'), 'import_enabled');
285 $item->setInfo($this->lng->txt('dcl_import_enabled_desc'));
286 $this->form->addItem($item);
287
288 $item = new ilCheckboxInputGUI($this->lng->txt('dcl_limited'), 'limited');
289 $sitem1 = new ilDateTimeInputGUI($this->lng->txt('dcl_limit_start'), 'limit_start');
290 $sitem1->setShowTime(true);
291 $sitem2 = new ilDateTimeInputGUI($this->lng->txt('dcl_limit_end'), 'limit_end');
292 $sitem2->setShowTime(true);
293 $item->setInfo($this->lng->txt("dcl_limited_desc"));
294 $item->addSubItem($sitem1);
295 $item->addSubItem($sitem2);
296 $this->form->addItem($item);
297
298 if ($a_mode == "edit") {
299 $this->form->addCommandButton('update', $this->lng->txt('dcl_table_' . $a_mode));
300 } else {
301 $this->form->addCommandButton('save', $this->lng->txt('dcl_table_' . $a_mode));
302 }
303
304 $this->form->addCommandButton('cancel', $this->lng->txt('cancel'));
305 $this->form->setFormAction($this->ctrl->getFormAction($this, $a_mode));
306 if ($a_mode == "edit") {
307 $this->form->setTitle($this->lng->txt('dcl_edit_table'));
308 } else {
309 $this->form->setTitle($this->lng->txt('dcl_new_table'));
310 }
311 }
$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.
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 $options, $section, and createTableSwitcher().

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 327 of file class.ilDclTableEditGUI.php.

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

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

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 35 of file class.ilDclTableEditGUI.php.

◆ $form

ilDclTableEditGUI::$form
protected

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

◆ $lng

ilDclTableEditGUI::$lng
protected

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

Referenced by __construct().

◆ $table

ilDclTableEditGUI::$table
private

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

Referenced by createTableSwitcher().

◆ $table_id

ilDclTableEditGUI::$table_id
private

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

◆ $toolbar

ilDclTableEditGUI::$toolbar
protected

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

Referenced by __construct().

◆ $tpl

ilDclTableEditGUI::$tpl
protected

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

Referenced by __construct().


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