Merge pull request #15 from LDAPAccountManager/type_api_tmp
Type api tmp
This commit is contained in:
commit
c8b1dfe35b
|
@ -34,7 +34,7 @@ $Id$
|
|||
* @package types
|
||||
*/
|
||||
class baseType {
|
||||
|
||||
|
||||
/** label to create another account */
|
||||
public $LABEL_CREATE_ANOTHER_ACCOUNT;
|
||||
/** label to return to account list */
|
||||
|
@ -47,7 +47,7 @@ class baseType {
|
|||
$this->LABEL_CREATE_ANOTHER_ACCOUNT = _('Create another account');
|
||||
$this->LABEL_BACK_TO_ACCOUNT_LIST = _('Back to account list');
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Returns the alias name of this account type.
|
||||
* This function must be overwritten by the child classes.
|
||||
|
@ -57,7 +57,7 @@ class baseType {
|
|||
public function getAlias() {
|
||||
return "baseType";
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Returns the description of this account type.
|
||||
* This function must be overwritten by the child classes.
|
||||
|
@ -67,7 +67,7 @@ class baseType {
|
|||
public function getDescription() {
|
||||
return "base type";
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Returns the class name for the list object.
|
||||
*
|
||||
|
@ -76,7 +76,7 @@ class baseType {
|
|||
public function getListClassName() {
|
||||
return "lamList";
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Returns the default attribute list for this account type.
|
||||
* This function must be overwritten by the child classes.
|
||||
|
@ -96,7 +96,7 @@ class baseType {
|
|||
public function getListAttributeDescriptions() {
|
||||
return array();
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Returns if entries of this type may be created via file upload.
|
||||
*
|
||||
|
@ -105,7 +105,7 @@ class baseType {
|
|||
public function supportsFileUpload() {
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Returns the the title text for the title bar on the new/edit page.
|
||||
*
|
||||
|
@ -128,10 +128,10 @@ class baseType {
|
|||
public function getTitleBarSubtitle($container) {
|
||||
return null;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Returns a list of LDAP suffixes for this type.
|
||||
*
|
||||
*
|
||||
* @return array sorted list of possible suffixes for this type.
|
||||
*/
|
||||
public function getSuffixList() {
|
||||
|
@ -175,25 +175,25 @@ class baseType {
|
|||
usort($ret, 'compareDN');
|
||||
return $ret;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* This function is called after the edit page is processed and before the page content is generated.
|
||||
* This can be used to run custom handlers after each page processing.
|
||||
*
|
||||
*
|
||||
* @param accountContainer $container account container
|
||||
*/
|
||||
public function runEditPagePostAction(&$container) {
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Returns a list of configuration options.
|
||||
*
|
||||
*
|
||||
* The field names are used as keywords to load and save settings.
|
||||
* We recommend to use the type name as prefix for them (e.g. user_someSetting) to avoid naming conflicts.
|
||||
*
|
||||
* @return mixed htmlElement or array of htmlElement
|
||||
*
|
||||
*
|
||||
* @see htmlElement
|
||||
*/
|
||||
public function get_configOptions() {
|
||||
|
@ -212,7 +212,11 @@ class baseType {
|
|||
public function check_configOptions(&$options) {
|
||||
return array();
|
||||
}
|
||||
|
||||
|
||||
public function supportsMultipleConfigs() {
|
||||
return false;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
?>
|
|
@ -660,17 +660,17 @@ class LAMConfig {
|
|||
$allTypes = LAM\TYPES\getTypes();
|
||||
$activeTypes = $this->get_ActiveTypes();
|
||||
for ($i = 0; $i < sizeof($activeTypes); $i++) {
|
||||
if (!in_array($activeTypes[$i], $allTypes)) {
|
||||
if (!in_array(\LAM\TYPES\getScopeFromTypeId($activeTypes[$i]), $allTypes)) {
|
||||
unset($activeTypes[$i]);
|
||||
}
|
||||
}
|
||||
$activeTypes = array_values($activeTypes);
|
||||
$this->set_ActiveTypes($activeTypes);
|
||||
// check modules
|
||||
$scopes = $this->get_ActiveTypes();
|
||||
for ($s = 0; $s < sizeof($scopes); $s++) {
|
||||
$scope = $scopes[$s];
|
||||
$moduleVar = "modules_" . $scope;
|
||||
$types = $this->get_ActiveTypes();
|
||||
foreach ($types as $type) {
|
||||
$scope = \LAM\TYPES\getScopeFromTypeId($type);
|
||||
$moduleVar = "modules_" . $type;
|
||||
if (isset($this->typeSettings[$moduleVar])){
|
||||
$modules = explode(",", $this->typeSettings[$moduleVar]);
|
||||
$available = getAvailableModules($scope);
|
||||
|
|
|
@ -73,16 +73,21 @@ function getTypes() {
|
|||
* Returns the alias name of an account type.
|
||||
*
|
||||
* @param string $type type name
|
||||
* @param \LAMConfig $config config (optional, uses $_SESSION['config'] by default)
|
||||
* @return string type alias
|
||||
*/
|
||||
function getTypeAlias($type) {
|
||||
if (!empty($_SESSION['config'])) {
|
||||
$typeSettings = $_SESSION['config']->get_typeSettings();
|
||||
function getTypeAlias($type, $config = null) {
|
||||
if (($config == null) && !empty($_SESSION['config'])) {
|
||||
$config = $_SESSION['config'];
|
||||
}
|
||||
if ($config != null) {
|
||||
$typeSettings = $config->get_typeSettings();
|
||||
if (!empty($typeSettings['customLabel_' . $type])) {
|
||||
return $typeSettings['customLabel_' . $type];
|
||||
}
|
||||
}
|
||||
$obj = new $type();
|
||||
$scope = getScopeFromTypeId($type);
|
||||
$obj = new $scope();
|
||||
return $obj->getAlias();
|
||||
}
|
||||
|
||||
|
@ -132,6 +137,17 @@ function getListAttributeDescriptions($type) {
|
|||
return $obj->getListAttributeDescriptions();
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the account type for a given type id.
|
||||
*
|
||||
* @param string $typeId type id (e.g. user_1)
|
||||
* @return string scope (e.g. user)
|
||||
*/
|
||||
function getScopeFromTypeId($typeId) {
|
||||
$parts = explode('_', $typeId);
|
||||
return $parts[0];
|
||||
}
|
||||
|
||||
/**
|
||||
* Represents a configured account type variant.
|
||||
*
|
||||
|
@ -244,7 +260,7 @@ class ConfiguredType {
|
|||
/**
|
||||
* Returns the base type of this configured type.
|
||||
*
|
||||
* @return baseType base type
|
||||
* @return \baseType base type
|
||||
*/
|
||||
public function getBaseType() {
|
||||
if ($this->baseType != null) {
|
||||
|
@ -330,6 +346,20 @@ class ListAttribute {
|
|||
*/
|
||||
class TypeManager {
|
||||
|
||||
private $config;
|
||||
|
||||
/**
|
||||
* Constructor
|
||||
*
|
||||
* @param \LAMConfig $config configuration (uses $_SESSION['config'] by default)
|
||||
*/
|
||||
public function __construct(&$config = null) {
|
||||
if ($config == null) {
|
||||
$config = &$_SESSION['config'];
|
||||
}
|
||||
$this->config = &$config;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the configured type with the given id or null.
|
||||
*
|
||||
|
@ -338,7 +368,7 @@ class TypeManager {
|
|||
*/
|
||||
public function getConfiguredType($typeId) {
|
||||
$configuredTypes = array();
|
||||
$activeTypes = $_SESSION['config']->get_ActiveTypes();
|
||||
$activeTypes = $this->config->get_ActiveTypes();
|
||||
if (in_array($typeId, $activeTypes)) {
|
||||
return $this->buildConfiguredType($typeId);
|
||||
}
|
||||
|
@ -352,7 +382,7 @@ class TypeManager {
|
|||
*/
|
||||
public function getConfiguredTypes() {
|
||||
$configuredTypes = array();
|
||||
$activeTypes = $_SESSION['config']->get_ActiveTypes();
|
||||
$activeTypes = $this->config->get_ActiveTypes();
|
||||
foreach ($activeTypes as $typeId) {
|
||||
$configuredTypes[] = $this->buildConfiguredType($typeId);
|
||||
}
|
||||
|
@ -365,12 +395,11 @@ class TypeManager {
|
|||
* @param string $typeId type id
|
||||
*/
|
||||
private function buildConfiguredType($typeId) {
|
||||
$parts = explode('_', $typeId);
|
||||
$scope = $parts[0];
|
||||
$suffix = $_SESSION['config']->get_Suffix($typeId);
|
||||
$scope = getScopeFromTypeId($typeId);
|
||||
$suffix = $this->config->get_Suffix($typeId);
|
||||
$attributes = $this->getAttributes($typeId, $scope);
|
||||
$alias = getTypeAlias($typeId);
|
||||
$ldapFilter = $_SESSION['config']->get_Suffix($typeId);
|
||||
$alias = getTypeAlias($typeId, $this->config);
|
||||
$ldapFilter = $this->config->get_Suffix($typeId);
|
||||
$hidden = isAccountTypeHidden($typeId);
|
||||
return new ConfiguredType($scope, $typeId, $suffix, $attributes, $alias, $ldapFilter, $hidden);
|
||||
}
|
||||
|
@ -383,7 +412,7 @@ class TypeManager {
|
|||
* @return \LAM\TYPES\ListAttribute[] list attributes
|
||||
*/
|
||||
private function getAttributes($typeId, $scope) {
|
||||
$attributeString = $_SESSION['config']->get_listAttributes($typeId);
|
||||
$attributeString = $this->config->get_listAttributes($typeId);
|
||||
$attributeSpecs = explode(';', $attributeString);
|
||||
$attributes = array();
|
||||
foreach ($attributeSpecs as $attributeSpec) {
|
||||
|
@ -392,6 +421,23 @@ class TypeManager {
|
|||
return $attributes;
|
||||
}
|
||||
|
||||
/**
|
||||
* Generates a new unique type id for the given scope.
|
||||
*
|
||||
* @param string $scope account type (e.g. user)
|
||||
*/
|
||||
public function generateNewTypeId($scope) {
|
||||
$activeTypes = $this->config->get_ActiveTypes();
|
||||
if (!in_array($scope, $activeTypes)) {
|
||||
return $scope;
|
||||
}
|
||||
$counter = 1;
|
||||
while (in_array($scope . '_' . $counter, $activeTypes)) {
|
||||
$counter++;
|
||||
}
|
||||
return $scope . '_' . $counter;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
?>
|
|
@ -1,4 +1,16 @@
|
|||
<?php
|
||||
namespace LAM\CONFIG;
|
||||
use \htmlTable;
|
||||
use \htmlOutputText;
|
||||
use \htmlHelpLink;
|
||||
use \htmlHiddenInput;
|
||||
use \htmlButton;
|
||||
use \htmlSpacer;
|
||||
use \htmlElement;
|
||||
use \htmlImage;
|
||||
use \htmlSortableList;
|
||||
use \htmlSubTitle;
|
||||
use \htmlDiv;
|
||||
/*
|
||||
$Id$
|
||||
|
||||
|
@ -95,8 +107,6 @@ if (isset($_POST['saveSettings']) || isset($_POST['editmodules'])
|
|||
}
|
||||
}
|
||||
|
||||
$types = $conf->get_ActiveTypes();
|
||||
|
||||
echo $_SESSION['header'];
|
||||
|
||||
echo "<title>" . _("LDAP Account Manager Configuration") . "</title>\n";
|
||||
|
@ -209,15 +219,12 @@ jQuery(document).ready(function() {
|
|||
<div class="ui-tabs-panel ui-widget-content ui-corner-bottom user-bright">
|
||||
<?php
|
||||
|
||||
|
||||
$account_list = array();
|
||||
for ($i = 0; $i < sizeof($types); $i++) {
|
||||
$account_list[] = array($types[$i], LAM\TYPES\getTypeAlias($types[$i]));
|
||||
}
|
||||
$typeManager = new \LAM\TYPES\TypeManager($conf);
|
||||
$types = $typeManager->getConfiguredTypes();
|
||||
|
||||
$container = new htmlTable();
|
||||
for ($i = 0; $i < sizeof($account_list); $i++) {
|
||||
config_showAccountModules($account_list[$i][0], $account_list[$i][1], $container);
|
||||
foreach ($types as $type) {
|
||||
config_showAccountModules($type, $container);
|
||||
}
|
||||
|
||||
$legendContainer = new htmlTable();
|
||||
|
@ -260,20 +267,19 @@ echo "</html>\n";
|
|||
/**
|
||||
* Displays the module selection boxes and checks if dependencies are fulfilled.
|
||||
*
|
||||
* @param string $scope account type
|
||||
* @param string $title title for module selection (e.g. "User modules")
|
||||
* @param \LAM\TYPES\ConfiguredType $type account type
|
||||
* @param htmlTable $container meta HTML container
|
||||
*/
|
||||
function config_showAccountModules($scope, $title, &$container) {
|
||||
function config_showAccountModules($type, &$container) {
|
||||
$conf = &$_SESSION['conf_config'];
|
||||
$typeSettings = $conf->get_typeSettings();
|
||||
// account modules
|
||||
$available = getAvailableModules($scope, true);
|
||||
$selected = !empty($typeSettings['modules_' . $scope]) ? $typeSettings['modules_' . $scope] : '';
|
||||
$available = getAvailableModules($type->getScope(), true);
|
||||
$selected = !empty($typeSettings['modules_' . $type->getId()]) ? $typeSettings['modules_' . $type->getId()] : '';
|
||||
$selected = explode(',', $selected);
|
||||
$sortedAvailable = array();
|
||||
for ($i = 0; $i < sizeof($available); $i++) {
|
||||
$sortedAvailable[$available[$i]] = getModuleAlias($available[$i], $scope);
|
||||
$sortedAvailable[$available[$i]] = getModuleAlias($available[$i], $type->getScope());
|
||||
}
|
||||
natcasesort($sortedAvailable);
|
||||
|
||||
|
@ -281,18 +287,18 @@ function config_showAccountModules($scope, $title, &$container) {
|
|||
$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], $scope)) { // mark base modules
|
||||
$selOptions[getModuleAlias($selected[$i], $scope) . " (" . $selected[$i] . ")(*)"] = $selected[$i];
|
||||
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], $scope) . " (" . $selected[$i] . ")"] = $selected[$i];
|
||||
$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, $scope)) { // mark base modules
|
||||
if (is_base_module($key, $type->getScope())) { // mark base modules
|
||||
$availOptions[$value . " (" . $key . ")(*)"] = $key;
|
||||
}
|
||||
else {
|
||||
|
@ -302,7 +308,7 @@ function config_showAccountModules($scope, $title, &$container) {
|
|||
}
|
||||
|
||||
// add account module selection
|
||||
$container->addElement(new htmlSubTitle($title, '../../graphics/' . $scope . '.png'), true);
|
||||
$container->addElement(new htmlSubTitle($type->getAlias(), '../../graphics/' . $type->getScope() . '.png'), true);
|
||||
$container->addElement(new htmlOutputText(_("Selected modules")));
|
||||
$container->addElement(new htmlOutputText(''));
|
||||
$container->addElement(new htmlOutputText(_("Available modules")), true);
|
||||
|
@ -313,17 +319,17 @@ function config_showAccountModules($scope, $title, &$container) {
|
|||
$listElements = array();
|
||||
foreach ($selOptions as $key => $value) {
|
||||
$el = new htmlTable('100%');
|
||||
$mod = new $value($scope);
|
||||
$mod = new $value($type->getScope());
|
||||
$el->addElement(new htmlImage('../../graphics/' . $mod->getIcon(), '16px', '16px'));
|
||||
$el->addElement(new htmlOutputText($key));
|
||||
$delButton = new htmlButton('del_' . $scope . '_' . $value, 'del.png', true);
|
||||
$delButton = new htmlButton('del_' . $type->getId() . '_' . $value, 'del.png', true);
|
||||
$delButton->alignment = htmlElement::ALIGN_RIGHT;
|
||||
$el->addElement($delButton);
|
||||
$listElements[] = $el;
|
||||
}
|
||||
$selSortable = new htmlSortableList($listElements, $scope . '_selected', '350px');
|
||||
$selSortable = new htmlSortableList($listElements, $type->getId() . '_selected', '350px');
|
||||
$selSortable->alignment = htmlElement::ALIGN_TOP;
|
||||
$selSortable->setOnUpdate('updateModulePositions(\'positions_' . $scope . '\', ui.item.data(\'posOrig\'), ui.item.index());');
|
||||
$selSortable->setOnUpdate('updateModulePositions(\'positions_' . $type->getId() . '\', ui.item.data(\'posOrig\'), ui.item.index());');
|
||||
$container->addElement($selSortable);
|
||||
}
|
||||
else {
|
||||
|
@ -335,10 +341,10 @@ function config_showAccountModules($scope, $title, &$container) {
|
|||
if (sizeof($availOptions) > 0) {
|
||||
$availTable = new htmlTable();
|
||||
foreach ($availOptions as $text => $key) {
|
||||
$mod = new $key($scope);
|
||||
$mod = new $key($type->getScope());
|
||||
$availTable->addElement(new htmlImage('../../graphics/' . $mod->getIcon(), '16px', '16px'));
|
||||
$availTable->addElement(new htmlOutputText($text));
|
||||
$addButton = new htmlButton('add_' . $scope . '_' . $key, 'add.png', true);
|
||||
$addButton = new htmlButton('add_' . $type->getId() . '_' . $key, 'add.png', true);
|
||||
$addButton->alignment = htmlElement::ALIGN_RIGHT;
|
||||
$availTable->addElement($addButton, true);
|
||||
}
|
||||
|
@ -351,7 +357,7 @@ function config_showAccountModules($scope, $title, &$container) {
|
|||
for ($i = 0; $i < sizeof($selOptions); $i++) {
|
||||
$positions[] = $i;
|
||||
}
|
||||
$container->addElement(new htmlHiddenInput('positions_' . $scope, implode(',', $positions)), true);
|
||||
$container->addElement(new htmlHiddenInput('positions_' . $type->getId(), implode(',', $positions)), true);
|
||||
// spacer to next account type
|
||||
$container->addElement(new htmlSpacer(null, '30px'), true);
|
||||
}
|
||||
|
@ -368,11 +374,13 @@ function checkInput() {
|
|||
$errors = array();
|
||||
$conf = &$_SESSION['conf_config'];
|
||||
$typeSettings = $conf->get_typeSettings();
|
||||
$accountTypes = $conf->get_ActiveTypes();
|
||||
for ($t = 0; $t < sizeof($accountTypes); $t++) {
|
||||
$scope = $accountTypes[$t];
|
||||
$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_' . $scope])) ? $typeSettings['modules_' . $scope] : '';
|
||||
$selected_temp = (isset($typeSettings['modules_' . $typeId])) ? $typeSettings['modules_' . $typeId] : '';
|
||||
$selected_temp = explode(',', $selected_temp);
|
||||
$selected = array();
|
||||
// only use available modules as selected
|
||||
|
@ -382,7 +390,7 @@ function checkInput() {
|
|||
}
|
||||
}
|
||||
// reorder based on sortable list
|
||||
$sorting = $_POST['positions_' . $scope];
|
||||
$sorting = $_POST['positions_' . $typeId];
|
||||
if (!empty($sorting)) {
|
||||
$sorting = explode(',', $sorting);
|
||||
$sortTmp = array();
|
||||
|
@ -394,17 +402,17 @@ function checkInput() {
|
|||
// remove modules from selection
|
||||
$new_selected = array();
|
||||
for ($i = 0; $i < sizeof($selected); $i++) {
|
||||
if (!isset($_POST['del_' . $scope . '_' . $selected[$i]])) {
|
||||
if (!isset($_POST['del_' . $typeId . '_' . $selected[$i]])) {
|
||||
$new_selected[] = $selected[$i];
|
||||
}
|
||||
}
|
||||
$selected = $new_selected;
|
||||
$typeSettings['modules_' . $scope] = implode(',', $selected);
|
||||
$typeSettings['modules_' . $typeId] = implode(',', $selected);
|
||||
// add modules to selection
|
||||
foreach ($available as $modName) {
|
||||
if (isset($_POST['add_' . $scope . '_' . $modName])) {
|
||||
if (isset($_POST['add_' . $typeId . '_' . $modName])) {
|
||||
$selected[] = $modName;
|
||||
$typeSettings['modules_' . $scope] = implode(',', $selected);
|
||||
$typeSettings['modules_' . $typeId] = implode(',', $selected);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
@ -412,7 +420,7 @@ function checkInput() {
|
|||
$depends = check_module_depends($selected, getModulesDependencies($scope));
|
||||
if ($depends != false) {
|
||||
for ($i = 0; $i < sizeof($depends); $i++) {
|
||||
$errors[] = array('ERROR', LAM\TYPES\getTypeAlias($scope), _("Unsolved dependency:") . ' ' .
|
||||
$errors[] = array('ERROR', $type->getAlias(), _("Unsolved dependency:") . ' ' .
|
||||
$depends[$i][0] . " (" . $depends[$i][1] . ")");
|
||||
}
|
||||
}
|
||||
|
@ -420,7 +428,7 @@ function checkInput() {
|
|||
$conflicts = check_module_conflicts($selected, getModulesDependencies($scope));
|
||||
if ($conflicts != false) {
|
||||
for ($i = 0; $i < sizeof($conflicts); $i++) {
|
||||
$errors[] = array('ERROR', LAM\TYPES\getTypeAlias($scope), _("Conflicting module:") . ' ' .
|
||||
$errors[] = array('ERROR', $type->getAlias(), _("Conflicting module:") . ' ' .
|
||||
$conflicts[$i][0] . " (" . $conflicts[$i][1] . ")");
|
||||
}
|
||||
}
|
||||
|
@ -432,7 +440,7 @@ function checkInput() {
|
|||
}
|
||||
}
|
||||
if ($baseCount != 1) {
|
||||
$errors[] = array('ERROR', LAM\TYPES\getTypeAlias($scope), _("No or more than one base module selected!"));
|
||||
$errors[] = array('ERROR', $type->getAlias(), _("No or more than one base module selected!"));
|
||||
}
|
||||
}
|
||||
$conf->set_typeSettings($typeSettings);
|
||||
|
|
|
@ -1,4 +1,16 @@
|
|||
<?php
|
||||
namespace LAM\CONFIG;
|
||||
use \htmlTable;
|
||||
use \htmlSubTitle;
|
||||
use \htmlImage;
|
||||
use \htmlOutputText;
|
||||
use \htmlSpacer;
|
||||
use \htmlButton;
|
||||
use \htmlElement;
|
||||
use \htmlGroup;
|
||||
use \htmlTableExtendedInputField;
|
||||
use \LAMConfig;
|
||||
use \htmlTableExtendedInputCheckbox;
|
||||
/*
|
||||
$Id$
|
||||
|
||||
|
@ -105,15 +117,22 @@ if (isset($_POST['saveSettings']) || isset($_POST['editmodules'])
|
|||
}
|
||||
|
||||
$typeSettings = $conf->get_typeSettings();
|
||||
$allTypes = LAM\TYPES\getTypes();
|
||||
$activeTypes = $conf->get_ActiveTypes();
|
||||
$availableTypes = array();
|
||||
for ($i = 0; $i < sizeof($allTypes); $i++) {
|
||||
if (!in_array($allTypes[$i], $activeTypes)) {
|
||||
$availableTypes[$allTypes[$i]] = LAM\TYPES\getTypeAlias($allTypes[$i]);
|
||||
$allScopes = \LAM\TYPES\getTypes();
|
||||
$typeManager = new \LAM\TYPES\TypeManager($conf);
|
||||
$activeTypes = $typeManager->getConfiguredTypes();
|
||||
$activeScopes = array();
|
||||
foreach ($activeTypes as $activeType) {
|
||||
$activeScopes[] = $activeType->getScope();
|
||||
}
|
||||
$activeScopes = array_unique($activeScopes);
|
||||
$availableScopes = array();
|
||||
foreach ($allScopes as $scope) {
|
||||
$scopeObj = new $scope();
|
||||
if (!in_array($scope, $activeScopes) || $scopeObj->supportsMultipleConfigs()) {
|
||||
$availableScopes[$scope] = $scopeObj->getAlias();
|
||||
}
|
||||
}
|
||||
natcasesort($availableTypes);
|
||||
natcasesort($availableScopes);
|
||||
|
||||
echo $_SESSION['header'];
|
||||
|
||||
|
@ -223,14 +242,14 @@ jQuery(document).ready(function() {
|
|||
$container = new htmlTable();
|
||||
|
||||
// show available types
|
||||
if (sizeof($availableTypes) > 0) {
|
||||
if (sizeof($availableScopes) > 0) {
|
||||
$container->addElement(new htmlSubTitle(_("Available account types")), true);
|
||||
$availableContainer = new htmlTable();
|
||||
foreach ($availableTypes as $key => $value) {
|
||||
foreach ($availableScopes as $key => $value) {
|
||||
$availableContainer->addElement(new htmlImage('../../graphics/' . $key . '.png'));
|
||||
$availableContainer->addElement(new htmlOutputText($value));
|
||||
$availableContainer->addElement(new htmlSpacer('10px', null));
|
||||
$availableContainer->addElement(new htmlOutputText(LAM\TYPES\getTypeDescription($key)));
|
||||
$availableContainer->addElement(new htmlOutputText(\LAM\TYPES\getTypeDescription($key)));
|
||||
$button = new htmlButton('add_' . $key, 'add.png', true);
|
||||
$button->setTitle(_("Add"));
|
||||
$availableContainer->addElement($button, true);
|
||||
|
@ -244,59 +263,58 @@ $_SESSION['conftypes_optionTypes'] = array();
|
|||
if (sizeof($activeTypes) > 0) {
|
||||
$container->addElement(new htmlSubTitle(_("Active account types")), true);
|
||||
$activeContainer = new htmlTable();
|
||||
for ($i = 0; $i < sizeof($activeTypes); $i++) {
|
||||
foreach ($activeTypes as $activeType) {
|
||||
// title
|
||||
$titleGroup = new htmlGroup();
|
||||
$titleGroup->colspan = 6;
|
||||
$titleGroup->addElement(new htmlImage('../../graphics/' . $activeTypes[$i] . '.png'));
|
||||
$titleText = new htmlOutputText(LAM\TYPES\getTypeAlias($activeTypes[$i]));
|
||||
$titleGroup->addElement(new htmlImage('../../graphics/' . $activeType->getScope() . '.png'));
|
||||
$titleText = new htmlOutputText($activeType->getAlias());
|
||||
$titleText->setIsBold(true);
|
||||
$titleGroup->addElement($titleText);
|
||||
$titleGroup->addElement(new htmlSpacer('10px', null));
|
||||
$titleGroup->addElement(new htmlOutputText(LAM\TYPES\getTypeDescription($activeTypes[$i])));
|
||||
$titleGroup->addElement(new htmlOutputText($activeType->getBaseType()->getDescription()));
|
||||
$activeContainer->addElement($titleGroup);
|
||||
// delete button
|
||||
$delButton = new htmlButton('rem_'. $activeTypes[$i], 'del.png', true);
|
||||
$delButton = new htmlButton('rem_'. $activeType->getId(), 'del.png', true);
|
||||
$delButton->alignment = htmlElement::ALIGN_RIGHT;
|
||||
$delButton->setTitle(_("Remove this account type"));
|
||||
$activeContainer->addElement($delButton, true); //del.png
|
||||
$activeContainer->addElement(new htmlSpacer(null, '5px'), true);
|
||||
// LDAP suffix
|
||||
$suffixInput = new htmlTableExtendedInputField(_("LDAP suffix"), 'suffix_' . $activeTypes[$i], $typeSettings['suffix_' . $activeTypes[$i]], '202');
|
||||
$suffixInput = new htmlTableExtendedInputField(_("LDAP suffix"), 'suffix_' . $activeType->getId(), $typeSettings['suffix_' . $activeType->getId()], '202');
|
||||
$suffixInput->setFieldSize(40);
|
||||
$activeContainer->addElement($suffixInput);
|
||||
$activeContainer->addElement(new htmlSpacer('20px', null));
|
||||
// list attributes
|
||||
if (isset($typeSettings['attr_' . $activeTypes[$i]])) {
|
||||
$attributes = $typeSettings['attr_' . $activeTypes[$i]];
|
||||
if (isset($typeSettings['attr_' . $activeType->getId()])) {
|
||||
$attributes = $typeSettings['attr_' . $activeType->getId()];
|
||||
}
|
||||
else {
|
||||
$attributes = LAM\TYPES\getDefaultListAttributes($activeTypes[$i]);
|
||||
$attributes = \LAM\TYPES\getDefaultListAttributes($activeType->getScope());
|
||||
}
|
||||
$attrsInput = new htmlTableExtendedInputField(_("List attributes"), 'attr_' . $activeTypes[$i], $attributes, '206');
|
||||
$attrsInput = new htmlTableExtendedInputField(_("List attributes"), 'attr_' . $activeType->getId(), $attributes, '206');
|
||||
$attrsInput->setFieldSize(40);
|
||||
$attrsInput->setFieldMaxLength(1000);
|
||||
$activeContainer->addElement($attrsInput, true);
|
||||
// custom label
|
||||
$customLabel = '';
|
||||
if (isset($typeSettings['customLabel_' . $activeTypes[$i]])) {
|
||||
$customLabel = $typeSettings['customLabel_' . $activeTypes[$i]];
|
||||
if (isset($typeSettings['customLabel_' . $activeType->getId()])) {
|
||||
$customLabel = $typeSettings['customLabel_' . $activeType->getId()];
|
||||
}
|
||||
$customLabelInput = new htmlTableExtendedInputField(_('Custom label'), 'customLabel_' . $activeTypes[$i], $customLabel, '264');
|
||||
$customLabelInput = new htmlTableExtendedInputField(_('Custom label'), 'customLabel_' . $activeType->getId(), $customLabel, '264');
|
||||
$customLabelInput->setFieldSize(40);
|
||||
$activeContainer->addElement($customLabelInput);
|
||||
$activeContainer->addElement(new htmlSpacer('20px', null));
|
||||
// LDAP filter
|
||||
$filter = '';
|
||||
if (isset($typeSettings['filter_' . $activeTypes[$i]])) {
|
||||
$filter = $typeSettings['filter_' . $activeTypes[$i]];
|
||||
if (isset($typeSettings['filter_' . $activeType->getId()])) {
|
||||
$filter = $typeSettings['filter_' . $activeType->getId()];
|
||||
}
|
||||
$filterInput = new htmlTableExtendedInputField(_("Additional LDAP filter"), 'filter_' . $activeTypes[$i], $filter, '260');
|
||||
$filterInput = new htmlTableExtendedInputField(_("Additional LDAP filter"), 'filter_' . $activeType->getId(), $filter, '260');
|
||||
$filterInput->setFieldSize(40);
|
||||
$activeContainer->addElement($filterInput, true);
|
||||
// type options
|
||||
$typeObj = new $activeTypes[$i];
|
||||
$typeConfigOptions = $typeObj->get_configOptions();
|
||||
$typeConfigOptions = $activeType->getBaseType()->get_configOptions();
|
||||
if (!empty($typeConfigOptions)) {
|
||||
foreach ($typeConfigOptions as $typeConfigOption) {
|
||||
$activeContainer->addElement($typeConfigOption, true);
|
||||
|
@ -314,35 +332,35 @@ if (sizeof($activeTypes) > 0) {
|
|||
// read-only
|
||||
if (isLAMProVersion() && ($conf->getAccessLevel() == LAMConfig::ACCESS_ALL)) {
|
||||
$isReadOnly = false;
|
||||
if (isset($typeSettings['readOnly_' . $activeTypes[$i]])) {
|
||||
$isReadOnly = $typeSettings['readOnly_' . $activeTypes[$i]];
|
||||
if (isset($typeSettings['readOnly_' . $activeType->getId()])) {
|
||||
$isReadOnly = $typeSettings['readOnly_' . $activeType->getId()];
|
||||
}
|
||||
$readOnly = new htmlTableExtendedInputCheckbox('readOnly_' . $activeTypes[$i], $isReadOnly, _('Read-only'), '265');
|
||||
$readOnly->setElementsToDisable(array('hideNewButton_' . $activeTypes[$i], 'hideDeleteButton_' . $activeTypes[$i]));
|
||||
$readOnly = new htmlTableExtendedInputCheckbox('readOnly_' . $activeType->getId(), $isReadOnly, _('Read-only'), '265');
|
||||
$readOnly->setElementsToDisable(array('hideNewButton_' . $activeType->getId(), 'hideDeleteButton_' . $activeType->getId()));
|
||||
$advancedOptions->addElement($readOnly);
|
||||
$advancedOptions->addElement(new htmlSpacer('20px', null));
|
||||
}
|
||||
// hidden type
|
||||
$hidden = false;
|
||||
if (isset($typeSettings['hidden_' . $activeTypes[$i]])) {
|
||||
$hidden = $typeSettings['hidden_' . $activeTypes[$i]];
|
||||
if (isset($typeSettings['hidden_' . $activeType->getId()])) {
|
||||
$hidden = $typeSettings['hidden_' . $activeType->getId()];
|
||||
}
|
||||
$advancedOptions->addElement(new htmlTableExtendedInputCheckbox('hidden_' . $activeTypes[$i], $hidden, _('Hidden'), '261'));
|
||||
$advancedOptions->addElement(new htmlTableExtendedInputCheckbox('hidden_' . $activeType->getId(), $hidden, _('Hidden'), '261'));
|
||||
if (isLAMProVersion() && ($conf->getAccessLevel() == LAMConfig::ACCESS_ALL)) {
|
||||
$advancedOptions->addElement(new htmlSpacer('20px', null));
|
||||
// hide button to create new accounts
|
||||
$hideNewButton = false;
|
||||
if (isset($typeSettings['hideNewButton_' . $activeTypes[$i]])) {
|
||||
$hideNewButton = $typeSettings['hideNewButton_' . $activeTypes[$i]];
|
||||
if (isset($typeSettings['hideNewButton_' . $activeType->getId()])) {
|
||||
$hideNewButton = $typeSettings['hideNewButton_' . $activeType->getId()];
|
||||
}
|
||||
$advancedOptions->addElement(new htmlTableExtendedInputCheckbox('hideNewButton_' . $activeTypes[$i], $hideNewButton, _('No new entries'), '262'));
|
||||
$advancedOptions->addElement(new htmlTableExtendedInputCheckbox('hideNewButton_' . $activeType->getId(), $hideNewButton, _('No new entries'), '262'));
|
||||
$advancedOptions->addElement(new htmlSpacer('20px', null));
|
||||
// hide button to delete accounts
|
||||
$hideDeleteButton = false;
|
||||
if (isset($typeSettings['hideDeleteButton_' . $activeTypes[$i]])) {
|
||||
$hideDeleteButton = $typeSettings['hideDeleteButton_' . $activeTypes[$i]];
|
||||
if (isset($typeSettings['hideDeleteButton_' . $activeType->getId()])) {
|
||||
$hideDeleteButton = $typeSettings['hideDeleteButton_' . $activeType->getId()];
|
||||
}
|
||||
$advancedOptions->addElement(new htmlTableExtendedInputCheckbox('hideDeleteButton_' . $activeTypes[$i], $hideDeleteButton, _('Disallow delete'), '263'), true);
|
||||
$advancedOptions->addElement(new htmlTableExtendedInputCheckbox('hideDeleteButton_' . $activeType->getId(), $hideDeleteButton, _('Disallow delete'), '263'), true);
|
||||
}
|
||||
$activeContainer->addElement($advancedOptions, true);
|
||||
|
||||
|
@ -391,6 +409,7 @@ function checkInput() {
|
|||
}
|
||||
$errors = array();
|
||||
$conf = &$_SESSION['conf_config'];
|
||||
$typeManager = new \LAM\TYPES\TypeManager($conf);
|
||||
$typeSettings = $conf->get_typeSettings();
|
||||
$accountTypes = $conf->get_ActiveTypes();
|
||||
$postKeys = array_keys($_POST);
|
||||
|
@ -404,17 +423,12 @@ function checkInput() {
|
|||
$accountTypes = array_flip($accountTypes);
|
||||
$accountTypes = array_values($accountTypes);
|
||||
}
|
||||
// check if add button was pressed
|
||||
else if (substr($key, 0, 4) == "add_") {
|
||||
$type = substr($key, 4);
|
||||
$accountTypes[] = $type;
|
||||
}
|
||||
// set suffixes
|
||||
elseif (substr($key, 0, 7) == "suffix_") {
|
||||
$typeSettings[$key] = trim($_POST[$key]);
|
||||
$type = substr($postKeys[$i], 7);
|
||||
if (strlen($_POST[$key]) < 1) {
|
||||
$errors[] = array("ERROR", _("LDAP Suffix is invalid!"), LAM\TYPES\getTypeAlias($type));
|
||||
$errors[] = array("ERROR", _("LDAP Suffix is invalid!"), \LAM\TYPES\getTypeAlias($type));
|
||||
}
|
||||
}
|
||||
// set attributes
|
||||
|
@ -422,7 +436,7 @@ function checkInput() {
|
|||
$typeSettings[$key] = $_POST[$key];
|
||||
$type = substr($postKeys[$i], 5);
|
||||
if (!is_string($_POST[$key]) || !preg_match("/^((#[^:;]+)|([^:;]*:[^:;]+))(;((#[^:;]+)|([^:;]*:[^:;]+)))*$/", $_POST[$key])) {
|
||||
$errors[] = array("ERROR", _("List attributes are invalid!"), LAM\TYPES\getTypeAlias($type));
|
||||
$errors[] = array("ERROR", _("List attributes are invalid!"), \LAM\TYPES\getTypeAlias($type));
|
||||
}
|
||||
}
|
||||
// set filter
|
||||
|
@ -435,28 +449,36 @@ function checkInput() {
|
|||
}
|
||||
}
|
||||
$typeConfigOptions = extractConfigOptionsFromPOST($_SESSION['conftypes_optionTypes']);
|
||||
for ($i = 0; $i < sizeof($accountTypes); $i++) {
|
||||
foreach ($accountTypes as $accountType) {
|
||||
// set hidden
|
||||
$key = "hidden_" . $accountTypes[$i];
|
||||
$key = "hidden_" . $accountType;
|
||||
$typeSettings[$key] = (isset($_POST[$key]) && ($_POST[$key] == 'on'));
|
||||
if (isLAMProVersion() && ($conf->getAccessLevel() == LAMConfig::ACCESS_ALL)) {
|
||||
// set if new entries are allowed
|
||||
$key = "hideNewButton_" . $accountTypes[$i];
|
||||
$key = "hideNewButton_" . $accountType;
|
||||
$typeSettings[$key] = (isset($_POST[$key]) && ($_POST[$key] == 'on'));
|
||||
// set if deletion of entries is allowed
|
||||
$key = "hideDeleteButton_" . $accountTypes[$i];
|
||||
$key = "hideDeleteButton_" . $accountType;
|
||||
$typeSettings[$key] = (isset($_POST[$key]) && ($_POST[$key] == 'on'));
|
||||
// set if account type is read-only
|
||||
$key = "readOnly_" . $accountTypes[$i];
|
||||
$key = "readOnly_" . $accountType;
|
||||
$typeSettings[$key] = (isset($_POST[$key]) && ($_POST[$key] == 'on'));
|
||||
}
|
||||
// check dynamic type settings
|
||||
$typeObj = new $accountTypes[$i];
|
||||
$typeObj = $typeManager->getConfiguredType($accountType)->getBaseType();
|
||||
$typeMessages = $typeObj->check_configOptions($typeConfigOptions);
|
||||
if (!empty($typeMessages)) {
|
||||
$errors = array_merge($errors, $typeMessages);
|
||||
}
|
||||
}
|
||||
// new type
|
||||
foreach ($_POST as $key => $value) {
|
||||
// check if add button was pressed
|
||||
if (substr($key, 0, 4) == "add_") {
|
||||
$scope = substr($key, 4);
|
||||
$accountTypes[] = $typeManager->generateNewTypeId($scope);
|
||||
}
|
||||
}
|
||||
// add dynamic type settings
|
||||
foreach ($typeConfigOptions as $key => $value) {
|
||||
$typeSettings[$key] = implode(LAMConfig::LINE_SEPARATOR, $value);
|
||||
|
|
|
@ -62,11 +62,13 @@ if (!is_array($classes)) {
|
|||
}
|
||||
else {
|
||||
// loop for active account types
|
||||
for ($t = 0; $t < sizeof($types); $t++) {
|
||||
$modules = $_SESSION['config']->get_AccountModules($types[$t]);
|
||||
$container->addElement(new htmlSubTitle(LAM\TYPES\getTypeAlias($types[$t])), true);
|
||||
$typeManager = new \LAM\TYPES\TypeManager();
|
||||
$types = $typeManager->getConfiguredTypes();
|
||||
foreach ($types as $type) {
|
||||
$modules = $_SESSION['config']->get_AccountModules($type->getId());
|
||||
$container->addElement(new htmlSubTitle($type->getAlias()), true);
|
||||
for ($m = 0; $m < sizeof($modules); $m++) {
|
||||
$error = checkSchemaForModule($modules[$m], $types[$t]);
|
||||
$error = checkSchemaForModule($modules[$m], $type->getScope());
|
||||
$message = _("No problems found.");
|
||||
$icon = '../../graphics/pass.png';
|
||||
if ($error != null) {
|
||||
|
@ -74,7 +76,7 @@ else {
|
|||
$message = $error;
|
||||
}
|
||||
// module name
|
||||
$container->addElement(new htmlOutputText(getModuleAlias($modules[$m], $types[$t])));
|
||||
$container->addElement(new htmlOutputText(getModuleAlias($modules[$m], $type->getScope())));
|
||||
$container->addElement(new htmlSpacer('10px', null));
|
||||
// icon
|
||||
$container->addElement(new htmlImage($icon));
|
||||
|
|
Loading…
Reference in New Issue