* You should have received a copy of the GNU General Public License * along with this program. If not, see <http://www.gnu.org/licenses/>. * * @package elis * @subpackage curriculummanagement * @author Remote-Learner.net Inc * @license http://www.gnu.org/copyleft/gpl.html GNU GPL * @copyright (C) 2008-2012 Remote Learner.net Inc http://www.remote-learner.net * */ require_once '../../config.php'; require_once $CFG->dirroot . '/blocks/php_report/lib/filtering.php'; //report instance id can be a block instance id //or a general report shortname $id = required_param('id', PARAM_CLEAN); //selected export format $format = required_param('format', PARAM_CLEAN); //load filter classes php_report_filtering_require_dependencies(); $report = php_report::get_default_instance($id); //permissions checking if ($report->can_view_report()) { //NOTE: this is fast because it will not populate filter values $report->init_all($id); //require any necessary report-specific dependencies $report->require_dependencies(); //make sure we have enough resources to export our report php_report::allocate_extra_resources(); //initiate download using sql query without paging $report->download($format, $report->get_complete_sql_query(false)); }
/** * API call for exporting a report execution * * @param string $shortname Shortname of the report to be executed (should be * one of the folder names found in the "instances" directory) * @param string $format The export format (one of the EXPORT_FORMAT_... constants) * @param string $filename Name of the file to write to (including extension) * @param stdClass $parameter_data Submitted parameter form data (in format directly returned by get_data) * @param int|NULL $userid Id of the Moodle user who this report is being * for * @param int $execution_mode The mode in which this report is being executed * * @return boolean true on success, otherwise false */ static function export_default_instance($shortname, $format, $filename, $parameter_data, $userid = NULL, $execution_mode = php_report::EXECUTION_MODE_INTERACTIVE) { //allocate some extra resources php_report::allocate_extra_resources(); //get a default instance $report_instance = php_report::get_default_instance($shortname, $userid, $execution_mode); if ($report_instance == false) { //user no longer has access, so signal failure return false; } $allowable_formats = $report_instance->get_export_formats(); if (!in_array($format, $allowable_formats)) { //specified format is not allowed return; } //make sure all dependencies are loaded $report_instance->require_dependencies(); //initialize all necessary data $report_instance->init_all($shortname, $parameter_data); //run the export $report_instance->download($format, $report_instance->get_complete_sql_query(FALSE), $filename); return true; }