51            $this->
id = $a_client_id;
 
   52            $this->ini_file_path = ILIAS_ABSOLUTE_PATH . 
"/" . ILIAS_WEB_DIR . 
"/" . $this->
getId() . 
"/client.ini.php";
 
   56        $this->client_defaults = ILIAS_ABSOLUTE_PATH . 
"/setup/client.master.ini.php";
 
   66        require_once(
'./setup/classes/class.ilDbSetup.php');
 
   69            if (is_null($this->db_setup)) {
 
   76        return \ilDbSetup::getNewInstanceForClient($this);
 
   86        $this->ini = 
new ilIniFile($this->ini_file_path);
 
   89        if (!@file_exists($this->ini_file_path)) {
 
   91            $this->ini->GROUPS = parse_ini_file($this->client_defaults, 
true);
 
   97        if (!$this->ini->read()) {
 
   98            $this->
error = get_class($this) . 
": " . $this->ini->getError();
 
  104        define(
"CLIENT_WEB_DIR", ILIAS_ABSOLUTE_PATH . 
"/" . ILIAS_WEB_DIR . 
"/" . $this->
getId());
 
  105        define(
"CLIENT_DATA_DIR", ILIAS_DATA_DIR . 
"/" . $this->
getId());
 
  106        define(
"DEVMODE", $this->ini->readVariable(
'system', 
'DEVMODE'));
 
  107        define(
"ROOT_FOLDER_ID", $this->ini->readVariable(
'system', 
'ROOT_FOLDER_ID'));
 
  108        define(
"SYSTEM_FOLDER_ID", $this->ini->readVariable(
'system', 
'SYSTEM_FOLDER_ID'));
 
  109        define(
"ROLE_FOLDER_ID", $this->ini->readVariable(
'system', 
'ROLE_FOLDER_ID'));
 
  110        define(
"ANONYMOUS_USER_ID", 13);
 
  111        define(
"ANONYMOUS_ROLE_ID", 14);
 
  112        define(
"SYSTEM_USER_ID", 6);
 
  113        define(
"SYSTEM_ROLE_ID", 2);
 
  115        $this->db_exists = $this->
getDBSetup()->isConnectable();
 
  117        if ($this->db_exists) {
 
  118            $this->db_installed = $this->
getDBSetup()->isDatabaseInstalled();
 
  151        $this->
id = $a_client_id;
 
  152        $this->webspace_dir = ILIAS_ABSOLUTE_PATH . 
"/" . ILIAS_WEB_DIR . 
"/" . 
$this->id;
 
  161        return $this->ini->readVariable(
"client", 
"name");
 
  170        $this->ini->setVariable(
"client", 
"name", $a_str);
 
  179        return $this->ini->readVariable(
"client", 
"description");
 
  188        $this->ini->setVariable(
"client", 
"description", $a_str);
 
  215        if (!$this->getdbHost() || !$this->getdbUser()) {
 
  216            $this->
error = 
"empty_fields";
 
  222        $this->db->setDBUser($this->getdbUser());
 
  223        $this->db->setDBPort($this->getdbPort());
 
  224        $this->db->setDBPassword($this->getdbPass());
 
  225        $this->db->setDBHost($this->getdbHost());
 
  226        $this->db->setDBName($this->getdbName());
 
  227        $con = $this->db->connect(
true);
 
  230            $this->
error = 
"Database connection failed.";
 
  235        if (
$GLOBALS[
"DIC"]->offsetExists(
"ilDB")) {
 
  236            $GLOBALS[
"DIC"]->offsetUnset(
"ilDB");
 
  243        $this->db_exists = 
true;
 
  254        if (method_exists($a_db, 
'loadModule')) {
 
  255            $a_db->loadModule(
'Manager');
 
  257        if (!$tables = $a_db->listTables()) {
 
  262        if (in_array(
"object_data", $tables) and in_array(
"object_reference", $tables) and in_array(
"usr_data", $tables) and in_array(
"rbac_ua", $tables)) {
 
  263            $this->db_installed = 
true;
 
  266        $this->db_installed = 
false;
 
  278                if (trim($this->getdbPort()) != 
"") {
 
  279                    $db_port_str = 
":" . $this->getdbPort();
 
  281                $this->dsn_host = 
"pgsql://" . $this->getdbUser() . 
":" . $this->getdbPass() . 
"@" . $this->getdbHost() . $db_port_str;
 
  282                $this->dsn = 
"pgsql://" . $this->getdbUser() . 
":" . $this->getdbPass() . 
"@" . $this->getdbHost() . $db_port_str . 
"/" . $this->getdbName();
 
  289                if (trim($this->getdbPort()) != 
"") {
 
  290                    $db_port_str = 
":" . $this->getdbPort();
 
  292                $this->dsn_host = 
"mysql://" . $this->getdbUser() . 
":" . $this->getdbPass() . 
"@" . $this->getdbHost() . $db_port_str;
 
  293                $this->dsn = 
"mysql://" . $this->getdbUser() . 
":" . $this->getdbPass() . 
"@" . $this->getdbHost() . $db_port_str . 
"/" . $this->getdbName();
 
  304        $this->ini->setVariable(
"db", 
"host", $a_str);
 
  314        return $this->ini->readVariable(
"db", 
"host");
 
  323        $this->ini->setVariable(
"db", 
"name", $a_str);
 
  332        return $this->ini->readVariable(
"db", 
"name");
 
  341        $this->ini->setVariable(
"db", 
"user", $a_str);
 
  350        return $this->ini->readVariable(
"db", 
"user");
 
  359        return $this->ini->readVariable(
"db", 
"port");
 
  368        $this->ini->setVariable(
"db", 
"port", $a_str);
 
  377        $this->ini->setVariable(
"db", 
"pass", $a_str);
 
  386        return $this->ini->readVariable(
"db", 
"pass");
 
  395        $this->ini->setVariable(
"db", 
"slave_active", (
int) $a_act);
 
  405        return (
int) $this->ini->readVariable(
"db", 
"slave_active");
 
  414        $this->ini->setVariable(
"db", 
"slave_host", $a_str);
 
  424        return $this->ini->readVariable(
"db", 
"slave_host");
 
  433        $this->ini->setVariable(
"db", 
"slave_name", $a_str);
 
  442        return $this->ini->readVariable(
"db", 
"slave_name");
 
  451        $this->ini->setVariable(
"db", 
"slave_user", $a_str);
 
  460        return $this->ini->readVariable(
"db", 
"slave_user");
 
  469        return $this->ini->readVariable(
"db", 
"slave_port");
 
  478        $this->ini->setVariable(
"db", 
"slave_port", $a_str);
 
  487        $this->ini->setVariable(
"db", 
"slave_pass", $a_str);
 
  496        return $this->ini->readVariable(
"db", 
"slave_pass");
 
  505        $this->ini->setVariable(
"db", 
"type", $a_str);
 
  514        $val = $this->ini->readVariable(
"db", 
"type");
 
  528        return ILIAS_DATA_DIR . 
"/" . $this->
getId();
 
  537        return ILIAS_ABSOLUTE_PATH . 
"/" . ILIAS_WEB_DIR . 
"/" . $this->
getId();
 
  569        include_once 
'./Services/Administration/classes/class.ilSetting.php';
 
  572        return $set->get($a_keyword);
 
  582        include_once 
'./Services/Administration/classes/class.ilSetting.php';
 
  584        return $set->getAll();
 
  596        include_once 
'./Services/Administration/classes/class.ilSetting.php';
 
  598        $set->set($a_key, $a_val);
 
  609        $inst_id = (empty($settings[
"inst_id"])) ? 
"0" : $settings[
"inst_id"];
 
  616                "&inst_id=" . rawurlencode($inst_id) .
 
  617                "&hostname=" . rawurlencode(
$_SERVER[
"SERVER_NAME"]) .
 
  618                "&inst_name=" . rawurlencode($this->ini->readVariable(
"client", 
"name")) .
 
  619                "&inst_info=" . rawurlencode($this->ini->readVariable(
"client", 
"description")) .
 
  621                "&contact_firstname=" . rawurlencode($settings[
"admin_firstname"]) .
 
  622                "&contact_lastname=" . rawurlencode($settings[
"admin_lastname"]) .
 
  623                "&contact_email=" . rawurlencode($settings[
"admin_email"]) .
 
  624                "&nic_key=" . rawurlencode($this->
getNICkey());
 
  648        require_once(__DIR__ . 
"/../../Services/WebServices/Curl/classes/class.ilCurlConnection.php");
 
  650            $this->
setError(
"CURL-extension not loaded.");
 
  654        if (!isset(
$GLOBALS[
"ilSetting"])) {
 
  662        $req->setOpt(CURLOPT_HEADER, 1);
 
  663        $req->setOpt(CURLOPT_RETURNTRANSFER, 1);
 
  664        $req->setOpt(CURLOPT_CONNECTTIMEOUT, $socket_timeout);
 
  665        $req->setOpt(CURLOPT_MAXREDIRS, $max_redirects);
 
  669        $response_body = 
$req->getResponseBody();
 
  671        $info = 
$req->getInfo();
 
  672        if ($info[
"http_code"] != 
"200") {
 
  673            $this->
setError(
"Could not connect to NIC-Server at '" . 
$url . 
"'");
 
  677        $this->nic_status = explode(
"\n", $response_body);
 
  694        mt_srand((
double) microtime() * 1000000);
 
  695        $nic_key = md5(str_replace(
".", 
"", 
$_SERVER[
"SERVER_ADDR"]) +
 
  696                    mt_rand(100000, 999999));
 
  700        $this->nic_key = $nic_key;
 
  712        $this->nic_key = $this->
getSetting(
"nic_key");
 
  714        if (empty($this->nic_key)) {
 
  718        return $this->nic_key;
 
  729        $this->ini->setVariable(
"language", 
"default", $a_lang_key);
 
  755        $this->
error = $error_message;
 
  766    public function delete($a_ini = 
true, $a_db = 
false, $a_files = 
false)
 
  768        if ($a_ini === 
true and file_exists(ILIAS_ABSOLUTE_PATH . 
"/" . ILIAS_WEB_DIR . 
"/" . $this->
getId() . 
"/client.ini.php")) {
 
  769            unlink(CLIENT_WEB_DIR . 
"/client.ini.php");
 
  770            $msg[] = 
"ini_deleted";
 
  773        if ($a_db === 
true and $this->db_exists) {
 
  774            $this->db->query(
"DROP DATABASE " . $this->
getDbName());
 
  775            $msg[] = 
"db_deleted";
 
  778        if ($a_files === 
true and file_exists(CLIENT_WEB_DIR) and is_dir(CLIENT_WEB_DIR)) {
 
  782            $msg[] = 
"files_deleted";
 
  797            $this->
error = 
"could_not_create_base_data_dir :" . $this->
getDataDir();
 
  803            $this->
error = 
"could_not_create_mail_data_dir :" . $this->
getDataDir() . 
"/mail";
 
  808            $this->
error = 
"could_not_create_lm_data_dir :" . $this->
getDataDir() . 
"/lm_data";
 
  813            $this->
error = 
"could_not_create_forum_data_dir :" . $this->
getDataDir() . 
"/forum";
 
  818            $this->
error = 
"could_not_create_files_data_dir :" . $this->
getDataDir() . 
"/files";
 
  830            $this->
error = 
"could_not_create_lm_webspace_dir :" . $this->
getWebspaceDir() . 
"/lm_data";
 
  835            $this->
error = 
"could_not_create_usr_images_webspace_dir :" . $this->
getWebspaceDir() . 
"/usr_images";
 
  850        if (!$this->ini->write()) {
 
  851            $this->
error = get_class($this) . 
": " . $this->ini->getError();
 
if(!defined('PATH_SEPARATOR')) $GLOBALS['_PEAR_default_error_mode']
An exception for terminatinating execution or to throw for unit testing.
error($a_errmsg)
set error message @access public
getAllSettings()
read all values from settings table @access public
setName($a_str)
set client name
init()
init client load client.ini and set some constants
isInstalledDB(&$a_db)
check if client db is installed
__construct($a_client_id)
ilClient constructor.
setDbSlaveHost($a_str)
set the slave host
setDbPort($a_str)
set db port
getDbSlaveName()
get name of slave database
setDescription($a_str)
set client description
setDbName($a_str)
set the name of database
setDbSlaveName($a_str)
set the name of slave database
create()
create a new client and its subdirectories
setNICkey()
set nic_key generate nic_key if nic_key field in cust table is empty.
getDataDir()
get client datadir path
getWebspaceDir()
get client webspacedir path
getURLStringForNIC($a_nic_url)
setDbSlaveUser($a_str)
set slave db user
getDbName()
get name of database
getDbSlaveActive()
get slave active
getDbType()
get type of database
setId($a_client_id)
set client id
getDbSlaveUser()
get slave db user
setDbType($a_str)
set the type of database
getSetting($a_keyword)
read one value from settings table
setDbSlavePort($a_str)
set slave db port
getDbSlavePort()
get slave db port
setDefaultLanguage($a_lang_key)
connect()
connect to client database
setDbSlavePass($a_str)
set slave db password
setDbPass($a_str)
set db password
setDbSlaveActive($a_act)
set the slave active
setSetting($a_key, $a_val)
write one value to settings table @access public
getDbPass()
get db password
getDbSlavePass()
get slave db password
getDbSlaveHost()
get db slave host
updateNIC($a_nic_url)
Connect to ILIAS-NIC.
setDbUser($a_str)
set db user
setDSN()
set the dsn and dsn_host
getNICkey()
get nic_key @access public
getDescription()
get client description
setDbHost($a_str)
set the host
getError()
get error message and clear error var
checkDatabaseExists($a_keep_connection=false)
check database connection with database name
static _isCurlExtensionLoaded()
Check if curl extension is loaded.
static getWrapper($a_type)
static getNewInstanceForClient(\ilClient $client)
static getLogger($a_component_id)
Get component logger.
static delDir($a_dir, $a_clean_only=false)
removes a dir and all its content (subdirs and files) recursively
static makeDir($a_dir)
creates a new directory and inherits all filesystem permissions of the parent directory You may pass ...