Go to the documentation of this file.00001 <?php
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00033 class ilECSSettings
00034 {
00035 const PROTOCOL_HTTP = 0;
00036 const PROTOCOL_HTTPS = 1;
00037
00038 public $fisch = 5;
00039
00040 protected static $instance = null;
00041
00042 private $active = false;
00043 private $server;
00044 private $protocol;
00045 private $port;
00046 private $client_cert_path;
00047 private $ca_cert_path;
00048 private $key_path;
00049 private $key_pathword;
00050 private $polling;
00051 private $import_id;
00052
00058 private function __construct()
00059 {
00060 $this->initStorage();
00061 $this->read();
00062 }
00063
00071 public static function _getInstance()
00072 {
00073 if(self::$instance)
00074 {
00075 return self::$instance;
00076 }
00077 return self::$instance = new ilECSSettings();
00078 }
00079
00087 public function setEnabledStatus($a_status)
00088 {
00089 $this->active = $a_status;
00090 }
00091
00098 public function isEnabled()
00099 {
00100 return $this->active;
00101 }
00102
00110 public function setServer($a_server)
00111 {
00112 $this->server = $a_server;
00113 }
00114
00122 public function getServer()
00123 {
00124 return $this->server;
00125 }
00126
00133 public function getServerURI()
00134 {
00135 switch($this->getProtocol())
00136 {
00137 case self::PROTOCOL_HTTP:
00138 $uri = 'http://';
00139 break;
00140
00141 case self::PROTOCOL_HTTPS:
00142 $uri = 'https://';
00143 break;
00144 }
00145 $uri .= $this->getServer().':'.$this->getPort();
00146 return $uri;
00147 }
00148
00156 public function setProtocol($a_prot)
00157 {
00158 $this->protocol = $a_prot;
00159 }
00160
00167 public function getProtocol()
00168 {
00169 return $this->protocol;
00170 }
00171
00179 public function setPort($a_port)
00180 {
00181 $this->port = $a_port;
00182 }
00183
00191 public function getPort()
00192 {
00193 return $this->port;
00194 }
00195
00203 public function setPollingTime($a_time)
00204 {
00205 $this->polling = $a_time;
00206 }
00207
00214 public function getPollingTime()
00215 {
00216 return $this->polling;
00217 }
00218
00225 public function getPollingTimeSeconds()
00226 {
00227 return (int) ($this->polling % 60);
00228 }
00229
00236 public function getPollingTimeMinutes()
00237 {
00238 return (int) ($this->polling / 60);
00239 }
00240
00249 public function setPollingTimeMS($a_min,$a_sec)
00250 {
00251 $this->setPollingTime(60 * $a_min + $a_sec);
00252 }
00253
00261 public function setClientCertPath($a_path)
00262 {
00263 $this->client_cert_path = $a_path;
00264 }
00265
00271 public function getClientCertPath()
00272 {
00273 return $this->client_cert_path;
00274 }
00275
00283 public function setCACertPath($a_ca)
00284 {
00285 $this->ca_cert_path = $a_ca;
00286 }
00287
00294 public function getCACertPath()
00295 {
00296 return $this->ca_cert_path;
00297 }
00298
00305 public function getKeyPath()
00306 {
00307 return $this->key_path;
00308 }
00309
00317 public function setKeyPath($a_path)
00318 {
00319 $this->key_path = $a_path;
00320 }
00321
00328 public function getKeyPassword()
00329 {
00330 return $this->key_password;
00331 }
00332
00340 public function setKeyPassword($a_pass)
00341 {
00342 $this->key_password = $a_pass;
00343 }
00344
00352 public function setImportId($a_id)
00353 {
00354 $this->import_id = $a_id;
00355 }
00356
00362 public function getImportId()
00363 {
00364 return $this->import_id;
00365 }
00366
00375 public function validate()
00376 {
00377 if(!$this->isEnabled())
00378 {
00379 return true;
00380 }
00381 if(!$this->getServer() or !$this->getPort() or !$this->getClientCertPath() or !$this->getCACertPath()
00382 or !$this->getKeyPath() or !$this->getKeyPassword())
00383 {
00384 return false;
00385 }
00386 return true;
00387 }
00388
00395 public function save()
00396 {
00397 $this->storage->set('active',(int) $this->isEnabled());
00398 $this->storage->set('server',$this->getServer());
00399 $this->storage->set('port',$this->getPort());
00400 $this->storage->set('protocol',$this->getProtocol());
00401 $this->storage->set('client_cert_path',$this->getClientCertPath());
00402 $this->storage->set('ca_cert_path',$this->getCACertPath());
00403 $this->storage->set('key_path',$this->getKeyPath());
00404 $this->storage->set('key_password',$this->getKeyPassword());
00405 $this->storage->set('import_id',$this->getImportId());
00406 $this->storage->set('polling',$this->getPollingTime());
00407 }
00408
00414 private function initStorage()
00415 {
00416 include_once('./Services/Administration/classes/class.ilSetting.php');
00417 $this->storage = new ilSetting('ecs');
00418 }
00419
00425 private function read()
00426 {
00427 $this->setServer($this->storage->get('server'));
00428 $this->setProtocol($this->storage->get('protocol'));
00429 $this->setPort($this->storage->get('port'));
00430 $this->setClientCertPath($this->storage->get('client_cert_path'));
00431 $this->setCACertPath($this->storage->get('ca_cert_path'));
00432 $this->setKeyPath($this->storage->get('key_path'));
00433 $this->setKeyPassword($this->storage->get('key_password'));
00434 $this->setPollingTime($this->storage->get('polling',128));
00435 $this->setImportId($this->storage->get('import_id'));
00436 $this->setEnabledStatus((int) $this->storage->get('active'));
00437 }
00438 }
00439 ?>