ILIAS  trunk Revision v11.0_alpha-2638-g80c1d007f79
ilECSCommunitiesCache Class Reference
+ Collaboration diagram for ilECSCommunitiesCache:

Public Member Functions

 delete (int $a_server_id)
 Delete comunities by server id. More...
 
 getCommunities ()
 Get communities. More...
 
 lookupOwnId (int $a_server_id, int $a_mid)
 Lookup own mid of the community of a mid. More...
 
 lookupTitle (int $a_server_id, int $a_mid)
 Lookup community title. More...
 

Static Public Member Functions

static getInstance ()
 Singleton instance. More...
 

Protected Member Functions

 __construct ()
 Singleton constructor. More...
 

Private Member Functions

 read ()
 Read comunities. More...
 

Private Attributes

ilDBInterface $db
 
array $communities = array()
 

Static Private Attributes

static ilECSCommunitiesCache $instance = null
 

Detailed Description

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

Definition at line 24 of file class.ilECSCommunitiesCache.php.

Constructor & Destructor Documentation

◆ __construct()

ilECSCommunitiesCache::__construct ( )
protected

Singleton constructor.

Definition at line 35 of file class.ilECSCommunitiesCache.php.

References $DIC, and read().

36  {
37  global $DIC;
38 
39  $this->db = $DIC->database();
40 
41  $this->read();
42  }
global $DIC
Definition: shib_login.php:26
+ Here is the call graph for this function:

Member Function Documentation

◆ delete()

ilECSCommunitiesCache::delete ( int  $a_server_id)

Delete comunities by server id.

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

References read().

56  : void
57  {
58  $query = 'DELETE FROM ecs_community ' .
59  'WHERE sid = ' . $this->db->quote($a_server_id, 'integer');
60  $this->db->manipulate($query);
61  $this->read();
62  }
+ Here is the call graph for this function:

◆ getCommunities()

ilECSCommunitiesCache::getCommunities ( )

Get communities.

Returns
ilECSCommunityCache[]

Definition at line 68 of file class.ilECSCommunitiesCache.php.

References $communities.

Referenced by lookupOwnId(), and lookupTitle().

68  : array
69  {
70  return $this->communities;
71  }
+ Here is the caller graph for this function:

◆ getInstance()

static ilECSCommunitiesCache::getInstance ( )
static

Singleton instance.

Returns
ilECSCommunitiesCache

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

Referenced by ilECSUtils\getMatchableContent().

49  {
50  return self::$instance ?? (self::$instance = new ilECSCommunitiesCache());
51  }
+ Here is the caller graph for this function:

◆ lookupOwnId()

ilECSCommunitiesCache::lookupOwnId ( int  $a_server_id,
int  $a_mid 
)

Lookup own mid of the community of a mid.

Definition at line 76 of file class.ilECSCommunitiesCache.php.

References getCommunities().

76  : int
77  {
78  foreach ($this->getCommunities() as $com) {
79  if (($com->getServerId() === $a_server_id) && in_array($a_mid, $com->getMids(), true)) {
80  return $com->getOwnId();
81  }
82  }
83  return 0;
84  }
+ Here is the call graph for this function:

◆ lookupTitle()

ilECSCommunitiesCache::lookupTitle ( int  $a_server_id,
int  $a_mid 
)

Lookup community title.

Parameters
intserver_id
intmid

Definition at line 91 of file class.ilECSCommunitiesCache.php.

References getCommunities().

91  : string
92  {
93  foreach ($this->getCommunities() as $com) {
94  if (($com->getServerId() === $a_server_id) && in_array($a_mid, $com->getMids(), true)) {
95  return $com->getCommunityName();
96  }
97  }
98  return '';
99  }
+ Here is the call graph for this function:

◆ read()

ilECSCommunitiesCache::read ( )
private

Read comunities.

Definition at line 104 of file class.ilECSCommunitiesCache.php.

References $res, ilDBConstants\FETCHMODE_OBJECT, and ilECSCommunityCache\getInstance().

Referenced by __construct(), and delete().

104  : void
105  {
106  $query = 'SELECT sid,cid FROM ecs_community ';
107  $res = $this->db->query($query);
108  while ($row = $res->fetchRow(ilDBConstants::FETCHMODE_OBJECT)) {
109  $this->communities[] = ilECSCommunityCache::getInstance((int) $row->sid, (int) $row->cid);
110  }
111  }
$res
Definition: ltiservices.php:66
static getInstance(int $a_server_id, int $a_community_id)
Get instance.
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

Field Documentation

◆ $communities

array ilECSCommunitiesCache::$communities = array()
private

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

Referenced by getCommunities().

◆ $db

ilDBInterface ilECSCommunitiesCache::$db
private

Definition at line 28 of file class.ilECSCommunitiesCache.php.

◆ $instance

ilECSCommunitiesCache ilECSCommunitiesCache::$instance = null
staticprivate

Definition at line 26 of file class.ilECSCommunitiesCache.php.


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