ILIAS  trunk Revision v11.0_alpha-3011-gc6b235a2e85
ilECSCommunityReader Class Reference
+ Collaboration diagram for ilECSCommunityReader:

Public Member Functions

 getServer ()
 Get server setting. More...
 
 getParticipants ()
 Get participants. More...
 
 getOwnMIDs ()
 get publishable ids More...
 
 getCommunities ()
 get communities More...
 
 getCommunityById ($a_id)
 get community by id More...
 
 getParticipantsByPid (int $a_pid)
 
 getParticipantByMID ($a_mid)
 get participant by id More...
 
 getParticipantNameByMid ($a_mid)
 
 getCommunityByMID (int $a_mid)
 Get community by mid. More...
 
 getEnabledParticipants ()
 get enabled participants More...
 

Static Public Member Functions

static getInstanceByServerId (int $a_server_id)
 Get instance by server id. More...
 

Private Member Functions

 __construct (ilECSSetting $setting)
 Singleton constructor. More...
 
 read ()
 Read. More...
 

Private Attributes

int $position = 0
 
ilLogger $logger
 
ilECSSetting $settings
 
ilECSConnector $connector
 
array $communities = array()
 
array $participants = array()
 
array $own_ids = array()
 

Static Private Attributes

static array $instances = null
 

Detailed Description

Author
Stefan Meyer meyer.nosp@m.@lei.nosp@m.fos.c.nosp@m.om

Definition at line 24 of file class.ilECSCommunityReader.php.

Constructor & Destructor Documentation

◆ __construct()

ilECSCommunityReader::__construct ( ilECSSetting  $setting)
private

Singleton constructor.

@access private

Exceptions
ilECSConnectorException

Definition at line 47 of file class.ilECSCommunityReader.php.

48 {
49 global $DIC;
50
51 $this->logger = $DIC->logger()->wsrv();
52 $this->logger->debug(print_r($setting->getServerId(), true));
53 $this->settings = $setting;
54
55 $this->connector = new ilECSConnector($this->settings);
56
57 $this->read();
58 $this->logger->debug(__METHOD__ . ': Finished reading communities');
59 }
getServerId()
Get current server id.
global $DIC
Definition: shib_login.php:26

References $DIC, ilECSSetting\getServerId(), ILIAS\Repository\logger(), read(), and ILIAS\Repository\settings().

+ Here is the call graph for this function:

Member Function Documentation

◆ getCommunities()

ilECSCommunityReader::getCommunities ( )

get communities

@access public

Returns
\ilECSCommunity[]

Definition at line 101 of file class.ilECSCommunityReader.php.

101 : array
102 {
103 return $this->communities ?: [];
104 }

Referenced by getEnabledParticipants(), and getParticipantsByPid().

+ Here is the caller graph for this function:

◆ getCommunityById()

ilECSCommunityReader::getCommunityById (   $a_id)

get community by id

@access public

Parameters
intcomm_id

Definition at line 112 of file class.ilECSCommunityReader.php.

113 {
114 foreach ($this->communities as $community) {
115 if ($community->getId() === $a_id) {
116 return $community;
117 }
118 }
119 return null;
120 }

◆ getCommunityByMID()

ilECSCommunityReader::getCommunityByMID ( int  $a_mid)

Get community by mid.

Definition at line 159 of file class.ilECSCommunityReader.php.

160 {
161 foreach ($this->communities as $community) {
162 foreach ($community->getParticipants() as $part) {
163 if ($part->getMID() === $a_mid) {
164 return $community;
165 }
166 }
167 }
168 return null;
169 }

◆ getEnabledParticipants()

ilECSCommunityReader::getEnabledParticipants ( )

get enabled participants

Definition at line 174 of file class.ilECSCommunityReader.php.

174 : array
175 {
176 $ps = ilECSParticipantSettings::getInstanceByServerId($this->getServer()->getServerId());
177 $en = $ps->getEnabledParticipants();
178 $e_part = [];
179 foreach ($this->getCommunities() as $community) {
180 foreach ($community->getParticipants() as $participant) {
181 if (in_array($participant->getMid(), $en, true)) {
182 $e_part[] = $participant;
183 }
184 }
185 }
186 return $e_part;
187 }
getServer()
Get server setting.
static getInstanceByServerId(int $a_server_id)
Get instance by server id.

References getCommunities(), ilECSParticipantSettings\getInstanceByServerId(), and getServer().

+ Here is the call graph for this function:

◆ getInstanceByServerId()

static ilECSCommunityReader::getInstanceByServerId ( int  $a_server_id)
static

◆ getOwnMIDs()

ilECSCommunityReader::getOwnMIDs ( )

get publishable ids

Definition at line 90 of file class.ilECSCommunityReader.php.

90 : array
91 {
92 return $this->own_ids ?: [];
93 }

◆ getParticipantByMID()

ilECSCommunityReader::getParticipantByMID (   $a_mid)

get participant by id

@access public

Parameters
intmid

Definition at line 144 of file class.ilECSCommunityReader.php.

145 {
146 return $this->participants[$a_mid] ?? false;
147 }

◆ getParticipantNameByMid()

ilECSCommunityReader::getParticipantNameByMid (   $a_mid)

Definition at line 149 of file class.ilECSCommunityReader.php.

149 : string
150 {
151 return isset($this->participants[$a_mid]) ?
152 $this->participants[$a_mid]-> getParticipantName() :
153 '';
154 }

◆ getParticipants()

ilECSCommunityReader::getParticipants ( )

Get participants.

Returns
ilECSParticipant[]

Definition at line 81 of file class.ilECSCommunityReader.php.

81 : array
82 {
84 }

References $participants.

◆ getParticipantsByPid()

ilECSCommunityReader::getParticipantsByPid ( int  $a_pid)
Returns
\ilECSParticipant[]

Definition at line 125 of file class.ilECSCommunityReader.php.

125 : array
126 {
127 $participants = [];
128 foreach ($this->getCommunities() as $community) {
129 foreach ($community->getParticipants() as $participant) {
130 if ($participant->getPid() === $a_pid) {
131 $participants[] = $participant;
132 }
133 }
134 }
135 return $participants;
136 }

References $participants, and getCommunities().

+ Here is the call graph for this function:

◆ getServer()

ilECSCommunityReader::getServer ( )

Get server setting.

Definition at line 72 of file class.ilECSCommunityReader.php.

References $settings.

Referenced by getEnabledParticipants().

+ Here is the caller graph for this function:

◆ read()

ilECSCommunityReader::read ( )
private

Read.

Exceptions
ilECSConnectorException

Definition at line 194 of file class.ilECSCommunityReader.php.

194 : void
195 {
196 try {
197 $res = $this->connector->getMemberships();
198
199 if (!is_array($res->getResult())) {
200 return;
201 }
202 foreach ($res->getResult() as $community) {
203 $tmp_comm = new ilECSCommunity($community);
204 foreach ($tmp_comm->getParticipants() as $participant) {
205 $this->participants[$participant->getMID()] = $participant;
206 if ($participant->isSelf()) {
207 $this->own_ids[] = $participant->getMID();
208 }
209 }
210 $this->communities[] = $tmp_comm;
211 }
212 } catch (ilECSConnectorException $e) {
213 $this->logger->error(__METHOD__ . ': Error connecting to ECS server. ' . $e->getMessage());
214 throw $e;
215 }
216 }
$res
Definition: ltiservices.php:69

References Vendor\Package\$e, $res, and ILIAS\Repository\logger().

Referenced by __construct().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

Field Documentation

◆ $communities

array ilECSCommunityReader::$communities = array()
private

Definition at line 37 of file class.ilECSCommunityReader.php.

◆ $connector

ilECSConnector ilECSCommunityReader::$connector
private

Definition at line 32 of file class.ilECSCommunityReader.php.

◆ $instances

array ilECSCommunityReader::$instances = null
staticprivate

Definition at line 26 of file class.ilECSCommunityReader.php.

◆ $logger

ilLogger ilECSCommunityReader::$logger
private

Definition at line 30 of file class.ilECSCommunityReader.php.

◆ $own_ids

array ilECSCommunityReader::$own_ids = array()
private

Definition at line 39 of file class.ilECSCommunityReader.php.

◆ $participants

array ilECSCommunityReader::$participants = array()
private

Definition at line 38 of file class.ilECSCommunityReader.php.

Referenced by getParticipants(), and getParticipantsByPid().

◆ $position

int ilECSCommunityReader::$position = 0
private

Definition at line 28 of file class.ilECSCommunityReader.php.

◆ $settings

ilECSSetting ilECSCommunityReader::$settings
private

Definition at line 31 of file class.ilECSCommunityReader.php.

Referenced by getServer().


The documentation for this class was generated from the following file: