Rev 1130 | Rev 1132 | Go to most recent revision | Show entire file | Regard whitespace | Details | Blame | Last modification | View Log | RSS feed
Rev 1130 | Rev 1131 | ||
---|---|---|---|
Line 21... | Line 21... | ||
21 | 21 | ||
22 | // phpcs:disable PSR1.Files.SideEffects |
22 | // phpcs:disable PSR1.Files.SideEffects |
23 | \defined('INSIDE_OIDPLUS') or die; |
23 | \defined('INSIDE_OIDPLUS') or die; |
24 | // phpcs:enable PSR1.Files.SideEffects |
24 | // phpcs:enable PSR1.Files.SideEffects |
25 | 25 | ||
26 | class OIDplusPagePublicObjects extends OIDplusPagePluginPublic { |
26 | class OIDplusPagePublicObjects extends OIDplusPagePluginPublic |
- | 27 | implements INTF_OID_1_3_6_1_4_1_37476_2_5_2_3_1, /* oobeEntry, oobeRequested */ |
|
- | 28 | INTF_OID_1_3_6_1_4_1_37476_2_5_2_3_8 /* getNotifications */ |
|
- | 29 | // Important: Do NOT implement INTF_OID_1_3_6_1_4_1_37476_2_5_2_3_7, because our getAlternativesForQuery() is the one that calls others! |
|
- | 30 | { |
|
27 | 31 | ||
28 | /** |
32 | /** |
29 | * @param string|OIDplusObject $ot |
33 | * @param string|OIDplusObject $ot |
30 | * @return string|null |
34 | * @return string|null |
31 | */ |
35 | */ |
Line 78... | Line 82... | ||
78 | 82 | ||
79 | // Check if permitted |
83 | // Check if permitted |
80 | if (!$obj->userHasParentalWriteRights()) throw new OIDplusException(_L('Authentication error. Please log in as the superior RA to delete this OID.')); |
84 | if (!$obj->userHasParentalWriteRights()) throw new OIDplusException(_L('Authentication error. Please log in as the superior RA to delete this OID.')); |
81 | 85 | ||
82 | foreach (OIDplus::getAllPlugins() as $plugin) { |
86 | foreach (OIDplus::getAllPlugins() as $plugin) { |
83 | if ($plugin->implementsFeature('1.3.6.1.4.1.37476.2.5.2.3.3')) { |
87 | if ($plugin instanceof INTF_OID_1_3_6_1_4_1_37476_2_5_2_3_3) { |
84 | $plugin->beforeObjectDelete($id); /** @phpstan-ignore-line */ |
88 | $plugin->beforeObjectDelete($id); |
85 | } |
89 | } |
86 | } |
90 | } |
87 | 91 | ||
88 | OIDplus::logger()->log("[WARN]OID($id)+[?WARN/!OK]SUPOIDRA($id)?/[?INFO/!OK]A?", "Object '$id' (recursively) deleted"); |
92 | OIDplus::logger()->log("[WARN]OID($id)+[?WARN/!OK]SUPOIDRA($id)?/[?INFO/!OK]A?", "Object '$id' (recursively) deleted"); |
89 | OIDplus::logger()->log("[CRIT]OIDRA($id)!", "Lost ownership of object '$id' because it was deleted"); |
93 | OIDplus::logger()->log("[CRIT]OIDRA($id)!", "Lost ownership of object '$id' because it was deleted"); |
Line 115... | Line 119... | ||
115 | } |
119 | } |
116 | OIDplus::db()->query("delete from ###asn1id where well_known = ? and oid not in (select id from ###objects where id like 'oid:%')", array(false)); |
120 | OIDplus::db()->query("delete from ###asn1id where well_known = ? and oid not in (select id from ###objects where id like 'oid:%')", array(false)); |
117 | OIDplus::db()->query("delete from ###iri where well_known = ? and oid not in (select id from ###objects where id like 'oid:%')", array(false)); |
121 | OIDplus::db()->query("delete from ###iri where well_known = ? and oid not in (select id from ###objects where id like 'oid:%')", array(false)); |
118 | 122 | ||
119 | foreach (OIDplus::getAllPlugins() as $plugin) { |
123 | foreach (OIDplus::getAllPlugins() as $plugin) { |
120 | if ($plugin->implementsFeature('1.3.6.1.4.1.37476.2.5.2.3.3')) { |
124 | if ($plugin instanceof INTF_OID_1_3_6_1_4_1_37476_2_5_2_3_3) { |
121 | $plugin->afterObjectDelete($id); /** @phpstan-ignore-line */ |
125 | $plugin->afterObjectDelete($id); |
122 | } |
126 | } |
123 | } |
127 | } |
124 | 128 | ||
125 | return array("status" => 0); |
129 | return array("status" => 0); |
126 | } |
130 | } |
Line 144... | Line 148... | ||
144 | 148 | ||
145 | // Check if permitted |
149 | // Check if permitted |
146 | if (!$obj->userHasParentalWriteRights()) throw new OIDplusException(_L('Authentication error. Please log in as the superior RA to update this OID.')); |
150 | if (!$obj->userHasParentalWriteRights()) throw new OIDplusException(_L('Authentication error. Please log in as the superior RA to update this OID.')); |
147 | 151 | ||
148 | foreach (OIDplus::getAllPlugins() as $plugin) { |
152 | foreach (OIDplus::getAllPlugins() as $plugin) { |
149 | if ($plugin->implementsFeature('1.3.6.1.4.1.37476.2.5.2.3.3')) { |
153 | if ($plugin instanceof INTF_OID_1_3_6_1_4_1_37476_2_5_2_3_3) { |
150 | $plugin->beforeObjectUpdateSuperior($id, $params); /** @phpstan-ignore-line */ |
154 | $plugin->beforeObjectUpdateSuperior($id, $params); |
151 | } |
155 | } |
152 | } |
156 | } |
153 | 157 | ||
154 | // First, do a simulation for ASN.1 IDs and IRIs to check if there are any problems (then an Exception will be thrown) |
158 | // First, do a simulation for ASN.1 IDs and IRIs to check if there are any problems (then an Exception will be thrown) |
155 | if ($obj::ns() == 'oid') { |
159 | if ($obj::ns() == 'oid') { |
Line 254... | Line 258... | ||
254 | $status += 4; |
258 | $status += 4; |
255 | } |
259 | } |
256 | } |
260 | } |
257 | 261 | ||
258 | foreach (OIDplus::getAllPlugins() as $plugin) { |
262 | foreach (OIDplus::getAllPlugins() as $plugin) { |
259 | if ($plugin->implementsFeature('1.3.6.1.4.1.37476.2.5.2.3.3')) { |
263 | if ($plugin instanceof INTF_OID_1_3_6_1_4_1_37476_2_5_2_3_3) { |
260 | $plugin->afterObjectUpdateSuperior($id, $params); /** @phpstan-ignore-line */ |
264 | $plugin->afterObjectUpdateSuperior($id, $params); |
261 | } |
265 | } |
262 | } |
266 | } |
263 | 267 | ||
264 | return array("status" => $status); |
268 | return array("status" => $status); |
265 | } |
269 | } |
Line 280... | Line 284... | ||
280 | 284 | ||
281 | // Check if allowed |
285 | // Check if allowed |
282 | if (!$obj->userHasWriteRights()) throw new OIDplusException(_L('Authentication error. Please log in as the RA to update this OID.')); |
286 | if (!$obj->userHasWriteRights()) throw new OIDplusException(_L('Authentication error. Please log in as the RA to update this OID.')); |
283 | 287 | ||
284 | foreach (OIDplus::getAllPlugins() as $plugin) { |
288 | foreach (OIDplus::getAllPlugins() as $plugin) { |
285 | if ($plugin->implementsFeature('1.3.6.1.4.1.37476.2.5.2.3.3')) { |
289 | if ($plugin instanceof INTF_OID_1_3_6_1_4_1_37476_2_5_2_3_3) { |
286 | $plugin->beforeObjectUpdateSelf($id, $params); /** @phpstan-ignore-line */ |
290 | $plugin->beforeObjectUpdateSelf($id, $params); |
287 | } |
291 | } |
288 | } |
292 | } |
289 | 293 | ||
290 | OIDplus::logger()->log("[INFO]OID($id)+[?INFO/!OK]OIDRA($id)?/[?INFO/!OK]A?", "Title/Description of object '$id' updated"); |
294 | OIDplus::logger()->log("[INFO]OID($id)+[?INFO/!OK]OIDRA($id)?/[?INFO/!OK]A?", "Title/Description of object '$id' updated"); |
291 | 295 | ||
Line 303... | Line 307... | ||
303 | 307 | ||
304 | OIDplus::db()->query("UPDATE ###objects SET updated = ".OIDplus::db()->sqlDate()." WHERE id = ?", array($id)); |
308 | OIDplus::db()->query("UPDATE ###objects SET updated = ".OIDplus::db()->sqlDate()." WHERE id = ?", array($id)); |
305 | OIDplusObject::resetObjectInformationCache(); |
309 | OIDplusObject::resetObjectInformationCache(); |
306 | 310 | ||
307 | foreach (OIDplus::getAllPlugins() as $plugin) { |
311 | foreach (OIDplus::getAllPlugins() as $plugin) { |
308 | if ($plugin->implementsFeature('1.3.6.1.4.1.37476.2.5.2.3.3')) { |
312 | if ($plugin instanceof INTF_OID_1_3_6_1_4_1_37476_2_5_2_3_3) { |
309 | $plugin->afterObjectUpdateSelf($id, $params); /** @phpstan-ignore-line */ |
313 | $plugin->afterObjectUpdateSelf($id, $params); |
310 | } |
314 | } |
311 | } |
315 | } |
312 | 316 | ||
313 | return array("status" => 0); |
317 | return array("status" => 0); |
314 | } |
318 | } |
Line 376... | Line 380... | ||
376 | 380 | ||
377 | $obj = OIDplusObject::parse($id); |
381 | $obj = OIDplusObject::parse($id); |
378 | if (!$obj) throw new OIDplusException(_L('%1 action failed because object "%2" cannot be parsed!','INSERT',$id)); |
382 | if (!$obj) throw new OIDplusException(_L('%1 action failed because object "%2" cannot be parsed!','INSERT',$id)); |
379 | 383 | ||
380 | foreach (OIDplus::getAllPlugins() as $plugin) { |
384 | foreach (OIDplus::getAllPlugins() as $plugin) { |
381 | if ($plugin->implementsFeature('1.3.6.1.4.1.37476.2.5.2.3.3')) { |
385 | if ($plugin instanceof INTF_OID_1_3_6_1_4_1_37476_2_5_2_3_3) { |
382 | $plugin->beforeObjectInsert($id, $params); /** @phpstan-ignore-line */ |
386 | $plugin->beforeObjectInsert($id, $params); |
383 | } |
387 | } |
384 | } |
388 | } |
385 | 389 | ||
386 | // First simulate if there are any problems of ASN.1 IDs und IRIs |
390 | // First simulate if there are any problems of ASN.1 IDs und IRIs |
387 | if ($obj::ns() == 'oid') { |
391 | if ($obj::ns() == 'oid') { |
Line 465... | Line 469... | ||
465 | $status += 4; |
469 | $status += 4; |
466 | } |
470 | } |
467 | } |
471 | } |
468 | 472 | ||
469 | foreach (OIDplus::getAllPlugins() as $plugin) { |
473 | foreach (OIDplus::getAllPlugins() as $plugin) { |
470 | if ($plugin->implementsFeature('1.3.6.1.4.1.37476.2.5.2.3.3')) { |
474 | if ($plugin instanceof INTF_OID_1_3_6_1_4_1_37476_2_5_2_3_3) { |
471 | $plugin->afterObjectInsert($id, $params); /** @phpstan-ignore-line */ |
475 | $plugin->afterObjectInsert($id, $params); |
472 | } |
476 | } |
473 | } |
477 | } |
474 | 478 | ||
475 | return array( |
479 | return array( |
476 | "status" => $status, |
480 | "status" => $status, |
Line 526... | Line 530... | ||
526 | /** |
530 | /** |
527 | * @param string $id |
531 | * @param string $id |
528 | * @return array |
532 | * @return array |
529 | */ |
533 | */ |
530 | public static function getAlternativesForQuery(string $id): array { |
534 | public static function getAlternativesForQuery(string $id): array { |
531 | // Attention: This is NOT an implementation of 1.3.6.1.4.1.37476.2.5.2.3.7 ! |
535 | // Attention: This is NOT an implementation of INTF_OID_1_3_6_1_4_1_37476_2_5_2_3_7! |
532 | // This is the function that calls getAlternativesForQuery() of every plugin that implements 1.3.6.1.4.1.37476.2.5.2.3.7 |
536 | // This is the function that calls getAlternativesForQuery() of every plugin that implements INTF_OID_1_3_6_1_4_1_37476_2_5_2_3_7 |
533 | 537 | ||
534 | // e.g. used for "Reverse Alt Id" |
538 | // e.g. used for "Reverse Alt Id" |
535 | $alternatives = array(); |
539 | $alternatives = array(); |
536 | foreach (OIDplus::getAllPlugins() as $plugin) { |
540 | foreach (OIDplus::getAllPlugins() as $plugin) { |
537 | if ($plugin->implementsFeature('1.3.6.1.4.1.37476.2.5.2.3.7')) { |
541 | if ($plugin instanceof INTF_OID_1_3_6_1_4_1_37476_2_5_2_3_7) { |
538 | $tmp = $plugin->getAlternativesForQuery($id); /** @phpstan-ignore-line */ |
542 | $tmp = $plugin->getAlternativesForQuery($id); |
539 | if (is_array($tmp)) { |
543 | if (is_array($tmp)) { |
540 | $alternatives = array_merge($tmp, $alternatives); |
544 | $alternatives = array_merge($tmp, $alternatives); |
541 | } |
545 | } |
542 | } |
546 | } |
543 | } |
547 | } |
Line 732... | Line 736... | ||
732 | $out['text'] .= "$aiddesc: <code>$ns:$aid</code>$suffix<br>"; |
736 | $out['text'] .= "$aiddesc: <code>$ns:$aid</code>$suffix<br>"; |
733 | } |
737 | } |
734 | } |
738 | } |
735 | 739 | ||
736 | foreach (OIDplus::getAllPlugins() as $plugin) { |
740 | foreach (OIDplus::getAllPlugins() as $plugin) { |
737 | if ($plugin->implementsFeature('1.3.6.1.4.1.37476.2.5.2.3.2')) { |
741 | if ($plugin instanceof INTF_OID_1_3_6_1_4_1_37476_2_5_2_3_2) { |
738 | $plugin->modifyContent($obj->nodeId(), $out['title'], $out['icon'], $out['text']); /** @phpstan-ignore-line */ |
742 | $plugin->modifyContent($obj->nodeId(), $out['title'], $out['icon'], $out['text']); |
739 | } |
743 | } |
740 | } |
744 | } |
741 | } |
745 | } |
742 | } |
746 | } |
743 | 747 | ||
Line 1083... | Line 1087... | ||
1083 | $output .= '<tr>'; |
1087 | $output .= '<tr>'; |
1084 | $prefix = $objParent->crudInsertPrefix(); |
1088 | $prefix = $objParent->crudInsertPrefix(); |
1085 | 1089 | ||
1086 | $suffix = $objParent->crudInsertSuffix(); |
1090 | $suffix = $objParent->crudInsertSuffix(); |
1087 | foreach (OIDplus::getObjectTypePlugins() as $plugin) { |
1091 | foreach (OIDplus::getObjectTypePlugins() as $plugin) { |
1088 | if (($plugin::getObjectTypeClassName()::ns() == $parentNS) && $plugin->implementsFeature('1.3.6.1.4.1.37476.2.5.2.3.6')) { |
1092 | if (($plugin::getObjectTypeClassName()::ns() == $parentNS) && ($plugin instanceof INTF_OID_1_3_6_1_4_1_37476_2_5_2_3_6)) { |
1089 | $suffix .= $plugin->gridGeneratorLinks($objParent); /** @phpstan-ignore-line */ |
1093 | $suffix .= $plugin->gridGeneratorLinks($objParent); |
1090 | } |
1094 | } |
1091 | } |
1095 | } |
1092 | 1096 | ||
1093 | if ($parentNS == 'guid') { |
1097 | if ($parentNS == 'guid') { |
1094 | $output .= ' <td>'.$prefix.' <input type="text" id="id" value="" style="width:100%;min-width:275px">'.$suffix.'</td>'; |
1098 | $output .= ' <td>'.$prefix.' <input type="text" id="id" value="" style="width:100%;min-width:275px">'.$suffix.'</td>'; |
Line 1229... | Line 1233... | ||
1229 | 1233 | ||
1230 | return $out; |
1234 | return $out; |
1231 | } |
1235 | } |
1232 | 1236 | ||
1233 | /** |
1237 | /** |
1234 | * @param string $id |
- | |
1235 | * @return bool |
- | |
1236 | */ |
- | |
1237 | public function implementsFeature(string $id): bool { |
- | |
1238 | if (strtolower($id) == '1.3.6.1.4.1.37476.2.5.2.3.1') return true; // oobeEntry, oobeRequested() |
- | |
1239 | // Important: Do NOT 1.3.6.1.4.1.37476.2.5.2.3.7 because our getAlternativesForQuery() is the one that calls others! |
- | |
1240 | if (strtolower($id) == '1.3.6.1.4.1.37476.2.5.2.3.8') return true; // getNotifications() |
- | |
1241 | return false; |
- | |
1242 | } |
- | |
1243 | - | ||
1244 | /** |
- | |
1245 | * Implements interface 1.3.6.1.4.1.37476.2.5.2.3.1 |
1238 | * Implements interface INTF_OID_1_3_6_1_4_1_37476_2_5_2_3_1 |
1246 | * @return bool |
1239 | * @return bool |
1247 | * @throws OIDplusException |
1240 | * @throws OIDplusException |
1248 | */ |
1241 | */ |
1249 | public function oobeRequested(): bool { |
1242 | public function oobeRequested(): bool { |
1250 | return OIDplus::config()->getValue('oobe_objects_done') == '0'; |
1243 | return OIDplus::config()->getValue('oobe_objects_done') == '0'; |
1251 | } |
1244 | } |
1252 | 1245 | ||
1253 | /** |
1246 | /** |
1254 | * Implements interface 1.3.6.1.4.1.37476.2.5.2.3.1 |
1247 | * Implements interface INTF_OID_1_3_6_1_4_1_37476_2_5_2_3_1 |
1255 | * @param int $step |
1248 | * @param int $step |
1256 | * @param bool $do_edits |
1249 | * @param bool $do_edits |
1257 | * @param bool $errors_happened |
1250 | * @param bool $errors_happened |
1258 | * @return void |
1251 | * @return void |
1259 | */ |
1252 | */ |
Line 1302... | Line 1295... | ||
1302 | 1295 | ||
1303 | echo ' <font color="red"><b>'.$msg.'</b></font>'; |
1296 | echo ' <font color="red"><b>'.$msg.'</b></font>'; |
1304 | } |
1297 | } |
1305 | 1298 | ||
1306 | /** |
1299 | /** |
1307 | * Implements interface 1.3.6.1.4.1.37476.2.5.2.3.8 |
1300 | * Implements interface INTF_OID_1_3_6_1_4_1_37476_2_5_2_3_8 |
1308 | * @param string|null $user |
1301 | * @param string|null $user |
1309 | * @return array |
1302 | * @return array |
1310 | * @throws OIDplusException |
1303 | * @throws OIDplusException |
1311 | */ |
1304 | */ |
1312 | public function getNotifications(string $user=null): array { |
1305 | public function getNotifications(string $user=null): array { |