ILIAS  release_8 Revision v8.24
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 ()
 
 askDeleteGrouping ()
 
 deleteGrouping ()
 
 create (?ilPropertyFormGUI $a_form=null)
 
 initForm (bool $a_create)
 
 add ()
 
 edit (?ilPropertyFormGUI $a_form=null)
 
 update ()
 
 selectCourse ()
 
 assignCourse ()
 

Protected Attributes

ilGlobalTemplateInterface $tpl
 
ilCtrlInterface $ctrl
 
ilLanguage $lng
 
ilErrorHandling $error
 
ilAccessHandler $access
 
ilTabsGUI $tabs
 
ilToolbarGUI $toolbar
 
GlobalHttpState $http
 
Factory $refinery
 

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 28 of file class.ilObjCourseGroupingGUI.php.

Constructor & Destructor Documentation

◆ __construct()

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

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

46 {
47 global $DIC;
48
49 $this->tpl = $DIC->ui()->mainTemplate();
50 $this->ctrl = $DIC->ctrl();
51 $this->lng = $DIC->language();
52 $this->access = $DIC->access();
53 $this->error = $DIC['ilErr'];
54 $this->tabs = $DIC->tabs();
55 $this->toolbar = $DIC->toolbar();
56 $this->http = $DIC->http();
57 $this->refinery = $DIC->refinery();
58
59 $this->content_obj = $content_obj;
60 $this->content_type = ilObject::_lookupType($this->content_obj->getId());
61
62 $this->id = $a_obj_id;
63 $this->ctrl->saveParameter($this, 'obj_id');
64 $this->__initGroupingObject();
65 }
error(string $a_errmsg)
static _lookupType(int $id, bool $reference=false)
global $DIC
Definition: feed.php:28
static http()
Fetches the global http state from ILIAS.

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 77 of file class.ilObjCourseGroupingGUI.php.

77 : void
78 {
79 $this->grp_obj = new ilObjCourseGrouping($this->id);
80 }
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...

Referenced by __construct().

+ Here is the caller graph for this function:

◆ add()

ilObjCourseGroupingGUI::add ( )

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

232 : void
233 {
234 $form = $this->initForm(true);
235 if ($form->checkInput()) {
236 $this->grp_obj->setTitle($form->getInput('title'));
237 $this->grp_obj->setDescription($form->getInput('description'));
238 $this->grp_obj->setUniqueField($form->getInput('unique'));
239
240 $this->grp_obj->create($this->content_obj->getRefId(), $this->content_obj->getId());
241 $this->tpl->setOnScreenMessage('success', $this->lng->txt('crs_grp_added_grouping'), true);
242 $this->ctrl->redirect($this, 'listGroupings');
243 }
244 $form->setValuesByPost();
245 $this->create($form);
246 }
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 ( )

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

102 : void
103 {
104 if (!$this->access->checkAccess('write', '', $this->content_obj->getRefId())) {
105 $this->error->raiseError($this->lng->txt('permission_denied'), $this->error->MESSAGE);
106 }
107
108 $grouping = [];
109 if ($this->http->wrapper()->post()->has('grouping')) {
110 $grouping = $this->http->wrapper()->post()->retrieve(
111 'grouping',
112 $this->refinery->kindlyTo()->listOf(
113 $this->refinery->kindlyTo()->int()
114 )
115 );
116 }
117
118 if (!count($grouping)) {
119 $this->tpl->setOnScreenMessage('failure', $this->lng->txt('crs_grouping_select_one'));
120 $this->listGroupings();
121 return;
122 }
123
124 // display confirmation message
125 $cgui = new ilConfirmationGUI();
126 $cgui->setFormAction($this->ctrl->getFormAction($this));
127 $cgui->setHeaderText($this->lng->txt("crs_grouping_delete_sure"));
128 $cgui->setCancel($this->lng->txt("cancel"), "listGroupings");
129 $cgui->setConfirm($this->lng->txt("delete"), "deleteGrouping");
130
131 // list objects that should be deleted
132 foreach ($grouping as $grouping_id) {
133 $tmp_obj = new ilObjCourseGrouping($grouping_id);
134 $cgui->addItem("grouping[]", $grouping_id, $tmp_obj->getTitle());
135 }
136 $this->tpl->setContent($cgui->getHTML());
137 }
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(), ILIAS\FileDelivery\http(), listGroupings(), ILIAS\Repository\lng(), and ILIAS\Repository\refinery().

+ Here is the call graph for this function:

◆ assignCourse()

ilObjCourseGroupingGUI::assignCourse ( )

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

310 : void
311 {
312 if (!$this->access->checkAccess('write', '', $this->content_obj->getRefId())) {
313 $this->error->raiseError($this->lng->txt('permission_denied'), $this->error->MESSAGE);
314 }
315
316 if (!$this->id) {
317 $this->listGroupings();
318 return;
319 }
320
321 // delete all existing conditions
322 $condh = new ilConditionHandler();
323 $condh->deleteByObjId($this->id);
324
325 $added = 0;
326 $container_ids = [];
327 if ($this->http->wrapper()->post()->has('crs_ids')) {
328 $container_ids = $this->http->wrapper()->post()->retrieve(
329 'crs_ids',
330 $this->refinery->kindlyTo()->listOf(
331 $this->refinery->kindlyTo()->int()
332 )
333 );
334 }
335
336 foreach ($container_ids as $course_ref_id) {
337 $tmp_crs = ilObjectFactory::getInstanceByRefId($course_ref_id);
338 $tmp_condh = new ilConditionHandler();
339 $tmp_condh->enableAutomaticValidation(false);
340
341 $tmp_condh->setTargetRefId($course_ref_id);
342 $tmp_condh->setTargetObjId($tmp_crs->getId());
343 $tmp_condh->setTargetType($this->getContentType());
344 $tmp_condh->setTriggerRefId(0);
345 $tmp_condh->setTriggerObjId($this->id);
346 $tmp_condh->setTriggerType('crsg');
347 $tmp_condh->setOperator('not_member');
348 $tmp_condh->setValue($this->grp_obj->getUniqueField());
349
350 if (!$tmp_condh->checkExists()) {
351 $tmp_condh->storeCondition();
352 ++$added;
353 }
354 }
355
356 $this->tpl->setOnScreenMessage('success', $this->lng->txt('settings_saved'), true);
357 $this->ctrl->redirect($this, 'edit');
358 }
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
static getInstanceByRefId(int $ref_id, bool $stop_on_error=true)
get an instance of an Ilias object by reference id

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

+ Here is the call graph for this function:

◆ create()

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

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

163 : void
164 {
165 if (!$this->access->checkAccess('write', '', $this->content_obj->getRefId())) {
166 $this->error->raiseError($this->lng->txt('permission_denied'), $this->error->MESSAGE);
167 }
168
169 if (!$a_form) {
170 $a_form = $this->initForm(true);
171 }
172
173 $this->tpl->setContent($a_form->getHTML());
174 }

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 139 of file class.ilObjCourseGroupingGUI.php.

139 : void
140 {
141 if (!$this->access->checkAccess('write', '', $this->content_obj->getRefId())) {
142 $this->error->raiseError($this->lng->txt('permission_denied'), $this->error->MESSAGE);
143 }
144 $grouping = [];
145 if ($this->http->wrapper()->post()->has('grouping')) {
146 $grouping = $this->http->wrapper()->post()->retrieve(
147 'grouping',
148 $this->refinery->kindlyTo()->listOf(
149 $this->refinery->kindlyTo()->int()
150 )
151 );
152 }
153
154 foreach ($grouping as $grouping_id) {
155 $tmp_obj = new ilObjCourseGrouping((int) $grouping_id);
156 $tmp_obj->delete();
157 }
158
159 $this->tpl->setOnScreenMessage('success', $this->lng->txt('crs_grouping_deleted'), true);
160 $this->ctrl->redirect($this, 'listGroupings');
161 }

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 248 of file class.ilObjCourseGroupingGUI.php.

248 : void
249 {
250 if (!$this->access->checkAccess('write', '', $this->content_obj->getRefId())) {
251 $this->error->raiseError($this->lng->txt('permission_denied'), $this->error->MESSAGE);
252 }
253 if (!$a_form) {
254 $a_form = $this->initForm(false);
255 }
256 $this->tpl->setContent($a_form->getHTML());
257 }

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 67 of file class.ilObjCourseGroupingGUI.php.

67 : void
68 {
69 $this->tabs->setTabActive('crs_groupings');
70 $cmd = $this->ctrl->getCmd();
71 if (!$cmd = $this->ctrl->getCmd()) {
72 $cmd = "edit";
73 }
74 $this->$cmd();
75 }

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

+ Here is the call graph for this function:

◆ getContentType()

ilObjCourseGroupingGUI::getContentType ( )

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

82 : string
83 {
85 }

References $content_type.

Referenced by assignCourse().

+ Here is the caller graph for this function:

◆ initForm()

ilObjCourseGroupingGUI::initForm ( bool  $a_create)

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

177 {
178 $form = new ilPropertyFormGUI();
179 $form->setFormAction($this->ctrl->getFormAction($this));
180
181 $title = new ilTextInputGUI($this->lng->txt('title'), 'title');
182 $title->setRequired(true);
183 $form->addItem($title);
184
185 $desc = new ilTextAreaInputGUI($this->lng->txt('description'), 'description');
186 $form->addItem($desc);
187
188 $options = array('login' => 'login',
189 'email' => 'email',
190 'matriculation' => 'matriculation'
191 );
192
193 foreach ($options as $value => $caption) {
194 $options[$value] = $this->lng->txt($caption);
195 }
196 $uniq = new ilSelectInputGUI($this->lng->txt('unambiguousness'), 'unique');
197 $uniq->setRequired(true);
198 $uniq->setOptions($options);
199 $form->addItem($uniq);
200
201 if ($a_create) {
202 $form->setTitle($this->lng->txt('crs_add_grouping'));
203 $form->addCommandButton('add', $this->lng->txt('btn_add'));
204 } else {
205 $grouping = new ilObjCourseGrouping($this->id);
206 $title->setValue($grouping->getTitle());
207 $desc->setValue($grouping->getDescription());
208 $uniq->setValue($grouping->getUniqueField());
209
210 $ass = new ilCustomInputGUI($this->lng->txt('groupings_assigned_obj_' . $this->getContentType()));
211 $form->addItem($ass);
212
213 // assignments
214 $items = array();
215 foreach ($grouping->getAssignedItems() as $cond_data) {
216 $items[] = ilObject::_lookupTitle($cond_data['target_obj_id']);
217 }
218 if ($items !== []) {
219 $ass->setHtml(implode("<br />", $items));
220 } else {
221 $ass->setHtml($this->lng->txt('crs_grp_no_courses_assigned'));
222 }
223
224 $form->setTitle($this->lng->txt('edit_grouping'));
225 $form->addCommandButton('update', $this->lng->txt('save'));
226 $form->addCommandButton('selectCourse', $this->lng->txt('grouping_change_assignment'));
227 }
228 $form->addCommandButton('listGroupings', $this->lng->txt('cancel'));
229 return $form;
230 }
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
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 87 of file class.ilObjCourseGroupingGUI.php.

87 : void
88 {
89 if (!$this->access->checkAccess('write', '', $this->content_obj->getRefId())) {
90 $this->error->raiseError($this->lng->txt('permission_denied'), $this->error->MESSAGE);
91 }
92
93 $this->toolbar->addButton(
94 $this->lng->txt('crs_add_grouping'),
95 $this->ctrl->getLinkTarget($this, 'create')
96 );
97
98 $table = new ilCourseGroupingTableGUI($this, 'listGroupings', $this->content_obj);
99 $this->tpl->setContent($table->getHTML());
100 }
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...

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 288 of file class.ilObjCourseGroupingGUI.php.

288 : void
289 {
290 if (!$this->access->checkAccess('write', '', $this->content_obj->getRefId())) {
291 $this->error->raiseError($this->lng->txt('permission_denied'), $this->error->MESSAGE);
292 }
293
294 if (!$this->id) {
295 $this->tpl->setOnScreenMessage('failure', $this->lng->txt('crs_grp_no_grouping_id_given'));
296 $this->listGroupings();
297 return;
298 }
299
300 $this->tabs->clearTargets();
301 $this->tabs->setBackTarget(
302 $this->lng->txt('back'),
303 $this->ctrl->getLinkTarget($this, 'edit')
304 );
305 $tmp_grouping = new ilObjCourseGrouping($this->id);
306 $table = new ilCourseGroupingAssignmentTableGUI($this, 'selectCourse', $this->content_obj, $tmp_grouping);
307 $this->tpl->setContent($table->getHTML());
308 }
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...

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 259 of file class.ilObjCourseGroupingGUI.php.

259 : void
260 {
261 if (!$this->access->checkAccess('write', '', $this->content_obj->getRefId())) {
262 $this->error->raiseError($this->lng->txt('permission_denied'), $this->error->MESSAGE);
263 }
264
265 $obj_id = 0;
266 if ($this->http->wrapper()->query()->has('obj_id')) {
267 $obj_id = $this->http->wrapper()->query()->retrieve(
268 'obj_id',
269 $this->refinery->kindlyTo()->int()
270 );
271 }
272 $form = $this->initForm(false);
273 if ($form->checkInput()) {
274 $tmp_grouping = new ilObjCourseGrouping($obj_id);
275 $tmp_grouping->setTitle($form->getInput('title'));
276 $tmp_grouping->setDescription($form->getInput('description'));
277 $tmp_grouping->setUniqueField($form->getInput('unique'));
278 $tmp_grouping->update();
279
280 $this->tpl->setOnScreenMessage('success', $this->lng->txt('settings_saved'), true);
281 $this->ctrl->redirect($this, 'listGroupings');
282 }
283
284 $form->setValuesByPost();
285 $this->edit($form);
286 }
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 39 of file class.ilObjCourseGroupingGUI.php.

◆ $content_obj

ilObject ilObjCourseGroupingGUI::$content_obj
private

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

Referenced by __construct().

◆ $content_type

string ilObjCourseGroupingGUI::$content_type = ''
private

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

Referenced by getContentType().

◆ $ctrl

ilCtrlInterface ilObjCourseGroupingGUI::$ctrl
protected

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

◆ $error

ilErrorHandling ilObjCourseGroupingGUI::$error
protected

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

◆ $grp_obj

ilObjCourseGrouping ilObjCourseGroupingGUI::$grp_obj
private

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

◆ $http

GlobalHttpState ilObjCourseGroupingGUI::$http
protected

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

◆ $id

int ilObjCourseGroupingGUI::$id
private

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

◆ $lng

ilLanguage ilObjCourseGroupingGUI::$lng
protected

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

◆ $refinery

Factory ilObjCourseGroupingGUI::$refinery
protected

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

◆ $tabs

ilTabsGUI ilObjCourseGroupingGUI::$tabs
protected

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

◆ $toolbar

ilToolbarGUI ilObjCourseGroupingGUI::$toolbar
protected

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

◆ $tpl

ilGlobalTemplateInterface ilObjCourseGroupingGUI::$tpl
protected

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


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