ILIAS  release_5-2 Revision v5.2.25-18-g3f80b828510
class.ilAwarenessUserProviderMemberships.php
Go to the documentation of this file.
1 <?php
2 
3 /* Copyright (c) 1998-2014 ILIAS open source, Extended GPL, see docs/LICENSE */
4 
5 include_once("./Services/Awareness/classes/class.ilAwarenessUserProvider.php");
6 
15 {
21  function getProviderId()
22  {
23  return "mmbr_user_grpcrs";
24  }
25 
31  function getTitle()
32  {
33  $this->lng->loadLanguageModule("mmbr");
34  return $this->lng->txt("mmbr_awrn_my_groups_courses");
35  }
36 
42  function getInfo()
43  {
44  $this->lng->loadLanguageModule("crs");
45  return $this->lng->txt("mmbr_awrn_my_groups_courses_info");
46  }
47 
53  function getInitialUserSet()
54  {
55  global $ilDB;
56 
57 
58  include_once("./Services/Membership/classes/class.ilParticipants.php");
59  $groups_and_courses_of_user = ilParticipants::_getMembershipByType($this->getUserId(), array("grp", "crs"));
60  $this->log->debug("user: ".$this->getUserId().", courses and groups: ".implode(",", $groups_and_courses_of_user));
61 
62  $set = $ilDB->query("SELECT DISTINCT usr_id, obj_id FROM obj_members ".
63  " WHERE ".$ilDB->in("obj_id", $groups_and_courses_of_user, false, "integer").' '.
64  'AND (admin > '.$ilDB->quote(0,'integer').' '.
65  'OR tutor > '.$ilDB->quote(0,'integer').' '.
66  'OR member > '.$ilDB->quote(0,'integer').")"
67  );
68  $ub = array();
69  while ($rec = $ilDB->fetchAssoc($set))
70  {
71  if (!in_array($rec["usr_id"], $ub))
72  {
73  $ub[] = $rec["usr_id"];
74  if ($this->log->isHandling(ilLogLevel::DEBUG))
75  {
76  // cross-check if user is in course
77  include_once("./Services/Membership/classes/class.ilParticipants.php");
78  $ref_ids = ilObject::_getAllReferences($rec["obj_id"]);
79  $ref_id = current($ref_ids);
80  $this->log->debug("Cross-checking all members...");
81  if (!ilParticipants::_isParticipant($ref_id, $rec["usr_id"]))
82  {
83  $this->log->debug("ERROR: obj_members has entry for user id: ".$rec["usr_id"].
84  ", user : ".ilObject::_lookupTitle($rec["usr_id"]).", course ref: ".$ref_id.", course: ".
85  ilObject::_lookupTitle($rec["obj_id"]).", but ilParticipants does not list this user as a member.");
86  }
87  }
88  }
89  }
90 
91  $this->log->debug("Got ".count($ub)." distinct members.");
92 
93  return $ub;
94  }
95 }
96 ?>
static _isParticipant($a_ref_id, $a_usr_id)
Static function to check if a user is a participant of the container object.
getTitle()
Provider title (used in awareness overlay and in administration settings)
getInfo()
Provider info (used in administration settings)
static _getMembershipByType($a_usr_id, $a_type, $a_only_member_role=false)
get membership by type Get course or group membership
static _lookupTitle($a_id)
lookup object title
A class that provides a collection of users for the awareness tool.
static _getAllReferences($a_id)
get all reference ids of object
All members of the same courses/groups as the user.
Create styles array
The data for the language used.
global $ilDB