83 $this->server_id = $a_server_id;
97 $GLOBALS[
'ilLog']->write(__METHOD__.
': Using deprecated call.');
109 if(self::$instances[$a_server_id])
111 return self::$instances[$a_server_id];
113 return self::$instances[$a_server_id] =
new ilECSSetting($a_server_id);
122 $this->title = $a_title;
140 $this->auth_type = $a_auth_type;
158 $this->auth_user = $a_user;
176 $this->auth_pass = $a_pass;
206 $this->active = $a_status;
229 $this->server = $a_server;
254 case self::PROTOCOL_HTTP:
258 case self::PROTOCOL_HTTPS:
266 foreach((array) explode(
'/',$this->
getServer()) as $key => $part)
271 $uri .=
':'.$this->getPort();
276 $uri = substr($uri,0,-1);
281 $uri .= (
':'.$this->getPort());
296 $this->protocol = $a_prot;
319 $this->port = $a_port;
343 $this->polling = $a_time;
365 return (
int) ($this->polling % 60);
376 return (
int) ($this->polling / 60);
401 $this->client_cert_path = $a_path;
423 $this->ca_cert_path = $a_ca;
457 $this->key_path = $a_path;
480 $this->key_password = $a_pass;
492 $this->import_id = $a_id;
514 $this->cert_serial_number = $a_cert_serial;
525 return $this->cert_serial_number;
548 $this->global_role = $a_role_id;
560 $this->duration = $a_duration;
582 return explode(
',',$this->user_recipients);
593 return $this->user_recipients ? $this->user_recipients :
'';
605 $this->user_recipients = $a_logins;
616 return explode(
',',$this->econtent_recipients);
627 return $this->econtent_recipients ? $this->econtent_recipients :
'';
639 $this->econtent_recipients = $a_logins;
650 return explode(
',',$this->approval_recipients);
662 return $this->approval_recipients ? $this->approval_recipients :
'';
673 $this->approval_recipients = $a_rcp;
739 global $ilObjDataCache,$tree;
745 if($ilObjDataCache->lookupType($ilObjDataCache->lookupObjId($this->getImportId())) !=
'cat')
749 if($tree->isDeleted($this->getImportId()))
766 $this->server_id = $ilDB->nextId(
'ecs_server');
767 $ilDB->manipulate($q =
'INSERT INTO ecs_server (server_id,active,title,protocol,server,port,auth_type,client_cert_path,ca_cert_path,'.
768 'key_path,key_password,cert_serial,polling_time,import_id,global_role,econtent_rcp,user_rcp,approval_rcp,duration,auth_user,auth_pass) '.
770 $ilDB->quote($this->getServerId(),
'integer').
', '.
771 $ilDB->quote((
int) $this->isEnabled(),
'integer').
', '.
772 $ilDB->quote($this->getTitle(),
'text').
', '.
773 $ilDB->quote((
int) $this->getProtocol(),
'integer').
', '.
774 $ilDB->quote($this->getServer(),
'text').
', '.
775 $ilDB->quote($this->getPort(),
'integer').
', '.
776 $ilDB->quote($this->getAuthType(),
'integer').
', '.
777 $ilDB->quote($this->getClientCertPath(),
'text').
', '.
778 $ilDB->quote($this->getCACertPath(),
'text').
', '.
779 $ilDB->quote($this->getKeyPath(),
'text').
', '.
780 $ilDB->quote($this->getKeyPassword(),
'text').
', '.
781 $ilDB->quote($this->getCertSerialNumber(),
'text').
', '.
782 $ilDB->quote($this->getPollingTime(),
'integer').
', '.
783 $ilDB->quote($this->getImportId(),
'integer').
', '.
784 $ilDB->quote($this->getGlobalRole(),
'integer').
', '.
785 $ilDB->quote($this->getEContentRecipientsAsString(),
'text').
', '.
786 $ilDB->quote($this->getUserRecipientsAsString(),
'text').
', '.
787 $ilDB->quote($this->getApprovalRecipientsAsString(),
'text').
', '.
788 $ilDB->quote($this->getDuration(),
'integer').
', '.
789 $ilDB->quote($this->getAuthUser(),
'text').
', '.
790 $ilDB->quote($this->getAuthPass(),
'text').
' '.
802 $ilDB->manipulate(
'UPDATE ecs_server SET '.
803 'server_id = '.$ilDB->quote($this->getServerId(),
'integer').
', '.
804 'active = '.$ilDB->quote((
int) $this->isEnabled(),
'integer').
', '.
805 'title = '.$ilDB->quote($this->getTitle(),
'text').
', '.
806 'protocol = '.$ilDB->quote((
int) $this->getProtocol(),
'integer').
', '.
807 'server = '.$ilDB->quote($this->getServer(),
'text').
', '.
808 'port = '.$ilDB->quote($this->getPort(),
'integer').
', '.
809 'auth_type = '.$ilDB->quote($this->getAuthType(),
'integer').
', '.
810 'client_cert_path = '.$ilDB->quote($this->getClientCertPath(),
'text').
', '.
811 'ca_cert_path = '.$ilDB->quote($this->getCACertPath(),
'text').
', '.
812 'key_path = '.$ilDB->quote($this->getKeyPath(),
'text').
', '.
813 'key_password = '.$ilDB->quote($this->getKeyPassword(),
'text').
', '.
814 'cert_serial = '.$ilDB->quote($this->getCertSerialNumber(),
'text').
', '.
815 'polling_time = '.$ilDB->quote($this->getPollingTime(),
'integer').
', '.
816 'import_id = '.$ilDB->quote($this->getImportId(),
'integer').
', '.
817 'global_role = '.$ilDB->quote($this->getGlobalRole(),
'integer').
', '.
818 'econtent_rcp = '.$ilDB->quote($this->getEContentRecipientsAsString(),
'text').
', '.
819 'user_rcp = '.$ilDB->quote($this->getUserRecipientsAsString(),
'text').
', '.
820 'approval_rcp = '.$ilDB->quote($this->getApprovalRecipientsAsString(),
'text').
', '.
821 'duration = '.$ilDB->quote($this->getDuration(),
'integer').
', '.
822 'auth_user = '.$ilDB->quote($this->getAuthUser(),
'text').
', '.
823 'auth_pass = '.$ilDB->quote($this->getAuthPass(),
'text').
', '.
824 'auth_type = '.$ilDB->quote($this->getAuthType(),
'integer').
' '.
825 'WHERE server_id = '.$ilDB->quote($this->getServerId(),
'integer')
832 public function delete()
837 'DELETE FROM ecs_server '.
838 'WHERE server_id = '.$ilDB->quote($this->getServerId(),
'integer')
858 if(function_exists(
'openssl_x509_parse') and $cert = openssl_x509_parse(
'file://'.$this->
getClientCertPath()))
860 if(isset($cert[
'validTo_time_t']) and $cert[
'validTo_time_t'])
880 if(function_exists(
'openssl_x509_parse') and $cert = openssl_x509_parse(
'file://'.$this->
getClientCertPath()))
882 if(isset($cert[
'serialNumber']) and $cert[
'serialNumber'])
885 $ilLog->write(__METHOD__.
': Serial number is '.$cert[
'serialNumber']);
896 foreach($lines as $line)
898 if(strpos($line,
'Serial Number:') !==
false)
901 $serial_line = explode(
':',$line);
902 $serial = (int) trim($serial_line[1]);
932 $query =
'SELECT * FROM ecs_server '.
933 'WHERE server_id = '.$ilDB->quote($this->
getServerId(),
'integer');
950 $this->econtent_recipients = $row[
'econtent_rcp'];
951 $this->approval_recipients = $row[
'approval_rcp'];
952 $this->user_recipients = $row[
'user_rcp'];
966 $this->server_id = 0;