ILIAS  release_7 Revision v7.30-3-g800a261c036
class.ilChatroomMetricsCollectedObjective.php
Go to the documentation of this file.
1<?php
2
3/* Copyright (c) 2021 Daniel Weise <daniel.weise@concepts-and-training.de> Extended GPL, see docs/LICENSE */
4
6use ILIAS\DI;
7
9{
10 protected function getTentativePreconditions(Setup\Environment $environment) : array
11 {
12 return [
13 new \ilIniFilesLoadedObjective(),
14 new \ilDatabaseInitializedObjective(),
15 new \ilFileSystemComponentDataDirectoryCreatedObjective("chatroom")
16 ];
17 }
18
19 protected function collectFrom(Setup\Environment $environment, Setup\Metrics\Storage $storage) : void
20 {
21 $db = $environment->getResource(Setup\Environment::RESOURCE_DATABASE);
22
23 // ATTENTION: This is a total abomination. It only exists to allow various
24 // sub components of the various readers to run. This is a memento to the
25 // fact, that dependency injection is something we want. Currently, every
26 // component could just service locate the whole world via the global $DIC.
27 $DIC = $GLOBALS["DIC"];
28 $GLOBALS["DIC"] = new DI\Container();
29 $GLOBALS["DIC"]["ilDB"] = $db;
30 $GLOBALS["DIC"]["ilBench"] = null;
31
32 $chatAdministrations = ilObject::_getObjectsByType('chta');
33 $chatAdministration = current($chatAdministrations);
34
35 $chat_admin = new ilChatroomAdmin((int) $chatAdministration['obj_id']);
36 $settings = $chat_admin->loadGeneralSettings();
37
38 if (count($settings) > 0) {
39 $storage->storeConfigText(
40 "address",
41 $settings['address'] ?? "",
42 "IP-Address/FQN of Chat Server."
43 );
44 $storage->storeConfigText(
45 "port",
46 $settings['port'] ?? "",
47 "Port of the chat server."
48 );
49 $storage->storeConfigText(
50 "sub_directory",
51 $settings['sub_directory'] ?? "",
52 "http(s)://[IP/Domain]/[SUB_DIRECTORY]"
53 );
54
55 $storage->storeConfigText(
56 "protocol",
57 $settings['protocol'] ?? "",
58 "Protocol used for connection (http/https)."
59 );
60
61 if ($settings['protocol'] === 'https') {
62 $cert = new Setup\Metrics\Metric(
63 Setup\Metrics\Metric::STABILITY_CONFIG,
64 Setup\Metrics\Metric::TYPE_TEXT,
65 $settings['cert'] ?? ""
66 );
67 $key = new Setup\Metrics\Metric(
68 Setup\Metrics\Metric::STABILITY_CONFIG,
69 Setup\Metrics\Metric::TYPE_TEXT,
70 $settings['key'] ?? ""
71 );
72 $dhparam = new Setup\Metrics\Metric(
73 Setup\Metrics\Metric::STABILITY_CONFIG,
74 Setup\Metrics\Metric::TYPE_TEXT,
75 $settings['dhparam'] ?? ""
76 );
78 Setup\Metrics\Metric::STABILITY_CONFIG,
79 Setup\Metrics\Metric::TYPE_COLLECTION,
80 [
81 "cert" => $cert,
82 "key" => $key,
83 "dhparam" => $dhparam,
84 ],
85 "Holds parameters for https."
86 );
87 $storage->store("https", $https);
88 }
89
90 $storage->storeConfigText(
91 "log",
92 $settings['log'] ?? "",
93 "Absolute server path to the chat server's log file."
94 );
95 $storage->storeConfigText(
96 "log_level",
97 $settings['log_level'] ?? "",
98 "Possible values are emerg, alert, crit error, warning, notice, info, debug, silly."
99 );
100 $storage->storeConfigText(
101 "error_log",
102 $settings['error_log'] ?? "",
103 "Absolute server path to the chat server's error log file."
104 );
105
106 if ($settings['ilias_proxy']) {
107 $ilias_url = new Setup\Metrics\Metric(
108 Setup\Metrics\Metric::STABILITY_CONFIG,
109 Setup\Metrics\Metric::TYPE_TEXT,
110 $settings['ilias_url'] ?? ""
111 );
112 $ilias_proxy = new Setup\Metrics\Metric(
113 Setup\Metrics\Metric::STABILITY_CONFIG,
114 Setup\Metrics\Metric::TYPE_COLLECTION,
115 [
116 "ilias_url" => $ilias_url
117 ],
118 "Holds proxy url if ILIAS proxy is enabled."
119 );
120 $storage->store("ilias_proxy", $ilias_proxy);
121 } else {
122 $storage->storeConfigBool(
123 "ilias_proxy",
124 false,
125 "Holds proxy url if ILIAS proxy is enabled."
126 );
127 }
128
129 if ($settings['client_proxy']) {
130 $client_url = new Setup\Metrics\Metric(
131 Setup\Metrics\Metric::STABILITY_CONFIG,
132 Setup\Metrics\Metric::TYPE_TEXT,
133 $settings['client_url'] ?? ""
134 );
135 $client_proxy = new Setup\Metrics\Metric(
136 Setup\Metrics\Metric::STABILITY_CONFIG,
137 Setup\Metrics\Metric::TYPE_COLLECTION,
138 [
139 "client_url" => $client_url
140 ],
141 "Holds proxy url if client proxy is enabled."
142 );
143 $storage->store("client_proxy", $client_proxy);
144 } else {
145 $storage->storeConfigBool(
146 "client_proxy",
147 false,
148 "Holds proxy url if client proxy is enabled."
149 );
150 }
151
152 if ($settings['deletion_mode']) {
153 $deletion_unit = new Setup\Metrics\Metric(
154 Setup\Metrics\Metric::STABILITY_CONFIG,
155 Setup\Metrics\Metric::TYPE_TEXT,
156 $settings['deletion_unit'] ?? ""
157 );
158 $deletion_value = new Setup\Metrics\Metric(
159 Setup\Metrics\Metric::STABILITY_CONFIG,
160 Setup\Metrics\Metric::TYPE_TEXT,
161 (string) $settings['deletion_value'] ?? ""
162 );
163 $deletion_time = new Setup\Metrics\Metric(
164 Setup\Metrics\Metric::STABILITY_CONFIG,
165 Setup\Metrics\Metric::TYPE_TEXT,
166 $settings['deletion_time'] ?? ""
167 );
168 $deletion_mode = new Setup\Metrics\Metric(
169 Setup\Metrics\Metric::STABILITY_CONFIG,
170 Setup\Metrics\Metric::TYPE_COLLECTION,
171 [
172 "deletion_unit" => $deletion_unit,
173 "deletion_value" => $deletion_value,
174 "deletion_time" => $deletion_time,
175 ],
176 "Holds information about deletion process."
177 );
178 $storage->store("deletion_mode", $deletion_mode);
179 }
180 }
181
182 $GLOBALS["DIC"] = $DIC;
183 }
184}
if(!defined('PATH_SEPARATOR')) $GLOBALS['_PEAR_default_error_mode']
Definition: PEAR.php:64
An exception for terminatinating execution or to throw for unit testing.
Customizing of pimple-DIC for ILIAS.
Definition: Container.php:19
A metric is something we can measure about the system.
Definition: Metric.php:18
Class ilChatroomAdmin.
collectFrom(Setup\Environment $environment, Setup\Metrics\Storage $storage)
static _getObjectsByType($a_obj_type="", $a_owner="")
Get objects by type.
global $DIC
Definition: goto.php:24
$https
Definition: imgupload.php:19
An environment holds resources to be used in the setup process.
Definition: Environment.php:12
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...