ILIAS  release_5-3 Revision v5.3.23-19-g915713cf615
class.ilECSCommunitiesCache.php
Go to the documentation of this file.
1<?php
24include_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}
An exception for terminatinating execution or to throw for unit testing.
+--------------------------------------------------------------------------—+ | ILIAS open source | +...
static getInstance()
Singleton instance.
__construct()
Singleton constructor.
lookupOwnId($a_server_id, $a_mid)
Lookup own mid of the community of a mid.
lookupTitle($a_server_id, $a_mid)
Lookup community title.
static getInstance($a_sid, $a_cid)
Get instance.
$query
foreach($_POST as $key=> $value) $res
global $ilDB