$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. $optionskeys = array_keys($options);