From cea3fdd67bf7d77610d303f5b603674272578cef Mon Sep 17 00:00:00 2001 From: Roland Gruber Date: Thu, 16 Dec 2010 17:59:04 +0000 Subject: [PATCH] fixed homedir creation on file upload --- lam/HISTORY | 3 ++- lam/lib/baseModule.inc | 3 ++- lam/lib/modules.inc | 5 +++-- lam/lib/modules/posixAccount.inc | 17 +++++++++++++++-- lam/lib/modules/quota.inc | 3 ++- lam/templates/massDoUpload.php | 4 ++-- 6 files changed, 26 insertions(+), 9 deletions(-) diff --git a/lam/HISTORY b/lam/HISTORY index 1af13e75..989b7550 100644 --- a/lam/HISTORY +++ b/lam/HISTORY @@ -1,10 +1,11 @@ -December 2010 3.3.0 +January 2011 3.3.0 - additional usability enhancements - new IMAP module ("Mailbox (imapAccess)") allows to create/delete user mailboxes - PDF export: higher resolution for logos - reduced number of LDAP queries - fixed bugs: -> ignore comment lines in shells file (3107124) + -> home directory creation on file upload 28.10.2010 3.2.0 diff --git a/lam/lib/baseModule.inc b/lam/lib/baseModule.inc index 2889d3e5..fd258c31 100644 --- a/lam/lib/baseModule.inc +++ b/lam/lib/baseModule.inc @@ -989,6 +989,7 @@ abstract class baseModule { * @param array $ids maps the column names to keys for the sub arrays (array( => )) * @param array $failed list of account numbers which could not be successfully uploaded to LDAP * @param array $temp variable to store temporary data between two post actions + * @param array $accounts list of LDAP entries * @return array current status *
array ( *
'status' => 'finished' | 'inProgress' // defines if all operations are complete @@ -996,7 +997,7 @@ abstract class baseModule { *
'errors' => array // list of arrays which are used to generate StatusMessages *
) */ - public function doUploadPostActions($data, $ids, $failed, &$temp) { + public function doUploadPostActions(&$data, $ids, $failed, &$temp, &$accounts) { return array( 'status' => 'finished', 'progress' => 100, diff --git a/lam/lib/modules.inc b/lam/lib/modules.inc index f181b801..dad04bf3 100644 --- a/lam/lib/modules.inc +++ b/lam/lib/modules.inc @@ -492,6 +492,7 @@ function buildUploadAccounts($scope, $data, $ids, $selectedModules) { * @param array $ids array( => ) * @param array $failed list of accounts which were not created successfully * @param array $selectedModules list of selected account modules +* @param array $accounts list of LDAP entries * @return array current status *
array ( *
'status' => 'finished' | 'inProgress' @@ -500,7 +501,7 @@ function buildUploadAccounts($scope, $data, $ids, $selectedModules) { *
'errors' => array () *
) */ -function doUploadPostActions($scope, $data, $ids, $failed, $selectedModules) { +function doUploadPostActions($scope, &$data, $ids, $failed, $selectedModules, &$accounts) { // check if function is called the first time if (! isset($_SESSION['mass_postActions']['remainingModules'])) { // make list of remaining modules @@ -514,7 +515,7 @@ function doUploadPostActions($scope, $data, $ids, $failed, $selectedModules) { } // let first module do one post action $module = new $activeModule($scope); - $return = $module->doUploadPostActions($data, $ids, $failed, $_SESSION['mass_postActions'][$activeModule]); + $return = $module->doUploadPostActions($data, $ids, $failed, $_SESSION['mass_postActions'][$activeModule], $accounts); // remove active module from list if already finished if ($return['status'] == 'finished') { unset($_SESSION['mass_postActions']['remainingModules'][0]); diff --git a/lam/lib/modules/posixAccount.inc b/lam/lib/modules/posixAccount.inc index f7d46457..0fc10d7f 100644 --- a/lam/lib/modules/posixAccount.inc +++ b/lam/lib/modules/posixAccount.inc @@ -1468,6 +1468,7 @@ class posixAccount extends baseModule implements passwordService { * @param array $ids array( => ) * @param array $failed list of accounts which were not created successfully * @param array $temp variable to store temporary data between two post actions + * @param array $accounts list of LDAP entries * @return array current status *
array ( *
'status' => 'finished' | 'inProgress' @@ -1475,7 +1476,7 @@ class posixAccount extends baseModule implements passwordService { *
'errors' => array () *
) */ - function doUploadPostActions($data, $ids, $failed, &$temp) { + function doUploadPostActions(&$data, $ids, $failed, &$temp, &$accounts) { if (!checkIfWriteAccessIsAllowed()) { die(); } @@ -1569,7 +1570,19 @@ class posixAccount extends baseModule implements passwordService { // create home directories elseif ($temp['counter'] < (sizeof($temp['groups']) + sizeof($temp['createHomes']))) { $pos = $temp['createHomes'][$temp['counter'] - sizeof($temp['groups'])]; - $result = lamdaemon(implode(posixAccount::$SPLIT_DELIMITER, array($data[$pos][$ids['posixAccount_userName']], "home", "add", "0".$_SESSION['config']->get_scriptRights())), + $result = lamdaemon( + implode( + posixAccount::$SPLIT_DELIMITER, + array( + $data[$pos][$ids['posixAccount_userName']], + "home", + "add", + $accounts[$pos]['homeDirectory'], + "0".$_SESSION['config']->get_scriptRights(), + $accounts[$pos]['uidNumber'], + $accounts[$pos]['gidNumber'], + ) + ), $data[$pos][$ids['posixAccount_createHomeDir']]); $errors = array(); if (($result != false) && (sizeof($result) == 1)) { diff --git a/lam/lib/modules/quota.inc b/lam/lib/modules/quota.inc index 44aba381..2823c81c 100644 --- a/lam/lib/modules/quota.inc +++ b/lam/lib/modules/quota.inc @@ -688,6 +688,7 @@ class quota extends baseModule { * @param array $ids array( => ) * @param array $failed list of accounts which were not created successfully * @param array $temp variable to store temporary data between two post actions + * @param array $accounts list of LDAP entries * @return array current status *
array ( *
'status' => 'finished' | 'inProgress' @@ -695,7 +696,7 @@ class quota extends baseModule { *
'errors' => array () *
) */ - function doUploadPostActions($data, $ids, $failed, &$temp) { + function doUploadPostActions(&$data, $ids, $failed, &$temp, &$accounts) { $errors = array(); // first call, get list of user names and quota values if (!isset($temp['counter'])) { diff --git a/lam/templates/massDoUpload.php b/lam/templates/massDoUpload.php index 743cab6d..7e98eb5a 100644 --- a/lam/templates/massDoUpload.php +++ b/lam/templates/massDoUpload.php @@ -95,7 +95,7 @@ if (($_SESSION['mass_counter'] < sizeof($accounts)) || !isset($_SESSION['mass_po // do post upload actions if ($_SESSION['mass_counter'] >= sizeof($accounts)) { $data = unserialize($_SESSION['ldap']->decrypt($_SESSION['mass_data'])); - $return = doUploadPostActions($_SESSION['mass_scope'], $data, $_SESSION['mass_ids'], $_SESSION['mass_failed'], $_SESSION['mass_selectedModules']); + $return = doUploadPostActions($_SESSION['mass_scope'], $data, $_SESSION['mass_ids'], $_SESSION['mass_failed'], $_SESSION['mass_selectedModules'], $accounts); if ($return['status'] == 'finished') { $_SESSION['mass_postActions']['finished'] = true; } @@ -107,7 +107,7 @@ if (($_SESSION['mass_counter'] < sizeof($accounts)) || !isset($_SESSION['mass_po echo ""; flush(); while (!isset($_SESSION['mass_postActions']['finished']) && (($startTime + $maxTime) > time())) { - $return = doUploadPostActions($_SESSION['mass_scope'], $data, $_SESSION['mass_ids'], $_SESSION['mass_failed'], $_SESSION['mass_selectedModules']); + $return = doUploadPostActions($_SESSION['mass_scope'], $data, $_SESSION['mass_ids'], $_SESSION['mass_failed'], $_SESSION['mass_selectedModules'], $accounts); if ($return['status'] == 'finished') { $_SESSION['mass_postActions']['finished'] = true; }