Rev 967 | Rev 970 | Go to most recent revision | Details | Compare with Previous | Last modification | View Log | RSS feed
Rev | Author | Line No. | Line |
---|---|---|---|
635 | daniel-mar | 1 | <?php |
2 | |||
3 | /* |
||
4 | * OIDplus 2.0 |
||
772 | daniel-mar | 5 | * Copyright 2019 - 2022 Daniel Marschall, ViaThinkSoft |
635 | daniel-mar | 6 | * |
7 | * Licensed under the Apache License, Version 2.0 (the "License"); |
||
8 | * you may not use this file except in compliance with the License. |
||
9 | * You may obtain a copy of the License at |
||
10 | * |
||
11 | * http://www.apache.org/licenses/LICENSE-2.0 |
||
12 | * |
||
13 | * Unless required by applicable law or agreed to in writing, software |
||
14 | * distributed under the License is distributed on an "AS IS" BASIS, |
||
15 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
||
16 | * See the License for the specific language governing permissions and |
||
17 | * limitations under the License. |
||
18 | */ |
||
19 | |||
20 | if (!defined('INSIDE_OIDPLUS')) die(); |
||
21 | |||
22 | class OIDplusPagePublicObjects extends OIDplusPagePluginPublic { |
||
23 | |||
24 | private function get_treeicon_root($ot) { |
||
25 | $dirs = glob(OIDplus::localpath().'plugins/'.'*'.'/objectTypes/'.$ot::ns()); |
||
26 | |||
27 | if (count($dirs) == 0) { |
||
28 | $icon = null; |
||
29 | } else { |
||
30 | $dir = $dirs[0]; |
||
805 | daniel-mar | 31 | $icon_name = $ot::treeIconFilename('root'); |
800 | daniel-mar | 32 | if (!$icon_name) return null; |
33 | $icon = $dir.'/'.$icon_name; |
||
34 | if (!file_exists($icon)) return null; |
||
635 | daniel-mar | 35 | $icon = substr($icon, strlen(OIDplus::localpath())); |
36 | } |
||
37 | |||
38 | return $icon; |
||
39 | } |
||
40 | |||
41 | private function ra_change_rec($id, $old_ra, $new_ra) { |
||
42 | if (is_null($old_ra)) $old_ra = ''; |
||
43 | OIDplus::db()->query("update ###objects set ra_email = ?, updated = ".OIDplus::db()->sqlDate()." where id = ? and ".OIDplus::db()->getSlang()->isNullFunction('ra_email',"''")." = ?", array($new_ra, $id, $old_ra)); |
||
44 | |||
45 | $res = OIDplus::db()->query("select id from ###objects where parent = ? and ".OIDplus::db()->getSlang()->isNullFunction('ra_email',"''")." = ?", array($id, $old_ra)); |
||
46 | while ($row = $res->fetch_array()) { |
||
47 | $this->ra_change_rec($row['id'], $old_ra, $new_ra); |
||
48 | } |
||
49 | } |
||
50 | |||
51 | public function action($actionID, $params) { |
||
52 | |||
53 | // Action: Delete |
||
54 | // Method: POST |
||
55 | // Parameters: id |
||
56 | // Outputs: <0 Error, =0 Success |
||
57 | if ($actionID == 'Delete') { |
||
58 | _CheckParamExists($params, 'id'); |
||
59 | $id = $params['id']; |
||
60 | $obj = OIDplusObject::parse($id); |
||
61 | if ($obj === null) throw new OIDplusException(_L('%1 action failed because object "%2" cannot be parsed!','DELETE',$id)); |
||
62 | |||
790 | daniel-mar | 63 | if (!OIDplus::db()->query("select id from ###objects where id = ?", array($id))->any()) { |
635 | daniel-mar | 64 | throw new OIDplusException(_L('Object %1 does not exist',$id)); |
65 | } |
||
66 | |||
67 | // Check if permitted |
||
68 | if (!$obj->userHasParentalWriteRights()) throw new OIDplusException(_L('Authentication error. Please log in as the superior RA to delete this OID.')); |
||
69 | |||
70 | foreach (OIDplus::getPagePlugins() as $plugin) { |
||
71 | if ($plugin->implementsFeature('1.3.6.1.4.1.37476.2.5.2.3.3')) { |
||
72 | $plugin->beforeObjectDelete($id); |
||
73 | } |
||
74 | } |
||
75 | |||
76 | OIDplus::logger()->log("[WARN]OID($id)+[?WARN/!OK]SUPOIDRA($id)?/[?INFO/!OK]A?", "Object '$id' (recursively) deleted"); |
||
77 | OIDplus::logger()->log("[CRIT]OIDRA($id)!", "Lost ownership of object '$id' because it was deleted"); |
||
78 | |||
79 | if ($parentObj = $obj->getParent()) { |
||
80 | $parent_oid = $parentObj->nodeId(); |
||
81 | OIDplus::logger()->log("[WARN]OID($parent_oid)", "Object '$id' (recursively) deleted"); |
||
82 | } |
||
83 | |||
84 | // Delete object |
||
85 | OIDplus::db()->query("delete from ###objects where id = ?", array($id)); |
||
86 | |||
87 | // Delete orphan stuff |
||
88 | foreach (OIDplus::getEnabledObjectTypes() as $ot) { |
||
89 | do { |
||
90 | $res = OIDplus::db()->query("select tchild.id from ###objects tchild " . |
||
91 | "left join ###objects tparent on tparent.id = tchild.parent " . |
||
92 | "where tchild.parent <> ? and tchild.id like ? and tparent.id is null;", array($ot::root(), $ot::root().'%')); |
||
790 | daniel-mar | 93 | if (!$res->any()) break; |
635 | daniel-mar | 94 | |
95 | while ($row = $res->fetch_array()) { |
||
96 | $id_to_delete = $row['id']; |
||
97 | OIDplus::logger()->log("[CRIT]OIDRA($id_to_delete)!", "Lost ownership of object '$id_to_delete' because one of the superior objects ('$id') was recursively deleted"); |
||
98 | OIDplus::db()->query("delete from ###objects where id = ?", array($id_to_delete)); |
||
99 | } |
||
100 | } while (true); |
||
101 | } |
||
102 | OIDplus::db()->query("delete from ###asn1id where well_known = ? and oid not in (select id from ###objects where id like 'oid:%')", array(false)); |
||
103 | OIDplus::db()->query("delete from ###iri where well_known = ? and oid not in (select id from ###objects where id like 'oid:%')", array(false)); |
||
104 | |||
105 | foreach (OIDplus::getPagePlugins() as $plugin) { |
||
106 | if ($plugin->implementsFeature('1.3.6.1.4.1.37476.2.5.2.3.3')) { |
||
107 | $plugin->afterObjectDelete($id); |
||
108 | } |
||
109 | } |
||
110 | |||
111 | return array("status" => 0); |
||
112 | } |
||
113 | |||
114 | // Action: Update |
||
115 | // Method: POST |
||
116 | // Parameters: id, ra_email, comment, iris, asn1ids, confidential |
||
117 | // Outputs: <0 Error, =0 Success, with following bitfields for further information: |
||
118 | // 1 = RA is not registered |
||
119 | // 2 = RA is not registered, but it cannot be invited |
||
120 | // 4 = OID is a well-known OID, so RA, ASN.1 and IRI identifiers were reset |
||
121 | else if ($actionID == 'Update') { |
||
122 | _CheckParamExists($params, 'id'); |
||
123 | $id = $params['id']; |
||
124 | $obj = OIDplusObject::parse($id); |
||
125 | if ($obj === null) throw new OIDplusException(_L('%1 action failed because object "%2" cannot be parsed!','UPDATE',$id)); |
||
126 | |||
790 | daniel-mar | 127 | if (!OIDplus::db()->query("select id from ###objects where id = ?", array($id))->any()) { |
635 | daniel-mar | 128 | throw new OIDplusException(_L('Object %1 does not exist',$id)); |
129 | } |
||
130 | |||
131 | // Check if permitted |
||
132 | if (!$obj->userHasParentalWriteRights()) throw new OIDplusException(_L('Authentication error. Please log in as the superior RA to update this OID.')); |
||
133 | |||
134 | foreach (OIDplus::getPagePlugins() as $plugin) { |
||
135 | if ($plugin->implementsFeature('1.3.6.1.4.1.37476.2.5.2.3.3')) { |
||
136 | $plugin->beforeObjectUpdateSuperior($id, $params); |
||
137 | } |
||
138 | } |
||
139 | |||
140 | // First, do a simulation for ASN.1 IDs and IRIs to check if there are any problems (then an Exception will be thrown) |
||
141 | if ($obj::ns() == 'oid') { |
||
142 | if (!$obj->isWellKnown()) { |
||
143 | if (isset($params['iris'])) { |
||
144 | $ids = ($params['iris'] == '') ? array() : explode(',',$params['iris']); |
||
145 | $ids = array_map('trim',$ids); |
||
146 | $obj->replaceIris($ids, true); |
||
147 | } |
||
148 | |||
149 | if (isset($params['asn1ids'])) { |
||
150 | $ids = ($params['asn1ids'] == '') ? array() : explode(',',$params['asn1ids']); |
||
151 | $ids = array_map('trim',$ids); |
||
152 | $obj->replaceAsn1Ids($ids, true); |
||
153 | } |
||
154 | } |
||
155 | } |
||
156 | |||
157 | // RA E-Mail change |
||
158 | if (isset($params['ra_email'])) { |
||
159 | // Validate RA email address |
||
160 | $new_ra = $params['ra_email']; |
||
161 | if ($obj::ns() == 'oid') { |
||
162 | if ($obj->isWellKnown()) { |
||
163 | $new_ra = ''; |
||
164 | } |
||
165 | } |
||
166 | if (!empty($new_ra) && !OIDplus::mailUtils()->validMailAddress($new_ra)) { |
||
167 | throw new OIDplusException(_L('Invalid RA email address')); |
||
168 | } |
||
169 | |||
170 | // Change RA recursively |
||
171 | $res = OIDplus::db()->query("select ra_email from ###objects where id = ?", array($id)); |
||
172 | if ($row = $res->fetch_array()) { |
||
173 | $current_ra = $row['ra_email']; |
||
174 | if ($new_ra != $current_ra) { |
||
175 | OIDplus::logger()->log("[INFO]OID($id)+[?INFO/!OK]SUPOIDRA($id)?/[?INFO/!OK]A?", "RA of object '$id' changed from '$current_ra' to '$new_ra'"); |
||
176 | OIDplus::logger()->log("[WARN]RA($current_ra)!", "Lost ownership of object '$id' due to RA transfer of superior RA / admin."); |
||
177 | OIDplus::logger()->log("[INFO]RA($new_ra)!", "Gained ownership of object '$id' due to RA transfer of superior RA / admin."); |
||
178 | if ($parentObj = $obj->getParent()) { |
||
179 | $parent_oid = $parentObj->nodeId(); |
||
180 | OIDplus::logger()->log("[INFO]OID($parent_oid)", "RA of object '$id' changed from '$current_ra' to '$new_ra'"); |
||
181 | } |
||
182 | $this->ra_change_rec($id, $current_ra, $new_ra); // Recursively change inherited RAs |
||
183 | } |
||
184 | } |
||
185 | } |
||
186 | |||
187 | // Log if confidentially flag was changed |
||
188 | OIDplus::logger()->log("[INFO]OID($id)+[?INFO/!OK]SUPOIDRA($id)?/[?INFO/!OK]A?", "Identifiers/Confidential flag of object '$id' updated"); // TODO: Check if they were ACTUALLY updated! |
||
189 | if ($parentObj = $obj->getParent()) { |
||
190 | $parent_oid = $parentObj->nodeId(); |
||
191 | OIDplus::logger()->log("[INFO]OID($parent_oid)", "Identifiers/Confidential flag of object '$id' updated"); // TODO: Check if they were ACTUALLY updated! |
||
192 | } |
||
193 | |||
194 | // Replace ASN.1 IDs und IRIs |
||
195 | if ($obj::ns() == 'oid') { |
||
196 | if (!$obj->isWellKnown()) { |
||
197 | if (isset($params['iris'])) { |
||
198 | $ids = ($params['iris'] == '') ? array() : explode(',',$params['iris']); |
||
199 | $ids = array_map('trim',$ids); |
||
200 | $obj->replaceIris($ids, false); |
||
201 | } |
||
202 | |||
203 | if (isset($params['asn1ids'])) { |
||
204 | $ids = ($params['asn1ids'] == '') ? array() : explode(',',$params['asn1ids']); |
||
205 | $ids = array_map('trim',$ids); |
||
206 | $obj->replaceAsn1Ids($ids, false); |
||
207 | } |
||
208 | } |
||
209 | |||
210 | // TODO: Check if any identifiers have been actually changed, |
||
211 | // and log it to OID($id), OID($parent), ... (see above) |
||
212 | } |
||
213 | |||
214 | if (isset($params['confidential'])) { |
||
215 | $confidential = $params['confidential'] == 'true'; |
||
216 | OIDplus::db()->query("UPDATE ###objects SET confidential = ? WHERE id = ?", array($confidential, $id)); |
||
217 | } |
||
218 | |||
219 | if (isset($params['comment'])) { |
||
220 | $comment = $params['comment']; |
||
221 | OIDplus::db()->query("UPDATE ###objects SET comment = ? WHERE id = ?", array($comment, $id)); |
||
222 | } |
||
223 | |||
224 | OIDplus::db()->query("UPDATE ###objects SET updated = ".OIDplus::db()->sqlDate()." WHERE id = ?", array($id)); |
||
225 | |||
226 | $status = 0; |
||
227 | |||
228 | if (!empty($new_ra)) { |
||
229 | $res = OIDplus::db()->query("select ra_name from ###ra where email = ?", array($new_ra)); |
||
230 | $invitePlugin = OIDplus::getPluginByOid('1.3.6.1.4.1.37476.2.5.2.4.2.92'); // OIDplusPageRaInvite |
||
790 | daniel-mar | 231 | if (!$res->any()) $status = !is_null($invitePlugin) && OIDplus::config()->getValue('ra_invitation_enabled') ? 1 : 2; |
635 | daniel-mar | 232 | } |
233 | |||
234 | if ($obj::ns() == 'oid') { |
||
235 | if ($obj->isWellKnown()) { |
||
236 | $status += 4; |
||
237 | } |
||
238 | } |
||
239 | |||
240 | foreach (OIDplus::getPagePlugins() as $plugin) { |
||
241 | if ($plugin->implementsFeature('1.3.6.1.4.1.37476.2.5.2.3.3')) { |
||
242 | $plugin->afterObjectUpdateSuperior($id, $params); |
||
243 | } |
||
244 | } |
||
245 | |||
246 | return array("status" => $status); |
||
247 | } |
||
248 | |||
249 | // Action: Update2 |
||
250 | // Method: POST |
||
251 | // Parameters: id, title, description |
||
252 | // Outputs: <0 Error, =0 Success |
||
253 | else if ($actionID == 'Update2') { |
||
254 | _CheckParamExists($params, 'id'); |
||
255 | $id = $params['id']; |
||
256 | $obj = OIDplusObject::parse($id); |
||
257 | if ($obj === null) throw new OIDplusException(_L('%1 action failed because object "%2" cannot be parsed!','UPDATE2',$id)); |
||
258 | |||
790 | daniel-mar | 259 | if (!OIDplus::db()->query("select id from ###objects where id = ?", array($id))->any()) { |
635 | daniel-mar | 260 | throw new OIDplusException(_L('Object %1 does not exist',$id)); |
261 | } |
||
262 | |||
263 | // Check if allowed |
||
264 | if (!$obj->userHasWriteRights()) throw new OIDplusException(_L('Authentication error. Please log in as the RA to update this OID.')); |
||
265 | |||
266 | foreach (OIDplus::getPagePlugins() as $plugin) { |
||
267 | if ($plugin->implementsFeature('1.3.6.1.4.1.37476.2.5.2.3.3')) { |
||
268 | $plugin->beforeObjectUpdateSelf($id, $params); |
||
269 | } |
||
270 | } |
||
271 | |||
272 | OIDplus::logger()->log("[INFO]OID($id)+[?INFO/!OK]OIDRA($id)?/[?INFO/!OK]A?", "Title/Description of object '$id' updated"); |
||
273 | |||
274 | if (isset($params['title'])) { |
||
275 | $title = $params['title']; |
||
276 | OIDplus::db()->query("UPDATE ###objects SET title = ? WHERE id = ?", array($title, $id)); |
||
277 | } |
||
278 | |||
279 | if (isset($params['description'])) { |
||
280 | $description = $params['description']; |
||
281 | OIDplus::db()->query("UPDATE ###objects SET description = ? WHERE id = ?", array($description, $id)); |
||
282 | } |
||
283 | |||
284 | OIDplus::db()->query("UPDATE ###objects SET updated = ".OIDplus::db()->sqlDate()." WHERE id = ?", array($id)); |
||
285 | |||
286 | foreach (OIDplus::getPagePlugins() as $plugin) { |
||
287 | if ($plugin->implementsFeature('1.3.6.1.4.1.37476.2.5.2.3.3')) { |
||
288 | $plugin->afterObjectUpdateSelf($id, $params); |
||
289 | } |
||
290 | } |
||
291 | |||
292 | return array("status" => 0); |
||
293 | } |
||
294 | |||
295 | // Generate UUID |
||
296 | else if ($actionID == 'generate_uuid') { |
||
297 | $uuid = gen_uuid(); |
||
298 | if (!$uuid) return array("status" => 1); |
||
299 | return array( |
||
300 | "status" => 0, |
||
301 | "uuid" => $uuid, |
||
302 | "intval" => substr(uuid_to_oid($uuid),strlen('2.25.')) |
||
303 | ); |
||
304 | } |
||
305 | |||
306 | // Action: Insert |
||
307 | // Method: POST |
||
308 | // Parameters: parent, id, ra_email, confidential, iris, asn1ids |
||
309 | // Outputs: status=<0 Error, =0 Success, with following bitfields for further information: |
||
310 | // 1 = RA is not registered |
||
311 | // 2 = RA is not registered, but it cannot be invited |
||
312 | // 4 = OID is a well-known OID, so RA, ASN.1 and IRI identifiers were reset |
||
313 | else if ($actionID == 'Insert') { |
||
314 | // Check if you have write rights on the parent (to create a new object) |
||
315 | _CheckParamExists($params, 'parent'); |
||
316 | $objParent = OIDplusObject::parse($params['parent']); |
||
317 | if ($objParent === null) throw new OIDplusException(_L('%1 action failed because parent object "%2" cannot be parsed!','INSERT',$params['parent'])); |
||
318 | |||
790 | daniel-mar | 319 | if (!$objParent->isRoot() && (!OIDplus::db()->query("select id from ###objects where id = ?", array($objParent->nodeId()))->any())) { |
635 | daniel-mar | 320 | throw new OIDplusException(_L('Parent object %1 does not exist','".($objParent->nodeId())."')); |
321 | } |
||
322 | |||
323 | if (!$objParent->userHasWriteRights()) throw new OIDplusException(_L('Authentication error. Please log in as the correct RA to insert an OID at this arc.')); |
||
324 | |||
325 | // Check if the ID is valid |
||
326 | _CheckParamExists($params, 'id'); |
||
327 | if ($params['id'] == '') throw new OIDplusException(_L('ID may not be empty')); |
||
328 | |||
772 | daniel-mar | 329 | // For the root objects, let the user also enter a WEID |
330 | if ($objParent::ns() == 'oid') { |
||
331 | if (strtolower(substr(trim($params['id']),0,5)) === 'weid:') { |
||
332 | if ($objParent->isRoot()) { |
||
333 | $params['id'] = WeidOidConverter::weid2oid($params['id']); |
||
334 | if ($params['id'] === false) { |
||
335 | throw new OIDplusException(_L('Invalid WEID')); |
||
336 | } |
||
337 | } else { |
||
338 | throw new OIDplusException(_L('You can use the WEID syntax only at your object tree root.')); |
||
339 | } |
||
340 | } |
||
341 | } |
||
342 | |||
635 | daniel-mar | 343 | // Determine absolute OID name |
344 | // Note: At addString() and parse(), the syntax of the ID will be checked |
||
345 | $id = $objParent->addString($params['id']); |
||
346 | |||
347 | // Check, if the OID exists |
||
348 | $test = OIDplus::db()->query("select id from ###objects where id = ?", array($id)); |
||
790 | daniel-mar | 349 | if ($test->any()) { |
635 | daniel-mar | 350 | throw new OIDplusException(_L('Object %1 already exists!',$id)); |
351 | } |
||
352 | |||
353 | $obj = OIDplusObject::parse($id); |
||
953 | daniel-mar | 354 | if ($obj === null) throw new OIDplusException(_L('%1 action failed because object "%2" cannot be parsed!','INSERT',$id)); |
635 | daniel-mar | 355 | |
356 | foreach (OIDplus::getPagePlugins() as $plugin) { |
||
357 | if ($plugin->implementsFeature('1.3.6.1.4.1.37476.2.5.2.3.3')) { |
||
358 | $plugin->beforeObjectInsert($id, $params); |
||
359 | } |
||
360 | } |
||
361 | |||
362 | // First simulate if there are any problems of ASN.1 IDs und IRIs |
||
363 | if ($obj::ns() == 'oid') { |
||
364 | if (!$obj->isWellKnown()) { |
||
365 | if (isset($params['iris'])) { |
||
366 | $ids = ($params['iris'] == '') ? array() : explode(',',$params['iris']); |
||
367 | $ids = array_map('trim',$ids); |
||
368 | $obj->replaceIris($ids, true); |
||
369 | } |
||
370 | |||
371 | if (isset($params['asn1ids'])) { |
||
372 | $ids = ($params['asn1ids'] == '') ? array() : explode(',',$params['asn1ids']); |
||
373 | $ids = array_map('trim',$ids); |
||
374 | $obj->replaceAsn1Ids($ids, true); |
||
375 | } |
||
376 | } |
||
377 | } |
||
378 | |||
379 | // Apply superior RA change |
||
380 | $parent = $params['parent']; |
||
381 | $ra_email = isset($params['ra_email']) ? $params['ra_email'] : ''; |
||
382 | if ($obj::ns() == 'oid') { |
||
383 | if ($obj->isWellKnown()) { |
||
384 | $ra_email = ''; |
||
385 | } |
||
386 | } |
||
387 | if (!empty($ra_email) && !OIDplus::mailUtils()->validMailAddress($ra_email)) { |
||
388 | throw new OIDplusException(_L('Invalid RA email address')); |
||
389 | } |
||
390 | |||
391 | OIDplus::logger()->log("[INFO]OID($parent)+[INFO]OID($id)+[?INFO/!OK]OIDRA($parent)?/[?INFO/!OK]A?", "Object '$id' created, ".(empty($ra_email) ? "without defined RA" : "given to RA '$ra_email'")).", superior object is '$parent'"; |
||
392 | if (!empty($ra_email)) { |
||
393 | OIDplus::logger()->log("[INFO]RA($ra_email)!", "Gained ownership of newly created object '$id'"); |
||
394 | } |
||
395 | |||
396 | $confidential = isset($params['confidential']) ? ($params['confidential'] == 'true') : false; |
||
397 | $comment = isset($params['comment']) ? $params['comment'] : ''; |
||
398 | $title = ''; |
||
399 | $description = ''; |
||
400 | |||
401 | if (strlen($id) > OIDplus::baseConfig()->getValue('LIMITS_MAX_ID_LENGTH')) { |
||
402 | $maxlen = OIDplus::baseConfig()->getValue('LIMITS_MAX_ID_LENGTH'); |
||
403 | throw new OIDplusException(_L('The identifier %1 is too long (max allowed length: %2)',$id,$maxlen)); |
||
404 | } |
||
405 | |||
406 | OIDplus::db()->query("INSERT INTO ###objects (id, parent, ra_email, confidential, comment, created, title, description) VALUES (?, ?, ?, ?, ?, ".OIDplus::db()->sqlDate().", ?, ?)", array($id, $parent, $ra_email, $confidential, $comment, $title, $description)); |
||
407 | |||
408 | // Set ASN.1 IDs und IRIs |
||
409 | if ($obj::ns() == 'oid') { |
||
410 | if (!$obj->isWellKnown()) { |
||
411 | if (isset($params['iris'])) { |
||
412 | $ids = ($params['iris'] == '') ? array() : explode(',',$params['iris']); |
||
413 | $ids = array_map('trim',$ids); |
||
414 | $obj->replaceIris($ids, false); |
||
415 | } |
||
416 | |||
417 | if (isset($params['asn1ids'])) { |
||
418 | $ids = ($params['asn1ids'] == '') ? array() : explode(',',$params['asn1ids']); |
||
419 | $ids = array_map('trim',$ids); |
||
420 | $obj->replaceAsn1Ids($ids, false); |
||
421 | } |
||
422 | } |
||
423 | } |
||
424 | |||
425 | $status = 0; |
||
426 | |||
427 | if (!empty($ra_email)) { |
||
428 | // Do we need to notify that the RA does not exist? |
||
429 | $res = OIDplus::db()->query("select ra_name from ###ra where email = ?", array($ra_email)); |
||
430 | $invitePlugin = OIDplus::getPluginByOid('1.3.6.1.4.1.37476.2.5.2.4.2.92'); // OIDplusPageRaInvite |
||
790 | daniel-mar | 431 | if (!$res->any()) $status = !is_null($invitePlugin) && OIDplus::config()->getValue('ra_invitation_enabled') ? 1 : 2; |
635 | daniel-mar | 432 | } |
433 | |||
434 | if ($obj::ns() == 'oid') { |
||
435 | if ($obj->isWellKnown()) { |
||
436 | $status += 4; |
||
437 | } |
||
438 | } |
||
439 | |||
440 | foreach (OIDplus::getPagePlugins() as $plugin) { |
||
441 | if ($plugin->implementsFeature('1.3.6.1.4.1.37476.2.5.2.3.3')) { |
||
442 | $plugin->afterObjectInsert($id, $params); |
||
443 | } |
||
444 | } |
||
445 | |||
446 | return array( |
||
447 | "status" => $status, |
||
448 | "inserted_id" => $id |
||
449 | ); |
||
450 | } else { |
||
451 | throw new OIDplusException(_L('Unknown action ID')); |
||
452 | } |
||
453 | } |
||
454 | |||
455 | public function init($html=true) { |
||
456 | OIDplus::config()->prepareConfigKey('oobe_objects_done', '"Out Of Box Experience" wizard for OIDplusPagePublicObjects done once?', '0', OIDplusConfig::PROTECTION_HIDDEN, function($value) {}); |
||
693 | daniel-mar | 457 | OIDplus::config()->prepareConfigKey('oid_grid_show_weid', 'Show WEID/Base36 column in CRUD grid of OIDs?', '1', OIDplusConfig::PROTECTION_EDITABLE, function($value) { |
458 | if (!is_numeric($value) || ($value < 0) || ($value > 1)) { |
||
459 | throw new OIDplusException(_L('Please enter a valid value (0=no, 1=yes).')); |
||
460 | } |
||
461 | }); |
||
635 | daniel-mar | 462 | } |
463 | |||
951 | daniel-mar | 464 | private function tryObject($id, &$out) { |
465 | $parent = null; |
||
466 | $res = null; |
||
467 | $row = null; |
||
954 | daniel-mar | 468 | $obj = OIDplusObject::parse($id); |
469 | if (is_null($obj)) return false; |
||
470 | if ($obj->isRoot()) { |
||
471 | $obj->getContentPage($out['title'], $out['text'], $out['icon']); |
||
472 | $parent = null; // $obj->getParent(); |
||
473 | } else { |
||
474 | $res = OIDplus::db()->query("select * from ###objects where id = ?", array($obj->nodeId())); |
||
475 | if (!$res->any()) { |
||
476 | return false; |
||
477 | } else { |
||
478 | $row = $res->fetch_array(); // will be used further down the code |
||
479 | $obj->getContentPage($out['title'], $out['text'], $out['icon']); |
||
480 | if (empty($out['title'])) $out['title'] = explode(':',$obj->nodeId(),2)[1]; |
||
481 | $parent = $obj->getParent(); |
||
953 | daniel-mar | 482 | } |
951 | daniel-mar | 483 | } |
955 | daniel-mar | 484 | return array($id, $parent, $res, $row); |
951 | daniel-mar | 485 | } |
486 | |||
967 | daniel-mar | 487 | public static function getAlternativesForQuery($id) { |
968 | daniel-mar | 488 | // Attention: This is NOT an implementation of 1.3.6.1.4.1.37476.2.5.2.3.7 ! |
489 | // This is the function that calls getAlternativesForQuery() of every plugin that implements 1.3.6.1.4.1.37476.2.5.2.3.7 |
||
490 | |||
951 | daniel-mar | 491 | // e.g. used for "Reverse Alt Id" |
492 | $alternatives = array(); |
||
493 | foreach (array_merge(OIDplus::getPagePlugins(),OIDplus::getObjectTypePlugins()) as $plugin) { |
||
494 | if ($plugin->implementsFeature('1.3.6.1.4.1.37476.2.5.2.3.7')) { |
||
495 | $tmp = $plugin->getAlternativesForQuery($id); |
||
496 | if (is_array($tmp)) { |
||
497 | $alternatives = array_merge($tmp, $alternatives); |
||
498 | } |
||
499 | } |
||
500 | } |
||
968 | daniel-mar | 501 | |
502 | // If something is more than one time, remove it |
||
951 | daniel-mar | 503 | $alternatives = array_unique($alternatives); |
968 | daniel-mar | 504 | |
505 | // If a plugin accidentally added the own ID, remove it. This function lists only alternatives, not the own ID |
||
506 | $alternatives_tmp = array(); |
||
507 | foreach ($alternatives as $alt) { |
||
508 | if ($alt !== $id) $alternatives_tmp[] = $alt; |
||
509 | } |
||
510 | $alternatives = $alternatives_tmp; |
||
511 | |||
951 | daniel-mar | 512 | return $alternatives; |
513 | } |
||
514 | |||
635 | daniel-mar | 515 | public function gui($id, &$out, &$handled) { |
516 | if ($id === 'oidplus:system') { |
||
517 | $handled = true; |
||
518 | |||
519 | $out['title'] = OIDplus::config()->getValue('system_title'); |
||
801 | daniel-mar | 520 | $out['icon'] = OIDplus::webpath(__DIR__,OIDplus::PATH_RELATIVE).'img/main_icon.png'; |
635 | daniel-mar | 521 | |
522 | if (file_exists(OIDplus::localpath() . 'userdata/welcome/welcome$'.OIDplus::getCurrentLang().'.html')) { |
||
523 | $cont = file_get_contents(OIDplus::localpath() . 'userdata/welcome/welcome$'.OIDplus::getCurrentLang().'.html'); |
||
524 | } else if (file_exists(OIDplus::localpath() . 'userdata/welcome/welcome.html')) { |
||
525 | $cont = file_get_contents(OIDplus::localpath() . 'userdata/welcome/welcome.html'); |
||
526 | } else if (file_exists(__DIR__ . '/welcome$'.OIDplus::getCurrentLang().'.html')) { |
||
527 | $cont = file_get_contents(__DIR__ . '/welcome$'.OIDplus::getCurrentLang().'.html'); |
||
528 | } else if (file_exists(__DIR__ . '/welcome.html')) { |
||
529 | $cont = file_get_contents(__DIR__ . '/welcome.html'); |
||
530 | } else { |
||
531 | $cont = ''; |
||
532 | } |
||
533 | |||
534 | list($html, $js, $css) = extractHtmlContents($cont); |
||
535 | $cont = ''; |
||
536 | if (!empty($js)) $cont .= "<script>\n$js\n</script>"; |
||
537 | if (!empty($css)) $cont .= "<style>\n$css\n</style>"; |
||
821 | daniel-mar | 538 | $cont .= stripHtmlComments($html); |
635 | daniel-mar | 539 | |
540 | $out['text'] = $cont; |
||
541 | |||
542 | if (strpos($out['text'], '%%OBJECT_TYPE_LIST%%') !== false) { |
||
543 | $tmp = '<ul>'; |
||
544 | foreach (OIDplus::getEnabledObjectTypes() as $ot) { |
||
545 | $tmp .= '<li><a '.OIDplus::gui()->link($ot::root()).'>'.htmlentities($ot::objectTypeTitle()).'</a></li>'; |
||
546 | } |
||
547 | $tmp .= '</ul>'; |
||
548 | $out['text'] = str_replace('%%OBJECT_TYPE_LIST%%', $tmp, $out['text']); |
||
549 | } |
||
550 | |||
551 | return; |
||
552 | } |
||
553 | |||
957 | daniel-mar | 554 | // Never answer to an object type that is called 'oidplus:', |
555 | // otherwise, an object type plugin could break the whole system! |
||
556 | else if ((strpos($id,':') !== false) && (!str_starts_with($id,'oidplus:'))) { |
||
635 | daniel-mar | 557 | |
955 | daniel-mar | 558 | // --- Try to find the object or an alternative |
635 | daniel-mar | 559 | |
951 | daniel-mar | 560 | $test = $this->tryObject($id, $out); |
561 | if ($test === false) { |
||
955 | daniel-mar | 562 | // try to find an alternative |
952 | daniel-mar | 563 | $alternatives = $this->getAlternativesForQuery($id); |
951 | daniel-mar | 564 | foreach ($alternatives as $alternative) { |
565 | $test = $this->tryObject($alternative, $out); |
||
955 | daniel-mar | 566 | if ($test !== false) break; // found something |
635 | daniel-mar | 567 | } |
568 | } |
||
955 | daniel-mar | 569 | if ($test !== false) { |
570 | list($id, $parent, $res, $row) = $test; |
||
571 | } |
||
572 | |||
573 | // --- If the object type is disabled or not an object at all (e.g. "oidplus:"), then $handled=false |
||
574 | // If the object type is enabled but object not found, $handled=true |
||
575 | |||
576 | try { |
||
577 | $obj = OIDplusObject::parse($id); |
||
578 | } catch (Exception $e) { |
||
579 | $obj = null; |
||
580 | } |
||
581 | |||
951 | daniel-mar | 582 | if ($test === false) { |
955 | daniel-mar | 583 | if (is_null($obj)) { |
584 | // Object type disabled or not known (e.g. ObjectType "oidplus:"). |
||
585 | $handled = false; |
||
586 | return; |
||
587 | } else { |
||
588 | // Object type enabled but identifier not in database |
||
589 | $handled = true; |
||
590 | if (isset($_SERVER['SCRIPT_FILENAME']) && (strtolower(basename($_SERVER['SCRIPT_FILENAME'])) !== 'ajax.php')) { // don't send HTTP error codes in ajax.php, because we want a page and not a JavaScript alert box, when someone enters an invalid OID in the GoTo-Box |
||
591 | http_response_code(404); |
||
592 | } |
||
593 | $out['title'] = _L('Object not found'); |
||
594 | $out['icon'] = 'img/error.png'; |
||
595 | $out['text'] = _L('The object %1 was not found in this database.','<code>'.htmlentities($id).'</code>'); |
||
596 | return; |
||
597 | } |
||
598 | } else { |
||
599 | $handled = true; |
||
600 | } |
||
601 | |||
602 | unset($test); |
||
603 | |||
604 | // --- If found, do we have read rights? |
||
605 | |||
606 | if (!$obj->userHasReadRights()) { |
||
843 | daniel-mar | 607 | if (isset($_SERVER['SCRIPT_FILENAME']) && (strtolower(basename($_SERVER['SCRIPT_FILENAME'])) !== 'ajax.php')) { // don't send HTTP error codes in ajax.php, because we want a page and not a JavaScript alert box, when someone enters an invalid OID in the GoTo-Box |
955 | daniel-mar | 608 | http_response_code(403); |
843 | daniel-mar | 609 | } |
955 | daniel-mar | 610 | $out['title'] = _L('Access denied'); |
800 | daniel-mar | 611 | $out['icon'] = 'img/error.png'; |
955 | daniel-mar | 612 | $out['text'] = '<p>'._L('Please <a %1>log in</a> to receive information about this object.',OIDplus::gui()->link('oidplus:login')).'</p>'; |
635 | daniel-mar | 613 | return; |
614 | } |
||
615 | |||
616 | // --- |
||
617 | |||
618 | if ($parent) { |
||
619 | if ($parent->isRoot()) { |
||
620 | |||
621 | $parent_link_text = $parent->objectTypeTitle(); |
||
622 | $out['text'] = '<p><a '.OIDplus::gui()->link($parent->root()).'><img src="img/arrow_back.png" width="16" alt="'._L('Go back').'"> '._L('Parent node: %1',htmlentities($parent_link_text)).'</a></p>' . $out['text']; |
||
623 | |||
624 | } else { |
||
625 | $res_ = OIDplus::db()->query("select * from ###objects where id = ?", array($parent->nodeId())); |
||
790 | daniel-mar | 626 | if ($res_->any()) { |
635 | daniel-mar | 627 | $row_ = $res_->fetch_array(); |
628 | |||
629 | $parent_title = $row_['title']; |
||
630 | if (empty($parent_title) && ($parent->ns() == 'oid')) { |
||
631 | // If not title is available, then use an ASN.1 identifier |
||
632 | $res_ = OIDplus::db()->query("select name from ###asn1id where oid = ?", array($parent->nodeId())); |
||
790 | daniel-mar | 633 | if ($res_->any()) { |
635 | daniel-mar | 634 | $row_ = $res_->fetch_array(); |
635 | $parent_title = $row_['name']; // TODO: multiple ASN1 ids? |
||
636 | } |
||
637 | } |
||
638 | |||
639 | $parent_link_text = empty($parent_title) ? explode(':',$parent->nodeId())[1] : $parent_title.' ('.explode(':',$parent->nodeId())[1].')'; |
||
640 | |||
641 | $out['text'] = '<p><a '.OIDplus::gui()->link($parent->nodeId()).'><img src="img/arrow_back.png" width="16" alt="'._L('Go back').'"> '._L('Parent node: %1',htmlentities($parent_link_text)).'</a></p>' . $out['text']; |
||
642 | } else { |
||
643 | $out['text'] = ''; |
||
644 | } |
||
645 | } |
||
646 | } else { |
||
647 | $parent_link_text = _L('Go back to front page'); |
||
648 | $out['text'] = '<p><a '.OIDplus::gui()->link('oidplus:system').'><img src="img/arrow_back.png" width="16" alt="'._L('Go back').'"> '.htmlentities($parent_link_text).'</a></p>' . $out['text']; |
||
649 | } |
||
650 | |||
651 | // --- |
||
652 | |||
783 | daniel-mar | 653 | // DM 16.03.2022 commented out isset() because Oracle does not set 'description' if it is NULL?! |
654 | if (!is_null($row)/* && isset($row['description'])*/) { |
||
635 | daniel-mar | 655 | if (empty($row['description'])) { |
656 | if (empty($row['title'])) { |
||
657 | $desc = '<p><i>'._L('No description for this object available').'</i></p>'; |
||
658 | } else { |
||
659 | $desc = $row['title']; |
||
660 | } |
||
661 | } else { |
||
662 | $desc = self::objDescription($row['description']); |
||
663 | } |
||
664 | |||
665 | if ($obj->userHasWriteRights()) { |
||
666 | $rand = ++self::$crudCounter; |
||
667 | $desc = '<noscript><p><b>'._L('You need to enable JavaScript to edit title or description of this object.').'</b></p>'.$desc.'</noscript>'; |
||
668 | $desc .= '<div class="container box" style="display:none" id="descbox_'.$rand.'">'; |
||
669 | $desc .= _L('Title').': <input type="text" name="title" id="titleedit" value="'.htmlentities($row['title']).'"><br><br>'._L('Description').':<br>'; |
||
670 | $desc .= self::showMCE('description', $row['description']); |
||
671 | $desc .= '<button type="button" name="update_desc" id="update_desc" class="btn btn-success btn-xs update" onclick="OIDplusPagePublicObjects.updateDesc()">'._L('Update description').'</button>'; |
||
672 | $desc .= '</div>'; |
||
673 | $desc .= '<script>$("#descbox_'.$rand.'")[0].style.display = "block";</script>'; |
||
674 | } |
||
675 | } else { |
||
676 | $desc = ''; |
||
677 | } |
||
678 | |||
679 | // --- |
||
680 | |||
681 | if (strpos($out['text'], '%%DESC%%') !== false) |
||
682 | $out['text'] = str_replace('%%DESC%%', $desc, $out['text']); |
||
683 | if (strpos($out['text'], '%%CRUD%%') !== false) |
||
856 | daniel-mar | 684 | $out['text'] = str_replace('%%CRUD%%', self::showCrud($obj->nodeId()), $out['text']); |
635 | daniel-mar | 685 | if (strpos($out['text'], '%%RA_INFO%%') !== false) |
686 | $out['text'] = str_replace('%%RA_INFO%%', OIDplusPagePublicRaInfo::showRaInfo($row['ra_email']), $out['text']); |
||
687 | |||
688 | $alt_ids = $obj->getAltIds(); |
||
689 | if (count($alt_ids) > 0) { |
||
690 | $out['text'] .= '<h2>'._L('Alternative Identifiers').'</h2>'; |
||
691 | foreach ($alt_ids as $alt_id) { |
||
692 | $ns = $alt_id->getNamespace(); |
||
693 | $aid = $alt_id->getId(); |
||
694 | $aiddesc = $alt_id->getDescription(); |
||
945 | daniel-mar | 695 | $suffix = $alt_id->getSuffix(); |
696 | $out['text'] .= "$aiddesc: <code>$ns:$aid</code>$suffix<br>"; |
||
635 | daniel-mar | 697 | } |
698 | } |
||
699 | |||
700 | foreach (OIDplus::getPagePlugins() as $plugin) { |
||
701 | if ($plugin->implementsFeature('1.3.6.1.4.1.37476.2.5.2.3.2')) { |
||
856 | daniel-mar | 702 | $plugin->modifyContent($obj->nodeId(), $out['title'], $out['icon'], $out['text']); |
635 | daniel-mar | 703 | } |
704 | } |
||
705 | } |
||
706 | } |
||
707 | |||
708 | private function publicSitemap_rec($json, &$out) { |
||
709 | foreach ($json as $x) { |
||
710 | if (isset($x['id']) && $x['id']) { |
||
711 | $out[] = $x['id']; |
||
712 | } |
||
713 | if (isset($x['children'])) { |
||
714 | $this->publicSitemap_rec($x['children'], $out); |
||
715 | } |
||
716 | } |
||
717 | } |
||
718 | |||
719 | public function publicSitemap(&$out) { |
||
720 | $json = array(); |
||
721 | $this->tree($json, null/*RA EMail*/, false/*HTML tree algorithm*/, true/*display all*/); |
||
722 | $this->publicSitemap_rec($json, $out); |
||
723 | } |
||
724 | |||
725 | public function tree(&$json, $ra_email=null, $nonjs=false, $req_goto='') { |
||
726 | if ($nonjs) { |
||
727 | $json[] = array( |
||
728 | 'id' => 'oidplus:system', |
||
801 | daniel-mar | 729 | 'icon' => OIDplus::webpath(__DIR__,OIDplus::PATH_RELATIVE).'img/main_icon16.png', |
635 | daniel-mar | 730 | 'text' => _L('System') |
731 | ); |
||
732 | |||
733 | $parent = ''; |
||
734 | $res = OIDplus::db()->query("select parent from ###objects where id = ?", array($req_goto)); |
||
735 | while ($row = $res->fetch_object()) { |
||
736 | $parent = $row->parent; |
||
737 | } |
||
738 | |||
739 | $objTypesChildren = array(); |
||
740 | foreach (OIDplus::getEnabledObjectTypes() as $ot) { |
||
741 | $icon = $this->get_treeicon_root($ot); |
||
742 | |||
743 | $json[] = array( |
||
744 | 'id' => $ot::root(), |
||
745 | 'icon' => $icon, |
||
746 | 'text' => $ot::objectTypeTitle() |
||
747 | ); |
||
748 | |||
954 | daniel-mar | 749 | $tmp = OIDplusObject::parse($req_goto); |
635 | daniel-mar | 750 | if (!is_null($tmp) && ($ot == get_class($tmp))) { |
751 | // TODO: Instead of just having 3 levels (parent, this and children), it would be better if we'd had a full tree of all parents |
||
752 | // on the other hand, for giving search engines content, this is good enough |
||
753 | if (empty($parent)) { |
||
754 | $res = OIDplus::db()->query("select * from ###objects where " . |
||
755 | "parent = ? or " . |
||
756 | "id = ? " . |
||
757 | "order by ".OIDplus::db()->natOrder('id'), array($req_goto, $req_goto)); |
||
758 | } else { |
||
759 | $res = OIDplus::db()->query("select * from ###objects where " . |
||
760 | "parent = ? or " . |
||
761 | "id = ? or " . |
||
762 | "id = ? ". |
||
763 | "order by ".OIDplus::db()->natOrder('id'), array($req_goto, $req_goto, $parent)); |
||
764 | } |
||
765 | |||
766 | $z_used = 0; |
||
767 | $y_used = 0; |
||
768 | $x_used = 0; |
||
769 | $stufe = 0; |
||
770 | $menu_entries = array(); |
||
771 | $stufen = array(); |
||
772 | while ($row = $res->fetch_object()) { |
||
773 | $obj = OIDplusObject::parse($row->id); |
||
774 | if (is_null($obj)) continue; // might happen if the objectType is not available/loaded |
||
775 | if (!$obj->userHasReadRights()) continue; |
||
776 | $txt = $row->title == '' ? '' : ' -- '.htmlentities($row->title); |
||
777 | |||
778 | if ($row->id == $parent) { $stufe=0; $z_used++; } |
||
779 | if ($row->id == $req_goto) { $stufe=1; $y_used++; } |
||
780 | if ($row->parent == $req_goto) { $stufe=2; $x_used++; } |
||
781 | |||
782 | $menu_entry = array('id' => $row->id, 'icon' => '', 'text' => $txt, 'indent' => 0); |
||
783 | $menu_entries[] = $menu_entry; |
||
784 | $stufen[] = $stufe; |
||
785 | } |
||
786 | if ($x_used) foreach ($menu_entries as $i => &$menu_entry) if ($stufen[$i] >= 2) $menu_entry['indent'] += 1; |
||
787 | if ($y_used) foreach ($menu_entries as $i => &$menu_entry) if ($stufen[$i] >= 1) $menu_entry['indent'] += 1; |
||
788 | if ($z_used) foreach ($menu_entries as $i => &$menu_entry) if ($stufen[$i] >= 0) $menu_entry['indent'] += 1; |
||
789 | $json = array_merge($json, $menu_entries); |
||
790 | } |
||
791 | } |
||
792 | |||
793 | return true; |
||
794 | } else { |
||
795 | if ($req_goto === true) { |
||
796 | $goto_path = true; // display everything recursively |
||
797 | } else if (isset($req_goto)) { |
||
798 | $goto = $req_goto; |
||
799 | $path = array(); |
||
800 | while (true) { |
||
801 | $path[] = $goto; |
||
802 | $res = OIDplus::db()->query("select parent from ###objects where id = ?", array($goto)); |
||
790 | daniel-mar | 803 | if (!$res->any()) break; |
635 | daniel-mar | 804 | $row = $res->fetch_array(); |
805 | $goto = $row['parent']; |
||
806 | if ($goto == '') continue; |
||
807 | } |
||
808 | |||
809 | $goto_path = array_reverse($path); |
||
810 | } else { |
||
811 | $goto_path = null; |
||
812 | } |
||
813 | |||
814 | $objTypesChildren = array(); |
||
815 | foreach (OIDplus::getEnabledObjectTypes() as $ot) { |
||
816 | $icon = $this->get_treeicon_root($ot); |
||
817 | |||
818 | $child = array('id' => $ot::root(), |
||
819 | 'text' => $ot::objectTypeTitle(), |
||
820 | 'state' => array("opened" => true), |
||
821 | 'icon' => $icon, |
||
822 | 'children' => OIDplus::menuUtils()->tree_populate($ot::root(), $goto_path) |
||
823 | ); |
||
824 | if (!file_exists($child['icon'])) $child['icon'] = null; // default icon (folder) |
||
825 | $objTypesChildren[] = $child; |
||
826 | } |
||
827 | |||
828 | $json[] = array( |
||
829 | 'id' => "oidplus:system", |
||
830 | 'text' => _L('Objects'), |
||
831 | 'state' => array( |
||
832 | "opened" => true, |
||
833 | // "selected" => true) // "selected" is buggy: |
||
834 | // 1) The select-event will not be triggered upon loading |
||
835 | // 2) The nodes directly blow cannot be opened (loading infinite time) |
||
836 | ), |
||
801 | daniel-mar | 837 | 'icon' => OIDplus::webpath(__DIR__,OIDplus::PATH_RELATIVE).'img/main_icon16.png', |
635 | daniel-mar | 838 | 'children' => $objTypesChildren |
839 | ); |
||
840 | |||
841 | return true; |
||
842 | } |
||
843 | } |
||
844 | |||
845 | public function tree_search($request) { |
||
846 | $ary = array(); |
||
951 | daniel-mar | 847 | $found_leaf = false; |
635 | daniel-mar | 848 | if ($obj = OIDplusObject::parse($request)) { |
951 | daniel-mar | 849 | $found_leaf = OIDplusObject::exists($request); |
850 | do { |
||
851 | if ($obj->userHasReadRights()) { |
||
635 | daniel-mar | 852 | $ary[] = $obj->nodeId(); |
951 | daniel-mar | 853 | } |
854 | } while ($obj = $obj->getParent()); |
||
855 | $ary = array_reverse($ary); |
||
856 | } |
||
857 | if (!$found_leaf) { |
||
952 | daniel-mar | 858 | $alternatives = $this->getAlternativesForQuery($request); |
951 | daniel-mar | 859 | foreach ($alternatives as $alternative) { |
860 | $ary_ = array(); |
||
861 | if ($obj = OIDplusObject::parse($alternative)) { |
||
862 | if ($obj->userHasReadRights() && OIDplusObject::exists($alternative)) { |
||
863 | do { |
||
864 | $ary_[] = $obj->nodeId(); |
||
865 | } while ($obj = $obj->getParent()); |
||
866 | $ary_ = array_reverse($ary_); |
||
867 | } |
||
868 | } |
||
869 | if (!empty($ary_)) { |
||
870 | $ary = $ary_; |
||
871 | break; |
||
872 | } |
||
635 | daniel-mar | 873 | } |
874 | } |
||
875 | return $ary; |
||
876 | } |
||
877 | |||
878 | private static $crudCounter = 0; |
||
879 | |||
880 | protected static function showCrud($parent='oid:') { |
||
881 | $items_total = 0; |
||
882 | $items_hidden = 0; |
||
883 | |||
884 | $objParent = OIDplusObject::parse($parent); |
||
885 | $parentNS = $objParent::ns(); |
||
886 | |||
887 | // http://www.oid-info.com/cgi-bin/display?a=list-by-category&category=Not%20allocating%20identifiers |
||
888 | $no_asn1 = array( |
||
889 | 'oid:1.3.6.1.4.1', |
||
890 | 'oid:1.3.6.1.4.1.37476.9000', |
||
891 | 'oid:1.3.6.1.4.1.37553.8.8', |
||
892 | 'oid:2.16.276.1', |
||
719 | daniel-mar | 893 | //'oid:2.25', // according to Olivier, it is OK that UUID owners define their own ASN.1 ID, since the ASN.1 ID is not required to be unique |
894 | //'oid:1.2.840.113556.1.8000.2554' // Adhoc (GUID/UUID-based) customer use. It is probably the same case as the UUID OIDs, after all, these are UUIDs, too. |
||
635 | daniel-mar | 895 | ); |
896 | |||
897 | // http://www.oid-info.com/cgi-bin/display?a=list-by-category&category=Not%20allocating%20Unicode%20labels |
||
898 | $no_iri = array( |
||
899 | 'oid:1.2.250.1', |
||
900 | 'oid:1.3.6.1.4.1', |
||
901 | 'oid:1.3.6.1.4.1.37476.9000', |
||
902 | 'oid:1.3.6.1.4.1.37553.8.8', |
||
903 | 'oid:2.16.276.1', |
||
904 | 'oid:2.25' |
||
905 | ); |
||
906 | |||
907 | $accepts_asn1 = ($parentNS == 'oid') && (!in_array($objParent->nodeId(), $no_asn1)) && (!is_uuid_oid($objParent->nodeId(),true)); |
||
908 | $accepts_iri = ($parentNS == 'oid') && (!in_array($objParent->nodeId(), $no_iri)) && (!is_uuid_oid($objParent->nodeId(),true)); |
||
909 | |||
910 | $result = OIDplus::db()->query("select o.*, r.ra_name " . |
||
911 | "from ###objects o " . |
||
912 | "left join ###ra r on r.email = o.ra_email " . |
||
913 | "where parent = ? " . |
||
914 | "order by ".OIDplus::db()->natOrder('id'), array($parent)); |
||
915 | |||
693 | daniel-mar | 916 | $rows = array(); |
917 | while ($row = $result->fetch_object()) { |
||
918 | $obj = OIDplusObject::parse($row->id); |
||
919 | $rows[] = array($obj,$row); |
||
920 | } |
||
921 | |||
922 | $enable_weid_presentation = OIDplus::config()->getValue('oid_grid_show_weid'); |
||
923 | |||
635 | daniel-mar | 924 | $output = ''; |
925 | $output .= '<div class="container box"><div id="suboid_table" class="table-responsive">'; |
||
926 | $output .= '<table class="table table-bordered table-striped">'; |
||
927 | $output .= ' <tr>'; |
||
928 | $output .= ' <th>'._L('ID').(($parentNS == 'gs1') ? ' '._L('(without check digit)') : '').'</th>'; |
||
692 | daniel-mar | 929 | if ($enable_weid_presentation && ($parentNS == 'oid') && !$objParent->isRoot()) { |
693 | daniel-mar | 930 | $output .= ' <th><abbr title="'._L('Binary-to-text encoding used for WEIDs').'">'._L('Base36').'</abbr></th>'; |
931 | } |
||
635 | daniel-mar | 932 | if ($parentNS == 'oid') { |
933 | if ($accepts_asn1) $output .= ' <th>'._L('ASN.1 IDs (comma sep.)').'</th>'; |
||
934 | if ($accepts_iri) $output .= ' <th>'._L('IRI IDs (comma sep.)').'</th>'; |
||
935 | } |
||
936 | $output .= ' <th>'._L('RA').'</th>'; |
||
937 | $output .= ' <th>'._L('Comment').'</th>'; |
||
938 | if ($objParent->userHasWriteRights()) { |
||
939 | $output .= ' <th>'._L('Hide').'</th>'; |
||
940 | $output .= ' <th>'._L('Update').'</th>'; |
||
941 | $output .= ' <th>'._L('Delete').'</th>'; |
||
942 | } |
||
943 | $output .= ' <th>'._L('Created').'</th>'; |
||
944 | $output .= ' <th>'._L('Updated').'</th>'; |
||
945 | $output .= ' </tr>'; |
||
946 | |||
947 | foreach ($rows as list($obj,$row)) { |
||
948 | $items_total++; |
||
949 | if (!$obj->userHasReadRights()) { |
||
950 | $items_hidden++; |
||
951 | continue; |
||
952 | } |
||
953 | |||
954 | $show_id = $obj->crudShowId($objParent); |
||
955 | |||
956 | $asn1ids = array(); |
||
957 | $res2 = OIDplus::db()->query("select name from ###asn1id where oid = ? order by lfd", array($row->id)); |
||
958 | while ($row2 = $res2->fetch_array()) { |
||
959 | $asn1ids[] = $row2['name']; |
||
960 | } |
||
961 | |||
962 | $iris = array(); |
||
963 | $res2 = OIDplus::db()->query("select name from ###iri where oid = ? order by lfd", array($row->id)); |
||
964 | while ($row2 = $res2->fetch_array()) { |
||
965 | $iris[] = $row2['name']; |
||
966 | } |
||
967 | |||
968 | $date_created = explode(' ', $row->created)[0] == '0000-00-00' ? '' : explode(' ', $row->created)[0]; |
||
969 | $date_updated = explode(' ', $row->updated)[0] == '0000-00-00' ? '' : explode(' ', $row->updated)[0]; |
||
970 | |||
971 | $output .= '<tr>'; |
||
693 | daniel-mar | 972 | $output .= ' <td><a href="?goto='.urlencode($row->id).'" onclick="openAndSelectNode('.js_escape($row->id).', '.js_escape($parent).'); return false;">'.htmlentities($show_id).'</a>'; |
973 | if ($enable_weid_presentation && ($parentNS == 'oid') && $objParent->isRoot()) { |
||
974 | // To save space horizontal space, the WEIDs were written below the OIDs |
||
975 | $output .= '<br>'.$obj->getWeidNotation(true); |
||
976 | } |
||
977 | $output .= '</td>'; |
||
978 | if ($enable_weid_presentation && ($parentNS == 'oid') && !$objParent->isRoot()) { |
||
979 | $output .= ' <td>'.htmlentities($obj->weidArc()).'</td>'; |
||
980 | } |
||
635 | daniel-mar | 981 | if ($objParent->userHasWriteRights()) { |
982 | if ($parentNS == 'oid') { |
||
983 | if ($accepts_asn1) $output .= ' <td><input type="text" id="asn1ids_'.$row->id.'" value="'.implode(', ', $asn1ids).'"></td>'; |
||
984 | if ($accepts_iri) $output .= ' <td><input type="text" id="iris_'.$row->id.'" value="'.implode(', ', $iris).'"></td>'; |
||
985 | } |
||
986 | $output .= ' <td><input type="text" id="ra_email_'.$row->id.'" value="'.htmlentities($row->ra_email).'"></td>'; |
||
987 | $output .= ' <td><input type="text" id="comment_'.$row->id.'" value="'.htmlentities($row->comment).'"></td>'; |
||
988 | $output .= ' <td><input type="checkbox" id="hide_'.$row->id.'" '.($row->confidential ? 'checked' : '').'></td>'; |
||
989 | $output .= ' <td><button type="button" name="update_'.$row->id.'" id="update_'.$row->id.'" class="btn btn-success btn-xs update" onclick="OIDplusPagePublicObjects.crudActionUpdate('.js_escape($row->id).', '.js_escape($parent).')">'._L('Update').'</button></td>'; |
||
990 | $output .= ' <td><button type="button" name="delete_'.$row->id.'" id="delete_'.$row->id.'" class="btn btn-danger btn-xs delete" onclick="OIDplusPagePublicObjects.crudActionDelete('.js_escape($row->id).', '.js_escape($parent).')">'._L('Delete').'</button></td>'; |
||
991 | $output .= ' <td>'.$date_created.'</td>'; |
||
992 | $output .= ' <td>'.$date_updated.'</td>'; |
||
993 | } else { |
||
994 | if ($parentNS == 'oid') { |
||
693 | daniel-mar | 995 | if ($asn1ids == '') $asn1ids = '<i>'._L('(none)').'</i>'; |
996 | if ($iris == '') $iris = '<i>'._L('(none)').'</i>'; |
||
635 | daniel-mar | 997 | $asn1ids_ext = array(); |
998 | foreach ($asn1ids as $asn1id) { |
||
999 | $asn1ids_ext[] = '<a href="?goto='.urlencode($row->id).'" onclick="openAndSelectNode('.js_escape($row->id).', '.js_escape($parent).'); return false;">'.$asn1id.'</a>'; |
||
1000 | } |
||
1001 | if ($accepts_asn1) $output .= ' <td>'.implode(', ', $asn1ids_ext).'</td>'; |
||
1002 | if ($accepts_iri) $output .= ' <td>'.implode(', ', $iris).'</td>'; |
||
1003 | } |
||
1004 | $output .= ' <td><a '.OIDplus::gui()->link('oidplus:rainfo$'.str_replace('@','&',$row->ra_email)).'>'.htmlentities(empty($row->ra_name) ? str_replace('@','&',$row->ra_email) : $row->ra_name).'</a></td>'; |
||
1005 | $output .= ' <td>'.htmlentities($row->comment).'</td>'; |
||
1006 | $output .= ' <td>'.$date_created.'</td>'; |
||
1007 | $output .= ' <td>'.$date_updated.'</td>'; |
||
1008 | } |
||
1009 | $output .= '</tr>'; |
||
1010 | } |
||
1011 | |||
1012 | $result = OIDplus::db()->query("select * from ###objects where id = ?", array($parent)); |
||
790 | daniel-mar | 1013 | $parent_ra_email = $result->any() ? $result->fetch_object()->ra_email : ''; |
693 | daniel-mar | 1014 | |
692 | daniel-mar | 1015 | // "Create OID" row |
635 | daniel-mar | 1016 | if ($objParent->userHasWriteRights()) { |
1017 | $output .= '<tr>'; |
||
1018 | $prefix = is_null($objParent) ? '' : $objParent->crudInsertPrefix(); |
||
693 | daniel-mar | 1019 | |
707 | daniel-mar | 1020 | $suffix = is_null($objParent) ? '' : $objParent->crudInsertSuffix(); |
693 | daniel-mar | 1021 | foreach (OIDplus::getObjectTypePlugins() as $plugin) { |
1022 | if (($plugin::getObjectTypeClassName()::ns() == $parentNS) && $plugin->implementsFeature('1.3.6.1.4.1.37476.2.5.2.3.6')) { |
||
695 | daniel-mar | 1023 | $suffix .= $plugin->gridGeneratorLinks($objParent); |
693 | daniel-mar | 1024 | } |
1025 | } |
||
1026 | |||
1027 | if ($parentNS == 'guid') { |
||
695 | daniel-mar | 1028 | $output .= ' <td>'.$prefix.' <input type="text" id="id" value="" style="width:100%;min-width:275px">'.$suffix.'</td>'; |
693 | daniel-mar | 1029 | } else if ($parentNS == 'oid') { |
635 | daniel-mar | 1030 | // TODO: Idea: Give a class name, e.g. "OID" and then with a oid-specific CSS make the width individual. So, every plugin has more control over the appearance and widths of the input fields |
693 | daniel-mar | 1031 | if ($objParent->nodeId() === 'oid:2.25') { |
695 | daniel-mar | 1032 | $output .= ' <td>'.$prefix.' <input type="text" id="id" value="" style="width:100%;min-width:345px">'.$suffix.'</td>'; |
693 | daniel-mar | 1033 | if ($enable_weid_presentation) $output .= ' <td> </td>'; // For UUID-OIDs, you must generate a valid one. Don't be tempted to create one using the Base36 input! |
1034 | } else if ($objParent->isRoot()) { |
||
695 | daniel-mar | 1035 | $output .= ' <td>'.$prefix.' <input type="text" id="id" value="" style="width:100%;min-width:345px">'.$suffix.'</td>'; |
693 | daniel-mar | 1036 | if ($enable_weid_presentation) $output .= ''; // WEID-editor not available for root nodes at the moment. For the moment you need to enter the OID (TODO: Create JavaScript WEID encoder/decoder) |
635 | daniel-mar | 1037 | } else { |
693 | daniel-mar | 1038 | if ($enable_weid_presentation) { |
695 | daniel-mar | 1039 | $output .= ' <td>'.$prefix.' <input oninput="OIDplusPagePublicObjects.frdl_oidid_change()" type="text" id="id" value="" style="width:100%;min-width:100px">'.$suffix.'</td>'; |
693 | daniel-mar | 1040 | $output .= ' <td><input type="text" name="weid" id="weid" value="" oninput="OIDplusPagePublicObjects.frdl_weid_change()" style="width:100%;min-width:100px"></td>'; |
1041 | } else { |
||
695 | daniel-mar | 1042 | $output .= ' <td>'.$prefix.' <input type="text" id="id" value="" style="width:100%;min-width:100px">'.$suffix.'</td>'; |
693 | daniel-mar | 1043 | } |
635 | daniel-mar | 1044 | } |
1045 | } else { |
||
695 | daniel-mar | 1046 | $output .= ' <td>'.$prefix.' <input type="text" id="id" value="" style="width:100%;min-width:100px">'.$suffix.'</td>'; |
635 | daniel-mar | 1047 | } |
1048 | if ($accepts_asn1) $output .= ' <td><input type="text" id="asn1ids" value=""></td>'; |
||
1049 | if ($accepts_iri) $output .= ' <td><input type="text" id="iris" value=""></td>'; |
||
1050 | $output .= ' <td><input type="text" id="ra_email" value="'.htmlentities($parent_ra_email).'"></td>'; |
||
1051 | $output .= ' <td><input type="text" id="comment" value=""></td>'; |
||
1052 | $output .= ' <td><input type="checkbox" id="hide"></td>'; |
||
1053 | $output .= ' <td><button type="button" name="insert" id="insert" class="btn btn-success btn-xs update" onclick="OIDplusPagePublicObjects.crudActionInsert('.js_escape($parent).')">'._L('Insert').'</button></td>'; |
||
1054 | $output .= ' <td></td>'; |
||
1055 | $output .= ' <td></td>'; |
||
1056 | $output .= ' <td></td>'; |
||
1057 | $output .= '</tr>'; |
||
1058 | } else { |
||
1059 | if ($items_total-$items_hidden == 0) { |
||
1060 | $cols = ($parentNS == 'oid') ? 7 : 5; |
||
692 | daniel-mar | 1061 | if ($enable_weid_presentation && ($parentNS == 'oid') && !$objParent->isRoot()) { |
1062 | $cols++; |
||
693 | daniel-mar | 1063 | } |
635 | daniel-mar | 1064 | $output .= '<tr><td colspan="'.$cols.'">'._L('No items available').'</td></tr>'; |
1065 | } |
||
1066 | } |
||
1067 | |||
1068 | $output .= '</table>'; |
||
1069 | $output .= '</div></div>'; |
||
1070 | |||
1071 | if ($items_hidden == 1) { |
||
1072 | $output .= '<p>'._L('One item is hidden. Please <a %1>log in</a> to see it.',$items_hidden,OIDplus::gui()->link('oidplus:login')).'</p>'; |
||
1073 | } else if ($items_hidden > 1) { |
||
1074 | $output .= '<p>'._L('%1 items are hidden. Please <a %2>log in</a> to see them.',$items_hidden,OIDplus::gui()->link('oidplus:login')).'</p>'; |
||
1075 | } |
||
1076 | |||
1077 | return $output; |
||
1078 | } |
||
1079 | |||
1080 | protected static function objDescription($html) { |
||
1081 | // We allow HTML, but no hacking |
||
1082 | $html = anti_xss($html); |
||
1083 | |||
1084 | return trim_br($html); |
||
1085 | } |
||
1086 | |||
1087 | // 'quickbars' added 11 July 2019: Disabled because of two problems: |
||
1088 | // 1. When you load TinyMCE via AJAX using the left menu, the quickbar is immediately shown, even if TinyMCE does not have the focus |
||
1089 | // 2. When you load a page without TinyMCE using the left menu, the quickbar is still visible, although there is no edit |
||
1090 | // 'colorpicker', 'textcolor' and 'contextmenu' added in 07 April 2020, because it is built in in the core. |
||
1091 | // 'importcss' added 17 September 2020, because it breaks the "Format/Style" dropdown box ("styleselect" toolbar) |
||
753 | daniel-mar | 1092 | // 'legacyoutput' added 24 September 2021, because it is declared as deprecated |
1093 | // 'spellchecker' added 6 October 2021, because it is declared as deprecated and marked for removal in TinyMCE 6.0 |
||
1094 | // 'imagetools' and 'toc' added 23 February 2022, because they are declared as deprecated and marked for removal in TinyMCE 6.0 ("moving to premium") |
||
1095 | public static $exclude_tinymce_plugins = array('fullpage', 'bbcode', 'quickbars', 'colorpicker', 'textcolor', 'contextmenu', 'importcss', 'legacyoutput', 'spellchecker', 'imagetools', 'toc'); |
||
635 | daniel-mar | 1096 | |
1097 | protected static function showMCE($name, $content) { |
||
1098 | $mce_plugins = array(); |
||
1099 | foreach (glob(OIDplus::localpath().'vendor/tinymce/tinymce/plugins/*') as $m) { // */ |
||
1100 | $mce_plugins[] = basename($m); |
||
1101 | } |
||
1102 | |||
1103 | foreach (self::$exclude_tinymce_plugins as $exclude) { |
||
1104 | $index = array_search($exclude, $mce_plugins); |
||
1105 | if ($index !== false) unset($mce_plugins[$index]); |
||
1106 | } |
||
1107 | |||
1108 | $oidplusLang = OIDplus::getCurrentLang(); |
||
1109 | |||
1110 | $langCandidates = array( |
||
1111 | strtolower(substr($oidplusLang,0,2)).'_'.strtoupper(substr($oidplusLang,2,2)), // de_DE |
||
1112 | strtolower(substr($oidplusLang,0,2)) // de |
||
1113 | ); |
||
1114 | $tinyMCELang = ''; |
||
1115 | foreach ($langCandidates as $candidate) { |
||
1116 | if (file_exists(OIDplus::localpath().'vendor/tweeb/tinymce-i18n/langs/'.$candidate.'.js')) { |
||
1117 | $tinyMCELang = $candidate; |
||
1118 | break; |
||
1119 | } |
||
1120 | } |
||
1121 | |||
1122 | $out = '<script> |
||
1123 | tinymce.EditorManager.baseURL = "vendor/tinymce/tinymce"; |
||
1124 | tinymce.init({ |
||
801 | daniel-mar | 1125 | document_base_url: "'.OIDplus::webpath(null,OIDplus::PATH_ABSOLUTE_CANONICAL).'", |
635 | daniel-mar | 1126 | selector: "#'.$name.'", |
1127 | height: 200, |
||
1128 | statusbar: false, |
||
1129 | // menubar:false, |
||
1130 | // toolbar: "undo redo | styleselect | bold italic | alignleft aligncenter alignright alignjustify | bullist numlist outdent indent | table | fontsizeselect", |
||
1131 | toolbar: "undo redo | styleselect | bold italic underline forecolor | bullist numlist | outdent indent | table | fontsizeselect", |
||
1132 | plugins: "'.implode(' ', $mce_plugins).'", |
||
1133 | mobile: { |
||
1134 | theme: "mobile", |
||
1135 | toolbar: "undo redo | styleselect | bold italic underline forecolor | bullist numlist | outdent indent | table | fontsizeselect", |
||
1136 | plugins: "'.implode(' ', $mce_plugins).'" |
||
1137 | } |
||
1138 | '.($tinyMCELang == '' ? '' : ', language : "'.$tinyMCELang.'"').' |
||
801 | daniel-mar | 1139 | '.($tinyMCELang == '' ? '' : ', language_url : "'.OIDplus::webpath(null,OIDplus::PATH_ABSOLUTE_CANONICAL).'vendor/tweeb/tinymce-i18n/langs/'.$tinyMCELang.'.js"').' |
635 | daniel-mar | 1140 | }); |
1141 | |||
1142 | pageChangeRequestCallbacks.push([OIDplusPagePublicObjects.cbQueryTinyMCE, "#'.$name.'"]); |
||
1143 | pageChangeCallbacks.push([OIDplusPagePublicObjects.cbRemoveTinyMCE, "#'.$name.'"]); |
||
1144 | </script>'; |
||
1145 | |||
1146 | $content = htmlentities($content); // For some reason, if we want to display the text "<xyz>" in TinyMCE, we need to double-encode things! < will not be accepted, we need &lt; ... why? |
||
1147 | |||
1148 | $out .= '<textarea name="'.htmlentities($name).'" id="'.htmlentities($name).'">'.trim($content).'</textarea><br>'; |
||
1149 | |||
1150 | return $out; |
||
1151 | } |
||
1152 | |||
1153 | public function implementsFeature($id) { |
||
1154 | if (strtolower($id) == '1.3.6.1.4.1.37476.2.5.2.3.1') return true; // oobeEntry, oobeRequested() |
||
952 | daniel-mar | 1155 | // Important: Do NOT 1.3.6.1.4.1.37476.2.5.2.3.7 because our getAlternativesForQuery() is the one that calls others! |
635 | daniel-mar | 1156 | return false; |
1157 | } |
||
1158 | |||
1159 | public function oobeRequested(): bool { |
||
1160 | // Interface 1.3.6.1.4.1.37476.2.5.2.3.1 |
||
1161 | |||
1162 | return OIDplus::config()->getValue('oobe_objects_done') == '0'; |
||
1163 | } |
||
1164 | |||
1165 | public function oobeEntry($step, $do_edits, &$errors_happened)/*: void*/ { |
||
1166 | // Interface 1.3.6.1.4.1.37476.2.5.2.3.1 |
||
1167 | |||
1168 | echo '<p><u>'._L('Step %1: Enable/Disable object type plugins',$step).'</u></p>'; |
||
1169 | echo '<p>'._L('Which object types do you want to manage using OIDplus?').'</p>'; |
||
1170 | |||
1171 | $enabled_ary = array(); |
||
1172 | |||
1173 | foreach (OIDplus::getEnabledObjectTypes() as $ot) { |
||
1174 | echo '<input type="checkbox" name="enable_ot_'.$ot::ns().'" id="enable_ot_'.$ot::ns().'"'; |
||
1175 | if (isset($_REQUEST['sent'])) { |
||
1176 | if (isset($_REQUEST['enable_ot_'.$ot::ns()])) { |
||
1177 | echo ' checked'; |
||
1178 | $enabled_ary[] = $ot::ns(); |
||
1179 | } |
||
1180 | } else { |
||
1181 | echo ' checked'; |
||
1182 | } |
||
1183 | echo '> <label for="enable_ot_'.$ot::ns().'">'.htmlentities($ot::objectTypeTitle()).'</label><br>'; |
||
1184 | } |
||
1185 | |||
1186 | foreach (OIDplus::getDisabledObjectTypes() as $ot) { |
||
1187 | echo '<input type="checkbox" name="enable_ot_'.$ot::ns().'" id="enable_ot_'.$ot::ns().'"'; |
||
1188 | if (isset($_REQUEST['sent'])) { |
||
1189 | if (isset($_REQUEST['enable_ot_'.$ot::ns()])) { |
||
1190 | echo ' checked'; |
||
1191 | $enabled_ary[] = $ot::ns(); |
||
1192 | } |
||
1193 | } else { |
||
1194 | echo ''; // <-- difference |
||
1195 | } |
||
1196 | echo '> <label for="enable_ot_'.$ot::ns().'">'.htmlentities($ot::objectTypeTitle()).'</label><br>'; |
||
1197 | } |
||
1198 | |||
1199 | $msg = ''; |
||
1200 | if ($do_edits) { |
||
1201 | try { |
||
1202 | OIDplus::config()->setValue('objecttypes_enabled', implode(';', $enabled_ary)); |
||
1203 | OIDplus::config()->setValue('oobe_objects_done', '1'); |
||
1204 | } catch (Exception $e) { |
||
1205 | $msg = $e->getMessage(); |
||
1206 | $errors_happened = true; |
||
1207 | } |
||
1208 | } |
||
1209 | |||
1210 | echo ' <font color="red"><b>'.$msg.'</b></font>'; |
||
1211 | } |
||
1212 | |||
693 | daniel-mar | 1213 | } |