15 return hash(
"sha256", self::class);
20 return "The NIC key is registered at the ILIAS Open Source society";
30 $http_config = $environment->getConfigFor(
"http");
32 new \ilNICKeyStoredObjective($this->config),
33 new \ilSettingsFactoryExistsObjective(),
34 new \ilHttpConfigStoredObjective($http_config)
40 $factory = $environment->getResource(Setup\Environment::RESOURCE_SETTINGS_FACTORY);
41 $settings =
$factory->settingsFor(
"common");
42 $systemfolder_config = $environment->getConfigFor(
"systemfolder");
43 $http_config = $environment->getConfigFor(
"http");
46 throw new Setup\UnachievableException(
47 "CURL extension is required to register NIC." 52 $old_settings =
$GLOBALS[
"ilSetting"] ?? null;
60 if (
$req->getInfo()[
"http_code"] !=
"200") {
61 $settings->set(
"nic_enabled",
"-1");
62 throw new Setup\UnachievableException(
63 "Could not connect to NIC server at \"" . self::ILIAS_NIC_SERVER .
"\"" 67 $status = explode(
"\n",
$req->getResponseBody());
68 $settings->set(
"nic_enabled",
"1");
69 $settings->set(
"inst_id", $status[2]);
71 $GLOBALS[
"ilSetting"] = $old_settings;
78 $inst_id = $settings->get(
"inst_id", 0);
80 $host_name = parse_url($http_path)[
"host"];
82 $url = self::ILIAS_NIC_SERVER .
84 "&inst_id=" . rawurlencode($inst_id) .
85 "&hostname=" . rawurlencode($host_name) .
86 "&inst_name=" . rawurlencode($systemfolder_config->
getClientName()) .
88 "&http_path=" . rawurlencode($http_path) .
91 "&contact_email=" . rawurlencode($systemfolder_config->
getContactEMail()) .
92 "&nic_key=" . rawurlencode($settings->get(
"nic_key"));
99 $req = new \ilCurlConnection($url);
102 $req->setOpt(CURLOPT_HEADER, 1);
103 $req->setOpt(CURLOPT_RETURNTRANSFER, 1);
104 $req->setOpt(CURLOPT_CONNECTTIMEOUT, self::SOCKET_TIMEOUT);
105 $req->setOpt(CURLOPT_MAXREDIRS, self::MAX_REDIRECTS);
getPreconditions(Setup\Environment $environment)
getCurlConnection(string $url)
static _isCurlExtensionLoaded()
Check if curl extension is loaded.
if(!defined('PATH_SEPARATOR')) $GLOBALS['_PEAR_default_error_mode']
An environment holds resources to be used in the setup process.
achieve(Setup\Environment $environment)
getURLStringForNIC($settings, \ilSystemFolderSetupConfig $systemfolder_config, \ilHttpSetupConfig $http_config)