ILIAS  trunk Revision v11.0_alpha-3011-gc6b235a2e85
ilObjCourseGroupingGUI Class Reference

Class ilObjCourseGroupingGUI. More...

+ Collaboration diagram for ilObjCourseGroupingGUI:

Public Member Functions

 __construct (ilObject $content_obj, int $a_obj_id=0)
 
 executeCommand ()
 
 __initGroupingObject ()
 
 getContentType ()
 
 listGroupings ()
 
 handleGroupingTableAction ()
 
 askDeleteGrouping (int ... $grouping_ids)
 
 deleteGrouping ()
 
 create (?ilPropertyFormGUI $a_form=null)
 
 initForm (bool $a_create)
 
 add ()
 
 edit (?ilPropertyFormGUI $a_form=null)
 
 update ()
 
 selectCourse ()
 
 handleAssignmentTableAction ()
 
 assignCourse (int ... $ref_ids)
 

Protected Attributes

ilGlobalTemplateInterface $tpl
 
ilCtrlInterface $ctrl
 
ilLanguage $lng
 
ilErrorHandling $error
 
ilAccessHandler $access
 
ilTabsGUI $tabs
 
ilToolbarGUI $toolbar
 
GlobalHttpState $http
 
RefineryFactory $refinery
 
UIRenderer $ui_renderer
 
GroupingTableHandler $grouping_table_handler
 
AssignmentTableHandler $assignment_table_handler
 

Private Attributes

ilObjCourseGrouping $grp_obj
 
int $id
 
ilObject $content_obj
 
string $content_type = ''
 

Detailed Description

Class ilObjCourseGroupingGUI.

Author
your name <your email>

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

Constructor & Destructor Documentation

◆ __construct()

ilObjCourseGroupingGUI::__construct ( ilObject  $content_obj,
int  $a_obj_id = 0 
)

Definition at line 53 of file class.ilObjCourseGroupingGUI.php.

54 {
55 global $DIC;
56
57 $this->tpl = $DIC->ui()->mainTemplate();
58 $this->ctrl = $DIC->ctrl();
59 $this->lng = $DIC->language();
60 $this->access = $DIC->access();
61 $this->error = $DIC['ilErr'];
62 $this->tabs = $DIC->tabs();
63 $this->toolbar = $DIC->toolbar();
64 $this->http = $DIC->http();
65 $this->ui_renderer = $DIC->ui()->renderer();
66 $this->refinery = $DIC->refinery();
67
68 $this->content_obj = $content_obj;
69 $this->content_type = ilObject::_lookupType($this->content_obj->getId());
70
71 $this->id = $a_obj_id;
72 $this->ctrl->saveParameter($this, 'obj_id');
73 $this->__initGroupingObject();
74
75 $data_factory = new DataFactory();
76 $this->grouping_table_handler = new GroupingTableHandler(
77 $this->ctrl->getLinkTarget($this, 'handleGroupingTableAction'),
78 $this->content_obj->getId(),
79 $this->lng,
80 $DIC->ui()->factory(),
81 $data_factory,
82 $this->http,
83 $this->refinery,
84 $DIC['static_url']
85 );
86 $this->assignment_table_handler = new AssignmentTableHandler(
87 $this->ctrl->getLinkTarget($this, 'handleAssignmentTableAction'),
88 $this->content_obj->getId(),
89 $this->grp_obj,
90 $this->lng,
91 $DIC->ui()->factory(),
92 $data_factory,
93 $this->http,
94 $this->refinery,
95 $DIC->user(),
96 $DIC->repositoryTree()
97 );
98 }
error(string $a_errmsg)
static _lookupType(int $id, bool $reference=false)
static http()
Fetches the global http state from ILIAS.
global $DIC
Definition: shib_login.php:26

References $content_obj, $DIC, __initGroupingObject(), ilObject\_lookupType(), ILIAS\Repository\access(), ILIAS\Repository\ctrl(), error(), ILIAS\FileDelivery\http(), ILIAS\Repository\lng(), ILIAS\Repository\refinery(), ILIAS\Repository\tabs(), and ILIAS\Repository\toolbar().

+ Here is the call graph for this function:

Member Function Documentation

◆ __initGroupingObject()

ilObjCourseGroupingGUI::__initGroupingObject ( )

Definition at line 110 of file class.ilObjCourseGroupingGUI.php.

110 : void
111 {
112 $this->grp_obj = new ilObjCourseGrouping($this->id);
113 }
Class ilObj<module_name>

Referenced by __construct().

+ Here is the caller graph for this function:

◆ add()

ilObjCourseGroupingGUI::add ( )

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

270 : void
271 {
272 $form = $this->initForm(true);
273 if ($form->checkInput()) {
274 $this->grp_obj->setTitle($form->getInput('title'));
275 $this->grp_obj->setDescription($form->getInput('description'));
276 $this->grp_obj->setUniqueField($form->getInput('unique'));
277
278 $this->grp_obj->create($this->content_obj->getRefId(), $this->content_obj->getId());
279 $this->tpl->setOnScreenMessage('success', $this->lng->txt('crs_grp_added_grouping'), true);
280 $this->ctrl->redirect($this, 'listGroupings');
281 }
282 $form->setValuesByPost();
283 $this->create($form);
284 }
create(?ilPropertyFormGUI $a_form=null)

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

+ Here is the call graph for this function:

◆ askDeleteGrouping()

ilObjCourseGroupingGUI::askDeleteGrouping ( int ...  $grouping_ids)

Definition at line 150 of file class.ilObjCourseGroupingGUI.php.

150 : void
151 {
152 if (!$this->access->checkAccess('write', '', $this->content_obj->getRefId())) {
153 $this->error->raiseError($this->lng->txt('permission_denied'), $this->error->MESSAGE);
154 }
155
156 if (!count($grouping_ids)) {
157 $this->tpl->setOnScreenMessage('failure', $this->lng->txt('crs_grouping_select_one'));
158 $this->listGroupings();
159 return;
160 }
161
162 // display confirmation message
163 $cgui = new ilConfirmationGUI();
164 $cgui->setFormAction($this->ctrl->getFormAction($this));
165 $cgui->setHeaderText($this->lng->txt("crs_grouping_delete_sure"));
166 $cgui->setCancel($this->lng->txt("cancel"), "listGroupings");
167 $cgui->setConfirm($this->lng->txt("delete"), "deleteGrouping");
168
169 // list objects that should be deleted
170 foreach ($grouping_ids as $grouping_id) {
171 $tmp_obj = new ilObjCourseGrouping($grouping_id);
172 $cgui->addItem("grouping[]", $grouping_id, $tmp_obj->getTitle());
173 }
174 $this->tpl->setContent($cgui->getHTML());
175 }
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...

References ILIAS\Repository\access(), ILIAS\Repository\ctrl(), error(), listGroupings(), and ILIAS\Repository\lng().

Referenced by handleGroupingTableAction().

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

◆ assignCourse()

ilObjCourseGroupingGUI::assignCourse ( int ...  $ref_ids)

Definition at line 357 of file class.ilObjCourseGroupingGUI.php.

357 : void
358 {
359 if (!$this->access->checkAccess('write', '', $this->content_obj->getRefId())) {
360 $this->error->raiseError($this->lng->txt('permission_denied'), $this->error->MESSAGE);
361 }
362
363 if (!$this->id) {
364 $this->listGroupings();
365 return;
366 }
367
368 // add assignments of not selected items that were assigned
369 // add assignments for selected items that were not assigned
370 $grouping = new ilObjCourseGrouping($this->id);
371 $assigned = $grouping->getAssignedItems();
372 $old_assigned_ref_ids = [];
373 foreach ($assigned as $item) {
374 $old_assigned_ref_ids[] = $item['target_ref_id'];
375 }
376 $new_assigned_ref_ids = array_merge(
377 array_diff($old_assigned_ref_ids, $ref_ids),
378 array_diff($ref_ids, $old_assigned_ref_ids)
379 );
380
381 // delete all existing conditions
382 $condh = new ilConditionHandler();
383 $condh->deleteByObjId($this->id);
384
385 foreach ($new_assigned_ref_ids as $ref_id) {
387 $tmp_condh = new ilConditionHandler();
388 $tmp_condh->enableAutomaticValidation(false);
389
390 $tmp_condh->setTargetRefId($ref_id);
391 $tmp_condh->setTargetObjId($tmp_crs->getId());
392 $tmp_condh->setTargetType($this->getContentType());
393 $tmp_condh->setTriggerRefId(0);
394 $tmp_condh->setTriggerObjId($this->id);
395 $tmp_condh->setTriggerType('crsg');
396 $tmp_condh->setOperator('not_member');
397 $tmp_condh->setValue($this->grp_obj->getUniqueField());
398
399 if (!$tmp_condh->checkExists()) {
400 $tmp_condh->storeCondition();
401 }
402 }
403
404 $this->tpl->setOnScreenMessage('success', $this->lng->txt('settings_saved'), true);
405 $this->ctrl->redirect($this, 'edit');
406 }
INTERNAL CLASS: Please do not use in consumer code.
static getInstanceByRefId(int $ref_id, bool $stop_on_error=true)
get an instance of an Ilias object by reference id
$ref_id
Definition: ltiauth.php:66

References $ref_id, ILIAS\Repository\access(), ILIAS\Repository\ctrl(), error(), getContentType(), ilObjectFactory\getInstanceByRefId(), listGroupings(), and ILIAS\Repository\lng().

Referenced by handleAssignmentTableAction().

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

◆ create()

ilObjCourseGroupingGUI::create ( ?ilPropertyFormGUI  $a_form = null)

Definition at line 201 of file class.ilObjCourseGroupingGUI.php.

201 : void
202 {
203 if (!$this->access->checkAccess('write', '', $this->content_obj->getRefId())) {
204 $this->error->raiseError($this->lng->txt('permission_denied'), $this->error->MESSAGE);
205 }
206
207 if (!$a_form) {
208 $a_form = $this->initForm(true);
209 }
210
211 $this->tpl->setContent($a_form->getHTML());
212 }

References ILIAS\Repository\access(), error(), initForm(), and ILIAS\Repository\lng().

Referenced by add().

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

◆ deleteGrouping()

ilObjCourseGroupingGUI::deleteGrouping ( )

Definition at line 177 of file class.ilObjCourseGroupingGUI.php.

177 : void
178 {
179 if (!$this->access->checkAccess('write', '', $this->content_obj->getRefId())) {
180 $this->error->raiseError($this->lng->txt('permission_denied'), $this->error->MESSAGE);
181 }
182 $grouping = [];
183 if ($this->http->wrapper()->post()->has('grouping')) {
184 $grouping = $this->http->wrapper()->post()->retrieve(
185 'grouping',
186 $this->refinery->kindlyTo()->listOf(
187 $this->refinery->kindlyTo()->int()
188 )
189 );
190 }
191
192 foreach ($grouping as $grouping_id) {
193 $tmp_obj = new ilObjCourseGrouping((int) $grouping_id);
194 $tmp_obj->delete();
195 }
196
197 $this->tpl->setOnScreenMessage('success', $this->lng->txt('crs_grouping_deleted'), true);
198 $this->ctrl->redirect($this, 'listGroupings');
199 }

References ILIAS\Repository\access(), ILIAS\Repository\ctrl(), error(), ILIAS\FileDelivery\http(), ILIAS\Repository\lng(), and ILIAS\Repository\refinery().

+ Here is the call graph for this function:

◆ edit()

ilObjCourseGroupingGUI::edit ( ?ilPropertyFormGUI  $a_form = null)

Definition at line 286 of file class.ilObjCourseGroupingGUI.php.

286 : void
287 {
288 if (!$this->access->checkAccess('write', '', $this->content_obj->getRefId())) {
289 $this->error->raiseError($this->lng->txt('permission_denied'), $this->error->MESSAGE);
290 }
291 if (!$a_form) {
292 $a_form = $this->initForm(false);
293 }
294 $this->tpl->setContent($a_form->getHTML());
295 }

References ILIAS\Repository\access(), error(), initForm(), and ILIAS\Repository\lng().

Referenced by update().

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

◆ executeCommand()

ilObjCourseGroupingGUI::executeCommand ( )

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

100 : void
101 {
102 $this->tabs->setTabActive('crs_groupings');
103 $cmd = $this->ctrl->getCmd();
104 if (!$cmd = $this->ctrl->getCmd()) {
105 $cmd = "edit";
106 }
107 $this->$cmd();
108 }

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

+ Here is the call graph for this function:

◆ getContentType()

ilObjCourseGroupingGUI::getContentType ( )

Definition at line 115 of file class.ilObjCourseGroupingGUI.php.

115 : string
116 {
117 return $this->content_type;
118 }

References $content_type.

Referenced by assignCourse().

+ Here is the caller graph for this function:

◆ handleAssignmentTableAction()

ilObjCourseGroupingGUI::handleAssignmentTableAction ( )

Definition at line 348 of file class.ilObjCourseGroupingGUI.php.

348 : void
349 {
350 switch ($this->assignment_table_handler->getSelectedTableAction()) {
351 case AssignmentTableHandler::ACTION_TOGGLE_ASSIGNMENT:
352 $this->assignCourse(...$this->assignment_table_handler->getSelectedRefIDs());
353 break;
354 }
355 }

References assignCourse().

+ Here is the call graph for this function:

◆ handleGroupingTableAction()

ilObjCourseGroupingGUI::handleGroupingTableAction ( )

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

135 : void
136 {
137 switch ($this->grouping_table_handler->getSelectedTableAction()) {
138 case GroupingTableHandler::ACTION_EDIT:
139 $selected = $this->grouping_table_handler->getSelectedGroupingIDs()[0] ?? 0;
140 $this->ctrl->setParameter($this, 'obj_id', $selected);
141 $this->ctrl->redirect($this, 'edit');
142 break;
143
144 case GroupingTableHandler::ACTION_DELETE:
145 $this->askDeleteGrouping(...$this->grouping_table_handler->getSelectedGroupingIDs());
146 break;
147 }
148 }
askDeleteGrouping(int ... $grouping_ids)

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

+ Here is the call graph for this function:

◆ initForm()

ilObjCourseGroupingGUI::initForm ( bool  $a_create)

Definition at line 214 of file class.ilObjCourseGroupingGUI.php.

215 {
216 $form = new ilPropertyFormGUI();
217 $form->setFormAction($this->ctrl->getFormAction($this));
218
219 $title = new ilTextInputGUI($this->lng->txt('title'), 'title');
220 $title->setRequired(true);
221 $form->addItem($title);
222
223 $desc = new ilTextAreaInputGUI($this->lng->txt('description'), 'description');
224 $form->addItem($desc);
225
226 $options = array('login' => 'login',
227 'email' => 'email',
228 'matriculation' => 'matriculation'
229 );
230
231 foreach ($options as $value => $caption) {
232 $options[$value] = $this->lng->txt($caption);
233 }
234 $uniq = new ilSelectInputGUI($this->lng->txt('unambiguousness'), 'unique');
235 $uniq->setRequired(true);
236 $uniq->setOptions($options);
237 $form->addItem($uniq);
238
239 if ($a_create) {
240 $form->setTitle($this->lng->txt('crs_add_grouping'));
241 $form->addCommandButton('add', $this->lng->txt('btn_add'));
242 } else {
243 $grouping = new ilObjCourseGrouping($this->id);
244 $title->setValue($grouping->getTitle());
245 $desc->setValue($grouping->getDescription());
246 $uniq->setValue($grouping->getUniqueField());
247
248 $ass = new ilCustomInputGUI($this->lng->txt('groupings_assigned_obj_' . $this->getContentType()));
249 $form->addItem($ass);
250
251 // assignments
252 $items = array();
253 foreach ($grouping->getAssignedItems() as $cond_data) {
254 $items[] = ilObject::_lookupTitle($cond_data['target_obj_id']);
255 }
256 if ($items !== []) {
257 $ass->setHtml(implode("<br />", $items));
258 } else {
259 $ass->setHtml($this->lng->txt('crs_grp_no_courses_assigned'));
260 }
261
262 $form->setTitle($this->lng->txt('edit_grouping'));
263 $form->addCommandButton('update', $this->lng->txt('save'));
264 $form->addCommandButton('selectCourse', $this->lng->txt('grouping_change_assignment'));
265 }
266 $form->addCommandButton('listGroupings', $this->lng->txt('cancel'));
267 return $form;
268 }
This class represents a custom property in a property form.
static _lookupTitle(int $obj_id)
This class represents a property form user interface.
This class represents a selection list property in a property form.
This class represents a text area property in a property form.
This class represents a text property in a property form.

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

Referenced by add(), create(), edit(), and update().

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

◆ listGroupings()

ilObjCourseGroupingGUI::listGroupings ( )

Definition at line 120 of file class.ilObjCourseGroupingGUI.php.

120 : void
121 {
122 if (!$this->access->checkAccess('write', '', $this->content_obj->getRefId())) {
123 $this->error->raiseError($this->lng->txt('permission_denied'), $this->error->MESSAGE);
124 }
125
126 $this->toolbar->addButton(
127 $this->lng->txt('crs_add_grouping'),
128 $this->ctrl->getLinkTarget($this, 'create')
129 );
130
131 $table = $this->grouping_table_handler->getTable();
132 $this->tpl->setContent($this->ui_renderer->render($table));
133 }

References ILIAS\Repository\access(), error(), ILIAS\Repository\lng(), and ILIAS\Repository\toolbar().

Referenced by askDeleteGrouping(), assignCourse(), and selectCourse().

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

◆ selectCourse()

ilObjCourseGroupingGUI::selectCourse ( )

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

326 : void
327 {
328 if (!$this->access->checkAccess('write', '', $this->content_obj->getRefId())) {
329 $this->error->raiseError($this->lng->txt('permission_denied'), $this->error->MESSAGE);
330 }
331
332 if (!$this->id) {
333 $this->tpl->setOnScreenMessage('failure', $this->lng->txt('crs_grp_no_grouping_id_given'));
334 $this->listGroupings();
335 return;
336 }
337
338 $this->tabs->clearTargets();
339 $this->tabs->setBackTarget(
340 $this->lng->txt('back'),
341 $this->ctrl->getLinkTarget($this, 'edit')
342 );
343
344 $table = $this->assignment_table_handler->getTable();
345 $this->tpl->setContent($this->ui_renderer->render($table));
346 }

References ILIAS\Repository\access(), error(), listGroupings(), ILIAS\Repository\lng(), and ILIAS\Repository\tabs().

+ Here is the call graph for this function:

◆ update()

ilObjCourseGroupingGUI::update ( )

Definition at line 297 of file class.ilObjCourseGroupingGUI.php.

297 : void
298 {
299 if (!$this->access->checkAccess('write', '', $this->content_obj->getRefId())) {
300 $this->error->raiseError($this->lng->txt('permission_denied'), $this->error->MESSAGE);
301 }
302
303 $obj_id = 0;
304 if ($this->http->wrapper()->query()->has('obj_id')) {
305 $obj_id = $this->http->wrapper()->query()->retrieve(
306 'obj_id',
307 $this->refinery->kindlyTo()->int()
308 );
309 }
310 $form = $this->initForm(false);
311 if ($form->checkInput()) {
312 $tmp_grouping = new ilObjCourseGrouping($obj_id);
313 $tmp_grouping->setTitle($form->getInput('title'));
314 $tmp_grouping->setDescription($form->getInput('description'));
315 $tmp_grouping->setUniqueField($form->getInput('unique'));
316 $tmp_grouping->update();
317
318 $this->tpl->setOnScreenMessage('success', $this->lng->txt('settings_saved'), true);
319 $this->ctrl->redirect($this, 'listGroupings');
320 }
321
322 $form->setValuesByPost();
323 $this->edit($form);
324 }
edit(?ilPropertyFormGUI $a_form=null)

References ILIAS\Repository\access(), ILIAS\Repository\ctrl(), edit(), error(), ILIAS\FileDelivery\http(), initForm(), ILIAS\Repository\lng(), and ILIAS\Repository\refinery().

+ Here is the call graph for this function:

Field Documentation

◆ $access

ilAccessHandler ilObjCourseGroupingGUI::$access
protected

Definition at line 43 of file class.ilObjCourseGroupingGUI.php.

◆ $assignment_table_handler

AssignmentTableHandler ilObjCourseGroupingGUI::$assignment_table_handler
protected

Definition at line 51 of file class.ilObjCourseGroupingGUI.php.

◆ $content_obj

ilObject ilObjCourseGroupingGUI::$content_obj
private

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

Referenced by __construct().

◆ $content_type

string ilObjCourseGroupingGUI::$content_type = ''
private

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

Referenced by getContentType().

◆ $ctrl

ilCtrlInterface ilObjCourseGroupingGUI::$ctrl
protected

Definition at line 40 of file class.ilObjCourseGroupingGUI.php.

◆ $error

ilErrorHandling ilObjCourseGroupingGUI::$error
protected

Definition at line 42 of file class.ilObjCourseGroupingGUI.php.

◆ $grouping_table_handler

GroupingTableHandler ilObjCourseGroupingGUI::$grouping_table_handler
protected

Definition at line 50 of file class.ilObjCourseGroupingGUI.php.

◆ $grp_obj

ilObjCourseGrouping ilObjCourseGroupingGUI::$grp_obj
private

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

◆ $http

GlobalHttpState ilObjCourseGroupingGUI::$http
protected

Definition at line 46 of file class.ilObjCourseGroupingGUI.php.

◆ $id

int ilObjCourseGroupingGUI::$id
private

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

◆ $lng

ilLanguage ilObjCourseGroupingGUI::$lng
protected

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

◆ $refinery

RefineryFactory ilObjCourseGroupingGUI::$refinery
protected

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

◆ $tabs

ilTabsGUI ilObjCourseGroupingGUI::$tabs
protected

Definition at line 44 of file class.ilObjCourseGroupingGUI.php.

◆ $toolbar

ilToolbarGUI ilObjCourseGroupingGUI::$toolbar
protected

Definition at line 45 of file class.ilObjCourseGroupingGUI.php.

◆ $tpl

ilGlobalTemplateInterface ilObjCourseGroupingGUI::$tpl
protected

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

◆ $ui_renderer

UIRenderer ilObjCourseGroupingGUI::$ui_renderer
protected

Definition at line 48 of file class.ilObjCourseGroupingGUI.php.


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