new type API
This commit is contained in:
parent
84f2b43923
commit
d6b9a28b58
|
@ -672,13 +672,14 @@ function searchLDAPByAttribute($name, $value, $objectClass, $attributes, $scopes
|
||||||
elseif (sizeof($filterParts) > 1) {
|
elseif (sizeof($filterParts) > 1) {
|
||||||
$filter = '(& ' . implode(' ', $filterParts) . ')';
|
$filter = '(& ' . implode(' ', $filterParts) . ')';
|
||||||
}
|
}
|
||||||
$activeTypes = $_SESSION['config']->get_ActiveTypes();
|
$typeManager = new \LAM\TYPES\TypeManager();
|
||||||
for ($s = 0; $s < sizeof($scopes); $s++) {
|
$activeTypes = $typeManager->getConfiguredTypes();
|
||||||
if (!in_array($scopes[$s], $activeTypes)) {
|
foreach ($activeTypes as $type) {
|
||||||
|
if (!in_array($type->getScope(), $scopes)) {
|
||||||
continue; // skip non-active account types
|
continue; // skip non-active account types
|
||||||
}
|
}
|
||||||
// search LDAP
|
// search LDAP
|
||||||
$entries = searchLDAPPaged($_SESSION['ldap']->server(), escapeDN($_SESSION['config']->get_Suffix($scopes[$s])),
|
$entries = searchLDAPPaged($_SESSION['ldap']->server(), escapeDN($type->getSuffix()),
|
||||||
$filter, $attributes, 0, $_SESSION['config']->get_searchLimit());
|
$filter, $attributes, 0, $_SESSION['config']->get_searchLimit());
|
||||||
if (ldap_errno($_SESSION['ldap']->server()) == 4) {
|
if (ldap_errno($_SESSION['ldap']->server()) == 4) {
|
||||||
logNewMessage(LOG_WARNING, 'LDAP size limit exeeded. Please increase the limit on your server.');
|
logNewMessage(LOG_WARNING, 'LDAP size limit exeeded. Please increase the limit on your server.');
|
||||||
|
|
|
@ -8,7 +8,7 @@ $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 - 2006 Michael Duergner
|
Copyright (C) 2003 - 2006 Michael Duergner
|
||||||
2011 - 2016 Roland Gruber
|
2011 - 2017 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
|
||||||
|
@ -40,19 +40,20 @@ include_once("ldap.inc");
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* This function will return all available PDF structure definitions for the submitted
|
* This function will return all available PDF structure definitions for the submitted
|
||||||
* account scope.
|
* account type.
|
||||||
*
|
*
|
||||||
* @param string $scope The account scope the PDF structure definitions should be
|
* @param string $typeId the account type
|
||||||
* returned.
|
|
||||||
* @param string $profile server profile name
|
* @param string $profile server profile name
|
||||||
*
|
*
|
||||||
* @return array $scope All available PDF structure definitions for the submitted account
|
* @return array All available PDF structure definitions for the submitted account
|
||||||
* scope. Each entry is a string being the filename that may be passed to the
|
* scope. Each entry is a string being the filename that may be passed to the
|
||||||
* createModulePDF() function as second argument.
|
* createModulePDF() function as second argument.
|
||||||
*/
|
*/
|
||||||
function getPDFStructures($scope = "user", $profile = null) {
|
function getPDFStructures($typeId, $profile = null) {
|
||||||
$return = array();
|
$return = array();
|
||||||
|
if (!preg_match('/[a-zA-Z]+/', $typeId)) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
if (!isset($profile)) {
|
if (!isset($profile)) {
|
||||||
$profile = $_SESSION['config']->getName();
|
$profile = $_SESSION['config']->getName();
|
||||||
}
|
}
|
||||||
|
@ -61,7 +62,7 @@ function getPDFStructures($scope = "user", $profile = null) {
|
||||||
$dirHandle = opendir($path);
|
$dirHandle = opendir($path);
|
||||||
while($file = readdir($dirHandle)) {
|
while($file = readdir($dirHandle)) {
|
||||||
$struct_file = explode('.',$file);
|
$struct_file = explode('.',$file);
|
||||||
if(!is_dir($path.$file) && ($file != '.') && ($file != '..') && (sizeof($struct_file) == 3) && ($struct_file[1] == $scope) && ($struct_file[2] == 'xml')) {
|
if(!is_dir($path.$file) && ($file != '.') && ($file != '..') && (sizeof($struct_file) == 3) && ($struct_file[1] == $typeId) && ($struct_file[2] == 'xml')) {
|
||||||
array_push($return, $struct_file[0]);
|
array_push($return, $struct_file[0]);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -292,14 +293,15 @@ function deletePDFLogo($name) {
|
||||||
return new htmlStatusMessage('ERROR', _('File does not exist.'), htmlspecialchars($name));
|
return new htmlStatusMessage('ERROR', _('File does not exist.'), htmlspecialchars($name));
|
||||||
}
|
}
|
||||||
// check if still in use
|
// check if still in use
|
||||||
$activeTypes = $_SESSION['config']->get_ActiveTypes();
|
$typeManager = new \LAM\TYPES\TypeManager();
|
||||||
|
$activeTypes = $typeManager->getConfiguredTypes();
|
||||||
foreach ($activeTypes as $type) {
|
foreach ($activeTypes as $type) {
|
||||||
$structures = getPDFStructures($type);
|
$structures = getPDFStructures($type->getId());
|
||||||
foreach ($structures as $structure) {
|
foreach ($structures as $structure) {
|
||||||
$data = loadPDFStructure($type, $structure);
|
$data = loadPDFStructure($type->getId(), $structure);
|
||||||
if ($data['page_definitions']['filename'] == $name) {
|
if ($data['page_definitions']['filename'] == $name) {
|
||||||
return new htmlStatusMessage('ERROR', _('Unable to delete logo file.'),
|
return new htmlStatusMessage('ERROR', _('Unable to delete logo file.'),
|
||||||
sprintf(_('Logo is still in use by PDF structure "%s" in account type "%s".'), $structure, \LAM\TYPES\getTypeAlias($type)));
|
sprintf(_('Logo is still in use by PDF structure "%s" in account type "%s".'), $structure, $type->getAlias()));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue