ILIAS  trunk Revision v11.0_alpha-1851-ga8564da6fed
All Data Structures Namespaces Files Functions Variables Enumerations Enumerator Modules Pages
ilDclTableEditGUI Class Reference
+ Collaboration diagram for ilDclTableEditGUI:

Public Member Functions

 __construct (ilDclTableListGUI $a_parent_obj)
 
 executeCommand ()
 
 create ()
 
 edit ()
 
 cancel ()
 
 initForm (string $a_mode='create')
 
 save (string $a_mode='edit')
 
 confirmDelete ()
 
 cancelDelete ()
 
 delete ()
 
 enableVisible ()
 
 disableVisible ()
 
 enableComments ()
 
 disableComments ()
 
 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 Attributes

int $table_id
 
ilDclTable $table
 

Detailed Description

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

Constructor & Destructor Documentation

◆ __construct()

ilDclTableEditGUI::__construct ( ilDclTableListGUI  $a_parent_obj)

Definition at line 40 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(), null, ILIAS\Repository\refinery(), and ILIAS\Repository\toolbar().

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

Member Function Documentation

◆ cancel()

ilDclTableEditGUI::cancel ( )

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

References ILIAS\Repository\ctrl().

100  : void
101  {
102  $this->ctrl->redirectByClass(ilDclTableListGUI::class, 'listTables');
103  }
+ Here is the call graph for this function:

◆ cancelDelete()

ilDclTableEditGUI::cancelDelete ( )

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

References ILIAS\Repository\ctrl().

284  : void
285  {
286  $this->ctrl->redirectByClass("ilDclTableListGUI", "listTables");
287  }
+ Here is the call graph for this function:

◆ checkAccess()

ilDclTableEditGUI::checkAccess ( )
protected

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

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

Referenced by __construct().

349  : bool
350  {
351  $ref_id = $this->parent_object->getDataCollectionObject()->getRefId();
352 
353  return $this->table_id ? ilObjDataCollectionAccess::hasAccessToEditTable(
354  $ref_id,
355  $this->table_id
356  ) : ilObjDataCollectionAccess::hasWriteAccess($ref_id);
357  }
$ref_id
Definition: ltiauth.php:65
static hasAccessToEditTable(int $ref_id, int $table_id)
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ confirmDelete()

ilDclTableEditGUI::confirmDelete ( )

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

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

270  : void
271  {
272  $conf = new ilConfirmationGUI();
273  $conf->setFormAction($this->ctrl->getFormAction($this));
274  $conf->setHeaderText($this->lng->txt('dcl_confirm_delete_table'));
275 
276  $conf->addItem('table', (string) $this->table->getId(), $this->table->getTitle());
277 
278  $conf->setConfirm($this->lng->txt('delete'), 'delete');
279  $conf->setCancel($this->lng->txt('cancel'), 'cancelDelete');
280 
281  $this->tpl->setContent($conf->getHTML());
282  }
+ Here is the call graph for this function:

◆ create()

ilDclTableEditGUI::create ( )

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

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

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

◆ delete()

ilDclTableEditGUI::delete ( )

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

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

289  : void
290  {
291  if (count($this->table->getCollectionObject()->getTables()) < 2) {
292  $this->tpl->setOnScreenMessage(
293  'failure',
294  $this->lng->txt("dcl_cant_delete_last_table"),
295  true
296  ); //TODO change lng var
297  $this->table->doDelete(true);
298  } else {
299  $this->table->doDelete();
300  }
301  $this->ctrl->clearParameterByClass("ilobjdatacollectiongui", "table_id");
302  $this->ctrl->redirectByClass("ildcltablelistgui", "listtables");
303  }
+ Here is the call graph for this function:

◆ disableComments()

ilDclTableEditGUI::disableComments ( )

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

References ILIAS\Repository\ctrl().

326  : void
327  {
328  $this->table->setPublicCommentsEnabled(false);
329  $this->table->doUpdate();
330  $this->ctrl->redirectByClass(ilDclTableListGUI::class, 'listTables');
331  }
+ Here is the call graph for this function:

◆ disableVisible()

ilDclTableEditGUI::disableVisible ( )

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

References ILIAS\Repository\ctrl().

312  : void
313  {
314  $this->table->setIsVisible(false);
315  $this->table->doUpdate();
316  $this->ctrl->redirectByClass(ilDclTableListGUI::class, 'listTables');
317  }
+ Here is the call graph for this function:

◆ edit()

ilDclTableEditGUI::edit ( )

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

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

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

◆ enableComments()

ilDclTableEditGUI::enableComments ( )

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

References ILIAS\Repository\ctrl().

319  : void
320  {
321  $this->table->setPublicCommentsEnabled(true);
322  $this->table->doUpdate();
323  $this->ctrl->redirectByClass(ilDclTableListGUI::class, 'listTables');
324  }
+ Here is the call graph for this function:

◆ enableVisible()

ilDclTableEditGUI::enableVisible ( )

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

References ILIAS\Repository\ctrl().

305  : void
306  {
307  $this->table->setIsVisible(true);
308  $this->table->doUpdate();
309  $this->ctrl->redirectByClass(ilDclTableListGUI::class, 'listTables');
310  }
+ Here is the call graph for this function:

◆ executeCommand()

ilDclTableEditGUI::executeCommand ( )

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

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

78  : void
79  {
80  $cmd = $this->ctrl->getCmd();
81  if ($cmd === 'save_create') {
82  $this->save('create');
83  } else {
84  $this->$cmd();
85  }
86  }
save(string $a_mode='edit')
+ Here is the call graph for this function:

◆ initForm()

ilDclTableEditGUI::initForm ( string  $a_mode = 'create')

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

References ILIAS\UI\Implementation\Component\Input\$inputs, ILIAS\Repository\ctrl(), ILIAS\Repository\lng(), null, setValues(), and ILIAS\UI\Implementation\Component\Input\withValue().

Referenced by create(), and save().

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

◆ save()

ilDclTableEditGUI::save ( string  $a_mode = 'edit')

Definition at line 205 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(), ILIAS\Repository\lng(), and null.

Referenced by executeCommand().

205  : void
206  {
207  if (!ilObjDataCollectionAccess::checkActionForObjId('write', $this->obj_id)) {
208  return;
209  }
210 
211  $form = $this->initForm($a_mode)->withRequest($this->http->request());
212  $data = $form->getData();
213 
214  if ($data !== null) {
215  if ($a_mode === 'create') {
216  $this->table = new ilDclTable();
217  }
218  foreach (ilObjectFactory::getInstanceByObjId($this->obj_id)->getTables() as $table) {
219  if ($table->getTitle() === $data['edit']['title'] && $table->getId() !== $this->table->getId()) {
220  $this->tpl->setOnScreenMessage($this->tpl::MESSAGE_TYPE_FAILURE, $this->lng->txt('dcl_table_title_unique'));
221  $this->tpl->setContent($this->ui_renderer->render($form));
222  return;
223  }
224  }
225 
226  $this->table->setObjId($this->obj_id);
227  $this->table->setTitle($data['edit']['title']);
228  if ($a_mode !== 'create') {
229  $this->table->setDefaultSortField($data['edit']['default_sort_field']);
230  $this->table->setDefaultSortFieldOrder($data['edit']['default_sort_field_order']);
231  }
232  $this->table->setDescription($data['edit']['description']);
233 
234  $this->table->setAddPerm($data['user']['add_perm'] !== null);
235  $this->table->setSaveConfirmation($data['user']['add_perm']['save_confirmation'] ?? false);
236  $this->table->setEditPerm($data['user']['edit_perm'] !== 'none');
237  $this->table->setEditByOwner($data['user']['edit_perm'] === 'own');
238  $this->table->setDeletePerm($data['user']['delete_perm'] !== 'none');
239  $this->table->setDeleteByOwner($data['user']['delete_perm'] === 'own');
240  $this->table->setViewOwnRecordsPerm($data['user']['view_own_records_perm']);
241  $this->table->setExportEnabled($data['user']['export_enabled']);
242  $this->table->setImportEnabled($data['user']['import_enabled']);
243  $this->table->setLimited($data['user']['limited'] !== null);
244  if ($data['user']['limited']['limit_start'] ?? null !== null) {
245  $this->table->setLimitStart($data['user']['limited']['limit_start']->format('Y-m-d H:i:s'));
246  } else {
247  $this->table->setLimitStart('');
248  }
249  if ($data['user']['limited']['limit_end'] ?? null !== null) {
250  $this->table->setLimitEnd($data['user']['limited']['limit_end']->format('Y-m-d H:i:s'));
251  } else {
252  $this->table->setLimitEnd('');
253  }
254 
255  if ($a_mode === 'create') {
256  $this->table->doCreate();
257  $this->tpl->setOnScreenMessage($this->tpl::MESSAGE_TYPE_SUCCESS, $this->lng->txt('dcl_msg_table_created'), true);
258  $this->ctrl->setParameterByClass(ilDclFieldListGUI::class, 'table_id', $this->table->getId());
259  $this->ctrl->redirectByClass(ilDclFieldListGUI::class, 'listFields');
260  } else {
261  $this->table->doUpdate();
262  $this->tpl->setOnScreenMessage($this->tpl::MESSAGE_TYPE_SUCCESS, $this->lng->txt('dcl_msg_table_edited'), true);
263  $this->ctrl->redirectByClass(ilDclTableEditGUI::class, 'edit');
264  }
265  } else {
266  $this->tpl->setContent($this->ui_renderer->render($form));
267  }
268  }
initForm(string $a_mode='create')
while($session_entry=$r->fetchRow(ilDBConstants::FETCHMODE_ASSOC)) return null
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
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 333 of file class.ilDclTableEditGUI.php.

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

333  : void
334  {
335  $object = ilObjectFactory::getInstanceByObjId($this->obj_id);
336  $order = 20;
337  foreach ($object->getTables() as $table) {
338  if ($table->getId() === $this->table->getId()) {
339  $table->setOrder(10);
340  } else {
341  $table->setOrder($order);
342  $order += 10;
343  }
344  $table->doUpdate();
345  }
346  $this->ctrl->redirectByClass(ilDclTableListGUI::class, 'listTables');
347  }
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 184 of file class.ilDclTableEditGUI.php.

References ILIAS\UI\Implementation\Component\Input\$inputs, and null.

Referenced by initForm().

184  : array
185  {
186  $inputs['edit'] = $inputs['edit']->withValue([
187  'title' => $this->table->getTitle(),
188  'default_sort_field' => $this->table->getDefaultSortField(),
189  'default_sort_field_order' => $this->table->getDefaultSortFieldOrder(),
190  'description' => $this->table->getDescription(),
191  ]);
192  $inputs['user'] = $inputs['user']->withValue([
193  'add_perm' => $this->table->getAddPerm() ? ['save_confirmation' => $this->table->getSaveConfirmation()] : null,
194  'edit_perm' => $this->table->getEditPerm() ? ($this->table->getEditByOwner() ? 'own' : 'all') : 'none',
195  'delete_perm' => $this->table->getDeletePerm() ? ($this->table->getDeleteByOwner() ? 'own' : 'all') : 'none',
196  'view_own_records_perm' => $this->table->getViewOwnRecordsPerm(),
197  'export_enabled' => $this->table->getExportEnabled(),
198  'import_enabled' => $this->table->getImportEnabled(),
199  'limited' => $this->table->getLimited() ? ['limit_start' => $this->table->getLimitStart(), 'limit_end' => $this->table->getLimitEnd()] : null
200  ]);
201 
202  return $inputs;
203  }
while($session_entry=$r->fetchRow(ilDBConstants::FETCHMODE_ASSOC)) return null
+ Here is the caller graph for this function:

Field Documentation

◆ $ctrl

ilCtrl ilDclTableEditGUI::$ctrl
protected

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

◆ $form

Form ilDclTableEditGUI::$form
protected

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

◆ $help

ilHelpGUI ilDclTableEditGUI::$help
protected

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

◆ $http

ILIAS HTTP Services ilDclTableEditGUI::$http
protected

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

◆ $lng

ilLanguage ilDclTableEditGUI::$lng
protected

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

◆ $obj_id

int ilDclTableEditGUI::$obj_id
protected

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

◆ $parent_object

ilDclTableListGUI ilDclTableEditGUI::$parent_object
protected

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

◆ $refinery

ILIAS Refinery Factory ilDclTableEditGUI::$refinery
protected

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

◆ $table

ilDclTable ilDclTableEditGUI::$table
private

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

Referenced by setAsDefault().

◆ $table_id

int ilDclTableEditGUI::$table_id
private

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

Referenced by __construct().

◆ $toolbar

ilToolbarGUI ilDclTableEditGUI::$toolbar
protected

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

◆ $tpl

ilGlobalTemplateInterface ilDclTableEditGUI::$tpl
protected

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

◆ $ui_factory

ILIAS UI Factory ilDclTableEditGUI::$ui_factory
protected

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

◆ $ui_renderer

ILIAS UI Renderer ilDclTableEditGUI::$ui_renderer
protected

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


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