Public Member Functions | |
ilClient ($a_client_id=0) | |
Constructor. | |
init () | |
init client load client.ini and set some constants | |
getId () | |
get client id | |
setId ($a_client_id) | |
set client id | |
getName () | |
get client name | |
setName ($a_str) | |
set client name | |
getDescription () | |
get client description | |
setDescription ($a_str) | |
set client description | |
getMySQLVersion () | |
get mysql version | |
isMysql4_1OrHigher () | |
check wether current MySQL server is version 4.1.x or higher | |
connect () | |
connect to client database | |
isInstalledDB (&$a_db) | |
check if client db is installed | |
setDSN () | |
set the dsn and dsn_host | |
setDbHost ($a_str) | |
set the host | |
getDbHost () | |
get db host | |
setDbName ($a_str) | |
set the name of database | |
getDbName () | |
get name of database | |
setDbUser ($a_str) | |
set db user | |
getDbUser () | |
get db user | |
setDbPass ($a_str) | |
set db password | |
getDbPass () | |
get db password | |
getDataDir () | |
get client datadir path | |
getWebspaceDir () | |
get client webspacedir path | |
checkDatabaseHost () | |
check database connection | |
checkDatabaseExists () | |
check database connection with database name | |
getSetting ($a_keyword) | |
read one value from settings table public | |
getAllSettings () | |
read all values from settings table public | |
setSetting ($a_key, $a_val) | |
write one value to settings table public | |
getURLStringForNIC ($a_nic_url) | |
updateNIC ($a_nic_url) | |
Connect to ILIAS-NIC. | |
setNICkey () | |
set nic_key generate nic_key if nic_key field in cust table is empty. | |
getNICkey () | |
get nic_key public | |
getDefaultLanguage () | |
setDefaultLanguage ($a_lang_key) | |
getError () | |
get error message and clear error var | |
delete ($a_ini=true, $a_db=false, $a_files=false) | |
delete client | |
create () | |
create a new client and its subdirectories | |
Data Fields | |
$id | |
$dir | |
$name | |
$db_exists = false | |
$db_installed = false | |
$client_defaults | |
$status | |
$setup_ok = false | |
$nic_status |
Definition at line 33 of file class.ilClient.php.
ilClient::checkDatabaseExists | ( | ) |
check database connection with database name
Definition at line 378 of file class.ilClient.php.
References connect(), and isInstalledDB().
{ //try to connect to database $db = DB::connect($this->dsn); if (DB::isError($db)) { return false; } if (!$this->isInstalledDB($db)) { return false; } return true; }
ilClient::checkDatabaseHost | ( | ) |
check database connection
Definition at line 360 of file class.ilClient.php.
References connect().
{ //connect to databasehost $db = DB::connect($this->dsn_host); if (DB::isError($db)) { $this->error = $db->getMessage()."! Please check database hostname, username & password."; return false; } return true; }
ilClient::connect | ( | ) |
connect to client database
Definition at line 194 of file class.ilClient.php.
References isMysql4_1OrHigher(), and setDSN().
Referenced by checkDatabaseExists(), checkDatabaseHost(), and init().
{ // check parameters if (!$this->getdbHost() || !$this->getdbName() || !$this->getdbUser()) { $this->error = "empty_fields"; return false; } $this->setDSN(); $this->db = DB::connect($this->dsn,true); if (DB::isError($this->db)) { $this->error = $this->db->getMessage()."! not_connected_to_db"; return false; } // NOTE: Three sourcecodes use this or a similar handling: // - classes/class.ilDBx.php // - calendar/classes/class.ilCalInterface.php->setNames // - setup/classes/class.ilClient.php if ($this->isMysql4_1OrHigher()) { $this->db->query("SET NAMES utf8"); $this->db->query("SET SESSION SQL_MODE = ''"); } $this->db_exists = true; return true; }
ilClient::create | ( | ) |
create a new client and its subdirectories
Definition at line 635 of file class.ilClient.php.
References getDataDir(), getWebspaceDir(), and ilUtil::makeDir().
{ //var_dump($this->getDataDir());exit; // create base data dir if (!ilUtil::makeDir($this->getDataDir())) { $this->error = "could_not_create_base_data_dir :".$this->getDataDir(); return false; } // create sub dirs in base data dir if (!ilUtil::makeDir($this->getDataDir()."/mail")) { $this->error = "could_not_create_mail_data_dir :".$this->getDataDir()."/mail"; return false; } if (!ilUtil::makeDir($this->getDataDir()."/lm_data")) { $this->error = "could_not_create_lm_data_dir :".$this->getDataDir()."/lm_data"; return false; } if (!ilUtil::makeDir($this->getDataDir()."/forum")) { $this->error = "could_not_create_forum_data_dir :".$this->getDataDir()."/forum"; return false; } if (!ilUtil::makeDir($this->getDataDir()."/files")) { $this->error = "could_not_create_files_data_dir :".$this->getDataDir()."/files"; return false; } // create base webspace dir if (!ilUtil::makeDir($this->getWebspaceDir())) { $this->error = "could_not_create_base_webspace_dir :".$this->getWebspaceDir(); return false; } // create sub dirs in base webspace dir if (!ilUtil::makeDir($this->getWebspaceDir()."/lm_data")) { $this->error = "could_not_create_lm_webspace_dir :".$this->getWebspaceDir()."/lm_data"; return false; } if (!ilUtil::makeDir($this->getWebspaceDir()."/usr_images")) { $this->error = "could_not_create_usr_images_webspace_dir :".$this->getWebspaceDir()."/usr_images"; return false; } if (!ilUtil::makeDir($this->getWebspaceDir()."/mobs")) { $this->error = "could_not_create_mobs_webspace_dir :".$this->getWebspaceDir()."/mobs"; return false; } if (!ilUtil::makeDir($this->getWebspaceDir()."/css")) { $this->error = "could_not_create_css_webspace_dir :".$this->getWebspaceDir()."/css"; return false; } // write client ini if (!$this->ini->write()) { $this->error = get_class($this).": ".$this->ini->getError(); return false; } return true; }
ilClient::delete | ( | $ | a_ini = true , |
|
$ | a_db = false , |
|||
$ | a_files = false | |||
) |
delete client
boolean | remove ini if true | |
boolean | remove db if true | |
boolean | remove files if true |
Definition at line 606 of file class.ilClient.php.
References ilUtil::delDir(), and getDbName().
{ if ($a_ini === true and file_exists(ILIAS_ABSOLUTE_PATH."/".ILIAS_WEB_DIR."/".$this->getId()."/client.ini.php")) { unlink(CLIENT_WEB_DIR."/client.ini.php"); $msg[] = "ini_deleted"; } if ($a_db === true and $this->db_exists) { $this->db->query("DROP DATABASE ".$this->getDbName()); $msg[] = "db_deleted"; } if ($a_files === true and file_exists(CLIENT_WEB_DIR) and is_dir(CLIENT_WEB_DIR)) { // rmdir(); ilUtil::delDir(CLIENT_WEB_DIR); ilUtil::delDir(CLIENT_DATA_DIR); $msg[] = "files_deleted"; } return $msg; }
ilClient::getAllSettings | ( | ) |
read all values from settings table public
Definition at line 423 of file class.ilClient.php.
Referenced by getURLStringForNIC().
{ $q = "SELECT * FROM settings"; $r = $this->db->query($q); while ($row = $r->fetchRow(DB_FETCHMODE_ASSOC)) { $arr[$row["keyword"]] = $row["value"]; } return $arr; }
ilClient::getDataDir | ( | ) |
get client datadir path
Definition at line 342 of file class.ilClient.php.
References getId().
Referenced by create().
{ return ILIAS_DATA_DIR."/".$this->getId(); }
ilClient::getDbHost | ( | ) |
get db host
Definition at line 279 of file class.ilClient.php.
{ return $this->ini->readVariable("db","host"); }
ilClient::getDbName | ( | ) |
get name of database
Definition at line 297 of file class.ilClient.php.
Referenced by delete().
{ return $this->ini->readVariable("db","name"); }
ilClient::getDbPass | ( | ) |
get db password
Definition at line 333 of file class.ilClient.php.
{ return $this->ini->readVariable("db","pass"); }
ilClient::getDbUser | ( | ) |
get db user
Definition at line 315 of file class.ilClient.php.
{ return $this->ini->readVariable("db","user"); }
ilClient::getDefaultLanguage | ( | ) |
Definition at line 572 of file class.ilClient.php.
References getSetting().
{ return $this->getSetting("language"); }
ilClient::getDescription | ( | ) |
get client description
Definition at line 148 of file class.ilClient.php.
{ return $this->ini->readVariable("client","description"); }
ilClient::getError | ( | ) |
get error message and clear error var
Definition at line 590 of file class.ilClient.php.
{ $error = $this->error; $this->error = ""; return $error; }
ilClient::getId | ( | ) |
get client id
Definition at line 111 of file class.ilClient.php.
Referenced by getDataDir(), getWebspaceDir(), and ilClient().
{
return $this->id;
}
ilClient::getMySQLVersion | ( | ) |
get mysql version
Definition at line 165 of file class.ilClient.php.
{
return mysql_get_server_info();
}
ilClient::getName | ( | ) |
get client name
Definition at line 130 of file class.ilClient.php.
{ return $this->ini->readVariable("client","name"); }
ilClient::getNICkey | ( | ) |
get nic_key public
Definition at line 560 of file class.ilClient.php.
References getSetting(), and setNICkey().
Referenced by getURLStringForNIC().
{ $this->nic_key = $this->getSetting("nic_key"); if (empty($this->nic_key)) { $this->setNICkey(); } return $this->nic_key; }
ilClient::getSetting | ( | $ | a_keyword | ) |
read one value from settings table public
string | keyword |
Definition at line 402 of file class.ilClient.php.
Referenced by getDefaultLanguage(), and getNICkey().
{ $q = "SELECT value FROM settings WHERE keyword='".$a_keyword."'"; $r = $this->db->query($q); if ($r->numRows() > 0) { $row = $r->fetchRow(); return $row[0]; } else { return false; } }
ilClient::getURLStringForNIC | ( | $ | a_nic_url | ) |
string | url to ilias nic server |
Definition at line 455 of file class.ilClient.php.
References getAllSettings(), and getNICkey().
Referenced by updateNIC().
{ $settings = $this->getAllSettings(); $inst_id = (empty($settings["inst_id"])) ? "0" : $settings["inst_id"]; // send host information to ilias-nic $url = $a_nic_url. "?cmd=getid". "&inst_id=".rawurlencode($inst_id). "&hostname=".rawurlencode($_SERVER["SERVER_NAME"]). "&ipadr=".rawurlencode($_SERVER["SERVER_ADDR"]). "&server_port=".rawurlencode($_SERVER["SERVER_PORT"]). "&server_software=".rawurlencode($_SERVER["SERVER_SOFTWARE"]). "&inst_name=".rawurlencode($this->ini->readVariable("client","name")). "&inst_info=".rawurlencode($this->ini->readVariable("client","description")). "&institution=".rawurlencode($settings["inst_institution"]). "&http_path=".rawurlencode(ILIAS_HTTP_PATH). "&contact_firstname=".rawurlencode($settings["admin_firstname"]). "&contact_lastname=".rawurlencode($settings["admin_lastname"]). "&contact_title=".rawurlencode($settings["admin_title"]). "&contact_position=".rawurlencode($settings["admin_position"]). "&contact_institution=".rawurlencode($settings["admin_institution"]). "&contact_street=".rawurlencode($settings["admin_street"]). "&contact_pcode=".rawurlencode($settings["admin_zipcode"]). "&contact_city=".rawurlencode($settings["admin_city"]). "&contact_country=".rawurlencode($settings["admin_country"]). "&contact_phone=".rawurlencode($settings["admin_phone"]). "&contact_email=".rawurlencode($settings["admin_email"]). "&nic_key=".rawurlencode($this->getNICkey()). "&version=".rawurlencode($settings["ilias_version"]); return $url; }
ilClient::getWebspaceDir | ( | ) |
get client webspacedir path
Definition at line 351 of file class.ilClient.php.
References getId().
Referenced by create().
{ return ILIAS_ABSOLUTE_PATH."/".ILIAS_WEB_DIR."/".$this->getId(); }
ilClient::ilClient | ( | $ | a_client_id = 0 |
) |
Constructor.
string | client id |
Definition at line 50 of file class.ilClient.php.
References getId().
{ if ($a_client_id) { $this->id = $a_client_id; $this->ini_file_path = ILIAS_ABSOLUTE_PATH."/".ILIAS_WEB_DIR."/".$this->getId()."/client.ini.php"; } // set path default.ini $this->client_defaults = ILIAS_ABSOLUTE_PATH."/setup/client.master.ini.php"; }
ilClient::init | ( | ) |
init client load client.ini and set some constants
Definition at line 67 of file class.ilClient.php.
References connect(), and isInstalledDB().
{ $this->ini = new ilIniFile($this->ini_file_path); // load defaults only if no client.ini was found if (!@file_exists($this->ini_file_path)) { $this->ini->GROUPS = parse_ini_file($this->client_defaults,true); return false; } // read client.ini if (!$this->ini->read()) { $this->error = get_class($this).": ".$this->ini->getError(); return false; } // only for ilias main define("CLIENT_WEB_DIR",ILIAS_ABSOLUTE_PATH."/".ILIAS_WEB_DIR."/".$this->getId()); define("CLIENT_DATA_DIR",ILIAS_DATA_DIR."/".$this->getId()); define ("DEVMODE",$this->ini->readVariable('system','DEVMODE')); define ("ROOT_FOLDER_ID",$this->ini->readVariable('system','ROOT_FOLDER_ID')); define ("SYSTEM_FOLDER_ID",$this->ini->readVariable('system','SYSTEM_FOLDER_ID')); define ("ROLE_FOLDER_ID",$this->ini->readVariable('system','ROLE_FOLDER_ID')); define ("ANONYMOUS_USER_ID",13); define ("ANONYMOUS_ROLE_ID",14); define ("SYSTEM_USER_ID",6); define ("SYSTEM_ROLE_ID",2); $this->db_exists = $this->connect(); if ($this->db_exists) { $this->db_installed = $this->isInstalledDB($this->db); } return true; }
ilClient::isInstalledDB | ( | &$ | a_db | ) |
check if client db is installed
object | db object |
Definition at line 232 of file class.ilClient.php.
References $q, $row, and $tables.
Referenced by checkDatabaseExists(), and init().
{ $q = "SHOW TABLES"; $r = $a_db->query($q); $tables = array(); while ($row = $r->fetchRow(DB_FETCHMODE_ASSOC)) { $tables[] = implode($row); } // check existence of some basic tables from ilias3 to determine if ilias3 is already installed in given database if (in_array("object_data",$tables) and in_array("object_reference",$tables) and in_array("usr_data",$tables) and in_array("rbac_ua",$tables)) { $this->db_installed = true; return true; } $this->db_installed = false; return false; }
ilClient::isMysql4_1OrHigher | ( | ) |
check wether current MySQL server is version 4.1.x or higher
NOTE: Three sourcecodes use this or a similar handling:
Definition at line 178 of file class.ilClient.php.
Referenced by connect().
{ $version = explode(".", $this->getMysqlVersion()); if ((int)$version[0] >= 5 || ((int)$version[0] == 4 && (int)$version[1] >= 1)) { return true; } return false; }
ilClient::setDbHost | ( | $ | a_str | ) |
set the host
string |
Definition at line 269 of file class.ilClient.php.
{ $this->ini->setVariable("db","host",$a_str); }
ilClient::setDbName | ( | $ | a_str | ) |
set the name of database
string |
Definition at line 288 of file class.ilClient.php.
{ $this->ini->setVariable("db","name",$a_str); }
ilClient::setDbPass | ( | $ | a_str | ) |
set db password
string |
Definition at line 324 of file class.ilClient.php.
{ $this->ini->setVariable("db","pass",$a_str); }
ilClient::setDbUser | ( | $ | a_str | ) |
set db user
string | db user |
Definition at line 306 of file class.ilClient.php.
{ $this->ini->setVariable("db","user",$a_str); }
ilClient::setDefaultLanguage | ( | $ | a_lang_key | ) |
Definition at line 577 of file class.ilClient.php.
References setSetting().
{ $this->setSetting("language",$a_lang_key); $this->ini->setVariable("language","default",$a_lang_key); $this->ini->write(); return true; }
ilClient::setDescription | ( | $ | a_str | ) |
set client description
string | client description |
Definition at line 157 of file class.ilClient.php.
{ $this->ini->setVariable("client","description",$a_str); }
ilClient::setDSN | ( | ) |
set the dsn and dsn_host
Definition at line 258 of file class.ilClient.php.
Referenced by connect().
{ $this->dsn_host = "mysql://".$this->getdbUser().":".$this->getdbPass()."@".$this->getdbHost(); $this->dsn = "mysql://".$this->getdbUser().":".$this->getdbPass()."@".$this->getdbHost()."/".$this->getdbName(); }
ilClient::setId | ( | $ | a_client_id | ) |
set client id
string | client id |
Definition at line 120 of file class.ilClient.php.
{ $this->id = $a_client_id; $this->webspace_dir = ILIAS_ABSOLUTE_PATH."/".ILIAS_WEB_DIR."/".$this->id; }
ilClient::setName | ( | $ | a_str | ) |
set client name
string | client name |
Definition at line 139 of file class.ilClient.php.
{ $this->ini->setVariable("client","name",$a_str); }
ilClient::setNICkey | ( | ) |
set nic_key generate nic_key if nic_key field in cust table is empty.
the nic_key is used for authentication update requests sent to the ILIAS-NIC server. public
Definition at line 542 of file class.ilClient.php.
References setSetting().
Referenced by getNICkey().
{ mt_srand((double)microtime()*1000000); $nic_key = md5(str_replace(".","",$_SERVER["SERVER_ADDR"]) + mt_rand(100000,999999)); $this->setSetting("nic_key",$nic_key); $this->nic_key = $nic_key; return true; }
ilClient::setSetting | ( | $ | a_key, | |
$ | a_val | |||
) |
write one value to settings table public
string | keyword | |
string | value |
Definition at line 443 of file class.ilClient.php.
References $q.
Referenced by setDefaultLanguage(), and setNICkey().
{ $q = "REPLACE INTO settings SET keyword = '".$a_key."', value = '".$a_val."'"; $this->db->query($q); return true; }
ilClient::updateNIC | ( | $ | a_nic_url | ) |
Connect to ILIAS-NIC.
This function establishes a HTTP connection to the ILIAS Network Information Center (NIC) in order to update the ILIAS-NIC host database and - in case of a newly installed system - obtain an installation id at first connection. This function my be put into a dedicated include file as soon as there are more functions concerning the interconnection of ILIAS hosts
void |
Definition at line 504 of file class.ilClient.php.
References getURLStringForNIC().
{ $url = $this->getURLStringForNIC($a_nic_url); $conn =fopen($url,"r"); $input = ""; if (!$conn) { return false; } else { while(!feof($conn)) { $input.= fgets($conn, 4096); } fclose($conn); $line = explode("\n",$input); $ret = $line; } $this->nic_status = $ret; return true; }
ilClient::$client_defaults |
Definition at line 41 of file class.ilClient.php.
ilClient::$db_exists = false |
Definition at line 38 of file class.ilClient.php.
ilClient::$db_installed = false |
Definition at line 39 of file class.ilClient.php.
ilClient::$dir |
Definition at line 36 of file class.ilClient.php.
ilClient::$id |
Definition at line 35 of file class.ilClient.php.
ilClient::$name |
Definition at line 37 of file class.ilClient.php.
ilClient::$nic_status |
Definition at line 44 of file class.ilClient.php.
ilClient::$setup_ok = false |
Definition at line 43 of file class.ilClient.php.
ilClient::$status |
Definition at line 42 of file class.ilClient.php.