new type API
This commit is contained in:
parent
207cd984ce
commit
dbb3c779c4
|
@ -19,6 +19,7 @@
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
@ -48,6 +49,7 @@ This is a list of API changes for all LAM releases.
|
||||||
|
|
||||||
<h2>5.5 -> 5.6</h2>
|
<h2>5.5 -> 5.6</h2>
|
||||||
Functions in lib/types.inc got namespace LAM/TYPES (e.g. getTypeAlias()).<br>
|
Functions in lib/types.inc got namespace LAM/TYPES (e.g. getTypeAlias()).<br>
|
||||||
|
New API to access configured account types: LAM\TYPES\TypeManager.<br>
|
||||||
|
|
||||||
<h2>5.4 -> 5.5</h2>Functions Ldap::encrypt/decrypt in ldap.inc moved to lamEncrypt/lamDecrypt in security.inc.<br>
|
<h2>5.4 -> 5.5</h2>Functions Ldap::encrypt/decrypt in ldap.inc moved to lamEncrypt/lamDecrypt in security.inc.<br>
|
||||||
<br>
|
<br>
|
||||||
|
|
|
@ -197,21 +197,27 @@ jQuery(document).ready(function() {
|
||||||
<div class="ui-tabs ui-widget ui-widget-content ui-corner-all">
|
<div class="ui-tabs ui-widget ui-widget-content ui-corner-all">
|
||||||
<ul class="ui-tabs-nav ui-helper-reset ui-helper-clearfix ui-widget-header ui-corner-all">
|
<ul class="ui-tabs-nav ui-helper-reset ui-helper-clearfix ui-widget-header ui-corner-all">
|
||||||
<?php
|
<?php
|
||||||
$typeManager = new LAM\TYPES\TypeManager();
|
printTypeTabs($headerPrefix);
|
||||||
$types = $typeManager->getConfiguredTypes();
|
|
||||||
$linkList = array();
|
|
||||||
foreach ($types as $type) {
|
|
||||||
if ($type->isHidden()) {
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
$link = '<a href="' . $headerPrefix . 'lists/list.php?type=' . $type->getId() .
|
|
||||||
'" onmouseover="jQuery(this).addClass(\'tabs-hover\');" onmouseout="jQuery(this).removeClass(\'tabs-hover\');">' .
|
|
||||||
'<img height="16" width="16" alt="' . $type->getId() . '" src="' . $headerPrefix . '../graphics/' . $type->getScope() . '.png"> ' .
|
|
||||||
$type->getAlias() . '</a>';
|
|
||||||
echo '<li id="tab_' . $type->getId() . '" class="ui-state-default ui-corner-top">';
|
|
||||||
echo $link;
|
|
||||||
echo "</li>\n";
|
|
||||||
}
|
|
||||||
?>
|
?>
|
||||||
</ul>
|
</ul>
|
||||||
|
|
||||||
|
<?php
|
||||||
|
|
||||||
|
function printTypeTabs($headerPrefix) {
|
||||||
|
$typeManager = new LAM\TYPES\TypeManager();
|
||||||
|
$types = $typeManager->getConfiguredTypes();
|
||||||
|
$linkList = array();
|
||||||
|
foreach ($types as $type) {
|
||||||
|
if ($type->isHidden()) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
$link = '<a href="' . $headerPrefix . 'lists/list.php?type=' . $type->getId() .
|
||||||
|
'" onmouseover="jQuery(this).addClass(\'tabs-hover\');" onmouseout="jQuery(this).removeClass(\'tabs-hover\');">' .
|
||||||
|
'<img height="16" width="16" alt="' . $type->getId() . '" src="' . $headerPrefix . '../graphics/' . $type->getScope() . '.png"> ' .
|
||||||
|
$type->getAlias() . '</a>';
|
||||||
|
echo '<li id="tab_' . $type->getId() . '" class="ui-state-default ui-corner-top">';
|
||||||
|
echo $link;
|
||||||
|
echo "</li>\n";
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
|
@ -51,16 +51,17 @@ if (!empty($_POST)) {
|
||||||
validateSecurityToken();
|
validateSecurityToken();
|
||||||
}
|
}
|
||||||
|
|
||||||
$types = $_SESSION['config']->get_ActiveTypes();
|
$typeManager = new LAM\TYPES\TypeManager();
|
||||||
|
$types = $typeManager->getConfiguredTypes();
|
||||||
$profileClasses = array();
|
$profileClasses = array();
|
||||||
$profileClassesTemp = array();
|
$profileClassesTemp = array();
|
||||||
for ($i = 0; $i < sizeof($types); $i++) {
|
foreach ($types as $type) {
|
||||||
if (isAccountTypeHidden($types[$i]) || !checkIfWriteAccessIsAllowed($types[$i])) {
|
if ($type->isHidden() || !checkIfWriteAccessIsAllowed($type->getId())) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
$profileClassesTemp[LAM\TYPES\getTypeAlias($types[$i])] = array(
|
$profileClassesTemp[$type->getAlias()] = array(
|
||||||
'scope' => $types[$i],
|
'typeId' => $type->getId(),
|
||||||
'title' => LAM\TYPES\getTypeAlias($types[$i]),
|
'title' => $type->getAlias(),
|
||||||
'profiles' => "");
|
'profiles' => "");
|
||||||
}
|
}
|
||||||
$profileClassesKeys = array_keys($profileClassesTemp);
|
$profileClassesKeys = array_keys($profileClassesTemp);
|
||||||
|
@ -83,9 +84,9 @@ elseif (isset($_POST['createProfileButton'])) {
|
||||||
}
|
}
|
||||||
// check if a profile should be edited
|
// check if a profile should be edited
|
||||||
for ($i = 0; $i < sizeof($profileClasses); $i++) {
|
for ($i = 0; $i < sizeof($profileClasses); $i++) {
|
||||||
if (isset($_POST['editProfile_' . $profileClasses[$i]['scope']]) || isset($_POST['editProfile_' . $profileClasses[$i]['scope'] . '_x'])) {
|
if (isset($_POST['editProfile_' . $profileClasses[$i]['typeId']]) || isset($_POST['editProfile_' . $profileClasses[$i]['typeId'] . '_x'])) {
|
||||||
metaRefresh("profilepage.php?type=" . htmlspecialchars($profileClasses[$i]['scope']) .
|
metaRefresh("profilepage.php?type=" . htmlspecialchars($profileClasses[$i]['typeId']) .
|
||||||
"&edit=" . htmlspecialchars($_POST['profile_' . $profileClasses[$i]['scope']]));
|
"&edit=" . htmlspecialchars($_POST['profile_' . $profileClasses[$i]['typeId']]));
|
||||||
exit;
|
exit;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -99,18 +100,19 @@ $container = new htmlTable();
|
||||||
$container->addElement(new htmlTitle(_("Profile editor")), true);
|
$container->addElement(new htmlTitle(_("Profile editor")), true);
|
||||||
|
|
||||||
if (isset($_POST['deleteProfile']) && ($_POST['deleteProfile'] == 'true')) {
|
if (isset($_POST['deleteProfile']) && ($_POST['deleteProfile'] == 'true')) {
|
||||||
if (isAccountTypeHidden($_POST['profileDeleteType'])) {
|
$type = $typeManager->getConfiguredType($_POST['profileDeleteType']);
|
||||||
|
if ($type->isHidden()) {
|
||||||
logNewMessage(LOG_ERR, 'User tried to delete hidden account type profile: ' . $_POST['profileDeleteType']);
|
logNewMessage(LOG_ERR, 'User tried to delete hidden account type profile: ' . $_POST['profileDeleteType']);
|
||||||
die();
|
die();
|
||||||
}
|
}
|
||||||
// delete profile
|
// delete profile
|
||||||
if (delAccountProfile($_POST['profileDeleteName'], $_POST['profileDeleteType'])) {
|
if (delAccountProfile($_POST['profileDeleteName'], $_POST['profileDeleteType'])) {
|
||||||
$message = new htmlStatusMessage('INFO', _('Deleted profile.'), LAM\TYPES\getTypeAlias($_POST['profileDeleteType']) . ': ' . htmlspecialchars($_POST['profileDeleteName']));
|
$message = new htmlStatusMessage('INFO', _('Deleted profile.'), $type->getAlias() . ': ' . htmlspecialchars($_POST['profileDeleteName']));
|
||||||
$message->colspan = 10;
|
$message->colspan = 10;
|
||||||
$container->addElement($message, true);
|
$container->addElement($message, true);
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
$message = new htmlStatusMessage('ERROR', _('Unable to delete profile!'), LAM\TYPES\getTypeAlias($_POST['profileDeleteType']) . ': ' . htmlspecialchars($_POST['profileDeleteName']));
|
$message = new htmlStatusMessage('ERROR', _('Unable to delete profile!'), $type->getAlias() . ': ' . htmlspecialchars($_POST['profileDeleteName']));
|
||||||
$message->colspan = 10;
|
$message->colspan = 10;
|
||||||
$container->addElement($message, true);
|
$container->addElement($message, true);
|
||||||
}
|
}
|
||||||
|
@ -120,12 +122,12 @@ if (isset($_POST['deleteProfile']) && ($_POST['deleteProfile'] == 'true')) {
|
||||||
if (isset($_POST['importexport']) && ($_POST['importexport'] === '1')) {
|
if (isset($_POST['importexport']) && ($_POST['importexport'] === '1')) {
|
||||||
$cfg = new LAMCfgMain();
|
$cfg = new LAMCfgMain();
|
||||||
$impExpMessage = null;
|
$impExpMessage = null;
|
||||||
if (isset($_POST['importProfiles_' . $_POST['scope']])) {
|
if (isset($_POST['importProfiles_' . $_POST['typeId']])) {
|
||||||
// check master password
|
// check master password
|
||||||
if (!$cfg->checkPassword($_POST['passwd_' . $_POST['scope']])) {
|
if (!$cfg->checkPassword($_POST['passwd_' . $_POST['typeId']])) {
|
||||||
$impExpMessage = new htmlStatusMessage('ERROR', _('Master password is wrong!'));
|
$impExpMessage = new htmlStatusMessage('ERROR', _('Master password is wrong!'));
|
||||||
}
|
}
|
||||||
elseif (copyAccountProfiles($_POST['importProfiles_' . $_POST['scope']], $_POST['scope'])) {
|
elseif (copyAccountProfiles($_POST['importProfiles_' . $_POST['typeId']], $_POST['typeId'])) {
|
||||||
$impExpMessage = new htmlStatusMessage('INFO', _('Import successful'));
|
$impExpMessage = new htmlStatusMessage('INFO', _('Import successful'));
|
||||||
}
|
}
|
||||||
} else if (isset($_POST['exportProfiles'])) {
|
} else if (isset($_POST['exportProfiles'])) {
|
||||||
|
@ -133,7 +135,7 @@ if (isset($_POST['importexport']) && ($_POST['importexport'] === '1')) {
|
||||||
if (!$cfg->checkPassword($_POST['passwd'])) {
|
if (!$cfg->checkPassword($_POST['passwd'])) {
|
||||||
$impExpMessage = new htmlStatusMessage('ERROR', _('Master password is wrong!'));
|
$impExpMessage = new htmlStatusMessage('ERROR', _('Master password is wrong!'));
|
||||||
}
|
}
|
||||||
elseif (copyAccountProfiles($_POST['exportProfiles'], $_POST['scope'], $_POST['destServerProfiles'])) {
|
elseif (copyAccountProfiles($_POST['exportProfiles'], $_POST['typeId'], $_POST['destServerProfiles'])) {
|
||||||
$impExpMessage = new htmlStatusMessage('INFO', _('Export successful'));
|
$impExpMessage = new htmlStatusMessage('INFO', _('Export successful'));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -145,7 +147,7 @@ if (isset($_POST['importexport']) && ($_POST['importexport'] === '1')) {
|
||||||
|
|
||||||
// get list of profiles for each account type
|
// get list of profiles for each account type
|
||||||
for ($i = 0; $i < sizeof($profileClasses); $i++) {
|
for ($i = 0; $i < sizeof($profileClasses); $i++) {
|
||||||
$profileList = getAccountProfiles($profileClasses[$i]['scope']);
|
$profileList = getAccountProfiles($profileClasses[$i]['typeId']);
|
||||||
natcasesort($profileList);
|
natcasesort($profileList);
|
||||||
$profileClasses[$i]['profiles'] = $profileList;
|
$profileClasses[$i]['profiles'] = $profileList;
|
||||||
}
|
}
|
||||||
|
@ -161,7 +163,7 @@ if (!empty($profileClasses)) {
|
||||||
$container->addElement(new htmlSubTitle(_('Create a new profile')), true);
|
$container->addElement(new htmlSubTitle(_('Create a new profile')), true);
|
||||||
$sortedTypes = array();
|
$sortedTypes = array();
|
||||||
for ($i = 0; $i < sizeof($profileClasses); $i++) {
|
for ($i = 0; $i < sizeof($profileClasses); $i++) {
|
||||||
$sortedTypes[$profileClasses[$i]['title']] = $profileClasses[$i]['scope'];
|
$sortedTypes[$profileClasses[$i]['title']] = $profileClasses[$i]['typeId'];
|
||||||
}
|
}
|
||||||
natcasesort($sortedTypes);
|
natcasesort($sortedTypes);
|
||||||
$newContainer = new htmlTable();
|
$newContainer = new htmlTable();
|
||||||
|
@ -188,32 +190,32 @@ for ($i = 0; $i < sizeof($profileClasses); $i++) {
|
||||||
$existingContainer->addElement(new htmlSpacer(null, '10px'), true);
|
$existingContainer->addElement(new htmlSpacer(null, '10px'), true);
|
||||||
}
|
}
|
||||||
|
|
||||||
$existingContainer->addElement(new htmlImage('../../graphics/' . $profileClasses[$i]['scope'] . '.png'));
|
$existingContainer->addElement(new htmlImage('../../graphics/' . $profileClasses[$i]['typeId'] . '.png'));
|
||||||
$existingContainer->addElement(new htmlSpacer('3px', null));
|
$existingContainer->addElement(new htmlSpacer('3px', null));
|
||||||
$existingContainer->addElement(new htmlOutputText($profileClasses[$i]['title']));
|
$existingContainer->addElement(new htmlOutputText($profileClasses[$i]['title']));
|
||||||
$existingContainer->addElement(new htmlSpacer('3px', null));
|
$existingContainer->addElement(new htmlSpacer('3px', null));
|
||||||
$select = new htmlSelect('profile_' . $profileClasses[$i]['scope'], $profileClasses[$i]['profiles']);
|
$select = new htmlSelect('profile_' . $profileClasses[$i]['typeId'], $profileClasses[$i]['profiles']);
|
||||||
$select->setWidth('15em');
|
$select->setWidth('15em');
|
||||||
$existingContainer->addElement($select);
|
$existingContainer->addElement($select);
|
||||||
$existingContainer->addElement(new htmlSpacer('3px', null));
|
$existingContainer->addElement(new htmlSpacer('3px', null));
|
||||||
$editButton = new htmlButton('editProfile_' . $profileClasses[$i]['scope'], 'edit.png', true);
|
$editButton = new htmlButton('editProfile_' . $profileClasses[$i]['typeId'], 'edit.png', true);
|
||||||
$editButton->setTitle(_('Edit'));
|
$editButton->setTitle(_('Edit'));
|
||||||
$existingContainer->addElement($editButton);
|
$existingContainer->addElement($editButton);
|
||||||
$deleteLink = new htmlLink(null, '#', '../../graphics/delete.png');
|
$deleteLink = new htmlLink(null, '#', '../../graphics/delete.png');
|
||||||
$deleteLink->setTitle(_('Delete'));
|
$deleteLink->setTitle(_('Delete'));
|
||||||
$deleteLink->setOnClick("profileShowDeleteDialog('" . _('Delete') . "', '" . _('Ok') . "', '" . _('Cancel') . "', '" . $profileClasses[$i]['scope'] . "', '" . 'profile_' . $profileClasses[$i]['scope'] . "');");
|
$deleteLink->setOnClick("profileShowDeleteDialog('" . _('Delete') . "', '" . _('Ok') . "', '" . _('Cancel') . "', '" . $profileClasses[$i]['typeId'] . "', '" . 'profile_' . $profileClasses[$i]['typeId'] . "');");
|
||||||
$existingContainer->addElement($deleteLink);
|
$existingContainer->addElement($deleteLink);
|
||||||
if (count($configProfiles) > 1) {
|
if (count($configProfiles) > 1) {
|
||||||
$importLink = new htmlLink(null, '#', '../../graphics/import.png');
|
$importLink = new htmlLink(null, '#', '../../graphics/import.png');
|
||||||
$importLink->setTitle(_('Import profiles'));
|
$importLink->setTitle(_('Import profiles'));
|
||||||
$importLink->setOnClick("showDistributionDialog('" . _("Import profiles") . "', '" .
|
$importLink->setOnClick("showDistributionDialog('" . _("Import profiles") . "', '" .
|
||||||
_('Ok') . "', '" . _('Cancel') . "', '" . $profileClasses[$i]['scope'] . "', 'import');");
|
_('Ok') . "', '" . _('Cancel') . "', '" . $profileClasses[$i]['typeId'] . "', 'import');");
|
||||||
$existingContainer->addElement($importLink);
|
$existingContainer->addElement($importLink);
|
||||||
}
|
}
|
||||||
$exportLink = new htmlLink(null, '#', '../../graphics/export.png');
|
$exportLink = new htmlLink(null, '#', '../../graphics/export.png');
|
||||||
$exportLink->setTitle(_('Export profile'));
|
$exportLink->setTitle(_('Export profile'));
|
||||||
$exportLink->setOnClick("showDistributionDialog('" . _("Export profile") . "', '" .
|
$exportLink->setOnClick("showDistributionDialog('" . _("Export profile") . "', '" .
|
||||||
_('Ok') . "', '" . _('Cancel') . "', '" . $profileClasses[$i]['scope'] . "', 'export', '" . 'profile_' . $profileClasses[$i]['scope'] . "', '" . $_SESSION['config']->getName() . "');");
|
_('Ok') . "', '" . _('Cancel') . "', '" . $profileClasses[$i]['typeId'] . "', 'export', '" . 'profile_' . $profileClasses[$i]['typeId'] . "', '" . $_SESSION['config']->getName() . "');");
|
||||||
$existingContainer->addElement($exportLink);
|
$existingContainer->addElement($exportLink);
|
||||||
$existingContainer->addNewLine();
|
$existingContainer->addNewLine();
|
||||||
}
|
}
|
||||||
|
@ -228,11 +230,11 @@ echo "</form>\n";
|
||||||
echo "</div>\n";
|
echo "</div>\n";
|
||||||
|
|
||||||
for ($i = 0; $i < sizeof($profileClasses); $i++) {
|
for ($i = 0; $i < sizeof($profileClasses); $i++) {
|
||||||
$scope = $profileClasses[$i]['scope'];
|
$typeId = $profileClasses[$i]['typeId'];
|
||||||
$tmpArr = array();
|
$tmpArr = array();
|
||||||
foreach ($configProfiles as $profile) {
|
foreach ($configProfiles as $profile) {
|
||||||
if ($profile != $_SESSION['config']->getName()) {
|
if ($profile != $_SESSION['config']->getName()) {
|
||||||
$accountProfiles = getAccountProfiles($scope, $profile);
|
$accountProfiles = getAccountProfiles($typeId, $profile);
|
||||||
if (!empty($accountProfiles)) {
|
if (!empty($accountProfiles)) {
|
||||||
for ($p = 0; $p < sizeof($accountProfiles); $p++) {
|
for ($p = 0; $p < sizeof($accountProfiles); $p++) {
|
||||||
$tmpArr[$profile][$accountProfiles[$p]] = $profile . '##' . $accountProfiles[$p];
|
$tmpArr[$profile][$accountProfiles[$p]] = $profile . '##' . $accountProfiles[$p];
|
||||||
|
@ -242,13 +244,13 @@ for ($i = 0; $i < sizeof($profileClasses); $i++) {
|
||||||
}
|
}
|
||||||
|
|
||||||
//import dialog
|
//import dialog
|
||||||
echo "<div id=\"importDialog_$scope\" class=\"hidden\">\n";
|
echo "<div id=\"importDialog_$typeId\" class=\"hidden\">\n";
|
||||||
echo "<form id=\"importDialogForm_$scope\" method=\"post\" action=\"profilemain.php\">\n";
|
echo "<form id=\"importDialogForm_$typeId\" method=\"post\" action=\"profilemain.php\">\n";
|
||||||
|
|
||||||
$container = new htmlTable();
|
$container = new htmlTable();
|
||||||
$container->addElement(new htmlOutputText(_('Profiles')), true);
|
$container->addElement(new htmlOutputText(_('Profiles')), true);
|
||||||
|
|
||||||
$select = new htmlSelect('importProfiles_' . $scope, $tmpArr, array(), count($tmpArr, 1) < 15 ? count($tmpArr, 1) : 15);
|
$select = new htmlSelect('importProfiles_' . $typeId, $tmpArr, array(), count($tmpArr, 1) < 15 ? count($tmpArr, 1) : 15);
|
||||||
$select->setMultiSelect(true);
|
$select->setMultiSelect(true);
|
||||||
$select->setHasDescriptiveElements(true);
|
$select->setHasDescriptiveElements(true);
|
||||||
$select->setContainsOptgroups(true);
|
$select->setContainsOptgroups(true);
|
||||||
|
@ -260,12 +262,12 @@ for ($i = 0; $i < sizeof($profileClasses); $i++) {
|
||||||
$container->addElement(new htmlSpacer(null, '10px'), true);
|
$container->addElement(new htmlSpacer(null, '10px'), true);
|
||||||
|
|
||||||
$container->addElement(new htmlOutputText(_("Master password")), true);
|
$container->addElement(new htmlOutputText(_("Master password")), true);
|
||||||
$exportPasswd = new htmlInputField('passwd_' . $scope);
|
$exportPasswd = new htmlInputField('passwd_' . $typeId);
|
||||||
$exportPasswd->setIsPassword(true);
|
$exportPasswd->setIsPassword(true);
|
||||||
$container->addElement($exportPasswd);
|
$container->addElement($exportPasswd);
|
||||||
$container->addElement(new htmlHelpLink('236'));
|
$container->addElement(new htmlHelpLink('236'));
|
||||||
$container->addElement(new htmlHiddenInput('importexport', '1'));
|
$container->addElement(new htmlHiddenInput('importexport', '1'));
|
||||||
$container->addElement(new htmlHiddenInput('scope', $scope), true);
|
$container->addElement(new htmlHiddenInput('typeId', $typeId), true);
|
||||||
addSecurityTokenToMetaHTML($container);
|
addSecurityTokenToMetaHTML($container);
|
||||||
|
|
||||||
parseHtml(null, $container, array(), false, $tabindex, 'user');
|
parseHtml(null, $container, array(), false, $tabindex, 'user');
|
||||||
|
|
|
@ -3,7 +3,7 @@
|
||||||
$Id$
|
$Id$
|
||||||
|
|
||||||
This code is part of LDAP Account Manager (http://www.ldap-account-manager.org/)
|
This code is part of LDAP Account Manager (http://www.ldap-account-manager.org/)
|
||||||
Copyright (C) 2003 - 2015 Roland Gruber
|
Copyright (C) 2003 - 2016 Roland Gruber
|
||||||
|
|
||||||
This program is free software; you can redistribute it and/or modify
|
This program is free software; you can redistribute it and/or modify
|
||||||
it under the terms of the GNU General Public License as published by
|
it under the terms of the GNU General Public License as published by
|
||||||
|
@ -62,10 +62,16 @@ if (!$_SESSION['ldap'] || !$_SESSION['ldap']->server()) {
|
||||||
}
|
}
|
||||||
|
|
||||||
// copy type and profile name from POST to GET
|
// copy type and profile name from POST to GET
|
||||||
if (isset($_POST['profname'])) $_GET['edit'] = $_POST['profname'];
|
if (isset($_POST['profname'])) {
|
||||||
if (isset($_POST['accounttype'])) $_GET['type'] = $_POST['accounttype'];
|
$_GET['edit'] = $_POST['profname'];
|
||||||
|
}
|
||||||
|
if (isset($_POST['accounttype'])) {
|
||||||
|
$_GET['type'] = $_POST['accounttype'];
|
||||||
|
}
|
||||||
|
|
||||||
if (isAccountTypeHidden($_GET['type']) || !checkIfWriteAccessIsAllowed($_GET['type'])) {
|
$typeManager = new LAM\TYPES\TypeManager();
|
||||||
|
$type = $typeManager->getConfiguredType($_GET['type']);
|
||||||
|
if ($type->isHidden() || !checkIfWriteAccessIsAllowed($_GET['type'])) {
|
||||||
logNewMessage(LOG_ERR, 'User tried to access hidden account type profile: ' . $_GET['type']);
|
logNewMessage(LOG_ERR, 'User tried to access hidden account type profile: ' . $_GET['type']);
|
||||||
die();
|
die();
|
||||||
}
|
}
|
||||||
|
@ -108,14 +114,14 @@ if (isset($_POST['save'])) {
|
||||||
$options[$element] = explode("\r\n", $_POST[$element]);
|
$options[$element] = explode("\r\n", $_POST[$element]);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// remove double slashes if magic quotes are on
|
// remove double slashes if magic quotes are on
|
||||||
if (get_magic_quotes_gpc() == 1) {
|
if (get_magic_quotes_gpc() == 1) {
|
||||||
foreach ($opt_keys as $element) {
|
foreach ($opt_keys as $element) {
|
||||||
if (isset($options[$element][0]) && is_string($options[$element][0])) $options[$element][0] = stripslashes($options[$element][0]);
|
if (isset($options[$element][0]) && is_string($options[$element][0])) $options[$element][0] = stripslashes($options[$element][0]);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// check options
|
// check options
|
||||||
$errors = checkProfileOptions($_POST['accounttype'], $options);
|
$errors = checkProfileOptions($_POST['accounttype'], $options);
|
||||||
if (sizeof($errors) == 0) { // input data is valid, save profile
|
if (sizeof($errors) == 0) { // input data is valid, save profile
|
||||||
|
@ -140,15 +146,12 @@ if (sizeof($errors) > 0) {
|
||||||
call_user_func_array('StatusMessage', $errors[$i]);
|
call_user_func_array('StatusMessage', $errors[$i]);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// empty list of attribute types
|
// empty list of attribute types
|
||||||
$_SESSION['profile_types'] = array();
|
$_SESSION['profile_types'] = array();
|
||||||
|
|
||||||
// check if account type is valid
|
|
||||||
$type = $_GET['type'];
|
|
||||||
|
|
||||||
// get module options
|
// get module options
|
||||||
$options = getProfileOptions($type);
|
$options = getProfileOptions($type->getId());
|
||||||
|
|
||||||
// load old profile or POST values if needed
|
// load old profile or POST values if needed
|
||||||
$old_options = array();
|
$old_options = array();
|
||||||
|
@ -169,11 +172,11 @@ if (isset($_POST['save'])) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
elseif (isset($_GET['edit'])) {
|
elseif (isset($_GET['edit'])) {
|
||||||
$old_options = loadAccountProfile($_GET['edit'], $type);
|
$old_options = loadAccountProfile($_GET['edit'], $type->getId());
|
||||||
}
|
}
|
||||||
|
|
||||||
// display formular
|
// display formular
|
||||||
echo "<form action=\"profilepage.php?type=$type\" method=\"post\">\n";
|
echo "<form action=\"profilepage.php?type=" . $type->getId() . "\" method=\"post\">\n";
|
||||||
echo '<input type="hidden" name="' . getSecurityTokenName() . '" value="' . getSecurityTokenValue() . '">';
|
echo '<input type="hidden" name="' . getSecurityTokenName() . '" value="' . getSecurityTokenValue() . '">';
|
||||||
|
|
||||||
$profName = '';
|
$profName = '';
|
||||||
|
@ -192,10 +195,10 @@ $dnContent->addElement(new htmlTableExtendedInputField(_("Profile name") . '*',
|
||||||
$dnContent->addElement(new htmlSpacer(null, '10px'), true);
|
$dnContent->addElement(new htmlSpacer(null, '10px'), true);
|
||||||
// suffix box
|
// suffix box
|
||||||
// get root suffix
|
// get root suffix
|
||||||
$rootsuffix = $_SESSION['config']->get_Suffix($type);
|
$rootsuffix = $type->getSuffix();
|
||||||
// get subsuffixes
|
// get subsuffixes
|
||||||
$suffixes = array('-' => '-');
|
$suffixes = array('-' => '-');
|
||||||
$typeObj = new $type();
|
$typeObj = $type->getBaseType();
|
||||||
$possibleSuffixes = $typeObj->getSuffixList();
|
$possibleSuffixes = $typeObj->getSuffixList();
|
||||||
foreach ($possibleSuffixes as $suffix) {
|
foreach ($possibleSuffixes as $suffix) {
|
||||||
$suffixes[getAbstractDN($suffix)] = $suffix;
|
$suffixes[getAbstractDN($suffix)] = $suffix;
|
||||||
|
@ -210,7 +213,7 @@ $suffixSelect->setSortElements(false);
|
||||||
$suffixSelect->setRightToLeftTextDirection(true);
|
$suffixSelect->setRightToLeftTextDirection(true);
|
||||||
$dnContent->addElement($suffixSelect, true);
|
$dnContent->addElement($suffixSelect, true);
|
||||||
// RDNs
|
// RDNs
|
||||||
$rdns = getRDNAttributes($type);
|
$rdns = getRDNAttributes($type->getId());
|
||||||
$selectedRDN = array();
|
$selectedRDN = array();
|
||||||
if (isset($old_options['ldap_rdn'][0])) {
|
if (isset($old_options['ldap_rdn'][0])) {
|
||||||
$selectedRDN[] = $old_options['ldap_rdn'][0];
|
$selectedRDN[] = $old_options['ldap_rdn'][0];
|
||||||
|
@ -220,22 +223,22 @@ $dnContent->addElement(new htmlTableExtendedSelect('ldap_rdn', $rdns, $selectedR
|
||||||
$container->addElement(new htmlFieldset($dnContent, _("General settings"), '../../graphics/logo32.png'), true);
|
$container->addElement(new htmlFieldset($dnContent, _("General settings"), '../../graphics/logo32.png'), true);
|
||||||
$container->addElement(new htmlSpacer(null, '15px'), true);
|
$container->addElement(new htmlSpacer(null, '15px'), true);
|
||||||
|
|
||||||
$_SESSION['profile_types'] = parseHtml(null, $container, $old_options, false, $tabindex, $type);
|
$_SESSION['profile_types'] = parseHtml(null, $container, $old_options, false, $tabindex, $type->getScope());
|
||||||
|
|
||||||
// display module options
|
// display module options
|
||||||
$modules = array_keys($options);
|
$modules = array_keys($options);
|
||||||
for ($m = 0; $m < sizeof($modules); $m++) {
|
for ($m = 0; $m < sizeof($modules); $m++) {
|
||||||
// ignore modules without options
|
// ignore modules without options
|
||||||
if (sizeof($options[$modules[$m]]) < 1) continue;
|
if (sizeof($options[$modules[$m]]) < 1) continue;
|
||||||
$module = new $modules[$m]($type);
|
$module = new $modules[$m]($type->getId());
|
||||||
$icon = $module->getIcon();
|
$icon = $module->getIcon();
|
||||||
if (($icon != null) && !(strpos($icon, 'http') === 0) && !(strpos($icon, '/') === 0)) {
|
if (($icon != null) && !(strpos($icon, 'http') === 0) && !(strpos($icon, '/') === 0)) {
|
||||||
$icon = '../../graphics/' . $icon;
|
$icon = '../../graphics/' . $icon;
|
||||||
}
|
}
|
||||||
$container = new htmlTable();
|
$container = new htmlTable();
|
||||||
$container->addElement(new htmlFieldset($options[$modules[$m]], getModuleAlias($modules[$m], $type), $icon), true);
|
$container->addElement(new htmlFieldset($options[$modules[$m]], getModuleAlias($modules[$m], $type->getScope()), $icon), true);
|
||||||
$container->addElement(new htmlSpacer(null, '15px'), true);
|
$container->addElement(new htmlSpacer(null, '15px'), true);
|
||||||
$_SESSION['profile_types'] = array_merge($_SESSION['profile_types'], parseHtml($modules[$m], $container, $old_options, false, $tabindex, $type));
|
$_SESSION['profile_types'] = array_merge($_SESSION['profile_types'], parseHtml($modules[$m], $container, $old_options, false, $tabindex, $type->getScope()));
|
||||||
}
|
}
|
||||||
|
|
||||||
// profile name and submit/abort buttons
|
// profile name and submit/abort buttons
|
||||||
|
@ -246,9 +249,9 @@ $buttonTable->addElement($saveButton);
|
||||||
$cancelButton = new htmlButton('abort', _('Cancel'));
|
$cancelButton = new htmlButton('abort', _('Cancel'));
|
||||||
$cancelButton->setIconClass('cancelButton');
|
$cancelButton->setIconClass('cancelButton');
|
||||||
$buttonTable->addElement($cancelButton);
|
$buttonTable->addElement($cancelButton);
|
||||||
$buttonTable->addElement(new htmlHiddenInput('accounttype', $type));
|
$buttonTable->addElement(new htmlHiddenInput('accounttype', $type->getId()));
|
||||||
|
|
||||||
$_SESSION['profile_types'] = array_merge($_SESSION['profile_types'], parseHtml(null, $buttonTable, $old_options, false, $tabindex, $type));
|
$_SESSION['profile_types'] = array_merge($_SESSION['profile_types'], parseHtml(null, $buttonTable, $old_options, false, $tabindex, $type->getScope()));
|
||||||
|
|
||||||
?>
|
?>
|
||||||
<script type="text/javascript">
|
<script type="text/javascript">
|
||||||
|
|
Loading…
Reference in New Issue