ILIAS  release_5-4 Revision v5.4.26-12-gabc799a52e6
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 $DIC;
67 
68  $ilDB = $DIC['ilDB'];
69 
70  $query = 'DELETE FROM ecs_community ' .
71  'WHERE sid = ' . $ilDB->quote($a_server_id, 'integer');
72  $ilDB->manipulate($query);
73  }
74 
79  public function getCommunities()
80  {
81  return (array) $this->communities;
82  }
83 
87  public function lookupOwnId($a_server_id, $a_mid)
88  {
89  foreach ($this->getCommunities() as $com) {
90  if ($com->getServerId() == $a_server_id) {
91  if (in_array($a_mid, $com->getMids())) {
92  return $com->getOwnId();
93  }
94  }
95  }
96  return 0;
97  }
98 
104  public function lookupTitle($a_server_id, $a_mid)
105  {
106  foreach ($this->getCommunities() as $com) {
107  if ($com->getServerId() == $a_server_id) {
108  if (in_array($a_mid, $com->getMids())) {
109  return $com->getCommunityName();
110  }
111  }
112  }
113  return '';
114  }
115 
119  private function read()
120  {
121  global $DIC;
122 
123  $ilDB = $DIC['ilDB'];
124 
125  $query = 'SELECT sid,cid FROM ecs_community ';
126  $res = $ilDB->query($query);
127  while ($row = $res->fetchRow(ilDBConstants::FETCHMODE_OBJECT)) {
128  $this->communities[] = ilECSCommunityCache::getInstance($row->sid, $row->cid);
129  }
130  return true;
131  }
132 }
global $DIC
Definition: saml.php:7
lookupTitle($a_server_id, $a_mid)
Lookup community title.
__construct()
Singleton constructor.
foreach($_POST as $key=> $value) $res
$query
static getInstance()
Singleton instance.
$row
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 | +...