ILIAS  release_10 Revision v10.1-43-ga1241a92c2f
ilDclTableEditGUI Class Reference
+ Collaboration diagram for ilDclTableEditGUI:

Public Member Functions

 __construct (ilDclTableListGUI $a_parent_obj)
 
 executeCommand ()
 
 create ()
 
 edit ()
 
 cancel ()
 
 initForm (bool $create=true)
 
 save (bool $create=true)
 
 confirmDelete ()
 
 cancelDelete ()
 
 delete ()
 
 setAsDefault ()
 

Protected Member Functions

 setValues (array $inputs)
 
 checkAccess ()
 

Protected Attributes

ILIAS UI Factory $ui_factory
 
ILIAS UI Renderer $ui_renderer
 
ilLanguage $lng
 
ilCtrl $ctrl
 
ilGlobalTemplateInterface $tpl
 
ilToolbarGUI $toolbar
 
Form $form
 
ilHelpGUI $help
 
ILIAS HTTP Services $http
 
ILIAS Refinery Factory $refinery
 
ilDclTableListGUI $parent_object
 
int $obj_id
 

Private Member Functions

 checkbox (string $label)
 

Private Attributes

int $table_id
 
ilDclTable $table
 

Detailed Description

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

Constructor & Destructor Documentation

◆ __construct()

ilDclTableEditGUI::__construct ( ilDclTableListGUI  $a_parent_obj)

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

References $DIC, $table_id, checkAccess(), ILIAS\Repository\ctrl(), ilDclTableListGUI\getObjId(), ilDclCache\getTableCache(), ILIAS\Repository\help(), ILIAS\FileDelivery\http(), ILIAS\Repository\lng(), ILIAS\Repository\refinery(), and ILIAS\Repository\toolbar().

42  {
43  global $DIC;
44 
45  $locator = $DIC['ilLocator'];
46 
47  $this->ctrl = $DIC->ctrl();
48  $this->lng = $DIC->language();
49  $this->tpl = $DIC->ui()->mainTemplate();
50  $this->toolbar = $DIC->toolbar();
51  $this->parent_object = $a_parent_obj;
52  $this->obj_id = $a_parent_obj->getObjId();
53  $this->help = $DIC->help();
54  $this->http = $DIC->http();
55  $this->refinery = $DIC->refinery();
56  $this->ui_factory = $DIC->ui()->factory();
57  $this->ui_renderer = $DIC->ui()->renderer();
58 
59  $table_id = null;
60  if ($this->http->wrapper()->query()->has('table_id')) {
61  $table_id = $this->http->wrapper()->query()->retrieve('table_id', $this->refinery->kindlyTo()->int());
62  }
63 
64  $this->table_id = $table_id;
65  $this->table = ilDclCache::getTableCache($this->table_id);
66 
67  $this->ctrl->saveParameter($this, 'table_id');
68  if ($this->table->getTitle()) {
69  $locator->addItem($this->table->getTitle(), $this->ctrl->getLinkTarget($this, 'edit'));
70  }
71  $this->tpl->setLocator();
72 
73  if (!$this->checkAccess()) {
74  $this->tpl->setOnScreenMessage('failure', $this->lng->txt('permission_denied'), true);
75  $this->ctrl->redirectByClass(ilDclRecordListGUI::class, 'listRecords');
76  }
77  }
static http()
Fetches the global http state from ILIAS.
static getTableCache(int $table_id=null)
global $DIC
Definition: shib_login.php:25
+ Here is the call graph for this function:

Member Function Documentation

◆ cancel()

ilDclTableEditGUI::cancel ( )

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

References ILIAS\Repository\ctrl().

104  : void
105  {
106  $this->ctrl->redirectByClass(ilDclTableListGUI::class, 'listTables');
107  }
+ Here is the call graph for this function:

◆ cancelDelete()

ilDclTableEditGUI::cancelDelete ( )

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

References ILIAS\Repository\ctrl().

296  : void
297  {
298  $this->ctrl->redirectByClass("ilDclTableListGUI", "listTables");
299  }
+ Here is the call graph for this function:

◆ checkAccess()

ilDclTableEditGUI::checkAccess ( )
protected

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

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

Referenced by __construct().

333  : bool
334  {
335  $ref_id = $this->parent_object->getDataCollectionObject()->getRefId();
336 
337  return $this->table_id ? ilObjDataCollectionAccess::hasAccessToEditTable(
338  $ref_id,
339  $this->table_id
340  ) : ilObjDataCollectionAccess::hasWriteAccess($ref_id);
341  }
$ref_id
Definition: ltiauth.php:66
static hasAccessToEditTable(int $ref_id, int $table_id)
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ checkbox()

ilDclTableEditGUI::checkbox ( string  $label)
private

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

References ILIAS\Repository\lng().

Referenced by initForm().

182  : Checkbox
183  {
184  return $this->ui_factory->input()->field()->checkbox(
185  $this->lng->txt('dcl_' . $label),
186  $this->lng->txt('dcl_' . $label . '_desc')
187  );
188  }
This describes checkbox inputs.
Definition: Checkbox.php:28
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ confirmDelete()

ilDclTableEditGUI::confirmDelete ( )

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

References ILIAS\Repository\ctrl(), and ILIAS\Repository\lng().

282  : void
283  {
284  $conf = new ilConfirmationGUI();
285  $conf->setFormAction($this->ctrl->getFormAction($this));
286  $conf->setHeaderText($this->lng->txt('dcl_confirm_delete_table'));
287 
288  $conf->addItem('table', (string) $this->table->getId(), $this->table->getTitle());
289 
290  $conf->setConfirm($this->lng->txt('delete'), 'delete');
291  $conf->setCancel($this->lng->txt('cancel'), 'cancelDelete');
292 
293  $this->tpl->setContent($conf->getHTML());
294  }
+ Here is the call graph for this function:

◆ create()

ilDclTableEditGUI::create ( )

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

References ILIAS\Repository\help(), initForm(), and ILIAS\Repository\lng().

89  : void
90  {
91  $this->help->setSubScreenId('create');
92  $this->tpl->setContent($this->lng->txt('dcl_new_table') . $this->ui_renderer->render($this->initForm()));
93  }
initForm(bool $create=true)
+ Here is the call graph for this function:

◆ delete()

ilDclTableEditGUI::delete ( )

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

References ILIAS\Repository\ctrl(), and ILIAS\Repository\lng().

301  : void
302  {
303  if (count($this->table->getCollectionObject()->getTables()) < 2) {
304  $this->tpl->setOnScreenMessage(
305  $this->tpl::MESSAGE_TYPE_FAILURE,
306  $this->lng->txt("dcl_cant_delete_last_table"),
307  true
308  );
309  $this->table->doDelete(true);
310  } else {
311  $this->table->doDelete();
312  }
313  $this->ctrl->clearParameterByClass("ilobjdatacollectiongui", "table_id");
314  $this->ctrl->redirectByClass("ildcltablelistgui", "listtables");
315  }
+ Here is the call graph for this function:

◆ edit()

ilDclTableEditGUI::edit ( )

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

References ILIAS\Repository\help(), and ILIAS\Repository\lng().

95  : void
96  {
97  $this->help->setSubScreenId('edit');
98  $this->tpl->setContent(
99  sprintf($this->lng->txt('dcl_edit_table'), $this->table->getTitle()) .
100  $this->ui_renderer->render($this->initForm(false))
101  );
102  }
+ Here is the call graph for this function:

◆ executeCommand()

ilDclTableEditGUI::executeCommand ( )

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

References ILIAS\Repository\ctrl(), and save().

79  : void
80  {
81  $cmd = $this->ctrl->getCmd();
82  if ($cmd === 'update') {
83  $this->save(false);
84  } else {
85  $this->$cmd();
86  }
87  }
+ Here is the call graph for this function:

◆ initForm()

ilDclTableEditGUI::initForm ( bool  $create = true)

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

References Vendor\Package\$f, ILIAS\UI\Implementation\Component\Input\$inputs, checkbox(), ILIAS\Repository\ctrl(), ilDclTable\getTitle(), ILIAS\Repository\lng(), setValues(), and ILIAS\UI\Implementation\Component\Input\withValue().

Referenced by create(), and save().

109  : Form
110  {
111  $f = $this->ui_factory->input()->field();
112  $inputs = [];
113 
114  $edit = [];
115  $edit['title'] = $f->text($this->lng->txt('title'))->withRequired(true);
116  $edit['description'] = $f->markdown(new ilUIMarkdownPreviewGUI(), $this->lng->txt('additional_info'));
117  $edit['visible'] = $this->checkbox('visible');
118  $inputs['edit'] = $f->section($edit, $this->lng->txt('general_settings'));
119 
120  $table = [];
121  if (!$create) {
122  $options = [];
123  foreach ($this->table->getFields() as $field) {
124  if ($field->getId() !== 'comments' && $field->getRecordQuerySortObject() !== null) {
125  $options[$field->getId()] = $field->getTitle();
126  }
127  }
128  $table['default_sort_field'] = $f->select(
129  $this->lng->txt('dcl_default_sort_field'),
130  $options
131  );
132 
133  $table['default_sort_field_order'] = $f->select(
134  $this->lng->txt('dcl_default_sort_field_order'),
135  ['asc' => $this->lng->txt('dcl_asc'), 'desc' => $this->lng->txt('dcl_desc')],
136  $this->lng->txt('dcl_default_sort_field_order_desc')
137  );
138  }
139  $table['export_enabled'] = $this->checkbox('export_enabled');
140  $table['import_enabled'] = $this->checkbox('import_enabled');
141  $table['comments_enabled'] = $this->checkbox('comments');
142  $inputs['table'] = $f->section($table, $this->lng->txt('dcl_table_settings'));
143 
144  $record = [];
145  $record['add_perm'] = $f->optionalGroup(
146  ['save_confirmation' => $this->checkbox('save_confirmation')],
147  $this->lng->txt('dcl_add_perm'),
148  $this->lng->txt('dcl_add_perm_desc')
149  )->withValue(['save_confirmation' => false]);
150  $record['edit_perm'] = $f->radio($this->lng->txt('dcl_edit_perm'))
151  ->withOption('all', $this->lng->txt('dcl_all_entries'))
152  ->withOption('own', $this->lng->txt('dcl_own_entries'))
153  ->withOption('none', $this->lng->txt('dcl_no_entries'))
154  ->withValue('own');
155  $record['delete_perm'] = $f->radio($this->lng->txt('dcl_delete_perm'))
156  ->withOption('all', $this->lng->txt('dcl_all_entries'))
157  ->withOption('own', $this->lng->txt('dcl_own_entries'))
158  ->withOption('none', $this->lng->txt('dcl_no_entries'))
159  ->withValue('own');
160  $record['view_own_records_perm'] = $this->checkbox('view_own_records_perm');
161  $record['limited'] = $f->optionalGroup(
162  [
163  'limit_start' => $f->dateTime($this->lng->txt('dcl_limit_start'))->withUseTime(true),
164  'limit_end' => $f->dateTime($this->lng->txt('dcl_limit_end'))->withUseTime(true)
165  ],
166  $this->lng->txt('dcl_limited'),
167  $this->lng->txt('dcl_limited_desc')
168  )->withValue(null);
169  $inputs['record'] = $f->section($record, $this->lng->txt('dcl_record_settings'));
170 
171  if (!$create) {
172  $inputs = $this->setValues($inputs);
173  }
174 
175  $this->ctrl->setParameter($this, 'table_id', $this->table_id);
176  return $this->ui_factory->input()->container()->form()->standard(
177  $this->ctrl->getFormAction($this, $create ? 'save' : 'update'),
178  $inputs
179  );
180  }
This describes commonalities between all forms.
Definition: Form.php:32
withValue($value)
Get an input like this with another value displayed on the client side.
Definition: Group.php:59
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ save()

ilDclTableEditGUI::save ( bool  $create = true)

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

References $data, ilObjDataCollectionAccess\checkActionForObjId(), ILIAS\Repository\ctrl(), ILIAS\UI\Component\Input\Container\Container\getData(), ilObjectFactory\getInstanceByObjId(), ILIAS\FileDelivery\http(), initForm(), and ILIAS\Repository\lng().

Referenced by executeCommand().

216  : void
217  {
218  if (!ilObjDataCollectionAccess::checkActionForObjId('write', $this->obj_id)) {
219  return;
220  }
221 
222  $form = $this->initForm($create)->withRequest($this->http->request());
223  $data = $form->getData();
224 
225  if ($data !== null) {
226  if ($create) {
227  $this->table = new ilDclTable();
228  }
229  foreach (ilObjectFactory::getInstanceByObjId($this->obj_id)->getTables() as $table) {
230  if ($table->getTitle() === $data['edit']['title'] && $table->getId() !== $this->table->getId()) {
231  $this->tpl->setOnScreenMessage($this->tpl::MESSAGE_TYPE_FAILURE, $this->lng->txt('dcl_table_title_unique'));
232  $this->tpl->setContent($this->ui_renderer->render($form));
233  return;
234  }
235  }
236 
237  $this->table->setObjId($this->obj_id);
238  $this->table->setTitle($data['edit']['title']);
239  $this->table->setDescription($data['edit']['description']);
240  $this->table->setIsVisible($data['edit']['visible']);
241 
242  $this->table->setExportEnabled($data['table']['export_enabled']);
243  $this->table->setImportEnabled($data['table']['import_enabled']);
244  $this->table->setPublicCommentsEnabled($data['table']['comments_enabled']);
245 
246  $this->table->setAddPerm($data['record']['add_perm'] !== null);
247  $this->table->setSaveConfirmation($data['record']['add_perm']['save_confirmation'] ?? false);
248  $this->table->setEditPerm($data['record']['edit_perm'] !== 'none');
249  $this->table->setEditByOwner($data['record']['edit_perm'] === 'own');
250  $this->table->setDeletePerm($data['record']['delete_perm'] !== 'none');
251  $this->table->setDeleteByOwner($data['record']['delete_perm'] === 'own');
252  $this->table->setViewOwnRecordsPerm($data['record']['view_own_records_perm']);
253  $this->table->setLimited($data['record']['limited'] !== null);
254  if ($data['record']['limited']['limit_start'] ?? null !== null) {
255  $this->table->setLimitStart($data['record']['limited']['limit_start']->format('Y-m-d H:i:s'));
256  } else {
257  $this->table->setLimitStart('');
258  }
259  if ($data['record']['limited']['limit_end'] ?? null !== null) {
260  $this->table->setLimitEnd($data['record']['limited']['limit_end']->format('Y-m-d H:i:s'));
261  } else {
262  $this->table->setLimitEnd('');
263  }
264 
265  if ($create) {
266  $this->table->doCreate();
267  $this->ctrl->setParameter($this, 'table_id', $this->table->getId());
268  $message = 'dcl_msg_table_created';
269  } else {
270  $this->table->setDefaultSortField($data['table']['default_sort_field']);
271  $this->table->setDefaultSortFieldOrder($data['table']['default_sort_field_order']);
272  $this->table->doUpdate();
273  $message = 'dcl_msg_table_edited';
274  }
275  $this->tpl->setOnScreenMessage($this->tpl::MESSAGE_TYPE_SUCCESS, $this->lng->txt($message), true);
276  $this->ctrl->redirectByClass(ilDclTableEditGUI::class, 'edit');
277  } else {
278  $this->tpl->setContent($this->ui_renderer->render($form));
279  }
280  }
static http()
Fetches the global http state from ILIAS.
static getInstanceByObjId(?int $obj_id, bool $stop_on_error=true)
get an instance of an Ilias object by object id
initForm(bool $create=true)
getData()
Get the data in the form if all inputs are ok, where the transformation is applied if one was added...
static checkActionForObjId(string $action, int $obj_id)
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ setAsDefault()

ilDclTableEditGUI::setAsDefault ( )

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

References $table, ILIAS\Repository\ctrl(), ilDclTable\doUpdate(), ilDclTable\getId(), ilObjectFactory\getInstanceByObjId(), and ilDclTable\setOrder().

317  : void
318  {
319  $object = ilObjectFactory::getInstanceByObjId($this->obj_id);
320  $order = 20;
321  foreach ($object->getTables() as $table) {
322  if ($table->getId() === $this->table->getId()) {
323  $table->setOrder(10);
324  } else {
325  $table->setOrder($order);
326  $order += 10;
327  }
328  $table->doUpdate();
329  }
330  $this->ctrl->redirectByClass(ilDclTableListGUI::class, 'listTables');
331  }
getId()
Get table id.
setOrder(int $table_order)
static getInstanceByObjId(?int $obj_id, bool $stop_on_error=true)
get an instance of an Ilias object by object id
+ Here is the call graph for this function:

◆ setValues()

ilDclTableEditGUI::setValues ( array  $inputs)
protected

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

References ILIAS\UI\Implementation\Component\Input\$inputs.

Referenced by initForm().

190  : array
191  {
192  $inputs['edit'] = $inputs['edit']->withValue([
193  'title' => $this->table->getTitle(),
194  'description' => $this->table->getDescription(),
195  'visible' => $this->table->getIsVisible(),
196  ]);
197  $sort_field = $this->table->getDefaultSortField();
198  $inputs['table'] = $inputs['table']->withValue([
199  'default_sort_field' => in_array($sort_field, $this->table->getFieldIds()) ? $sort_field : '',
200  'default_sort_field_order' => $this->table->getDefaultSortFieldOrder(),
201  'export_enabled' => $this->table->getExportEnabled(),
202  'import_enabled' => $this->table->getImportEnabled(),
203  'comments_enabled' => $this->table->getPublicCommentsEnabled()
204  ]);
205  $inputs['record'] = $inputs['record']->withValue([
206  'add_perm' => $this->table->getAddPerm() ? ['save_confirmation' => $this->table->getSaveConfirmation()] : null,
207  'edit_perm' => $this->table->getEditPerm() ? ($this->table->getEditByOwner() ? 'own' : 'all') : 'none',
208  'delete_perm' => $this->table->getDeletePerm() ? ($this->table->getDeleteByOwner() ? 'own' : 'all') : 'none',
209  'view_own_records_perm' => $this->table->getViewOwnRecordsPerm(),
210  'limited' => $this->table->getLimited() ? ['limit_start' => $this->table->getLimitStart(), 'limit_end' => $this->table->getLimitEnd()] : null
211  ]);
212 
213  return $inputs;
214  }
+ Here is the caller graph for this function:

Field Documentation

◆ $ctrl

ilCtrl ilDclTableEditGUI::$ctrl
protected

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

◆ $form

Form ilDclTableEditGUI::$form
protected

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

◆ $help

ilHelpGUI ilDclTableEditGUI::$help
protected

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

◆ $http

ILIAS HTTP Services ilDclTableEditGUI::$http
protected

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

◆ $lng

ilLanguage ilDclTableEditGUI::$lng
protected

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

◆ $obj_id

int ilDclTableEditGUI::$obj_id
protected

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

◆ $parent_object

ilDclTableListGUI ilDclTableEditGUI::$parent_object
protected

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

◆ $refinery

ILIAS Refinery Factory ilDclTableEditGUI::$refinery
protected

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

◆ $table

ilDclTable ilDclTableEditGUI::$table
private

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

Referenced by setAsDefault().

◆ $table_id

int ilDclTableEditGUI::$table_id
private

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

Referenced by __construct().

◆ $toolbar

ilToolbarGUI ilDclTableEditGUI::$toolbar
protected

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

◆ $tpl

ilGlobalTemplateInterface ilDclTableEditGUI::$tpl
protected

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

◆ $ui_factory

ILIAS UI Factory ilDclTableEditGUI::$ui_factory
protected

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

◆ $ui_renderer

ILIAS UI Renderer ilDclTableEditGUI::$ui_renderer
protected

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


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