// upload.inc written by Matthew Gregg
//
// Bulk upload from text files
/* SuperUser or Designers with "Administer Group Members(pgroup)" permissions only*/
if(($_SESSION['acl']['superuser'] != 'Y' &&
(count($_SESSION['acl']['pgroup']) == 0 &&
count($_SESSION['acl']['puser']) == 0)) &&
!auth_no_access(_('to access this form'))) {
return;
}
$bg1 =& $ESPCONFIG['bgalt_color1'];
$bg2 =& $ESPCONFIG['bgalt_color2'];
if(isset($_GET['account_type'])) {
$account_type = htmlspecialchars($_GET['account_type']);
}
else {
$account_type = "respondents";
}
$errstr = '';
// End the included form so we can do a multipart/form-data form
?>
MoveNext();
array_push($group_acl, $row);
}
db_close($result);
} elseif(count($_SESSION['acl']['pgroup']) > 0) {
$group_acl =& $_SESSION['acl']['pgroup'];
} else {
$group_acl =& $_SESSION['acl']['puser'];
}
if(!empty($upload_type) && !empty($account_type) && is_uploaded_file($upload_file)) {
$file = file($upload_file);
$exceptions = array();
$success = account_upload($exceptions, $upload_type, $account_type, $group_acl, $file);
if($success) {
unset($_POST['account_type']);
unset($_POST['submit']);
include(esp_where("$account_type"));
return;
}
elseif(count($exceptions) > 1) {
$errstr .= mkerror(_('An error occurred during upload. Rows that failed are listed below.'));
$exception_table = ("\n");
$bg = $ESPCONFIG['bgalt_color2'];
$exception_table .= "\n";
/* Build exception rows */
/* Header row*/
while (list(, $col) = each ($exceptions[0])) {
$exception_table .= "| $col | \n";
}
$exception_table .= "
\n";
/* Data rows*/
next($exceptions);
while (list(, $row) = each ($exceptions)) {
if ($bg == $ESPCONFIG['bgalt_color1'])
$bg =& $ESPCONFIG['bgalt_color2'];
else
$bg =& $ESPCONFIG['bgalt_color1'];
$exception_table .= "\n";
foreach($row as $col) {
$exception_table .= "| $col | \n";
}
}
$exception_table .= "
\n
";
}
else {
$errstr .= mkerror(_('An error occurred during upload. Please check the format of your text file.'));
}
}
else {
$errstr .= mkerror(_('An error occurred during upload. Please complete all form fields.'));
}
}
?>
$errstr
\n"); ?>
" onclick="window.open(this.href,'_blank');return false;">
$exception_table\n"); ?>