Example #1
0
    $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);
    if (empty($options)) {
        throw new portfolio_export_exception($exporter, 'noavailableplugins', 'portfolio');
    } else {
        if (count($options) == 1) {
            // no point displaying a form, just redirect.
Example #2
0
    }
    // for build navigation
    if (!($course = $caller->get('course'))) {
        $course = $courseid;
    }
    // set up the course so that build_navigation works nice
    $PAGE->set_course($course);
    // and now we know the course for sure, call require_login with it
    require_login($course);
    list($extranav, $cm) = $caller->get_navigation();
    $extranav[] = array('type' => 'title', 'name' => get_string('exporting', 'portfolio'));
    $navigation = build_navigation($extranav, $cm);
    // finally! set up the exporter object with the portfolio instance, caller information, and navigation elements
    $exporter = new portfolio_exporter($instance, $caller, $callbackfile, $navigation);
    // set the export-specific variables, and save.
    $exporter->set('user', $USER);
    $exporter->set('sesskey', sesskey());
    $exporter->save();
    // and finally, put it in the session for waking up again later.
    $SESSION->portfolioexport = $exporter->get('id');
}
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.
    $mform = new portfolio_instance_select('', array('caller' => $exporter->get('caller')));
    if ($mform->is_cancelled()) {
        $exporter->cancel_request();
    } else {
        if ($fromform = $mform->get_data()) {