ILIAS  release_5-4 Revision v5.4.26-12-gabc799a52e6
class.ilLearningSequenceMembershipGUI.php
Go to the documentation of this file.
1 <?php
2 
3 declare(strict_types=1);
4 
17 {
18  public function __construct(
20  ilObject $repository_obj,
21  ilObjUserTracking $obj_user_tracking,
22  ilPrivacySettings $privacy_settings,
24  ilCtrl $ctrl,
26  ilRbacReview $rbac_review,
27  ilSetting $settings,
28  ilToolbarGUI $toolbar
29  ) {
30  parent::__construct($repository_gui, $repository_obj);
31 
32  $this->obj_user_tracking = $obj_user_tracking;
33  $this->privacy_settings = $privacy_settings;
34  $this->lng = $lng;
35  $this->ctrl = $ctrl;
36  $this->access = $access;
37  $this->rbac_review = $rbac_review;
38  $this->settings = $settings;
39  $this->obj = $repository_obj;
40  $this->toolbar = $toolbar;
41  }
42 
43  protected function printMembers()
44  {
45  $this->checkPermission('read');
46  if ($this->checkRbacOrPositionAccessBool('manage_members', 'manage_members')) {
47  $back_cmd = 'participants';
48  } else {
49  $back_cmd = 'jump2UsersGallery';
50  }
51 
52  global $DIC;
53  $ilTabs = $DIC['ilTabs'];
54  $ilTabs->clearTargets();
55  $ilTabs->setBackTarget(
56  $this->lng->txt('back'),
57  $this->ctrl->getLinkTarget($this, $back_cmd)
58  );
59 
60  $list = $this->initAttendanceList();
61  $form = $list->initForm('printMembersOutput');
62  $this->tpl->setContent($form->getHTML());
63  }
64 
65  public function getDefaultCommand()
66  {
67  $back_cmd = $_GET['back_cmd'];
68  return $back_cmd;
69  }
70 
76  public function filterUserIdsByRbacOrPositionOfCurrentUser($user_ids)
77  {
78  return $this->access->filterUserIdsByRbacOrPositionOfCurrentUser(
79  'manage_members',
80  'manage_members',
81  $this->getParentObject()->getRefId(),
82  $user_ids
83  );
84  }
85 
86  public function assignMembers(array $user_ids, string $type)
87  {
88  $object = $this->getParentObject();
89  $members = $this->getParentObject()->getLSParticipants();
90 
91  if (count($user_ids) == 0) {
92  $this->lng->loadLanguageModule('search');
93  ilUtil::sendFailure($this->lng->txt('search_err_user_not_exist'), true);
94  return false;
95  }
96 
97  $assigned = false;
98  foreach ($user_ids as $new_member) {
99  if ($members->isAssigned($new_member)) {
100  continue;
101  }
102 
103  switch ($type) {
104  case $object->getDefaultAdminRole():
105  $members->add($new_member, IL_LSO_ADMIN);
106  $members->sendNotification(
108  $new_member
109  );
110  $assigned = true;
111  break;
112  case $object->getDefaultMemberRole():
113  $members->add($new_member, IL_LSO_MEMBER);
114  $members->sendNotification(
116  $new_member
117  );
118  $assigned = true;
119  break;
120  default:
121  if (in_array($type, $object->getLocalLearningSequenceRoles(true))) {
122  $members->add($new_member, IL_LSO_MEMBER);
123  $members->updateRoleAssignments($new_member, array($type));
124  } else {
125  ilLoggerFactory::getLogger('lso')->notice('Can not find role with id .' . $type . ' to assign users.');
126  ilUtil::sendFailure($this->lng->txt("lso_cannot_find_role"), true);
127  return false;
128  }
129 
130  $members->sendNotification(
132  $new_member
133  );
134  $assigned = true;
135  break;
136  }
137  }
138 
139  if ($assigned) {
140  ilUtil::sendSuccess($this->lng->txt("lso_msg_member_assigned"), true);
141  } else {
142  ilUtil::sendSuccess($this->lng->txt('lso_users_already_assigned'), true);
143  }
144 
145  $this->ctrl->redirect($this, 'participants');
146  }
147 
151  protected function updateParticipantsStatus()
152  {
153  $members = $this->getParentObject()->getLSParticipants();
154 
155  $participants = (array) $_POST['visible_member_ids'];
156  $notification = (array) $_POST['notification'];
157 
158  foreach ($participants as $participant) {
159  if ($members->isAdmin($participant)) {
160  $members->updateNotification($participant, in_array($participant, $notification));
161  continue;
162  }
163  $members->updateNotification($participant, false);
164  }
165 
166  ilUtil::sendSuccess($this->lng->txt('settings_saved'), true);
167  $this->ctrl->redirect($this, 'participants');
168  }
169 
171  {
173  $this,
174  $this->getParentObject(),
175  $this->obj_user_tracking,
176  $this->privacy_settings,
177  $this->lng,
178  $this->access,
179  $this->rbac_review,
180  $this->settings
181  );
182  }
183 
185  {
187  $this,
188  $this->getParentObject(),
189  $this->getParentObject()->getLSParticipants(),
190  $this->privacy_settings,
191  $this->lng,
192  $this->ctrl
193  );
194 
195  $table->setTitle($this->lng->txt($this->getParentObject()->getType() . '_header_edit_members'));
196  $table->setData($this->readMemberData($participants));
197 
198  return $table;
199  }
200 
204  protected function initParticipantTemplate()
205  {
206  $this->tpl->addBlockFile('ADM_CONTENT', 'adm_content', 'tpl.lso_edit_members.html', 'Modules/LearningSequence');
207  }
208 
209  public function getLocalTypeRole($a_translation = false)
210  {
211  return $this->getParentObject()->getLocalLearningSequenceRoles($a_translation);
212  }
213 
214  public function readMemberData(array $user_ids, array $columns = null)
215  {
216  return $this->getParentObject()->readMemberData($user_ids, $columns);
217  }
218 
219  protected function updateLPFromStatus()
220  {
221  return null;
222  }
223 
225  {
226  return new ilLearningSequenceWaitingList($this->getParentObject()->getId());
227  }
228 
229  protected function getDefaultRole() : int
230  {
231  return $this->getParentObject()->getDefaultMemberRole();
232  }
233 
234  public function getPrintMemberData(array $members) : array
235  {
236  $member_data = $this->readMemberData($members, array());
237  $member_data = $this->getParentGUI()->addCustomData($member_data);
238 
239  return $member_data;
240  }
241 
242  public function getAttendanceListUserData(int $user_id) : array
243  {
244  $data = array();
245 
246  if ($this->filterUserIdsByRbacOrPositionOfCurrentUser([$user_id])) {
247  $data = $this->member_data[$user_id];
248  $data['access'] = $data['access_time'];
249  $data['progress'] = $this->lng->txt($data['progress']);
250  }
251 
252  return $data;
253  }
254 
255  public function getMembersObject()
256  {
257  if ($this->participants instanceof ilParticipants) {
258  return $this->participants;
259  }
260  return $this->participants = ilParticipants::getInstance($this->getParentObject()->getRefId());
261  }
262 
266  protected function getMailMemberRoles()
267  {
269  }
270 
271  protected function setSubTabs(ilTabsGUI $tabs)
272  {
274  'manage_members',
275  'manage_members',
276  $this->getParentObject()->getRefId()
277  );
278 
279  if ($access) {
280  $tabs->addSubTabTarget(
281  $this->getParentObject()->getType() . "_member_administration",
282  $this->ctrl->getLinkTarget($this, 'participants'),
283  "members",
284  get_class($this)
285  );
286 
287  $tabs->addSubTabTarget(
288  $this->getParentObject()->getType() . '_members_gallery',
289  $this->ctrl->getLinkTargetByClass(array(get_class($this),'ilUsersGalleryGUI')),
290  'view',
291  'ilUsersGalleryGUI'
292  );
293  } elseif ($this->getParentObject()->getShowMembers()) {
294  $tabs->addSubTabTarget(
295  $this->getParentObject()->getType() . '_members_gallery',
296  $this->ctrl->getLinkTargetByClass(array(get_class($this),'ilUsersGalleryGUI')),
297  'view',
298  'ilUsersGalleryGUI'
299  );
300  }
301  }
302 
303  protected function showParticipantsToolbar()
304  {
305  $toolbar_entries = [
306  'auto_complete_name' => $this->lng->txt('user'),
307  'user_type' => $this->getParentGUI()->getLocalRoles(),
308  'user_type_default' => $this->getDefaultRole(),
309  'submit_name' => $this->lng->txt('add'),
310  'add_search' => true,
311  ];
312 
313  $search_params = ['crs', 'grp'];
314  $parent_container = $this->obj->getParentObjectInfo(
315  (int) $this->obj->getRefId(),
316  $search_params
317  );
318  if (!is_null($parent_container)) {
319  $container_id = $parent_container['ref_id'];
320  $toolbar_entries['add_from_container'] = $container_id;
321  }
322 
324  $this,
325  $this->toolbar,
326  $toolbar_entries
327  );
328 
329  $this->toolbar->addSeparator();
330 
331  $this->toolbar->addButton(
332  $this->lng->txt($this->getParentObject()->getType() . "_print_list"),
333  $this->ctrl->getLinkTarget($this, 'printMembers')
334  );
335 
336  $this->showMailToMemberToolbarButton($this->toolbar, 'participants', false);
337  }
338 }
if(isset($_REQUEST['delete'])) $list
Definition: registry.php:41
This class provides processing control methods.
settings()
Definition: settings.php:2
Base class for member tab content.
addSubTabTarget( $a_text, $a_link, $a_cmd="", $a_cmdClass="", $a_frame="", $a_activate=false, $a_dir_text=false)
DEPRECATED.
Tabs GUI.
$type
global $DIC
Definition: saml.php:7
const IL_LSO_MEMBER
$_GET["client_id"]
__construct(ilObjectGUI $repository_gui, ilObject $repository_obj, ilObjUserTracking $obj_user_tracking, ilPrivacySettings $privacy_settings, ilLanguage $lng, ilCtrl $ctrl, ilAccess $access, ilRbacReview $rbac_review, ilSetting $settings, ilToolbarGUI $toolbar)
checkPermission($a_permission, $a_cmd="")
Check permission If not granted redirect to parent gui.
Class ilAccessHandler.
const IL_LSO_ADMIN
readMemberData(array $user_ids, array $columns=null)
static getInstance($a_ref_id)
Get instance by ref_id.
showMailToMemberToolbarButton(ilToolbarGUI $toolbar, $a_back_cmd=null, $a_separator=false)
Show mail to member toolbar button.
if(isset($_POST['submit'])) $form
Singleton class that stores all privacy settings.
Class ilObjectGUI Basic methods of all Output classes.
initParticipantTemplate()
Init participant view template.
getParentGUI()
Get parent gui.
static sendFailure($a_info="", $a_keep=false)
Send Failure Message to Screen.
if(!empty($this->data['faventry'])) $tabs
Definition: disco.tpl.php:124
filterUserIdsByRbacOrPositionOfCurrentUser($user_ids)
Filter user ids by access.
participants()
Show participant table, subscriber table, wating list table;.
language handling
static getLogger($a_component_id)
Get component logger.
static fillAutoCompleteToolbar($parent_object, ilToolbarGUI $toolbar=null, $a_options=array(), $a_sticky=false)
fill toolbar with
getParentObject()
Get parent object.
if(empty($password)) $table
Definition: pwgen.php:24
if(! $in) $columns
Definition: Utf8Test.php:45
$_POST["username"]
checkRbacOrPositionAccessBool($a_rbac_perm, $a_pos_perm, $a_ref_id=0)
Check if rbac or position access is granted.
GUI class for learning sequence membership features.
$data
Definition: bench.php:6
class ilRbacReview Contains Review functions of core Rbac.