示例#1
0
require_once $CFG->libdir . '/adminlib.php';
require_login(SITEID, false);
require_capability('report/customlang:view', get_system_context());
$action = optional_param('action', '', PARAM_ALPHA);
$confirm = optional_param('confirm', false, PARAM_BOOL);
$lng = optional_param('lng', '', PARAM_LANG);
admin_externalpage_setup('reportcustomlang');
$langs = get_string_manager()->get_list_of_translations();
// pre-output actions
if ($action === 'checkout') {
    require_sesskey();
    require_capability('report/customlang:edit', get_system_context());
    if (empty($lng)) {
        print_error('missingparameter');
    }
    report_customlang_utils::checkout($lng);
    redirect(new moodle_url('/admin/report/customlang/edit.php', array('lng' => $lng)));
}
if ($action === 'checkin') {
    require_sesskey();
    require_capability('report/customlang:edit', get_system_context());
    if (empty($lng)) {
        print_error('missingparameter');
    }
    if (!$confirm) {
        $output = $PAGE->get_renderer('report_customlang');
        echo $output->header();
        echo $output->heading(get_string('pluginname', 'report_customlang'));
        echo $output->heading($langs[$lng], 3);
        $numofmodified = report_customlang_utils::get_count_of_modified($lng);
        if ($numofmodified != 0) {
    require_capability('report/customlang:edit', get_system_context());
    if (empty($lng)) {
        print_error('missingparameter');
    }
    $PAGE->set_cacheable(false);
    // progress bar is used here
    $output = $PAGE->get_renderer('report_customlang');
    echo $output->header();
    echo $output->heading(get_string('pluginname', 'report_customlang'));
    $progressbar = new progress_bar();
    $progressbar->create();
    // prints the HTML code of the progress bar
    // we may need a bit of extra execution time and memory here
    @set_time_limit(HOURSECS);
    raise_memory_limit(MEMORY_EXTRA);
    report_customlang_utils::checkout($lng, $progressbar);
    echo $output->continue_button(new moodle_url('/admin/report/customlang/edit.php', array('lng' => $lng)), 'get');
    echo $output->footer();
    exit;
}
if ($action === 'checkin') {
    require_sesskey();
    require_capability('report/customlang:edit', get_system_context());
    if (empty($lng)) {
        print_error('missingparameter');
    }
    if (!$confirm) {
        $output = $PAGE->get_renderer('report_customlang');
        echo $output->header();
        echo $output->heading(get_string('pluginname', 'report_customlang'));
        echo $output->heading($langs[$lng], 3);