ILIAS  release_5-3 Revision v5.3.23-19-g915713cf615
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 ($a_pid)
 
 getParticipantByMID ($a_mid)
 get participant by id More...
 
 getCommunityByMID ($a_mid)
 Get community by mid. More...
 
 getPublishableParticipants ()
 get publishable communities More...
 
 getEnabledParticipants ()
 get enabled participants More...
 

Static Public Member Functions

static _getInstance ()
 get singleton instance More...
 
static getInstanceByServerId ($a_server_id)
 Get instance by server id. More...
 

Protected Attributes

 $position = 0
 
 $log
 
 $settings = null
 
 $connector = null
 
 $communities = array()
 
 $participants = array()
 
 $own_ids = array()
 

Private Member Functions

 __construct (ilECSSetting $setting=null)
 Singleton constructor. More...
 
 read ()
 Read @access private. More...
 

Static Private Attributes

static $instances = null
 

Detailed Description

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

@ilCtrl_Calls

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

Constructor & Destructor Documentation

◆ __construct()

ilECSCommunityReader::__construct ( ilECSSetting  $setting = null)
private

Singleton constructor.

@access private

Exceptions
ilECSConnectorException

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

57 {
58 global $ilLog;
59
60 include_once('Services/WebServices/ECS/classes/class.ilECSSetting.php');
61 include_once('Services/WebServices/ECS/classes/class.ilECSConnector.php');
62 include_once('Services/WebServices/ECS/classes/class.ilECSConnectorException.php');
63 include_once('Services/WebServices/ECS/classes/class.ilECSCommunity.php');
64
65 if ($setting) {
66 $this->settings = $setting;
67 } else {
68 $GLOBALS['ilLog']->write(__METHOD__ . ': Using deprecated call');
69 $GLOBALS['ilLog']->logStack();
70 }
71 $this->connector = new ilECSConnector($this->settings);
72 $this->log = $ilLog;
73
74 $this->read();
75 }
$GLOBALS['loaded']
Global hash that tracks already loaded includes.
settings()
Definition: settings.php:2

References $GLOBALS, $ilLog, read(), and settings().

+ Here is the call graph for this function:

Member Function Documentation

◆ _getInstance()

static ilECSCommunityReader::_getInstance ( )
static

get singleton instance

@access public

Returns
ilECSCommunityReader

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

85 {
86 $GLOBALS['ilLog']->write(__METHOD__ . ': Using deprecated call');
88 }
static getInstanceByServerId($a_server_id)
Get instance by server id.

References $GLOBALS, and getInstanceByServerId().

Referenced by ilECSSettingsGUI\exportImported().

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

◆ getCommunities()

ilECSCommunityReader::getCommunities ( )

get communities

@access public

Returns
\ilECSCommunity[]

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

140 {
141 return $this->communities ? $this->communities : array();
142 }

Referenced by getEnabledParticipants(), getParticipantsByPid(), and getPublishableParticipants().

+ 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 151 of file class.ilECSCommunityReader.php.

152 {
153 foreach ($this->communities as $community) {
154 if ($community->getId() == $a_id) {
155 return $community;
156 }
157 }
158 return null;
159 }

◆ getCommunityByMID()

ilECSCommunityReader::getCommunityByMID (   $a_mid)

Get community by mid.

Parameters
int$a_mid
Returns
ilECSCommunity

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

195 {
196 foreach ($this->communities as $community) {
197 foreach ($community->getParticipants() as $part) {
198 if ($part->getMID() == $a_mid) {
199 return $community;
200 }
201 }
202 }
203 return null;
204 }

◆ getEnabledParticipants()

ilECSCommunityReader::getEnabledParticipants ( )

get enabled participants

@access public

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

231 {
232 include_once './Services/WebServices/ECS/classes/class.ilECSParticipantSettings.php';
233 $ps = ilECSParticipantSettings::getInstanceByServerId($this->getServer()->getServerId());
234 $en = $ps->getEnabledParticipants();
235 foreach ($this->getCommunities() as $community) {
236 foreach ($community->getParticipants() as $participant) {
237 if (in_array($participant->getMid(), $en)) {
238 $e_part[] = $participant;
239 }
240 }
241 }
242 return $e_part ? $e_part : array();
243 }
static getInstanceByServerId($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 (   $a_server_id)
static

Get instance by server id.

Parameters
int$a_server_id
Returns
ilECSCommunityReader

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

96 {
97 if (isset(self::$instances[$a_server_id])) {
98 return self::$instances[$a_server_id];
99 }
100 return self::$instances[$a_server_id] = new ilECSCommunityReader(ilECSSetting::getInstanceByServerId($a_server_id));
101 }
static getInstanceByServerId($a_server_id)
Get singleton instance per server.

References ilECSSetting\getInstanceByServerId().

Referenced by _getInstance(), ilECSSettingsGUI\communities(), ilECSUtils\lookupParticipantName(), ilECSImportedContentTableGUI\parse(), ilECSTaskScheduler\readMIDs(), ilECSSettingsGUI\refreshParticipants(), ilECSObjectSettings\sendNewContentNotification(), ilECSSettingsGUI\updateCommunities(), ilECSSettingsGUI\updateTitle(), ilAuthContainerECS\validateHash(), and ilAuthProviderECS\validateHash().

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

◆ getOwnMIDs()

ilECSCommunityReader::getOwnMIDs ( )

get publishable ids

@access public

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

129 {
130 return $this->own_ids ? $this->own_ids : array();
131 }

◆ getParticipantByMID()

ilECSCommunityReader::getParticipantByMID (   $a_mid)

get participant by id

@access public

Parameters
intmid

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

185 {
186 return isset($this->participants[$a_mid]) ? $this->participants[$a_mid] : false;
187 }

◆ getParticipants()

ilECSCommunityReader::getParticipants ( )

Get participants.

Returns
ilECSParticipant[]

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

References $participants.

◆ getParticipantsByPid()

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

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

166 {
167 $participants = [];
168 foreach ($this->getCommunities() as $community) {
169 foreach ($community->getParticipants() as $participant) {
170 if ($participant->getPid() == $a_pid) {
171 $participants[] = $participant;
172 }
173 }
174 }
175 return $participants;
176 }

References $participants, and getCommunities().

+ Here is the call graph for this function:

◆ getPublishableParticipants()

ilECSCommunityReader::getPublishableParticipants ( )

get publishable communities

@access public

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

213 {
214 foreach ($this->getCommunities() as $community) {
215 foreach ($community->getParticipants() as $participant) {
216 if ($participant->isPublishable()) {
217 $p_part[] = $participant;
218 }
219 }
220 }
221 return $p_part ? $p_part : array();
222 }

References getCommunities().

+ Here is the call graph for this function:

◆ getServer()

ilECSCommunityReader::getServer ( )

Get server setting.

Returns
ilECSSetting

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

References $settings.

Referenced by getEnabledParticipants().

+ Here is the caller graph for this function:

◆ read()

ilECSCommunityReader::read ( )
private

Read @access private.

Exceptions
ilECSConnectorException

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

252 {
253 global $ilLog;
254
255 try {
256 $res = $this->connector->getMemberships();
257 if (!is_array($res->getResult())) {
258 return false;
259 }
260 foreach ($res->getResult() as $community) {
261 $tmp_comm = new ilECSCommunity($community);
262 foreach ($tmp_comm->getParticipants() as $participant) {
263 $this->participants[$participant->getMID()] = $participant;
264 if ($participant->isSelf()) {
265 $this->own_ids[] = $participant->getMID();
266 }
267 }
268 $this->communities[] = $tmp_comm;
269 }
270 } catch (ilECSConnectorException $e) {
271 $ilLog->write(__METHOD__ . ': Error connecting to ECS server. ' . $e->getMessage());
272 throw $e;
273 }
274 }
foreach($_POST as $key=> $value) $res

References $ilLog, and $res.

Referenced by __construct().

+ Here is the caller graph for this function:

Field Documentation

◆ $communities

ilECSCommunityReader::$communities = array()
protected

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

◆ $connector

ilECSCommunityReader::$connector = null
protected

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

◆ $instances

ilECSCommunityReader::$instances = null
staticprivate

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

◆ $log

ilECSCommunityReader::$log
protected

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

◆ $own_ids

ilECSCommunityReader::$own_ids = array()
protected

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

◆ $participants

ilECSCommunityReader::$participants = array()
protected

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

Referenced by getParticipants(), and getParticipantsByPid().

◆ $position

ilECSCommunityReader::$position = 0
protected

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

◆ $settings

ilECSCommunityReader::$settings = null
protected

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

Referenced by getServer().


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