ILIAS  release_8 Revision v8.24
ilECSCommunityCache Class Reference
+ Collaboration diagram for ilECSCommunityCache:

Public Member Functions

 getServerId ()
 
 getCommunityId ()
 
 setOwnId (int $a_id)
 
 getOwnId ()
 
 setCommunityName (string $a_name)
 
 getCommunityName ()
 
 setMids (array $a_mids)
 
 getMids ()
 
 update ()
 Create or update ecs community. More...
 
 deleteByServerId (int $a_server_id)
 

Static Public Member Functions

static getInstance (int $a_server_id, int $a_community_id)
 Get instance. More...
 

Protected Member Functions

 __construct (int $server_id, int $community_id)
 Singleton constructor. More...
 
 create ()
 Create new dataset. More...
 

Protected Attributes

int $server_id = 0
 
int $community_id = 0
 
int $own_id = 0
 
string $cname = ''
 
array $mids = array()
 
bool $entryExists = false
 

Static Protected Attributes

static array $instance = []
 

Private Member Functions

 read ()
 Read dataset. More...
 

Private Attributes

ilDBInterface $db
 

Detailed Description

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

Definition at line 23 of file class.ilECSCommunityCache.php.

Constructor & Destructor Documentation

◆ __construct()

ilECSCommunityCache::__construct ( int  $server_id,
int  $community_id 
)
protected

Singleton constructor.

Parameters
int$server_id
int$community_id

Definition at line 43 of file class.ilECSCommunityCache.php.

44 {
45 global $DIC;
46
47 $this->db = $DIC->database();
48
49 $this->server_id = $server_id;
50 $this->community_id = $community_id;
51
52 $this->read();
53 }
global $DIC
Definition: feed.php:28

References $community_id, $DIC, $server_id, and read().

+ Here is the call graph for this function:

Member Function Documentation

◆ create()

ilECSCommunityCache::create ( )
protected

Create new dataset.

Definition at line 136 of file class.ilECSCommunityCache.php.

136 : bool
137 {
138 $query = 'INSERT INTO ecs_community (sid,cid,own_id,cname,mids) ' .
139 'VALUES( ' .
140 $this->db->quote($this->getServerId(), 'integer') . ', ' .
141 $this->db->quote($this->getCommunityId(), 'integer') . ', ' .
142 $this->db->quote($this->getOwnId(), 'integer') . ', ' .
143 $this->db->quote($this->getCommunityName(), 'text') . ', ' .
144 $this->db->quote(serialize($this->getMids()), 'text') . ' ' .
145 ')';
146 $this->db->manipulate($query);
147 return true;
148 }
$query

References $query, getCommunityId(), getCommunityName(), getMids(), getOwnId(), and getServerId().

Referenced by update().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ deleteByServerId()

ilECSCommunityCache::deleteByServerId ( int  $a_server_id)
Todo:
move function into CommunityCacheRepository
Parameters
int$a_server_id
Returns
bool

Definition at line 175 of file class.ilECSCommunityCache.php.

175 : bool
176 {
177 $query = 'DELETE FROM ecs_community' .
178 ' WHERE sid = ' . $this->db->quote($a_server_id, 'integer');
179 $this->db->manipulate($query);
180 return true;
181 }

References $query.

◆ getCommunityId()

ilECSCommunityCache::getCommunityId ( )

Definition at line 77 of file class.ilECSCommunityCache.php.

77 : int
78 {
80 }

References $community_id.

Referenced by create(), read(), and update().

+ Here is the caller graph for this function:

◆ getCommunityName()

ilECSCommunityCache::getCommunityName ( )

Definition at line 97 of file class.ilECSCommunityCache.php.

97 : string
98 {
99 return $this->cname;
100 }

References $cname.

Referenced by create(), and update().

+ Here is the caller graph for this function:

◆ getInstance()

static ilECSCommunityCache::getInstance ( int  $a_server_id,
int  $a_community_id 
)
static

Get instance.

Parameters
int$a_server_id
int$a_community_id
Returns
ilECSCommunityCache

Definition at line 61 of file class.ilECSCommunityCache.php.

62 {
63 return self::$instance[$a_server_id][$a_community_id] ??
64 (self::$instance[$a_server_id][$a_community_id] = new ilECSCommunityCache(
65 $a_server_id,
66 $a_community_id
67 ));
68 }

Referenced by ilECSSetting\delete(), ilECSCommunitiesCache\read(), and ilECSSettingsGUI\updateCommunities().

+ Here is the caller graph for this function:

◆ getMids()

ilECSCommunityCache::getMids ( )

Definition at line 107 of file class.ilECSCommunityCache.php.

107 : array
108 {
109 return $this->mids;
110 }

References $mids.

Referenced by create(), and update().

+ Here is the caller graph for this function:

◆ getOwnId()

ilECSCommunityCache::getOwnId ( )

Definition at line 87 of file class.ilECSCommunityCache.php.

87 : int
88 {
89 return $this->own_id;
90 }

References $own_id.

Referenced by create(), and update().

+ Here is the caller graph for this function:

◆ getServerId()

ilECSCommunityCache::getServerId ( )

Definition at line 72 of file class.ilECSCommunityCache.php.

72 : int
73 {
74 return $this->server_id;
75 }

References $server_id.

Referenced by create(), read(), and update().

+ Here is the caller graph for this function:

◆ read()

ilECSCommunityCache::read ( )
private

Read dataset.

Definition at line 153 of file class.ilECSCommunityCache.php.

153 : void
154 {
155 $this->entryExists = false;
156
157 $query = 'SELECT * FROM ecs_community ' .
158 'WHERE sid = ' . $this->db->quote($this->getServerId(), 'integer') . ' ' .
159 'AND cid = ' . $this->db->quote($this->getCommunityId(), 'integer');
160 $res = $this->db->query($query);
161 while ($row = $res->fetchRow(ilDBConstants::FETCHMODE_OBJECT)) {
162 $this->entryExists = true;
163 $this->setOwnId((int) $row->own_id);
164 $this->setCommunityName($row->cname);
165 $this->setMids(unserialize($row->mids, ['allowed_classes' => true]));
166 }
167 }
$res
Definition: ltiservices.php:69

References $query, $res, ilDBConstants\FETCHMODE_OBJECT, getCommunityId(), getServerId(), setCommunityName(), setMids(), and setOwnId().

Referenced by __construct().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ setCommunityName()

ilECSCommunityCache::setCommunityName ( string  $a_name)

Definition at line 92 of file class.ilECSCommunityCache.php.

92 : void
93 {
94 $this->cname = $a_name;
95 }

Referenced by read().

+ Here is the caller graph for this function:

◆ setMids()

ilECSCommunityCache::setMids ( array  $a_mids)

Definition at line 102 of file class.ilECSCommunityCache.php.

102 : void
103 {
104 $this->mids = $a_mids;
105 }

Referenced by read().

+ Here is the caller graph for this function:

◆ setOwnId()

ilECSCommunityCache::setOwnId ( int  $a_id)

Definition at line 82 of file class.ilECSCommunityCache.php.

82 : void
83 {
84 $this->own_id = $a_id;
85 }

Referenced by read().

+ Here is the caller graph for this function:

◆ update()

ilECSCommunityCache::update ( )

Create or update ecs community.

Definition at line 115 of file class.ilECSCommunityCache.php.

115 : bool
116 {
117 if (!$this->entryExists) {
118 return $this->create();
119 }
120
121 $query = 'UPDATE ecs_community ' .
122 'SET own_id = ' . $this->db->quote($this->getOwnId(), 'integer') . ', ' .
123 'cname = ' . $this->db->quote($this->getCommunityName(), 'text') . ', ' .
124 'mids = ' . $this->db->quote(serialize($this->getMids()), 'text') . ' ' .
125 'WHERE sid = ' . $this->db->quote($this->getServerId(), 'integer') . ' ' .
126 'AND cid = ' . $this->db->quote($this->getCommunityId(), 'integer');
127 $this->db->manipulate($query);
128 return true;
129 }

References $query, create(), getCommunityId(), getCommunityName(), getMids(), getOwnId(), and getServerId().

+ Here is the call graph for this function:

Field Documentation

◆ $cname

string ilECSCommunityCache::$cname = ''
protected

Definition at line 31 of file class.ilECSCommunityCache.php.

Referenced by getCommunityName().

◆ $community_id

int ilECSCommunityCache::$community_id = 0
protected

Definition at line 29 of file class.ilECSCommunityCache.php.

Referenced by __construct(), and getCommunityId().

◆ $db

ilDBInterface ilECSCommunityCache::$db
private

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

◆ $entryExists

bool ilECSCommunityCache::$entryExists = false
protected

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

◆ $instance

array ilECSCommunityCache::$instance = []
staticprotected

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

◆ $mids

array ilECSCommunityCache::$mids = array()
protected

Definition at line 32 of file class.ilECSCommunityCache.php.

Referenced by getMids().

◆ $own_id

int ilECSCommunityCache::$own_id = 0
protected

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

Referenced by getOwnId().

◆ $server_id

int ilECSCommunityCache::$server_id = 0
protected

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

Referenced by __construct(), and getServerId().


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