ILIAS  release_5-3 Revision v5.3.23-19-g915713cf615
ilClient Class Reference

Client Management. More...

+ Collaboration diagram for ilClient:

Public Member Functions

 __construct ($a_client_id, $a_db_connections)
 ilClient constructor. More...
 
 getDBSetup ()
 
 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
 

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 44 of file class.ilClient.php.

References getId().

45  {
46  if ($a_client_id) {
47  $this->id = $a_client_id;
48  $this->ini_file_path = ILIAS_ABSOLUTE_PATH . "/" . ILIAS_WEB_DIR . "/" . $this->getId() . "/client.ini.php";
49  }
50 
51  $this->db_connections = $a_db_connections;
52 
53  // set path default.ini
54  $this->client_defaults = ILIAS_ABSOLUTE_PATH . "/setup/client.master.ini.php";
55  }
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 558 of file class.ilClient.php.

References $db, $GLOBALS, getDBSetup(), MDB2\isError(), and isInstalledDB().

559  {
560  return $this->getDBSetup()->isConnectable();
561 
562  //try to connect to database
563  $db = $this->db_connections->connectDB($this->dsn);
564  if (MDB2::isError($db)) {
565  return false;
566  }
567 
568  if (!$this->isInstalledDB($db)) {
569  return false;
570  }
571 
572  // #10633
573  if ($a_keep_connection) {
574  $GLOBALS["ilDB"] = $this->db;
575  $GLOBALS["DIC"]["ilDB"] = function ($c) {
576  return $GLOBALS["ilDB"];
577  };
578  }
579 
580  return true;
581  }
isError($data, $code=null)
Tell whether a value is a MDB2 error.
Definition: MDB2.php:599
isInstalledDB(&$a_db)
check if client db is installed
$GLOBALS['loaded']
Global hash that tracks already loaded includes.
+ Here is the call graph for this function:

◆ connect()

ilClient::connect ( )

connect to client database

Returns
boolean true on success

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

References $db, and $GLOBALS.

Referenced by reconnect().

201  {
202  // check parameters
203  // To support oracle tnsnames.ora dbname is not required
204  if (!$this->getdbHost() || !$this->getdbUser()) {
205  $this->error = "empty_fields";
206 
207  return false;
208  }
209 
210  include_once("./Services/Database/classes/class.ilDBWrapperFactory.php");
211  $this->db = ilDBWrapperFactory::getWrapper(
212  $this->getdbType(),
213  $this->ini->readVariable("db", "inactive_mysqli")
214  );
215  $this->db->setDBUser($this->getdbUser());
216  $this->db->setDBPort($this->getdbPort());
217  $this->db->setDBPassword($this->getdbPass());
218  $this->db->setDBHost($this->getdbHost());
219  $this->db->setDBName($this->getdbName());
220  $con = $this->db->connect(true);
221 
222  if (!$con) {
223  $this->error = "Database connection failed.";
224  return false;
225  }
226  $GLOBALS["ilDB"] = $this->db;
227 
228  if ($GLOBALS["DIC"]->offsetExists("ilDB")) {
229  $GLOBALS["DIC"]->offsetUnset("ilDB");
230  }
231 
232  $GLOBALS["DIC"]["ilDB"] = function ($c) {
233  return $GLOBALS["ilDB"];
234  };
235 
236  $this->db_exists = true;
237  return true;
238  }
$GLOBALS['loaded']
Global hash that tracks already loaded includes.
+ 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 828 of file class.ilClient.php.

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

829  {
830  //var_dump($this->getDataDir());exit;
831  // create base data dir
832  if (!ilUtil::makeDir($this->getDataDir())) {
833  $this->error = "could_not_create_base_data_dir :" . $this->getDataDir();
834  return false;
835  }
836 
837  // create sub dirs in base data dir
838  if (!ilUtil::makeDir($this->getDataDir() . "/mail")) {
839  $this->error = "could_not_create_mail_data_dir :" . $this->getDataDir() . "/mail";
840  return false;
841  }
842 
843  if (!ilUtil::makeDir($this->getDataDir() . "/lm_data")) {
844  $this->error = "could_not_create_lm_data_dir :" . $this->getDataDir() . "/lm_data";
845  return false;
846  }
847 
848  if (!ilUtil::makeDir($this->getDataDir() . "/forum")) {
849  $this->error = "could_not_create_forum_data_dir :" . $this->getDataDir() . "/forum";
850  return false;
851  }
852 
853  if (!ilUtil::makeDir($this->getDataDir() . "/files")) {
854  $this->error = "could_not_create_files_data_dir :" . $this->getDataDir() . "/files";
855  return false;
856  }
857 
858  // create base webspace dir
859  if (!ilUtil::makeDir($this->getWebspaceDir())) {
860  $this->error = "could_not_create_base_webspace_dir :" . $this->getWebspaceDir();
861  return false;
862  }
863 
864  // create sub dirs in base webspace dir
865  if (!ilUtil::makeDir($this->getWebspaceDir() . "/lm_data")) {
866  $this->error = "could_not_create_lm_webspace_dir :" . $this->getWebspaceDir() . "/lm_data";
867  return false;
868  }
869 
870  if (!ilUtil::makeDir($this->getWebspaceDir() . "/usr_images")) {
871  $this->error = "could_not_create_usr_images_webspace_dir :" . $this->getWebspaceDir() . "/usr_images";
872  return false;
873  }
874 
875  if (!ilUtil::makeDir($this->getWebspaceDir() . "/mobs")) {
876  $this->error = "could_not_create_mobs_webspace_dir :" . $this->getWebspaceDir() . "/mobs";
877  return false;
878  }
879 
880  if (!ilUtil::makeDir($this->getWebspaceDir() . "/css")) {
881  $this->error = "could_not_create_css_webspace_dir :" . $this->getWebspaceDir() . "/css";
882  return false;
883  }
884 
885  // write client ini
886  if (!$this->ini->write()) {
887  $this->error = get_class($this) . ": " . $this->ini->getError();
888  return false;
889  }
890 
891  return true;
892  }
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 802 of file class.ilClient.php.

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

803  {
804  if ($a_ini === true and file_exists(ILIAS_ABSOLUTE_PATH . "/" . ILIAS_WEB_DIR . "/" . $this->getId() . "/client.ini.php")) {
805  unlink(CLIENT_WEB_DIR . "/client.ini.php");
806  $msg[] = "ini_deleted";
807  }
808 
809  if ($a_db === true and $this->db_exists) {
810  $this->db->query("DROP DATABASE " . $this->getDbName());
811  $msg[] = "db_deleted";
812  }
813 
814  if ($a_files === true and file_exists(CLIENT_WEB_DIR) and is_dir(CLIENT_WEB_DIR)) {
815  // rmdir();
816  ilUtil::delDir(CLIENT_WEB_DIR);
817  ilUtil::delDir(CLIENT_DATA_DIR);
818  $msg[] = "files_deleted";
819  }
820 
821  return $msg;
822  }
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 613 of file class.ilClient.php.

Referenced by getURLStringForNIC(), and updateNIC().

614  {
615  include_once './Services/Administration/classes/class.ilSetting.php';
616  $set = new ilSetting("common", true);
617  return $set->getAll();
618  }
+ Here is the caller graph for this function:

◆ getDataDir()

ilClient::getDataDir ( )

get client datadir path

Returns
string client datadir path

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

References getId().

Referenced by create().

540  {
541  return ILIAS_DATA_DIR . "/" . $this->getId();
542  }
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 191 of file class.ilClient.php.

References $db.

192  {
193  return $this->db;
194  }

◆ getDbHost()

ilClient::getDbHost ( )

get db host

Returns
string db host

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

326  {
327  return $this->ini->readVariable("db", "host");
328  }

◆ getDbName()

ilClient::getDbName ( )

get name of database

Returns
string name of database

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

Referenced by delete().

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

◆ getDbPass()

ilClient::getDbPass ( )

get db password

Returns
string db password

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

398  {
399  return $this->ini->readVariable("db", "pass");
400  }

◆ getDbPort()

ilClient::getDbPort ( )

get db port

Returns
string db port

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

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

◆ getDBSetup()

ilClient::getDBSetup ( )
Returns

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

References ilDbSetup\getInstanceForClient().

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

62  {
63  require_once('./setup/classes/class.ilDbSetup.php');
64 
65  return ilDbSetup::getInstanceForClient($this);
66  }
static getInstanceForClient(\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 416 of file class.ilClient.php.

417  {
418  return (int) $this->ini->readVariable("db", "slave_active");
419  }

◆ getDbSlaveHost()

ilClient::getDbSlaveHost ( )

get db slave host

Returns
string db host

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

436  {
437  return $this->ini->readVariable("db", "slave_host");
438  }

◆ getDbSlaveName()

ilClient::getDbSlaveName ( )

get name of slave database

Returns
string name of database

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

454  {
455  return $this->ini->readVariable("db", "slave_name");
456  }

◆ getDbSlavePass()

ilClient::getDbSlavePass ( )

get slave db password

Returns
string db password

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

508  {
509  return $this->ini->readVariable("db", "slave_pass");
510  }

◆ getDbSlavePort()

ilClient::getDbSlavePort ( )

get slave db port

Returns
string db port

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

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

◆ getDbSlaveUser()

ilClient::getDbSlaveUser ( )

get slave db user

Returns
string db user

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

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

◆ getDbType()

ilClient::getDbType ( )

get type of database

Returns
string name of database

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

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

526  {
527  $val = $this->ini->readVariable("db", "type");
528  if ($val == "") {
529  return "mysql";
530  } else {
531  return $val;
532  }
533  }
+ Here is the caller graph for this function:

◆ getDbUser()

ilClient::getDbUser ( )

get db user

Returns
string db user

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

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

◆ getDefaultLanguage()

ilClient::getDefaultLanguage ( )

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

References getSetting().

758  {
759  return $this->getSetting("language");
760  }
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 166 of file class.ilClient.php.

167  {
168  return $this->ini->readVariable("client", "description");
169  }

◆ getError()

ilClient::getError ( )

get error message and clear error var

Returns
string error message

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

References $error.

778  {
780  $this->error = "";
781 
782  return $error;
783  }

◆ getId()

ilClient::getId ( )

get client id

Returns
string client id

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

References $id.

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

130  {
131  return $this->id;
132  }
+ Here is the caller graph for this function:

◆ getName()

ilClient::getName ( )

get client name

Returns
string client name

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

149  {
150  return $this->ini->readVariable("client", "name");
151  }

◆ getNICkey()

ilClient::getNICkey ( )

get nic_key public

Returns
string nic_key

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

References getSetting(), and setNICkey().

Referenced by getURLStringForNIC().

747  {
748  $this->nic_key = $this->getSetting("nic_key");
749 
750  if (empty($this->nic_key)) {
751  $this->setNICkey();
752  }
753 
754  return $this->nic_key;
755  }
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 596 of file class.ilClient.php.

References $ilDB, and getDBSetup().

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

597  {
598  global $ilDB;
599  if (!$this->getDBSetup()->isDatabaseInstalled() || !$ilDB) {
600  return false;
601  }
602  include_once './Services/Administration/classes/class.ilSetting.php';
603  $set = new ilSetting("common", true);
604 
605  return $set->get($a_keyword);
606  }
global $ilDB
+ 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 638 of file class.ilClient.php.

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

Referenced by updateNIC().

639  {
640  $settings = $this->getAllSettings();
641 
642  $inst_id = (empty($settings["inst_id"])) ? "0" : $settings["inst_id"];
643 
644  // send host information to ilias-nic
645  //#18132: removed ipadr, server_port, server_software, institution, contact_title, contact_position,
646  // contact_institution, contact_street, contact_pcode, contact_city, contact_country, contact_phone
647  $url = $a_nic_url .
648  "?cmd=getid" .
649  "&inst_id=" . rawurlencode($inst_id) .
650  "&hostname=" . rawurlencode($_SERVER["SERVER_NAME"]) .
651  "&inst_name=" . rawurlencode($this->ini->readVariable("client", "name")) .
652  "&inst_info=" . rawurlencode($this->ini->readVariable("client", "description")) .
653  "&http_path=" . rawurlencode(ILIAS_HTTP_PATH) .
654  "&contact_firstname=" . rawurlencode($settings["admin_firstname"]) .
655  "&contact_lastname=" . rawurlencode($settings["admin_lastname"]) .
656  "&contact_email=" . rawurlencode($settings["admin_email"]) .
657  "&nic_key=" . rawurlencode($this->getNICkey());
658 
659  return $url;
660  }
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 548 of file class.ilClient.php.

References getId().

Referenced by create().

549  {
550  return ILIAS_ABSOLUTE_PATH . "/" . ILIAS_WEB_DIR . "/" . $this->getId();
551  }
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 73 of file class.ilClient.php.

References getDBSetup(), and getId().

74  {
75  $this->ini = new ilIniFile($this->ini_file_path);
76 
77  // load defaults only if no client.ini was found
78  if (!@file_exists($this->ini_file_path)) {
79  //echo "<br>A-".$this->ini_file_path."-";
80  $this->ini->GROUPS = parse_ini_file($this->client_defaults, true);
81 
82  return false;
83  }
84 
85  // read client.ini
86  if (!$this->ini->read()) {
87  $this->error = get_class($this) . ": " . $this->ini->getError();
88 
89  return false;
90  }
91 
92  // only for ilias main
93  define("CLIENT_WEB_DIR", ILIAS_ABSOLUTE_PATH . "/" . ILIAS_WEB_DIR . "/" . $this->getId());
94  define("CLIENT_DATA_DIR", ILIAS_DATA_DIR . "/" . $this->getId());
95  define("DEVMODE", $this->ini->readVariable('system', 'DEVMODE'));
96  define("ROOT_FOLDER_ID", $this->ini->readVariable('system', 'ROOT_FOLDER_ID'));
97  define("SYSTEM_FOLDER_ID", $this->ini->readVariable('system', 'SYSTEM_FOLDER_ID'));
98  define("ROLE_FOLDER_ID", $this->ini->readVariable('system', 'ROLE_FOLDER_ID'));
99  define("ANONYMOUS_USER_ID", 13);
100  define("ANONYMOUS_ROLE_ID", 14);
101  define("SYSTEM_USER_ID", 6);
102  define("SYSTEM_ROLE_ID", 2);
103 
104  $this->db_exists = $this->getDBSetup()->isConnectable();
105  $this->getDBSetup()->provideGlobalDB();
106  if ($this->db_exists) {
107  $this->db_installed = $this->getDBSetup()->isDatabaseInstalled();
108  }
109 
110  return true;
111  }
getId()
get client id
INIFile Parser.
+ 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 245 of file class.ilClient.php.

Referenced by checkDatabaseExists().

246  {
247  if (method_exists($a_db, 'loadModule')) {
248  $a_db->loadModule('Manager');
249  }
250  if (!$tables = $a_db->listTables()) {
251  return false;
252  }
253 
254  // check existence of some basic tables from ilias3 to determine if ilias3 is already installed in given database
255  if (in_array("object_data", $tables) and in_array("object_reference", $tables) and in_array("usr_data", $tables) and in_array("rbac_ua", $tables)) {
256  $this->db_installed = true;
257  return true;
258  }
259  $this->db_installed = false;
260  return false;
261  }
+ Here is the caller graph for this function:

◆ provideGlobalDB()

ilClient::provideGlobalDB ( )

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

References getDBSetup().

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

115  {
116  $this->getDBSetup()->provideGlobalDB();
117  }
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ reconnect()

ilClient::reconnect ( )

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

References connect().

584  {
585  $this->connect();
586  }
connect()
connect to client database
+ Here is the call graph for this function:

◆ revokeGlobalDB()

ilClient::revokeGlobalDB ( )

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

References getDBSetup().

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

121  {
122  $this->getDBSetup()->provideGlobalDB();
123  }
+ 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 315 of file class.ilClient.php.

316  {
317  $this->ini->setVariable("db", "host", $a_str);
318  }

◆ setDbName()

ilClient::setDbName (   $a_str)

set the name of database

Parameters
string

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

335  {
336  $this->ini->setVariable("db", "name", $a_str);
337  }

◆ setDbPass()

ilClient::setDbPass (   $a_str)

set db password

Parameters
string

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

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

◆ setDbPort()

ilClient::setDbPort (   $a_str)

set db port

Parameters
string

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

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

◆ setDbSlaveActive()

ilClient::setDbSlaveActive (   $a_act)

set the slave active

Parameters
int

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

407  {
408  $this->ini->setVariable("db", "slave_active", (int) $a_act);
409  }

◆ setDbSlaveHost()

ilClient::setDbSlaveHost (   $a_str)

set the slave host

Parameters
string

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

426  {
427  $this->ini->setVariable("db", "slave_host", $a_str);
428  }

◆ setDbSlaveName()

ilClient::setDbSlaveName (   $a_str)

set the name of slave database

Parameters
string

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

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

◆ setDbSlavePass()

ilClient::setDbSlavePass (   $a_str)

set slave db password

Parameters
string

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

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

◆ setDbSlavePort()

ilClient::setDbSlavePort (   $a_str)

set slave db port

Parameters
string

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

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

◆ setDbSlaveUser()

ilClient::setDbSlaveUser (   $a_str)

set slave db user

Parameters
stringdb user

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

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

◆ setDbType()

ilClient::setDbType (   $a_str)

set the type of database

Parameters
string

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

517  {
518  $this->ini->setVariable("db", "type", $a_str);
519  }

◆ setDbUser()

ilClient::setDbUser (   $a_str)

set db user

Parameters
stringdb user

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

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

◆ setDefaultLanguage()

ilClient::setDefaultLanguage (   $a_lang_key)

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

References setSetting().

763  {
764  $this->setSetting("language", $a_lang_key);
765  $this->ini->setVariable("language", "default", $a_lang_key);
766  $this->ini->write();
767 
768  return true;
769  }
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 175 of file class.ilClient.php.

176  {
177  $this->ini->setVariable("client", "description", $a_str);
178  }

◆ setDSN()

ilClient::setDSN ( )

set the dsn and dsn_host

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

References array, and getDbType().

267  {
268  switch ($this->getDbType()) {
269  case "oracle":
270  //$this->dsn_host = "oci8://".$this->getdbUser().":".$this->getdbPass()."@".$this->getdbHost();
271  $this->dsn_host = array(
272  'phptype' => 'oci8',
273  'hostspec' => $this->getdbHost(),
274  'username' => $this->getdbUser(),
275  'port' => $this->getdbPort(),
276  'password' => $this->getdbPass(),
277  );
278  //$this->dsn = "oci8://".$this->getdbUser().":".$this->getdbPass()."@".$this->getdbHost()."/?service=".$this->getdbName();
279  $this->dsn = $this->dsn = array(
280  'phptype' => 'oci8',
281  'hostspec' => $this->getdbHost(),
282  'username' => $this->getdbUser(),
283  'port' => $this->getdbPort(),
284  'password' => $this->getdbPass(),
285  'service' => $this->getdbName()
286  );
287  break;
288 
289  case "postgres":
290  $db_port_str = "";
291  if (trim($this->getdbPort()) != "") {
292  $db_port_str = ":" . $this->getdbPort();
293  }
294  $this->dsn_host = "pgsql://" . $this->getdbUser() . ":" . $this->getdbPass() . "@" . $this->getdbHost() . $db_port_str;
295  $this->dsn = "pgsql://" . $this->getdbUser() . ":" . $this->getdbPass() . "@" . $this->getdbHost() . $db_port_str . "/" . $this->getdbName();
296  break;
297 
298  case "mysql":
299  case "innodb":
300  default:
301  $db_port_str = "";
302  if (trim($this->getdbPort()) != "") {
303  $db_port_str = ":" . $this->getdbPort();
304  }
305  $this->dsn_host = "mysql://" . $this->getdbUser() . ":" . $this->getdbPass() . "@" . $this->getdbHost() . $db_port_str;
306  $this->dsn = "mysql://" . $this->getdbUser() . ":" . $this->getdbPass() . "@" . $this->getdbHost() . $db_port_str . "/" . $this->getdbName();
307  break;
308  }
309  }
Create styles array
The data for the language used.
getDbType()
get type of database
+ Here is the call graph for this function:

◆ setError()

ilClient::setError (   $error_message)
Parameters
$error_message

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

Referenced by updateNIC().

790  {
791  $this->error = $error_message;
792  }
+ Here is the caller graph for this function:

◆ setId()

ilClient::setId (   $a_client_id)

set client id

Parameters
stringclient id

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

References $id.

139  {
140  $this->id = $a_client_id;
141  $this->webspace_dir = ILIAS_ABSOLUTE_PATH . "/" . ILIAS_WEB_DIR . "/" . $this->id;
142  }

◆ setName()

ilClient::setName (   $a_str)

set client name

Parameters
stringclient name

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

158  {
159  $this->ini->setVariable("client", "name", $a_str);
160  }

◆ 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 728 of file class.ilClient.php.

References $_SERVER, and setSetting().

Referenced by getNICkey().

729  {
730  mt_srand((double) microtime()*1000000);
731  $nic_key = md5(str_replace(".", "", $_SERVER["SERVER_ADDR"]) +
732  mt_rand(100000, 999999));
733 
734  $this->setSetting("nic_key", $nic_key);
735 
736  $this->nic_key = $nic_key;
737 
738  return true;
739  }
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 627 of file class.ilClient.php.

Referenced by setDefaultLanguage(), and setNICkey().

628  {
629  include_once './Services/Administration/classes/class.ilSetting.php';
630  $set = new ilSetting("common", true);
631  $set->set($a_key, $a_val);
632  }
+ 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 676 of file class.ilClient.php.

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

677  {
678  $max_redirects = 5;
679  $socket_timeout = 5;
680 
681  require_once(__DIR__ . "/../../Services/WebServices/Curl/classes/class.ilCurlConnection.php");
683  $this->setError("CURL-extension not loaded.");
684  return false;
685  }
686 
687  $url = $this->getURLStringForNIC($a_nic_url);
688  $req = new ilCurlConnection($url);
689  $req->init();
690 
691  $settings = $this->getAllSettings();
692  if ((bool) $settings['proxy_status'] && strlen($settings['proxy_host']) && strlen($settings['proxy_port'])) {
693  $req->setOpt(CURLOPT_HTTPPROXYTUNNEL, true);
694  $req->setOpt(CURLOPT_PROXY, $settings["proxy_host"]);
695  $req->setOpt(CURLOPT_PROXYPORT, $settings["proxy_port"]);
696  }
697 
698  $req->setOpt(CURLOPT_HEADER, 1);
699  $req->setOpt(CURLOPT_RETURNTRANSFER, 1);
700  $req->setOpt(CURLOPT_CONNECTTIMEOUT, $socket_timeout);
701  $req->setOpt(CURLOPT_MAXREDIRS, $max_redirects);
702  $response = $req->exec();
703 
704  $req->parseResponse($response);
705  $response_body = $req->getResponseBody();
706 
707  $info = $req->getInfo();
708  if ($info["http_code"] != "200") {
709  $this->setError("Could not connect to NIC-Server at '" . $url . "'");
710  return false;
711  }
712 
713  $this->nic_status = explode("\n", $response_body);
714 
715  ilLoggerFactory::getLogger('setup')->dump($nic_status);
716 
717  return true;
718  }
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 900 of file class.ilClient.php.

901  {
902  $this->ini->write();
903  }

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.

◆ $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.

Referenced by updateNIC().

◆ $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: