ILIAS  release_5-4 Revision v5.4.26-12-gabc799a52e6
ilClient Class Reference

Client Management. More...

+ Collaboration diagram for ilClient:

Public Member Functions

 __construct ($a_client_id, $a_db_connections)
 ilClient constructor. More...
 
 getDBSetup ($cached=true)
 
 init ()
 init client load client.ini and set some constants More...
 
 provideGlobalDB ()
 
 revokeGlobalDB ()
 
 getId ()
 get client id More...
 
 setId ($a_client_id)
 set client id More...
 
 getName ()
 get client name More...
 
 setName ($a_str)
 set client name More...
 
 getDescription ()
 get client description More...
 
 setDescription ($a_str)
 set client description More...
 
 getDB ()
 get mysql version More...
 
 connect ()
 connect to client database More...
 
 isInstalledDB (&$a_db)
 check if client db is installed More...
 
 setDSN ()
 set the dsn and dsn_host More...
 
 setDbHost ($a_str)
 set the host More...
 
 getDbHost ()
 get db host More...
 
 setDbName ($a_str)
 set the name of database More...
 
 getDbName ()
 get name of database More...
 
 setDbUser ($a_str)
 set db user More...
 
 getDbUser ()
 get db user More...
 
 getDbPort ()
 get db port More...
 
 setDbPort ($a_str)
 set db port More...
 
 setDbPass ($a_str)
 set db password More...
 
 getDbPass ()
 get db password More...
 
 setDbSlaveActive ($a_act)
 set the slave active More...
 
 getDbSlaveActive ()
 get slave active More...
 
 setDbSlaveHost ($a_str)
 set the slave host More...
 
 getDbSlaveHost ()
 get db slave host More...
 
 setDbSlaveName ($a_str)
 set the name of slave database More...
 
 getDbSlaveName ()
 get name of slave database More...
 
 setDbSlaveUser ($a_str)
 set slave db user More...
 
 getDbSlaveUser ()
 get slave db user More...
 
 getDbSlavePort ()
 get slave db port More...
 
 setDbSlavePort ($a_str)
 set slave db port More...
 
 setDbSlavePass ($a_str)
 set slave db password More...
 
 getDbSlavePass ()
 get slave db password More...
 
 setDbType ($a_str)
 set the type of database More...
 
 getDbType ()
 get type of database More...
 
 getDataDir ()
 get client datadir path More...
 
 getWebspaceDir ()
 get client webspacedir path More...
 
 checkDatabaseExists ($a_keep_connection=false)
 check database connection with database name More...
 
 reconnect ()
 
 getSetting ($a_keyword)
 read one value from settings table More...
 
 getAllSettings ()
 read all values from settings table public More...
 
 setSetting ($a_key, $a_val)
 write one value to settings table public More...
 
 getURLStringForNIC ($a_nic_url)
 
 updateNIC ($a_nic_url)
 Connect to ILIAS-NIC. More...
 
 setNICkey ()
 set nic_key generate nic_key if nic_key field in cust table is empty. More...
 
 getNICkey ()
 get nic_key public More...
 
 getDefaultLanguage ()
 
 setDefaultLanguage ($a_lang_key)
 
 getError ()
 get error message and clear error var More...
 
 setError ($error_message)
 
 delete ($a_ini=true, $a_db=false, $a_files=false)
 delete client More...
 
 create ()
 create a new client and its subdirectories More...
 
 writeIni ()
 write init More...
 

Data Fields

 $id
 
 $dir
 
 $name
 
 $db_exists = false
 
 $db_installed = false
 
 $client_defaults
 
 $status
 
 $setup_ok = false
 
 $nic_status
 
 $error = ''
 
 $db
 
 $ini
 

Protected Attributes

 $db_setup = null
 

Detailed Description

Client Management.

Author
Sascha Hofmann shofm.nosp@m.ann@.nosp@m.datab.nosp@m.ay.d.nosp@m.e
Alex Killing alex..nosp@m.kill.nosp@m.ing@g.nosp@m.mx.d.nosp@m.e
Version
$Id$

Definition at line 12 of file class.ilClient.php.

Constructor & Destructor Documentation

◆ __construct()

ilClient::__construct (   $a_client_id,
  $a_db_connections 
)

ilClient constructor.

Parameters
$a_client_id
$a_db_connections

Definition at line 49 of file class.ilClient.php.

References getId().

50  {
51  if ($a_client_id) {
52  $this->id = $a_client_id;
53  $this->ini_file_path = ILIAS_ABSOLUTE_PATH . "/" . ILIAS_WEB_DIR . "/" . $this->getId() . "/client.ini.php";
54  }
55 
56  $this->db_connections = $a_db_connections;
57 
58  // set path default.ini
59  $this->client_defaults = ILIAS_ABSOLUTE_PATH . "/setup/client.master.ini.php";
60  }
getId()
get client id
+ Here is the call graph for this function:

Member Function Documentation

◆ checkDatabaseExists()

ilClient::checkDatabaseExists (   $a_keep_connection = false)

check database connection with database name

Returns
boolean

Definition at line 549 of file class.ilClient.php.

References $c, $db, $GLOBALS, getDBSetup(), and isInstalledDB().

550  {
551  return $this->getDBSetup()->isConnectable();
552 
553  //try to connect to database
554  $db = $this->db_connections->connectDB($this->dsn);
555  if (MDB2::isError($db)) {
556  return false;
557  }
558 
559  if (!$this->isInstalledDB($db)) {
560  return false;
561  }
562 
563  // #10633
564  if ($a_keep_connection) {
565  $GLOBALS["ilDB"] = $this->db;
566  $GLOBALS["DIC"]["ilDB"] = function ($c) {
567  return $GLOBALS["ilDB"];
568  };
569  }
570 
571  return true;
572  }
isInstalledDB(&$a_db)
check if client db is installed
getDBSetup($cached=true)
$GLOBALS['JPEG_Segment_Names']
Global Variable: XMP_tag_captions.
+ Here is the call graph for this function:

◆ connect()

ilClient::connect ( )

connect to client database

Returns
boolean true on success

Definition at line 214 of file class.ilClient.php.

References $c, $db, and $GLOBALS.

Referenced by reconnect().

215  {
216  // check parameters
217  // To support oracle tnsnames.ora dbname is not required
218  if (!$this->getdbHost() || !$this->getdbUser()) {
219  $this->error = "empty_fields";
220 
221  return false;
222  }
223 
224  include_once("./Services/Database/classes/class.ilDBWrapperFactory.php");
225  $this->db = ilDBWrapperFactory::getWrapper($this->getdbType());
226  $this->db->setDBUser($this->getdbUser());
227  $this->db->setDBPort($this->getdbPort());
228  $this->db->setDBPassword($this->getdbPass());
229  $this->db->setDBHost($this->getdbHost());
230  $this->db->setDBName($this->getdbName());
231  $con = $this->db->connect(true);
232 
233  if (!$con) {
234  $this->error = "Database connection failed.";
235  return false;
236  }
237  $GLOBALS["ilDB"] = $this->db;
238 
239  if ($GLOBALS["DIC"]->offsetExists("ilDB")) {
240  $GLOBALS["DIC"]->offsetUnset("ilDB");
241  }
242 
243  $GLOBALS["DIC"]["ilDB"] = function ($c) {
244  return $GLOBALS["ilDB"];
245  };
246 
247  $this->db_exists = true;
248  return true;
249  }
$GLOBALS['JPEG_Segment_Names']
Global Variable: XMP_tag_captions.
+ Here is the caller graph for this function:

◆ create()

ilClient::create ( )

create a new client and its subdirectories

Returns
boolean true on success

Definition at line 819 of file class.ilClient.php.

References getDataDir(), getWebspaceDir(), and ilUtil\makeDir().

820  {
821  //var_dump($this->getDataDir());exit;
822  // create base data dir
823  if (!ilUtil::makeDir($this->getDataDir())) {
824  $this->error = "could_not_create_base_data_dir :" . $this->getDataDir();
825  return false;
826  }
827 
828  // create sub dirs in base data dir
829  if (!ilUtil::makeDir($this->getDataDir() . "/mail")) {
830  $this->error = "could_not_create_mail_data_dir :" . $this->getDataDir() . "/mail";
831  return false;
832  }
833 
834  if (!ilUtil::makeDir($this->getDataDir() . "/lm_data")) {
835  $this->error = "could_not_create_lm_data_dir :" . $this->getDataDir() . "/lm_data";
836  return false;
837  }
838 
839  if (!ilUtil::makeDir($this->getDataDir() . "/forum")) {
840  $this->error = "could_not_create_forum_data_dir :" . $this->getDataDir() . "/forum";
841  return false;
842  }
843 
844  if (!ilUtil::makeDir($this->getDataDir() . "/files")) {
845  $this->error = "could_not_create_files_data_dir :" . $this->getDataDir() . "/files";
846  return false;
847  }
848 
849  // create base webspace dir
850  if (!ilUtil::makeDir($this->getWebspaceDir())) {
851  $this->error = "could_not_create_base_webspace_dir :" . $this->getWebspaceDir();
852  return false;
853  }
854 
855  // create sub dirs in base webspace dir
856  if (!ilUtil::makeDir($this->getWebspaceDir() . "/lm_data")) {
857  $this->error = "could_not_create_lm_webspace_dir :" . $this->getWebspaceDir() . "/lm_data";
858  return false;
859  }
860 
861  if (!ilUtil::makeDir($this->getWebspaceDir() . "/usr_images")) {
862  $this->error = "could_not_create_usr_images_webspace_dir :" . $this->getWebspaceDir() . "/usr_images";
863  return false;
864  }
865 
866  if (!ilUtil::makeDir($this->getWebspaceDir() . "/mobs")) {
867  $this->error = "could_not_create_mobs_webspace_dir :" . $this->getWebspaceDir() . "/mobs";
868  return false;
869  }
870 
871  if (!ilUtil::makeDir($this->getWebspaceDir() . "/css")) {
872  $this->error = "could_not_create_css_webspace_dir :" . $this->getWebspaceDir() . "/css";
873  return false;
874  }
875 
876  // write client ini
877  if (!$this->ini->write()) {
878  $this->error = get_class($this) . ": " . $this->ini->getError();
879  return false;
880  }
881 
882  return true;
883  }
static makeDir($a_dir)
creates a new directory and inherits all filesystem permissions of the parent directory You may pass ...
getDataDir()
get client datadir path
getWebspaceDir()
get client webspacedir path
+ Here is the call graph for this function:

◆ delete()

ilClient::delete (   $a_ini = true,
  $a_db = false,
  $a_files = false 
)

delete client

Parameters
booleanremove ini if true
booleanremove db if true
booleanremove files if true
Returns
array confirmation messages

Definition at line 793 of file class.ilClient.php.

References ilUtil\delDir(), getDbName(), and getId().

794  {
795  if ($a_ini === true and file_exists(ILIAS_ABSOLUTE_PATH . "/" . ILIAS_WEB_DIR . "/" . $this->getId() . "/client.ini.php")) {
796  unlink(CLIENT_WEB_DIR . "/client.ini.php");
797  $msg[] = "ini_deleted";
798  }
799 
800  if ($a_db === true and $this->db_exists) {
801  $this->db->query("DROP DATABASE " . $this->getDbName());
802  $msg[] = "db_deleted";
803  }
804 
805  if ($a_files === true and file_exists(CLIENT_WEB_DIR) and is_dir(CLIENT_WEB_DIR)) {
806  // rmdir();
807  ilUtil::delDir(CLIENT_WEB_DIR);
808  ilUtil::delDir(CLIENT_DATA_DIR);
809  $msg[] = "files_deleted";
810  }
811 
812  return $msg;
813  }
getDbName()
get name of database
getId()
get client id
static delDir($a_dir, $a_clean_only=false)
removes a dir and all its content (subdirs and files) recursively
+ Here is the call graph for this function:

◆ getAllSettings()

ilClient::getAllSettings ( )

read all values from settings table public

Returns
array keyword/value pairs

Definition at line 604 of file class.ilClient.php.

Referenced by getURLStringForNIC(), and updateNIC().

605  {
606  include_once './Services/Administration/classes/class.ilSetting.php';
607  $set = new ilSetting("common", true);
608  return $set->getAll();
609  }
+ Here is the caller graph for this function:

◆ getDataDir()

ilClient::getDataDir ( )

get client datadir path

Returns
string client datadir path

Definition at line 530 of file class.ilClient.php.

References getId().

Referenced by create().

531  {
532  return ILIAS_DATA_DIR . "/" . $this->getId();
533  }
getId()
get client id
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ getDB()

ilClient::getDB ( )

get mysql version

Get DB object

Definition at line 205 of file class.ilClient.php.

References $db.

206  {
207  return $this->db;
208  }

◆ getDbHost()

ilClient::getDbHost ( )

get db host

Returns
string db host

Definition at line 316 of file class.ilClient.php.

317  {
318  return $this->ini->readVariable("db", "host");
319  }

◆ getDbName()

ilClient::getDbName ( )

get name of database

Returns
string name of database

Definition at line 334 of file class.ilClient.php.

Referenced by delete().

335  {
336  return $this->ini->readVariable("db", "name");
337  }
+ Here is the caller graph for this function:

◆ getDbPass()

ilClient::getDbPass ( )

get db password

Returns
string db password

Definition at line 388 of file class.ilClient.php.

389  {
390  return $this->ini->readVariable("db", "pass");
391  }

◆ getDbPort()

ilClient::getDbPort ( )

get db port

Returns
string db port

Definition at line 361 of file class.ilClient.php.

362  {
363  return $this->ini->readVariable("db", "port");
364  }

◆ getDBSetup()

ilClient::getDBSetup (   $cached = true)
Parameters
bool$cached
Returns

Definition at line 67 of file class.ilClient.php.

References $db_setup, and ilDbSetup\getNewInstanceForClient().

Referenced by checkDatabaseExists(), getSetting(), init(), provideGlobalDB(), and revokeGlobalDB().

68  {
69  require_once('./setup/classes/class.ilDbSetup.php');
70 
71  if ($cached) {
72  if (is_null($this->db_setup)) {
73  $this->db_setup = \ilDbSetup::getNewInstanceForClient($this);
74  }
75  return $this->db_setup;
76  }
77 
78 
79  return \ilDbSetup::getNewInstanceForClient($this);
80  }
static getNewInstanceForClient(\ilClient $client)
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ getDbSlaveActive()

ilClient::getDbSlaveActive ( )

get slave active

Returns
int active

Definition at line 407 of file class.ilClient.php.

408  {
409  return (int) $this->ini->readVariable("db", "slave_active");
410  }

◆ getDbSlaveHost()

ilClient::getDbSlaveHost ( )

get db slave host

Returns
string db host

Definition at line 426 of file class.ilClient.php.

427  {
428  return $this->ini->readVariable("db", "slave_host");
429  }

◆ getDbSlaveName()

ilClient::getDbSlaveName ( )

get name of slave database

Returns
string name of database

Definition at line 444 of file class.ilClient.php.

445  {
446  return $this->ini->readVariable("db", "slave_name");
447  }

◆ getDbSlavePass()

ilClient::getDbSlavePass ( )

get slave db password

Returns
string db password

Definition at line 498 of file class.ilClient.php.

499  {
500  return $this->ini->readVariable("db", "slave_pass");
501  }

◆ getDbSlavePort()

ilClient::getDbSlavePort ( )

get slave db port

Returns
string db port

Definition at line 471 of file class.ilClient.php.

472  {
473  return $this->ini->readVariable("db", "slave_port");
474  }

◆ getDbSlaveUser()

ilClient::getDbSlaveUser ( )

get slave db user

Returns
string db user

Definition at line 462 of file class.ilClient.php.

463  {
464  return $this->ini->readVariable("db", "slave_user");
465  }

◆ getDbType()

ilClient::getDbType ( )

get type of database

Returns
string name of database

Definition at line 516 of file class.ilClient.php.

Referenced by ilDbSetup\__construct(), and setDSN().

517  {
518  $val = $this->ini->readVariable("db", "type");
519  if ($val == "") {
520  return "mysql";
521  } else {
522  return $val;
523  }
524  }
+ Here is the caller graph for this function:

◆ getDbUser()

ilClient::getDbUser ( )

get db user

Returns
string db user

Definition at line 352 of file class.ilClient.php.

353  {
354  return $this->ini->readVariable("db", "user");
355  }

◆ getDefaultLanguage()

ilClient::getDefaultLanguage ( )

Definition at line 748 of file class.ilClient.php.

References getSetting().

749  {
750  return $this->getSetting("language");
751  }
getSetting($a_keyword)
read one value from settings table
+ Here is the call graph for this function:

◆ getDescription()

ilClient::getDescription ( )

get client description

Returns
string client description

Definition at line 180 of file class.ilClient.php.

181  {
182  return $this->ini->readVariable("client", "description");
183  }

◆ getError()

ilClient::getError ( )

get error message and clear error var

Returns
string error message

Definition at line 768 of file class.ilClient.php.

References $error.

769  {
771  $this->error = "";
772 
773  return $error;
774  }

◆ getId()

ilClient::getId ( )

get client id

Returns
string client id

Definition at line 143 of file class.ilClient.php.

References $id.

Referenced by __construct(), delete(), getDataDir(), ilDbSetup\getInstanceForClient(), getWebspaceDir(), and init().

144  {
145  return $this->id;
146  }
+ Here is the caller graph for this function:

◆ getName()

ilClient::getName ( )

get client name

Returns
string client name

Definition at line 162 of file class.ilClient.php.

163  {
164  return $this->ini->readVariable("client", "name");
165  }

◆ getNICkey()

ilClient::getNICkey ( )

get nic_key public

Returns
string nic_key

Definition at line 737 of file class.ilClient.php.

References getSetting(), and setNICkey().

Referenced by getURLStringForNIC().

738  {
739  $this->nic_key = $this->getSetting("nic_key");
740 
741  if (empty($this->nic_key)) {
742  $this->setNICkey();
743  }
744 
745  return $this->nic_key;
746  }
setNICkey()
set nic_key generate nic_key if nic_key field in cust table is empty.
getSetting($a_keyword)
read one value from settings table
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ getSetting()

ilClient::getSetting (   $a_keyword)

read one value from settings table

public

Parameters
stringkeyword
Returns
string value

Definition at line 587 of file class.ilClient.php.

References $ilDB, and getDBSetup().

Referenced by ilSetup\checkClientDatabase(), getDefaultLanguage(), and getNICkey().

588  {
589  global $ilDB;
590  if (!$this->getDBSetup()->isDatabaseInstalled() || !$ilDB) {
591  return false;
592  }
593  include_once './Services/Administration/classes/class.ilSetting.php';
594  $set = new ilSetting("common", true);
595 
596  return $set->get($a_keyword);
597  }
global $ilDB
getDBSetup($cached=true)
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ getURLStringForNIC()

ilClient::getURLStringForNIC (   $a_nic_url)
Parameters
stringurl to ilias nic server
Returns
string url with required parameters

Definition at line 629 of file class.ilClient.php.

References $_SERVER, $url, getAllSettings(), and getNICkey().

Referenced by updateNIC().

630  {
631  $settings = $this->getAllSettings();
632 
633  $inst_id = (empty($settings["inst_id"])) ? "0" : $settings["inst_id"];
634 
635  // send host information to ilias-nic
636  //#18132: removed ipadr, server_port, server_software, institution, contact_title, contact_position,
637  // contact_institution, contact_street, contact_pcode, contact_city, contact_country, contact_phone
638  $url = $a_nic_url .
639  "?cmd=getid" .
640  "&inst_id=" . rawurlencode($inst_id) .
641  "&hostname=" . rawurlencode($_SERVER["SERVER_NAME"]) .
642  "&inst_name=" . rawurlencode($this->ini->readVariable("client", "name")) .
643  "&inst_info=" . rawurlencode($this->ini->readVariable("client", "description")) .
644  "&http_path=" . rawurlencode(ILIAS_HTTP_PATH) .
645  "&contact_firstname=" . rawurlencode($settings["admin_firstname"]) .
646  "&contact_lastname=" . rawurlencode($settings["admin_lastname"]) .
647  "&contact_email=" . rawurlencode($settings["admin_email"]) .
648  "&nic_key=" . rawurlencode($this->getNICkey());
649 
650  return $url;
651  }
if((!isset($_SERVER['DOCUMENT_ROOT'])) OR(empty($_SERVER['DOCUMENT_ROOT']))) $_SERVER['DOCUMENT_ROOT']
getNICkey()
get nic_key public
getAllSettings()
read all values from settings table public
$url
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ getWebspaceDir()

ilClient::getWebspaceDir ( )

get client webspacedir path

Returns
string clietn webspacedir path

Definition at line 539 of file class.ilClient.php.

References getId().

Referenced by create().

540  {
541  return ILIAS_ABSOLUTE_PATH . "/" . ILIAS_WEB_DIR . "/" . $this->getId();
542  }
getId()
get client id
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ init()

ilClient::init ( )

init client load client.ini and set some constants

Returns
boolean

Definition at line 87 of file class.ilClient.php.

References getDBSetup(), and getId().

88  {
89  $this->ini = new ilIniFile($this->ini_file_path);
90 
91  // load defaults only if no client.ini was found
92  if (!@file_exists($this->ini_file_path)) {
93  //echo "<br>A-".$this->ini_file_path."-";
94  $this->ini->GROUPS = parse_ini_file($this->client_defaults, true);
95 
96  return false;
97  }
98 
99  // read client.ini
100  if (!$this->ini->read()) {
101  $this->error = get_class($this) . ": " . $this->ini->getError();
102 
103  return false;
104  }
105 
106  // only for ilias main
107  define("CLIENT_WEB_DIR", ILIAS_ABSOLUTE_PATH . "/" . ILIAS_WEB_DIR . "/" . $this->getId());
108  define("CLIENT_DATA_DIR", ILIAS_DATA_DIR . "/" . $this->getId());
109  define("DEVMODE", $this->ini->readVariable('system', 'DEVMODE'));
110  define("ROOT_FOLDER_ID", $this->ini->readVariable('system', 'ROOT_FOLDER_ID'));
111  define("SYSTEM_FOLDER_ID", $this->ini->readVariable('system', 'SYSTEM_FOLDER_ID'));
112  define("ROLE_FOLDER_ID", $this->ini->readVariable('system', 'ROLE_FOLDER_ID'));
113  define("ANONYMOUS_USER_ID", 13);
114  define("ANONYMOUS_ROLE_ID", 14);
115  define("SYSTEM_USER_ID", 6);
116  define("SYSTEM_ROLE_ID", 2);
117 
118  $this->db_exists = $this->getDBSetup()->isConnectable();
119  $this->getDBSetup()->provideGlobalDB();
120  if ($this->db_exists) {
121  $this->db_installed = $this->getDBSetup()->isDatabaseInstalled();
122  }
123 
124  return true;
125  }
getId()
get client id
INIFile Parser.
getDBSetup($cached=true)
+ Here is the call graph for this function:

◆ isInstalledDB()

ilClient::isInstalledDB ( $a_db)

check if client db is installed

Parameters
objectdb object
Returns
boolean true if installed

Definition at line 256 of file class.ilClient.php.

Referenced by checkDatabaseExists().

257  {
258  if (method_exists($a_db, 'loadModule')) {
259  $a_db->loadModule('Manager');
260  }
261  if (!$tables = $a_db->listTables()) {
262  return false;
263  }
264 
265  // check existence of some basic tables from ilias3 to determine if ilias3 is already installed in given database
266  if (in_array("object_data", $tables) and in_array("object_reference", $tables) and in_array("usr_data", $tables) and in_array("rbac_ua", $tables)) {
267  $this->db_installed = true;
268  return true;
269  }
270  $this->db_installed = false;
271  return false;
272  }
+ Here is the caller graph for this function:

◆ provideGlobalDB()

ilClient::provideGlobalDB ( )

Definition at line 128 of file class.ilClient.php.

References getDBSetup().

Referenced by ilSetup\checkClientDatabase(), ilSetup\checkClientLanguages(), and ilSetup\checkClientProxySettings().

129  {
130  $this->getDBSetup()->provideGlobalDB();
131  }
getDBSetup($cached=true)
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ reconnect()

ilClient::reconnect ( )

Definition at line 574 of file class.ilClient.php.

References connect().

575  {
576  $this->connect();
577  }
connect()
connect to client database
+ Here is the call graph for this function:

◆ revokeGlobalDB()

ilClient::revokeGlobalDB ( )

Definition at line 134 of file class.ilClient.php.

References getDBSetup().

Referenced by ilSetup\checkClientDatabase(), and ilSetup\checkClientLanguages().

135  {
136  $this->getDBSetup()->provideGlobalDB();
137  }
getDBSetup($cached=true)
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ setDbHost()

ilClient::setDbHost (   $a_str)

set the host

Parameters
string

Definition at line 306 of file class.ilClient.php.

307  {
308  $this->ini->setVariable("db", "host", $a_str);
309  }

◆ setDbName()

ilClient::setDbName (   $a_str)

set the name of database

Parameters
string

Definition at line 325 of file class.ilClient.php.

326  {
327  $this->ini->setVariable("db", "name", $a_str);
328  }

◆ setDbPass()

ilClient::setDbPass (   $a_str)

set db password

Parameters
string

Definition at line 379 of file class.ilClient.php.

380  {
381  $this->ini->setVariable("db", "pass", $a_str);
382  }

◆ setDbPort()

ilClient::setDbPort (   $a_str)

set db port

Parameters
string

Definition at line 370 of file class.ilClient.php.

371  {
372  $this->ini->setVariable("db", "port", $a_str);
373  }

◆ setDbSlaveActive()

ilClient::setDbSlaveActive (   $a_act)

set the slave active

Parameters
int

Definition at line 397 of file class.ilClient.php.

398  {
399  $this->ini->setVariable("db", "slave_active", (int) $a_act);
400  }

◆ setDbSlaveHost()

ilClient::setDbSlaveHost (   $a_str)

set the slave host

Parameters
string

Definition at line 416 of file class.ilClient.php.

417  {
418  $this->ini->setVariable("db", "slave_host", $a_str);
419  }

◆ setDbSlaveName()

ilClient::setDbSlaveName (   $a_str)

set the name of slave database

Parameters
string

Definition at line 435 of file class.ilClient.php.

436  {
437  $this->ini->setVariable("db", "slave_name", $a_str);
438  }

◆ setDbSlavePass()

ilClient::setDbSlavePass (   $a_str)

set slave db password

Parameters
string

Definition at line 489 of file class.ilClient.php.

490  {
491  $this->ini->setVariable("db", "slave_pass", $a_str);
492  }

◆ setDbSlavePort()

ilClient::setDbSlavePort (   $a_str)

set slave db port

Parameters
string

Definition at line 480 of file class.ilClient.php.

481  {
482  $this->ini->setVariable("db", "slave_port", $a_str);
483  }

◆ setDbSlaveUser()

ilClient::setDbSlaveUser (   $a_str)

set slave db user

Parameters
stringdb user

Definition at line 453 of file class.ilClient.php.

454  {
455  $this->ini->setVariable("db", "slave_user", $a_str);
456  }

◆ setDbType()

ilClient::setDbType (   $a_str)

set the type of database

Parameters
string

Definition at line 507 of file class.ilClient.php.

508  {
509  $this->ini->setVariable("db", "type", $a_str);
510  }

◆ setDbUser()

ilClient::setDbUser (   $a_str)

set db user

Parameters
stringdb user

Definition at line 343 of file class.ilClient.php.

344  {
345  $this->ini->setVariable("db", "user", $a_str);
346  }

◆ setDefaultLanguage()

ilClient::setDefaultLanguage (   $a_lang_key)

Definition at line 753 of file class.ilClient.php.

References setSetting().

754  {
755  $this->setSetting("language", $a_lang_key);
756  $this->ini->setVariable("language", "default", $a_lang_key);
757  $this->ini->write();
758 
759  return true;
760  }
setSetting($a_key, $a_val)
write one value to settings table public
+ Here is the call graph for this function:

◆ setDescription()

ilClient::setDescription (   $a_str)

set client description

Parameters
stringclient description

Definition at line 189 of file class.ilClient.php.

190  {
191  $this->ini->setVariable("client", "description", $a_str);
192  }

◆ setDSN()

ilClient::setDSN ( )

set the dsn and dsn_host

Definition at line 277 of file class.ilClient.php.

References getDbType().

278  {
279  switch ($this->getDbType()) {
280  case "postgres":
281  $db_port_str = "";
282  if (trim($this->getdbPort()) != "") {
283  $db_port_str = ":" . $this->getdbPort();
284  }
285  $this->dsn_host = "pgsql://" . $this->getdbUser() . ":" . $this->getdbPass() . "@" . $this->getdbHost() . $db_port_str;
286  $this->dsn = "pgsql://" . $this->getdbUser() . ":" . $this->getdbPass() . "@" . $this->getdbHost() . $db_port_str . "/" . $this->getdbName();
287  break;
288 
289  case "mysql":
290  case "innodb":
291  default:
292  $db_port_str = "";
293  if (trim($this->getdbPort()) != "") {
294  $db_port_str = ":" . $this->getdbPort();
295  }
296  $this->dsn_host = "mysql://" . $this->getdbUser() . ":" . $this->getdbPass() . "@" . $this->getdbHost() . $db_port_str;
297  $this->dsn = "mysql://" . $this->getdbUser() . ":" . $this->getdbPass() . "@" . $this->getdbHost() . $db_port_str . "/" . $this->getdbName();
298  break;
299  }
300  }
getDbType()
get type of database
+ Here is the call graph for this function:

◆ setError()

ilClient::setError (   $error_message)
Parameters
$error_message

Definition at line 780 of file class.ilClient.php.

Referenced by updateNIC().

781  {
782  $this->error = $error_message;
783  }
+ Here is the caller graph for this function:

◆ setId()

ilClient::setId (   $a_client_id)

set client id

Parameters
stringclient id

Definition at line 152 of file class.ilClient.php.

References $id.

153  {
154  $this->id = $a_client_id;
155  $this->webspace_dir = ILIAS_ABSOLUTE_PATH . "/" . ILIAS_WEB_DIR . "/" . $this->id;
156  }

◆ setName()

ilClient::setName (   $a_str)

set client name

Parameters
stringclient name

Definition at line 171 of file class.ilClient.php.

172  {
173  $this->ini->setVariable("client", "name", $a_str);
174  }

◆ setNICkey()

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

Returns
boolean

Definition at line 719 of file class.ilClient.php.

References $_SERVER, and setSetting().

Referenced by getNICkey().

720  {
721  mt_srand((double) microtime() * 1000000);
722  $nic_key = md5(str_replace(".", "", $_SERVER["SERVER_ADDR"]) +
723  mt_rand(100000, 999999));
724 
725  $this->setSetting("nic_key", $nic_key);
726 
727  $this->nic_key = $nic_key;
728 
729  return true;
730  }
if((!isset($_SERVER['DOCUMENT_ROOT'])) OR(empty($_SERVER['DOCUMENT_ROOT']))) $_SERVER['DOCUMENT_ROOT']
setSetting($a_key, $a_val)
write one value to settings table public
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ setSetting()

ilClient::setSetting (   $a_key,
  $a_val 
)

write one value to settings table public

Parameters
stringkeyword
stringvalue
Returns
boolean true on success

Definition at line 618 of file class.ilClient.php.

Referenced by setDefaultLanguage(), and setNICkey().

619  {
620  include_once './Services/Administration/classes/class.ilSetting.php';
621  $set = new ilSetting("common", true);
622  $set->set($a_key, $a_val);
623  }
+ Here is the caller graph for this function:

◆ updateNIC()

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

Parameters
void
Returns
string/array $ret error message or data array

Definition at line 667 of file class.ilClient.php.

References $info, $req, $response, $url, ilCurlConnection\_isCurlExtensionLoaded(), getAllSettings(), ilLoggerFactory\getLogger(), getURLStringForNIC(), and setError().

668  {
669  $max_redirects = 5;
670  $socket_timeout = 5;
671 
672  require_once(__DIR__ . "/../../Services/WebServices/Curl/classes/class.ilCurlConnection.php");
674  $this->setError("CURL-extension not loaded.");
675  return false;
676  }
677 
678  $url = $this->getURLStringForNIC($a_nic_url);
679  $req = new ilCurlConnection($url);
680  $req->init();
681 
682  $settings = $this->getAllSettings();
683  if ((bool) $settings['proxy_status'] && strlen($settings['proxy_host']) && strlen($settings['proxy_port'])) {
684  $req->setOpt(CURLOPT_HTTPPROXYTUNNEL, true);
685  $req->setOpt(CURLOPT_PROXY, $settings["proxy_host"]);
686  $req->setOpt(CURLOPT_PROXYPORT, $settings["proxy_port"]);
687  }
688 
689  $req->setOpt(CURLOPT_HEADER, 1);
690  $req->setOpt(CURLOPT_RETURNTRANSFER, 1);
691  $req->setOpt(CURLOPT_CONNECTTIMEOUT, $socket_timeout);
692  $req->setOpt(CURLOPT_MAXREDIRS, $max_redirects);
693  $response = $req->exec();
694 
695  $req->parseResponse($response);
696  $response_body = $req->getResponseBody();
697 
698  $info = $req->getInfo();
699  if ($info["http_code"] != "200") {
700  $this->setError("Could not connect to NIC-Server at '" . $url . "'");
701  return false;
702  }
703 
704  $this->nic_status = explode("\n", $response_body);
705 
706  ilLoggerFactory::getLogger('setup')->dump($this->nic_status);
707 
708  return true;
709  }
setError($error_message)
$req
Definition: getUserInfo.php:20
getURLStringForNIC($a_nic_url)
static _isCurlExtensionLoaded()
Check if curl extension is loaded.
getAllSettings()
read all values from settings table public
static getLogger($a_component_id)
Get component logger.
$url
$info
Definition: index.php:5
$response
+ Here is the call graph for this function:

◆ writeIni()

ilClient::writeIni ( )

write init

Parameters

Definition at line 891 of file class.ilClient.php.

892  {
893  $this->ini->write();
894  }

Field Documentation

◆ $client_defaults

ilClient::$client_defaults

Definition at line 20 of file class.ilClient.php.

◆ $db

ilClient::$db

Definition at line 31 of file class.ilClient.php.

Referenced by checkDatabaseExists(), connect(), and getDB().

◆ $db_exists

ilClient::$db_exists = false

Definition at line 17 of file class.ilClient.php.

◆ $db_installed

ilClient::$db_installed = false

Definition at line 18 of file class.ilClient.php.

◆ $db_setup

ilClient::$db_setup = null
protected

Definition at line 40 of file class.ilClient.php.

Referenced by getDBSetup().

◆ $dir

ilClient::$dir

Definition at line 15 of file class.ilClient.php.

◆ $error

ilClient::$error = ''

Definition at line 27 of file class.ilClient.php.

Referenced by getError().

◆ $id

ilClient::$id

Definition at line 14 of file class.ilClient.php.

Referenced by getId(), and setId().

◆ $ini

ilClient::$ini

Definition at line 35 of file class.ilClient.php.

◆ $name

ilClient::$name

Definition at line 16 of file class.ilClient.php.

◆ $nic_status

ilClient::$nic_status

Definition at line 23 of file class.ilClient.php.

◆ $setup_ok

ilClient::$setup_ok = false

Definition at line 22 of file class.ilClient.php.

◆ $status

ilClient::$status

Definition at line 21 of file class.ilClient.php.


The documentation for this class was generated from the following file: