Exemplo n.º 1
0
        $data->visible = 1;
        $data->components = '';

        // extra check
        if ($data->type == 'sql' && !has_capability('block/cobalt_reports:managesqlreports', $context))
            print_error('nosqlpermissions');

        if (!$lastid = $DB->insert_record('block_cobalt_reports', $data)) {
            print_error('errorsavingreport', 'block_cobalt_reports');
        } else {
            cr_add_to_log($courseid, 'cobalt_reports', 'report created', '/block/cobalt_reports/editreport.php?id=' . $lastid, $data->name);
            $reportclass = new $reportclassname($lastid);
            redirect($CFG->wwwroot . '/blocks/cobalt_reports/editcomp.php?id=' . $lastid . '&comp=' . $reportclass->components[0]);
        }
    } else {
        cr_add_to_log($report->courseid, 'cobalt_reports', 'edit', '/block/cobalt_reports/editreport.php?id=' . $id, $report->name);
        $reportclass = new $reportclassname($data->id);
        $data->type = $report->type;

        if (!$DB->update_record('block_cobalt_reports', $data)) {
            print_error('errorsavingreport', 'block_cobalt_reports');
        } else {
            redirect($CFG->wwwroot . '/blocks/cobalt_reports/editcomp.php?id=' . $data->id . '&comp=' . $reportclass->components[0]);
        }
    }
}


$PAGE->set_context($context);

Exemplo n.º 2
0
    $context = context_course::instance($course->id);
}
require_once $CFG->dirroot . '/blocks/configurable_reports/report.class.php';
require_once $CFG->dirroot . '/blocks/configurable_reports/reports/' . $report->type . '/report.class.php';
$reportclassname = 'report_' . $report->type;
$reportclass = new $reportclassname($report);
if (!$reportclass->check_permissions($USER->id, $context)) {
    print_error("badpermissions", 'block_configurable_reports');
}
$PAGE->set_context($context);
$PAGE->set_pagelayout('incourse');
$PAGE->set_url('/blocks/configurable_reports/viewreport.php', array('id' => $id));
$reportclass->create_report();
$download = $download && $format && strpos($report->export, $format . ',') !== false ? true : false;
$action = $download ? 'download' : 'view';
cr_add_to_log($report->courseid, 'configurable_reports', $action, '/block/configurable_reports/viewreport.php?id=' . $id, $report->name);
// No download, build navigation header etc..
if (!$download) {
    $reportclass->check_filters_request();
    $reportname = format_string($report->name);
    $navlinks = array();
    if (has_capability('block/configurable_reports:managereports', $context) || has_capability('block/configurable_reports:manageownreports', $context) && $report->ownerid == $USER->id) {
        //$courseurl =  new moodle_url($CFG->wwwroot.'/course/view.php',array('id'=>$report->courseid));
        //$PAGE->navbar->add($COURSE->shortname, $courseurl);
        $managereporturl = new moodle_url($CFG->wwwroot . '/blocks/configurable_reports/managereport.php', array('courseid' => $report->courseid));
        $PAGE->navbar->add(get_string('managereports', 'block_configurable_reports'), $managereporturl);
        $PAGE->navbar->add($report->name);
    }
    $PAGE->set_title($reportname);
    $PAGE->set_heading($reportname);
    $PAGE->set_cacheable(true);
Exemplo n.º 3
0
    /**
     * @method Process Scheduled reports
     *
     */
    function process_scheduled_reports() {
        global $CFG, $DB;

        require_once($CFG->dirroot . '/calendar/lib.php');

        $sql = "SELECT crs.*, cr.name, u.timezone
            FROM {block_cobaltreports_schedule} crs
            JOIN {block_cobalt_reports} cr
            ON crs.reportid = cr.id
            JOIN {user} u
            ON crs.userid = u.id";

        $scheduledreports = $DB->get_records_sql($sql);

        mtrace('Processing ' . count($scheduledreports) . ' scheduled reports');

        foreach ($scheduledreports as $report) {
            $reportname = $report->name;

            //if ($this->is_time($report->nextschedule)) {
            $report->nextschedule = $this->next($report);

            if (get_config('block_cobalt_reports', 'exportfilesystem') == 0) {
                $exporttofilesystem = REPORT_EMAIL;
            } else {
                $exporttofilesystem = $report->exporttofilesystem;
            }

            switch ($exporttofilesystem) {
                case REPORT_EXPORT_AND_EMAIL:
                    mtrace('ReportID:(' . $report->id . ') Option: Email and save scheduled report to file.');
                    break;
                case REPORT_EXPORT:
                    mtrace('ReportID:(' . $report->id . ') Option: Save scheduled report to file system only.');
                    break;
                default:
                    mtrace('ReportID:(' . $report->id . ') Option: Email scheduled report.');
            }

            //Send email
            if ($this->scheduledreport_send_scheduled_report($report)) {
                mtrace('Sent email for report ' . $report->id);
            } else if ($exporttofilesystem == REPORT_EXPORT) {
                mtrace('No scheduled report email has been send');
            } else {
                mtrace('Failed to send email for report ' . $report->id);
            }
            cr_add_to_log(SITEID, 'block_cobalt_reports', 'dailyreport', null, "$reportname (ID $report->id)");

            if (!$DB->update_record('block_cobaltreports_schedule', $report)) {
                mtrace('Failed to update next report field for scheduled report id:' . $report->id);
            }
        }
    }
Exemplo n.º 4
0
$elements = isset($elements[$comp]['elements']) ? $elements[$comp]['elements'] : array();

require_once($CFG->dirroot . '/blocks/cobalt_reports/components/' . $comp . '/component.class.php');
$componentclassname = 'component_' . $comp;
$compclass = new $componentclassname($report->id);

if ($compclass->form) {
    require_once($CFG->dirroot . '/blocks/cobalt_reports/components/' . $comp . '/form.php');
    $classname = $comp . '_form';
    $editform = new $classname('editcomp.php?id=' . $id . '&comp=' . $comp, compact('compclass', 'comp', 'id', 'report', 'reportclass', 'elements'));

    if ($editform->is_cancelled()) {
        redirect($CFG->wwwroot . '/blocks/cobalt_reports/editcomp.php?id=' . $id . '&comp=' . $comp);
    } else if ($data = $editform->get_data()) {
        $compclass->form_process_data($editform);
        cr_add_to_log($courseid, 'cobalt_reports', 'edit', '', $report->name);
    }

    $compclass->form_set_data($editform);
}

if ($compclass->plugins) {
    $currentplugins = array();
    if ($elements) {
        foreach ($elements as $e) {
            $currentplugins[] = $e['pluginname'];
        }
    }
    $plugins = get_list_of_plugins('blocks/cobalt_reports/components/' . $comp);
    $optionsplugins = array();
Exemplo n.º 5
0
}
$elements = cr_unserialize($report->components);
$elements = isset($elements[$comp]['elements']) ? $elements[$comp]['elements'] : array();
require_once $CFG->dirroot . '/blocks/configurable_reports/components/' . $comp . '/component.class.php';
$componentclassname = 'component_' . $comp;
$compclass = new $componentclassname($report->id);
if ($compclass->form) {
    require_once $CFG->dirroot . '/blocks/configurable_reports/components/' . $comp . '/form.php';
    $classname = $comp . '_form';
    $editform = new $classname('editcomp.php?id=' . $id . '&comp=' . $comp, compact('compclass', 'comp', 'id', 'report', 'reportclass', 'elements'));
    if ($editform->is_cancelled()) {
        redirect($CFG->wwwroot . '/blocks/configurable_reports/editcomp.php?id=' . $id . '&comp=' . $comp);
    } else {
        if ($data = $editform->get_data()) {
            $compclass->form_process_data($editform);
            cr_add_to_log($courseid, 'configurable_reports', 'edit', '', $report->name);
        }
    }
    $compclass->form_set_data($editform);
}
if ($compclass->plugins) {
    $currentplugins = array();
    if ($elements) {
        foreach ($elements as $e) {
            $currentplugins[] = $e['pluginname'];
        }
    }
    $plugins = get_list_of_plugins('blocks/configurable_reports/components/' . $comp);
    $optionsplugins = array();
    foreach ($plugins as $p) {
        require_once $CFG->dirroot . '/blocks/configurable_reports/components/' . $comp . '/' . $p . '/plugin.class.php';