" . _("LDAP Account Manager Configuration") . "\n"; // include all CSS files $cssDirName = dirname(__FILE__) . '/../../style'; $cssDir = dir($cssDirName); $cssFiles = array(); $cssEntry = $cssDir->read(); while ($cssEntry !== false) { if (substr($cssEntry, strlen($cssEntry) - 4, 4) == '.css') { $cssFiles[] = $cssEntry; } $cssEntry = $cssDir->read(); } sort($cssFiles); foreach ($cssFiles as $cssEntry) { echo "\n"; } echo "\n"; echo "\n"; echo "\n"; // include all JavaScript files $jsDirName = dirname(__FILE__) . '/../lib'; $jsDir = dir($jsDirName); $jsFiles = array(); while ($jsEntry = $jsDir->read()) { if (substr($jsEntry, strlen($jsEntry) - 3, 3) != '.js') continue; $jsFiles[] = $jsEntry; } sort($jsFiles); foreach ($jsFiles as $jsEntry) { echo "\n"; } ?>
getName(); ?>   

\n"); // hidden submit buttons which are clicked by tabs echo "
\n"; echo ""; echo ""; echo ""; echo ""; echo ""; echo "
\n"; // tabs echo '
'; echo ''; ?>
getConfiguredTypes(); $container = new htmlTable(); foreach ($types as $type) { config_showAccountModules($type, $container); } $legendContainer = new htmlTable(); $legendContainer->addElement(new htmlOutputText("(*) " . _("Base module"))); $legendContainer->addElement(new htmlHelpLink('237')); $container->addElement($legendContainer); $container->addElement(new htmlHiddenInput('postAvailable', 'yes')); $tabindex = 1; parseHtml(null, $container, array(), false, $tabindex, 'user'); echo "
"; $buttonContainer = new htmlTable(); $buttonContainer->addElement(new htmlSpacer(null, '10px'), true); $saveButton = new htmlButton('saveSettings', _('Save')); $saveButton->setIconClass('saveButton'); $buttonContainer->addElement($saveButton); $cancelButton = new htmlButton('cancelSettings', _('Cancel')); $cancelButton->setIconClass('cancelButton'); $buttonContainer->addElement($cancelButton, true); $buttonContainer->addElement(new htmlSpacer(null, '10px'), true); parseHtml(null, $buttonContainer, array(), false, $tabindex, 'user'); if ((sizeof($errorsToDisplay) == 0) && isset($_POST['scrollPositionTop']) && isset($_POST['scrollPositionLeft'])) { // scroll to last position echo ''; } echo "\n"; echo "\n"; echo "\n"; /** * Displays the module selection boxes and checks if dependencies are fulfilled. * * @param \LAM\TYPES\ConfiguredType $type account type * @param htmlTable $container meta HTML container */ function config_showAccountModules($type, &$container) { // account modules $available = getAvailableModules($type->getScope(), true); $selected = $type->getModules(); $sortedAvailable = array(); for ($i = 0; $i < sizeof($available); $i++) { $sortedAvailable[$available[$i]] = getModuleAlias($available[$i], $type->getScope()); } natcasesort($sortedAvailable); // build options for selected and available modules $selOptions = array(); for ($i = 0; $i < sizeof($selected); $i++) { if (in_array($selected[$i], $available)) { // selected modules must be available if (is_base_module($selected[$i], $type->getScope())) { // mark base modules $selOptions[getModuleAlias($selected[$i], $type->getScope()) . " (" . $selected[$i] . ")(*)"] = $selected[$i]; } else { $selOptions[getModuleAlias($selected[$i], $type->getScope()) . " (" . $selected[$i] . ")"] = $selected[$i]; } } } $availOptions = array(); foreach ($sortedAvailable as $key => $value) { if (! in_array($key, $selected)) { // display non-selected modules if (is_base_module($key, $type->getScope())) { // mark base modules $availOptions[$value . " (" . $key . ")(*)"] = $key; } else { $availOptions[$value . " (" . $key . ")"] = $key; } } } // add account module selection $container->addElement(new htmlSubTitle($type->getAlias(), '../../graphics/' . $type->getIcon()), true); $container->addElement(new htmlOutputText(_("Selected modules"))); $container->addElement(new htmlOutputText('')); $container->addElement(new htmlOutputText(_("Available modules")), true); $container->addVerticalSpace('10px'); $container->addNewLine(); // selected modules if (sizeof($selOptions) > 0) { $listElements = array(); foreach ($selOptions as $key => $value) { $el = new htmlTable('100%'); $mod = new $value($type->getScope()); $el->addElement(new htmlImage('../../graphics/' . $mod->getIcon(), '16px', '16px')); $el->addElement(new htmlOutputText($key)); $delButton = new htmlButton('del_' . $type->getId() . '_' . $value, 'del.png', true); $delButton->alignment = htmlElement::ALIGN_RIGHT; $el->addElement($delButton); $listElements[] = $el; } $selSortable = new htmlSortableList($listElements, $type->getId() . '_selected', '350px'); $selSortable->alignment = htmlElement::ALIGN_TOP; $selSortable->setOnUpdate('updateModulePositions(\'positions_' . $type->getId() . '\', ui.item.data(\'posOrig\'), ui.item.index());'); $container->addElement($selSortable); } else { $container->addElement(new htmlOutputText('')); } // space $container->addSpace('20px'); // available modules if (sizeof($availOptions) > 0) { $availTable = new htmlTable(); foreach ($availOptions as $text => $key) { $mod = new $key($type->getScope()); $availTable->addElement(new htmlImage('../../graphics/' . $mod->getIcon(), '16px', '16px')); $availTable->addElement(new htmlOutputText($text)); $addButton = new htmlButton('add_' . $type->getId() . '_' . $key, 'add.png', true); $addButton->alignment = htmlElement::ALIGN_RIGHT; $availTable->addElement($addButton, true); } $availDiv = new htmlDiv(null, $availTable); $availDiv->alignment = htmlElement::ALIGN_TOP; $availDiv->setCSSClasses(array('confModList')); $container->addElement($availDiv, true); } $positions = array(); for ($i = 0; $i < sizeof($selOptions); $i++) { $positions[] = $i; } $container->addElement(new htmlHiddenInput('positions_' . $type->getId(), implode(',', $positions)), true); // spacer to next account type $container->addElement(new htmlSpacer(null, '30px'), true); } /** * Checks user input and saves the entered settings. * * @return array list of errors */ function checkInput() { if (!isset($_POST['postAvailable'])) { return array(); } $errors = array(); $conf = &$_SESSION['conf_config']; $typeSettings = $conf->get_typeSettings(); $typeManager = new \LAM\TYPES\TypeManager($conf); $accountTypes = $typeManager->getConfiguredTypes(); foreach ($accountTypes as $type) { $scope = $type->getScope(); $typeId = $type->getId(); $available = getAvailableModules($scope, true); $selected_temp = (isset($typeSettings['modules_' . $typeId])) ? $typeSettings['modules_' . $typeId] : ''; $selected_temp = explode(',', $selected_temp); $selected = array(); // only use available modules as selected for ($i = 0; $i < sizeof($selected_temp); $i++) { if (in_array($selected_temp[$i], $available)) { $selected[] = $selected_temp[$i]; } } // reorder based on sortable list $sorting = $_POST['positions_' . $typeId]; if (!empty($sorting)) { $sorting = explode(',', $sorting); $sortTmp = array(); foreach ($sorting as $pos) { $sortTmp[] = $selected[$pos]; } $selected = $sortTmp; } // remove modules from selection $new_selected = array(); for ($i = 0; $i < sizeof($selected); $i++) { if (!isset($_POST['del_' . $typeId . '_' . $selected[$i]])) { $new_selected[] = $selected[$i]; } } $selected = $new_selected; $typeSettings['modules_' . $typeId] = implode(',', $selected); // add modules to selection foreach ($available as $modName) { if (isset($_POST['add_' . $typeId . '_' . $modName])) { $selected[] = $modName; $typeSettings['modules_' . $typeId] = implode(',', $selected); break; } } // check dependencies $depends = check_module_depends($selected, getModulesDependencies($scope)); if ($depends != false) { for ($i = 0; $i < sizeof($depends); $i++) { $errors[] = array('ERROR', $type->getAlias(), _("Unsolved dependency:") . ' ' . $depends[$i][0] . " (" . $depends[$i][1] . ")"); } } // check conflicts $conflicts = check_module_conflicts($selected, getModulesDependencies($scope)); if ($conflicts != false) { for ($i = 0; $i < sizeof($conflicts); $i++) { $errors[] = array('ERROR', $type->getAlias(), _("Conflicting module:") . ' ' . $conflicts[$i][0] . " (" . $conflicts[$i][1] . ")"); } } // check for base module $baseCount = 0; for ($i = 0; $i < sizeof($selected); $i++) { if (is_base_module($selected[$i], $scope)) { $baseCount++; } } if ($baseCount != 1) { $errors[] = array('ERROR', $type->getAlias(), _("No or more than one base module selected!")); } } $conf->set_typeSettings($typeSettings); return $errors; } ?>