コード例 #1
0
        $exporter = new $class($user, $exportdata['views'], PluginExport::EXPORT_COLLECTIONS, 'export_iframe_progress_handler');
        break;
    default:
        export_iframe_die(get_string('unabletoexportportfoliousingoptions', 'export'));
}
$exporter->includefeedback = $exportdata['includefeedback'];
// Get an estimate of how big the unzipped export file would be
// so we can check that we have enough disk space for it
$space = $exporter->is_diskspace_available();
if (!$space) {
    export_iframe_die(get_string('exportfiletoobig', 'mahara'), get_config('wwwroot') . 'view/index.php');
}
try {
    $zipfile = $exporter->export();
} catch (SystemException $e) {
    export_iframe_die($e->getMessage(), get_config('wwwroot') . 'view/index.php');
}
// Store the filename in the session, and redirect the iframe to it to trigger
// the download. Here it would be nice to trigger the download for everyone,
// but alas this is not possible for people without javascript.
$SESSION->set('exportfile', $exporter->get('exportdir') . $zipfile);
$continueurl = 'download.php';
$continueurljs = get_config('wwwroot') . 'export/index.php';
$result = $SESSION->get('messages');
if (empty($result)) {
    $strexport = get_string('exportgeneratedsuccessfully1', 'export');
} else {
    $SESSION->clear('messages');
    $strexport = get_string('exportgeneratedwitherrors', 'export');
}
print_export_footer($strexport, $continueurl, $continueurljs, $result, 'download.php');
コード例 #2
0
    $percentage = min($percentage, 98);
    export_iframe_progress_handler($percentage, get_string('exportingusername', 'admin', $username));
    $exporter = new PluginExportLeap($user, PluginExport::EXPORT_ALL_VIEWS, PluginExport::EXPORT_ALL_ARTEFACTS);
    try {
        $zipfile = $exporter->export();
    } catch (Exception $e) {
        $exporterrors[] = $username;
        continue;
    }
    $listing[] = array($username, $zipfile);
    $files[] = $exporter->get('exportdir') . $zipfile;
    $exportcount++;
}
export_iframe_progress_handler(99, get_string('creatingzipfile', 'export'));
if (!($zipfile = create_zipfile($listing, $files))) {
    export_iframe_die(get_string('bulkexportempty', 'admin'));
}
export_iframe_progress_handler(100, get_string('Done', 'export'));
ob_end_flush();
log_info("Exported {$exportcount} users to {$zipfile}");
if (!empty($exporterrors)) {
    $SESSION->add_error_msg(get_string('couldnotexportusers', 'admin', implode(', ', $exporterrors)));
}
// Store the filename in the session, and redirect the iframe to it to trigger
// the download. Here it would be nice to trigger the download for everyone,
// but alas this is not possible for people without javascript.
$SESSION->set('exportfile', $zipfile);
$wwwroot = get_config('wwwroot');
$strexportgeneratedsuccessfullyjs = get_string('exportgeneratedsuccessfullyjs', 'export', '<a href="' . $wwwroot . '" target="_top">', '</a>');
$strexportgeneratedsuccessfully = get_string('exportgeneratedsuccessfully', 'export', '<a href="bulkdownload.php" target="_top">', '</a>');
print_export_footer($strexportgeneratedsuccessfully, $strexportgeneratedsuccessfullyjs);
コード例 #3
0
ファイル: bulkexport.php プロジェクト: sarahjcotton/mahara
function bulkexport_submit(Pieform $form, $values)
{
    global $SESSION;
    $usernames = array();
    // Read in the usernames explicitly specified
    foreach (explode("\n", $values['usernames']) as $username) {
        $username = trim($username);
        if (!empty($username)) {
            $usernames[] = $username;
        }
    }
    if (empty($usernames) and !empty($values['authinstance'])) {
        // Export all users from the selected institution
        $rs = get_recordset_select('usr', 'authinstance = ? AND deleted = 0', array($values['authinstance']), '', 'username');
        while ($record = $rs->FetchRow()) {
            $usernames[] = $record['username'];
        }
    }
    safe_require('export', 'leap');
    $listing = array();
    $files = array();
    $exportcount = 0;
    $exporterrors = array();
    $num_users = count($usernames);
    foreach ($usernames as $username) {
        if (!($exportcount % 25)) {
            set_progress_info('bulkexport', $exportcount, $num_users, get_string('validating', 'admin'));
        }
        $user = new User();
        try {
            $user->find_by_username($username);
        } catch (AuthUnknownUserException $e) {
            continue;
            // Skip non-existent users
        }
        $exporter = new PluginExportLeap($user, PluginExport::EXPORT_ALL_VIEWS_COLLECTIONS, PluginExport::EXPORT_ALL_ARTEFACTS);
        try {
            $zipfile = $exporter->export();
        } catch (Exception $e) {
            $exporterrors[] = $username;
            continue;
        }
        $listing[] = array($username, $zipfile);
        $files[] = $exporter->get('exportdir') . $zipfile;
        $exportcount++;
    }
    if (!($zipfile = create_zipfile($listing, $files))) {
        export_iframe_die(get_string('bulkexportempty', 'admin'));
    }
    log_info("Exported {$exportcount} users to {$zipfile}");
    if (!empty($exporterrors)) {
        $SESSION->add_error_msg(get_string('couldnotexportusers', 'admin', implode(', ', $exporterrors)));
    }
    // Store the filename in the session, and redirect the iframe to it to trigger
    // the download. Here it would be nice to trigger the download for everyone,
    // but alas this is not possible for people without javascript.
    $SESSION->set('exportfile', $zipfile);
    set_progress_done('bulkexport', array('redirect' => get_config('wwwroot') . 'admin/users/bulkexport.php'));
    // Download the export file once it has been generated
    require_once 'file.php';
    serve_file($zipfile, basename($zipfile), 'application/x-zip', array('lifetime' => 0, 'forcedownload' => true));
    // TODO: delete the zipfile (and temporary files) once it's been downloaded
}
コード例 #4
0
    print_iframe_progress_handler($percent, $status);
    flush();
}
// Bail if we don't have enough data to do an export
if (!isset($exportdata['format']) || !isset($exportdata['what']) || !isset($exportdata['views'])) {
    export_iframe_die(get_string('unabletogenerateexport', 'export'));
    exit;
}
safe_require('export', $exportdata['format']);
$user = new User();
$user->find_by_id($USER->get('id'));
$class = generate_class_name('export', $exportdata['format']);
switch ($exportdata['what']) {
    case 'all':
        $exporter = new $class($user, PluginExport::EXPORT_ALL_VIEWS, PluginExport::EXPORT_ALL_ARTEFACTS, 'export_iframe_progress_handler');
        break;
    case 'views':
        $exporter = new $class($user, $exportdata['views'], PluginExport::EXPORT_ARTEFACTS_FOR_VIEWS, 'export_iframe_progress_handler');
        break;
    default:
        export_iframe_die(get_string('unabletoexportportfoliousingoptions', 'export'));
}
$zipfile = $exporter->export();
// Store the filename in the session, and redirect the iframe to it to trigger
// the download. Here it would be nice to trigger the download for everyone,
// but alas this is not possible for people without javascript.
$SESSION->set('exportfile', $exporter->get('exportdir') . $zipfile);
$wwwroot = get_config('wwwroot');
$strexportgeneratedsuccessfullyjs = get_string('exportgeneratedsuccessfullyjs', 'export', '<a href="' . $wwwroot . 'export/" target="_top">', '</a>');
$strexportgeneratedsuccessfully = get_string('exportgeneratedsuccessfully', 'export', '<a href="download.php" target="_top">', '</a>');
print_export_footer($strexportgeneratedsuccessfully, $strexportgeneratedsuccessfullyjs);