ILIAS  release_8 Revision v8.19
All Data Structures Namespaces Files Functions Variables Modules Pages
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.

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

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
+ 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.

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

Referenced by update().

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
+ 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.

References $query.

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  }
$query

◆ getCommunityId()

ilECSCommunityCache::getCommunityId ( )

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

References $community_id.

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

77  : int
78  {
79  return $this->community_id;
80  }
+ Here is the caller graph for this function:

◆ getCommunityName()

ilECSCommunityCache::getCommunityName ( )

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

References $cname.

Referenced by create(), and update().

97  : string
98  {
99  return $this->cname;
100  }
+ 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.

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

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  }
+ Here is the caller graph for this function:

◆ getMids()

ilECSCommunityCache::getMids ( )

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

References $mids.

Referenced by create(), and update().

107  : array
108  {
109  return $this->mids;
110  }
+ Here is the caller graph for this function:

◆ getOwnId()

ilECSCommunityCache::getOwnId ( )

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

References $own_id.

Referenced by create(), and update().

87  : int
88  {
89  return $this->own_id;
90  }
+ Here is the caller graph for this function:

◆ getServerId()

ilECSCommunityCache::getServerId ( )

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

References $server_id.

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

72  : int
73  {
74  return $this->server_id;
75  }
+ Here is the caller graph for this function:

◆ read()

ilECSCommunityCache::read ( )
private

Read dataset.

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

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

Referenced by __construct().

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
$query
+ 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.

Referenced by read().

92  : void
93  {
94  $this->cname = $a_name;
95  }
+ Here is the caller graph for this function:

◆ setMids()

ilECSCommunityCache::setMids ( array  $a_mids)

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

Referenced by read().

102  : void
103  {
104  $this->mids = $a_mids;
105  }
+ Here is the caller graph for this function:

◆ setOwnId()

ilECSCommunityCache::setOwnId ( int  $a_id)

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

Referenced by read().

82  : void
83  {
84  $this->own_id = $a_id;
85  }
+ 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.

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

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  }
create()
Create new dataset.
$query
+ 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: