ILIAS  release_5-0 Revision 5.0.0-1144-gc4397b1f87
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...
 
 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 $GLOBALS, $ilLog, and read().

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  {
67  $this->settings = $setting;
68  }
69  else
70  {
71  $GLOBALS['ilLog']->write(__METHOD__.': Using deprecated call');
72  $GLOBALS['ilLog']->logStack();
73  }
74  $this->connector = new ilECSConnector($this->settings);
75  $this->log = $ilLog;
76 
77  $this->read();
78  }
$GLOBALS['ct_recipient']
+ 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 87 of file class.ilECSCommunityReader.php.

References $GLOBALS.

Referenced by ilECSSettingsGUI\exportImported().

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

◆ getCommunities()

ilECSCommunityReader::getCommunities ( )

get communities

public

Parameters

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

Referenced by getEnabledParticipants(), and getPublishableParticipants().

145  {
146  return $this->communities ? $this->communities : array();
147  }
+ Here is the caller graph for this function:

◆ getCommunityById()

ilECSCommunityReader::getCommunityById (   $a_id)

get community by id

public

Parameters
intcomm_id

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

157  {
158  foreach($this->communities as $community)
159  {
160  if($community->getId() == $a_id)
161  {
162  return $community;
163  }
164  }
165  return null;
166  }

◆ getCommunityByMID()

ilECSCommunityReader::getCommunityByMID (   $a_mid)

Get community by mid.

Parameters
int$a_mid
Returns
ilECSCommunity

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

185  {
186  foreach($this->communities as $community)
187  {
188  foreach($community->getParticipants() as $part)
189  {
190  if($part->getMID() == $a_mid)
191  {
192  return $community;
193  }
194  }
195  }
196  return null;
197  }

◆ getEnabledParticipants()

ilECSCommunityReader::getEnabledParticipants ( )

get enabled participants

public

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

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

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

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

133  {
134  return $this->own_ids ? $this->own_ids : array();
135  }

◆ getParticipantByMID()

ilECSCommunityReader::getParticipantByMID (   $a_mid)

get participant by id

public

Parameters
intmid

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

175  {
176  return isset($this->participants[$a_mid]) ? $this->participants[$a_mid] : false;
177  }

◆ getParticipants()

ilECSCommunityReader::getParticipants ( )

Get participants.

Returns
ilECSParticipant[]

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

References $participants.

◆ getPublishableParticipants()

ilECSCommunityReader::getPublishableParticipants ( )

get publishable communities

public

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

References getCommunities().

206  {
207  foreach($this->getCommunities() as $community)
208  {
209  foreach($community->getParticipants() as $participant)
210  {
211  if($participant->isPublishable())
212  {
213  $p_part[] = $participant;
214  }
215  }
216  }
217  return $p_part ? $p_part : array();
218  }
+ Here is the call graph for this function:

◆ getServer()

ilECSCommunityReader::getServer ( )

Get server setting.

Returns
ilECSSetting

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

References $settings.

Referenced by getEnabledParticipants().

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

◆ read()

ilECSCommunityReader::read ( )
private

Read private.

Exceptions
ilECSConnectorException

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

References $ilLog, and $res.

Referenced by __construct().

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

◆ $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: