ILIAS  release_5-4 Revision v5.4.26-12-gabc799a52e6
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 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$

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

Constructor & Destructor Documentation

◆ __construct()

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

Singleton constructor.

private

Exceptions
ilECSConnectorException

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

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

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  }
settings()
Definition: settings.php:2
global $DIC
Definition: saml.php:7
$GLOBALS['JPEG_Segment_Names']
Global Variable: XMP_tag_captions.
+ Here is the call graph for this function:

Member Function Documentation

◆ _getInstance()

static ilECSCommunityReader::_getInstance ( )
static

get singleton instance

public

Returns
ilECSCommunityReader

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

References $GLOBALS.

Referenced by ilECSSettingsGUI\exportImported().

87  {
88  $GLOBALS['DIC']['ilLog']->write(__METHOD__ . ': Using deprecated call');
89  return self::getInstanceByServerId(15);
90  }
$GLOBALS['JPEG_Segment_Names']
Global Variable: XMP_tag_captions.
+ Here is the caller graph for this function:

◆ getCommunities()

ilECSCommunityReader::getCommunities ( )

get communities

public

Returns
[]

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

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

142  {
143  return $this->communities ? $this->communities : array();
144  }
+ Here is the caller graph for this function:

◆ getCommunityById()

ilECSCommunityReader::getCommunityById (   $a_id)

get community by id

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

public

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

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

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  }
getServer()
Get server setting.
static getInstanceByServerId($a_server_id)
Get instance by server id.
+ 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.

References ilECSSetting\getInstanceByServerId().

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

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.
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ getOwnMIDs()

ilECSCommunityReader::getOwnMIDs ( )

get publishable ids

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

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
[]

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

References $participants, and getCommunities().

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  }
+ Here is the call graph for this function:

◆ getPublishableParticipants()

ilECSCommunityReader::getPublishableParticipants ( )

get publishable communities

public

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

References getCommunities().

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  }
+ 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().

110  {
111  return $this->settings;
112  }
+ Here is the caller graph for this function:

◆ read()

ilECSCommunityReader::read ( )
private

Read private.

Exceptions
ilECSConnectorException

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

References $DIC, $ilLog, and $res.

Referenced by __construct().

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  }
global $DIC
Definition: saml.php:7
foreach($_POST as $key=> $value) $res
+ 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: