upload post actions only for active modules

This commit is contained in:
Roland Gruber 2010-02-16 17:32:48 +00:00
parent 915bef996e
commit 84e5b750cb
3 changed files with 10 additions and 4 deletions

View File

@ -479,6 +479,7 @@ function buildUploadAccounts($scope, $data, $ids, $selectedModules) {
* @param array $data array containing one account in each element * @param array $data array containing one account in each element
* @param array $ids array(<column_name> => <column number>) * @param array $ids array(<column_name> => <column number>)
* @param array $failed list of accounts which were not created successfully * @param array $failed list of accounts which were not created successfully
* @param array $selectedModules list of selected account modules
* @return array current status * @return array current status
* <br> array ( * <br> array (
* <br> 'status' => 'finished' | 'inProgress' * <br> 'status' => 'finished' | 'inProgress'
@ -487,11 +488,11 @@ function buildUploadAccounts($scope, $data, $ids, $selectedModules) {
* <br> 'errors' => array (<array of parameters for StatusMessage>) * <br> 'errors' => array (<array of parameters for StatusMessage>)
* <br> ) * <br> )
*/ */
function doUploadPostActions($scope, $data, $ids, $failed) { function doUploadPostActions($scope, $data, $ids, $failed, $selectedModules) {
// check if function is called the first time // check if function is called the first time
if (! isset($_SESSION['mass_postActions']['remainingModules'])) { if (! isset($_SESSION['mass_postActions']['remainingModules'])) {
// make list of remaining modules // make list of remaining modules
$moduleList = $_SESSION['config']->get_AccountModules($scope); $moduleList = $selectedModules;
$_SESSION['mass_postActions']['remainingModules'] = $moduleList; $_SESSION['mass_postActions']['remainingModules'] = $moduleList;
} }
$activeModule = $_SESSION['mass_postActions']['remainingModules'][0]; $activeModule = $_SESSION['mass_postActions']['remainingModules'][0];

View File

@ -189,6 +189,7 @@ if ($_FILES['inputfile'] && ($_FILES['inputfile']['size'] > 0)) {
$_SESSION['mass_data'] = $_SESSION['ldap']->encrypt(serialize($data)); $_SESSION['mass_data'] = $_SESSION['ldap']->encrypt(serialize($data));
$_SESSION['mass_ids'] = $ids; $_SESSION['mass_ids'] = $ids;
$_SESSION['mass_scope'] = $_POST['scope']; $_SESSION['mass_scope'] = $_POST['scope'];
$_SESSION['mass_selectedModules'] = $selectedModules;
// show links for upload and LDIF export // show links for upload and LDIF export
echo "<h1 align=\"center\">" . _("LAM has checked your input and is now ready to create the accounts.") . "</h1>\n"; echo "<h1 align=\"center\">" . _("LAM has checked your input and is now ready to create the accounts.") . "</h1>\n";
echo "<p>&nbsp;</p>\n"; echo "<p>&nbsp;</p>\n";
@ -206,6 +207,10 @@ if ($_FILES['inputfile'] && ($_FILES['inputfile']['size'] > 0)) {
} }
} }
} }
else {
StatusMessage('ERROR', _('Please provide a file to upload.'));
echo '<br><a href="masscreate.php">' . _('Back') . '</a>';
}
echo "</body>\n"; echo "</body>\n";
echo "</html>\n"; echo "</html>\n";

View File

@ -94,7 +94,7 @@ if (($_SESSION['mass_counter'] < sizeof($accounts)) || !isset($_SESSION['mass_po
// do post upload actions // do post upload actions
if ($_SESSION['mass_counter'] >= sizeof($accounts)) { if ($_SESSION['mass_counter'] >= sizeof($accounts)) {
$data = unserialize($_SESSION['ldap']->decrypt($_SESSION['mass_data'])); $data = unserialize($_SESSION['ldap']->decrypt($_SESSION['mass_data']));
$return = doUploadPostActions($_SESSION['mass_scope'], $data, $_SESSION['mass_ids'], $_SESSION['mass_failed']); $return = doUploadPostActions($_SESSION['mass_scope'], $data, $_SESSION['mass_ids'], $_SESSION['mass_failed'], $_SESSION['mass_selectedModules']);
if ($return['status'] == 'finished') { if ($return['status'] == 'finished') {
$_SESSION['mass_postActions']['finished'] = true; $_SESSION['mass_postActions']['finished'] = true;
} }
@ -106,7 +106,7 @@ if (($_SESSION['mass_counter'] < sizeof($accounts)) || !isset($_SESSION['mass_po
echo "</table>"; echo "</table>";
flush(); flush();
while (!isset($_SESSION['mass_postActions']['finished']) && (($startTime + $maxTime) > time())) { while (!isset($_SESSION['mass_postActions']['finished']) && (($startTime + $maxTime) > time())) {
$return = doUploadPostActions($_SESSION['mass_scope'], $data, $_SESSION['mass_ids'], $_SESSION['mass_failed']); $return = doUploadPostActions($_SESSION['mass_scope'], $data, $_SESSION['mass_ids'], $_SESSION['mass_failed'], $_SESSION['mass_selectedModules']);
if ($return['status'] == 'finished') { if ($return['status'] == 'finished') {
$_SESSION['mass_postActions']['finished'] = true; $_SESSION['mass_postActions']['finished'] = true;
} }