19declare(strict_types=1);
31 return hash(
"sha256", self::class);
36 return "The NIC key is registered at the ILIAS Open Source society";
46 $http_config = $environment->getConfigFor(
"http");
48 new \ilNICKeyStoredObjective($this->config),
49 new \ilSettingsFactoryExistsObjective(),
50 new \ilHttpConfigStoredObjective($http_config),
57 $factory = $environment->
getResource(
Setup\Environment::RESOURCE_SETTINGS_FACTORY);
58 $settings = $factory->settingsFor(
"common");
60 $systemfolder_config = $environment->getConfigFor(
"systemfolder");
61 $http_config = $environment->getConfigFor(
"http");
65 "CURL extension is required to register NIC."
70 $old_settings =
$GLOBALS[
"ilSetting"] ??
null;
82 if (
$req->getInfo()[
"http_code"] !=
"200") {
83 $settings->set(
"nic_enabled",
"-1");
85 "Could not connect to NIC server at \"" . self::ILIAS_NIC_SERVER .
"\""
89 $status = explode(
"\n",
$req->getResponseBody());
91 $nic_id = ($status[2] ??
'');
93 $settings->set(
"nic_enabled",
"-1");
95 "Did not receive valid installation id from " .
96 "NIC server (\"" . self::ILIAS_NIC_SERVER .
"\") for URL: $url" .
101 $settings->set(
"nic_enabled",
"1");
102 $settings->set(
"inst_id", $status[2]);
105 $GLOBALS[
"ilSetting"] = $old_settings;
115 $factory = $environment->getResource(
Setup\Environment::RESOURCE_SETTINGS_FACTORY);
116 $settings = $factory->settingsFor(
"common");
117 return ($settings->get(
"inst_id") ===
'0') && $this->config->getRegisterNIC();
122 $error_code = trim((
string) ($nic_response_parts[1] ??
''));
125 switch ($error_code) {
127 $message =
"NIC server could not connect to database";
131 $message =
"NIC server could not execute query";
135 $message =
"The installation name was missing in request, please check your " .
136 "configuration (systemfolder.client.name)";
140 $message =
"The http path or contact's lastname was missing in request, please check " .
141 "your configuration (http.path or systemfolder.contact.lastname)";
145 $message =
"The contact's firstname was missing in request, please check your " .
146 "configuration (systemfolder.contact.firstname)";
150 $message =
"The contact's email address was missing in request, please check your " .
151 "configuration (systemfolder.contact.email)";
160 $inst_id = (string) $settings->get(
'inst_id',
'0');
162 $host_name = parse_url($http_path)[
"host"];
164 $url = self::ILIAS_NIC_SERVER .
166 "&inst_id=" . rawurlencode($inst_id) .
167 "&hostname=" . rawurlencode($host_name) .
168 "&inst_name=" . rawurlencode($systemfolder_config->
getClientName() ??
'') .
170 "&http_path=" . rawurlencode($http_path) .
173 "&contact_email=" . rawurlencode($systemfolder_config->
getContactEMail()) .
174 "&nic_key=" . rawurlencode($settings->get(
"nic_key"));
184 $req->setOpt(CURLOPT_HEADER, 1);
185 $req->setOpt(CURLOPT_RETURNTRANSFER, 1);
186 $req->setOpt(CURLOPT_CONNECTTIMEOUT, self::SOCKET_TIMEOUT);
187 $req->setOpt(CURLOPT_MAXREDIRS, self::MAX_REDIRECTS);
Customizing of pimple-DIC for ILIAS.
Signals that some goal won't be achievable by actions of the system ever.
static _isCurlExtensionLoaded()
getPreconditions(Setup\Environment $environment)
getCurlConnection(string $url)
achieve(Setup\Environment $environment)
getURLStringForNIC($settings, \ilSystemFolderSetupConfig $systemfolder_config, \ilHttpSetupConfig $http_config)
isApplicable(Setup\Environment $environment)
@inheritDoc
getRegistrationProblem(array $nic_response_parts)
An environment holds resources to be used in the setup process.
getResource(string $id)
Consumers of this method should check if the result is what they expect, e.g.
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
catch(\Exception $e) $req