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')) {
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));
return false;
}

View File

@ -3,7 +3,7 @@
This code is part of LDAP Account Manager (http://www.ldap-account-manager.org/)
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
it under the terms of the GNU General Public License as published by
@ -341,7 +341,6 @@ function generateRandomPassword() {
if ($length < 12) {
$length = 12;
}
$isOk = false;
for ($x = 0; $x < 10000; $x++) {
$password = '';
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/)
Copyright (C) 2018 Roland Gruber
Copyright (C) 2018 - 2019 Roland Gruber
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
@ -109,8 +109,7 @@ class Importer {
*/
public function getTasks($lines) {
$chunks = $this->extractImportChunks($lines);
$tasks = $this->convertToTasks($chunks);
return $tasks;
return $this->convertToTasks($chunks);
}
/**
@ -297,7 +296,6 @@ class Importer {
elseif ($type !== 'modify') {
throw new LAMException(_('Invalid data'), htmlspecialchars($dn) . ' - changeType: ' . htmlspecialchars($type));
}
$changes = array();
$subtasks = array();
$currentLines = array();
$linesCount = sizeof($entry);
@ -337,7 +335,7 @@ class Importer {
if (($delOldRdnData[Importer::KEY] !== 'deleteoldrdn') || !in_array($delOldRdnData[Importer::VALUE], array('0', '1'), true)) {
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);
}

View File

@ -4,7 +4,7 @@ use \LAM\TYPES\TypeManager;
/*
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
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']) . ")";
}
$loginData = $_SESSION['ldap']->decrypt_login();
$finalFilter = str_replace('@@LOGIN_DN@@', $loginData[0], $finalFilter);
return $finalFilter;
return str_replace('@@LOGIN_DN@@', $loginData[0], $finalFilter);
}
/**
@ -190,7 +189,9 @@ function getRDNAttributes($typeId, $selectedModules=null) {
if (!in_array($attrs_normal[$i], $return)) $return[] = $attrs_normal[$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;
}
@ -252,8 +253,10 @@ function check_module_depends($selected, $deps) {
}
}
}
if (sizeof($ret) > 0) return $ret;
else return false;
if (sizeof($ret) > 0) {
return $ret;
}
return false;
}
/**
@ -273,8 +276,10 @@ function check_module_conflicts($selected, $deps) {
}
}
}
if (sizeof($ret) > 0) return $ret;
else return false;
if (sizeof($ret) > 0) {
return $ret;
}
return false;
}
/**
@ -289,7 +294,7 @@ function getAvailableModules($scope, $mustSupportAdminInterface = false) {
$dir = dir($dirname);
$return = array();
// get module names.
while ($entry = $dir->read())
while ($entry = $dir->read()) {
if ((substr($entry, strlen($entry) - 4, 4) == '.inc') && is_file($dirname . '/'.$entry)) {
$entry = substr($entry, 0, strpos($entry, '.'));
$temp = moduleCache::getModule($entry, $scope);
@ -300,6 +305,7 @@ function getAvailableModules($scope, $mustSupportAdminInterface = false) {
$return[] = $entry;
}
}
}
return $return;
}
@ -389,7 +395,9 @@ function getHelp($module,$helpID,$scope='') {
global $helpArray;
if (!isset($module) || ($module == '') || ($module == 'main')) {
$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)) {
include_once($helpPath);
}
@ -512,7 +520,9 @@ function buildUploadAccounts($type, $data, $ids, $selectedModules, htmlResponsiv
break;
}
}
if ($newRound) continue;
if ($newRound) {
continue;
}
// 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);
return false;
@ -701,7 +711,9 @@ function lamCompareDescriptiveOptions(&$a, &$b) {
*/
function printHelpLink($entry, $number, $module = '', $scope = '', $classes = array()) {
$helpPath = "../";
if (is_file("./help.php")) $helpPath = "";
if (is_file("./help.php")) {
$helpPath = "";
}
$title = $entry['Headline'];
$message = $entry['Text'];
if (isset($entry['attr'])) {
@ -736,8 +748,12 @@ class accountContainer {
* @param integer $randomID random ID to avoid parallel editing (default: null)
*/
function __construct($type, $base, $randomID = null) {
if (!($type instanceof ConfiguredType)) 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);
if (!($type instanceof ConfiguredType)) {
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->base = $base;
// Set startpage
@ -855,13 +871,14 @@ class accountContainer {
}
$oldPage = $this->current_page;
$oldSubpage = $this->subpage;
$post = $_POST;
$result = array();
$stopProcessing = false; // when set to true, no module options are displayed
$errorsOccured = false;
$typeObject = $this->type->getBaseType();
$profileLoaded = $this->loadProfileIfRequested();
if ($this->subpage=='') $this->subpage='attributes';
if ($this->subpage == '') {
$this->subpage='attributes';
}
if (isset($_POST['accountContainerReset'])) {
$result = $this->load_account($this->dn_orig);
}
@ -1225,7 +1242,7 @@ class accountContainer {
$return['forcePasswordChange'] = $forcePasswordChange;
if ($return['errorsOccured'] == 'false') {
// set new password
foreach ($this->module as $name => $module) {
foreach ($this->module as $module) {
if ($module instanceof passwordService) {
$messages = $module->passwordChangeRequested($password1, $modules, $forcePasswordChange);
for ($m = 0; $m < sizeof($messages); $m++) {
@ -1334,7 +1351,7 @@ class accountContainer {
* @return boolean show or hide button
*/
private function showSetPasswordButton() {
foreach ($this->module as $name => $module) {
foreach ($this->module as $module) {
if (($module instanceof passwordService) && $module->managesPasswordAttributes()) {
return true;
}
@ -1442,11 +1459,12 @@ class accountContainer {
$this->lastLoadedProfile = $_POST['accountContainerSelectLoadProfile'];
// pass profile to each module
$modules = array_keys($this->module);
foreach ($modules as $module) $this->module[$module]->load_profile($profile);
if (isset($profile['ldap_rdn'][0])) {
if (in_array($profile['ldap_rdn'][0], getRDNAttributes($this->type->getId()))) {
$this->rdn = $profile['ldap_rdn'][0];
foreach ($modules as $module) {
$this->module[$module]->load_profile($profile);
}
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] != '-')) {
$this->dnSuffix = $profile['ldap_suffix'][0];
@ -1468,7 +1486,9 @@ class accountContainer {
$buttonStatus = $this->module[$this->order[$i]]->getButtonStatus();
$alias = $this->module[$this->order[$i]]->get_alias();
// skip hidden buttons
if ($buttonStatus == 'hidden') continue;
if ($buttonStatus == 'hidden') {
continue;
}
$buttonImage = $this->module[$this->order[$i]]->getIcon();
$activatedClass = '';
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;';
echo "<button style=\"" . $buttonStyle . "\" name=\"form_main_".$this->order[$i]."\"";
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\');">';
if ($buttonImage != null) {
if (!(strpos($buttonImage, 'http') === 0) && !(strpos($buttonImage, '/') === 0)) {
@ -1523,12 +1545,12 @@ class accountContainer {
if (isset($orig[$name]) && is_array($orig[$name])) {
foreach ($orig[$name] as $j => $value) {
if (is_array($attributes[$name])) {
if (!in_array($value, $attributes[$name], true)) {
if (($value !== null) && ($value !== '')) {
if (!in_array($value, $attributes[$name], true)
&& ($value !== null)
&& ($value !== '')) {
$torem[$name][] = $value;
}
}
}
elseif (($value !== null) && ($value !== '')) {
$torem[$name][] = $value;
}
@ -1538,11 +1560,11 @@ class accountContainer {
if (isset($attributes[$name]) && is_array($attributes[$name])) {
foreach ($attributes[$name] as $j => $value) {
if (isset($orig[$name]) && is_array($orig[$name])) {
if (!in_array($value, $orig[$name], true))
if (($value !== null) && ($value !== '')) {
if (!in_array($value, $orig[$name], true)
&& ($value !== null)
&& ($value !== ''))
$toadd[$name][] = $value;
}
}
elseif (($value !== null) && ($value !== '')) {
$toadd[$name][] = $value;
}
@ -1663,7 +1685,9 @@ class accountContainer {
* @return array fixed attributes
*/
function fixLDAPAttributes($attributes, $modules) {
if (!is_array($attributes)) return $attributes;
if (!is_array($attributes)) {
return $attributes;
}
$keys = array_keys($attributes);
// get correct object class names, aliases and attributes
$objectClasses = array();
@ -1800,10 +1824,14 @@ class accountContainer {
foreach ($module as $singlemodule) {
// load changes
$temp = $this->module[$singlemodule]->save_attributes();
if (!is_array($temp)) $temp = array();
if (!is_array($temp)) {
$temp = array();
}
// merge changes
$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++) {
$ops = array_keys($temp[$DNs[$i]]);
for ($j=0; $j<count($ops); $j++) {
@ -2075,8 +2103,7 @@ class accountContainer {
if (isset($this->finalDN)) {
$dn = $this->finalDN;
}
$return = array_merge($return,array('main_dn' => array(new \LAM\PDF\PDFLabelValue(_('DN'), $dn))));
return $return;
return array_merge($return,array('main_dn' => array(new \LAM\PDF\PDFLabelValue(_('DN'), $dn))));
}
/**
@ -2150,7 +2177,9 @@ class accountContainer {
}
// add modules which could not be sorted (e.g. because of cyclic dependencies)
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
$activeModules = array();
@ -2177,9 +2206,10 @@ class accountContainer {
* @return String RDN
*/
function getRDN($dn) {
if (($dn == "") || ($dn == null)) return "";
$rdn = substr($dn, 0, strpos($dn, ","));
return $rdn;
if (($dn == "") || ($dn == null)) {
return "";
}
return substr($dn, 0, strpos($dn, ","));
}
/**
@ -2189,9 +2219,10 @@ class accountContainer {
* @return String DN
*/
function getParentDN($dn) {
if (($dn == "") || ($dn == null)) return "";
$parent = substr($dn, strpos($dn, ",") + 1);
return $parent;
if (($dn == "") || ($dn == null)) {
return "";
}
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)
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
it under the terms of the GNU General Public License as published by
@ -345,7 +345,8 @@ class asteriskExtension extends baseModule {
$displayEntrNum++;
$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(new htmlButton("add_rule", _('Add another rule')), true);
@ -509,8 +510,9 @@ class asteriskExtension extends baseModule {
$this->searchOwnersInTreeSuffix = false;
}
}
if (!isset($this->extensionOwners))
if (!isset($this->extensionOwners)) {
$this->extensionOwners = array();
}
if (isset($_POST['addusers']) && isset($_POST['addusers_button'])) { // Add users to list
// Add new user
$this->extensionOwners = @array_merge($this->extensionOwners, $_POST['addusers']);
@ -662,8 +664,7 @@ class asteriskExtension extends baseModule {
*/
function getDefaultExtensionOwner(){
$credentials = $_SESSION['ldap']->decrypt_login();
$login = $credentials[0];
return $login;
return $credentials[0];
}
/**
@ -691,11 +692,10 @@ class asteriskExtension extends baseModule {
$extRow["objectclass"][2] = "AsteriskExtension";
$extRow['astapplication'][0] = $_POST['AstApplication_' . $entryCounter];
if (!isset($_POST['AstApplication_' . $entryCounter]) || $_POST['AstApplication_' . $entryCounter] == '') {
if ($entryCounter < ($_POST['extension_rows'] - 1)) {
if ((!isset($_POST['AstApplication_' . $entryCounter]) || $_POST['AstApplication_' . $entryCounter] == '')
&& ($entryCounter < ($_POST['extension_rows'] - 1))) {
$errors[] = $this->messages['AstApplication'][0];
}
}
$extRow['astpriority'][0] = $extensionPriorityCntr;
@ -707,11 +707,10 @@ class asteriskExtension extends baseModule {
//Fille the member filed
$extRow['member'] = $this->extensionOwners;
if (!isset($extRow['member']) || count($extRow['member']) == 0) {
if (!isset($_POST['form_subpage_' . get_class($this) . '_user_open'])) {
if ((!isset($extRow['member']) || count($extRow['member']) == 0)
&& !isset($_POST['form_subpage_' . get_class($this) . '_user_open'])) {
$errors[] = $this->messages['member'][0];
}
}
return $errors;
}
@ -800,8 +799,6 @@ class asteriskExtension extends baseModule {
* @see baseModule::get_pdfEntries()
*/
function get_pdfEntries($pdfKeys, $typeId) {
$a = $this->attributes;
$o = $this->orig;
$return = array();
$extName = '';
if (isset($this->attributes['AstExtension'][0])) {
@ -849,10 +846,12 @@ class asteriskExtension extends baseModule {
$extensionNamePriorityMap = array();
for ($i = 0; $i < sizeof($rawAccounts); $i++) {
// add object class
if (!in_array("AsteriskExtension", $partialAccounts[$i]['objectClass']))
if (!in_array("AsteriskExtension", $partialAccounts[$i]['objectClass'])) {
$partialAccounts[$i]['objectClass'][] = "AsteriskExtension";
if (!in_array("groupOfNames", $partialAccounts[$i]['objectClass']))
}
if (!in_array("groupOfNames", $partialAccounts[$i]['objectClass'])) {
$partialAccounts[$i]['objectClass'][] = "groupOfNames";
}
// attributes
$this->mapSimpleUploadField($rawAccounts, $ids, $partialAccounts, $i, 'asteriskExtension_AstExtension', 'AstExtension');
@ -891,7 +890,6 @@ class asteriskExtension extends baseModule {
*/
function moveExtentionToNewSuffix($rowOrig) {
if ($this->isMoveToNewSuffix()) {
$orig_suffix = extractDNSuffix($this->getAccountContainer()->dn_orig);
$oldDN = "cn=" . $rowOrig["cn"][0] . "," . extractDNSuffix($this->getAccountContainer()->dn_orig);
$newRDN = "cn=" . $rowOrig["cn"][0];
$is_rename_success = false;
@ -924,7 +922,6 @@ class asteriskExtension extends baseModule {
* @return array list of modifications
*/
function save_attributes() {
$errors = array();
$this->extensionRows = $this->array_sort($this->extensionRows, 'astpriority');
//Modify existent config roes if necessary
@ -949,7 +946,8 @@ class asteriskExtension extends baseModule {
$diffVals = array_map("unserialize", $diffValsSerialysed);
if($row["cn"][0] == $rowOrig["cn"][0]){
ldap_mod_replace($_SESSION['ldap']->server(), "cn=" . $row["cn"][0] . "," . $this->getAccountContainer()->dnSuffix, $diffVals);
}else{
}
else {
$origDN = "cn=" . $rowOrig["cn"][0] . "," . $this->getAccountContainer()->dnSuffix;
$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()->finalDN = "cn=" . $this->extensionRows[0]['cn'][0] . "," . $this->getAccountContainer()->dnSuffix;
$retun_obj = $this->getAccountContainer()->save_module_attributes($this->orig, $this->orig);
return $retun_obj;
return $this->getAccountContainer()->save_module_attributes($this->orig, $this->orig);
}
/**

View File

@ -3,7 +3,7 @@ use \LAM\TYPES\TypeManager;
/*
* This code is part of LDAP Account Manager (http://www.ldap-account-manager.org/)
* Copyright (C) 2017 Lars Althof
* 2017 Roland Gruber
* 2017 - 2019 Roland Gruber
*
* 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
@ -559,12 +559,12 @@ class courierMailAccount extends baseModule {
// profile mappings in meta data
parent::load_profile($profile);
// add extension
if (isset($profile['courierMailAccount_addExt'][0]) && ($profile['courierMailAccount_addExt'][0] == "true")) {
if (!in_array('courierMailAccount', $this->attributes['objectClass'])) {
if (isset($profile['courierMailAccount_addExt'][0])
&& ($profile['courierMailAccount_addExt'][0] == "true")
&& !in_array('courierMailAccount', $this->attributes['objectClass'])) {
$this->attributes['objectClass'][] = 'courierMailAccount';
}
}
}
/**
* 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
*/
private function isUnixDisabled($modules) {
if (in_array('posixAccount', $modules)) {
return false;
}
else {
return true;
}
return !in_array('posixAccount', $modules);
}
}

View File

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

View File

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

View File

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

View File

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

View File

@ -312,13 +312,13 @@ function showConfirmationDialog(title, okText, cancelText, dialogDiv, formName,
jQuery('#' + dialogDiv).dialog('close');
if (resultField) {
jQuery('#' + resultField).val('ok');
};
}
appendDialogInputsToFormAndSubmit(dialogDiv, formName);
};
buttonList[cancelText] = function() {
if (resultField) {
jQuery('#' + resultField).val('cancel');
};
}
jQuery(this).dialog("close");
};
jQuery('#' + dialogDiv).dialog({
@ -375,7 +375,7 @@ function equalWidth(elementIDs) {
for (var i = 0; i < elementIDs.length; ++i) {
if (jQuery(elementIDs[i]).width() > maxWidth) {
maxWidth = jQuery(elementIDs[i]).width();
};
}
}
if (maxWidth < 5) {
// 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) {
if (jQuery(elementIDs[i]).height() > max) {
max = jQuery(elementIDs[i]).height();
};
}
}
for (var i = 0; i < elementIDs.length; ++i) {
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() {
if (jQuery(this).height() > maxHeight) {
maxHeight = jQuery(this).height();
};
}
});
jQuery('.lamEqualHeightTabContent').each(function() {
jQuery(this).css({'height': maxHeight});