ILIAS  release_8 Revision v8.19-1-g4e8f2f9140c
All Data Structures Namespaces Files Functions Variables Modules Pages
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 23 of file class.ilECSCommunityReader.php.

Constructor & Destructor Documentation

◆ __construct()

ilECSCommunityReader::__construct ( ilECSSetting  $setting)
private

Singleton constructor.

private

Exceptions
ilECSConnectorException

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

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

47  {
48  global $DIC;
49 
50  $this->logger = $DIC->logger()->wsrv();
51  $this->logger->debug(print_r($setting->getServerId(), true));
52  $this->settings = $setting;
53 
54  $this->connector = new ilECSConnector($this->settings);
55 
56  $this->read();
57  $this->logger->debug(__METHOD__ . ': Finished reading communities');
58  }
getServerId()
Get current server id.
global $DIC
Definition: feed.php:28
+ Here is the call graph for this function:

Member Function Documentation

◆ getCommunities()

ilECSCommunityReader::getCommunities ( )

get communities

public

Returns
[]

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

Referenced by getEnabledParticipants(), and getParticipantsByPid().

100  : array
101  {
102  return $this->communities ?: [];
103  }
+ Here is the caller graph for this function:

◆ getCommunityById()

ilECSCommunityReader::getCommunityById (   $a_id)

get community by id

public

Parameters
intcomm_id

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

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

◆ getCommunityByMID()

ilECSCommunityReader::getCommunityByMID ( int  $a_mid)

Get community by mid.

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

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

◆ getEnabledParticipants()

ilECSCommunityReader::getEnabledParticipants ( )

get enabled participants

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

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

173  : array
174  {
175  $ps = ilECSParticipantSettings::getInstanceByServerId($this->getServer()->getServerId());
176  $en = $ps->getEnabledParticipants();
177  $e_part = [];
178  foreach ($this->getCommunities() as $community) {
179  foreach ($community->getParticipants() as $participant) {
180  if (in_array($participant->getMid(), $en, true)) {
181  $e_part[] = $participant;
182  }
183  }
184  }
185  return $e_part;
186  }
getServer()
Get server setting.
static getInstanceByServerId(int $a_server_id)
Get instance by server id.
+ 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 89 of file class.ilECSCommunityReader.php.

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

◆ getParticipantByMID()

ilECSCommunityReader::getParticipantByMID (   $a_mid)

get participant by id

public

Parameters
intmid

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

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

◆ getParticipantNameByMid()

ilECSCommunityReader::getParticipantNameByMid (   $a_mid)

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

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

◆ getParticipants()

ilECSCommunityReader::getParticipants ( )

Get participants.

Returns
ilECSParticipant[]

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

References $participants.

80  : array
81  {
82  return $this->participants;
83  }

◆ getParticipantsByPid()

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

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

References $participants, and getCommunities().

124  : array
125  {
126  $participants = [];
127  foreach ($this->getCommunities() as $community) {
128  foreach ($community->getParticipants() as $participant) {
129  if ($participant->getPid() === $a_pid) {
130  $participants[] = $participant;
131  }
132  }
133  }
134  return $participants;
135  }
+ Here is the call graph for this function:

◆ getServer()

ilECSCommunityReader::getServer ( )

Get server setting.

Definition at line 71 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 193 of file class.ilECSCommunityReader.php.

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

Referenced by __construct().

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

◆ $connector

ilECSConnector ilECSCommunityReader::$connector
private

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

◆ $instances

array ilECSCommunityReader::$instances = null
staticprivate

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

◆ $logger

ilLogger ilECSCommunityReader::$logger
private

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

◆ $own_ids

array ilECSCommunityReader::$own_ids = array()
private

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

◆ $participants

array ilECSCommunityReader::$participants = array()
private

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

Referenced by getParticipants(), and getParticipantsByPid().

◆ $position

int ilECSCommunityReader::$position = 0
private

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

◆ $settings

ilECSSetting ilECSCommunityReader::$settings
private

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

Referenced by getServer().


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