ILIAS  release_5-3 Revision v5.3.23-19-g915713cf615
class.ilCourseParticipantsGroupsTableGUI.php
Go to the documentation of this file.
1<?php
2/* Copyright (c) 1998-2010 ILIAS open source, Extended GPL, see docs/LICENSE */
3
4include_once("./Services/Table/classes/class.ilTable2GUI.php");
5
15{
16 protected $filter; // array
17 protected $groups; // array
18 protected $groups_rights; // array
19 protected $participants; // array
20
24 public function __construct($a_parent_obj, $a_parent_cmd, $ref_id)
25 {
26 global $ilCtrl, $ilObjDataCache,$lng;
27
28 $lng->loadLanguageModule('grp');
29
30 $this->ref_id = $ref_id;
31 $this->obj_id = $ilObjDataCache->lookupObjId($this->ref_id);
32
33 $this->setId('tblcrsprtgrp_' . $ref_id);
34
35 parent::__construct($a_parent_obj, $a_parent_cmd);
36 // $this->setTitle($lng->txt("tr_summary"));
37 $this->setLimit(9999);
38 // $this->setShowTemplates(true);
39
40 $this->setTitle($this->lng->txt('crs_grp_assignments'));
41
42 $this->addColumn('', '', 0);
43 $this->addColumn($this->lng->txt("name"), "name", '35%');
44 $this->addColumn($this->lng->txt("login"), "login", '35%');
45 $this->addColumn($this->lng->txt("crs_groups_nr"), "groups_number");
46 $this->addColumn($this->lng->txt("groups"));
47
48 // $this->setExternalSorting(true);
49 $this->setEnableHeader(true);
50 $this->setFormAction($ilCtrl->getFormAction($a_parent_obj, $a_parent_cmd));
51 $this->setRowTemplate("tpl.crs_members_grp_row.html", "Modules/Course");
52 $this->setSelectAllCheckbox("usrs");
53
54 $this->initGroups();
55
56 if ($this->groups) {
57 $selectable_groups = [];
58 foreach ($this->groups as $ref_id => $something) {
59 if ($this->groups_rights[$ref_id]['manage_members']) {
60 $selectable_groups[$ref_id] = $this->groups[$ref_id];
61 }
62 }
63 if (count($selectable_groups)) {
65 "grp_id",
66 $selectable_groups,
67 "add",
68 $this->lng->txt("crs_add_to_group")
69 );
70 }
71 $this->initFilter();
72 }
73
74
75
76 $this->getItems();
77 }
78
82 public function initGroups()
83 {
84 global $tree, $ilAccess;
85
86 $parent_node = $tree->getNodeData($this->ref_id);
87 $groups = $tree->getSubTree($parent_node, true, "grp");
88 if (is_array($groups) && sizeof($groups)) {
89 include_once('./Modules/Group/classes/class.ilGroupParticipants.php');
90 $this->participants = $this->groups = $this->groups_rights = array();
91 foreach ($groups as $idx => $group_data) {
92 // check for group in group
93 if ($group_data["parent"] != $this->ref_id && $tree->checkForParentType($group_data["ref_id"], "grp", true)) {
94 unset($groups[$idx]);
95 } else {
96 $this->groups[$group_data["ref_id"]] = $group_data["title"];
97 $this->groups_rights[$group_data["ref_id"]]["manage_members"] = (bool)
98 $GLOBALS['DIC']->access()->checkRbacOrPositionPermissionAccess(
99 'manage_members',
100 'manage_members',
101 $group_data['ref_id']
102 )
103 ;
104
105 $this->groups_rights[$group_data["ref_id"]]["edit_permission"] = (bool)
106 $GLOBALS['DIC']->access()->checkAccess(
107 "edit_permission",
108 "",
109 $group_data["ref_id"]
110 );
111
112 $gobj = ilGroupParticipants::_getInstanceByObjId($group_data["obj_id"]);
113
114 $members = $GLOBALS['DIC']->access()->filterUserIdsByRbacOrPositionOfCurrentUser(
115 'manage_members',
116 'manage_members',
117 $group_data['ref_id'],
118 $gobj->getMembers()
119 );
120 $admins = $GLOBALS['DIC']->access()->filterUserIdsByRbacOrPositionOfCurrentUser(
121 'manage_members',
122 'manage_members',
123 $group_data['ref_id'],
124 $gobj->getAdmins()
125 );
126
127 $this->participants[$group_data["ref_id"]]["members"] = $members;
128 $this->participants[$group_data["ref_id"]]["admins"] = $admins;
129 }
130 }
131 }
132 }
133
137 public function initFilter()
138 {
139 global $lng;
140
142 $this->filter["name"] = $item->getValue();
143
144 if ($this->groups) {
146 $item->setOptions(array("" => $lng->txt("all"))+$this->groups);
147 $this->filter["group"] = $item->getValue();
148 }
149 }
150
154 public function getItems()
155 {
156 if ($this->groups) {
157 include_once('./Modules/Course/classes/class.ilCourseParticipants.php');
158 $part = ilCourseParticipants::_getInstanceByObjId($this->obj_id);
159 $members = $GLOBALS['DIC']->access()->filterUserIdsByRbacOrPositionOfCurrentUser(
160 'manage_members',
161 'manage_members',
162 $this->ref_id,
163 $part->getMembers()
164 );
165
166 if (count($members)) {
167 include_once './Services/User/classes/class.ilUserUtil.php';
168 $usr_data = array();
169 foreach ($members as $usr_id) {
170 $name = ilObjUser::_lookupName($usr_id);
171 // #9984
172 $user_groups = array("members"=>array(),"admins"=>array());
173 $user_groups_number = 0;
174 foreach (array_keys($this->participants) as $group_id) {
175 if (in_array($usr_id, $this->participants[$group_id]["members"])) {
176 $user_groups["members"][$group_id] = $this->groups[$group_id];
177 $user_groups_number++;
178 } elseif (in_array($usr_id, $this->participants[$group_id]["admins"])) {
179 $user_groups["admins"][$group_id] = $this->groups[$group_id];
180 $user_groups_number++;
181 }
182 }
183
184 if ((!$this->filter["name"] || stristr(implode("", $name), $this->filter["name"])) &&
185 (!$this->filter["group"] || array_key_exists($this->filter["group"], $user_groups["members"]) ||
186 array_key_exists($this->filter["group"], $user_groups["admins"]))) {
187 $usr_data[] = array("usr_id" => $usr_id,
188 "name" => $name["lastname"] . ", " . $name["firstname"],
189 "groups" => $user_groups,
190 "groups_number" => $user_groups_number,
191 "login" => $name["login"]
192 );
193 }
194 }
195
196 // ???
197 $usr_data = array_slice($usr_data, (int) $this->getOffset(), (int) $this->getLimit());
198
199 $this->setMaxCount(sizeof($members));
200 $this->setData($usr_data);
201 }
202
203 return $titles;
204 }
205 }
206
210 protected function fillRow($a_set)
211 {
212 global $lng, $ilCtrl;
213
214 $this->tpl->setVariable("VAL_ID", $a_set["usr_id"]);
215
216 $this->tpl->setVariable("TXT_USER", $a_set["name"]);
217 $this->tpl->setVariable("TXT_LOGIN", $a_set["login"]);
218 $this->tpl->setVariable("VAL_GROUP_NUMBER", $a_set["groups_number"]);
219
220 if (sizeof($a_set["groups"])) {
221 foreach ($a_set["groups"] as $type => $groups) {
222 foreach ($groups as $grp_id => $title) {
223 if (
224 ($type == "admins" && $this->groups_rights[$grp_id]["edit_permission"]) ||
225 ($type == "members" && $this->groups_rights[$grp_id]["manage_members"])
226 ) {
227 $this->tpl->setCurrentBlock("groups_remove");
228
229 $this->tpl->setVariable("TXT_GROUP_REMOVE", $lng->txt("grp_unsubscribe"));
230
231 $ilCtrl->setParameter($this->parent_obj, "usr_id", $a_set["usr_id"]);
232 $ilCtrl->setParameter($this->parent_obj, "grp_id", $grp_id);
233 $this->tpl->setVariable("URL_REMOVE", $ilCtrl->getLinkTarget($this->parent_obj, "confirmremove"));
234 $ilCtrl->setParameter($this->parent_obj, "grp_id", "");
235 $ilCtrl->setParameter($this->parent_obj, "usr_id", "");
236
237 $this->tpl->parseCurrentBlock();
238 }
239
240 $this->tpl->setCurrentBlock("groups");
241 $this->tpl->setVariable("TXT_GROUP_TITLE", $title);
242 $this->tpl->parseCurrentBlock();
243 }
244 }
245 }
246 }
247}
An exception for terminatinating execution or to throw for unit testing.
__construct($a_parent_obj, $a_parent_cmd, $ref_id)
Constructor.
initGroups()
find groups in course, exclude groups in groups
getItems()
Build item rows for given object and filter(s)
static _getInstanceByObjId($a_obj_id)
Get singleton instance.
static _getInstanceByObjId($a_obj_id)
Get singleton instance.
static _lookupName($a_user_id)
lookup user name
Class ilTable2GUI.
setEnableHeader($a_enableheader)
Set Enable Header.
setTitle($a_title, $a_icon=0, $a_icon_alt=0)
Set title and title icon.
setData($a_data)
set table data @access public
getLimit()
Get limit.
setRowTemplate($a_template, $a_template_dir="")
Set row template.
setLimit($a_limit=0, $a_default_limit=0)
set max.
setSelectAllCheckbox($a_select_all_checkbox)
Set the name of the checkbox that should be toggled with a select all button.
addColumn( $a_text, $a_sort_field="", $a_width="", $a_is_checkbox_action_column=false, $a_class="", $a_tooltip="", $a_tooltip_with_html=false)
Add a column to the header.
addFilterItemByMetaType($id, $type=self::FILTER_TEXT, $a_optional=false, $caption=null)
Add filter by standard type.
getOffset()
Get offset.
setId($a_val)
Set id.
setFormAction($a_form_action, $a_multipart=false)
Set Form action parameter.
addMultiItemSelectionButton($a_sel_var, $a_options, $a_cmd, $a_text, $a_default_selection='')
Add Selection List + Command button for selected items.
setMaxCount($a_max_count)
set max.
$GLOBALS['loaded']
Global hash that tracks already loaded includes.
global $ilCtrl
Definition: ilias.php:18
if($format !==null) $name
Definition: metadata.php:146
$type