/** * Provides a default report instance used to display a report * (report is not a pre-configured instance) * * @param string $shortname Shortname of the report to be obtained * @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 php_report|boolean A new report instance of the specified type, or FALSE * if user doesn't have sufficient permissions */ static function get_default_instance($shortname, $userid = NULL, $execution_mode = php_report::EXECUTION_MODE_INTERACTIVE) { global $CFG; //get the name of the file containing the report definition $filename = php_report::get_report_filename($shortname); if (!file_exists($filename)) { //could not find the report definition return FALSE; } //load report definition require_once $filename; //create report instance $classname = $shortname . '_report'; //report "id" is actually the shortname because we are not //within a block instance $instance = new $classname($shortname, $userid, $execution_mode); if (!$instance->is_available()) { //necessary components for running this report are not installed return FALSE; } if (!$instance->can_view_report()) { //user doesn't have sufficient permissions return FALSE; } $instance->require_dependencies(); return $instance; }