ILIAS  trunk Revision v11.0_alpha-3011-gc6b235a2e85
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 24 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 44 of file class.ilECSCommunityCache.php.

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

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 137 of file class.ilECSCommunityCache.php.

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

References 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 176 of file class.ilECSCommunityCache.php.

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

◆ getCommunityId()

ilECSCommunityCache::getCommunityId ( )

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

78 : int
79 {
81 }

References $community_id.

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

+ Here is the caller graph for this function:

◆ getCommunityName()

ilECSCommunityCache::getCommunityName ( )

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

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

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 62 of file class.ilECSCommunityCache.php.

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

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

+ Here is the caller graph for this function:

◆ getMids()

ilECSCommunityCache::getMids ( )

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

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

References $mids.

Referenced by create(), and update().

+ Here is the caller graph for this function:

◆ getOwnId()

ilECSCommunityCache::getOwnId ( )

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

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

References $own_id.

Referenced by create(), and update().

+ Here is the caller graph for this function:

◆ getServerId()

ilECSCommunityCache::getServerId ( )

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

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

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 154 of file class.ilECSCommunityCache.php.

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

References $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 93 of file class.ilECSCommunityCache.php.

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

Referenced by read().

+ Here is the caller graph for this function:

◆ setMids()

ilECSCommunityCache::setMids ( array  $a_mids)

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

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

Referenced by read().

+ Here is the caller graph for this function:

◆ setOwnId()

ilECSCommunityCache::setOwnId ( int  $a_id)

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

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

Referenced by read().

+ Here is the caller graph for this function:

◆ update()

ilECSCommunityCache::update ( )

Create or update ecs community.

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

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

References 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 32 of file class.ilECSCommunityCache.php.

Referenced by getCommunityName().

◆ $community_id

int ilECSCommunityCache::$community_id = 0
protected

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

Referenced by __construct(), and getCommunityId().

◆ $db

ilDBInterface ilECSCommunityCache::$db
private

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

◆ $entryExists

bool ilECSCommunityCache::$entryExists = false
protected

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

◆ $instance

array ilECSCommunityCache::$instance = []
staticprotected

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

◆ $mids

array ilECSCommunityCache::$mids = array()
protected

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

Referenced by getMids().

◆ $own_id

int ilECSCommunityCache::$own_id = 0
protected

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

Referenced by getOwnId().

◆ $server_id

int ilECSCommunityCache::$server_id = 0
protected

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

Referenced by __construct(), and getServerId().


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