ILIAS  release_7 Revision v7.30-3-g800a261c036
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 $DIC;
59
60 $ilLog = $DIC['ilLog'];
61
62 include_once('Services/WebServices/ECS/classes/class.ilECSSetting.php');
63 include_once('Services/WebServices/ECS/classes/class.ilECSConnector.php');
64 include_once('Services/WebServices/ECS/classes/class.ilECSConnectorException.php');
65 include_once('Services/WebServices/ECS/classes/class.ilECSCommunity.php');
66
67 if ($setting) {
68 $this->settings = $setting;
69 } else {
70 $GLOBALS['DIC']['ilLog']->write(__METHOD__ . ': Using deprecated call');
71 $GLOBALS['DIC']['ilLog']->logStack();
72 }
73 $this->connector = new ilECSConnector($this->settings);
74 $this->log = $ilLog;
75
76 $this->read();
77 }
if(!defined('PATH_SEPARATOR')) $GLOBALS['_PEAR_default_error_mode']
Definition: PEAR.php:64
global $DIC
Definition: goto.php:24
settings()
Definition: settings.php:2

References $DIC, $GLOBALS, 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 86 of file class.ilECSCommunityReader.php.

87 {
88 $GLOBALS['DIC']['ilLog']->write(__METHOD__ . ': Using deprecated call');
90 }
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 141 of file class.ilECSCommunityReader.php.

142 {
143 return $this->communities ? $this->communities : array();
144 }

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

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

◆ getCommunityByMID()

ilECSCommunityReader::getCommunityByMID (   $a_mid)

Get community by mid.

Parameters
int$a_mid
Returns
ilECSCommunity

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

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

◆ getEnabledParticipants()

ilECSCommunityReader::getEnabledParticipants ( )

get enabled participants

@access public

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

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

98 {
99 if (isset(self::$instances[$a_server_id])) {
100 return self::$instances[$a_server_id];
101 }
102 return self::$instances[$a_server_id] = new ilECSCommunityReader(ilECSSetting::getInstanceByServerId($a_server_id));
103 }
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(), 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 130 of file class.ilECSCommunityReader.php.

131 {
132 return $this->own_ids ? $this->own_ids : array();
133 }

◆ getParticipantByMID()

ilECSCommunityReader::getParticipantByMID (   $a_mid)

get participant by id

@access public

Parameters
intmid

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

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

◆ getParticipants()

ilECSCommunityReader::getParticipants ( )

Get participants.

Returns
ilECSParticipant[]

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

References $participants.

◆ getParticipantsByPid()

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

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

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

References $participants, and getCommunities().

+ Here is the call graph for this function:

◆ getPublishableParticipants()

ilECSCommunityReader::getPublishableParticipants ( )

get publishable communities

@access public

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

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

References getCommunities().

+ Here is the call graph for this function:

◆ getServer()

ilECSCommunityReader::getServer ( )

Get server setting.

Returns
ilECSSetting

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

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

References $DIC, Vendor\Package\$e, 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: