fix for file upload

This commit is contained in:
Roland Gruber 2018-03-04 09:37:32 +01:00
parent f9e6247158
commit 1a37568520
2 changed files with 30 additions and 26 deletions

View File

@ -1124,7 +1124,7 @@ class posixAccount extends baseModule implements passwordService {
} }
} }
// id-number is in use and account is a new account // id-number is in use and account is a new account
if ((in_array($this->attributes['uidNumber'][0], $uids)) && !isset($this->orig['uidNumber'][0])) $errors[] = array('ERROR', _('ID-Number'), _('ID is already in use')); if ((in_array($this->attributes['uidNumber'][0], $uids)) && !isset($this->orig['uidNumber'][0])) $errors[] = $this->messages['uidNumber'][3];
// id-number is in use, account is existing account and id-number is not used by itself // id-number is in use, account is existing account and id-number is not used by itself
if ((in_array($this->attributes['uidNumber'][0], $uids)) && isset($this->orig['uidNumber'][0]) && ($this->orig['uidNumber'][0] != $this->attributes['uidNumber'][0]) ) { if ((in_array($this->attributes['uidNumber'][0], $uids)) && isset($this->orig['uidNumber'][0]) && ($this->orig['uidNumber'][0] != $this->attributes['uidNumber'][0]) ) {
$errors[] = $this->messages['uidNumber'][3]; $errors[] = $this->messages['uidNumber'][3];
@ -2155,7 +2155,7 @@ class posixAccount extends baseModule implements passwordService {
)); ));
} }
if (($this->get_scope() == 'user') && !$this->isBooleanConfigOptionSet('posixAccount_' . $typeId . '_hidegecos')) { if (($this->get_scope() == 'user') && !$this->isBooleanConfigOptionSet('posixAccount_' . $typeId . '_hidegecos')) {
$return['upload_columns'][] = array( $return[] = array(
'name' => 'posixAccount_gecos', 'name' => 'posixAccount_gecos',
'description' => _('Gecos'), 'description' => _('Gecos'),
'help' => 'gecos', 'help' => 'gecos',
@ -2163,7 +2163,7 @@ class posixAccount extends baseModule implements passwordService {
); );
} }
if (($this->get_scope() == 'host') && !$this->isBooleanConfigOptionSet('posixAccount_' . $typeId . '_hidegecos')) { if (($this->get_scope() == 'host') && !$this->isBooleanConfigOptionSet('posixAccount_' . $typeId . '_hidegecos')) {
$return['upload_columns'][] = array( $return[] = array(
'name' => 'posixAccount_gecos', 'name' => 'posixAccount_gecos',
'description' => _('Gecos'), 'description' => _('Gecos'),
'help' => 'gecos', 'help' => 'gecos',
@ -2584,29 +2584,34 @@ class posixAccount extends baseModule implements passwordService {
// create home directories // create home directories
elseif ($temp['counter'] < (sizeof($temp['groups']) + sizeof($temp['createHomes']))) { elseif ($temp['counter'] < (sizeof($temp['groups']) + sizeof($temp['createHomes']))) {
$pos = $temp['createHomes'][$temp['counter'] - sizeof($temp['groups'])]; $pos = $temp['createHomes'][$temp['counter'] - sizeof($temp['groups'])];
$remote = new \LAM\REMOTE\Remote(); try {
$remote->connect($data[$pos][$ids['posixAccount_createHomeDir']]); $remote = new \LAM\REMOTE\Remote();
$result = $remote->execute( $remote->connect($data[$pos][$ids['posixAccount_createHomeDir']]);
implode( $result = $remote->execute(
self::$SPLIT_DELIMITER, implode(
array( self::$SPLIT_DELIMITER,
$data[$pos][$ids['posixAccount_userName']], array(
"home", $data[$pos][$ids['posixAccount_userName']],
"add", "home",
$accounts[$pos][$homeDirAttr], "add",
"0".$_SESSION['config']->get_scriptRights(), $accounts[$pos][$homeDirAttr],
$accounts[$pos]['uidNumber'], "0".$_SESSION['config']->get_scriptRights(),
$accounts[$pos]['gidNumber'], $accounts[$pos]['uidNumber'],
) $accounts[$pos]['gidNumber'],
)); )
$remote->disconnect(); ));
$errors = array(); $remote->disconnect();
if (!empty($result)) { $errors = array();
$parts = explode(",", $result); if (!empty($result)) {
if (in_array($parts[0], array('ERROR', 'WARN'))) { $parts = explode(",", $result);
$errors[] = $parts; if (in_array($parts[0], array('ERROR', 'WARN'))) {
$errors[] = $parts;
}
} }
} }
catch (LAMException $e) {
$errors[] = array('ERROR', $e->getTitle(), $e->getMessage());
}
$temp['counter']++; $temp['counter']++;
return array ( return array (
'status' => 'inProgress', 'status' => 'inProgress',

View File

@ -1,10 +1,9 @@
<?php <?php
namespace LAM\AJAX; namespace LAM\AJAX;
/* /*
$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) 2011 - 2017 Roland Gruber Copyright (C) 2011 - 2018 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