ILIAS  release_5-3 Revision v5.3.23-19-g915713cf615
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
5include_once("./Services/Awareness/classes/class.ilAwarenessUserProvider.php");
6
15{
16
20 public function __construct()
21 {
22 global $DIC;
23
24 parent::__construct();
25
26 $this->db = $DIC->database();
27 }
28
34 public function getProviderId()
35 {
36 return "mmbr_user_grpcrs";
37 }
38
44 public function getTitle()
45 {
46 $this->lng->loadLanguageModule("mmbr");
47 return $this->lng->txt("mmbr_awrn_my_groups_courses");
48 }
49
55 public function getInfo()
56 {
57 $this->lng->loadLanguageModule("crs");
58 return $this->lng->txt("mmbr_awrn_my_groups_courses_info");
59 }
60
66 public function getInitialUserSet()
67 {
69
70
71 include_once("./Services/Membership/classes/class.ilParticipants.php");
72 $groups_and_courses_of_user = ilParticipants::_getMembershipByType($this->getUserId(), array("grp", "crs"));
73 $this->log->debug("user: " . $this->getUserId() . ", courses and groups: " . implode(",", $groups_and_courses_of_user));
74
75 $set = $ilDB->query(
76 "SELECT DISTINCT usr_id, obj_id FROM obj_members " .
77 " WHERE " . $ilDB->in("obj_id", $groups_and_courses_of_user, false, "integer") . ' ' .
78 'AND (admin > ' . $ilDB->quote(0, 'integer') . ' ' .
79 'OR tutor > ' . $ilDB->quote(0, 'integer') . ' ' .
80 'OR member > ' . $ilDB->quote(0, 'integer') . ")"
81 );
82 $ub = array();
83 while ($rec = $ilDB->fetchAssoc($set)) {
84 if (!in_array($rec["usr_id"], $ub)) {
85 $ub[] = $rec["usr_id"];
86 if ($this->log->isHandling(ilLogLevel::DEBUG)) {
87 // cross-check if user is in course
88 include_once("./Services/Membership/classes/class.ilParticipants.php");
89 $ref_ids = ilObject::_getAllReferences($rec["obj_id"]);
90 $ref_id = current($ref_ids);
91 $this->log->debug("Cross-checking all members...");
92 if (!ilParticipants::_isParticipant($ref_id, $rec["usr_id"])) {
93 $this->log->debug("ERROR: obj_members has entry for user id: " . $rec["usr_id"] .
94 ", user : " . ilObject::_lookupTitle($rec["usr_id"]) . ", course ref: " . $ref_id . ", course: " .
95 ilObject::_lookupTitle($rec["obj_id"]) . ", but ilParticipants does not list this user as a member.");
96 }
97 }
98 }
99 }
100
101 $this->log->debug("Got " . count($ub) . " distinct members.");
102
103 return $ub;
104 }
105}
An exception for terminatinating execution or to throw for unit testing.
All members of the same courses/groups as the user.
getInfo()
Provider info (used in administration settings)
getTitle()
Provider title (used in awareness overlay and in administration settings)
A class that provides a collection of users for the awareness tool.
static _lookupTitle($a_id)
lookup object title
static _getAllReferences($a_id)
get all reference ids of object
static _isParticipant($a_ref_id, $a_usr_id)
Static function to check if a user is a participant of the container object.
static _getMembershipByType($a_usr_id, $a_type, $a_only_member_role=false)
get membership by type Get course or group membership
global $DIC
Definition: saml.php:7
global $ilDB