ILIAS  release_7 Revision v7.30-3-g800a261c036
All Data Structures Namespaces Files Functions Variables Modules Pages
class.ilParticipants.php
Go to the documentation of this file.
1 <?php
2 /* Copyright (c) 1998-2010 ILIAS open source, Extended GPL, see docs/LICENSE */
3 
12 define("IL_CRS_ADMIN", 1);
13 define("IL_CRS_TUTOR", 3);
14 define("IL_CRS_MEMBER", 2);
15 
16 define('IL_GRP_ADMIN', 4);
17 define('IL_GRP_MEMBER', 5);
18 
19 define('IL_SESS_MEMBER', 6);
20 
21 define('IL_LSO_ADMIN', 7);
22 define('IL_LSO_MEMBER', 8);
23 
24 define("IL_ROLE_POSITION_ADMIN", 1);
25 define("IL_ROLE_POSITION_TUTOR", 2);
26 define("IL_ROLE_POSITION_MEMBER", 3);
27 
28 
29 abstract class ilParticipants
30 {
31  protected $component = '';
32 
33  protected $obj_id = 0;
34  protected $type = '';
35  protected $ref_id = 0;
36 
37  protected $roles = array();
38  protected $role_data = array();
39  protected $roles_sorted = [];
40  protected $role_assignments = [];
41 
42  protected $participants = array();
43  protected $participants_status = array();
44  protected $members = array();
45  protected $tutors = array();
46  protected $admins = array();
47 
48  protected $subscribers = array();
49 
53  protected $ilDB;
54 
58  protected $lng;
59 
64  protected $logger = null;
65 
70 
79  public function __construct($a_component_name, $a_ref_id)
80  {
81  $this->ilDB = $GLOBALS['DIC']->database();
82  $this->lng = $GLOBALS['DIC']->language();
83  $this->logger = $GLOBALS['DIC']->logger()->mem();
84 
85  $this->component = $a_component_name;
86 
87  $this->ref_id = $a_ref_id;
88  $this->obj_id = ilObject::_lookupObjId($a_ref_id);
89  $this->type = ilObject::_lookupType($this->obj_id);
90 
91  $this->readParticipants();
92  $this->readParticipantsStatus();
93  $this->recommended_content_manager = new ilRecommendedContentManager();
94  }
95 
101  public static function getInstance($a_ref_id)
102  {
103  $obj_id = ilObject::_lookupObjId($a_ref_id);
105 
106  switch ($type) {
107  case 'crs':
108  case 'grp':
109  case 'lso':
110  return self::getInstanceByObjId($obj_id);
111  case 'sess':
112  include_once './Modules/Session/classes/class.ilSessionParticipants.php';
113  return ilSessionParticipants::getInstance($a_ref_id);
114  default:
115  $GLOBALS['DIC']->logger()->mem()->logStack();
116  $GLOBALS['DIC']->logger()->mem()->warning('Invalid ref_id -> obj_id given: ' . $a_ref_id . ' -> ' . $obj_id);
117  throw new \InvalidArgumentException('Invalid obj_id given.');
118  }
119  }
120 
129  public static function getInstanceByObjId($a_obj_id)
130  {
131  $type = ilObject::_lookupType($a_obj_id);
132  switch ($type) {
133  case 'crs':
134  include_once './Modules/Course/classes/class.ilCourseParticipants.php';
136 
137  case 'grp':
138  include_once './Modules/Group/classes/class.ilGroupParticipants.php';
140 
141  case 'sess':
142  include_once './Modules/Session/classes/class.ilSessionParticipants.php';
144  case 'lso':
146  default:
147  $GLOBALS['DIC']->logger()->mmbr()->logStack(ilLogLevel::WARNING);
148  $GLOBALS['DIC']->logger()->mmbr()->warning(': Invalid obj_id given: ' . $a_obj_id);
149  throw new InvalidArgumentException('Invalid obj id given');
150  }
151  }
152 
157  protected function getComponent()
158  {
159  return $this->component;
160  }
161 
162 
163 
169  public static function hasParticipantListAccess($a_obj_id, $a_usr_id = null)
170  {
171  global $DIC;
172 
173  $access = $DIC->access();
174 
175  if (!$a_usr_id) {
176  $a_usr_id = $GLOBALS['DIC']['ilUser']->getId();
177  }
178 
179  // if write access granted => return true
180  $refs = ilObject::_getAllReferences($a_obj_id);
181  $ref_id = end($refs);
182 
183  if ($access->checkAccess('manage_members', '', $ref_id)) {
184  return true;
185  }
186  $part = self::getInstance($ref_id);
187  if ($part->isAssigned($a_usr_id)) {
188  if ($part->getType() == 'crs') {
189  if (!ilObjCourse::lookupShowMembersEnabled($a_obj_id)) {
190  return false;
191  }
192  }
193  if ($part->getType() == 'grp') {
194  if (!ilObjGroup::lookupShowMembersEnabled($a_obj_id)) {
195  return false;
196  }
197  }
198  return true;
199  }
200  // User is not assigned to course/group => no read access
201  return false;
202  }
203 
209  public static function canSendMailToMembers(
210  $ref_id_or_instance,
211  ?int $usr_id = null,
212  ?int $mail_obj_ref_id = null
213  ) : bool {
214  global $DIC;
215 
216  $access = $DIC->access();
217  $rbacsystem = $DIC->rbac()->system();
218 
219  if (is_null($usr_id)) {
220  $usr_id = $DIC->user()->getId();
221  }
222  if (is_null($mail_obj_ref_id)) {
223  $mail_obj_ref_id = (new ilMail($usr_id))->getMailObjectReferenceId();
224  }
225  if (is_int($ref_id_or_instance)) {
226  $ref_id = $ref_id_or_instance;
227  } elseif ($ref_id_or_instance instanceof ilObject) {
228  $ref_id = (int) $ref_id_or_instance->getRefId();
229  if ($ref_id === 0) {
230  $ref_id = array_keys(ilObject::_getAllReferences($ref_id_or_instance->getId()))[0];
231  }
232  } else {
233  return false;
234  }
235 
236  if (
237  $access->checkAccess('manage_members', '', $ref_id) &&
238  $rbacsystem->checkAccess('internal_mail', $mail_obj_ref_id)
239  ) {
240  return true;
241  }
242 
243  $part = self::getInstance($ref_id);
244  if (!$part->isAssigned($usr_id)) {
245  return false;
246  }
247 
248  $object = $ref_id_or_instance;
249  if (is_int($ref_id_or_instance)) {
250  $object = ilObjectFactory::getInstanceByRefId($ref_id_or_instance);
251  }
252 
253  if ($object instanceof ilObjCourse) {
254  return $object->getMailToMembersType() == ilCourseConstants::MAIL_ALLOWED_ALL;
255  } elseif ($object instanceof ilObjGroup) {
256  return $object->getMailToMembersType() == ilObjGroup::MAIL_ALLOWED_ALL;
257  } elseif ($object instanceof ilObjSession) {
258  return $object->getMailToMembersType() == ilObjSession::MAIL_ALLOWED_ALL;
259  }
260 
261  return false;
262  }
263 
264 
272  public static function getUserMembershipAssignmentsByType($a_user_ids, $a_type, $a_only_member_roles)
273  {
274  global $DIC;
275 
276  $logger = $DIC->logger()->mmbr();
277  $ilDB = $DIC->database();
278 
279  if ($a_only_member_roles) {
280  $j2 = "JOIN object_data obd2 ON (ua.rol_id = obd2.obj_id) ";
281  $a2 = 'AND obd2.title = ' . $ilDB->concat(
282  array(
283  array($ilDB->quote('il_', 'text')),
284  array('obd.type'),
285  array($ilDB->quote('_member_', 'text')),
286  array('obr.ref_id'),
287  ),
288  false
289  );
290  }
291 
292  $query = "SELECT DISTINCT obd.obj_id,obr.ref_id,ua.usr_id FROM rbac_ua ua " .
293  "JOIN rbac_fa fa ON ua.rol_id = fa.rol_id " .
294  "JOIN object_reference obr ON fa.parent = obr.ref_id " .
295  "JOIN object_data obd ON obr.obj_id = obd.obj_id " .
296  $j2 .
297  "WHERE " . $ilDB->in("obd.type", $a_type, false, "text") .
298  "AND fa.assign = 'y' " .
299  'AND ' . $ilDB->in('ua.usr_id', $a_user_ids, false, 'integer') . ' ' .
300  $a2;
301 
302  $obj_ids = [];
303  $res = $ilDB->query($query);
304  while ($row = $ilDB->fetchObject($res)) {
305  $obj_ids[$row->obj_id][] = $row->usr_id;
306  }
307 
308  $logger->dump($obj_ids, \ilLogLevel::DEBUG);
309 
310  return $obj_ids;
311  }
312 
324  public static function _getMembershipByType($a_usr_id, $a_type, $a_only_member_role = false)
325  {
326  global $DIC;
327 
328  $ilDB = $DIC['ilDB'];
329 
330  if (!is_array($a_type)) {
331  $a_type = array($a_type);
332  }
333 
334  // this will also dismiss local roles!
335  if ($a_only_member_role) {
336  $j2 = "JOIN object_data obd2 ON (ua.rol_id = obd2.obj_id) ";
337  $a2 = 'AND obd2.title = ' . $ilDB->concat(
338  array(
339  array($ilDB->quote('il_', 'text')),
340  array('obd.type'),
341  array($ilDB->quote('_member_', 'text')),
342  array('obr.ref_id'),
343  ),
344  false
345  );
346  }
347 
348  // #14290 - no role folder anymore
349  $query = "SELECT DISTINCT obd.obj_id,obr.ref_id FROM rbac_ua ua " .
350  "JOIN rbac_fa fa ON ua.rol_id = fa.rol_id " .
351  "JOIN object_reference obr ON fa.parent = obr.ref_id " .
352  "JOIN object_data obd ON obr.obj_id = obd.obj_id " .
353  $j2 .
354  "WHERE " . $ilDB->in("obd.type", $a_type, false, "text") . ' ' .
355  "AND fa.assign = 'y' " .
356  "AND ua.usr_id = " . $ilDB->quote($a_usr_id, 'integer') . " " .
357  'AND obr.deleted IS NULL ' .
358  $a2;
359  $res = $ilDB->query($query);
360  while ($row = $ilDB->fetchObject($res)) {
361  $ref_ids[] = $row->obj_id;
362  }
363 
364  return $ref_ids ? $ref_ids : array();
365  }
366 
367 
368 
377  public static function _isParticipant($a_ref_id, $a_usr_id)
378  {
379  global $DIC;
380 
381  $rbacreview = $DIC['rbacreview'];
382 
383  $local_roles = $rbacreview->getRolesOfRoleFolder($a_ref_id, false);
384 
385  return $rbacreview->isAssignedToAtLeastOneGivenRole($a_usr_id, $local_roles);
386  }
387 
395  public static function lookupNumberOfParticipants($a_ref_id)
396  {
397  global $DIC;
398 
399  $rbacreview = $DIC['rbacreview'];
400 
401  $lroles = $rbacreview->getRolesOfRoleFolder($a_ref_id, false);
402  return $rbacreview->getNumberOfAssignedUsers($lroles);
403  }
404 
412  public static function lookupNumberOfMembers($a_ref_id)
413  {
414  global $DIC;
415 
416  $rbacreview = $DIC->rbac()->review();
417  $ilObjDataCache = $DIC['ilObjDataCache'];
418 
419  $has_policies = $rbacreview->getLocalPolicies($a_ref_id);
420 
421  if (!$has_policies) {
422  return 0;
423  }
424  $lroles = $rbacreview->getRolesOfRoleFolder($a_ref_id, false);
425 
426  $memberRoles = array();
427  foreach ($lroles as $role_id) {
428  $title = $ilObjDataCache->lookupTitle($role_id);
429  switch (substr($title, 0, 8)) {
430  case 'il_crs_a':
431  case 'il_crs_t':
432  case 'il_grp_a':
433  break;
434 
435  default:
436  $memberRoles[] = $role_id;
437  break;
438  }
439  }
440  return $rbacreview->getNumberOfAssignedUsers($memberRoles);
441  }
442 
443 
453  public static function _isBlocked($a_obj_id, $a_usr_id)
454  {
455  global $DIC;
456 
457  $ilDB = $DIC['ilDB'];
458 
459  $query = "SELECT * FROM obj_members " .
460  "WHERE obj_id = " . $ilDB->quote($a_obj_id, 'integer') . " " .
461  "AND usr_id = " . $ilDB->quote($a_usr_id, 'integer') . " " .
462  "AND blocked = " . $ilDB->quote(1, 'integer');
463  $res = $ilDB->query($query);
464  return $res->numRows() ? true : false;
465  }
466 
476  public static function _hasPassed($a_obj_id, $a_usr_id)
477  {
478  global $DIC;
479 
480  $ilDB = $DIC['ilDB'];
481 
482  $query = "SELECT * FROM obj_members " .
483  "WHERE obj_id = " . $ilDB->quote($a_obj_id, 'integer') . " " .
484  "AND usr_id = " . $ilDB->quote($a_usr_id, 'integer') . " " .
485  "AND passed = '1'";
486  $res = $ilDB->query($query);
487  return $res->numRows() ? true : false;
488  }
489 
499  public static function _deleteAllEntries($a_obj_id)
500  {
501  global $DIC;
502 
503  $ilDB = $DIC['ilDB'];
504 
505  $query = "DELETE FROM obj_members " .
506  "WHERE obj_id = " . $ilDB->quote($a_obj_id, 'integer') . " ";
507  $res = $ilDB->manipulate($query);
508 
509  $query = "DELETE FROM il_subscribers " .
510  "WHERE obj_id = " . $ilDB->quote($a_obj_id, 'integer') . "";
511  $res = $ilDB->manipulate($query);
512 
513  $query = 'DELETE FROM crs_waiting_list ' .
514  'WHERE obj_id = ' . $ilDB->quote($a_obj_id, 'integer');
515  $ilDB->manipulate($query);
516 
517  return true;
518  }
519 
528  public static function _deleteUser($a_usr_id)
529  {
530  global $DIC;
531 
532  $ilDB = $DIC['ilDB'];
533 
534  $query = "DELETE FROM obj_members WHERE usr_id = " . $ilDB->quote($a_usr_id, 'integer') . "";
535  $res = $ilDB->manipulate($query);
536 
537  $query = "DELETE FROM il_subscribers WHERE usr_id = " . $ilDB->quote($a_usr_id, 'integer') . "";
538  $res = $ilDB->manipulate($query);
539 
540  include_once './Modules/Course/classes/class.ilCourseWaitingList.php';
542  }
543 
544  public static function getDefaultMemberRole($a_ref_id)
545  {
546  global $DIC;
547 
548  $ilCtrl = $DIC['ilCtrl'];
549 
550  $obj_id = ilObject::_lookupObjId($a_ref_id);
552 
553  if (!in_array($type, array('crs','grp'))) {
554  return 0;
555  }
556 
557  global $DIC;
558 
559  $rbacreview = $DIC['rbacreview'];
560 
561 
562  $roles = $rbacreview->getRolesOfRoleFolder($a_ref_id, false);
563 
564  foreach ($roles as $role) {
565  $title = ilObject::_lookupTitle($role);
566  if (substr($title, 0, 13) == ('il_' . $type . '_member')) {
567  return $role;
568  }
569  }
570  return 0;
571  }
572 
577  public function getObjId()
578  {
579  return $this->obj_id;
580  }
581 
586  public function getType()
587  {
588  return $this->type;
589  }
590 
597  public function getNotificationRecipients()
598  {
599  global $DIC;
600 
601  $ilDB = $DIC['ilDB'];
602 
603  $query = "SELECT * FROM obj_members " .
604  "WHERE notification = 1 " .
605  "AND obj_id = " . $ilDB->quote($this->obj_id) . " ";
606  $res = $ilDB->query($query);
607  $recp = [];
608  while ($row = $res->fetchRow(ilDBConstants::FETCHMODE_OBJECT)) {
609  if ($this->isAdmin($row->usr_id) or $this->isTutor($row->usr_id)) {
610  $recp[] = $row->usr_id;
611  }
612  }
613  return $recp;
614  }
615 
622  public function getCountMembers()
623  {
624  return count($this->members);
625  }
626 
633  public function getCountParticipants()
634  {
635  return count($this->participants);
636  }
637 
638 
639 
640 
647  public function getParticipants()
648  {
649  return $this->participants ? $this->participants : array();
650  }
651 
659  public function getMembers()
660  {
661  return $this->members ? $this->members : array();
662  }
669  public function getAdmins()
670  {
671  return $this->admins ? $this->admins : array();
672  }
673 
678  public function getCountAdmins()
679  {
680  return count($this->getAdmins());
681  }
682 
683 
690  public function getTutors()
691  {
692  return $this->tutors ? $this->tutors : array();
693  }
694 
702  public function isAdmin($a_usr_id)
703  {
704  return in_array($a_usr_id, $this->admins) ? true : false;
705  }
706 
714  public function isTutor($a_usr_id)
715  {
716  return in_array($a_usr_id, $this->tutors) ? true : false;
717  }
718 
726  public function isMember($a_usr_id)
727  {
728  return in_array($a_usr_id, $this->members) ? true : false;
729  }
730 
731 
732 
733 
741  public function isAssigned($a_usr_id)
742  {
743  return in_array($a_usr_id, $this->participants);
744  }
745 
751  public function isLastAdmin($a_usr_id)
752  {
753  return in_array($a_usr_id, $this->getAdmins()) and count($this->getAdmins()) == 1;
754  }
755 
756 
764  public function getRoles()
765  {
766  return $this->roles ? $this->roles : array();
767  }
768 
776  public function getAssignedRoles($a_usr_id)
777  {
778  global $DIC;
779 
780  $rbacreview = $DIC['rbacreview'];
781 
782  foreach ($this->roles as $role) {
783  if ($rbacreview->isAssigned($a_usr_id, $role)) {
784  $assigned[] = $role;
785  }
786  }
787  return $assigned ? $assigned : array();
788  }
789 
798  public function updateRoleAssignments($a_usr_id, $a_roles)
799  {
800  global $DIC;
801 
802  $rbacreview = $DIC['rbacreview'];
803  $rbacadmin = $DIC['rbacadmin'];
804 
805  $roles = $a_roles ? $a_roles : array();
806 
807  foreach ($this->getRoles() as $role_id) {
808  if ($rbacreview->isAssigned($a_usr_id, $role_id)) {
809  if (!in_array($role_id, $roles)) {
810  $rbacadmin->deassignUser($role_id, $a_usr_id);
811  }
812  } else {
813  if (in_array($role_id, $roles)) {
814  $rbacadmin->assignUser($role_id, $a_usr_id);
815  }
816  }
817  }
818  $rbacreview->clearCaches();
819  $this->readParticipants();
820  $this->readParticipantsStatus();
821  }
822 
830  public function checkLastAdmin($a_usr_ids)
831  {
832  foreach ($this->getAdmins() as $admin_id) {
833  if (!in_array($admin_id, $a_usr_ids)) {
834  return true;
835  }
836  }
837  return false;
838  }
839 
847  public function isBlocked($a_usr_id)
848  {
849  if (isset($this->participants_status[$a_usr_id])) {
850  return $this->participants_status[$a_usr_id]['blocked'] ? true : false;
851  }
852  return false;
853  }
854 
862  public function hasPassed($a_usr_id)
863  {
864  if (isset($this->participants_status[$a_usr_id])) {
865  return $this->participants_status[$a_usr_id]['passed'] ? true : false;
866  }
867  return false;
868  }
869 
877  public function delete($a_usr_id)
878  {
879  global $DIC;
880 
881  $rbacadmin = $DIC['rbacadmin'];
882  $ilDB = $DIC['ilDB'];
883 
884  $this->recommended_content_manager->removeObjectRecommendation($a_usr_id, $this->ref_id);
885 
886  foreach ($this->roles as $role_id) {
887  $rbacadmin->deassignUser($role_id, $a_usr_id);
888  }
889 
890  $query = "DELETE FROM obj_members " .
891  "WHERE usr_id = " . $ilDB->quote($a_usr_id, 'integer') . " " .
892  "AND obj_id = " . $ilDB->quote($this->obj_id, 'integer');
893  $res = $ilDB->manipulate($query);
894 
895  $this->readParticipants();
896  $this->readParticipantsStatus();
897 
898  $GLOBALS['DIC']['ilAppEventHandler']->raise(
899  $this->getComponent(),
900  "deleteParticipant",
901  array(
902  'obj_id' => $this->obj_id,
903  'usr_id' => $a_usr_id)
904  );
905 
906  return true;
907  }
908 
917  public function updateBlocked($a_usr_id, $a_blocked)
918  {
919  global $DIC;
920 
921  $ilDB = $DIC['ilDB'];
922 
923  $this->participants_status[$a_usr_id]['blocked'] = (int) $a_blocked;
924 
925  $query = "SELECT * FROM obj_members " .
926  "WHERE obj_id = " . $ilDB->quote($this->obj_id, 'integer') . " " .
927  "AND usr_id = " . $ilDB->quote($a_usr_id, 'integer');
928  $res = $ilDB->query($query);
929  if ($res->numRows()) {
930  $query = "UPDATE obj_members SET " .
931  "blocked = " . $ilDB->quote((int) $a_blocked, 'integer') . " " .
932  "WHERE obj_id = " . $ilDB->quote($this->obj_id, 'integer') . " " .
933  "AND usr_id = " . $ilDB->quote($a_usr_id, 'integer');
934  } else {
935  $query = "INSERT INTO obj_members (blocked,obj_id,usr_id,notification,passed) " .
936  "VALUES ( " .
937  $ilDB->quote((int) $a_blocked, 'integer') . ", " .
938  $ilDB->quote($this->obj_id, 'integer') . ", " .
939  $ilDB->quote($a_usr_id, 'integer') . ", " .
940  $ilDB->quote(0, 'integer') . ", " .
941  $ilDB->quote(0, 'integer') .
942  ")";
943  }
944  $res = $ilDB->manipulate($query);
945  return true;
946  }
947 
948  // cognos-blu-patch: begin
956  public function updateContact($a_usr_id, $a_contact)
957  {
958  global $DIC;
959 
960  $ilDB = $DIC['ilDB'];
961 
962  $ilDB->manipulate(
963  'UPDATE obj_members SET ' .
964  'contact = ' . $ilDB->quote($a_contact, 'integer') . ' ' .
965  'WHERE obj_id = ' . $ilDB->quote($this->obj_id, 'integer') . ' ' .
966  'AND usr_id = ' . $ilDB->quote($a_usr_id, 'integer')
967  );
968 
969  $this->participants_status[$a_usr_id]['contact'] = $a_contact;
970  return true;
971  }
972 
977  public function getContacts()
978  {
979  $contacts = array();
980  foreach ((array) $this->participants_status as $usr_id => $status) {
981  if ($status['contact']) {
982  $contacts[] = $usr_id;
983  }
984  }
985  return $contacts;
986  }
987 
988 
989  // cognos-blu-patch: end
990 
999  public function updateNotification($a_usr_id, $a_notification)
1000  {
1001  global $DIC;
1002 
1003  $ilDB = $DIC['ilDB'];
1004 
1005  $this->participants_status[$a_usr_id]['notification'] = (int) $a_notification;
1006 
1007  $query = "SELECT * FROM obj_members " .
1008  "WHERE obj_id = " . $ilDB->quote($this->obj_id, 'integer') . " " .
1009  "AND usr_id = " . $ilDB->quote($a_usr_id, 'integer');
1010  $res = $ilDB->query($query);
1011  if ($res->numRows()) {
1012  $query = "UPDATE obj_members SET " .
1013  "notification = " . $ilDB->quote((int) $a_notification, 'integer') . " " .
1014  "WHERE obj_id = " . $ilDB->quote($this->obj_id, 'integer') . " " .
1015  "AND usr_id = " . $ilDB->quote($a_usr_id, 'integer');
1016  } else {
1017  $query = "INSERT INTO obj_members (notification,obj_id,usr_id,passed,blocked) " .
1018  "VALUES ( " .
1019  $ilDB->quote((int) $a_notification, 'integer') . ", " .
1020  $ilDB->quote($this->obj_id, 'integer') . ", " .
1021  $ilDB->quote($a_usr_id, 'integer') . ", " .
1022  $ilDB->quote(0, 'integer') . ", " .
1023  $ilDB->quote(0, 'integer') .
1024  ")";
1025  }
1026  $res = $ilDB->manipulate($query);
1027  return true;
1028  }
1029 
1030 
1031 
1032 
1041  public function add($a_usr_id, $a_role)
1042  {
1043  global $DIC;
1044 
1045  $rbacadmin = $DIC['rbacadmin'];
1046  $ilAppEventHandler = $DIC['ilAppEventHandler'];
1047 
1048  if ($this->isAssigned($a_usr_id)) {
1049  return false;
1050  }
1051 
1052  switch ($a_role) {
1053  case IL_CRS_ADMIN:
1054  $this->admins[] = $a_usr_id;
1055  break;
1056 
1057  case IL_CRS_TUTOR:
1058  $this->tutors[] = $a_usr_id;
1059  break;
1060 
1061  case IL_CRS_MEMBER:
1062  $this->members[] = $a_usr_id;
1063  break;
1064 
1065  case IL_GRP_ADMIN:
1066  $this->admins[] = $a_usr_id;
1067  break;
1068 
1069  case IL_GRP_MEMBER:
1070  $this->members[] = $a_usr_id;
1071  break;
1072 
1073  case IL_LSO_ADMIN:
1074  $this->admins[] = $a_usr_id;
1075  break;
1076 
1077  case IL_LSO_MEMBER:
1078  $this->members[] = $a_usr_id;
1079  break;
1080 
1081  case IL_SESS_MEMBER:
1082  $this->members[] = $a_usr_id;
1083  break;
1084  }
1085 
1086  $this->participants[] = $a_usr_id;
1087  $rbacadmin->assignUser($this->role_data[$a_role], $a_usr_id);
1088 
1089  // Delete subscription request
1090  $this->deleteSubscriber($a_usr_id);
1091 
1092  include_once './Services/Membership/classes/class.ilWaitingList.php';
1093  ilWaitingList::deleteUserEntry($a_usr_id, $this->obj_id);
1094 
1095  $ilAppEventHandler->raise(
1096  $this->getComponent(),
1097  "addParticipant",
1098  array(
1099  'obj_id' => $this->obj_id,
1100  'usr_id' => $a_usr_id,
1101  'role_id' => $a_role)
1102  );
1103  return true;
1104  }
1105 
1106 
1114  public function deleteParticipants($a_user_ids)
1115  {
1116  foreach ($a_user_ids as $user_id) {
1117  $this->delete($user_id);
1118  }
1119  return true;
1120  }
1121 
1129  public function addRecommendation($a_usr_id)
1130  {
1131  // deactivated for now, see discussion at
1132  // https://docu.ilias.de/goto_docu_wiki_wpage_5620_1357.html
1133  // $this->recommended_content_manager->addObjectRecommendation($a_usr_id, $this->ref_id);
1134  return true;
1135  }
1136 
1137 
1138 
1146  public function isNotificationEnabled($a_usr_id)
1147  {
1148  if (isset($this->participants_status[$a_usr_id])) {
1149  return $this->participants_status[$a_usr_id]['notification'] ? true : false;
1150  }
1151  return false;
1152  }
1153 
1154  // cognos-blu-patch: begin
1159  public function isContact($a_usr_id)
1160  {
1161  if (isset($this->participants_status[$a_usr_id])) {
1162  return (bool) $this->participants_status[$a_usr_id]['contact'];
1163  }
1164  return false;
1165  }
1166  // cognos-blu-patch: end
1167 
1168 
1173  public function getAutoGeneratedRoleId($a_role_type)
1174  {
1175  if (array_key_exists($a_role_type, $this->role_data)) {
1176  return $this->role_data[$a_role_type];
1177  }
1178 
1179  return 0;
1180  }
1181 
1182 
1190  protected function readParticipants()
1191  {
1192  global $DIC;
1193 
1194  $rbacreview = $DIC['rbacreview'];
1195  $ilObjDataCache = $DIC['ilObjDataCache'];
1196  $ilLog = $DIC['ilLog'];
1197 
1198  $GLOBALS['DIC']['rbacreview']->clearCaches();
1199  $this->roles = $rbacreview->getRolesOfRoleFolder($this->ref_id, false);
1200 
1201  $users = array();
1202  $this->participants = array();
1203  $this->members = $this->admins = $this->tutors = array();
1204 
1205  $additional_roles = [];
1206  $auto_generated_roles = [];
1207  foreach ($this->roles as $role_id) {
1208  $title = $ilObjDataCache->lookupTitle($role_id);
1209  switch (substr($title, 0, 8)) {
1210  case 'il_crs_m':
1211  $auto_generated_roles[$role_id] = IL_ROLE_POSITION_MEMBER;
1212  $this->role_data[IL_CRS_MEMBER] = $role_id;
1213  $this->participants = array_unique(array_merge($assigned = $rbacreview->assignedUsers($role_id), $this->participants));
1214  $this->members = array_unique(array_merge($assigned, $this->members));
1215  $this->role_assignments[$role_id] = $assigned;
1216  break;
1217 
1218  case 'il_crs_a':
1219  $auto_generated_roles[$role_id] = IL_ROLE_POSITION_ADMIN;
1220  $this->role_data[IL_CRS_ADMIN] = $role_id;
1221  $this->participants = array_unique(array_merge($assigned = $rbacreview->assignedUsers($role_id), $this->participants));
1222  $this->admins = $rbacreview->assignedUsers($role_id);
1223  $this->role_assignments[$role_id] = $assigned;
1224  break;
1225 
1226  case 'il_crs_t':
1227  $auto_generated_roles[$role_id] = IL_ROLE_POSITION_TUTOR;
1228  $this->role_data[IL_CRS_TUTOR] = $role_id;
1229  $this->participants = array_unique(array_merge($assigned = $rbacreview->assignedUsers($role_id), $this->participants));
1230  $this->tutors = $rbacreview->assignedUsers($role_id);
1231  $this->role_assignments[$role_id] = $assigned;
1232  break;
1233 
1234  case 'il_grp_a':
1235  $auto_generated_roles[$role_id] = IL_ROLE_POSITION_ADMIN;
1236  $this->role_data[IL_GRP_ADMIN] = $role_id;
1237  $this->participants = array_unique(array_merge($assigned = $rbacreview->assignedUsers($role_id), $this->participants));
1238  $this->admins = $rbacreview->assignedUsers($role_id);
1239  $this->role_assignments[$role_id] = $assigned;
1240  break;
1241 
1242  case 'il_grp_m':
1243  $auto_generated_roles[$role_id] = IL_ROLE_POSITION_MEMBER;
1244  $this->role_data[IL_GRP_MEMBER] = $role_id;
1245  $this->participants = array_unique(array_merge($assigned = $rbacreview->assignedUsers($role_id), $this->participants));
1246  $this->members = $rbacreview->assignedUsers($role_id);
1247  $this->role_assignments[$role_id] = $assigned;
1248  break;
1249 
1250  case 'il_sess_':
1251  $this->role_data[IL_SESS_MEMBER] = $role_id;
1252  $this->participants = array_unique(array_merge($assigned = $rbacreview->assignedUsers($role_id), $this->participants));
1253  $this->members = $rbacreview->assignedUsers($role_id);
1254  break;
1255 
1256  case 'il_lso_m':
1257  $auto_generated_roles[$role_id] = IL_ROLE_POSITION_MEMBER;
1258  $this->role_data[IL_LSO_MEMBER] = $role_id;
1259  $this->participants = array_unique(array_merge($assigned = $rbacreview->assignedUsers($role_id), $this->participants));
1260  $this->members = $rbacreview->assignedUsers($role_id);
1261  $this->role_assignments[$role_id] = $assigned;
1262  break;
1263 
1264  case 'il_lso_a':
1265  $auto_generated_roles[$role_id] = IL_ROLE_POSITION_ADMIN;
1266  $this->role_data[IL_LSO_ADMIN] = $role_id;
1267  $this->participants = array_unique(array_merge($assigned = $rbacreview->assignedUsers($role_id), $this->participants));
1268  $this->admins = $rbacreview->assignedUsers($role_id);
1269  $this->role_assignments[$role_id] = $assigned;
1270  break;
1271 
1272  default:
1273  $additional_roles[$role_id] = $title;
1274  $this->participants = array_unique(array_merge($assigned = $rbacreview->assignedUsers($role_id), $this->participants));
1275  $this->members = array_unique(array_merge($assigned, $this->members));
1276  $this->role_assignments[$role_id] = $assigned;
1277  break;
1278  }
1279  }
1280  asort($auto_generated_roles);
1281  asort($additional_roles);
1282  $this->roles_sorted = $auto_generated_roles + $additional_roles;
1283  }
1284 
1292  protected function readParticipantsStatus()
1293  {
1294  global $DIC;
1295 
1296  $ilDB = $DIC['ilDB'];
1297 
1298  $query = "SELECT * FROM obj_members " .
1299  "WHERE obj_id = " . $ilDB->quote($this->obj_id, 'integer') . " ";
1300  $res = $ilDB->query($query);
1301  $this->participants_status = array();
1302  while ($row = $res->fetchRow(ilDBConstants::FETCHMODE_OBJECT)) {
1303  $this->participants_status[$row->usr_id]['blocked'] = $row->blocked;
1304  $this->participants_status[$row->usr_id]['notification'] = $row->notification;
1305  $this->participants_status[$row->usr_id]['passed'] = $row->passed;
1306  // cognos-blu-patch: begin
1307  $this->participants_status[$row->usr_id]['contact'] = $row->contact;
1308  // cognos-blu-patch: end
1309  }
1310  }
1311 
1319  public function isGroupingMember($a_usr_id, $a_field = '')
1320  {
1321  global $DIC;
1322 
1323  $rbacreview = $DIC['rbacreview'];
1324  $ilObjDataCache = $DIC['ilObjDataCache'];
1325  $ilDB = $DIC['ilDB'];
1326 
1327  // Used for membership limitations -> check membership by given field
1328  if ($a_field) {
1329  include_once './Services/User/classes/class.ilObjUser.php';
1330 
1331  $tmp_user = &ilObjectFactory::getInstanceByObjId($a_usr_id);
1332  switch ($a_field) {
1333  case 'login':
1334  $and = "AND login = " . $ilDB->quote($tmp_user->getLogin(), 'text') . " ";
1335  break;
1336  case 'email':
1337  $and = "AND email = " . $ilDB->quote($tmp_user->getEmail(), 'text') . " ";
1338  break;
1339  case 'matriculation':
1340  $and = "AND matriculation = " . $ilDB->quote($tmp_user->getMatriculation(), 'text') . " ";
1341  break;
1342 
1343  default:
1344  $and = "AND usr_id = " . $ilDB->quote($a_usr_id, 'integer') . " ";
1345  break;
1346  }
1347 
1348  if (!$this->getParticipants()) {
1349  return false;
1350  }
1351 
1352  $query = "SELECT * FROM usr_data ud " .
1353  "WHERE " . $ilDB->in('usr_id', $this->getParticipants(), false, 'integer') . " " .
1354  $and;
1355 
1356  $res = $ilDB->query($query);
1357  return $res->numRows() ? true : false;
1358  }
1359  }
1360 
1361  public static function lookupSubscribers($a_obj_id)
1362  {
1363  global $DIC;
1364 
1365  $ilDB = $DIC['ilDB'];
1366 
1367  $subscribers = array();
1368  $query = "SELECT usr_id FROM il_subscribers " .
1369  "WHERE obj_id = " . $ilDB->quote($a_obj_id, 'integer') . " " .
1370  "ORDER BY sub_time ";
1371 
1372  $res = $ilDB->query($query);
1373  while ($row = $res->fetchRow(ilDBConstants::FETCHMODE_OBJECT)) {
1374  $subscribers[] = $row->usr_id;
1375  }
1376  return $subscribers;
1377  }
1378 
1384  public function getSubscribers()
1385  {
1386  $this->readSubscribers();
1387 
1388  return $this->subscribers;
1389  }
1390 
1391 
1397  public function getCountSubscribers()
1398  {
1399  return count($this->getSubscribers());
1400  }
1401 
1407  public function getSubscriberData($a_usr_id)
1408  {
1409  return $this->readSubscriberData($a_usr_id);
1410  }
1411 
1412 
1413 
1419  public function assignSubscribers($a_usr_ids)
1420  {
1421  if (!is_array($a_usr_ids) or !count($a_usr_ids)) {
1422  return false;
1423  }
1424  foreach ($a_usr_ids as $id) {
1425  if (!$this->assignSubscriber($id)) {
1426  return false;
1427  }
1428  }
1429  return true;
1430  }
1431 
1437  public function assignSubscriber($a_usr_id)
1438  {
1439  global $DIC;
1440 
1441  $ilErr = $DIC['ilErr'];
1442 
1443  $ilErr->setMessage("");
1444  if (!$this->isSubscriber($a_usr_id)) {
1445  $ilErr->appendMessage($this->lng->txt("crs_user_notsubscribed"));
1446 
1447  return false;
1448  }
1449  if ($this->isAssigned($a_usr_id)) {
1450  $tmp_obj = ilObjectFactory::getInstanceByObjId($a_usr_id);
1451  $ilErr->appendMessage($tmp_obj->getLogin() . ": " . $this->lng->txt("crs_user_already_assigned"));
1452 
1453  return false;
1454  }
1455 
1456  if (!$tmp_obj = &ilObjectFactory::getInstanceByObjId($a_usr_id)) {
1457  $ilErr->appendMessage($this->lng->txt("crs_user_not_exists"));
1458 
1459  return false;
1460  }
1461 
1462  // TODO: must be group or course member role
1463  if ($this instanceof ilCourseParticipants) {
1464  $this->add($tmp_obj->getId(), IL_CRS_MEMBER);
1465  }
1466  if ($this instanceof ilGroupParticipants) {
1467  $this->add($tmp_obj->getId(), IL_GRP_MEMBER);
1468  }
1469  if ($this instanceof ilLearningSequenceParticipants) {
1470  $this->add($tmp_obj->getId(), IL_LSO_MEMBER);
1471  }
1472  if ($this instanceof ilSessionParticipants) {
1473  $this->register($tmp_obj->getId());
1474  }
1475  $this->deleteSubscriber($a_usr_id);
1476  return true;
1477  }
1478 
1484  public function autoFillSubscribers()
1485  {
1486  $this->readSubscribers();
1487 
1488  $counter = 0;
1489  foreach ($this->subscribers as $subscriber) {
1490  if (!$this->assignSubscriber($subscriber)) {
1491  continue;
1492  } else {
1493  // TODO: notification
1494  #$this->sendNotification($this->NOTIFY_ACCEPT_SUBSCRIBER,$subscriber);
1495  }
1496  ++$counter;
1497  }
1498 
1499  return $counter;
1500  }
1501 
1507  public function addSubscriber($a_usr_id)
1508  {
1509  global $DIC;
1510 
1511  $ilDB = $DIC['ilDB'];
1512 
1513  $query = "INSERT INTO il_subscribers (usr_id,obj_id,subject,sub_time) " .
1514  " VALUES (" .
1515  $ilDB->quote($a_usr_id, 'integer') . "," .
1516  $ilDB->quote($this->obj_id, 'integer') . ", " .
1517  $ilDB->quote('', 'text') . ", " .
1518  $ilDB->quote(time(), 'integer') .
1519  ")";
1520  $res = $ilDB->manipulate($query);
1521 
1522  return true;
1523  }
1524 
1525 
1531  public function updateSubscriptionTime($a_usr_id, $a_subtime)
1532  {
1533  global $DIC;
1534 
1535  $ilDB = $DIC['ilDB'];
1536 
1537  $query = "UPDATE il_subscribers " .
1538  "SET sub_time = " . $ilDB->quote($a_subtime, 'integer') . " " .
1539  "WHERE usr_id = " . $ilDB->quote($a_usr_id, 'integer') . " " .
1540  "AND obj_id = " . $ilDB->quote($this->obj_id, 'integer') . " ";
1541  $res = $ilDB->manipulate($query);
1542 
1543  return true;
1544  }
1545 
1553  public function updateSubject($a_usr_id, $a_subject)
1554  {
1555  global $DIC;
1556 
1557  $ilDB = $DIC['ilDB'];
1558 
1559  $query = "UPDATE il_subscribers " .
1560  "SET subject = " . $ilDB->quote($a_subject, 'text') . " " .
1561  "WHERE usr_id = " . $ilDB->quote($a_usr_id, 'integer') . " " .
1562  "AND obj_id = " . $ilDB->quote($this->obj_id, 'integer') . " ";
1563  $res = $ilDB->manipulate($query);
1564  return true;
1565  }
1566 
1567 
1573  public function deleteSubscriber($a_usr_id)
1574  {
1575  global $DIC;
1576 
1577  $ilDB = $DIC['ilDB'];
1578 
1579  $query = "DELETE FROM il_subscribers " .
1580  "WHERE usr_id = " . $ilDB->quote($a_usr_id, 'integer') . " " .
1581  "AND obj_id = " . $ilDB->quote($this->obj_id, 'integer') . " ";
1582  $res = $ilDB->manipulate($query);
1583 
1584  return true;
1585  }
1586 
1587 
1593  public function deleteSubscribers($a_usr_ids)
1594  {
1595  global $DIC;
1596 
1597  $ilErr = $DIC['ilErr'];
1598  $ilDB = $DIC['ilDB'];
1599 
1600  if (!is_array($a_usr_ids) or !count($a_usr_ids)) {
1601  $ilErr->setMessage('');
1602  $ilErr->appendMessage($this->lng->txt("no_usr_ids_given"));
1603 
1604  return false;
1605  }
1606  $query = "DELETE FROM il_subscribers " .
1607  "WHERE " . $ilDB->in('usr_id', (array) $a_usr_ids, false, 'integer') . " " .
1608  "AND obj_id = " . $ilDB->quote($this->obj_id, 'integer');
1609  $res = $ilDB->query($query);
1610  return true;
1611  }
1612 
1613 
1619  public function isSubscriber($a_usr_id)
1620  {
1621  global $DIC;
1622 
1623  $ilDB = $DIC['ilDB'];
1624 
1625  $query = "SELECT * FROM il_subscribers " .
1626  "WHERE usr_id = " . $ilDB->quote($a_usr_id, 'integer') . " " .
1627  "AND obj_id = " . $ilDB->quote($this->obj_id, 'integer') . "";
1628 
1629  $res = $ilDB->query($query);
1630  while ($row = $res->fetchRow(ilDBConstants::FETCHMODE_OBJECT)) {
1631  return true;
1632  }
1633  return false;
1634  }
1635 
1642  public static function _isSubscriber($a_obj_id, $a_usr_id)
1643  {
1644  global $DIC;
1645 
1646  $ilDB = $DIC['ilDB'];
1647 
1648  $query = "SELECT * FROM il_subscribers " .
1649  "WHERE usr_id = " . $ilDB->quote($a_usr_id, 'integer') . " " .
1650  "AND obj_id = " . $ilDB->quote($a_obj_id, 'integer') . "";
1651 
1652  $res = $ilDB->query($query);
1653  while ($row = $res->fetchRow(ilDBConstants::FETCHMODE_OBJECT)) {
1654  return true;
1655  }
1656  return false;
1657  }
1658 
1664  protected function readSubscribers()
1665  {
1666  global $DIC;
1667 
1668  $ilDB = $DIC['ilDB'];
1669 
1670  $this->subscribers = array();
1671 
1672  $query = "SELECT usr_id FROM il_subscribers " .
1673  "WHERE obj_id = " . $ilDB->quote($this->obj_id, 'integer') . " " .
1674  "ORDER BY sub_time ";
1675 
1676  $res = $this->ilDB->query($query);
1677  while ($row = $res->fetchRow(ilDBConstants::FETCHMODE_OBJECT)) {
1678  // DELETE SUBSCRIPTION IF USER HAS BEEN DELETED
1679  if (!ilObjectFactory::getInstanceByObjId($row->usr_id, false)) {
1680  $this->deleteSubscriber($row->usr_id);
1681  }
1682  $this->subscribers[] = $row->usr_id;
1683  }
1684  return true;
1685  }
1686 
1692  protected function readSubscriberData($a_usr_id)
1693  {
1694  global $DIC;
1695 
1696  $ilDB = $DIC['ilDB'];
1697 
1698  $query = "SELECT * FROM il_subscribers " .
1699  "WHERE obj_id = " . $ilDB->quote($this->obj_id, 'integer') . " " .
1700  "AND usr_id = " . $ilDB->quote($a_usr_id, 'integer') . "";
1701 
1702  $res = $this->ilDB->query($query);
1703  while ($row = $res->fetchRow(ilDBConstants::FETCHMODE_OBJECT)) {
1704  $data["time"] = $row->sub_time;
1705  $data["usr_id"] = $row->usr_id;
1706  $data['subject'] = $row->subject;
1707  }
1708  return $data ? $data : array();
1709  }
1710 
1711  public static function lookupSubscribersData($a_obj_id)
1712  {
1713  global $DIC;
1714 
1715  $ilDB = $DIC['ilDB'];
1716 
1717  $query = 'SELECT * FROM il_subscribers ' .
1718  'WHERE obj_id = ' . $ilDB->quote($a_obj_id, 'integer');
1719  $res = $ilDB->query($query);
1720 
1721  $data = array();
1722  while ($row = $res->fetchRow(ilDBConstants::FETCHMODE_OBJECT)) {
1723  $data[$row->usr_id]['time'] = $row->sub_time;
1724  $data[$row->usr_id]['usr_id'] = $row->usr_id;
1725  $data[$row->usr_id]['subject'] = $row->subject;
1726  }
1727  return $data;
1728  }
1729 
1737  public static function _getAllSupportContactsOfUser($a_usr_id, $a_type)
1738  {
1739  global $DIC;
1740 
1741  $ilDB = $DIC['ilDB'];
1742 
1743  // todo: join the two queries or alternatively reuse _getMembershipByType
1744  // for the first part
1745 
1746  // this will also dismiss local roles!
1747  $j2 = "JOIN object_data obd2 ON (ua.rol_id = obd2.obj_id) ";
1748  $a2 = "AND obd2.title LIKE 'il_" . $a_type . "_mem%' ";
1749 
1750  // #14290 - no role folder anymore
1751  $query = "SELECT DISTINCT obd.obj_id,obr.ref_id FROM rbac_ua ua " .
1752  "JOIN rbac_fa fa ON ua.rol_id = fa.rol_id " .
1753  "JOIN object_reference obr ON fa.parent = obr.ref_id " .
1754  "JOIN object_data obd ON obr.obj_id = obd.obj_id " .
1755  $j2 .
1756  "WHERE obd.type = " . $ilDB->quote($a_type, 'text') . " " .
1757  "AND fa.assign = 'y' " .
1758  "AND ua.usr_id = " . $ilDB->quote($a_usr_id, 'integer') . " " .
1759  $a2;
1760 
1761  $res = $ilDB->query($query);
1762  $obj_ids = array();
1763  while ($row = $ilDB->fetchObject($res)) {
1764  $obj_ids[] = $row->obj_id;
1765  }
1766 
1767  $set = $ilDB->query("SELECT obj_id, usr_id FROM obj_members " .
1768  " WHERE " . $ilDB->in("obj_id", $obj_ids, false, "integer") .
1769  " AND contact = " . $ilDB->quote(1, "integer"));
1770  $res = array();
1771  while ($rec = $ilDB->fetchAssoc($set)) {
1772  $res[] = $rec;
1773  }
1774 
1775  return $res;
1776  }
1777 
1783  public function setRoleOrderPosition($a_user_id)
1784  {
1785  $counter = 0;
1786  $sortable_assignments = '9999999999';
1787  foreach ($this->roles_sorted as $role_id => $trash) {
1788  if (in_array($a_user_id, (array) $this->role_assignments[$role_id])) {
1789  $sortable_assignments = substr_replace($sortable_assignments, '1', $counter, 1);
1790  }
1791  ++$counter;
1792  }
1793  return $sortable_assignments;
1794  }
1795 }
static canSendMailToMembers( $ref_id_or_instance, ?int $usr_id=null, ?int $mail_obj_ref_id=null)
This method was introduced as a band-aid fix for #22764.
getObjId()
get current obj_id
static _isParticipant($a_ref_id, $a_usr_id)
Static function to check if a user is a participant of the container object.
__construct($a_component_name, $a_ref_id)
Singleton Constructor.
getCountMembers()
Get number of members (not participants)
static _getAllSupportContactsOfUser($a_usr_id, $a_type)
Get all support contacts for a user.
static _isSubscriber($a_obj_id, $a_usr_id)
check if user is subscriber
static _deleteAllEntries($a_obj_id)
Delete all entries Normally called for course deletion.
autoFillSubscribers()
Assign subscriber.
static lookupNumberOfParticipants($a_ref_id)
Lookup the number of participants (crs admins, tutors, members, grp admins, members) ...
static lookupNumberOfMembers($a_ref_id)
Lookup number of members ilRbacReview $rbacreview <type> $ilObjDataCache.
updateContact($a_usr_id, $a_contact)
Update contact setting type $ilDB.
Session participation handling.
readParticipantsStatus()
Read status of participants (blocked, notification, passed)
$data
Definition: storeScorm.php:23
checkLastAdmin($a_usr_ids)
Check if user for deletion are last admins.
deleteParticipants($a_user_ids)
Delete users.
isAssigned($a_usr_id)
check if user is assigned
isLastAdmin($a_usr_id)
Check if user is last admin.
getCountAdmins()
Get number of admins.
static lookupSubscribers($a_obj_id)
updateBlocked($a_usr_id, $a_blocked)
Update blocked status.
static _deleteUser($a_usr_id)
Delete user.
const IL_LSO_MEMBER
const IL_GRP_ADMIN
assignSubscriber($a_usr_id)
Assign subscriber.
isAdmin($a_usr_id)
is user admin
static _getMembershipByType($a_usr_id, $a_type, $a_only_member_role=false)
get membership by type Get course or group membership
static _getInstanceByObjId($a_obj_id)
Get singleton instance.
isNotificationEnabled($a_usr_id)
check if notification is enabled
readSubscriberData($a_usr_id)
read subscribers
static _lookupTitle($a_id)
lookup object title
isMember($a_usr_id)
is user member
const IL_CRS_TUTOR
readSubscribers()
read subscribers
static getDefaultMemberRole($a_ref_id)
static _isBlocked($a_obj_id, $a_usr_id)
Check if user is blocked.
getAutoGeneratedRoleId($a_role_type)
Get role id of auto generated role type.
deleteSubscriber($a_usr_id)
Delete subsciber.
getAssignedRoles($a_usr_id)
Get assigned roles.
const IL_GRP_MEMBER
const IL_ROLE_POSITION_MEMBER
updateSubject($a_usr_id, $a_subject)
update subject
static _getInstanceByObjId($a_obj_id)
Get instance.
add($a_usr_id, $a_role)
Add user to object.
const IL_LSO_ADMIN
static hasParticipantListAccess($a_obj_id, $a_usr_id=null)
Check if (current) user has access to the participant list.
static _getAllReferences($a_id)
get all reference ids of object
$ilErr
Definition: raiseError.php:18
updateNotification($a_usr_id, $a_notification)
Update notification status.
getCountSubscribers()
get number of subscribers
const IL_CRS_MEMBER
static lookupShowMembersEnabled($a_obj_id)
Check if show member is enabled.
static getInstance($a_ref_id)
Get instance by ref_id.
setRoleOrderPosition($a_user_id)
Set role order position.
deleteSubscribers($a_usr_ids)
Delete subscibers.
getMembers()
Get all members ids (admins and tutors are not members) Use get participants to fetch all...
static lookupShowMembersEnabled(int $a_obj_id)
foreach($_POST as $key=> $value) $res
updateSubscriptionTime($a_usr_id, $a_subtime)
Update subscription time.
isSubscriber($a_usr_id)
check if is subscriber
getCountParticipants()
Get number of participants.
getSubscribers()
get all subscribers
static _lookupObjId($a_id)
global $DIC
Definition: goto.php:24
getParticipants()
Get all participants ids.
addSubscriber($a_usr_id)
Add subscriber.
if(!defined('PATH_SEPARATOR')) $GLOBALS['_PEAR_default_error_mode']
Definition: PEAR.php:64
static _hasPassed($a_obj_id, $a_usr_id)
Check if user has passed course.
isContact($a_usr_id)
Check if user is contact.
const IL_CRS_ADMIN
Base class for course and group participants.
$query
isBlocked($a_usr_id)
Check if user is blocked.
static getInstanceByObjId($a_obj_id, $stop_on_error=true)
get an instance of an Ilias object by object id
static _getInstanceByObjId($a_obj_id)
Get singleton instance.
static _lookupType($a_id, $a_reference=false)
lookup object type
hasPassed($a_usr_id)
Check if user has passed course.
getRoles()
Get course roles.
static getInstance($a_ref_id)
Get instance.
static lookupSubscribersData($a_obj_id)
assignSubscribers($a_usr_ids)
Assign subscribers.
updateRoleAssignments($a_usr_id, $a_roles)
Update role assignments.
addRecommendation($a_usr_id)
Add desktop item.
const MAIL_ALLOWED_ALL
getAdmins()
Get all admins ids.
getComponent()
Get component name Used for raising events.
static _deleteUser($a_usr_id)
Delete user data.
const IL_ROLE_POSITION_ADMIN
getNotificationRecipients()
Get admin, tutor which have notification enabled.
getContacts()
get user ids which are confirgured as contact
static getInstanceByRefId($a_ref_id, $stop_on_error=true)
get an instance of an Ilias object by reference id
static deleteUserEntry($a_usr_id, $a_obj_id)
Delete one user entry.
Class ilObjGroup.
static getUserMembershipAssignmentsByType($a_user_ids, $a_type, $a_only_member_roles)
Get user membership assignments by type.
const IL_SESS_MEMBER
Recommended content manager (business logic)
static getInstanceByObjId($a_obj_id)
Get instance by obj type.
isGroupingMember($a_usr_id, $a_field='')
Check grouping membership.
getType()
Get object type.
isTutor($a_usr_id)
is user tutor
getSubscriberData($a_usr_id)
get subscriber data
const IL_ROLE_POSITION_TUTOR
readParticipants()
Read participants.
getTutors()
Get all tutors ids.