Commit ea4826db authored by Dianne Tennent's avatar Dianne Tennent Committed by Robert Lyon
Browse files

Bug 1968939: 'Archived submissions' export CSV

Add columns filetitle, filepath and filename that were
removed accidentally.

Change-Id: I4fa8b18cd8fa5f191806155c34060155d1d0e26d
(cherry picked from commit cbe27267)
(cherry picked from commit a6a130fe)
parent f98dd60c
Loading
Loading
Loading
Loading
+3 −7
Original line number Diff line number Diff line
@@ -40,7 +40,6 @@ if (!empty($search->institution)) {
}

$results = get_admin_user_search_results($search, 0, 0);
$archivedflag = false;
if (!empty($results['data'])) {
    foreach ($results['data'] as $key => $data) {
        $primaryemail = '';
@@ -55,21 +54,18 @@ if (!empty($results['data'])) {

        // convert archivectime to human readable and sortable format
        if (!empty($results['data'][$key]['archivectime'])) {
            $archivedflag = true;
            $results['data'][$key]['archivectime'] = date("Y-m-d H:i:s", $results['data'][$key]['archivectime']);
        }
    }
}

if (!empty($results['data'])) {
    $csvfields = array('username', 'email', 'firstname', 'lastname', 'preferredname', 'submittedto', 'specialid');

    if ($archivedflag) {
        $csvfields[] = 'archivectime';
    if ($search->archivedsubmissions) {
        $csvfields = array('username', 'email', 'firstname', 'lastname', 'preferredname', 'submittedto', 'specialid', 'filetitle', 'filepath', 'filename', 'archivectime');
        $USER->set_download_file(generate_csv($results['data'], $csvfields), 'archivedsubmissions.csv', 'text/csv');
    }
    else {
        $csvfields[] = 'submittedtime';
        $csvfields = array('username', 'email', 'firstname', 'lastname', 'preferredname', 'submittedto', 'specialid', 'submittedtime');
        $USER->set_download_file(generate_csv($results['data'], $csvfields), 'currentsubmissions.csv', 'text/csv');
    }