示例#1
0
$verbosescales = optional_param('verbosescales', 1, PARAM_BOOL);
$iid = optional_param('iid', null, PARAM_INT);
$importcode = optional_param('importcode', '', PARAM_FILE);
$PAGE->set_context($context);
$PAGE->set_url($url);
$PAGE->set_pagelayout('standard');
$PAGE->navbar->add(get_string('roomsreserve', 'local_reservasalas'), 'reservar.php');
$PAGE->navbar->add('CSV');
echo $OUTPUT->header();
if (!has_capability('local/reservasalas:upload', $context)) {
    print_error(get_string('INVALID_ACCESS', 'Reserva_Sala'));
}
if (isset($CFG->local_uai_debug) && $CFG->local_uai_debug == 0) {
    print_error(get_string('INVALID_ACCESS', 'Reserva_Sala'));
}
$mform = new import_form(null, array('includeseparator' => true, 'verbosescales' => true));
/*echo html_writer::start_tag('div', array('class' => 'clearer'));
echo html_writer::end_tag('div');
$mform->display();
*/
if (!$iid) {
    // If the import form has been submitted.
    if ($mform->is_cancelled()) {
        redirect($url);
    } else {
        if ($formdata = $mform->get_data()) {
            // Large files are likely to take their time and memory. Let PHP know
            // that we'll take longer, and that the process should be recycled soon
            // to free up memory.
            @set_time_limit(0);
            raise_memory_limit(MEMORY_EXTRA);
if ($importurl) {
    $c = new curl();
    if ($data = $c->get($importurl)) {
        $data = json_decode($data);
        $xml = base64_decode($data->content);
    } else {
        print_error('errorimporting');
    }
    if (cr_import_xml($xml, $course)) {
        redirect("$CFG->wwwroot/blocks/cobalt_reports/managereport.php?courseid={$course->id}", get_string('reportcreated', 'block_cobalt_reports'));
    } else {
        print_error('errorimporting');
    }
}

$mform = new import_form(null, $course->id);

if ($data = $mform->get_data()) {
    if ($xml = $mform->get_file_content('userfile')) {
        if (cr_import_xml($xml, $course)) {
            redirect("$CFG->wwwroot/blocks/cobalt_reports/managereport.php?courseid={$course->id}", get_string('reportcreated', 'block_cobalt_reports'));
        } else {
            print_error('errorimporting');
        }
    }
}

$reports = cr_get_my_reports($course->id, $USER->id);

$title = get_string('reports', 'block_cobalt_reports');