new type API

This commit is contained in:
Roland Gruber 2016-12-26 19:11:05 +01:00
parent 0bf8702763
commit cbdd69f7f6
6 changed files with 133 additions and 106 deletions

View File

@ -1,9 +1,10 @@
<?php <?php
namespace LAM\TOOLS\UPLOAD;
/* /*
$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) 2009 - 2011 Roland Gruber Copyright (C) 2009 - 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
@ -33,7 +34,7 @@ $Id$
* *
* @package tools * @package tools
*/ */
class toolFileUpload implements LAMTool { class toolFileUpload implements \LAMTool {
/** /**
* Returns the name of the tool. * Returns the name of the tool.

View File

@ -1,20 +1,21 @@
<?php <?php
namespace LAM\TOOLS\MULTI_EDIT;
/* /*
$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) 2013 Roland Gruber Copyright (C) 2013 - 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
the Free Software Foundation; either version 2 of the License, or the Free Software Foundation; either version 2 of the License, or
(at your option) any later version. (at your option) any later version.
This program is distributed in the hope that it will be useful, This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details. GNU General Public License for more details.
You should have received a copy of the GNU General Public License You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software along with this program; if not, write to the Free Software
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
@ -30,56 +31,56 @@ $Id$
/** /**
* Multi edit tool that allows LDAP operations on multiple entries. * Multi edit tool that allows LDAP operations on multiple entries.
* *
* @package tools * @package tools
*/ */
class toolMultiEdit implements LAMTool { class toolMultiEdit implements \LAMTool {
/** /**
* Returns the name of the tool. * Returns the name of the tool.
* *
* @return string name * @return string name
*/ */
function getName() { function getName() {
return _("Multi edit"); return _("Multi edit");
} }
/** /**
* returns a description text for the tool. * returns a description text for the tool.
* *
* @return string description * @return string description
*/ */
function getDescription() { function getDescription() {
return _("Performs modifications on multiple LDAP entries."); return _("Performs modifications on multiple LDAP entries.");
} }
/** /**
* Returns a link to the tool page (relative to templates/). * Returns a link to the tool page (relative to templates/).
* *
* @return string link * @return string link
*/ */
function getLink() { function getLink() {
return "multiEdit.php"; return "multiEdit.php";
} }
/** /**
* Returns if the tool requires write access to LDAP. * Returns if the tool requires write access to LDAP.
* *
* @return boolean true if write access is needed * @return boolean true if write access is needed
*/ */
function getRequiresWriteAccess() { function getRequiresWriteAccess() {
return true; return true;
} }
/** /**
* Returns if the tool requires password change rights. * Returns if the tool requires password change rights.
* *
* @return boolean true if password change rights are needed * @return boolean true if password change rights are needed
*/ */
function getRequiresPasswordChangeRights() { function getRequiresPasswordChangeRights() {
return true; return true;
} }
/** /**
* Returns the link to the tool image (relative to graphics/) * Returns the link to the tool image (relative to graphics/)
* *
@ -88,7 +89,7 @@ class toolMultiEdit implements LAMTool {
function getImageLink() { function getImageLink() {
return 'edit.png'; return 'edit.png';
} }
/** /**
* Returns the prefered position of this tool on the tools page. * Returns the prefered position of this tool on the tools page.
* The position may be between 0 and 1000. 0 is the top position. * The position may be between 0 and 1000. 0 is the top position.
@ -98,16 +99,16 @@ class toolMultiEdit implements LAMTool {
function getPosition() { function getPosition() {
return 400; return 400;
} }
/** /**
* Returns a list of sub tools or an empty array. * Returns a list of sub tools or an empty array.
* *
* @return array list of subtools (LAMTool) * @return array list of subtools (LAMTool)
*/ */
function getSubTools() { function getSubTools() {
return array(); return array();
} }
/** /**
* Returns if the tool is visible in the menu. * Returns if the tool is visible in the menu.
* *
@ -116,16 +117,16 @@ class toolMultiEdit implements LAMTool {
function isVisible() { function isVisible() {
return true; return true;
} }
/** /**
* Returns if a tool may be hidden by configuration in the LAM server profile. * Returns if a tool may be hidden by configuration in the LAM server profile.
* *
* @return boolean hideable * @return boolean hideable
*/ */
function isHideable() { function isHideable() {
return true; return true;
} }
} }
?> ?>

View File

@ -1,4 +1,5 @@
<?php <?php
namespace LAM\TOOLS\SCHEMA;
/* /*
$Id$ $Id$
@ -9,12 +10,12 @@ $Id$
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
the Free Software Foundation; either version 2 of the License, or the Free Software Foundation; either version 2 of the License, or
(at your option) any later version. (at your option) any later version.
This program is distributed in the hope that it will be useful, This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details. GNU General Public License for more details.
You should have received a copy of the GNU General Public License You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software along with this program; if not, write to the Free Software
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
@ -30,56 +31,56 @@ $Id$
/** /**
* Schema browser * Schema browser
* *
* @package tools * @package tools
*/ */
class toolSchemaBrowser implements LAMTool { class toolSchemaBrowser implements \LAMTool {
/** /**
* Returns the name of the tool. * Returns the name of the tool.
* *
* @return string name * @return string name
*/ */
function getName() { function getName() {
return _("Schema browser"); return _("Schema browser");
} }
/** /**
* returns a description text for the tool. * returns a description text for the tool.
* *
* @return string description * @return string description
*/ */
function getDescription() { function getDescription() {
return _("Here you can browse LDAP object classes and attributes."); return _("Here you can browse LDAP object classes and attributes.");
} }
/** /**
* Returns a link to the tool page (relative to templates/). * Returns a link to the tool page (relative to templates/).
* *
* @return string link * @return string link
*/ */
function getLink() { function getLink() {
return "schema/schema.php"; return "schema/schema.php";
} }
/** /**
* Returns if the tool requires write access to LDAP. * Returns if the tool requires write access to LDAP.
* *
* @return boolean true if write access is needed * @return boolean true if write access is needed
*/ */
function getRequiresWriteAccess() { function getRequiresWriteAccess() {
return false; return false;
} }
/** /**
* Returns if the tool requires password change rights. * Returns if the tool requires password change rights.
* *
* @return boolean true if password change rights are needed * @return boolean true if password change rights are needed
*/ */
function getRequiresPasswordChangeRights() { function getRequiresPasswordChangeRights() {
return false; return false;
} }
/** /**
* Returns the link to the tool image (relative to graphics/) * Returns the link to the tool image (relative to graphics/)
* *
@ -88,7 +89,7 @@ class toolSchemaBrowser implements LAMTool {
function getImageLink() { function getImageLink() {
return 'schemaBrowser.png'; return 'schemaBrowser.png';
} }
/** /**
* Returns the prefered position of this tool on the tools page. * Returns the prefered position of this tool on the tools page.
* The position may be between 0 and 1000. 0 is the top position. * The position may be between 0 and 1000. 0 is the top position.
@ -98,16 +99,16 @@ class toolSchemaBrowser implements LAMTool {
function getPosition() { function getPosition() {
return 600; return 600;
} }
/** /**
* Returns a list of sub tools or an empty array. * Returns a list of sub tools or an empty array.
* *
* @return array list of subtools (LAMTool) * @return array list of subtools (LAMTool)
*/ */
function getSubTools() { function getSubTools() {
return array(); return array();
} }
/** /**
* Returns if the tool is visible in the menu. * Returns if the tool is visible in the menu.
* *
@ -116,16 +117,16 @@ class toolSchemaBrowser implements LAMTool {
function isVisible() { function isVisible() {
return true; return true;
} }
/** /**
* Returns if a tool may be hidden by configuration in the LAM server profile. * Returns if a tool may be hidden by configuration in the LAM server profile.
* *
* @return boolean hideable * @return boolean hideable
*/ */
function isHideable() { function isHideable() {
return true; return true;
} }
} }
?> ?>

View File

@ -1,20 +1,21 @@
<?php <?php
namespace LAM\TOOLS\SERVER_INFO;
/* /*
$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) 2009 - 2011 Roland Gruber Copyright (C) 2009 - 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
the Free Software Foundation; either version 2 of the License, or the Free Software Foundation; either version 2 of the License, or
(at your option) any later version. (at your option) any later version.
This program is distributed in the hope that it will be useful, This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details. GNU General Public License for more details.
You should have received a copy of the GNU General Public License You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software along with this program; if not, write to the Free Software
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
@ -30,56 +31,56 @@ $Id$
/** /**
* Server information * Server information
* *
* @package tools * @package tools
*/ */
class toolServerInformation implements LAMTool { class toolServerInformation implements \LAMTool {
/** /**
* Returns the name of the tool. * Returns the name of the tool.
* *
* @return string name * @return string name
*/ */
function getName() { function getName() {
return _("Server information"); return _("Server information");
} }
/** /**
* returns a description text for the tool. * returns a description text for the tool.
* *
* @return string description * @return string description
*/ */
function getDescription() { function getDescription() {
return _("Information about the LDAP server."); return _("Information about the LDAP server.");
} }
/** /**
* Returns a link to the tool page (relative to templates/). * Returns a link to the tool page (relative to templates/).
* *
* @return string link * @return string link
*/ */
function getLink() { function getLink() {
return "serverInfo.php"; return "serverInfo.php";
} }
/** /**
* Returns if the tool requires write access to LDAP. * Returns if the tool requires write access to LDAP.
* *
* @return boolean true if write access is needed * @return boolean true if write access is needed
*/ */
function getRequiresWriteAccess() { function getRequiresWriteAccess() {
return false; return false;
} }
/** /**
* Returns if the tool requires password change rights. * Returns if the tool requires password change rights.
* *
* @return boolean true if password change rights are needed * @return boolean true if password change rights are needed
*/ */
function getRequiresPasswordChangeRights() { function getRequiresPasswordChangeRights() {
return true; return true;
} }
/** /**
* Returns the link to the tool image (relative to graphics/) * Returns the link to the tool image (relative to graphics/)
* *
@ -88,7 +89,7 @@ class toolServerInformation implements LAMTool {
function getImageLink() { function getImageLink() {
return 'tree_info.png'; return 'tree_info.png';
} }
/** /**
* Returns the prefered position of this tool on the tools page. * Returns the prefered position of this tool on the tools page.
* The position may be between 0 and 1000. 0 is the top position. * The position may be between 0 and 1000. 0 is the top position.
@ -98,16 +99,16 @@ class toolServerInformation implements LAMTool {
function getPosition() { function getPosition() {
return 700; return 700;
} }
/** /**
* Returns a list of sub tools or an empty array. * Returns a list of sub tools or an empty array.
* *
* @return array list of subtools (LAMTool) * @return array list of subtools (LAMTool)
*/ */
function getSubTools() { function getSubTools() {
return array(); return array();
} }
/** /**
* Returns if the tool is visible in the menu. * Returns if the tool is visible in the menu.
* *
@ -116,16 +117,16 @@ class toolServerInformation implements LAMTool {
function isVisible() { function isVisible() {
return true; return true;
} }
/** /**
* Returns if a tool may be hidden by configuration in the LAM server profile. * Returns if a tool may be hidden by configuration in the LAM server profile.
* *
* @return boolean hideable * @return boolean hideable
*/ */
function isHideable() { function isHideable() {
return true; return true;
} }
} }
?> ?>

View File

@ -1,20 +1,21 @@
<?php <?php
namespace LAM\TOOLS\TESTS;
/* /*
$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) 2009 - 2011 Roland Gruber Copyright (C) 2009 - 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
the Free Software Foundation; either version 2 of the License, or the Free Software Foundation; either version 2 of the License, or
(at your option) any later version. (at your option) any later version.
This program is distributed in the hope that it will be useful, This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details. GNU General Public License for more details.
You should have received a copy of the GNU General Public License You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software along with this program; if not, write to the Free Software
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
@ -30,56 +31,56 @@ $Id$
/** /**
* Tests page * Tests page
* *
* @package tools * @package tools
*/ */
class toolTests implements LAMTool { class toolTests implements \LAMTool {
/** /**
* Returns the name of the tool. * Returns the name of the tool.
* *
* @return string name * @return string name
*/ */
function getName() { function getName() {
return _("Tests"); return _("Tests");
} }
/** /**
* returns a description text for the tool. * returns a description text for the tool.
* *
* @return string description * @return string description
*/ */
function getDescription() { function getDescription() {
return _("Here you can test if certain LAM features work on your installation."); return _("Here you can test if certain LAM features work on your installation.");
} }
/** /**
* Returns a link to the tool page (relative to templates/). * Returns a link to the tool page (relative to templates/).
* *
* @return string link * @return string link
*/ */
function getLink() { function getLink() {
return "tests/index.php"; return "tests/index.php";
} }
/** /**
* Returns if the tool requires write access to LDAP. * Returns if the tool requires write access to LDAP.
* *
* @return boolean true if write access is needed * @return boolean true if write access is needed
*/ */
function getRequiresWriteAccess() { function getRequiresWriteAccess() {
return true; return true;
} }
/** /**
* Returns if the tool requires password change rights. * Returns if the tool requires password change rights.
* *
* @return boolean true if password change rights are needed * @return boolean true if password change rights are needed
*/ */
function getRequiresPasswordChangeRights() { function getRequiresPasswordChangeRights() {
return true; return true;
} }
/** /**
* Returns the link to the tool image (relative to graphics/) * Returns the link to the tool image (relative to graphics/)
* *
@ -88,7 +89,7 @@ class toolTests implements LAMTool {
function getImageLink() { function getImageLink() {
return 'tests.png'; return 'tests.png';
} }
/** /**
* Returns the prefered position of this tool on the tools page. * Returns the prefered position of this tool on the tools page.
* The position may be between 0 and 1000. 0 is the top position. * The position may be between 0 and 1000. 0 is the top position.
@ -98,21 +99,21 @@ class toolTests implements LAMTool {
function getPosition() { function getPosition() {
return 1000; return 1000;
} }
/** /**
* Returns a list of sub tools or an empty array. * Returns a list of sub tools or an empty array.
* *
* @return array list of subtools (LAMTool) * @return array list of subtools (LAMTool)
*/ */
function getSubTools() { function getSubTools() {
$return = array(); $return = array();
$lamdaemonTest = new LAMSubTool(); $lamdaemonTest = new \LAMSubTool();
$lamdaemonTest->name = _("Lamdaemon test"); $lamdaemonTest->name = _("Lamdaemon test");
$lamdaemonTest->link = 'tests/lamdaemonTest.php'; $lamdaemonTest->link = 'tests/lamdaemonTest.php';
$lamdaemonTest->description = _("Check if quotas and homedirectories can be managed."); $lamdaemonTest->description = _("Check if quotas and homedirectories can be managed.");
$lamdaemonTest->image = 'lamdaemonSmall.png'; $lamdaemonTest->image = 'lamdaemonSmall.png';
$return[] = $lamdaemonTest; $return[] = $lamdaemonTest;
$schemaTest = new LAMSubTool(); $schemaTest = new \LAMSubTool();
$schemaTest->name = _("Schema test"); $schemaTest->name = _("Schema test");
$schemaTest->link = 'tests/schemaTest.php'; $schemaTest->link = 'tests/schemaTest.php';
$schemaTest->description = _("Check if the LDAP schema fits the requirements of the selected account modules."); $schemaTest->description = _("Check if the LDAP schema fits the requirements of the selected account modules.");
@ -120,7 +121,7 @@ class toolTests implements LAMTool {
$return[] = $schemaTest; $return[] = $schemaTest;
return $return; return $return;
} }
/** /**
* Returns if the tool is visible in the menu. * Returns if the tool is visible in the menu.
* *
@ -129,16 +130,16 @@ class toolTests implements LAMTool {
function isVisible() { function isVisible() {
return (sizeof($_SESSION['config']->get_ActiveTypes()) > 0); return (sizeof($_SESSION['config']->get_ActiveTypes()) > 0);
} }
/** /**
* Returns if a tool may be hidden by configuration in the LAM server profile. * Returns if a tool may be hidden by configuration in the LAM server profile.
* *
* @return boolean hideable * @return boolean hideable
*/ */
function isHideable() { function isHideable() {
return true; return true;
} }
} }
?> ?>

View File

@ -1,4 +1,22 @@
<?php <?php
namespace LAM\TOOLS\MULTI_EDIT;
use \htmlTable;
use \htmlTitle;
use \htmlSelect;
use \htmlOutputText;
use \htmlHelpLink;
use \htmlInputField;
use \htmlSubTitle;
use \htmlTableExtendedInputField;
use \htmlButton;
use \htmlStatusMessage;
use \htmlSpacer;
use \htmlHiddenInput;
use \htmlGroup;
use \htmlDiv;
use \htmlJavaScript;
use \htmlLink;
use \htmlInputTextarea;
/* /*
$Id$ $Id$
@ -85,11 +103,15 @@ function displayStartPage() {
$hideRules = array(); $hideRules = array();
$container->addElement(new htmlOutputText(_('LDAP suffix'))); $container->addElement(new htmlOutputText(_('LDAP suffix')));
$suffixGroup = new htmlTable(); $suffixGroup = new htmlTable();
$types = $_SESSION['config']->get_ActiveTypes(); $typeManager = new \LAM\TYPES\TypeManager();
$types = $typeManager->getConfiguredTypes();
$suffixes = array(); $suffixes = array();
foreach ($types as $type) { foreach ($types as $type) {
$suffixes[LAM\TYPES\getTypeAlias($type)] = $_SESSION['config']->get_Suffix($type); if ($type->isHidden()) {
$hideRules[$_SESSION['config']->get_Suffix($type)] = array('otherSuffix'); continue;
}
$suffixes[$type->getAlias()] = $type->getSuffix();
$hideRules[$type->getSuffix()] = array('otherSuffix');
} }
$treeSuffix = $_SESSION['config']->get_Suffix('tree'); $treeSuffix = $_SESSION['config']->get_Suffix('tree');
if (!empty($treeSuffix)) { if (!empty($treeSuffix)) {