ILIAS  release_5-3 Revision v5.3.23-19-g915713cf615
class.ilGroupMembershipGUI.php
Go to the documentation of this file.
1 <?php
2 
3 /* Copyright (c) 1998-2010 ILIAS open source, Extended GPL, see docs/LICENSE */
4 
5 include_once './Services/Membership/classes/class.ilMembershipGUI.php';
6 
19 {
25  public function filterUserIdsByRbacOrPositionOfCurrentUser($a_user_ids)
26  {
27  return $GLOBALS['DIC']->access()->filterUserIdsByRbacOrPositionOfCurrentUser(
28  'manage_members',
29  'manage_members',
30  $this->getParentObject()->getRefId(),
31  $a_user_ids
32  );
33  }
34 
38  public function assignMembers($user_ids, $a_type)
39  {
40  if (empty($user_ids[0])) {
41  $this->lng->loadLanguageModule('search');
42  ilUtil::sendFailure($this->lng->txt('search_err_user_not_exist'), true);
43  return false;
44  }
45 
46  $assigned = false;
47  foreach ((array) $user_ids as $new_member) {
48  if ($this->getMembersObject()->isAssigned($new_member)) {
49  continue;
50  }
51  switch ($a_type) {
52  case $this->getParentObject()->getDefaultAdminRole():
53  $this->getMembersObject()->add($new_member, IL_GRP_ADMIN);
54  include_once './Modules/Group/classes/class.ilGroupMembershipMailNotification.php';
55  $this->getMembersObject()->sendNotification(
57  $new_member
58  );
59  $assigned = true;
60  break;
61 
62  case $this->getParentObject()->getDefaultMemberRole():
63  $this->getMembersObject()->add($new_member, IL_GRP_MEMBER);
64  include_once './Modules/Group/classes/class.ilGroupMembershipMailNotification.php';
65  $this->getMembersObject()->sendNotification(
67  $new_member
68  );
69  $assigned = true;
70  break;
71 
72  default:
73  if (in_array($a_type, $this->getParentObject()->getLocalGroupRoles(true))) {
74  $this->getMembersObject()->add($new_member, IL_GRP_MEMBER);
75  $this->getMembersObject()->updateRoleAssignments($new_member, (array) $a_type);
76  } else {
77  ilLoggerFactory::getLogger('crs')->notice('Can not find role with id .' . $a_type . ' to assign users.');
78  ilUtil::sendFailure($this->lng->txt("crs_cannot_find_role"), true);
79  return false;
80  }
81  include_once './Modules/Group/classes/class.ilGroupMembershipMailNotification.php';
82  $this->getMembersObject()->sendNotification(
84  $new_member
85  );
86  $assigned = true;
87  break;
88  }
89  }
90 
91  if ($assigned) {
92  ilUtil::sendSuccess($this->lng->txt("grp_msg_member_assigned"), true);
93  } else {
94  ilUtil::sendSuccess($this->lng->txt('grp_users_already_assigned'), true);
95  }
96  $this->ctrl->redirect($this, 'participants');
97  }
98 
102  protected function updateParticipantsStatus()
103  {
104  $participants = (array) $_POST['visible_member_ids'];
105  $notification = (array) $_POST['notification'];
106  foreach ($participants as $mem_id) {
107  if ($this->getMembersObject()->isAdmin($mem_id)) {
108  $this->getMembersObject()->updateNotification($mem_id, in_array($mem_id, $notification));
109  } else {
110  $this->getMembersObject()->updateNotification($mem_id, false);
111  }
112  }
113  ilUtil::sendSuccess($this->lng->txt('settings_saved'), true);
114  $this->ctrl->redirect($this, 'participants');
115  }
116 
117 
121  protected function initParticipantTableGUI()
122  {
123  include_once './Services/Tracking/classes/class.ilObjUserTracking.php';
124  $show_tracking =
126  ;
127  if ($show_tracking) {
128  include_once('./Services/Object/classes/class.ilObjectLP.php');
129  $olp = ilObjectLP::getInstance($this->getParentObject()->getId());
130  $show_tracking = $olp->isActive();
131  }
132 
133  include_once './Modules/Group/classes/class.ilGroupParticipantsTableGUI.php';
134  return new ilGroupParticipantsTableGUI(
135  $this,
136  $this->getParentObject(),
137  $show_tracking
138  );
139  }
140 
146  protected function initEditParticipantTableGUI(array $participants)
147  {
148  include_once './Modules/Group/classes/class.ilGroupEditParticipantsTableGUI.php';
150  $table->setTitle($this->lng->txt($this->getParentObject()->getType() . '_header_edit_members'));
151  $table->setData($this->getParentGUI()->readMemberData($participants));
152 
153  return $table;
154  }
155 
156 
157 
161  protected function initParticipantTemplate()
162  {
163  $this->tpl->addBlockFile('ADM_CONTENT', 'adm_content', 'tpl.grp_edit_members.html', 'Modules/Group');
164  }
165 
169  public function getLocalTypeRole($a_translation = false)
170  {
171  return $this->getParentObject()->getLocalGroupRoles($a_translation);
172  }
173 
177  protected function updateLPFromStatus()
178  {
179  return null;
180  }
181 
186  protected function initWaitingList()
187  {
188  include_once './Modules/Group/classes/class.ilGroupWaitingList.php';
189  $wait = new ilGroupWaitingList($this->getParentObject()->getId());
190  return $wait;
191  }
192 
196  protected function getDefaultRole()
197  {
198  return $this->getParentGUI()->object->getDefaultMemberRole();
199  }
200 
205  public function getPrintMemberData($a_members)
206  {
207  $member_data = $this->readMemberData($a_members, array());
208  $member_data = $this->getParentGUI()->addCustomData($member_data);
209  return $member_data;
210  }
211 
217  public function getAttendanceListUserData($a_user_id)
218  {
219  if ($this->filterUserIdsByRbacOrPositionOfCurrentUser([$a_user_id])) {
220  $data = $this->member_data[$a_user_id];
221  $data['access'] = $data['access_time'];
222  $data['progress'] = $this->lng->txt($data['progress']);
223  return $data;
224  }
225  return [];
226  }
227 }
static sendSuccess($a_info="", $a_keep=false)
Send Success Message to Screen.
readMemberData(array $usr_ids, array $columns)
Required for member table guis.
Base class for member tab content.
updateLPFromStatus()
Update lp from status.
getMembersObject()
Get member object.
const IL_GRP_ADMIN
initParticipantTemplate()
Init participant view template.
$GLOBALS['loaded']
Global hash that tracks already loaded includes.
const IL_GRP_MEMBER
assignMembers($user_ids, $a_type)
public
$a_type
Definition: workflow.php:92
static _enabledUserRelatedData()
check wether user related tracking is enabled or not
static _enabledLearningProgress()
check wether learing progress is enabled or not
initWaitingList()
init waiting list
updateParticipantsStatus()
save in participants table
Waiting list for groups.
initEditParticipantTableGUI(array $participants)
init edit participants table gui
getParentGUI()
Get parent gui.
Create styles array
The data for the language used.
static sendFailure($a_info="", $a_keep=false)
Send Failure Message to Screen.
GUI class for membership features.
static getLogger($a_component_id)
Get component logger.
getParentObject()
Get parent object.
if(empty($password)) $table
Definition: pwgen.php:24
static getInstance($a_obj_id)
getLocalTypeRole($a_translation=false)
$_POST["username"]
getAttendanceListUserData($a_user_id)
Callback from attendance list.
filterUserIdsByRbacOrPositionOfCurrentUser($a_user_ids)
Filter user ids by access.