ILIAS  release_5-4 Revision v5.4.26-12-gabc799a52e6
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 {
23  protected function getMailMemberRoles()
24  {
25  return new ilMailMemberGroupRoles();
26  }
27 
28 
34  public function filterUserIdsByRbacOrPositionOfCurrentUser($a_user_ids)
35  {
36  return $GLOBALS['DIC']->access()->filterUserIdsByRbacOrPositionOfCurrentUser(
37  'manage_members',
38  'manage_members',
39  $this->getParentObject()->getRefId(),
40  $a_user_ids
41  );
42  }
43 
47  public function assignMembers($user_ids, $a_type)
48  {
49  if (empty($user_ids[0])) {
50  $this->lng->loadLanguageModule('search');
51  ilUtil::sendFailure($this->lng->txt('search_err_user_not_exist'), true);
52  return false;
53  }
54 
55  $assigned = false;
56  foreach ((array) $user_ids as $new_member) {
57  if ($this->getMembersObject()->isAssigned($new_member)) {
58  continue;
59  }
60  switch ($a_type) {
61  case $this->getParentObject()->getDefaultAdminRole():
62  $this->getMembersObject()->add($new_member, IL_GRP_ADMIN);
63  include_once './Modules/Group/classes/class.ilGroupMembershipMailNotification.php';
64  $this->getMembersObject()->sendNotification(
66  $new_member
67  );
68  $assigned = true;
69  break;
70 
71  case $this->getParentObject()->getDefaultMemberRole():
72  $this->getMembersObject()->add($new_member, IL_GRP_MEMBER);
73  include_once './Modules/Group/classes/class.ilGroupMembershipMailNotification.php';
74  $this->getMembersObject()->sendNotification(
76  $new_member
77  );
78  $assigned = true;
79  break;
80 
81  default:
82  if (in_array($a_type, $this->getParentObject()->getLocalGroupRoles(true))) {
83  $this->getMembersObject()->add($new_member, IL_GRP_MEMBER);
84  $this->getMembersObject()->updateRoleAssignments($new_member, (array) $a_type);
85  } else {
86  ilLoggerFactory::getLogger('crs')->notice('Can not find role with id .' . $a_type . ' to assign users.');
87  ilUtil::sendFailure($this->lng->txt("crs_cannot_find_role"), true);
88  return false;
89  }
90  include_once './Modules/Group/classes/class.ilGroupMembershipMailNotification.php';
91  $this->getMembersObject()->sendNotification(
93  $new_member
94  );
95  $assigned = true;
96  break;
97  }
98  }
99 
100  if ($assigned) {
101  ilUtil::sendSuccess($this->lng->txt("grp_msg_member_assigned"), true);
102  } else {
103  ilUtil::sendSuccess($this->lng->txt('grp_users_already_assigned'), true);
104  }
105  $this->ctrl->redirect($this, 'participants');
106  }
107 
111  protected function updateParticipantsStatus()
112  {
113  $participants = (array) $_POST['visible_member_ids'];
114  $notification = (array) $_POST['notification'];
115  $contact = (array) $_POST['contact'];
116 
117  ilLoggerFactory::getLogger('grp')->dump($contact);
118 
119  foreach ($participants as $mem_id) {
120  if ($this->getMembersObject()->isAdmin($mem_id)) {
121  $this->getMembersObject()->updateContact($mem_id, in_array($mem_id, $contact));
122  $this->getMembersObject()->updateNotification($mem_id, in_array($mem_id, $notification));
123  } else {
124  $this->getMembersObject()->updateContact($mem_id, false);
125  $this->getMembersObject()->updateNotification($mem_id, false);
126  }
127  }
128  ilUtil::sendSuccess($this->lng->txt('settings_saved'), true);
129  $this->ctrl->redirect($this, 'participants');
130  }
131 
132 
136  protected function initParticipantTableGUI()
137  {
138  include_once './Services/Tracking/classes/class.ilObjUserTracking.php';
139  $show_tracking =
141  ;
142  if ($show_tracking) {
143  include_once('./Services/Object/classes/class.ilObjectLP.php');
144  $olp = ilObjectLP::getInstance($this->getParentObject()->getId());
145  $show_tracking = $olp->isActive();
146  }
147 
148  include_once './Modules/Group/classes/class.ilGroupParticipantsTableGUI.php';
149  return new ilGroupParticipantsTableGUI(
150  $this,
151  $this->getParentObject(),
152  $show_tracking
153  );
154  }
155 
161  protected function initEditParticipantTableGUI(array $participants)
162  {
163  include_once './Modules/Group/classes/class.ilGroupEditParticipantsTableGUI.php';
165  $table->setTitle($this->lng->txt($this->getParentObject()->getType() . '_header_edit_members'));
166  $table->setData($this->getParentGUI()->readMemberData($participants));
167 
168  return $table;
169  }
170 
171 
172 
176  protected function initParticipantTemplate()
177  {
178  $this->tpl->addBlockFile('ADM_CONTENT', 'adm_content', 'tpl.grp_edit_members.html', 'Modules/Group');
179  }
180 
184  public function getLocalTypeRole($a_translation = false)
185  {
186  return $this->getParentObject()->getLocalGroupRoles($a_translation);
187  }
188 
192  protected function updateLPFromStatus()
193  {
194  return null;
195  }
196 
201  protected function initWaitingList()
202  {
203  include_once './Modules/Group/classes/class.ilGroupWaitingList.php';
204  $wait = new ilGroupWaitingList($this->getParentObject()->getId());
205  return $wait;
206  }
207 
211  protected function getDefaultRole()
212  {
213  return $this->getParentGUI()->object->getDefaultMemberRole();
214  }
215 
220  public function getPrintMemberData($a_members)
221  {
222  $member_data = $this->readMemberData($a_members, array());
223  $member_data = $this->getParentGUI()->addCustomData($member_data);
224  return $member_data;
225  }
226 
232  public function getAttendanceListUserData($a_user_id)
233  {
234  if (is_array($this->member_data) && array_key_exists($a_user_id, $this->member_data)) {
235  $user_data = $this->member_data[$a_user_id];
236  $user_data['access'] = $this->member_data['access_time'];
237  $user_data['progress'] = $this->lng->txt($this->member_data['progress']);
238  return $user_data;
239  }
240  return [];
241  }
242 }
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.
const IL_GRP_MEMBER
assignMembers($user_ids, $a_type)
public
Class ilMailMemberCourseRoles.
$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.
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"]
$GLOBALS['JPEG_Segment_Names']
Global Variable: XMP_tag_captions.
getAttendanceListUserData($a_user_id)
Callback from attendance list.
filterUserIdsByRbacOrPositionOfCurrentUser($a_user_ids)
Filter user ids by access.