ILIAS  release_5-3 Revision v5.3.23-19-g915713cf615
class.ilECSCommunitiesCache.php
Go to the documentation of this file.
1 <?php
24 include_once './Services/WebServices/ECS/classes/class.ilECSCommunityCache.php';
25 
35 {
36  private static $instance = null;
37 
38  private $communities = array();
39 
43  protected function __construct()
44  {
45  $this->read();
46  }
47 
52  public static function getInstance()
53  {
54  if (isset(self::$instance)) {
55  return self::$instance;
56  }
57  return self::$instance = new ilECSCommunitiesCache();
58  }
59 
64  public static function delete($a_server_id)
65  {
66  global $ilDB;
67 
68  $query = 'DELETE FROM ecs_community ' .
69  'WHERE sid = ' . $ilDB->quote($a_server_id, 'integer');
70  $ilDB->manipulate($query);
71  }
72 
77  public function getCommunities()
78  {
79  return (array) $this->communities;
80  }
81 
85  public function lookupOwnId($a_server_id, $a_mid)
86  {
87  foreach ($this->getCommunities() as $com) {
88  if ($com->getServerId() == $a_server_id) {
89  if (in_array($a_mid, $com->getMids())) {
90  return $com->getOwnId();
91  }
92  }
93  }
94  return 0;
95  }
96 
102  public function lookupTitle($a_server_id, $a_mid)
103  {
104  foreach ($this->getCommunities() as $com) {
105  if ($com->getServerId() == $a_server_id) {
106  if (in_array($a_mid, $com->getMids())) {
107  return $com->getCommunityName();
108  }
109  }
110  }
111  return '';
112  }
113 
117  private function read()
118  {
119  global $ilDB;
120 
121  $query = 'SELECT sid,cid FROM ecs_community ';
122  $res = $ilDB->query($query);
123  while ($row = $res->fetchRow(ilDBConstants::FETCHMODE_OBJECT)) {
124  $this->communities[] = ilECSCommunityCache::getInstance($row->sid, $row->cid);
125  }
126  return true;
127  }
128 }
lookupTitle($a_server_id, $a_mid)
Lookup community title.
__construct()
Singleton constructor.
foreach($_POST as $key=> $value) $res
$query
static getInstance()
Singleton instance.
Create styles array
The data for the language used.
lookupOwnId($a_server_id, $a_mid)
Lookup own mid of the community of a mid.
global $ilDB
static getInstance($a_sid, $a_cid)
Get instance.
+-----------------------------------------------------------------------——+ | ILIAS open source | +...