ILIAS  release_8 Revision v8.24
class.ilCourseGroupingAssignmentTableGUI.php
Go to the documentation of this file.
1<?php
2
3declare(strict_types=0);
26{
27 private string $type = '';
28
29 protected ilObjUser $user;
30 protected ilTree $tree;
31
32 public function __construct(
33 object $a_parent_obj,
34 string $a_parent_cmd,
35 ilObject $a_content_obj,
36 ilObjCourseGrouping $a_group_obj
37 ) {
38 global $DIC;
39
40 $this->user = $DIC->user();
41 $this->tree = $DIC->repositoryTree();
42
43 parent::__construct($a_parent_obj, $a_parent_cmd);
44 $this->type = ilObject::_lookupType($a_content_obj->getId());
45 $this->lng->loadLanguageModule($this->type);
46
47 // #9017
48 $this->setLimit(9999);
49
50 $this->addColumn('', '', '1');
51 $this->addColumn($this->lng->txt('title'), 'title');
52 $this->addColumn($this->lng->txt('path'), 'path');
53
54 $this->setDefaultOrderField('title');
55 $this->setDefaultOrderDirection('asc');
56
57 $this->setTitle($this->lng->txt('crs_grp_assign_crs') . ' (' . $a_group_obj->getTitle() . ')');
58
59 $this->setRowTemplate("tpl.crs_grp_select_crs.html", "Modules/Course");
60 $this->setFormAction($this->ctrl->getFormAction($a_parent_obj));
61
62 $this->addMultiCommand('assignCourse', $this->lng->txt('grouping_change_assignment'));
63 $this->addCommandButton('edit', $this->lng->txt('cancel'));
64
65 $this->getItems($a_group_obj);
66 }
67
68 protected function getItems(ilObjCourseGrouping $a_group_obj): void
69 {
71 $this->type,
72 'write',
73 $this->user->getId(),
74 -1
75 );
76 $items_obj_id = array();
77 $items_ids = array();
78 foreach ($items as $ref_id) {
80 $items_ids[$obj_id] = $ref_id;
81 $items_obj_id[] = $obj_id;
82 }
83 $items_obj_id = ilUtil::_sortIds($items_obj_id, 'object_data', 'title', 'obj_id');
84
85 $assigned_ids = array();
86 $assigned = $a_group_obj->getAssignedItems();
87 if ($assigned !== []) {
88 foreach ($assigned as $item) {
89 $assigned_ids[] = $item['target_ref_id'];
90 }
91 }
92
93 $data = array();
94 foreach ($items_obj_id as $obj_id) {
95 $item_id = $items_ids[$obj_id];
96 if ($this->tree->checkForParentType($item_id, 'adm')) {
97 continue;
98 }
99
100 $obj_id = ilObject::_lookupObjId($item_id);
101
102 $data[] = array('id' => $item_id,
103 'title' => ilObject::_lookupTitle($obj_id),
104 'description' => ilObject::_lookupDescription($obj_id),
105 'path' => $this->__formatPath($this->tree->getPathFull($item_id)),
106 'assigned' => in_array($item_id, $assigned_ids)
107 );
108 }
109 $this->setData($data);
110 }
111
115 public function __formatPath(array $a_path_arr): string
116 {
117 $counter = 0;
118 $path = '';
119 foreach ($a_path_arr as $data) {
120 if (!$counter++) {
121 continue;
122 }
123 if ($counter++ > 2) {
124 $path .= " -> ";
125 }
126 $path .= $data['title'];
127 }
128 return $path;
129 }
130
131 protected function fillRow(array $a_set): void
132 {
133 $this->tpl->setVariable("ID", $a_set["id"]);
134 $this->tpl->setVariable("TXT_TITLE", $a_set["title"]);
135 $this->tpl->setVariable("TXT_PATH", $a_set["path"]);
136
137 if ($a_set["assigned"]) {
138 $this->tpl->setVariable("STATUS_CHECKED", " checked=\"checked\"");
139 }
140 }
141}
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
__construct(object $a_parent_obj, string $a_parent_cmd, ilObject $a_content_obj, ilObjCourseGrouping $a_group_obj)
fillRow(array $a_set)
Standard Version of Fill Row.
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
User class.
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
static _lookupType(int $id, bool $reference=false)
static _lookupObjId(int $ref_id)
static _lookupTitle(int $obj_id)
static _lookupDescription(int $obj_id)
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
setLimit(int $a_limit=0, int $a_default_limit=0)
set max.
setTitle(string $a_title, string $a_icon="", string $a_icon_alt="")
addCommandButton(string $a_cmd, string $a_text, string $a_onclick='', string $a_id="", string $a_class="")
addMultiCommand(string $a_cmd, string $a_text)
setFormAction(string $a_form_action, bool $a_multipart=false)
addColumn(string $a_text, string $a_sort_field="", string $a_width="", bool $a_is_checkbox_action_column=false, string $a_class="", string $a_tooltip="", bool $a_tooltip_with_html=false)
setDefaultOrderField(string $a_defaultorderfield)
setRowTemplate(string $a_template, string $a_template_dir="")
Set row template.
setDefaultOrderDirection(string $a_defaultorderdirection)
setData(array $a_data)
Set table data.
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
static _sortIds(array $a_ids, string $a_table, string $a_field, string $a_id_name)
Function that sorts ids by a given table field using WHERE IN E.g: __sort(array(6,...
static _getObjectsByOperations( $a_obj_type, string $a_operation, int $a_usr_id=0, int $limit=0)
Get all objects of a specific type and check access This function is not recursive,...
global $DIC
Definition: feed.php:28
$ref_id
Definition: ltiauth.php:67
$path
Definition: ltiservices.php:32
__construct(Container $dic, ilPlugin $plugin)
@inheritDoc