Merge pull request #10 from LDAPAccountManager/type_api_tmp

new type API
This commit is contained in:
gruberroland 2016-12-24 15:46:35 +01:00 committed by GitHub
commit ad77a4054f
6 changed files with 69 additions and 66 deletions

View File

@ -1,4 +1,6 @@
<?php <?php
use LAM\TYPES\ConfiguredType;
/* /*
$Id$ $Id$
@ -688,17 +690,12 @@ class accountContainer {
/** /**
* Constructor * Constructor
* *
* @param string $type account type * @param ConfiguredType $type account type
* @param string $base key in $_SESSION where this object is saved * @param string $base key in $_SESSION where this object is saved
* @param integer $randomID random ID to avoid parallel editing (default: null) * @param integer $randomID random ID to avoid parallel editing (default: null)
*/ */
function __construct($type, $base, $randomID = null) { function __construct($type, $base, $randomID = null) {
/* Set the type of account. Valid if (!($type instanceof ConfiguredType)) trigger_error('Argument of accountContainer must be ConfiguredType.', E_USER_ERROR);
* types are: user, group, host
*/
// Check input variable
if (!is_string($type)) trigger_error('Argument of accountContainer must be string.', E_USER_ERROR);
if (!is_string($base)) trigger_error('Argument of accountContainer must be string.', E_USER_ERROR); if (!is_string($base)) trigger_error('Argument of accountContainer must be string.', E_USER_ERROR);
$this->type = $type; $this->type = $type;
$this->base = $base; $this->base = $base;
@ -800,7 +797,7 @@ class accountContainer {
/** /**
* Returns the accout type of this object (e.g. user, group, host). * Returns the accout type of this object (e.g. user, group, host).
* *
* @return string account type * @return ConfiguredType account type
*/ */
function get_type() { function get_type() {
return $this->type; return $this->type;
@ -812,7 +809,7 @@ class accountContainer {
*/ */
function continue_main() { function continue_main() {
if (!empty($_POST['account_randomID']) && ($this->randomID != $_POST['account_randomID'])) { if (!empty($_POST['account_randomID']) && ($this->randomID != $_POST['account_randomID'])) {
metaRefresh("../lists/list.php?type=" . $this->type . '&amp;accountEditInvalidID=true'); metaRefresh("../lists/list.php?type=" . $this->type->getId() . '&amp;accountEditInvalidID=true');
exit(); exit();
} }
$oldPage = $this->current_page; $oldPage = $this->current_page;
@ -821,7 +818,7 @@ class accountContainer {
$result = array(); $result = array();
$stopProcessing = false; // when set to true, no module options are displayed $stopProcessing = false; // when set to true, no module options are displayed
$errorsOccured = false; $errorsOccured = false;
$typeObject = new $this->type(); $typeObject = $this->type->getBaseType();
$profileLoaded = $this->loadProfileIfRequested(); $profileLoaded = $this->loadProfileIfRequested();
if ($this->subpage=='') $this->subpage='attributes'; if ($this->subpage=='') $this->subpage='attributes';
if (isset($_POST['accountContainerReset'])) { if (isset($_POST['accountContainerReset'])) {
@ -843,30 +840,30 @@ class accountContainer {
if (isset($_POST['accountContainerCreateAgain'])) { if (isset($_POST['accountContainerCreateAgain'])) {
// open fresh account page // open fresh account page
unset($_SESSION[$this->base]); unset($_SESSION[$this->base]);
metaRefresh("edit.php?type=" . $this->type . "&amp;suffix=" . $this->dnSuffix); metaRefresh("edit.php?type=" . $this->type->getId() . "&amp;suffix=" . $this->dnSuffix);
exit(); exit();
} }
// reedit account // reedit account
if (isset($_POST['accountContainerBackToEdit'])) { if (isset($_POST['accountContainerBackToEdit'])) {
// open fresh account page // open fresh account page
unset($_SESSION[$this->base]); unset($_SESSION[$this->base]);
metaRefresh("edit.php?type=" . $this->type . "&amp;DN=" . urlencode($this->finalDN)); metaRefresh("edit.php?type=" . $this->type->getId() . "&amp;DN=" . urlencode($this->finalDN));
exit(); exit();
} }
// back to account list // back to account list
if (isset($_POST['accountContainerBackToList'])) { if (isset($_POST['accountContainerBackToList'])) {
// Return to account list // Return to account list
unset($_SESSION[$this->base]); unset($_SESSION[$this->base]);
metaRefresh("../lists/list.php?type=" . $this->type . '&amp;accountEditBack=true'); metaRefresh("../lists/list.php?type=" . $this->type->getId() . '&amp;accountEditBack=true');
exit; exit;
} }
// create PDF file // create PDF file
if (isset($_POST['accountContainerCreatePDF'])) { if (isset($_POST['accountContainerCreatePDF'])) {
metaRefresh('../lists/list.php?printPDF=1&amp;type=' . $this->type . "&amp;refresh=true&amp;PDFSessionID=" . $this->base); metaRefresh('../lists/list.php?printPDF=1&amp;type=' . $this->type->getId() . "&amp;refresh=true&amp;PDFSessionID=" . $this->base);
exit; exit;
} }
// module actions // module actions
if ((sizeof($_POST) > 0) && checkIfWriteAccessIsAllowed($this->type)) { if ((sizeof($_POST) > 0) && checkIfWriteAccessIsAllowed($this->type->getId())) {
$result = call_user_func(array(&$this->module[$this->order[$this->current_page]], 'process_'.$this->subpage)); $result = call_user_func(array(&$this->module[$this->order[$this->current_page]], 'process_'.$this->subpage));
if (is_array($result)) { // messages were returned, check for errors if (is_array($result)) { // messages were returned, check for errors
for ($i = 0; $i < sizeof($result); $i++) { for ($i = 0; $i < sizeof($result); $i++) {
@ -987,13 +984,13 @@ class accountContainer {
} }
} }
echo '<div id="passwordMessageArea"></div>'; echo '<div id="passwordMessageArea"></div>';
echo "<table class=\"".$this->type."-bright\" border=0 width=\"100%\" style=\"border-collapse: collapse;\">\n"; echo "<table class=\"".$this->type->getScope()."-bright\" border=0 width=\"100%\" style=\"border-collapse: collapse;\">\n";
if (checkIfWriteAccessIsAllowed($this->type)) { if (checkIfWriteAccessIsAllowed($this->type->getId())) {
echo "<tr class=\"".$this->type."-bright\"><td style=\"padding: 15px 15px 0px 15px;\">\n"; echo "<tr class=\"" . $this->type->getScope() . "-bright\"><td style=\"padding: 15px 15px 0px 15px;\">\n";
$this->printCommonControls($tabindex); $this->printCommonControls($tabindex);
echo "</td></tr>\n"; echo "</td></tr>\n";
} }
echo "<tr class=\"".$this->type."-bright\" valign=\"top\"><td style=\"padding: 15px;\">"; echo "<tr class=\"" . $this->type->getScope() . "-bright\" valign=\"top\"><td style=\"padding: 15px;\">";
// print title bar // print title bar
echo '<div class="titleBar ui-corner-top">'; echo '<div class="titleBar ui-corner-top">';
echo '<table width="100%"><tr>'; echo '<table width="100%"><tr>';
@ -1021,10 +1018,10 @@ class accountContainer {
// RDN selection // RDN selection
$group->addElement(new htmlOutputText(_('RDN identifier'))); $group->addElement(new htmlOutputText(_('RDN identifier')));
$group->addElement(new htmlSpacer('2px', null)); $group->addElement(new htmlSpacer('2px', null));
$rdnlist = getRDNAttributes($this->type); $rdnlist = getRDNAttributes($this->type->getId());
$group->addElement(new htmlSelect('accountContainerRDN', $rdnlist, array($this->rdn))); $group->addElement(new htmlSelect('accountContainerRDN', $rdnlist, array($this->rdn)));
$group->addElement(new htmlHelpLink('301')); $group->addElement(new htmlHelpLink('301'));
parseHtml(null, $group, array(), true, $tabindex, $this->type); parseHtml(null, $group, array(), true, $tabindex, $this->type->getScope());
echo '</td>'; echo '</td>';
echo '</tr></table>'; echo '</tr></table>';
if ($this->titleBarSubtitle != null) { if ($this->titleBarSubtitle != null) {
@ -1044,7 +1041,7 @@ class accountContainer {
// display html-code from modules // display html-code from modules
$return = call_user_func(array($this->module[$this->order[$this->current_page]], 'display_html_'.$this->subpage)); $return = call_user_func(array($this->module[$this->order[$this->current_page]], 'display_html_'.$this->subpage));
$y = 5000; $y = 5000;
parseHtml($this->order[$this->current_page], $return, array(), false, $y, $this->type); parseHtml($this->order[$this->current_page], $return, array(), false, $y, $this->type->getScope());
echo "</div>\n"; echo "</div>\n";
echo '</td>'; echo '</td>';
echo '</tr>'; echo '</tr>';
@ -1114,9 +1111,9 @@ class accountContainer {
if (!(strpos($buttonImage, 'http') === 0) && !(strpos($buttonImage, '/') === 0)) { if (!(strpos($buttonImage, 'http') === 0) && !(strpos($buttonImage, '/') === 0)) {
$buttonImage = '../../graphics/' . $buttonImage; $buttonImage = '../../graphics/' . $buttonImage;
} }
$moduleContainer->addElement(new htmlImage($buttonImage, null, null, getModuleAlias($name, $this->type))); $moduleContainer->addElement(new htmlImage($buttonImage, null, null, getModuleAlias($name, $this->type->getScope())));
} }
$moduleContainer->addElement(new htmlTableExtendedInputCheckbox('password_cb_' . $name, true, getModuleAlias($name, $this->type), null, false)); $moduleContainer->addElement(new htmlTableExtendedInputCheckbox('password_cb_' . $name, true, getModuleAlias($name, $this->type->getScope()), null, false));
$moduleContainer->addElement(new htmlSpacer('10px', null)); $moduleContainer->addElement(new htmlSpacer('10px', null));
} }
} }
@ -1125,7 +1122,7 @@ class accountContainer {
// generate HTML // generate HTML
$tabindex = 2000; $tabindex = 2000;
if ($printContainer) { if ($printContainer) {
parseHtml(null, $container, array(), false, $tabindex, $this->type); parseHtml(null, $container, array(), false, $tabindex, $this->type->getScope());
} }
echo "</div>\n"; echo "</div>\n";
} }
@ -1260,7 +1257,7 @@ class accountContainer {
$rightGroup = new htmlGroup(); $rightGroup = new htmlGroup();
$rightGroup->alignment = htmlElement::ALIGN_RIGHT; $rightGroup->alignment = htmlElement::ALIGN_RIGHT;
// profile selection // profile selection
$profilelist = getAccountProfiles($this->type); $profilelist = getAccountProfiles($this->type->getId());
if (sizeof($profilelist) > 0) { if (sizeof($profilelist) > 0) {
$rightGroup->addElement(new htmlSelect('accountContainerSelectLoadProfile', $profilelist, array($this->lastLoadedProfile))); $rightGroup->addElement(new htmlSelect('accountContainerSelectLoadProfile', $profilelist, array($this->lastLoadedProfile)));
$profileButton = new htmlButton('accountContainerLoadProfile', _('Load profile')); $profileButton = new htmlButton('accountContainerLoadProfile', _('Load profile'));
@ -1275,7 +1272,7 @@ class accountContainer {
} }
$table->addElement($rightGroup); $table->addElement($rightGroup);
parseHtml(null, $table, array(), false, $tabindex, $this->type); parseHtml(null, $table, array(), false, $tabindex, $this->type->getScope());
?> ?>
<script type="text/javascript"> <script type="text/javascript">
jQuery(document).ready(function() { jQuery(document).ready(function() {
@ -1347,7 +1344,7 @@ class accountContainer {
else { else {
$text = _("Account was modified successfully."); $text = _("Account was modified successfully.");
} }
echo "<div class=\"".$this->type."-bright smallPaddingContent\">"; echo "<div class=\"" . $this->type->getScope() . "-bright smallPaddingContent\">";
$container = new htmlTable(); $container = new htmlTable();
// show messages // show messages
@ -1368,9 +1365,9 @@ class accountContainer {
$container->addElement($message, true); $container->addElement($message, true);
$container->addElement(new htmlSpacer(null, '20px'), true); $container->addElement(new htmlSpacer(null, '20px'), true);
$type = new $this->type(); $type = $this->type->getBaseType();
$buttonGroup = new htmlGroup(); $buttonGroup = new htmlGroup();
if (checkIfNewEntriesAreAllowed($this->type)) { if (checkIfNewEntriesAreAllowed($this->type->getId())) {
$createButton = new htmlButton('accountContainerCreateAgain', $type->LABEL_CREATE_ANOTHER_ACCOUNT); $createButton = new htmlButton('accountContainerCreateAgain', $type->LABEL_CREATE_ANOTHER_ACCOUNT);
$createButton->setIconClass('createButton'); $createButton->setIconClass('createButton');
$buttonGroup->addElement($createButton); $buttonGroup->addElement($createButton);
@ -1390,7 +1387,7 @@ class accountContainer {
$container->addElement($buttonGroup, true); $container->addElement($buttonGroup, true);
$tabindex = 1; $tabindex = 1;
parseHtml(null, $container, array(), false, $tabindex, $this->type); parseHtml(null, $container, array(), false, $tabindex, $this->type->getScope());
echo "</div>\n"; echo "</div>\n";
$this->printPageFooter(); $this->printPageFooter();
@ -1403,13 +1400,13 @@ class accountContainer {
*/ */
private function loadProfileIfRequested() { private function loadProfileIfRequested() {
if (isset($_POST['accountContainerLoadProfile']) && isset($_POST['accountContainerSelectLoadProfile'])) { if (isset($_POST['accountContainerLoadProfile']) && isset($_POST['accountContainerSelectLoadProfile'])) {
$profile = loadAccountProfile($_POST['accountContainerSelectLoadProfile'], $this->type); $profile = loadAccountProfile($_POST['accountContainerSelectLoadProfile'], $this->type->getId());
$this->lastLoadedProfile = $_POST['accountContainerSelectLoadProfile']; $this->lastLoadedProfile = $_POST['accountContainerSelectLoadProfile'];
// pass profile to each module // pass profile to each module
$modules = array_keys($this->module); $modules = array_keys($this->module);
foreach ($modules as $module) $this->module[$module]->load_profile($profile); foreach ($modules as $module) $this->module[$module]->load_profile($profile);
if (isset($profile['ldap_rdn'][0])) { if (isset($profile['ldap_rdn'][0])) {
if (in_array($profile['ldap_rdn'][0], getRDNAttributes($this->type))) { if (in_array($profile['ldap_rdn'][0], getRDNAttributes($this->type->getId()))) {
$this->rdn = $profile['ldap_rdn'][0]; $this->rdn = $profile['ldap_rdn'][0];
} }
} }
@ -1437,7 +1434,7 @@ class accountContainer {
$buttonImage = $this->module[$this->order[$i]]->getIcon(); $buttonImage = $this->module[$this->order[$i]]->getIcon();
$activatedClass = ''; $activatedClass = '';
if ($this->order[$this->current_page] == $this->order[$i]) { if ($this->order[$this->current_page] == $this->order[$i]) {
$activatedClass = ' ui-tabs-selected ui-state-active ' . $this->type . '-bright'; $activatedClass = ' ui-tabs-selected ui-state-active ' . $this->type->getScope() . '-bright';
} }
// print button // print button
echo '<li class="ui-state-default ui-corner-left' . $activatedClass . '">'; echo '<li class="ui-state-default ui-corner-left' . $activatedClass . '">';
@ -1551,11 +1548,11 @@ class accountContainer {
function load_account($dn, $infoAttributes = array()) { function load_account($dn, $infoAttributes = array()) {
logNewMessage(LOG_DEBUG, "Edit account " . $dn); logNewMessage(LOG_DEBUG, "Edit account " . $dn);
$this->module = array(); $this->module = array();
$modules = $_SESSION['config']->get_AccountModules($this->type); $modules = $_SESSION['config']->get_AccountModules($this->type->getId());
$search = substr($dn, 0, strpos($dn, ',')); $search = substr($dn, 0, strpos($dn, ','));
$searchAttrs = array('*', '+'); $searchAttrs = array('*', '+');
foreach ($modules as $module) { foreach ($modules as $module) {
$modTmp = new $module($this->type); $modTmp = new $module($this->type->getScope());
$searchAttrs = array_merge($searchAttrs, $modTmp->getManagedHiddenAttributes()); $searchAttrs = array_merge($searchAttrs, $modTmp->getManagedHiddenAttributes());
} }
$result = @ldap_read($_SESSION['ldap']->server(), escapeDN($dn), escapeDN($search), $searchAttrs, 0, 0, 0, LDAP_DEREF_NEVER); $result = @ldap_read($_SESSION['ldap']->server(), escapeDN($dn), escapeDN($search), $searchAttrs, 0, 0, 0, LDAP_DEREF_NEVER);
@ -1592,7 +1589,7 @@ class accountContainer {
foreach ($modules as $module) { foreach ($modules as $module) {
if (!isset($this->module[$module])) { if (!isset($this->module[$module])) {
$this->module[$module] = new $module($this->type); $this->module[$module] = new $module($this->type->getScope());
$this->module[$module]->init($this->base); $this->module[$module]->init($this->base);
} }
$this->module[$module]->load_attributes($attr); $this->module[$module]->load_attributes($attr);
@ -1601,7 +1598,7 @@ class accountContainer {
// sort module buttons // sort module buttons
$this->sortModules(); $this->sortModules();
// get titles // get titles
$typeObject = new $this->type(); $typeObject = $this->type->getBaseType();
$this->titleBarTitle = $typeObject->getTitleBarTitle($this); $this->titleBarTitle = $typeObject->getTitleBarTitle($this);
$this->titleBarSubtitle = $typeObject->getTitleBarSubtitle($this); $this->titleBarSubtitle = $typeObject->getTitleBarSubtitle($this);
return array(); return array();
@ -1622,7 +1619,7 @@ class accountContainer {
$aliases = array(); $aliases = array();
$ldapAttributesTemp = array(); $ldapAttributesTemp = array();
foreach ($modules as $module) { foreach ($modules as $module) {
$moduleObj = moduleCache::getModule($module, $this->type); $moduleObj = moduleCache::getModule($module, $this->type->getScope());
$objectClasses = array_merge($objectClasses, $moduleObj->getManagedObjectClasses()); $objectClasses = array_merge($objectClasses, $moduleObj->getManagedObjectClasses());
$aliases = array_merge($aliases, $moduleObj->getLDAPAliases()); $aliases = array_merge($aliases, $moduleObj->getLDAPAliases());
$ldapAttributesTemp = array_merge($ldapAttributesTemp, $moduleObj->getManagedAttributes()); $ldapAttributesTemp = array_merge($ldapAttributesTemp, $moduleObj->getManagedAttributes());
@ -1688,22 +1685,22 @@ class accountContainer {
* This function will prepare the object for a new account. * This function will prepare the object for a new account.
*/ */
function new_account() { function new_account() {
logNewMessage(LOG_DEBUG, "New account with type " . $this->type); logNewMessage(LOG_DEBUG, "New account with type " . $this->type->getId());
$this->isNewAccount = true; $this->isNewAccount = true;
$this->lastLoadedProfile = 'default'; $this->lastLoadedProfile = 'default';
$modules = $_SESSION['config']->get_AccountModules($this->type); $modules = $_SESSION['config']->get_AccountModules($this->type->getId());
foreach ($modules as $module) { foreach ($modules as $module) {
$this->module[$module] = new $module($this->type); $this->module[$module] = new $module($this->type->getScope());
$this->module[$module]->init($this->base); $this->module[$module]->init($this->base);
} }
// sort module buttons // sort module buttons
$this->sortModules(); $this->sortModules();
$profile = loadAccountProfile('default', $this->type); $profile = loadAccountProfile('default', $this->type->getId());
// pass profile to each module // pass profile to each module
$modules = array_keys($this->module); $modules = array_keys($this->module);
foreach ($modules as $module) $this->module[$module]->load_profile($profile); foreach ($modules as $module) $this->module[$module]->load_profile($profile);
if (isset($profile['ldap_rdn'][0])) { if (isset($profile['ldap_rdn'][0])) {
if (in_array($profile['ldap_rdn'][0], getRDNAttributes($this->type))) { if (in_array($profile['ldap_rdn'][0], getRDNAttributes($this->type->getId()))) {
$this->rdn = $profile['ldap_rdn'][0]; $this->rdn = $profile['ldap_rdn'][0];
} }
} }
@ -1711,7 +1708,7 @@ class accountContainer {
$this->dnSuffix = $profile['ldap_suffix'][0]; $this->dnSuffix = $profile['ldap_suffix'][0];
} }
// get titles // get titles
$typeObject = new $this->type(); $typeObject = $this->type->getBaseType();
$this->titleBarTitle = $typeObject->getTitleBarTitle($this); $this->titleBarTitle = $typeObject->getTitleBarTitle($this);
$this->titleBarSubtitle = $typeObject->getTitleBarSubtitle($this); $this->titleBarSubtitle = $typeObject->getTitleBarSubtitle($this);
return 0; return 0;
@ -1723,7 +1720,7 @@ class accountContainer {
* @return array list of status messages * @return array list of status messages
*/ */
function save_account() { function save_account() {
if (!checkIfWriteAccessIsAllowed($this->type)) { if (!checkIfWriteAccessIsAllowed($this->type->getId())) {
die(); die();
} }
$this->finalDN = $this->dn_orig; $this->finalDN = $this->dn_orig;
@ -2027,7 +2024,7 @@ class accountContainer {
for ($i = 0; $i < sizeof($modules); $i++) { for ($i = 0; $i < sizeof($modules); $i++) {
// insert waiting modules // insert waiting modules
for ($w = 0; $w < sizeof($depModules); $w++) { for ($w = 0; $w < sizeof($depModules); $w++) {
$dependencies = $this->module[$depModules[$w]]->get_dependencies($this->type); $dependencies = $this->module[$depModules[$w]]->get_dependencies($this->type->getScope());
$dependencies = $dependencies['depends']; $dependencies = $dependencies['depends'];
$everything_found = true; $everything_found = true;
for ($d = 0; $d < sizeof($dependencies); $d++) { for ($d = 0; $d < sizeof($dependencies); $d++) {
@ -2045,7 +2042,7 @@ class accountContainer {
} }
} }
// check next module // check next module
$dependencies = $this->module[$modules[$i]]->get_dependencies($this->type); $dependencies = $this->module[$modules[$i]]->get_dependencies($this->type->getScope());
if (is_array($dependencies['depends'])) { if (is_array($dependencies['depends'])) {
$everything_found = true; $everything_found = true;
$dependencies = $dependencies['depends']; $dependencies = $dependencies['depends'];
@ -2138,7 +2135,7 @@ class accountContainer {
if ($this->cachedOUs != null) { if ($this->cachedOUs != null) {
return $this->cachedOUs; return $this->cachedOUs;
} }
$typeObj = new $this->type(); $typeObj = $this->type->getBaseType();
$this->cachedOUs = $typeObj->getSuffixList(); $this->cachedOUs = $typeObj->getSuffixList();
return $this->cachedOUs; return $this->cachedOUs;
} }

View File

@ -67,7 +67,7 @@ function createModulePDF($accounts, $pdf_structure="default", $returnAsString =
$account_type = $accounts[0]->get_type(); $account_type = $accounts[0]->get_type();
// Get PDF structure from xml file // Get PDF structure from xml file
$load = loadPDFStructureDefinitions($account_type,$pdf_structure); $load = loadPDFStructureDefinitions($account_type->getId(), $pdf_structure);
$structure = $load['structure']; $structure = $load['structure'];
// get list of PDF keys // get list of PDF keys
$pdfKeys = array(); $pdfKeys = array();

View File

@ -330,6 +330,12 @@ class ListAttribute {
*/ */
class TypeManager { class TypeManager {
/**
* Returns the configured type with the given id or null.
*
* @param string $typeId type id
* @return \LAM\TYPES\ConfiguredType|NULL type
*/
public function getConfiguredType($typeId) { public function getConfiguredType($typeId) {
$configuredTypes = array(); $configuredTypes = array();
$activeTypes = $_SESSION['config']->get_ActiveTypes(); $activeTypes = $_SESSION['config']->get_ActiveTypes();

View File

@ -283,7 +283,8 @@ class Uploader {
} }
} }
// load account // load account
$_SESSION['mass_pdfAccount'] = new accountContainer($this->scope, 'mass_pdfAccount'); $typeManager = new \LAM\TYPES\TypeManager();
$_SESSION['mass_pdfAccount'] = new accountContainer($typeManager->getConfiguredType($this->scope), 'mass_pdfAccount');
$pdfErrors = $_SESSION['mass_pdfAccount']->load_account($dn, $infoAttributes); $pdfErrors = $_SESSION['mass_pdfAccount']->load_account($dn, $infoAttributes);
if (sizeof($pdfErrors) > 0) { if (sizeof($pdfErrors) > 0) {
$_SESSION['mass_errors'] = array_merge($_SESSION['mass_errors'], $pdfErrors); $_SESSION['mass_errors'] = array_merge($_SESSION['mass_errors'], $pdfErrors);

View File

@ -4,7 +4,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 Tilo Lutz Copyright (C) 2003 - 2006 Tilo Lutz
2005 - 2015 Roland Gruber 2005 - 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
@ -57,14 +57,13 @@ if (!isLoggedIn()) {
// Set correct language, codepages, .... // Set correct language, codepages, ....
setlanguage(); setlanguage();
$typeManager = new LAM\TYPES\TypeManager();
//load account //load account
if (isset($_GET['DN'])) { if (isset($_GET['DN'])) {
$type = $typeManager->getConfiguredType($_GET['type']);
$DN = str_replace("\\'", '', $_GET['DN']); $DN = str_replace("\\'", '', $_GET['DN']);
$type = str_replace("\\'", '', $_GET['type']); if ($type->isHidden()) {
if ($_GET['type'] == $type) $type = str_replace("'", '',$_GET['type']); logNewMessage(LOG_ERR, 'User tried to access hidden account type: ' . $type->getId());
if (isAccountTypeHidden($type)) {
logNewMessage(LOG_ERR, 'User tried to access hidden account type: ' . $type);
die(); die();
} }
if ($_GET['DN'] == $DN) { if ($_GET['DN'] == $DN) {
@ -75,10 +74,10 @@ if (isset($_GET['DN'])) {
$DN = substr($DN, 0, -1); $DN = substr($DN, 0, -1);
} }
} }
$suffix = strtolower($_SESSION['config']->get_Suffix($type)); $suffix = strtolower($type->getSuffix());
$DNlower = strtolower($DN); $DNlower = strtolower($DN);
if (strpos($DNlower, $suffix) !== (strlen($DNlower) - strlen($suffix))) { if (strpos($DNlower, $suffix) !== (strlen($DNlower) - strlen($suffix))) {
logNewMessage(LOG_ERR, 'User tried to access entry of type ' . $type . ' outside suffix ' . $suffix); logNewMessage(LOG_ERR, 'User tried to access entry of type ' . $type->getId() . ' outside suffix ' . $suffix);
die(); die();
} }
$_SESSION['account'] = new accountContainer($type, 'account', getRandomNumber()); $_SESSION['account'] = new accountContainer($type, 'account', getRandomNumber());
@ -94,14 +93,13 @@ if (isset($_GET['DN'])) {
} }
// new account // new account
else if (count($_POST)==0) { else if (count($_POST)==0) {
$type = str_replace("\\'", '', $_GET['type']); $type = $typeManager->getConfiguredType($_GET['type']);
if ($_GET['type'] == $type) $type = str_replace("'", '',$_GET['type']); if ($type->isHidden()) {
if (isAccountTypeHidden($type)) { logNewMessage(LOG_ERR, 'User tried to access hidden account type: ' . $type->getId());
logNewMessage(LOG_ERR, 'User tried to access hidden account type: ' . $type);
die(); die();
} }
elseif (!checkIfNewEntriesAreAllowed($type)) { elseif (!checkIfNewEntriesAreAllowed($type->getId())) {
logNewMessage(LOG_ERR, 'User tried to create entry of forbidden account type: ' . $type); logNewMessage(LOG_ERR, 'User tried to create entry of forbidden account type: ' . $type->getId());
die(); die();
} }
$_SESSION['account'] = new accountContainer($type, 'account', getRandomNumber()); $_SESSION['account'] = new accountContainer($type, 'account', getRandomNumber());

View File

@ -88,7 +88,8 @@ if (isset($_GET['type']) && isset($_SESSION['delete_dn'])) {
} }
//load account //load account
$_SESSION['account'] = new accountContainer($_GET['type'], 'account'); $typeManager = new LAM\TYPES\TypeManager();
$_SESSION['account'] = new accountContainer($typeManager->getConfiguredType($_GET['type']), 'account');
// Show HTML Page // Show HTML Page
include 'main_header.php'; include 'main_header.php';
echo "<div class=\"".$_GET['type']."-bright smallPaddingContent\">"; echo "<div class=\"".$_GET['type']."-bright smallPaddingContent\">";