Subversion Repositories oidplus

Rev

Rev 328 | Go to most recent revision | Blame | Last modification | View Log | RSS feed

  1. <?php
  2.  
  3. /*
  4.  * OIDplus 2.0
  5.  * Copyright 2019 Daniel Marschall, ViaThinkSoft
  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. class OIDplusPagePublicObjects extends OIDplusPagePluginPublic {
  21.  
  22.         private function ra_change_rec($id, $old_ra, $new_ra) {
  23.                 OIDplus::db()->query("update ###objects set ra_email = ?, updated = ".OIDplus::db()->sqlDate()." where id = ? and ifnull(ra_email,'') = ?", array($new_ra, $id, $old_ra));
  24.  
  25.                 $res = OIDplus::db()->query("select id from ###objects where parent = ? and ifnull(ra_email,'') = ?", array($id, $old_ra));
  26.                 while ($row = $res->fetch_array()) {
  27.                         $this->ra_change_rec($row['id'], $old_ra, $new_ra);
  28.                 }
  29.         }
  30.  
  31.         public function action($actionID, $params) {
  32.  
  33.                 // Action:     Delete
  34.                 // Method:     POST
  35.                 // Parameters: id
  36.                 // Outputs:    Text
  37.                 if ($actionID == 'Delete') {
  38.                         $id = $params['id'];
  39.                         $obj = OIDplusObject::parse($id);
  40.                         if ($obj === null) throw new OIDplusException(_L('%1 action failed because object "%2" cannot be parsed!','DELETE',$id));
  41.  
  42.                         if (OIDplus::db()->query("select id from ###objects where id = ?", array($id))->num_rows() == 0) {
  43.                                 throw new OIDplusException(_L('Object %1 does not exist',$id));
  44.                         }
  45.  
  46.                         // Check if permitted
  47.                         if (!$obj->userHasParentalWriteRights()) throw new OIDplusException(_L('Authentication error. Please log in as the superior RA to delete this OID.'));
  48.  
  49.                         foreach (OIDplus::getPagePlugins() as $plugin) {
  50.                                 if ($plugin->implementsFeature('1.3.6.1.4.1.37476.2.5.2.3.3')) {
  51.                                         $plugin->beforeObjectDelete($id);
  52.                                 }
  53.                         }
  54.  
  55.                         OIDplus::logger()->log("[WARN]OID($id)+[?WARN/!OK]SUPOIDRA($id)?/[?INFO/!OK]A?", "Object '$id' (recursively) deleted");
  56.                         OIDplus::logger()->log("[CRIT]OIDRA($id)!", "Lost ownership of object '$id' because it was deleted");
  57.  
  58.                         if ($parentObj = $obj->getParent()) {
  59.                                 $parent_oid = $parentObj->nodeId();
  60.                                 OIDplus::logger()->log("[WARN]OID($parent_oid)", "Object '$id' (recursively) deleted");
  61.                         }
  62.  
  63.                         // Delete object
  64.                         OIDplus::db()->query("delete from ###objects where id = ?", array($id));
  65.  
  66.                         // Delete orphan stuff
  67.                         foreach (OIDplus::getEnabledObjectTypes() as $ot) {
  68.                                 do {
  69.                                         $res = OIDplus::db()->query("select tchild.id from ###objects tchild " .
  70.                                                                     "left join ###objects tparent on tparent.id = tchild.parent " .
  71.                                                                     "where tchild.parent <> ? and tchild.id like ? and tparent.id is null;", array($ot::root(), $ot::root().'%'));
  72.                                         if ($res->num_rows() == 0) break;
  73.  
  74.                                         while ($row = $res->fetch_array()) {
  75.                                                 $id_to_delete = $row['id'];
  76.                                                 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");
  77.                                                 OIDplus::db()->query("delete from ###objects where id = ?", array($id_to_delete));
  78.                                         }
  79.                                 } while (true);
  80.                         }
  81.                         OIDplus::db()->query("delete from ###asn1id where well_known = '0' and oid not in (select id from ###objects where id like 'oid:%')");
  82.                         OIDplus::db()->query("delete from ###iri    where well_known = '0' and oid not in (select id from ###objects where id like 'oid:%')");
  83.  
  84.                         foreach (OIDplus::getPagePlugins() as $plugin) {
  85.                                 if ($plugin->implementsFeature('1.3.6.1.4.1.37476.2.5.2.3.3')) {
  86.                                         $plugin->afterObjectDelete($id);
  87.                                 }
  88.                         }
  89.  
  90.                         return array("status" => 0);
  91.                 }
  92.  
  93.                 // Action:     Update
  94.                 // Method:     POST
  95.                 // Parameters: id, ra_email, comment, iris, asn1ids, confidential
  96.                 // Outputs:    Text
  97.                 else if ($actionID == 'Update') {
  98.                         $id = $params['id'];
  99.                         $obj = OIDplusObject::parse($id);
  100.                         if ($obj === null) throw new OIDplusException(_L('%1 action failed because object "%2" cannot be parsed!','UPDATE',$id));
  101.  
  102.                         if (OIDplus::db()->query("select id from ###objects where id = ?", array($id))->num_rows() == 0) {
  103.                                 throw new OIDplusException(_L('Object %1 does not exist',$id));
  104.                         }
  105.  
  106.                         // Check if permitted
  107.                         if (!$obj->userHasParentalWriteRights()) throw new OIDplusException(_L('Authentication error. Please log in as the superior RA to update this OID.'));
  108.  
  109.                         foreach (OIDplus::getPagePlugins() as $plugin) {
  110.                                 if ($plugin->implementsFeature('1.3.6.1.4.1.37476.2.5.2.3.3')) {
  111.                                         $plugin->beforeObjectUpdateSuperior($id, $params);
  112.                                 }
  113.                         }
  114.  
  115.                         // Validate RA email address
  116.                         $new_ra = $params['ra_email'];
  117.                         if (!empty($new_ra) && !OIDplus::mailUtils()->validMailAddress($new_ra)) {
  118.                                 throw new OIDplusException(_L('Invalid RA email address'));
  119.                         }
  120.  
  121.                         // First, do a simulation for ASN.1 IDs and IRIs to check if there are any problems (then an Exception will be thrown)
  122.                         if ($obj::ns() == 'oid') {
  123.                                 $ids = ($params['iris'] == '') ? array() : explode(',',$params['iris']);
  124.                                 $ids = array_map('trim',$ids);
  125.                                 $obj->replaceIris($ids, true);
  126.  
  127.                                 $ids = ($params['asn1ids'] == '') ? array() : explode(',',$params['asn1ids']);
  128.                                 $ids = array_map('trim',$ids);
  129.                                 $obj->replaceAsn1Ids($ids, true);
  130.                         }
  131.  
  132.                         // Change RA recursively
  133.                         $res = OIDplus::db()->query("select ra_email from ###objects where id = ?", array($id));
  134.                         if ($row = $res->fetch_array()) {
  135.                                 $current_ra = $row['ra_email'];
  136.                                 if ($new_ra != $current_ra) {
  137.                                         OIDplus::logger()->log("[INFO]OID($id)+[?INFO/!OK]SUPOIDRA($id)?/[?INFO/!OK]A?", "RA of object '$id' changed from '$current_ra' to '$new_ra'");
  138.                                         OIDplus::logger()->log("[WARN]RA($current_ra)!",           "Lost ownership of object '$id' due to RA transfer of superior RA / admin.");
  139.                                         OIDplus::logger()->log("[INFO]RA($new_ra)!",               "Gained ownership of object '$id' due to RA transfer of superior RA / admin.");
  140.                                         if ($parentObj = $obj->getParent()) {
  141.                                                 $parent_oid = $parentObj->nodeId();
  142.                                                 OIDplus::logger()->log("[INFO]OID($parent_oid)", "RA of object '$id' changed from '$current_ra' to '$new_ra'");
  143.                                         }
  144.                                         $this->ra_change_rec($id, $current_ra, $new_ra); // Inherited RAs rekursiv mitändern
  145.                                 }
  146.                         }
  147.  
  148.                         // Log if confidentially flag was changed
  149.                         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!
  150.                         if ($parentObj = $obj->getParent()) {
  151.                                 $parent_oid = $parentObj->nodeId();
  152.                                 OIDplus::logger()->log("[INFO]OID($parent_oid)", "Identifiers/Confidential flag of object '$id' updated"); // TODO: Check if they were ACTUALLY updated!
  153.                         }
  154.  
  155.                         // Replace ASN.1 IDs und IRIs
  156.                         if ($obj::ns() == 'oid') {
  157.                                 $ids = ($params['iris'] == '') ? array() : explode(',',$params['iris']);
  158.                                 $ids = array_map('trim',$ids);
  159.                                 $obj->replaceIris($ids, false);
  160.  
  161.                                 $ids = ($params['asn1ids'] == '') ? array() : explode(',',$params['asn1ids']);
  162.                                 $ids = array_map('trim',$ids);
  163.                                 $obj->replaceAsn1Ids($ids, false);
  164.  
  165.                                 // TODO: Check if any identifiers have been actually changed,
  166.                                 // and log it to OID($id), OID($parent), ... (see above)
  167.                         }
  168.  
  169.                         $confidential = $params['confidential'] == 'true';
  170.                         $comment = $params['comment'];
  171.                         OIDplus::db()->query("UPDATE ###objects SET confidential = ?, comment = ?, updated = ".OIDplus::db()->sqlDate()." WHERE id = ?", array($confidential, $comment, $id));
  172.  
  173.                         $status = 0;
  174.  
  175.                         if (!empty($new_ra)) {
  176.                                 $res = OIDplus::db()->query("select ra_name from ###ra where email = ?", array($new_ra));
  177.                                 if ($res->num_rows() == 0) $status = class_exists('OIDplusPageRaInvite') && OIDplus::config()->getValue('ra_invitation_enabled') ? 1 : 2;
  178.                         }
  179.  
  180.                         foreach (OIDplus::getPagePlugins() as $plugin) {
  181.                                 if ($plugin->implementsFeature('1.3.6.1.4.1.37476.2.5.2.3.3')) {
  182.                                         $plugin->afterObjectUpdateSuperior($id, $params);
  183.                                 }
  184.                         }
  185.  
  186.                         return array("status" => $status);
  187.                 }
  188.  
  189.                 // Action:     Update2
  190.                 // Method:     POST
  191.                 // Parameters: id, title, description
  192.                 // Outputs:    Text
  193.                 else if ($actionID == 'Update2') {
  194.                         $id = $params['id'];
  195.                         $obj = OIDplusObject::parse($id);
  196.                         if ($obj === null) throw new OIDplusException(_L('%1 action failed because object "%2" cannot be parsed!','UPDATE2',$id));
  197.  
  198.                         if (OIDplus::db()->query("select id from ###objects where id = ?", array($id))->num_rows() == 0) {
  199.                                 throw new OIDplusException(_L('Object %1 does not exist',$id));
  200.                         }
  201.  
  202.                         // Check if allowed
  203.                         if (!$obj->userHasWriteRights()) throw new OIDplusException(_L('Authentication error. Please log in as the RA to update this OID.'));
  204.  
  205.                         foreach (OIDplus::getPagePlugins() as $plugin) {
  206.                                 if ($plugin->implementsFeature('1.3.6.1.4.1.37476.2.5.2.3.3')) {
  207.                                         $plugin->beforeObjectUpdateSelf($id, $params);
  208.                                 }
  209.                         }
  210.  
  211.                         OIDplus::logger()->log("[INFO]OID($id)+[?INFO/!OK]OIDRA($id)?/[?INFO/!OK]A?", "Title/Description of object '$id' updated");
  212.  
  213.                         OIDplus::db()->query("UPDATE ###objects SET title = ?, description = ?, updated = ".OIDplus::db()->sqlDate()." WHERE id = ?", array($params['title'], $params['description'], $id));
  214.  
  215.                         foreach (OIDplus::getPagePlugins() as $plugin) {
  216.                                 if ($plugin->implementsFeature('1.3.6.1.4.1.37476.2.5.2.3.3')) {
  217.                                         $plugin->afterObjectUpdateSelf($id, $params);
  218.                                 }
  219.                         }
  220.  
  221.                         return array("status" => 0);
  222.                 }
  223.  
  224.                 // Action:     Insert
  225.                 // Method:     POST
  226.                 // Parameters: parent, id, ra_email, confidential, iris, asn1ids
  227.                 // Outputs:    Text
  228.                 else if ($actionID == 'Insert') {
  229.                         // Validated are: ID, ra email, asn1 ids, iri ids
  230.  
  231.                         // Check if you have write rights on the parent (to create a new object)
  232.                         $objParent = OIDplusObject::parse($params['parent']);
  233.                         if ($objParent === null) throw new OIDplusException(_L('%1 action failed because parent object "%2" cannot be parsed!','INSERT',$params['parent']));
  234.  
  235.                         if (!$objParent::root() && (OIDplus::db()->query("select id from ###objects where id = ?", array($objParent->nodeId()))->num_rows() == 0)) {
  236.                                 throw new OIDplusException(_L('Parent object %1 does not exist','".($objParent->nodeId())."'));
  237.                         }
  238.  
  239.                         if (!$objParent->userHasWriteRights()) throw new OIDplusException(_L('Authentication error. Please log in as the correct RA to insert an OID at this arc.'));
  240.  
  241.                         // Check if the ID is valid
  242.                         if ($params['id'] == '') throw new OIDplusException(_L('ID may not be empty'));
  243.  
  244.                         // Determine absolute OID name
  245.                         // Note: At addString() and parse(), the syntax of the ID will be checked
  246.                         $id = $objParent->addString($params['id']);
  247.  
  248.                         // Check, if the OID exists
  249.                         $test = OIDplus::db()->query("select id from ###objects where id = ?", array($id));
  250.                         if ($test->num_rows() >= 1) {
  251.                                 throw new OIDplusException(_L('Object %1 already exists!',$id));
  252.                         }
  253.  
  254.                         $obj = OIDplusObject::parse($id);
  255.                         if ($obj === null) throw new OIDplusException(_L('%1 action failed because object "%2" cannot be parsed!','INSERT',$id));
  256.  
  257.                         foreach (OIDplus::getPagePlugins() as $plugin) {
  258.                                 if ($plugin->implementsFeature('1.3.6.1.4.1.37476.2.5.2.3.3')) {
  259.                                         $plugin->beforeObjectInsert($id, $params);
  260.                                 }
  261.                         }
  262.  
  263.                         // First simulate if there are any problems of ASN.1 IDs und IRIs
  264.                         if ($obj::ns() == 'oid') {
  265.                                 $ids = ($params['iris'] == '') ? array() : explode(',',$params['iris']);
  266.                                 $ids = array_map('trim',$ids);
  267.                                 $obj->replaceAsn1Ids($ids, true);
  268.  
  269.                                 $ids = ($params['asn1ids'] == '') ? array() : explode(',',$params['asn1ids']);
  270.                                 $ids = array_map('trim',$ids);
  271.                                 $obj->replaceIris($ids, true);
  272.                         }
  273.  
  274.                         // Apply superior RA change
  275.                         $parent = $params['parent'];
  276.                         $ra_email = $params['ra_email'];
  277.                         if (!empty($ra_email) && !OIDplus::mailUtils()->validMailAddress($ra_email)) {
  278.                                 throw new OIDplusException(_L('Invalid RA email address'));
  279.                         }
  280.  
  281.                         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'";
  282.                         if (!empty($ra_email)) {
  283.                                 OIDplus::logger()->log("[INFO]RA($ra_email)!", "Gained ownership of newly created object '$id'");
  284.                         }
  285.  
  286.                         $confidential = $params['confidential'] == 'true';
  287.                         $comment = $params['comment'];
  288.                         $title = '';
  289.                         $description = '';
  290.  
  291.                         if (strlen($id) > OIDplus::baseConfig()->getValue('LIMITS_MAX_ID_LENGTH')) {
  292.                                 $maxlen = OIDplus::baseConfig()->getValue('LIMITS_MAX_ID_LENGTH');
  293.                                 throw new OIDplusException(_L('The identifier %1 is too long (max allowed length: %2)',$id,$maxlen));
  294.                         }
  295.  
  296.                         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));
  297.  
  298.                         // Set ASN.1 IDs und IRIs
  299.                         if ($obj::ns() == 'oid') {
  300.                                 $ids = ($params['iris'] == '') ? array() : explode(',',$params['iris']);
  301.                                 $ids = array_map('trim',$ids);
  302.                                 $obj->replaceIris($ids, false);
  303.  
  304.                                 $ids = ($params['asn1ids'] == '') ? array() : explode(',',$params['asn1ids']);
  305.                                 $ids = array_map('trim',$ids);
  306.                                 $obj->replaceAsn1Ids($ids, false);
  307.                         }
  308.  
  309.                         $status = 0;
  310.  
  311.                         if (!empty($ra_email)) {
  312.                                 // Do we need to notify that the RA does not exist?
  313.                                 $res = OIDplus::db()->query("select ra_name from ###ra where email = ?", array($ra_email));
  314.                                 if ($res->num_rows() == 0) $status = class_exists('OIDplusPageRaInvite') && OIDplus::config()->getValue('ra_invitation_enabled') ? 1 : 2;
  315.                         }
  316.  
  317.                         foreach (OIDplus::getPagePlugins() as $plugin) {
  318.                                 if ($plugin->implementsFeature('1.3.6.1.4.1.37476.2.5.2.3.3')) {
  319.                                         $plugin->afterObjectInsert($id, $params);
  320.                                 }
  321.                         }
  322.  
  323.                         return array("status" => $status);
  324.                 } else {
  325.                         throw new OIDplusException(_L('Unknown action ID'));
  326.                 }
  327.         }
  328.  
  329.         public function init($html=true) {
  330.         }
  331.  
  332.         public function gui($id, &$out, &$handled) {
  333.                 if ($id === 'oidplus:system') {
  334.                         $handled = true;
  335.  
  336.                         $out['title'] = OIDplus::config()->getValue('system_title');
  337.                         $out['icon'] = OIDplus::webpath(__DIR__).'system_big.png';
  338.  
  339.                         if (file_exists(OIDplus::basePath() . '/userdata/welcome/welcome$'.OIDplus::getCurrentLang().'.html')) {
  340.                                 $out['text'] = file_get_contents(OIDplus::basePath() . '/userdata/welcome/welcome$'.OIDplus::getCurrentLang().'.html');
  341.                         } else if (file_exists(OIDplus::basePath() . '/userdata/welcome/welcome.html')) {
  342.                                 $out['text'] = file_get_contents(OIDplus::basePath() . '/userdata/welcome/welcome.html');
  343.                         } else if (file_exists(__DIR__ . '/welcome.local.html')) {
  344.                                 $out['text'] = file_get_contents(__DIR__ . '/welcome.local.html'); // Backwards compatibility. Do not use!
  345.                         } else if (file_exists(__DIR__ . '/welcome$'.OIDplus::getCurrentLang().'.html')) {
  346.                                 $out['text'] = file_get_contents(__DIR__ . '/welcome$'.OIDplus::getCurrentLang().'.html');
  347.                         } else if (file_exists(__DIR__ . '/welcome.html')) {
  348.                                 $out['text'] = file_get_contents(__DIR__ . '/welcome.html');
  349.                         } else {
  350.                                 $out['text'] = '';
  351.                         }
  352.  
  353.                         // make sure the program works even if the user provided HTML is not UTF-8
  354.                         $out['text'] = iconv(mb_detect_encoding($out['text'], mb_detect_order(), true), 'UTF-8', $out['text']);
  355.  
  356.                         if (strpos($out['text'], '%%OBJECT_TYPE_LIST%%') !== false) {
  357.                                 $tmp = '<ul>';
  358.                                 foreach (OIDplus::getEnabledObjectTypes() as $ot) {
  359.                                         $tmp .= '<li><a '.OIDplus::gui()->link($ot::root()).'>'.htmlentities($ot::objectTypeTitle()).'</a></li>';
  360.                                 }
  361.                                 $tmp .= '</ul>';
  362.                                 $out['text'] = str_replace('%%OBJECT_TYPE_LIST%%', $tmp, $out['text']);
  363.                         }
  364.  
  365.                         return;
  366.                 }
  367.  
  368.                 try {
  369.                         $obj = OIDplusObject::parse($id);
  370.                 } catch (Exception $e) {
  371.                         $obj = null;
  372.                 }
  373.  
  374.                 if (!is_null($obj)) {
  375.                         $handled = true;
  376.  
  377.                         if (!$obj->userHasReadRights()) {
  378.                                 $out['title'] = _L('Access denied');
  379.                                 $out['icon'] = 'img/error_big.png';
  380.                                 $out['text'] = '<p>'._L('Please <a %1>log in</a> to receive information about this object.',OIDplus::gui()->link('oidplus:login')).'</p>';
  381.                                 return;
  382.                         }
  383.  
  384.                         $parent = null;
  385.                         $res = null;
  386.                         $row = null;
  387.                         $matches_any_registered_type = false;
  388.                         foreach (OIDplus::getEnabledObjectTypes() as $ot) {
  389.                                 if ($obj = $ot::parse($id)) {
  390.                                         $matches_any_registered_type = true;
  391.                                         if ($obj->isRoot()) {
  392.                                                 $obj->getContentPage($out['title'], $out['text'], $out['icon']);
  393.                                                 $parent = null; // $obj->getParent();
  394.                                                 break;
  395.                                         } else {
  396.                                                 $res = OIDplus::db()->query("select * from ###objects where id = ?", array($obj->nodeId()));
  397.                                                 if ($res->num_rows() == 0) {
  398.                                                         http_response_code(404);
  399.                                                         $out['title'] = _L('Object not found');
  400.                                                         $out['icon'] = 'img/error_big.png';
  401.                                                         $out['text'] = _L('The object %1 was not found in this database.','<code>'.htmlentities($id).'</code>');
  402.                                                         return;
  403.                                                 } else {
  404.                                                         $row = $res->fetch_array(); // will be used further down the code
  405.                                                         $obj->getContentPage($out['title'], $out['text'], $out['icon']);
  406.                                                         if (empty($out['title'])) $out['title'] = explode(':',$id,2)[1];
  407.                                                         $parent = $obj->getParent();
  408.                                                         break;
  409.                                                 }
  410.                                         }
  411.                                 }
  412.                         }
  413.                         if (!$matches_any_registered_type) {
  414.                                 http_response_code(404);
  415.                                 $out['title'] = _L('Object not found');
  416.                                 $out['icon'] = 'img/error_big.png';
  417.                                 $out['text'] = _L('The object %1 was not found in this database.','<code>'.htmlentities($id).'</code>');
  418.                                 return;
  419.                         }
  420.  
  421.                         // ---
  422.  
  423.                         if ($parent) {
  424.                                 if ($parent->isRoot()) {
  425.  
  426.                                         $parent_link_text = $parent->objectTypeTitle();
  427.                                         $out['text'] = '<p><a '.OIDplus::gui()->link($parent->root()).'><img src="img/arrow_back.png" width="16"> '._L('Parent node: %1',htmlentities($parent_link_text)).'</a></p>' . $out['text'];
  428.  
  429.                                 } else {
  430.                                         $res_ = OIDplus::db()->query("select * from ###objects where id = ?", array($parent->nodeId()));
  431.                                         if ($res_->num_rows() > 0) {
  432.                                                 $row_ = $res_->fetch_array();
  433.  
  434.                                                 $parent_title = $row_['title'];
  435.                                                 if (empty($parent_title) && ($parent->ns() == 'oid')) {
  436.                                                         // If not title is available, then use an ASN.1 identifier
  437.                                                         $res_ = OIDplus::db()->query("select name from ###asn1id where oid = ?", array($parent->nodeId()));
  438.                                                         if ($res_->num_rows() > 0) {
  439.                                                                 $row_ = $res_->fetch_array();
  440.                                                                 $parent_title = $row_['name']; // TODO: multiple ASN1 ids?
  441.                                                         }
  442.                                                 }
  443.  
  444.                                                 $parent_link_text = empty($parent_title) ? explode(':',$parent->nodeId())[1] : $parent_title.' ('.explode(':',$parent->nodeId())[1].')';
  445.  
  446.                                                 $out['text'] = '<p><a '.OIDplus::gui()->link($parent->nodeId()).'><img src="img/arrow_back.png" width="16"> '._L('Parent node: %1',htmlentities($parent_link_text)).'</a></p>' . $out['text'];
  447.                                         } else {
  448.                                                 $out['text'] = '';
  449.                                         }
  450.                                 }
  451.                         } else {
  452.                                 $parent_link_text = _L('Go back to front page');
  453.                                 $out['text'] = '<p><a '.OIDplus::gui()->link('oidplus:system').'><img src="img/arrow_back.png" width="16"> '.htmlentities($parent_link_text).'</a></p>' . $out['text'];
  454.                         }
  455.  
  456.                         // ---
  457.  
  458.                         if (!is_null($row) && isset($row['description'])) {
  459.                                 if (empty($row['description'])) {
  460.                                         if (empty($row['title'])) {
  461.                                                 $desc = '<p><i>'._L('No description for this object available').'</i></p>';
  462.                                         } else {
  463.                                                 $desc = $row['title'];
  464.                                         }
  465.                                 } else {
  466.                                         $desc = self::objDescription($row['description']);
  467.                                 }
  468.  
  469.                                 if ($obj->userHasWriteRights()) {
  470.                                         $rand = ++self::$crudCounter;
  471.                                         $desc = '<noscript><p><b>'._L('You need to enable JavaScript to edit title or description of this object.').'</b></p>'.$desc.'</noscript>';
  472.                                         $desc .= '<div class="container box" style="display:none" id="descbox_'.$rand.'">';
  473.                                         $desc .= _L('Title').': <input type="text" name="title" id="titleedit" value="'.htmlentities($row['title']).'"><br><br>'._L('Description').':<br>';
  474.                                         $desc .= self::showMCE('description', $row['description']);
  475.                                         $desc .= '<button type="button" name="update_desc" id="update_desc" class="btn btn-success btn-xs update" onclick="updateDesc()">'._L('Update description').'</button>';
  476.                                         $desc .= '</div>';
  477.                                         $desc .= '<script>document.getElementById("descbox_'.$rand.'").style.display = "block";</script>';
  478.                                 }
  479.                         } else {
  480.                                 $desc = '';
  481.                         }
  482.  
  483.                         // ---
  484.  
  485.                         if (strpos($out['text'], '%%DESC%%') !== false)
  486.                                 $out['text'] = str_replace('%%DESC%%',    $desc,                              $out['text']);
  487.                         if (strpos($out['text'], '%%CRUD%%') !== false)
  488.                                 $out['text'] = str_replace('%%CRUD%%',    self::showCrud($id),                $out['text']);
  489.                         if (strpos($out['text'], '%%RA_INFO%%') !== false)
  490.                                 $out['text'] = str_replace('%%RA_INFO%%', OIDplusPagePublicRaInfo::showRaInfo($row['ra_email']), $out['text']);
  491.  
  492.                         $alt_ids = $obj->getAltIds();
  493.                         if (count($alt_ids) > 0) {
  494.                                 $out['text'] .= '<h2>'._L('Alternative Identifiers').'</h2>';
  495.                                 foreach ($alt_ids as $alt_id) {
  496.                                         $ns = $alt_id->getNamespace();
  497.                                         $aid = $alt_id->getId();
  498.                                         $aiddesc = $alt_id->getDescription();
  499.                                         $out['text'] .= "$aiddesc <code>$ns:$aid</code><br>";
  500.                                 }
  501.                         }
  502.  
  503.                         foreach (OIDplus::getPagePlugins() as $plugin) {
  504.                                 if ($plugin->implementsFeature('1.3.6.1.4.1.37476.2.5.2.3.2')) {
  505.                                         $plugin->modifyContent($id, $out['title'], $out['icon'], $out['text']);
  506.                                 }
  507.                         }
  508.                 }
  509.         }
  510.  
  511.         private function publicSitemap_rec($json, &$out) {
  512.                 foreach ($json as $x) {
  513.                         if (isset($x['id']) && $x['id']) {
  514.                                 $out[] = $x['id'];
  515.                         }
  516.                         if (isset($x['children'])) {
  517.                                 $this->publicSitemap_rec($x['children'], $out);
  518.                         }
  519.                 }
  520.         }
  521.  
  522.         public function publicSitemap(&$out) {
  523.                 $json = array();
  524.                 $this->tree($json, null/*RA EMail*/, false/*HTML tree algorithm*/, true/*display all*/);
  525.                 $this->publicSitemap_rec($json, $out);
  526.         }
  527.  
  528.         public function tree(&$json, $ra_email=null, $nonjs=false, $req_goto='') {
  529.                 if ($nonjs) {
  530.                         $json[] = array('id' => 'oidplus:system', 'icon' => OIDplus::webpath(__DIR__).'system.png', 'text' => _L('System'));
  531.  
  532.                         $parent = '';
  533.                         $res = OIDplus::db()->query("select parent from ###objects where id = ?", array($req_goto));
  534.                         while ($row = $res->fetch_object()) {
  535.                                 $parent = $row->parent;
  536.                         }
  537.  
  538.                         $objTypesChildren = array();
  539.                         foreach (OIDplus::getEnabledObjectTypes() as $ot) {
  540.                                 $icon = 'plugins/objectTypes/'.$ot::ns().'/img/treeicon_root.png';
  541.                                 $json[] = array('id' => $ot::root(), 'icon' => $icon, 'text' => $ot::objectTypeTitle());
  542.  
  543.                                 try {
  544.                                         $tmp = OIDplusObject::parse($req_goto);
  545.                                 } catch (Exception $e) {
  546.                                         $tmp = null;
  547.                                 }
  548.                                 if (!is_null($tmp) && ($ot == get_class($tmp))) {
  549.                                         // 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
  550.                                         //       on the other hand, for giving search engines content, this is good enough
  551.                                         if (empty($parent)) {
  552.                                                 $res = OIDplus::db()->query("select * from ###objects where " .
  553.                                                                                    "parent = ? or " .
  554.                                                                                    "id = ? " .
  555.                                                                                    "order by ".OIDplus::db()->natOrder('id'), array($req_goto, $req_goto));
  556.                                         } else {
  557.                                                 $res = OIDplus::db()->query("select * from ###objects where " .
  558.                                                                                    "parent = ? or " .
  559.                                                                                    "id = ? or " .
  560.                                                                                    "id = ? ".
  561.                                                                                    "order by ".OIDplus::db()->natOrder('id'), array($req_goto, $req_goto, $parent));
  562.                                         }
  563.  
  564.                                         $z_used = 0;
  565.                                         $y_used = 0;
  566.                                         $x_used = 0;
  567.                                         $stufe = 0;
  568.                                         $menu_entries = array();
  569.                                         $stufen = array();
  570.                                         while ($row = $res->fetch_object()) {
  571.                                                 $obj = OIDplusObject::parse($row->id);
  572.                                                 if (is_null($obj)) continue; // might happen if the objectType is not available/loaded
  573.                                                 if (!$obj->userHasReadRights()) continue;
  574.                                                 $txt = $row->title == '' ? '' : ' -- '.htmlentities($row->title);
  575.  
  576.                                                 if ($row->id == $parent) { $stufe=0; $z_used++; }
  577.                                                 if ($row->id == $req_goto) { $stufe=1; $y_used++; }
  578.                                                 if ($row->parent == $req_goto) { $stufe=2; $x_used++; }
  579.  
  580.                                                 $menu_entry = array('id' => $row->id, 'icon' => '', 'text' => $txt, 'indent' => 0);
  581.                                                 $menu_entries[] = $menu_entry;
  582.                                                 $stufen[] = $stufe;
  583.                                         }
  584.                                         if ($x_used) foreach ($menu_entries as $i => &$menu_entry) if ($stufen[$i] >= 2) $menu_entry['indent'] += 1;
  585.                                         if ($y_used) foreach ($menu_entries as $i => &$menu_entry) if ($stufen[$i] >= 1) $menu_entry['indent'] += 1;
  586.                                         if ($z_used) foreach ($menu_entries as $i => &$menu_entry) if ($stufen[$i] >= 0) $menu_entry['indent'] += 1;
  587.                                         $json = array_merge($json, $menu_entries);
  588.                                 }
  589.                         }
  590.  
  591.                         return true;
  592.                 } else {
  593.                         if ($req_goto === true) {
  594.                                 $goto_path = true; // display everything recursively
  595.                         } else if (isset($req_goto)) {
  596.                                 $goto = $req_goto;
  597.                                 $path = array();
  598.                                 while (true) {
  599.                                         $path[] = $goto;
  600.                                         $res = OIDplus::db()->query("select parent from ###objects where id = ?", array($goto));
  601.                                         if ($res->num_rows() == 0) break;
  602.                                         $row = $res->fetch_array();
  603.                                         $goto = $row['parent'];
  604.                                         if ($goto == '') continue;
  605.                                 }
  606.  
  607.                                 $goto_path = array_reverse($path);
  608.                         } else {
  609.                                 $goto_path = null;
  610.                         }
  611.  
  612.                         $objTypesChildren = array();
  613.                         foreach (OIDplus::getEnabledObjectTypes() as $ot) {
  614.                                 $child = array('id' => $ot::root(),
  615.                                                'text' => $ot::objectTypeTitle(),
  616.                                                'state' => array("opened" => true),
  617.                                                'icon' => 'plugins/objectTypes/'.$ot::ns().'/img/treeicon_root.png',
  618.                                                'children' => OIDplus::menuUtils()->tree_populate($ot::root(), $goto_path)
  619.                                                );
  620.                                 if (!file_exists($child['icon'])) $child['icon'] = null; // default icon (folder)
  621.                                 $objTypesChildren[] = $child;
  622.                         }
  623.  
  624.                         $json[] = array(
  625.                                 'id' => "oidplus:system",
  626.                                 'text' => _L('Objects'),
  627.                                 'state' => array(
  628.                                         "opened" => true,
  629.                                         // "selected" => true)  // "selected" ist buggy: 1) Das select-Event wird beim Laden nicht gefeuert 2) Die direkt untergeordneten Knoten lassen sich nicht öffnen (laden für ewig)
  630.                                 ),
  631.                                 'icon' => OIDplus::webpath(__DIR__).'system.png',
  632.                                 'children' => $objTypesChildren
  633.                         );
  634.  
  635.                         return true;
  636.                 }
  637.         }
  638.  
  639.         public function tree_search($request) {
  640.                 $ary = array();
  641.                 if ($obj = OIDplusObject::parse($request)) {
  642.                         if ($obj->userHasReadRights()) {
  643.                                 do {
  644.                                         $ary[] = $obj->nodeId();
  645.                                 } while ($obj = $obj->getParent());
  646.                                 $ary = array_reverse($ary);
  647.                         }
  648.                 }
  649.                 return $ary;
  650.         }
  651.  
  652.         private static $crudCounter = 0;
  653.  
  654.         protected static function showCrud($parent='oid:') {
  655.                 $items_total = 0;
  656.                 $items_hidden = 0;
  657.  
  658.                 $objParent = OIDplusObject::parse($parent);
  659.                 $parentNS = $objParent::ns();
  660.  
  661.                 $result = OIDplus::db()->query("select o.*, r.ra_name " .
  662.                                                "from ###objects o " .
  663.                                                "left join ###ra r on r.email = o.ra_email " .
  664.                                                "where parent = ? " .
  665.                                                "order by ".OIDplus::db()->natOrder('id'), array($parent));
  666.                 $rows = array();
  667.                 if ($parentNS == 'oid') {
  668.                         $one_weid_available = $objParent->isWeid(true);
  669.                         while ($row = $result->fetch_object()) {
  670.                                 $obj = OIDplusObject::parse($row->id);
  671.                                 $rows[] = array($obj,$row);
  672.                                 if (!$one_weid_available) {
  673.                                         if ($obj->isWeid(true)) $one_weid_available = true;
  674.                                 }
  675.                         }
  676.                 } else {
  677.                         $one_weid_available = false;
  678.                         while ($row = $result->fetch_object()) {
  679.                                 $obj = OIDplusObject::parse($row->id);
  680.                                 $rows[] = array($obj,$row);
  681.                         }
  682.                 }
  683.  
  684.                 $output = '';
  685.                 $output .= '<div class="container box"><div id="suboid_table" class="table-responsive">';
  686.                 $output .= '<table class="table table-bordered table-striped">';
  687.                 $output .= '    <tr>';
  688.                 $output .= '         <th>'._L('ID').(($parentNS == 'gs1') ? ' '._L('(without check digit)') : '').'</th>';
  689.                 if ($parentNS == 'oid') {
  690.                         if ($one_weid_available) $output .= '        <th>'._L('WEID').'</th>';
  691.                         $output .= '         <th>'._L('ASN.1 IDs (comma sep.)').'</th>';
  692.                         $output .= '         <th>'._L('IRI IDs (comma sep.)').'</th>';
  693.                 }
  694.                 $output .= '         <th>'._L('RA').'</th>';
  695.                 $output .= '         <th>'._L('Comment').'</th>';
  696.                 if ($objParent->userHasWriteRights()) {
  697.                         $output .= '         <th>'._L('Hide').'</th>';
  698.                         $output .= '         <th>'._L('Update').'</th>';
  699.                         $output .= '         <th>'._L('Delete').'</th>';
  700.                 }
  701.                 $output .= '         <th>'._L('Created').'</th>';
  702.                 $output .= '         <th>'._L('Updated').'</th>';
  703.                 $output .= '    </tr>';
  704.  
  705.                 foreach ($rows as list($obj,$row)) {
  706.                         $items_total++;
  707.                         if (!$obj->userHasReadRights()) {
  708.                                 $items_hidden++;
  709.                                 continue;
  710.                         }
  711.  
  712.                         $show_id = $obj->crudShowId($objParent);
  713.  
  714.                         $asn1ids = array();
  715.                         $res2 = OIDplus::db()->query("select name from ###asn1id where oid = ? order by lfd", array($row->id));
  716.                         while ($row2 = $res2->fetch_array()) {
  717.                                 $asn1ids[] = $row2['name'];
  718.                         }
  719.  
  720.                         $iris = array();
  721.                         $res2 = OIDplus::db()->query("select name from ###iri where oid = ? order by lfd", array($row->id));
  722.                         while ($row2 = $res2->fetch_array()) {
  723.                                 $iris[] = $row2['name'];
  724.                         }
  725.  
  726.                         $date_created = explode(' ', $row->created)[0] == '0000-00-00' ? '' : explode(' ', $row->created)[0];
  727.                         $date_updated = explode(' ', $row->updated)[0] == '0000-00-00' ? '' : explode(' ', $row->updated)[0];
  728.  
  729.                         $output .= '<tr>';
  730.                         $output .= '     <td><a href="?goto='.urlencode($row->id).'" onclick="openAndSelectNode('.js_escape($row->id).', '.js_escape($parent).'); return false;">'.htmlentities($show_id).'</a></td>';
  731.                         if ($objParent->userHasWriteRights()) {
  732.                                 if ($parentNS == 'oid') {
  733.                                         if ($one_weid_available) {
  734.                                                 if ($obj->isWeid(false)) {
  735.                                                         $output .= '    <td>'.$obj->weidArc().'</td>';
  736.                                                 } else {
  737.                                                         $output .= '    <td>'._L('n/a').'</td>';
  738.                                                 }
  739.                                         }
  740.                                         $output .= '     <td><input type="text" id="asn1ids_'.$row->id.'" value="'.implode(', ', $asn1ids).'"></td>';
  741.                                         $output .= '     <td><input type="text" id="iris_'.$row->id.'" value="'.implode(', ', $iris).'"></td>';
  742.                                 }
  743.                                 $output .= '     <td><input type="text" id="ra_email_'.$row->id.'" value="'.htmlentities($row->ra_email).'"></td>';
  744.                                 $output .= '     <td><input type="text" id="comment_'.$row->id.'" value="'.htmlentities($row->comment).'"></td>';
  745.                                 $output .= '     <td><input type="checkbox" id="hide_'.$row->id.'" '.($row->confidential ? 'checked' : '').'></td>';
  746.                                 $output .= '     <td><button type="button" name="update_'.$row->id.'" id="update_'.$row->id.'" class="btn btn-success btn-xs update" onclick="crudActionUpdate('.js_escape($row->id).', '.js_escape($parent).')">'._L('Update').'</button></td>';
  747.                                 $output .= '     <td><button type="button" name="delete_'.$row->id.'" id="delete_'.$row->id.'" class="btn btn-danger btn-xs delete" onclick="crudActionDelete('.js_escape($row->id).', '.js_escape($parent).')">'._L('Delete').'</button></td>';
  748.                                 $output .= '     <td>'.$date_created.'</td>';
  749.                                 $output .= '     <td>'.$date_updated.'</td>';
  750.                         } else {
  751.                                 if ($asn1ids == '') $asn1ids = '<i>'._L('(none)').'</i>';
  752.                                 if ($iris == '') $iris = '<i>'._L('(none)').'</i>';
  753.                                 if ($parentNS == 'oid') {
  754.                                         if ($one_weid_available) {
  755.                                                 if ($obj->isWeid(false)) {
  756.                                                         $output .= '    <td>'.$obj->weidArc().'</td>';
  757.                                                 } else {
  758.                                                         $output .= '    <td>'._L('n/a').'</td>';
  759.                                                 }
  760.                                         }
  761.                                         $asn1ids_ext = array();
  762.                                         foreach ($asn1ids as $asn1id) {
  763.                                                 $asn1ids_ext[] = '<a href="?goto='.urlencode($row->id).'" onclick="openAndSelectNode('.js_escape($row->id).', '.js_escape($parent).'); return false;">'.$asn1id.'</a>';
  764.                                         }
  765.                                         $output .= '     <td>'.implode(', ', $asn1ids_ext).'</td>';
  766.                                         $output .= '     <td>'.implode(', ', $iris).'</td>';
  767.                                 }
  768.                                 $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>';
  769.                                 $output .= '     <td>'.htmlentities($row->comment).'</td>';
  770.                                 $output .= '     <td>'.$date_created.'</td>';
  771.                                 $output .= '     <td>'.$date_updated.'</td>';
  772.                         }
  773.                         $output .= '</tr>';
  774.                 }
  775.  
  776.                 $result = OIDplus::db()->query("select * from ###objects where id = ?", array($parent));
  777.                 $parent_ra_email = $result->num_rows() > 0 ? $result->fetch_object()->ra_email : '';
  778.  
  779.                 if ($objParent->userHasWriteRights()) {
  780.                         $output .= '<tr>';
  781.                         $prefix = is_null($objParent) ? '' : $objParent->crudInsertPrefix();
  782.                         if ($parentNS == 'oid') {
  783.                                 if ($objParent->isWeid(true)) {
  784.                                         $output .= '     <td>'.$prefix.' <input oninput="frdl_oidid_change()" type="text" id="id" value="" style="width:100%;min-width:100px"></td>'; // TODO: idee classname vergeben, z.B. "OID" und dann mit einem oid-spezifischen css die breite einstellbar machen, somit hat das plugin mehr kontrolle über das aussehen und die mindestbreiten
  785.                                         $output .= '     <td><input type="text" name="weid" id="weid" value="" oninput="frdl_weid_change()"></td>';
  786.                                 } else {
  787.                                         $output .= '     <td>'.$prefix.' <input type="text" id="id" value="" style="width:100%;min-width:50px"></td>'; // TODO: idee classname vergeben, z.B. "OID" und dann mit einem oid-spezifischen css die breite einstellbar machen, somit hat das plugin mehr kontrolle über das aussehen und die mindestbreiten
  788.                                         if ($one_weid_available) $output .= '     <td></td>'; // WEID-editor not available for root nodes. Do it manually, please
  789.                                 }
  790.                         } else {
  791.                                 $output .= '     <td>'.$prefix.' <input type="text" id="id" value=""></td>';
  792.                         }
  793.                         if ($parentNS == 'oid') $output .= '     <td><input type="text" id="asn1ids" value=""></td>';
  794.                         if ($parentNS == 'oid') $output .= '     <td><input type="text" id="iris" value=""></td>';
  795.                         $output .= '     <td><input type="text" id="ra_email" value="'.htmlentities($parent_ra_email).'"></td>';
  796.                         $output .= '     <td><input type="text" id="comment" value=""></td>';
  797.                         $output .= '     <td><input type="checkbox" id="hide"></td>';
  798.                         $output .= '     <td><button type="button" name="insert" id="insert" class="btn btn-success btn-xs update" onclick="crudActionInsert('.js_escape($parent).')">'._L('Insert').'</button></td>';
  799.                         $output .= '     <td></td>';
  800.                         $output .= '     <td></td>';
  801.                         $output .= '     <td></td>';
  802.                         $output .= '</tr>';
  803.                 } else {
  804.                         if ($items_total-$items_hidden == 0) {
  805.                                 $cols = ($parentNS == 'oid') ? 7 : 5;
  806.                                 if ($one_weid_available) $cols++;
  807.                                 $output .= '<tr><td colspan="'.$cols.'">'._L('No items available').'</td></tr>';
  808.                         }
  809.                 }
  810.  
  811.                 $output .= '</table>';
  812.                 $output .= '</div></div>';
  813.  
  814.                 if ($items_hidden == 1) {
  815.                         $output .= '<p>'._L('One item is hidden. Please <a %1>log in</a> to see it.',$items_hidden,OIDplus::gui()->link('oidplus:login')).'</p>';
  816.                 } else if ($items_hidden > 1) {
  817.                         $output .= '<p>'._L('%1 items are hidden. Please <a %2>log in</a> to see them.',$items_hidden,OIDplus::gui()->link('oidplus:login')).'</p>';
  818.                 }
  819.  
  820.                 return $output;
  821.         }
  822.  
  823.         protected static function objDescription($html) {
  824.                 // We allow HTML, but no hacking
  825.                 $html = anti_xss($html);
  826.  
  827.                 return trim_br($html);
  828.         }
  829.  
  830.         // 'quickbars' added 11 July 2019: Disabled because of two problems:
  831.         //                                 1. When you load TinyMCE via AJAX using the left menu, the quickbar is immediately shown, even if TinyMCE does not have the focus
  832.         //                                 2. When you load a page without TinyMCE using the left menu, the quickbar is still visible, although there is no edit
  833.         // 'colorpicker', 'textcolor' and 'contextmenu' added in 07 April 2020, because it is built in in the core.
  834.         public static $exclude_tinymce_plugins = array('fullpage', 'bbcode', 'quickbars', 'colorpicker', 'textcolor', 'contextmenu');
  835.  
  836.         protected static function showMCE($name, $content) {
  837.                 $mce_plugins = array();
  838.                 foreach (glob(OIDplus::basePath().'/3p/tinymce/plugins/*') as $m) { // */
  839.                         $mce_plugins[] = basename($m);
  840.                 }
  841.  
  842.                 foreach (self::$exclude_tinymce_plugins as $exclude) {
  843.                         $index = array_search($exclude, $mce_plugins);
  844.                         if ($index !== false) unset($mce_plugins[$index]);
  845.                 }
  846.  
  847.                 $out = '<script>
  848.                                 tinymce.remove("#'.$name.'");
  849.                                 tinymce.EditorManager.baseURL = "3p/tinymce";
  850.                                 tinymce.init({
  851.                                         document_base_url: "'.OIDplus::getSystemUrl().'",
  852.                                         selector: "#'.$name.'",
  853.                                         height: 200,
  854.                                         statusbar: false,
  855. //                                      menubar:false,
  856. //                                      toolbar: "undo redo | styleselect | bold italic | alignleft aligncenter alignright alignjustify | bullist numlist outdent indent | table | fontsizeselect",
  857.                                         toolbar: "undo redo | styleselect | bold italic underline forecolor | bullist numlist | outdent indent | table | fontsizeselect",
  858.                                         plugins: "'.implode(' ', $mce_plugins).'",
  859.                                         mobile: {
  860.                                                 theme: "mobile",
  861.                                                 toolbar: "undo redo | styleselect | bold italic underline forecolor | bullist numlist | outdent indent | table | fontsizeselect",
  862.                                                 plugins: "'.implode(' ', $mce_plugins).'"
  863.                                         }
  864.  
  865.                                 });
  866.                         </script>';
  867.  
  868.                 $content = htmlentities($content); // For some reason, if we want to display the text "<xyz>" in TinyMCE, we need to double-encode things! &lt; will not be accepted, we need &amp;lt; ... why?
  869.  
  870.                 $out .= '<textarea name="'.htmlentities($name).'" id="'.htmlentities($name).'">'.trim($content).'</textarea><br>';
  871.  
  872.                 return $out;
  873.         }
  874.  
  875.         public function implementsFeature($id) {
  876.                 if (strtolower($id) == '1.3.6.1.4.1.37476.2.5.2.3.1') return true; // oobeEntry
  877.                 return false;
  878.         }
  879.  
  880.         public function oobeEntry($step, $do_edits, &$errors_happened)/*: void*/ {
  881.                 // Interface 1.3.6.1.4.1.37476.2.5.2.3.1
  882.  
  883.                 echo '<p><u>'._L('Step %1: Enable/Disable object type plugins',$step).'</u></p>';
  884.                 echo '<p>'._L('Which object types do you want to manage using OIDplus?').'</p>';
  885.  
  886.                 $enabled_ary = array();
  887.  
  888.                 foreach (OIDplus::getEnabledObjectTypes() as $ot) {
  889.                         echo '<input type="checkbox" name="enable_ot_'.$ot::ns().'" id="enable_ot_'.$ot::ns().'"';
  890.                         if (isset($_REQUEST['sent'])) {
  891.                                 if (isset($_REQUEST['enable_ot_'.$ot::ns()])) {
  892.                                         echo ' checked';
  893.                                         $enabled_ary[] = $ot::ns();
  894.                                 }
  895.                         } else {
  896.                                 echo ' checked';
  897.                         }
  898.                         echo '> <label for="enable_ot_'.$ot::ns().'">'.htmlentities($ot::objectTypeTitle()).'</label><br>';
  899.                 }
  900.  
  901.                 foreach (OIDplus::getDisabledObjectTypes() as $ot) {
  902.                         echo '<input type="checkbox" name="enable_ot_'.$ot::ns().'" id="enable_ot_'.$ot::ns().'"';
  903.                         if (isset($_REQUEST['sent'])) {
  904.                                 if (isset($_REQUEST['enable_ot_'.$ot::ns()])) {
  905.                                         echo ' checked';
  906.                                         $enabled_ary[] = $ot::ns();
  907.                                 }
  908.                         } else {
  909.                                 echo ''; // <-- difference
  910.                         }
  911.                         echo '> <label for="enable_ot_'.$ot::ns().'">'.htmlentities($ot::objectTypeTitle()).'</label><br>';
  912.                 }
  913.  
  914.                 $msg = '';
  915.                 if ($do_edits) {
  916.                         try {
  917.                                 OIDplus::config()->setValue('objecttypes_enabled', implode(';', $enabled_ary));
  918.                         } catch (Exception $e) {
  919.                                 $msg = $e->getMessage();
  920.                                 $errors_happened = true;
  921.                         }
  922.                 }
  923.  
  924.                 echo ' <font color="red"><b>'.$msg.'</b></font>';
  925.         }
  926.  
  927. }