ILIAS  release_8 Revision v8.19
All Data Structures Namespaces Files Functions Variables Modules Pages
class.ilChatroomMetricsCollectedObjective.php
Go to the documentation of this file.
1 <?php
2 
19 declare(strict_types=1);
20 
21 use ILIAS\DI;
22 use ILIAS\Setup;
23 
24 class ilChatroomMetricsCollectedObjective extends Setup\Metrics\CollectedObjective
25 {
26  protected function getTentativePreconditions(Setup\Environment $environment): array
27  {
28  return [
32  ];
33  }
34 
35  protected function collectFrom(Setup\Environment $environment, Setup\Metrics\Storage $storage): void
36  {
37  $db = $environment->getResource(Setup\Environment::RESOURCE_DATABASE);
38 
39  // ATTENTION: This is a total abomination. It only exists to allow various
40  // sub components of the various readers to run. This is a memento to the
41  // fact, that dependency injection is something we want. Currently, every
42  // component could just service locate the whole world via the global $DIC.
43  $DIC = $GLOBALS['DIC'];
44  $GLOBALS['DIC'] = new DI\Container();
45  $GLOBALS['DIC']['ilDB'] = $db;
46  $GLOBALS['DIC']['ilBench'] = null;
47 
48  $chatAdministrations = ilObject::_getObjectsByType('chta');
49  $chatAdministration = current($chatAdministrations);
50 
51  $chat_admin = new ilChatroomAdmin((int) $chatAdministration['obj_id']);
52  $settings = $chat_admin->loadGeneralSettings();
53 
54  if (count($settings) > 0) {
55  $storage->storeConfigText(
56  'address',
57  $settings['address'] ?? '',
58  'IP-Address/FQN of Chat Server.'
59  );
60  $storage->storeConfigText(
61  'port',
62  (string) ($settings['port'] ?? ''),
63  'Port of the chat server.'
64  );
65  $storage->storeConfigText(
66  'sub_directory',
67  $settings['sub_directory'] ?? '',
68  'http(s)://[IP/Domain]/[SUB_DIRECTORY]'
69  );
70 
71  $storage->storeConfigText(
72  'protocol',
73  $settings['protocol'] ?? '',
74  'Protocol used for connection (http/https).'
75  );
76 
77  if (isset($settings['protocol']) && $settings['protocol'] === 'https') {
78  $cert = new Setup\Metrics\Metric(
79  Setup\Metrics\Metric::STABILITY_CONFIG,
80  Setup\Metrics\Metric::TYPE_TEXT,
81  $settings['cert'] ?? ''
82  );
83  $key = new Setup\Metrics\Metric(
84  Setup\Metrics\Metric::STABILITY_CONFIG,
85  Setup\Metrics\Metric::TYPE_TEXT,
86  $settings['key'] ?? ''
87  );
88  $dhparam = new Setup\Metrics\Metric(
89  Setup\Metrics\Metric::STABILITY_CONFIG,
90  Setup\Metrics\Metric::TYPE_TEXT,
91  $settings['dhparam'] ?? ''
92  );
93  $https = new Setup\Metrics\Metric(
94  Setup\Metrics\Metric::STABILITY_CONFIG,
95  Setup\Metrics\Metric::TYPE_COLLECTION,
96  [
97  'cert' => $cert,
98  'key' => $key,
99  'dhparam' => $dhparam,
100  ],
101  'Holds parameters for https.'
102  );
103  $storage->store('https', $https);
104  }
105 
106  $storage->storeConfigText(
107  'log',
108  (string) ($settings['log'] ?? ''),
109  "Absolute server path to the chat server's log file."
110  );
111  $storage->storeConfigText(
112  'log_level',
113  $settings['log_level'] ?? '',
114  'Possible values are emerg, alert, crit error, warning, notice, info, debug, silly.'
115  );
116  $storage->storeConfigText(
117  'error_log',
118  $settings['error_log'] ?? '',
119  "Absolute server path to the chat server's error log file."
120  );
121 
122  if (isset($settings['ilias_proxy']) && $settings['ilias_proxy']) {
123  $ilias_url = new Setup\Metrics\Metric(
124  Setup\Metrics\Metric::STABILITY_CONFIG,
125  Setup\Metrics\Metric::TYPE_TEXT,
126  $settings['ilias_url'] ?? ''
127  );
128  $ilias_proxy = new Setup\Metrics\Metric(
129  Setup\Metrics\Metric::STABILITY_CONFIG,
130  Setup\Metrics\Metric::TYPE_COLLECTION,
131  [
132  'ilias_url' => $ilias_url
133  ],
134  'Holds proxy url if ILIAS proxy is enabled.'
135  );
136  $storage->store('ilias_proxy', $ilias_proxy);
137  } else {
138  $storage->storeConfigBool(
139  'ilias_proxy',
140  false,
141  'Holds proxy url if ILIAS proxy is enabled.'
142  );
143  }
144 
145  if (isset($settings['client_proxy']) && $settings['client_proxy']) {
146  $client_url = new Setup\Metrics\Metric(
147  Setup\Metrics\Metric::STABILITY_CONFIG,
148  Setup\Metrics\Metric::TYPE_TEXT,
149  $settings['client_url'] ?? ''
150  );
151  $client_proxy = new Setup\Metrics\Metric(
152  Setup\Metrics\Metric::STABILITY_CONFIG,
153  Setup\Metrics\Metric::TYPE_COLLECTION,
154  [
155  'client_url' => $client_url
156  ],
157  'Holds proxy url if client proxy is enabled.'
158  );
159  $storage->store('client_proxy', $client_proxy);
160  } else {
161  $storage->storeConfigBool(
162  'client_proxy',
163  false,
164  'Holds proxy url if client proxy is enabled.'
165  );
166  }
167 
168  if (isset($settings['deletion_mode']) && $settings['deletion_mode']) {
169  $deletion_unit = new Setup\Metrics\Metric(
170  Setup\Metrics\Metric::STABILITY_CONFIG,
171  Setup\Metrics\Metric::TYPE_TEXT,
172  $settings['deletion_unit'] ?? ''
173  );
174  $deletion_value = new Setup\Metrics\Metric(
175  Setup\Metrics\Metric::STABILITY_CONFIG,
176  Setup\Metrics\Metric::TYPE_TEXT,
177  (string) ($settings['deletion_value'] ?? '')
178  );
179  $deletion_time = new Setup\Metrics\Metric(
180  Setup\Metrics\Metric::STABILITY_CONFIG,
181  Setup\Metrics\Metric::TYPE_TEXT,
182  $settings['deletion_time'] ?? ''
183  );
184  $deletion_mode = new Setup\Metrics\Metric(
185  Setup\Metrics\Metric::STABILITY_CONFIG,
186  Setup\Metrics\Metric::TYPE_COLLECTION,
187  [
188  'deletion_unit' => $deletion_unit,
189  'deletion_value' => $deletion_value,
190  'deletion_time' => $deletion_time,
191  ],
192  'Holds information about deletion process.'
193  );
194  $storage->store(
195  'deletion_mode',
196  $deletion_mode
197  );
198  }
199  }
200 
201  $GLOBALS['DIC'] = $DIC;
202  }
203 }
collectFrom(Setup\Environment $environment, Setup\Metrics\Storage $storage)
array $settings
Setting values (LTI parameters, custom parameters and local parameters).
Definition: System.php:200
static _getObjectsByType(string $obj_type="", int $owner=null)
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
Definition: Container.php:19
global $DIC
Definition: feed.php:28
Class ilChatroomAdmin.
if(!defined('PATH_SEPARATOR')) $GLOBALS['_PEAR_default_error_mode']
Definition: PEAR.php:64
string $key
Consumer key/client ID value.
Definition: System.php:193
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
$https
Definition: imgupload.php:35
An environment holds resources to be used in the setup process.
Definition: Environment.php:27