示例#1
0
文件: add.php 项目: evltuma/moodle
            $callbackargs[substr($key, 3)] = $value;
        }
    }
    // Ensure that we found a file we can use, if not throw an exception.
    portfolio_include_callback_file($callbackcomponent, $callbackclass);
    $caller = new $callbackclass($callbackargs);
    $caller->set('user', $USER);
    if ($formats = explode(',', $callerformats)) {
        $caller->set_formats_from_button($formats);
    }
    $caller->load_data();
    // this must check capabilities and either throw an exception or return false.
    if (!$caller->check_permissions()) {
        throw new portfolio_caller_exception('nopermissions', 'portfolio', $caller->get_return_url());
    }
    portfolio_export_pagesetup($PAGE, $caller);
    // this calls require_login($course) if it can..
    // finally! set up the exporter object with the portfolio instance, and caller information elements
    $exporter = new portfolio_exporter($instance, $caller, $callbackcomponent);
    // set the export-specific variables, and save.
    $exporter->set('user', $USER);
    $exporter->save();
}
if (!$exporter->get('instance')) {
    // we've just arrived but have no instance
    // in this case the exporter object and the caller object have been set up above
    // so just make a little form to select the portfolio plugin instance,
    // which is the last thing to do before starting the export.
    //
    // first check to make sure there is actually a point
    $options = portfolio_instance_select(portfolio_instances(), $exporter->get('caller')->supported_formats(), get_class($exporter->get('caller')), $exporter->get('caller')->get_mimetype(), 'instance', true, true);
示例#2
0
文件: file.php 项目: evltuma/moodle
<?php

// this script is a slightly more user friendly way to 'send' the file to them
// (using portfolio/file.php) but still give them the 'return to where you were' link
// to go back to their assignment, or whatever
require __DIR__ . '/../../config.php';
if (empty($CFG->enableportfolios)) {
    print_error('disabled', 'portfolio');
}
require_once $CFG->libdir . '/portfoliolib.php';
require_once $CFG->libdir . '/portfolio/exporter.php';
$id = required_param('id', PARAM_INT);
$PAGE->set_url('/portfolio/download/file.php', array('id' => $id));
$exporter = portfolio_exporter::rewaken_object($id);
portfolio_export_pagesetup($PAGE, $exporter->get('caller'));
$exporter->verify_rewaken();
$exporter->print_header(get_string('downloading', 'portfolio_download'), false);
$returnurl = $exporter->get('caller')->get_return_url();
echo $OUTPUT->notification('<a href="' . $returnurl . '">' . get_string('returntowhereyouwere', 'portfolio') . '</a><br />');
$PAGE->requires->js('/portfolio/download/helper.js');
$PAGE->requires->js_function_call('submit_download_form', null, true);
// if they don't have javascript, they can submit the form here to get the file.
// if they do, it does it nicely for them.
echo '<div id="redirect">
    <form action="' . $exporter->get('instance')->get_base_file_url() . '" method="post" id="redirectform">
      <input type="submit" value="' . get_string('downloadfile', 'portfolio_download') . '" />
    </form>
';
echo $OUTPUT->footer();
示例#3
0
    // Ensure that we found a file we can use, if not throw an exception.
    portfolio_include_callback_file($callbackcomponent, $callbackclass);

    $caller = new $callbackclass($callbackargs);
    $caller->set('user', $USER);
    if ($formats = explode(',', $callerformats)) {
        $caller->set_formats_from_button($formats);
    }
    $caller->load_data();
    // this must check capabilities and either throw an exception or return false.
    if (!$caller->check_permissions()) {
        throw new portfolio_caller_exception('nopermissions', 'portfolio', $caller->get_return_url());
    }

    portfolio_export_pagesetup($PAGE, $caller); // this calls require_login($course) if it can..

    // finally! set up the exporter object with the portfolio instance, and caller information elements
    $exporter = new portfolio_exporter($instance, $caller, $callbackcomponent);

    // set the export-specific variables, and save.
    $exporter->set('user', $USER);
    $exporter->save();
}

if (!$exporter->get('instance')) {
    // we've just arrived but have no instance
    // in this case the exporter object and the caller object have been set up above
    // so just make a little form to select the portfolio plugin instance,
    // which is the last thing to do before starting the export.
    //