new type API

This commit is contained in:
Roland Gruber 2016-12-26 18:41:22 +01:00
parent fad7a009f0
commit 0bf8702763
4 changed files with 94 additions and 81 deletions

View File

@ -1,20 +1,21 @@
<?php <?php
namespace LAM\TOOLS\OU_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) 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$
/** /**
* OU editor * OU editor
* *
* @package tools * @package tools
*/ */
class toolOUEditor implements LAMTool { class toolOUEditor 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 _("OU editor"); return _("OU editor");
} }
/** /**
* 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 _("Manages OU objects in your LDAP tree."); return _("Manages OU objects in your LDAP tree.");
} }
/** /**
* 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 "ou_edit.php"; return "ou_edit.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 toolOUEditor implements LAMTool {
function getImageLink() { function getImageLink() {
return 'ou.png'; return 'ou.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 toolOUEditor implements LAMTool {
function getPosition() { function getPosition() {
return 500; return 500;
} }
/** /**
* 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 toolOUEditor 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,20 +1,21 @@
<?php <?php
namespace LAM\TOOLS\PDF_EDITOR;
/* /*
$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$
/** /**
* PDF editor * PDF editor
* *
* @package tools * @package tools
*/ */
class toolPDFEditor implements LAMTool { class toolPDFEditor 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 _("PDF editor"); return _("PDF editor");
} }
/** /**
* 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 _("This tool allows you to customize the PDF pages."); return _("This tool allows you to customize the PDF pages.");
} }
/** /**
* 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 "pdfedit/pdfmain.php"; return "pdfedit/pdfmain.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 toolPDFEditor implements LAMTool {
function getImageLink() { function getImageLink() {
return 'pdf.png'; return 'pdf.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 toolPDFEditor implements LAMTool {
function getPosition() { function getPosition() {
return 200; return 200;
} }
/** /**
* 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 toolPDFEditor 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,20 +1,21 @@
<?php <?php
namespace LAM\TOOLS\PROFILE_EDITOR;
/* /*
$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$
/** /**
* Profile editor * Profile editor
* *
* @package tools * @package tools
*/ */
class toolProfileEditor implements LAMTool { class toolProfileEditor 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 _("Profile editor"); return _("Profile editor");
} }
/** /**
* 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 manage your account profiles."); return _("Here you can manage your account profiles.");
} }
/** /**
* 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 "profedit/profilemain.php"; return "profedit/profilemain.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 toolProfileEditor 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 toolProfileEditor implements LAMTool {
function getPosition() { function getPosition() {
return 100; return 100;
} }
/** /**
* 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 toolProfileEditor 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,15 @@
<?php <?php
namespace LAM\TOOLS\OU_EDIT;
use \htmlTable;
use \htmlSpacer;
use \htmlOutputText;
use \htmlButton;
use \htmlHiddenInput;
use \htmlSubTitle;
use \htmlStatusMessage;
use \htmlSelect;
use \htmlHelpLink;
use \htmlInputField;
/* /*
$Id$ $Id$
@ -51,8 +62,6 @@ if (!empty($_POST)) {
validateSecurityToken(); validateSecurityToken();
} }
$types = $_SESSION['config']->get_ActiveTypes();
// check if deletion was canceled // check if deletion was canceled
if (isset($_POST['abort'])) { if (isset($_POST['abort'])) {
display_main(null, null); display_main(null, null);
@ -166,13 +175,14 @@ function display_main($message, $error) {
$container->addElement($msg, true); $container->addElement($msg, true);
} }
$typeManager = new \LAM\TYPES\TypeManager();
$typeList = $typeManager->getConfiguredTypes();
$types = array(); $types = array();
$typeList = $_SESSION['config']->get_ActiveTypes(); foreach ($typeList as $type) {
for ($i = 0; $i < sizeof($typeList); $i++) { if ($type->isHidden() || !checkIfWriteAccessIsAllowed($type->getId())) {
if (isAccountTypeHidden($typeList[$i]) || !checkIfWriteAccessIsAllowed($typeList[$i])) {
continue; continue;
} }
$types[$typeList[$i]] = LAM\TYPES\getTypeAlias($typeList[$i]); $types[$type->getId()] = $type->getAlias();
} }
natcasesort($types); natcasesort($types);
$options = array(); $options = array();