ILIAS  release_4-3 Revision
 All Data Structures Namespaces Files Functions Variables Groups Pages
class.ilECSServerSettings.php
Go to the documentation of this file.
1 <?php
2 /*
3  +-----------------------------------------------------------------------------+
4  | ILIAS open source |
5  +-----------------------------------------------------------------------------+
6  | Copyright (c) 1998-2006 ILIAS open source, University of Cologne |
7  | |
8  | This program is free software; you can redistribute it and/or |
9  | modify it under the terms of the GNU General Public License |
10  | as published by the Free Software Foundation; either version 2 |
11  | of the License, or (at your option) any later version. |
12  | |
13  | This program is distributed in the hope that it will be useful, |
14  | but WITHOUT ANY WARRANTY; without even the implied warranty of |
15  | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
16  | GNU General Public License for more details. |
17  | |
18  | You should have received a copy of the GNU General Public License |
19  | along with this program; if not, write to the Free Software |
20  | Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. |
21  +-----------------------------------------------------------------------------+
22 */
23 
24 include_once './Services/WebServices/ECS/classes/class.ilECSSetting.php';
25 
35 {
36  private static $instance = null;
37 
38  private $servers = array();
39 
40 
44  protected function __construct()
45  {
46  $this->readActiveServers();
47  }
48 
54  public static function getInstance()
55  {
56  if(self::$instance)
57  {
58  return self::$instance;
59  }
60  return self::$instance = new ilECSServerSettings();
61  }
62 
67  public function activeServerExists()
68  {
69  return count($this->getServers()) ? true : false;
70  }
71 
76  public function serverExists()
77  {
78  return count($this->getServers()) ? true : false;
79  }
80 
85  public function getServers()
86  {
87  return (array) $this->servers;
88  }
89 
94  public function readInactiveServers()
95  {
96  global $ilDB;
97 
98  $query = 'SELECT server_id FROM ecs_server '.
99  'WHERE active = '.$ilDB->quote(0,'integer').' '.
100  'ORDER BY title ';
101  $res = $ilDB->query($query);
102 
103  while($row = $res->fetchRow(DB_FETCHMODE_OBJECT))
104  {
105  $this->servers[$row->server_id] = ilECSSetting::getInstanceByServerId($row->server_id);
106  }
107  }
108 
113  private function readActiveServers()
114  {
115  global $ilDB;
116 
117  $query = 'SELECT server_id FROM ecs_server '.
118  'WHERE active = '.$ilDB->quote(1,'integer').' '.
119  'ORDER BY title ';
120  $res = $ilDB->query($query);
121 
122  $this->servers = array();
123  while($row = $res->fetchRow(DB_FETCHMODE_OBJECT))
124  {
125  $this->servers[$row->server_id] = ilECSSetting::getInstanceByServerId($row->server_id);
126  }
127  }
128 
129 }
130 ?>