refactoring

This commit is contained in:
Roland Gruber 2019-01-02 21:10:32 +01:00
parent 5682245739
commit 18547baad2
11 changed files with 164 additions and 159 deletions

View File

@ -217,8 +217,6 @@ class PrivacyIDEAProvider implements TwoFactorProvider {
if (($status == 'true') && ($value == 'true')) { if (($status == 'true') && ($value == 'true')) {
return true; return true;
} }
$errCode = isset($output->result->error) && isset($output->result->error->code) ? $output->result->error->code : '';
$errMessage = isset($output->result->error) && isset($output->result->error->message) ? $output->result->error->message : '';
logNewMessage(LOG_DEBUG, "Unable to verify token: " . print_r($output, true)); logNewMessage(LOG_DEBUG, "Unable to verify token: " . print_r($output, true));
return false; return false;
} }

View File

@ -3,7 +3,7 @@
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
2009 - 2018 Roland Gruber 2009 - 2019 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
@ -341,7 +341,6 @@ function generateRandomPassword() {
if ($length < 12) { if ($length < 12) {
$length = 12; $length = 12;
} }
$isOk = false;
for ($x = 0; $x < 10000; $x++) { for ($x = 0; $x < 10000; $x++) {
$password = ''; $password = '';
for ($i = 0; $i < $length; $i++) { for ($i = 0; $i < $length; $i++) {

View File

@ -5,7 +5,7 @@ use \LAMException;
/* /*
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) 2018 Roland Gruber Copyright (C) 2018 - 2019 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
@ -109,8 +109,7 @@ class Importer {
*/ */
public function getTasks($lines) { public function getTasks($lines) {
$chunks = $this->extractImportChunks($lines); $chunks = $this->extractImportChunks($lines);
$tasks = $this->convertToTasks($chunks); return $this->convertToTasks($chunks);
return $tasks;
} }
/** /**
@ -297,7 +296,6 @@ class Importer {
elseif ($type !== 'modify') { elseif ($type !== 'modify') {
throw new LAMException(_('Invalid data'), htmlspecialchars($dn) . ' - changeType: ' . htmlspecialchars($type)); throw new LAMException(_('Invalid data'), htmlspecialchars($dn) . ' - changeType: ' . htmlspecialchars($type));
} }
$changes = array();
$subtasks = array(); $subtasks = array();
$currentLines = array(); $currentLines = array();
$linesCount = sizeof($entry); $linesCount = sizeof($entry);
@ -337,7 +335,7 @@ class Importer {
if (($delOldRdnData[Importer::KEY] !== 'deleteoldrdn') || !in_array($delOldRdnData[Importer::VALUE], array('0', '1'), true)) { if (($delOldRdnData[Importer::KEY] !== 'deleteoldrdn') || !in_array($delOldRdnData[Importer::VALUE], array('0', '1'), true)) {
throw new LAMException(_('Invalid data'), htmlspecialchars($dn) . '<br>' . $entry[1]); throw new LAMException(_('Invalid data'), htmlspecialchars($dn) . '<br>' . $entry[1]);
} }
$delOldRdn = ($delOldRdnData[Importer::VALUE] === '0') ? false : true; $delOldRdn = ($delOldRdnData[Importer::VALUE] !== '0');
return new RenameEntryTask($dn, $newRdn, $delOldRdn); return new RenameEntryTask($dn, $newRdn, $delOldRdn);
} }

View File

@ -4,7 +4,7 @@ use \LAM\TYPES\TypeManager;
/* /*
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 - 2018 Roland Gruber Copyright (C) 2003 - 2019 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
@ -139,8 +139,7 @@ function get_ldap_filter($typeId) {
$finalFilter = "(&" . implode("", $filters['and']) . ")"; $finalFilter = "(&" . implode("", $filters['and']) . ")";
} }
$loginData = $_SESSION['ldap']->decrypt_login(); $loginData = $_SESSION['ldap']->decrypt_login();
$finalFilter = str_replace('@@LOGIN_DN@@', $loginData[0], $finalFilter); return str_replace('@@LOGIN_DN@@', $loginData[0], $finalFilter);
return $finalFilter;
} }
/** /**
@ -190,7 +189,9 @@ function getRDNAttributes($typeId, $selectedModules=null) {
if (!in_array($attrs_normal[$i], $return)) $return[] = $attrs_normal[$i]; if (!in_array($attrs_normal[$i], $return)) $return[] = $attrs_normal[$i];
} }
for ($i = 0; $i < sizeof($attrs_low); $i++) { for ($i = 0; $i < sizeof($attrs_low); $i++) {
if (!in_array($attrs_low[$i], $return)) $return[] = $attrs_low[$i]; if (!in_array($attrs_low[$i], $return)) {
$return[] = $attrs_low[$i];
}
} }
return $return; return $return;
} }
@ -252,8 +253,10 @@ function check_module_depends($selected, $deps) {
} }
} }
} }
if (sizeof($ret) > 0) return $ret; if (sizeof($ret) > 0) {
else return false; return $ret;
}
return false;
} }
/** /**
@ -273,8 +276,10 @@ function check_module_conflicts($selected, $deps) {
} }
} }
} }
if (sizeof($ret) > 0) return $ret; if (sizeof($ret) > 0) {
else return false; return $ret;
}
return false;
} }
/** /**
@ -289,7 +294,7 @@ function getAvailableModules($scope, $mustSupportAdminInterface = false) {
$dir = dir($dirname); $dir = dir($dirname);
$return = array(); $return = array();
// get module names. // get module names.
while ($entry = $dir->read()) while ($entry = $dir->read()) {
if ((substr($entry, strlen($entry) - 4, 4) == '.inc') && is_file($dirname . '/'.$entry)) { if ((substr($entry, strlen($entry) - 4, 4) == '.inc') && is_file($dirname . '/'.$entry)) {
$entry = substr($entry, 0, strpos($entry, '.')); $entry = substr($entry, 0, strpos($entry, '.'));
$temp = moduleCache::getModule($entry, $scope); $temp = moduleCache::getModule($entry, $scope);
@ -300,6 +305,7 @@ function getAvailableModules($scope, $mustSupportAdminInterface = false) {
$return[] = $entry; $return[] = $entry;
} }
} }
}
return $return; return $return;
} }
@ -389,7 +395,9 @@ function getHelp($module,$helpID,$scope='') {
global $helpArray; global $helpArray;
if (!isset($module) || ($module == '') || ($module == 'main')) { if (!isset($module) || ($module == '') || ($module == 'main')) {
$helpPath = "../help/help.inc"; $helpPath = "../help/help.inc";
if (is_file("../../help/help.inc")) $helpPath = "../../help/help.inc"; if (is_file("../../help/help.inc")) {
$helpPath = "../../help/help.inc";
}
if (!isset($helpArray)) { if (!isset($helpArray)) {
include_once($helpPath); include_once($helpPath);
} }
@ -512,7 +520,9 @@ function buildUploadAccounts($type, $data, $ids, $selectedModules, htmlResponsiv
break; break;
} }
} }
if ($newRound) continue; if ($newRound) {
continue;
}
// this point should never be reached, LAM was unable to find a correct module order // this point should never be reached, LAM was unable to find a correct module order
$container->add(new htmlStatusMessage("ERROR", "Internal Error: Unable to find correct module order."), 12); $container->add(new htmlStatusMessage("ERROR", "Internal Error: Unable to find correct module order."), 12);
return false; return false;
@ -701,7 +711,9 @@ function lamCompareDescriptiveOptions(&$a, &$b) {
*/ */
function printHelpLink($entry, $number, $module = '', $scope = '', $classes = array()) { function printHelpLink($entry, $number, $module = '', $scope = '', $classes = array()) {
$helpPath = "../"; $helpPath = "../";
if (is_file("./help.php")) $helpPath = ""; if (is_file("./help.php")) {
$helpPath = "";
}
$title = $entry['Headline']; $title = $entry['Headline'];
$message = $entry['Text']; $message = $entry['Text'];
if (isset($entry['attr'])) { if (isset($entry['attr'])) {
@ -736,8 +748,12 @@ class accountContainer {
* @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) {
if (!($type instanceof ConfiguredType)) trigger_error('Argument of accountContainer must be ConfiguredType.', E_USER_ERROR); if (!($type instanceof ConfiguredType)) {
if (!is_string($base)) trigger_error('Argument of accountContainer must be string.', E_USER_ERROR); trigger_error('Argument of accountContainer must be ConfiguredType.', 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;
// Set startpage // Set startpage
@ -855,13 +871,14 @@ class accountContainer {
} }
$oldPage = $this->current_page; $oldPage = $this->current_page;
$oldSubpage = $this->subpage; $oldSubpage = $this->subpage;
$post = $_POST;
$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 = $this->type->getBaseType(); $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'])) {
$result = $this->load_account($this->dn_orig); $result = $this->load_account($this->dn_orig);
} }
@ -1225,7 +1242,7 @@ class accountContainer {
$return['forcePasswordChange'] = $forcePasswordChange; $return['forcePasswordChange'] = $forcePasswordChange;
if ($return['errorsOccured'] == 'false') { if ($return['errorsOccured'] == 'false') {
// set new password // set new password
foreach ($this->module as $name => $module) { foreach ($this->module as $module) {
if ($module instanceof passwordService) { if ($module instanceof passwordService) {
$messages = $module->passwordChangeRequested($password1, $modules, $forcePasswordChange); $messages = $module->passwordChangeRequested($password1, $modules, $forcePasswordChange);
for ($m = 0; $m < sizeof($messages); $m++) { for ($m = 0; $m < sizeof($messages); $m++) {
@ -1334,7 +1351,7 @@ class accountContainer {
* @return boolean show or hide button * @return boolean show or hide button
*/ */
private function showSetPasswordButton() { private function showSetPasswordButton() {
foreach ($this->module as $name => $module) { foreach ($this->module as $module) {
if (($module instanceof passwordService) && $module->managesPasswordAttributes()) { if (($module instanceof passwordService) && $module->managesPasswordAttributes()) {
return true; return true;
} }
@ -1442,11 +1459,12 @@ class accountContainer {
$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) {
if (isset($profile['ldap_rdn'][0])) { $this->module[$module]->load_profile($profile);
if (in_array($profile['ldap_rdn'][0], getRDNAttributes($this->type->getId()))) {
$this->rdn = $profile['ldap_rdn'][0];
} }
if (isset($profile['ldap_rdn'][0])
&& in_array($profile['ldap_rdn'][0], getRDNAttributes($this->type->getId()))) {
$this->rdn = $profile['ldap_rdn'][0];
} }
if (isset($profile['ldap_suffix'][0]) && ($profile['ldap_suffix'][0] != '-')) { if (isset($profile['ldap_suffix'][0]) && ($profile['ldap_suffix'][0] != '-')) {
$this->dnSuffix = $profile['ldap_suffix'][0]; $this->dnSuffix = $profile['ldap_suffix'][0];
@ -1468,7 +1486,9 @@ class accountContainer {
$buttonStatus = $this->module[$this->order[$i]]->getButtonStatus(); $buttonStatus = $this->module[$this->order[$i]]->getButtonStatus();
$alias = $this->module[$this->order[$i]]->get_alias(); $alias = $this->module[$this->order[$i]]->get_alias();
// skip hidden buttons // skip hidden buttons
if ($buttonStatus == 'hidden') continue; if ($buttonStatus == 'hidden') {
continue;
}
$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]) {
@ -1479,7 +1499,9 @@ class accountContainer {
$buttonStyle = 'background-color:transparent;;border:0px solid;min-width: 200px;'; $buttonStyle = 'background-color:transparent;;border:0px solid;min-width: 200px;';
echo "<button style=\"" . $buttonStyle . "\" name=\"form_main_".$this->order[$i]."\""; echo "<button style=\"" . $buttonStyle . "\" name=\"form_main_".$this->order[$i]."\"";
echo " tabindex=$x"; echo " tabindex=$x";
if ($buttonStatus == 'disabled') echo " disabled"; if ($buttonStatus == 'disabled') {
echo " disabled";
}
echo ' onmouseover="jQuery(this).addClass(\'tabs-hover\');" onmouseout="jQuery(this).removeClass(\'tabs-hover\');">'; echo ' onmouseover="jQuery(this).addClass(\'tabs-hover\');" onmouseout="jQuery(this).removeClass(\'tabs-hover\');">';
if ($buttonImage != null) { if ($buttonImage != null) {
if (!(strpos($buttonImage, 'http') === 0) && !(strpos($buttonImage, '/') === 0)) { if (!(strpos($buttonImage, 'http') === 0) && !(strpos($buttonImage, '/') === 0)) {
@ -1523,12 +1545,12 @@ class accountContainer {
if (isset($orig[$name]) && is_array($orig[$name])) { if (isset($orig[$name]) && is_array($orig[$name])) {
foreach ($orig[$name] as $j => $value) { foreach ($orig[$name] as $j => $value) {
if (is_array($attributes[$name])) { if (is_array($attributes[$name])) {
if (!in_array($value, $attributes[$name], true)) { if (!in_array($value, $attributes[$name], true)
if (($value !== null) && ($value !== '')) { && ($value !== null)
&& ($value !== '')) {
$torem[$name][] = $value; $torem[$name][] = $value;
} }
} }
}
elseif (($value !== null) && ($value !== '')) { elseif (($value !== null) && ($value !== '')) {
$torem[$name][] = $value; $torem[$name][] = $value;
} }
@ -1538,11 +1560,11 @@ class accountContainer {
if (isset($attributes[$name]) && is_array($attributes[$name])) { if (isset($attributes[$name]) && is_array($attributes[$name])) {
foreach ($attributes[$name] as $j => $value) { foreach ($attributes[$name] as $j => $value) {
if (isset($orig[$name]) && is_array($orig[$name])) { if (isset($orig[$name]) && is_array($orig[$name])) {
if (!in_array($value, $orig[$name], true)) if (!in_array($value, $orig[$name], true)
if (($value !== null) && ($value !== '')) { && ($value !== null)
&& ($value !== ''))
$toadd[$name][] = $value; $toadd[$name][] = $value;
} }
}
elseif (($value !== null) && ($value !== '')) { elseif (($value !== null) && ($value !== '')) {
$toadd[$name][] = $value; $toadd[$name][] = $value;
} }
@ -1663,7 +1685,9 @@ class accountContainer {
* @return array fixed attributes * @return array fixed attributes
*/ */
function fixLDAPAttributes($attributes, $modules) { function fixLDAPAttributes($attributes, $modules) {
if (!is_array($attributes)) return $attributes; if (!is_array($attributes)) {
return $attributes;
}
$keys = array_keys($attributes); $keys = array_keys($attributes);
// get correct object class names, aliases and attributes // get correct object class names, aliases and attributes
$objectClasses = array(); $objectClasses = array();
@ -1800,10 +1824,14 @@ class accountContainer {
foreach ($module as $singlemodule) { foreach ($module as $singlemodule) {
// load changes // load changes
$temp = $this->module[$singlemodule]->save_attributes(); $temp = $this->module[$singlemodule]->save_attributes();
if (!is_array($temp)) $temp = array(); if (!is_array($temp)) {
$temp = array();
}
// merge changes // merge changes
$DNs = array_keys($temp); $DNs = array_keys($temp);
if (is_array($temp)) $attributes = array_merge_recursive($temp, $attributes); if (is_array($temp)) {
$attributes = array_merge_recursive($temp, $attributes);
}
for ($i = 0; $i < count($DNs); $i++) { for ($i = 0; $i < count($DNs); $i++) {
$ops = array_keys($temp[$DNs[$i]]); $ops = array_keys($temp[$DNs[$i]]);
for ($j=0; $j<count($ops); $j++) { for ($j=0; $j<count($ops); $j++) {
@ -2075,8 +2103,7 @@ class accountContainer {
if (isset($this->finalDN)) { if (isset($this->finalDN)) {
$dn = $this->finalDN; $dn = $this->finalDN;
} }
$return = array_merge($return,array('main_dn' => array(new \LAM\PDF\PDFLabelValue(_('DN'), $dn)))); return array_merge($return,array('main_dn' => array(new \LAM\PDF\PDFLabelValue(_('DN'), $dn))));
return $return;
} }
/** /**
@ -2150,7 +2177,9 @@ class accountContainer {
} }
// add modules which could not be sorted (e.g. because of cyclic dependencies) // add modules which could not be sorted (e.g. because of cyclic dependencies)
if (sizeof($depModules) > 0) { if (sizeof($depModules) > 0) {
for ($i = 0; $i < sizeof($depModules); $i++) $order[] = $depModules[$i]; for ($i = 0; $i < sizeof($depModules); $i++) {
$order[] = $depModules[$i];
}
} }
// move disabled modules to end // move disabled modules to end
$activeModules = array(); $activeModules = array();
@ -2177,9 +2206,10 @@ class accountContainer {
* @return String RDN * @return String RDN
*/ */
function getRDN($dn) { function getRDN($dn) {
if (($dn == "") || ($dn == null)) return ""; if (($dn == "") || ($dn == null)) {
$rdn = substr($dn, 0, strpos($dn, ",")); return "";
return $rdn; }
return substr($dn, 0, strpos($dn, ","));
} }
/** /**
@ -2189,9 +2219,10 @@ class accountContainer {
* @return String DN * @return String DN
*/ */
function getParentDN($dn) { function getParentDN($dn) {
if (($dn == "") || ($dn == null)) return ""; if (($dn == "") || ($dn == null)) {
$parent = substr($dn, strpos($dn, ",") + 1); return "";
return $parent; }
return substr($dn, strpos($dn, ",") + 1);
} }
/** /**

View File

@ -6,7 +6,7 @@ use \LAM\PDF\PDFTableRow;
This code is part of LDAP Account Manager (http://www.sourceforge.net/projects/lam) This code is part of LDAP Account Manager (http://www.sourceforge.net/projects/lam)
Copyright (C) 2009 - 2012 Pavel Pozdniak Copyright (C) 2009 - 2012 Pavel Pozdniak
2009 - 2018 Roland Gruber 2009 - 2019 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
@ -345,7 +345,8 @@ class asteriskExtension extends baseModule {
$displayEntrNum++; $displayEntrNum++;
$this->addRuleFlag = false; $this->addRuleFlag = false;
} }
$hidenInput = new htmlHiddenInput("extension_rows", $displayEntrNum); //the size of found rows plus 1 for new one; // the size of found rows plus 1 for new one
$hidenInput = new htmlHiddenInput("extension_rows", $displayEntrNum);
$renderContainer->addElement($hidenInput, true); $renderContainer->addElement($hidenInput, true);
$renderContainer->addElement(new htmlButton("add_rule", _('Add another rule')), true); $renderContainer->addElement(new htmlButton("add_rule", _('Add another rule')), true);
@ -509,8 +510,9 @@ class asteriskExtension extends baseModule {
$this->searchOwnersInTreeSuffix = false; $this->searchOwnersInTreeSuffix = false;
} }
} }
if (!isset($this->extensionOwners)) if (!isset($this->extensionOwners)) {
$this->extensionOwners = array(); $this->extensionOwners = array();
}
if (isset($_POST['addusers']) && isset($_POST['addusers_button'])) { // Add users to list if (isset($_POST['addusers']) && isset($_POST['addusers_button'])) { // Add users to list
// Add new user // Add new user
$this->extensionOwners = @array_merge($this->extensionOwners, $_POST['addusers']); $this->extensionOwners = @array_merge($this->extensionOwners, $_POST['addusers']);
@ -662,8 +664,7 @@ class asteriskExtension extends baseModule {
*/ */
function getDefaultExtensionOwner(){ function getDefaultExtensionOwner(){
$credentials = $_SESSION['ldap']->decrypt_login(); $credentials = $_SESSION['ldap']->decrypt_login();
$login = $credentials[0]; return $credentials[0];
return $login;
} }
/** /**
@ -691,11 +692,10 @@ class asteriskExtension extends baseModule {
$extRow["objectclass"][2] = "AsteriskExtension"; $extRow["objectclass"][2] = "AsteriskExtension";
$extRow['astapplication'][0] = $_POST['AstApplication_' . $entryCounter]; $extRow['astapplication'][0] = $_POST['AstApplication_' . $entryCounter];
if (!isset($_POST['AstApplication_' . $entryCounter]) || $_POST['AstApplication_' . $entryCounter] == '') { if ((!isset($_POST['AstApplication_' . $entryCounter]) || $_POST['AstApplication_' . $entryCounter] == '')
if ($entryCounter < ($_POST['extension_rows'] - 1)) { && ($entryCounter < ($_POST['extension_rows'] - 1))) {
$errors[] = $this->messages['AstApplication'][0]; $errors[] = $this->messages['AstApplication'][0];
} }
}
$extRow['astpriority'][0] = $extensionPriorityCntr; $extRow['astpriority'][0] = $extensionPriorityCntr;
@ -707,11 +707,10 @@ class asteriskExtension extends baseModule {
//Fille the member filed //Fille the member filed
$extRow['member'] = $this->extensionOwners; $extRow['member'] = $this->extensionOwners;
if (!isset($extRow['member']) || count($extRow['member']) == 0) { if ((!isset($extRow['member']) || count($extRow['member']) == 0)
if (!isset($_POST['form_subpage_' . get_class($this) . '_user_open'])) { && !isset($_POST['form_subpage_' . get_class($this) . '_user_open'])) {
$errors[] = $this->messages['member'][0]; $errors[] = $this->messages['member'][0];
} }
}
return $errors; return $errors;
} }
@ -800,8 +799,6 @@ class asteriskExtension extends baseModule {
* @see baseModule::get_pdfEntries() * @see baseModule::get_pdfEntries()
*/ */
function get_pdfEntries($pdfKeys, $typeId) { function get_pdfEntries($pdfKeys, $typeId) {
$a = $this->attributes;
$o = $this->orig;
$return = array(); $return = array();
$extName = ''; $extName = '';
if (isset($this->attributes['AstExtension'][0])) { if (isset($this->attributes['AstExtension'][0])) {
@ -849,10 +846,12 @@ class asteriskExtension extends baseModule {
$extensionNamePriorityMap = array(); $extensionNamePriorityMap = array();
for ($i = 0; $i < sizeof($rawAccounts); $i++) { for ($i = 0; $i < sizeof($rawAccounts); $i++) {
// add object class // add object class
if (!in_array("AsteriskExtension", $partialAccounts[$i]['objectClass'])) if (!in_array("AsteriskExtension", $partialAccounts[$i]['objectClass'])) {
$partialAccounts[$i]['objectClass'][] = "AsteriskExtension"; $partialAccounts[$i]['objectClass'][] = "AsteriskExtension";
if (!in_array("groupOfNames", $partialAccounts[$i]['objectClass'])) }
if (!in_array("groupOfNames", $partialAccounts[$i]['objectClass'])) {
$partialAccounts[$i]['objectClass'][] = "groupOfNames"; $partialAccounts[$i]['objectClass'][] = "groupOfNames";
}
// attributes // attributes
$this->mapSimpleUploadField($rawAccounts, $ids, $partialAccounts, $i, 'asteriskExtension_AstExtension', 'AstExtension'); $this->mapSimpleUploadField($rawAccounts, $ids, $partialAccounts, $i, 'asteriskExtension_AstExtension', 'AstExtension');
@ -891,7 +890,6 @@ class asteriskExtension extends baseModule {
*/ */
function moveExtentionToNewSuffix($rowOrig) { function moveExtentionToNewSuffix($rowOrig) {
if ($this->isMoveToNewSuffix()) { if ($this->isMoveToNewSuffix()) {
$orig_suffix = extractDNSuffix($this->getAccountContainer()->dn_orig);
$oldDN = "cn=" . $rowOrig["cn"][0] . "," . extractDNSuffix($this->getAccountContainer()->dn_orig); $oldDN = "cn=" . $rowOrig["cn"][0] . "," . extractDNSuffix($this->getAccountContainer()->dn_orig);
$newRDN = "cn=" . $rowOrig["cn"][0]; $newRDN = "cn=" . $rowOrig["cn"][0];
$is_rename_success = false; $is_rename_success = false;
@ -924,7 +922,6 @@ class asteriskExtension extends baseModule {
* @return array list of modifications * @return array list of modifications
*/ */
function save_attributes() { function save_attributes() {
$errors = array();
$this->extensionRows = $this->array_sort($this->extensionRows, 'astpriority'); $this->extensionRows = $this->array_sort($this->extensionRows, 'astpriority');
//Modify existent config roes if necessary //Modify existent config roes if necessary
@ -949,7 +946,8 @@ class asteriskExtension extends baseModule {
$diffVals = array_map("unserialize", $diffValsSerialysed); $diffVals = array_map("unserialize", $diffValsSerialysed);
if($row["cn"][0] == $rowOrig["cn"][0]){ if($row["cn"][0] == $rowOrig["cn"][0]){
ldap_mod_replace($_SESSION['ldap']->server(), "cn=" . $row["cn"][0] . "," . $this->getAccountContainer()->dnSuffix, $diffVals); ldap_mod_replace($_SESSION['ldap']->server(), "cn=" . $row["cn"][0] . "," . $this->getAccountContainer()->dnSuffix, $diffVals);
}else{ }
else {
$origDN = "cn=" . $rowOrig["cn"][0] . "," . $this->getAccountContainer()->dnSuffix; $origDN = "cn=" . $rowOrig["cn"][0] . "," . $this->getAccountContainer()->dnSuffix;
$newRDN = "cn=" . $row["cn"][0]; $newRDN = "cn=" . $row["cn"][0];
@ -971,9 +969,7 @@ class asteriskExtension extends baseModule {
$this->getAccountContainer()->dn_orig = "cn=" . $this->extensionRows[0]['cn'][0] . "," . $this->getAccountContainer()->dnSuffix; $this->getAccountContainer()->dn_orig = "cn=" . $this->extensionRows[0]['cn'][0] . "," . $this->getAccountContainer()->dnSuffix;
$this->getAccountContainer()->finalDN = "cn=" . $this->extensionRows[0]['cn'][0] . "," . $this->getAccountContainer()->dnSuffix; $this->getAccountContainer()->finalDN = "cn=" . $this->extensionRows[0]['cn'][0] . "," . $this->getAccountContainer()->dnSuffix;
$retun_obj = $this->getAccountContainer()->save_module_attributes($this->orig, $this->orig); return $this->getAccountContainer()->save_module_attributes($this->orig, $this->orig);
return $retun_obj;
} }
/** /**

View File

@ -3,7 +3,7 @@ use \LAM\TYPES\TypeManager;
/* /*
* 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) 2017 Lars Althof * Copyright (C) 2017 Lars Althof
* 2017 Roland Gruber * 2017 - 2019 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
@ -559,12 +559,12 @@ class courierMailAccount extends baseModule {
// profile mappings in meta data // profile mappings in meta data
parent::load_profile($profile); parent::load_profile($profile);
// add extension // add extension
if (isset($profile['courierMailAccount_addExt'][0]) && ($profile['courierMailAccount_addExt'][0] == "true")) { if (isset($profile['courierMailAccount_addExt'][0])
if (!in_array('courierMailAccount', $this->attributes['objectClass'])) { && ($profile['courierMailAccount_addExt'][0] == "true")
&& !in_array('courierMailAccount', $this->attributes['objectClass'])) {
$this->attributes['objectClass'][] = 'courierMailAccount'; $this->attributes['objectClass'][] = 'courierMailAccount';
} }
} }
}
/** /**
* Returns if this account is virtual only or also a unix account * Returns if this account is virtual only or also a unix account
@ -573,12 +573,7 @@ class courierMailAccount extends baseModule {
* @return boolean only virtual account * @return boolean only virtual account
*/ */
private function isUnixDisabled($modules) { private function isUnixDisabled($modules) {
if (in_array('posixAccount', $modules)) { return !in_array('posixAccount', $modules);
return false;
}
else {
return true;
}
} }
} }

View File

@ -3,7 +3,7 @@ use LAM\TYPES\TypeManager;
/* /*
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 - 2018 Roland Gruber Copyright (C) 2013 - 2019 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
@ -268,12 +268,12 @@ class kolabGroup extends baseModule {
// profile mappings in meta data // profile mappings in meta data
parent::load_profile($profile); parent::load_profile($profile);
// add extension // add extension
if (isset($profile['kolabGroup_addExt'][0]) && ($profile['kolabGroup_addExt'][0] == "true")) { if (isset($profile['kolabGroup_addExt'][0])
if (!in_array('kolabGroupOfUniqueNames', $this->attributes['objectClass'])) { && ($profile['kolabGroup_addExt'][0] == "true")
&& !in_array('kolabGroupOfUniqueNames', $this->attributes['objectClass'])) {
$this->attributes['objectClass'][] = 'kolabGroupOfUniqueNames'; $this->attributes['objectClass'][] = 'kolabGroupOfUniqueNames';
} }
} }
}
/** /**
* {@inheritDoc} * {@inheritDoc}
@ -369,12 +369,7 @@ class kolabGroup extends baseModule {
* @return boolean manage mail attribute * @return boolean manage mail attribute
*/ */
private function manageMail($modules) { private function manageMail($modules) {
if (in_array('qmailGroup', $modules)) { return !in_array('qmailGroup', $modules);
return false;
}
else {
return true;
}
} }
/** /**

View File

@ -6,7 +6,7 @@ use \LAM\PDF\PDFTableRow;
$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 - 2017 Roland Gruber Copyright (C) 2009 - 2019 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
@ -192,13 +192,17 @@ class nisnetgroup extends baseModule {
$return = new htmlTable(); $return = new htmlTable();
// user name // user name
$groupName = ''; $groupName = '';
if (isset($this->attributes['cn'][0])) $groupName = $this->attributes['cn'][0]; if (isset($this->attributes['cn'][0])) {
$groupName = $this->attributes['cn'][0];
}
$nameInput = new htmlTableExtendedInputField(_("Group name"), 'cn', $groupName, 'cn'); $nameInput = new htmlTableExtendedInputField(_("Group name"), 'cn', $groupName, 'cn');
$nameInput->setRequired(true); $nameInput->setRequired(true);
$nameInput->setFieldMaxLength(20); $nameInput->setFieldMaxLength(20);
$return->addElement($nameInput, true); $return->addElement($nameInput, true);
$description = ''; $description = '';
if (isset($this->attributes['description'][0])) $description = $this->attributes['description'][0]; if (isset($this->attributes['description'][0])) {
$description = $this->attributes['description'][0];
}
$return->addElement(new htmlTableExtendedInputField(_('Description'), 'description', $description, 'description'), true); $return->addElement(new htmlTableExtendedInputField(_('Description'), 'description', $description, 'description'), true);
$subgroupsContainer = new htmlTable(); $subgroupsContainer = new htmlTable();
if (isset($this->attributes['memberNisNetgroup']) && is_array($this->attributes['memberNisNetgroup'])) { if (isset($this->attributes['memberNisNetgroup']) && is_array($this->attributes['memberNisNetgroup'])) {
@ -262,9 +266,15 @@ class nisnetgroup extends baseModule {
$hostNew = ''; $hostNew = '';
$userNew = ''; $userNew = '';
$domainNew = ''; $domainNew = '';
if (isset($_POST['host_new'])) $hostNew = $_POST['host_new']; if (isset($_POST['host_new'])) {
if (isset($_POST['user_new'])) $userNew = $_POST['user_new']; $hostNew = $_POST['host_new'];
if (isset($_POST['domain_new'])) $domainNew = $_POST['domain_new']; }
if (isset($_POST['user_new'])) {
$userNew = $_POST['user_new'];
}
if (isset($_POST['domain_new'])) {
$domainNew = $_POST['domain_new'];
}
$hostField = new htmlInputField('host_new', $hostNew); $hostField = new htmlInputField('host_new', $hostNew);
$hostField->setFieldSize(20); $hostField->setFieldSize(20);
$memberTable->addElement($hostField); $memberTable->addElement($hostField);
@ -482,12 +492,16 @@ class nisnetgroup extends baseModule {
$return->addElement(new htmlButton($filterButtonName, _('Ok'))); $return->addElement(new htmlButton($filterButtonName, _('Ok')));
$return->addElement(new htmlHelpLink('filter'), true); $return->addElement(new htmlHelpLink('filter'), true);
$title = _('Host name'); $title = _('Host name');
if (!$selectHost) $title = _('User name'); if (!$selectHost) {
$title = _('User name');
}
$return->addElement(new htmlOutputText($title)); $return->addElement(new htmlOutputText($title));
$return->addElement(new htmlSelect('selectBox', $options), true); $return->addElement(new htmlSelect('selectBox', $options), true);
$return->addElement(new htmlSpacer(null, '10px'), true); $return->addElement(new htmlSpacer(null, '10px'), true);
$type = 'host'; $type = 'host';
if (!$selectHost) $type = 'user'; if (!$selectHost) {
$type = 'user';
}
$buttonContainer = new htmlTable(); $buttonContainer = new htmlTable();
$buttonContainer->addElement(new htmlAccountPageButton(get_class($this), 'attributes', 'select', _('Ok'))); $buttonContainer->addElement(new htmlAccountPageButton(get_class($this), 'attributes', 'select', _('Ok')));
$buttonContainer->addElement(new htmlAccountPageButton(get_class($this), 'attributes', 'back', _('Cancel'))); $buttonContainer->addElement(new htmlAccountPageButton(get_class($this), 'attributes', 'back', _('Cancel')));
@ -527,7 +541,9 @@ class nisnetgroup extends baseModule {
$existingGroups = $this->getGroupList(); $existingGroups = $this->getGroupList();
for ($i = 0; $i < sizeof($rawAccounts); $i++) { for ($i = 0; $i < sizeof($rawAccounts); $i++) {
// add object class // add object class
if (!in_array('nisNetgroup', $partialAccounts[$i]['objectClass'])) $partialAccounts[$i]['objectClass'][] = 'nisNetgroup'; if (!in_array('nisNetgroup', $partialAccounts[$i]['objectClass'])) {
$partialAccounts[$i]['objectClass'][] = 'nisNetgroup';
}
// add cn // add cn
$partialAccounts[$i]['cn'] = $rawAccounts[$i][$ids['nisnetgroup_cn']]; $partialAccounts[$i]['cn'] = $rawAccounts[$i][$ids['nisnetgroup_cn']];
// description (UTF-8, no regex check needed) // description (UTF-8, no regex check needed)
@ -558,12 +574,7 @@ class nisnetgroup extends baseModule {
* @return boolean true, if settings are complete * @return boolean true, if settings are complete
*/ */
function module_complete() { function module_complete() {
if (isset($this->attributes['cn']) && (sizeof($this->attributes['cn']) > 0)) { return (isset($this->attributes['cn']) && (sizeof($this->attributes['cn']) > 0));
return true;
}
else {
return false;
}
} }
/** /**

View File

@ -3,7 +3,7 @@ use \LAM\TYPES\TypeManager;
/* /*
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 - 2018 Roland Gruber Copyright (C) 2013 - 2019 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
@ -367,12 +367,12 @@ class pykotaGroup extends baseModule {
// profile mappings in meta data // profile mappings in meta data
parent::load_profile($profile); parent::load_profile($profile);
// add extension // add extension
if (isset($profile['pykotaGroup_addExt'][0]) && ($profile['pykotaGroup_addExt'][0] == "true")) { if (isset($profile['pykotaGroup_addExt'][0])
if (!in_array('pykotaGroup', $this->attributes['objectClass'])) { && ($profile['pykotaGroup_addExt'][0] == "true")
&& !in_array('pykotaGroup', $this->attributes['objectClass'])) {
$this->attributes['objectClass'][] = 'pykotaGroup'; $this->attributes['objectClass'][] = 'pykotaGroup';
} }
} }
}
/** /**
* {@inheritDoc} * {@inheritDoc}
@ -504,14 +504,9 @@ class pykotaGroup extends baseModule {
* @return bool not active * @return bool not active
*/ */
private function isUnixOrGonInactive($modules) { private function isUnixOrGonInactive($modules) {
if (in_array('posixGroup', $modules) return !in_array('posixGroup', $modules)
|| in_array('groupOfNames', $modules) && !in_array('groupOfNames', $modules)
|| in_array('groupOfUniqueNames', $modules)) { && !in_array('groupOfUniqueNames', $modules);
return false;
}
else {
return true;
}
} }
/** /**

View File

@ -6,7 +6,7 @@ use \LAM\TYPES\TypeManager;
/* /*
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 - 2018 Roland Gruber Copyright (C) 2013 - 2019 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
@ -961,7 +961,9 @@ class pykotaUser extends baseModule {
$return = array(); $return = array();
if (in_array('pykotaBalance', $fields)) { if (in_array('pykotaBalance', $fields)) {
$pykotaBalance = ''; $pykotaBalance = '';
if (isset($attributes['pykotaBalance'][0])) $pykotaBalance = $attributes['pykotaBalance'][0]; if (isset($attributes['pykotaBalance'][0])) {
$pykotaBalance = $attributes['pykotaBalance'][0];
}
$row = new htmlResponsiveRow(); $row = new htmlResponsiveRow();
$row->addLabel(new htmlOutputText($this->getSelfServiceLabel('pykotaBalance', _('Balance')))); $row->addLabel(new htmlOutputText($this->getSelfServiceLabel('pykotaBalance', _('Balance'))));
$row->addField(new htmlOutputText($pykotaBalance)); $row->addField(new htmlOutputText($pykotaBalance));
@ -969,7 +971,9 @@ class pykotaUser extends baseModule {
} }
if (in_array('pykotaLifeTimePaid', $fields)) { if (in_array('pykotaLifeTimePaid', $fields)) {
$pykotaLifeTimePaid = ''; $pykotaLifeTimePaid = '';
if (isset($attributes['pykotaLifeTimePaid'][0])) $pykotaLifeTimePaid = $attributes['pykotaLifeTimePaid'][0]; if (isset($attributes['pykotaLifeTimePaid'][0])) {
$pykotaLifeTimePaid = $attributes['pykotaLifeTimePaid'][0];
}
$row = new htmlResponsiveRow(); $row = new htmlResponsiveRow();
$row->addLabel(new htmlOutputText($this->getSelfServiceLabel('pykotaLifeTimePaid', _('Total paid')))); $row->addLabel(new htmlOutputText($this->getSelfServiceLabel('pykotaLifeTimePaid', _('Total paid'))));
$row->addField(new htmlOutputText($pykotaLifeTimePaid)); $row->addField(new htmlOutputText($pykotaLifeTimePaid));
@ -989,7 +993,6 @@ class pykotaUser extends baseModule {
$amount = new htmlOutputText($parts[1]); $amount = new htmlOutputText($parts[1]);
$amount->alignment = htmlElement::ALIGN_RIGHT; $amount->alignment = htmlElement::ALIGN_RIGHT;
$pykotaPayments->add($amount, 3); $pykotaPayments->add($amount, 3);
$comment = empty($parts[2]) ? '' : $parts[2];
$pykotaPayments->add(new htmlOutputText(base64_decode($parts[2])), 6); $pykotaPayments->add(new htmlOutputText(base64_decode($parts[2])), 6);
} }
} }
@ -1045,11 +1048,11 @@ class pykotaUser extends baseModule {
*/ */
public function checkSelfServiceSettings(&$options, &$profile) { public function checkSelfServiceSettings(&$options, &$profile) {
$errors = array(); $errors = array();
if (get_class($this) == 'pykotaUser') { if ((get_class($this) == 'pykotaUser')
if (!empty($options['pykotaUser_jobSuffix'][0]) && !get_preg($options['pykotaUser_jobSuffix'][0], 'dn')) { && !empty($options['pykotaUser_jobSuffix'][0])
&& !get_preg($options['pykotaUser_jobSuffix'][0], 'dn')) {
$errors[] = $this->messages['jobSuffix'][0]; $errors[] = $this->messages['jobSuffix'][0];
} }
}
return $errors; return $errors;
} }
@ -1060,13 +1063,7 @@ class pykotaUser extends baseModule {
* @return boolean manage uid attribute * @return boolean manage uid attribute
*/ */
private function manageUid($modules) { private function manageUid($modules) {
if (in_array('inetOrgPerson', $modules) return !in_array('inetOrgPerson', $modules) && !in_array('posixAccount', $modules);
|| in_array('posixAccount', $modules)) {
return false;
}
else {
return true;
}
} }
/** /**
@ -1076,12 +1073,7 @@ class pykotaUser extends baseModule {
* @return boolean manage mail attribute * @return boolean manage mail attribute
*/ */
private function manageMail($modules) { private function manageMail($modules) {
if (in_array('inetOrgPerson', $modules)) { return !in_array('inetOrgPerson', $modules);
return false;
}
else {
return true;
}
} }
/** /**
@ -1091,12 +1083,7 @@ class pykotaUser extends baseModule {
* @return boolean manage description attribute * @return boolean manage description attribute
*/ */
private function manageDescription($modules) { private function manageDescription($modules) {
if (in_array('inetOrgPerson', $modules)) { return !in_array('inetOrgPerson', $modules);
return false;
}
else {
return true;
}
} }
/** /**

View File

@ -312,13 +312,13 @@ function showConfirmationDialog(title, okText, cancelText, dialogDiv, formName,
jQuery('#' + dialogDiv).dialog('close'); jQuery('#' + dialogDiv).dialog('close');
if (resultField) { if (resultField) {
jQuery('#' + resultField).val('ok'); jQuery('#' + resultField).val('ok');
}; }
appendDialogInputsToFormAndSubmit(dialogDiv, formName); appendDialogInputsToFormAndSubmit(dialogDiv, formName);
}; };
buttonList[cancelText] = function() { buttonList[cancelText] = function() {
if (resultField) { if (resultField) {
jQuery('#' + resultField).val('cancel'); jQuery('#' + resultField).val('cancel');
}; }
jQuery(this).dialog("close"); jQuery(this).dialog("close");
}; };
jQuery('#' + dialogDiv).dialog({ jQuery('#' + dialogDiv).dialog({
@ -375,7 +375,7 @@ function equalWidth(elementIDs) {
for (var i = 0; i < elementIDs.length; ++i) { for (var i = 0; i < elementIDs.length; ++i) {
if (jQuery(elementIDs[i]).width() > maxWidth) { if (jQuery(elementIDs[i]).width() > maxWidth) {
maxWidth = jQuery(elementIDs[i]).width(); maxWidth = jQuery(elementIDs[i]).width();
}; }
} }
if (maxWidth < 5) { if (maxWidth < 5) {
// no action if invalid width value (e.g. because of hidden tab) // no action if invalid width value (e.g. because of hidden tab)
@ -396,7 +396,7 @@ function equalHeight(elementIDs) {
for (var i = 0; i < elementIDs.length; ++i) { for (var i = 0; i < elementIDs.length; ++i) {
if (jQuery(elementIDs[i]).height() > max) { if (jQuery(elementIDs[i]).height() > max) {
max = jQuery(elementIDs[i]).height(); max = jQuery(elementIDs[i]).height();
}; }
} }
for (var i = 0; i < elementIDs.length; ++i) { for (var i = 0; i < elementIDs.length; ++i) {
jQuery(elementIDs[i]).css({'height': max - (jQuery(elementIDs[i]).outerHeight() - jQuery(elementIDs[i]).height())}); jQuery(elementIDs[i]).css({'height': max - (jQuery(elementIDs[i]).outerHeight() - jQuery(elementIDs[i]).height())});
@ -768,7 +768,7 @@ window.lam.gui.equalHeight = function() {
jQuery('.lamEqualHeightTabContent').each(function() { jQuery('.lamEqualHeightTabContent').each(function() {
if (jQuery(this).height() > maxHeight) { if (jQuery(this).height() > maxHeight) {
maxHeight = jQuery(this).height(); maxHeight = jQuery(this).height();
}; }
}); });
jQuery('.lamEqualHeightTabContent').each(function() { jQuery('.lamEqualHeightTabContent').each(function() {
jQuery(this).css({'height': maxHeight}); jQuery(this).css({'height': maxHeight});