server(), $new_dn, $ou); if ($ret) { $message = _("New OU created successfully."); } else { $error = _("Unable to create new OU!"); } } else $error = _("OU already exists!"); } // show errormessage if ou is invalid else { $error = _("OU is invalid!") . "
" . htmlspecialchars($_POST['newOU']); } } // delete ou, user was sure elseif (isset($_POST['deleteOU']) && isset($_POST['sure'])) { $ret = ldap_delete($_SESSION['ldap']->server(), $_POST['deletename']); if ($ret) { $message = _("OU deleted successfully."); } else { $error = _("Unable to delete OU!"); } } // ask if user is sure to delete elseif (isset($_POST['deleteOU'])) { // check for sub entries $sr = ldap_list($_SESSION['ldap']->server(), $_POST['deleteableOU'], "ObjectClass=*", array("")); $info = ldap_get_entries($_SESSION['ldap']->server(), $sr); if ($sr && $info['count'] == 0) { // print header include 'main_header.php'; echo '
'; echo "
\n"; $tabindex = 1; $container = new htmlResponsiveRow(); $label = new htmlOutputText(_("Do you really want to delete this OU?")); $label->colspan = 5; $container->add($label, 12); $container->addVerticalSpacer('1rem'); $dnLabel = new htmlOutputText(getAbstractDN($_POST['deleteableOU'])); $dnLabel->colspan = 5; $container->add($dnLabel, 12); $container->addVerticalSpacer('1rem'); $buttonGroup = new htmlGroup(); $buttonGroup->addElement(new htmlButton('sure', _("Delete"))); $buttonGroup->addElement(new htmlSpacer('0.5rem', null)); $buttonGroup->addElement(new htmlButton('abort', _("Cancel"))); $container->add($buttonGroup, 12); $container->add(new htmlHiddenInput('deleteOU', 'submit'), 12); $container->add(new htmlHiddenInput('deletename', $_POST['deleteableOU']), 12); addSecurityTokenToMetaHTML($container); parseHtml(null, $container, array(), false, $tabindex, 'user'); echo "
"; echo '
'; include 'main_footer.php'; exit(); } else { $error = _("OU is not empty or invalid!"); } } } display_main($message, $error); /** * Displays the main page of the OU editor * * @param String $message info message * @param String $error error message */ function display_main($message, $error) { // display main page include '../lib/adminHeader.inc'; echo '
'; echo "
\n"; $tabindex = 1; $container = new htmlResponsiveRow(); $container->add(new htmlTitle(_("OU editor")), 12); if (isset($error)) { $msg = new htmlStatusMessage("ERROR", "", $error); $msg->colspan = 5; $container->add($msg, 12); } elseif (isset($message)) { $msg = new htmlStatusMessage("INFO", "", $message); $msg->colspan = 5; $container->add($msg, 12); } $typeManager = new \LAM\TYPES\TypeManager(); $typeList = $typeManager->getConfiguredTypes(); $types = array(); foreach ($typeList as $type) { if ($type->isHidden() || !checkIfWriteAccessIsAllowed($type->getId())) { continue; } $types[$type->getId()] = $type->getAlias(); } natcasesort($types); $options = array(); foreach ($types as $typeId => $title) { $type = $typeManager->getConfiguredType($typeId); $elements = array(); $units = searchLDAP($type->getSuffix(), '(objectclass=organizationalunit)', array('dn')); foreach ($units as $unit) { $elements[getAbstractDN($unit['dn'])] = $unit['dn']; } $options[$title] = $elements; } if (!empty($options)) { // new OU $container->add(new htmlSubTitle(_("New organisational unit")), 12); $parentOUSelect = new htmlResponsiveSelect('parentOU', $options, array(), _('Parent DN'), '601'); $parentOUSelect->setContainsOptgroups(true); $parentOUSelect->setHasDescriptiveElements(true); $parentOUSelect->setRightToLeftTextDirection(true); $parentOUSelect->setSortElements(false); $container->add($parentOUSelect, 12); $container->add(new htmlResponsiveInputField(_('Name'), 'newOU'), 12); $container->addLabel(new htmlOutputText(' ', false)); $container->addField(new htmlButton('createOU', _("Ok"))); $container->addVerticalSpacer('2rem'); // delete OU $container->add(new htmlSubTitle(_("Delete organisational unit")), 12); $deleteableOUSelect = new htmlResponsiveSelect('deleteableOU', $options, array(), _('Organisational unit'), '602'); $deleteableOUSelect->setContainsOptgroups(true); $deleteableOUSelect->setHasDescriptiveElements(true); $deleteableOUSelect->setRightToLeftTextDirection(true); $deleteableOUSelect->setSortElements(false); $container->add($deleteableOUSelect, 12); $container->addLabel(new htmlOutputText(' ', false)); $container->addField(new htmlButton('deleteOU', _("Ok"))); } addSecurityTokenToMetaHTML($container); parseHtml(null, $container, array(), false, $tabindex, 'user'); echo ("
\n"); echo '
'; include '../lib/adminFooter.inc'; }