ILIAS  trunk Revision v11.0_alpha-3011-gc6b235a2e85
ilDclTableEditGUI Class Reference
+ Collaboration diagram for ilDclTableEditGUI:

Public Member Functions

 __construct (ilDclTableListGUI $a_parent_obj)
 
 executeCommand ()
 
 create ()
 
 edit ()
 
 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.

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 getTableCache(?int $table_id=null)
static http()
Fetches the global http state from ILIAS.
global $DIC
Definition: shib_login.php:26

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().

+ Here is the call graph for this function:

Member Function Documentation

◆ cancelDelete()

ilDclTableEditGUI::cancelDelete ( )

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

291 : void
292 {
293 $this->ctrl->redirectByClass("ilDclTableListGUI", "listTables");
294 }

References ILIAS\Repository\ctrl().

+ Here is the call graph for this function:

◆ checkAccess()

ilDclTableEditGUI::checkAccess ( )
protected

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

328 : bool
329 {
330 $ref_id = $this->parent_object->getDataCollectionObject()->getRefId();
331
333 $ref_id,
334 $this->table_id
335 ) : ilObjDataCollectionAccess::hasWriteAccess($ref_id);
336 }
static hasAccessToEditTable(int $ref_id, int $table_id)
$ref_id
Definition: ltiauth.php:66

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

Referenced by __construct().

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

178 : Checkbox
179 {
180 return $this->ui_factory->input()->field()->checkbox(
181 $this->lng->txt('dcl_' . $label),
182 $this->lng->txt('dcl_' . $label . '_desc')
183 );
184 }
This describes checkbox inputs.
Definition: Checkbox.php:29

References ILIAS\Repository\lng().

Referenced by initForm().

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

◆ confirmDelete()

ilDclTableEditGUI::confirmDelete ( )

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

277 : void
278 {
279 $conf = new ilConfirmationGUI();
280 $conf->setFormAction($this->ctrl->getFormAction($this));
281 $conf->setHeaderText($this->lng->txt('dcl_confirm_delete_table'));
282
283 $conf->addItem('table', (string) $this->table->getId(), $this->table->getTitle());
284
285 $conf->setConfirm($this->lng->txt('delete'), 'delete');
286 $conf->setCancel($this->lng->txt('cancel'), 'cancelDelete');
287
288 $this->tpl->setContent($conf->getHTML());
289 }
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...

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

+ Here is the call graph for this function:

◆ create()

ilDclTableEditGUI::create ( )

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

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 }

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

+ Here is the call graph for this function:

◆ delete()

ilDclTableEditGUI::delete ( )

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

296 : void
297 {
298 if (count($this->table->getCollectionObject()->getTables()) < 2) {
299 $this->tpl->setOnScreenMessage(
300 $this->tpl::MESSAGE_TYPE_FAILURE,
301 $this->lng->txt("dcl_cant_delete_last_table"),
302 true
303 );
304 $this->table->doDelete(true);
305 } else {
306 $this->table->doDelete();
307 }
308 $this->ctrl->clearParameterByClass("ilobjdatacollectiongui", "table_id");
309 $this->ctrl->redirectByClass("ildcltablelistgui", "listtables");
310 }

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

+ Here is the call graph for this function:

◆ edit()

ilDclTableEditGUI::edit ( )

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

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 }

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

+ Here is the call graph for this function:

◆ executeCommand()

ilDclTableEditGUI::executeCommand ( )

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

79 : void
80 {
81 $cmd = $this->ctrl->getCmd();
82 if ($cmd === 'update') {
83 $this->save(false);
84 } else {
85 $this->$cmd();
86 }
87 }

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

+ Here is the call graph for this function:

◆ initForm()

ilDclTableEditGUI::initForm ( bool  $create = true)

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

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

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

Referenced by save().

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

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

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

Referenced by executeCommand().

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

◆ setAsDefault()

ilDclTableEditGUI::setAsDefault ( )

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

312 : void
313 {
314 $object = ilObjectFactory::getInstanceByObjId($this->obj_id);
315 $order = 20;
316 foreach ($object->getTables() as $table) {
317 if ($table->getId() === $this->table->getId()) {
318 $table->setOrder(10);
319 } else {
320 $table->setOrder($order);
321 $order += 10;
322 }
323 $table->doUpdate();
324 }
325 $this->ctrl->redirectByClass(ilDclTableListGUI::class, 'listTables');
326 }
setOrder(int $table_order)

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

+ Here is the call graph for this function:

◆ setValues()

ilDclTableEditGUI::setValues ( array  $inputs)
protected

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

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

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

Referenced by initForm().

+ 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.

Referenced by save().

◆ $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 initForm(), save(), and 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: