ILIAS  release_5-0 Revision 5.0.0-1144-gc4397b1f870
All Data Structures Namespaces Files Functions Variables Modules Pages
ilDataCollectionTableEditGUI Class Reference

Class ilDataCollectionField. More...

+ Collaboration diagram for ilDataCollectionTableEditGUI:

Public Member Functions

 __construct (ilObjDataCollectionGUI $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...
 
 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...
 
 checkPermission ()
 

Protected Attributes

 $lng
 
 $ctrl
 
 $tpl
 

Private Attributes

 $table_id
 
 $table
 

Detailed Description

Constructor & Destructor Documentation

◆ __construct()

ilDataCollectionTableEditGUI::__construct ( ilObjDataCollectionGUI  $a_parent_obj)

Constructor.

Parameters
ilObjDataCollectionGUI$a_parent_obj

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

References $_GET, $ilCtrl, $lng, $tpl, checkPermission(), ilDataCollectionCache\getTableCache(), and ilUtil\sendFailure().

47  {
48  global $ilCtrl, $lng, $tpl;
49 
50  $this->ctrl = $ilCtrl;
51  $this->lng = $lng;
52  $this->tpl = $tpl;
53  $this->parent_object = $a_parent_obj;
54  $this->obj_id = $a_parent_obj->obj_id;
55  $this->table_id = $_GET['table_id'];
56  $this->table = ilDataCollectionCache::getTableCache($this->table_id);
57  if (! $this->checkPermission()) {
58  ilUtil::sendFailure($this->lng->txt('permission_denied'), true);
59  $this->ctrl->redirectByClass('ildatacollectionrecordlistgui', 'listRecords');
60  }
61  }
$_GET["client_id"]
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()

ilDataCollectionTableEditGUI::accessDenied ( )

Definition at line 366 of file class.ilDataCollectionTableEditGUI.php.

Referenced by save().

366  {
367  $this->tpl->setContent("Access denied.");
368  }
+ Here is the caller graph for this function:

◆ cancel()

ilDataCollectionTableEditGUI::cancel ( )

Definition at line 165 of file class.ilDataCollectionTableEditGUI.php.

165  {
166  $this->ctrl->redirectByClass("ilDataCollectionFieldListGUI", "listFields");
167  }

◆ cancelDelete()

ilDataCollectionTableEditGUI::cancelDelete ( )

cancelDelete

Definition at line 392 of file class.ilDataCollectionTableEditGUI.php.

392  {
393  $this->ctrl->redirectByClass("ildatacollectionfieldlistgui", "listFields");
394  }

◆ checkInput()

ilDataCollectionTableEditGUI::checkInput (   $a_mode)
protected

Custom checks for the form input.

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

Definition at line 341 of file class.ilDataCollectionTableEditGUI.php.

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

Referenced by save().

341  {
342  $return = $this->form->checkInput();
343 
344  // Title of table must be unique in one DC
345  if ($a_mode == 'create') {
346  if ($title = $this->form->getInput('title')) {
347  if (ilObjDataCollection::_hasTableByTitle($title, $this->obj_id)) {
348  $inputObj = $this->form->getItemByPostVar('title');
349  $inputObj->setAlert($this->lng->txt("dcl_table_title_unique"));
350  $return = false;
351  }
352  }
353  }
354 
355  if (! $return) {
356  ilUtil::sendFailure($this->lng->txt("form_input_not_valid"));
357  }
358 
359  return $return;
360  }
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:

◆ checkPermission()

ilDataCollectionTableEditGUI::checkPermission ( )
protected
Returns
bool

Definition at line 416 of file class.ilDataCollectionTableEditGUI.php.

References $ref_id, and ilObjDataCollection\_hasWriteAccess().

Referenced by __construct().

416  {
417  $ref_id = $this->parent_object->getDataCollectionObject()->getRefId();
418 
420  }
$ref_id
Definition: sahs_server.php:39
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ confirmDelete()

ilDataCollectionTableEditGUI::confirmDelete ( )

confirmDelete

Definition at line 374 of file class.ilDataCollectionTableEditGUI.php.

374  {
375  include_once './Services/Utilities/classes/class.ilConfirmationGUI.php';
376  $conf = new ilConfirmationGUI();
377  $conf->setFormAction($this->ctrl->getFormAction($this));
378  $conf->setHeaderText($this->lng->txt('dcl_confirm_delete_table'));
379 
380  $conf->addItem('table', (int)$this->table->getId(), $this->table->getTitle());
381 
382  $conf->setConfirm($this->lng->txt('delete'), 'delete');
383  $conf->setCancel($this->lng->txt('cancel'), 'cancelDelete');
384 
385  $this->tpl->setContent($conf->getHTML());
386  }
Confirmation screen class.

◆ create()

ilDataCollectionTableEditGUI::create ( )

create table add form

Definition at line 87 of file class.ilDataCollectionTableEditGUI.php.

References getStandardValues(), and initForm().

87  {
88  $this->initForm();
89  $this->getStandardValues();
90  $this->tpl->setContent($this->form->getHTML());
91  }
initForm($a_mode="create")
initEditCustomForm
+ Here is the call graph for this function:

◆ delete()

ilDataCollectionTableEditGUI::delete ( )

Definition at line 400 of file class.ilDataCollectionTableEditGUI.php.

References ilUtil\sendFailure().

400  {
401  $mainTableId = $this->table->getCollectionObject()->getMainTableId();
402  if ($mainTableId == $this->table->getId()) {
403  ilUtil::sendFailure($this->lng->txt("dcl_cant_delete_main_table"), true);
404  } else {
405  $this->ctrl->setParameterByClass("ildatacollectionfieldlistgui", "table_id", $mainTableId);
406  }
407 
408  $this->table->doDelete();
409  $this->ctrl->redirectByClass("ildatacollectionfieldlistgui", "listFields");
410  }
static sendFailure($a_info="", $a_keep=false)
Send Failure Message to Screen.
+ Here is the call graph for this function:

◆ edit()

ilDataCollectionTableEditGUI::edit ( )

create field edit form

Definition at line 97 of file class.ilDataCollectionTableEditGUI.php.

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

97  {
98  if (! $this->table_id) {
99  $this->ctrl->redirectByClass("ildatacollectionfieldeditgui", "listFields");
100 
101  return;
102  } else {
103  $this->table = ilDataCollectionCache::getTableCache($this->table_id);
104  }
105  $this->initForm("edit");
106  $this->getValues();
107  $this->tpl->setContent($this->form->getHTML());
108  }
initForm($a_mode="create")
initEditCustomForm
+ Here is the call graph for this function:

◆ executeCommand()

ilDataCollectionTableEditGUI::executeCommand ( )

execute command

Definition at line 67 of file class.ilDataCollectionTableEditGUI.php.

References $cmd, and save().

67  {
68  $cmd = $this->ctrl->getCmd();
69  $this->tpl->getStandardTemplate();
70 
71  switch ($cmd) {
72  case 'update':
73  $this->save("update");
74  break;
75  default:
76  $this->$cmd();
77  break;
78  }
79 
80  return true;
81  }
$cmd
Definition: sahs_server.php:35
+ Here is the call graph for this function:

◆ getStandardValues()

ilDataCollectionTableEditGUI::getStandardValues ( )

getStandardValues

Definition at line 145 of file class.ilDataCollectionTableEditGUI.php.

Referenced by create().

145  {
146  $values = array(
147  'title' => "",
148  'is_visible' => 1,
149  'add_perm' => 1,
150  'edit_perm' => 1,
151  'delete_perm' => 1,
152  'edit_by_owner' => 1,
153  'export_enabled' => 0,
154  'limited' => 0,
155  'limit_start' => NULL,
156  'limit_end' => NULL
157  );
158  $this->form->setValuesByArray($values);
159  }
+ Here is the caller graph for this function:

◆ getValues()

ilDataCollectionTableEditGUI::getValues ( )

getFieldValues

Definition at line 114 of file class.ilDataCollectionTableEditGUI.php.

Referenced by edit().

114  {
115  $values = array(
116  'title' => $this->table->getTitle(),
117  'add_perm' => $this->table->getAddPerm(),
118  'edit_perm' => $this->table->getEditPerm(),
119  'delete_perm' => $this->table->getDeletePerm(),
120  'edit_by_owner' => $this->table->getEditByOwner(),
121  'export_enabled' => $this->table->getExportEnabled(),
122  'limited' => $this->table->getLimited(),
123  'limit_start' => array( "date" => substr($this->table->getLimitStart(), 0, 10), "time" => substr($this->table->getLimitStart(), - 8) ),
124  'limit_end' => array( "date" => substr($this->table->getLimitEnd(), 0, 10), "time" => substr($this->table->getLimitEnd(), - 8) ),
125  'is_visible' => $this->table->getIsVisible(),
126  'default_sort_field' => $this->table->getDefaultSortField(),
127  'default_sort_field_order' => $this->table->getDefaultSortFieldOrder(),
128  'description' => $this->table->getDescription(),
129  'public_comments' => $this->table->getPublicCommentsEnabled(),
130  'view_own_records_perm' => $this->table->getViewOwnRecordsPerm(),
131  );
132  if (! $this->table->getLimitStart()) {
133  $values['limit_start'] = NULL;
134  }
135  if (! $this->table->getLimitEnd()) {
136  $values['limit_end'] = NULL;
137  }
138  $this->form->setValuesByArray($values);
139  }
+ Here is the caller graph for this function:

◆ initForm()

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

initEditCustomForm

Parameters
string$a_mode

Definition at line 175 of file class.ilDataCollectionTableEditGUI.php.

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

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

175  {
176  include_once("./Services/Form/classes/class.ilPropertyFormGUI.php");
177  $this->form = new ilPropertyFormGUI();
178 
179  $item = new ilTextInputGUI($this->lng->txt('title'), 'title');
180  $item->setRequired(true);
181  $this->form->addItem($item);
182  $item = new ilCheckboxInputGUI($this->lng->txt('dcl_visible'), 'is_visible');
183  $this->form->addItem($item);
184 
185  // Show default order field and direction only in edit mode, because table id is not yet given and there are no fields to select
186  if ($a_mode != 'create') {
187  $item = new ilSelectInputGUI($this->lng->txt('dcl_default_sort_field'), 'default_sort_field');
188  $fields = $this->table->getVisibleFields();
189  $options = array( 0 => $this->lng->txt('dcl_please_select') );
190  foreach ($fields as $field) {
191  $options[$field->getId()] = $field->getTitle();
192  }
193  $item->setOptions($options);
194  $this->form->addItem($item);
195 
196  $item = new ilSelectInputGUI($this->lng->txt('dcl_default_sort_field_order'), 'default_sort_field_order');
197  $options = array( 'asc' => $this->lng->txt('dcl_asc'), 'desc' => $this->lng->txt('dcl_desc') );
198  $item->setOptions($options);
199  $this->form->addItem($item);
200  }
201 
202  $item = new ilTextAreaInputGUI($this->lng->txt('additional_info'), 'description');
203  $item->setUseRte(true);
204  // $item->setRTESupport($this->table->getId(), 'dcl', 'table_settings');
205  $item->setRteTagSet('mini');
206  $this->form->addItem($item);
207 
208  $item = new ilCheckboxInputGUI($this->lng->txt('dcl_public_comments'), 'public_comments');
209  $this->form->addItem($item);
210 
212  $section->setTitle($this->lng->txt('dcl_permissions_form'));
213  $this->form->addItem($section);
214 
215  $item = new ilCustomInputGUI();
216  $item->setHtml($this->lng->txt('dcl_table_info'));
217  $item->setTitle($this->lng->txt('dcl_table_info_title'));
218  $this->form->addItem($item);
219 
220  $item = new ilCheckboxInputGUI($this->lng->txt('dcl_add_perm'), 'add_perm');
221  // $item->setInfo($this->lng->txt("dcl_add_perm_info"));
222  $this->form->addItem($item);
223  $item = new ilCheckboxInputGUI($this->lng->txt('dcl_edit_perm'), 'edit_perm');
224  // $item->setInfo($this->lng->txt("dcl_edit_perm_info"));
225  $this->form->addItem($item);
226  $item = new ilCheckboxInputGUI($this->lng->txt('dcl_delete_perm'), 'delete_perm');
227  // $item->setInfo($this->lng->txt("dcl_delete_perm_info"));
228  $this->form->addItem($item);
229  $item = new ilCheckboxInputGUI($this->lng->txt('dcl_edit_by_owner'), 'edit_by_owner');
230  // $item->setInfo($this->lng->txt("dcl_edit_by_owner_info"));
231  $this->form->addItem($item);
232 
233  $item = new ilCheckboxInputGUI($this->lng->txt('dcl_view_own_records_perm'), 'view_own_records_perm');
234  // $item->setInfo($this->lng->txt("dcl_edit_by_owner_info"));
235  $this->form->addItem($item);
236 
237  $item = new ilCheckboxInputGUI($this->lng->txt('dcl_export_enabled'), 'export_enabled');
238  $this->form->addItem($item);
239 
240  $item = new ilCheckboxInputGUI($this->lng->txt('dcl_limited'), 'limited');
241  $sitem1 = new ilDateTimeInputGUI($this->lng->txt('dcl_limit_start'), 'limit_start');
242  $sitem1->setShowTime(true);
243  $sitem2 = new ilDateTimeInputGUI($this->lng->txt('dcl_limit_end'), 'limit_end');
244  $sitem2->setShowTime(true);
245  // $item->setInfo($this->lng->txt("dcl_limited_info"));
246  $item->addSubItem($sitem1);
247  $item->addSubItem($sitem2);
248  $this->form->addItem($item);
249 
250  if ($a_mode == "edit") {
251  $this->form->addCommandButton('update', $this->lng->txt('dcl_table_' . $a_mode));
252  } else {
253  $this->form->addCommandButton('save', $this->lng->txt('dcl_table_' . $a_mode));
254  }
255 
256  $this->form->addCommandButton('cancel', $this->lng->txt('cancel'));
257  $this->form->setFormAction($this->ctrl->getFormAction($this, $a_mode));
258  if ($a_mode == "edit") {
259  $this->form->setTitle($this->lng->txt('dcl_edit_table'));
260  } else {
261  $this->form->setTitle($this->lng->txt('dcl_new_table'));
262  }
263  }
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.
$section
Definition: Utf8Test.php:84
if(!is_array($argv)) $options
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()

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

save

Parameters
string$a_modevalues: create | edit

Definition at line 271 of file class.ilDataCollectionTableEditGUI.php.

References accessDenied(), ilObjDataCollectionAccess\checkActionForObjId(), checkInput(), ilDataCollectionCache\getTableCache(), initForm(), and ilUtil\sendSuccess().

Referenced by executeCommand().

271  {
272  global $ilTabs;
273 
274  if (! ilObjDataCollectionAccess::checkActionForObjId('write', $this->obj_id)) {
275  $this->accessDenied();
276 
277  return;
278  }
279 
280  $ilTabs->activateTab("id_fields");
281 
282  $this->initForm($a_mode);
283 
284  if ($this->checkInput($a_mode)) {
285  if ($a_mode != "update") {
286  $this->table = ilDataCollectionCache::getTableCache();
287  } elseif ($this->table_id) {
288  $this->table = ilDataCollectionCache::getTableCache($this->table_id);
289  } else {
290  $this->ctrl->redirectByClass("ildatacollectionfieldeditgui", "listFields");
291  }
292 
293  $this->table->setTitle($this->form->getInput("title"));
294  $this->table->setObjId($this->obj_id);
295  $this->table->setIsVisible($this->form->getInput("is_visible"));
296  $this->table->setAddPerm($this->form->getInput("add_perm"));
297  $this->table->setEditPerm($this->form->getInput("edit_perm"));
298  $this->table->setDeletePerm($this->form->getInput("delete_perm"));
299  $this->table->setEditByOwner($this->form->getInput("edit_by_owner"));
300  $this->table->setViewOwnRecordsPerm($this->form->getInput('view_own_records_perm'));
301  $this->table->setExportEnabled($this->form->getInput("export_enabled"));
302  $this->table->setDefaultSortField($this->form->getInput("default_sort_field"));
303  $this->table->setDefaultSortFieldOrder($this->form->getInput("default_sort_field_order"));
304  $this->table->setPublicCommentsEnabled($this->form->getInput('public_comments'));
305  $this->table->setLimited($this->form->getInput("limited"));
306  $this->table->setDescription($this->form->getInput('description'));
307  $limit_start = $this->form->getInput("limit_start");
308  $limit_end = $this->form->getInput("limit_end");
309  $this->table->setLimitStart($limit_start["date"] . " " . $limit_start["time"]);
310  $this->table->setLimitEnd($limit_end["date"] . " " . $limit_end["time"]);
311 
312  if (! $this->table->hasPermissionToAddTable($this->parent_object->ref_id)) {
313  $this->accessDenied();
314 
315  return;
316  }
317  if ($a_mode == "update") {
318  $this->table->doUpdate();
319  ilUtil::sendSuccess($this->lng->txt("dcl_msg_table_edited"), true);
320  $this->ctrl->redirectByClass("ildatacollectiontableeditgui", "edit");
321  } else {
322  $this->table->doCreate();
323  ilUtil::sendSuccess($this->lng->txt("dcl_msg_table_created"), true);
324  $this->ctrl->setParameterByClass("ildatacollectionfieldlistgui", "table_id", $this->table->getId());
325  $this->ctrl->redirectByClass("ildatacollectionfieldlistgui", "listFields");
326  }
327  } else {
328  $this->form->setValuesByPost();
329  $this->tpl->setContent($this->form->getHTML());
330  }
331  }
static sendSuccess($a_info="", $a_keep=false)
Send Success Message to Screen.
checkInput($a_mode)
Custom checks for the form input.
static checkActionForObjId($action, $obj_id)
initForm($a_mode="create")
initEditCustomForm
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

Field Documentation

◆ $ctrl

ilDataCollectionTableEditGUI::$ctrl
protected

Definition at line 35 of file class.ilDataCollectionTableEditGUI.php.

◆ $lng

ilDataCollectionTableEditGUI::$lng
protected

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

Referenced by __construct().

◆ $table

ilDataCollectionTableEditGUI::$table
private

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

◆ $table_id

ilDataCollectionTableEditGUI::$table_id
private

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

◆ $tpl

ilDataCollectionTableEditGUI::$tpl
protected

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

Referenced by __construct().


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