ILIAS  release_8 Revision v8.24
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 23 of file class.ilECSCommunitiesCache.php.

Constructor & Destructor Documentation

◆ __construct()

ilECSCommunitiesCache::__construct ( )
protected

Singleton constructor.

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

35 {
36 global $DIC;
37
38 $this->db = $DIC->database();
39
40 $this->read();
41 }
global $DIC
Definition: feed.php:28

References $DIC, and read().

+ 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 55 of file class.ilECSCommunitiesCache.php.

55 : void
56 {
57 $query = 'DELETE FROM ecs_community ' .
58 'WHERE sid = ' . $this->db->quote($a_server_id, 'integer');
59 $this->db->manipulate($query);
60 $this->read();
61 }
$query

References $query, and read().

+ Here is the call graph for this function:

◆ getCommunities()

ilECSCommunitiesCache::getCommunities ( )

Get communities.

Returns
ilECSCommunityCache[]

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

67 : array
68 {
69 return $this->communities;
70 }

References $communities.

Referenced by lookupOwnId(), and lookupTitle().

+ Here is the caller graph for this function:

◆ getInstance()

static ilECSCommunitiesCache::getInstance ( )
static

Singleton instance.

Returns
ilECSCommunitiesCache

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

48 {
49 return self::$instance ?? (self::$instance = new ilECSCommunitiesCache());
50 }

Referenced by ilECSUtils\getMatchableContent().

+ 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 75 of file class.ilECSCommunitiesCache.php.

75 : int
76 {
77 foreach ($this->getCommunities() as $com) {
78 if (($com->getServerId() === $a_server_id) && in_array($a_mid, $com->getMids(), true)) {
79 return $com->getOwnId();
80 }
81 }
82 return 0;
83 }

References getCommunities().

+ 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 90 of file class.ilECSCommunitiesCache.php.

90 : string
91 {
92 foreach ($this->getCommunities() as $com) {
93 if (($com->getServerId() === $a_server_id) && in_array($a_mid, $com->getMids(), true)) {
94 return $com->getCommunityName();
95 }
96 }
97 return '';
98 }

References getCommunities().

+ Here is the call graph for this function:

◆ read()

ilECSCommunitiesCache::read ( )
private

Read comunities.

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

103 : void
104 {
105 $query = 'SELECT sid,cid FROM ecs_community ';
106 $res = $this->db->query($query);
107 while ($row = $res->fetchRow(ilDBConstants::FETCHMODE_OBJECT)) {
108 $this->communities[] = ilECSCommunityCache::getInstance((int) $row->sid, (int) $row->cid);
109 }
110 }
static getInstance(int $a_server_id, int $a_community_id)
Get instance.
$res
Definition: ltiservices.php:69

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

Referenced by __construct(), and delete().

+ 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 29 of file class.ilECSCommunitiesCache.php.

Referenced by getCommunities().

◆ $db

ilDBInterface ilECSCommunitiesCache::$db
private

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

◆ $instance

ilECSCommunitiesCache ilECSCommunitiesCache::$instance = null
staticprivate

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


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