function definition_after_data() { global $CFG, $DB, $OUTPUT; $mform = $this->_form; $reportid = $mform->getElementValue('config_reportlist'); if (isset($reportid) && $reportid[0]) { if (!$report = $DB->get_record('block_cobalt_reports', array('id' => $reportid[0]))) print_error('reportdoesnotexists', 'block_cobalt_reports'); require_once($CFG->dirroot . '/blocks/cobalt_reports/reports/' . $report->type . '/report.class.php'); require_once($CFG->dirroot . '/blocks/cobalt_reports/locallib.php'); $reportcontenttypes = cr_listof_reporttypes($reportid[0]); $reportcontenttype = $mform->createElement('select', 'config_reportcontenttype', get_string('reportcontenttype', 'block_reportdashboard'), $reportcontenttypes); $mform->insertElementBefore($reportcontenttype, 'reportcontenttype'); } }
function get_content() { global $CFG, $DB, $PAGE; require_once($CFG->libdir . '/filelib.php'); require_once($CFG->dirroot . '/blocks/cobalt_reports/report.class.php'); require_once($CFG->dirroot . '/blocks/cobalt_reports/locallib.php'); if ($this->content !== NULL) { return $this->content; } $filteropt = new stdClass; $filteropt->overflowdiv = true; if ($this->content_is_trusted()) { // fancy reportdashboard allowed only on course, category and system blocks. $filteropt->noclean = true; } $this->content = new stdClass; $this->content->footer = ''; $this->content->text = ""; if (isset($this->config->reportlist)) { $reportid = $this->config->reportlist; $reportclass = create_reportclass($reportid); $components = cr_unserialize($reportclass->config->components); $reportcontenttypes = cr_listof_reporttypes($this->config->reportlist); $blockinstanceid = $this->instance->id; $this->content->text .= html_writer::select($reportcontenttypes, 'report', $this->config->reportcontenttype, false, array('id' => 'reporttype_' . $this->instance->id . '', 'onchange' => "generate_report(\"reporttype_\",$reportid,\"reportcontainer\",$blockinstanceid,\"$CFG->wwwroot\")")); $this->content->text .= html_writer::start_tag('div', array('id' => 'reportcontainer' . $this->instance->id . '')); $report = cr_get_reportinstance($this->config->reportlist); if (isset($report) && !$report->global) { $this->content->text .= ''; } elseif (isset($this->config->reportlist)) { $renderer = $this->page->get_renderer('block_reportdashboard'); $this->content->text .= $renderer->generate_dashboardreport($reportclass, $this->config->reportcontenttype, $blockinstanceid); } $this->content->text .=html_writer::end_tag('div'); $link_url = new moodle_url('/blocks/cobalt_reports/viewreport.php', array('id'=>$reportid, 'courseid' => 1)); $link = html_writer::link($link_url, html_writer::span(get_string('viewmore'), '', array('id'=>'reportdashboard_right'))); $this->content->text .=$link; } else { $this->content->text .= ''; } unset($filteropt); // memory footprint return $this->content; }