ILIAS  release_5-4 Revision v5.4.26-12-gabc799a52e6
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.

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

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  }
global $DIC
Definition: saml.php:7
$_GET["client_id"]
static getTableCache($table_id=0)
global $ilCtrl
Definition: ilias.php:18
static sendFailure($a_info="", $a_keep=false)
Send Failure Message to Screen.
+ Here is the call graph for this function:

Member Function Documentation

◆ accessDenied()

ilDclTableEditGUI::accessDenied ( )

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

Referenced by save().

428  {
429  $this->tpl->setContent("Access denied.");
430  }
+ 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 455 of file class.ilDclTableEditGUI.php.

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

◆ checkAccess()

ilDclTableEditGUI::checkAccess ( )
protected
Returns
bool

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

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

Referenced by __construct().

481  {
482  $ref_id = $this->parent_object->getDataCollectionObject()->getRefId();
483  return $this->table_id ? ilObjDataCollectionAccess::hasAccessToEditTable($ref_id, $this->table_id) : ilObjDataCollectionAccess::hasWriteAccess($ref_id);
484  }
static hasAccessToEditTable($ref_id, $table_id)
Class ilObjDataCollectionAccess.
+ 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 401 of file class.ilDclTableEditGUI.php.

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

Referenced by save().

402  {
403  $return = $this->form->checkInput();
404 
405  // Title of table must be unique in one DC
406  if ($a_mode == 'create') {
407  if ($title = $this->form->getInput('title')) {
408  if (ilObjDataCollection::_hasTableByTitle($title, $this->obj_id)) {
409  $inputObj = $this->form->getItemByPostVar('title');
410  $inputObj->setAlert($this->lng->txt("dcl_table_title_unique"));
411  $return = false;
412  }
413  }
414  }
415 
416  if (!$return) {
417  ilUtil::sendFailure($this->lng->txt("form_input_not_valid"));
418  }
419 
420  return $return;
421  }
static _hasTableByTitle($title, $obj_id)
Checks if a DataCollection has a table with a given title.
static sendFailure($a_info="", $a_keep=false)
Send Failure Message to Screen.
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ confirmDelete()

ilDclTableEditGUI::confirmDelete ( )

confirmDelete

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

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

◆ create()

ilDclTableEditGUI::create ( )

create table add form

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

References getStandardValues(), and initForm().

107  {
108  $this->initForm();
109  $this->getStandardValues();
110  $this->tpl->setContent($this->form->getHTML());
111  }
initForm($a_mode="create")
initEditCustomForm
getStandardValues()
getStandardValues
+ Here is the call graph for this function:

◆ createTableSwitcher()

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

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

References PHPMailer\PHPMailer\$options, $table, and ilSubmitButton\getInstance().

Referenced by initForm().

493  {
494  // Show tables
495  $tables = $this->parent_object->getDataCollectionObject()->getTables();
496 
497  foreach ($tables as $table) {
498  $options[$table->getId()] = $table->getTitle();
499  }
500  include_once './Services/Form/classes/class.ilSelectInputGUI.php';
501  $table_selection = new ilSelectInputGUI('', 'table_id');
502  $table_selection->setOptions($options);
503  $table_selection->setValue($this->table->getId());
504 
505  $this->toolbar->setFormAction($this->ctrl->getFormActionByClass("ilDclTableEditGUI", "doTableSwitch"));
506  $this->toolbar->addText($this->lng->txt("dcl_select"));
507  $this->toolbar->addInputItem($table_selection);
508  $button = ilSubmitButton::getInstance();
509  $button->setCommand("doTableSwitch");
510  $button->setCaption('change');
511  $this->toolbar->addButtonInstance($button);
512 
513  return $options;
514  }
This class represents a selection list property in a property form.
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ delete()

ilDclTableEditGUI::delete ( )

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

References ilUtil\sendFailure().

465  {
466  if (count($this->table->getCollectionObject()->getTables()) < 2) {
467  ilUtil::sendFailure($this->lng->txt("dcl_cant_delete_last_table"), true); //TODO change lng var
468  $this->table->doDelete(true);
469  } else {
470  $this->table->doDelete(false);
471  }
472 
473  $this->ctrl->redirectByClass("ildcltablelistgui", "listtables");
474  }
static sendFailure($a_info="", $a_keep=false)
Send Failure Message to Screen.
+ Here is the call graph for this function:

◆ doTableSwitch()

ilDclTableEditGUI::doTableSwitch ( )

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

References $_POST.

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

◆ edit()

ilDclTableEditGUI::edit ( )

create field edit form

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

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

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  }
initForm($a_mode="create")
initEditCustomForm
static getTableCache($table_id=0)
+ Here is the call graph for this function:

◆ executeCommand()

ilDclTableEditGUI::executeCommand ( )

execute command

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

References save().

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
+ Here is the call graph for this function:

◆ getStandardValues()

ilDclTableEditGUI::getStandardValues ( )

getStandardValues

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

References $values.

Referenced by create().

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  }
$values
+ Here is the caller graph for this function:

◆ getValues()

ilDclTableEditGUI::getValues ( )

getFieldValues

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

References $values.

Referenced by edit().

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  }
$values
+ 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.

References PHPMailer\PHPMailer\$options, $section, createTableSwitcher(), ilFormPropertyGUI\setInfo(), ilFormPropertyGUI\setRequired(), ilDateTimeInputGUI\setShowTime(), and ilTextAreaInputGUI\setUseRte().

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

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  }
This class represents an option in a radio group.
This class represents a selection list property in a property form.
This class represents a property form user interface.
This class represents a section header in a property form.
setUseRte($a_usert, $version='')
Set Use Rich Text Editing.
This class represents a checkbox property in a property form.
This class represents a date/time property in a property form.
setInfo($a_info)
Set Information Text.
$section
Definition: Utf8Test.php:83
This class represents a property in a property form.
This class represents a text property in a property form.
This class represents a custom property in a property form.
This class represents a text area property in a property form.
setRequired($a_required)
Set Required.
setShowTime($a_showtime)
Set Show Time Information.
+ 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 329 of file class.ilDclTableEditGUI.php.

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

Referenced by executeCommand().

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