/** * load all clients into clientlist */ function init() { // set path to directory where clients reside $d = dir($this->path); // $tmpPath = getcwd(); // chdir ($this->path); // get available lang-files while ($entry = $d->read()) { if (is_file($this->path . "/" . $entry . "/client.ini.php")) { $client = new ilClient($entry, $this->db_connections); $client->init(); $this->clients[$entry] = $client; unset($client); } } // chdir($tmpPath); }
/** * Clone source client into current client * @param array form data * @return boolean */ function cloneFromSource($source_id) { // Getting source and targets $source = new ilClient($source_id, $this->db_connections); $source->init(); $target = $this->client; // ************************************************ // ** COPY FILES // Cleaning up datadir if (!ilUtil::delDir($target->getDataDir())) { $this->error = "Could not delete data dir {$target->getDataDir}()"; //return false; } // Create empty datadir if (!ilUtil::makeDir($target->getDataDir())) { $this->error = "could_not_create_base_data_dir :" . $target->getDataDir(); return false; } // Copying datadir if (!ilUtil::rCopy($source->getDataDir(), $target->getDataDir())) { $this->error = "clone_datadircopyfail"; $target->ini->write(); return false; } // Cleaning up Webspacedir if (!ilUtil::delDir($target->getWebspaceDir())) { $this->error = "Could not delete webspace dir {$target->getWebspaceDir}()"; //return false; } // Create empty Webspacedir if (!ilUtil::makeDir($target->getWebspaceDir())) { $this->error = "could_not_create_base_webspace_dir :" . $target->getWebspaceDir(); return false; } // Copying Webspacedir if (!ilUtil::rCopy($source->getWebspaceDir(), $target->getWebspaceDir())) { $this->error = "clone_websipacedircopyfail"; $target->ini->write(); return false; } // Restore ini file $target->ini->write(); // ************************************************ // ** COPY DATABASE $source->connect(); if (!$source->db) { $this->error = "Source database connection failed."; return false; } $target->connect(); if (!$target->db) { $this->error = "Target database connection failed."; return false; } $source->connect(); $srcTables = $source->db->query("SHOW TABLES"); $target->connect(); // drop all tables of the target db $tarTables = $target->db->query("SHOW TABLES"); foreach ($tarTables->fetchAll() as $cTable) { $target->db->query("DROP TABLE IF EXISTS " . $cTable[0]); } foreach ($srcTables->fetchAll() as $cTable) { $drop = $target->db->query("DROP TABLE IF EXISTS " . $cTable[0]); $create = $target->db->query("CREATE TABLE " . $cTable[0] . " LIKE " . $source->getDbName() . "." . $cTable[0]); if (!$create) { $error = true; } $insert = $target->db->query("INSERT INTO " . $cTable[0] . " SELECT * FROM " . $source->getDbName() . "." . $cTable[0]); } return true; }
/** * set defualt client */ function changeDefaultClient() { if ($_POST["form"]) { $client = new ilClient($_POST["form"]["default"], $this->setup->db_connections); if (!$client->init()) { $this->setup->raiseError($this->lng->txt("no_valid_client_id"), $this->setup->error_obj->MESSAGE); } $status = $this->setup->getStatus($client); if ($status["finish"]["status"]) { $this->setup->ini->setVariable("clients", "default", $client->getId()); $this->setup->ini->write(); $message = "default_client_changed"; } else { $message = "client_setup_not_finished"; } } ilUtil::sendInfo($this->lng->txt($message), true); ilUtil::redirect("setup.php"); }