Search moodle.org's
Developer Documentation

See Release Notes
Long Term Support Release

  • Bug fixes for general core bugs in 4.1.x will end 13 November 2023 (12 months).
  • Bug fixes for security issues in 4.1.x will end 10 November 2025 (36 months).
  • PHP version: minimum PHP 7.4.0 Note: minimum PHP version has increased since Moodle 4.0. PHP 8.0.x is supported too.

Differences Between: [Versions 310 and 401] [Versions 311 and 401] [Versions 39 and 401] [Versions 400 and 401] [Versions 401 and 402] [Versions 401 and 403]

   1  <?php
   2  // This file is part of Moodle - http://moodle.org/
   3  //
   4  // Moodle is free software: you can redistribute it and/or modify
   5  // it under the terms of the GNU General Public License as published by
   6  // the Free Software Foundation, either version 3 of the License, or
   7  // (at your option) any later version.
   8  //
   9  // Moodle is distributed in the hope that it will be useful,
  10  // but WITHOUT ANY WARRANTY; without even the implied warranty of
  11  // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  12  // GNU General Public License for more details.
  13  //
  14  // You should have received a copy of the GNU General Public License
  15  // along with Moodle.  If not, see <http://www.gnu.org/licenses/>.
  16  
  17  /**
  18   * Script clears the fail delay for a task and reschedules its next execution.
  19   *
  20   * @package tool_task
  21   * @copyright 2017 The Open University
  22   * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
  23   */
  24  
  25  define('NO_OUTPUT_BUFFERING', true);
  26  
  27  require('../../../config.php');
  28  
  29  require_once($CFG->libdir.'/cronlib.php');
  30  
  31  // Basic security checks.
  32  require_admin();
  33  $context = context_system::instance();
  34  
  35  // Get task and check the parameter is valid.
  36  $taskname = required_param('task', PARAM_RAW_TRIMMED);
  37  $task = \core\task\manager::get_scheduled_task($taskname);
  38  if (!$task) {
  39      throw new \moodle_exception('cannotfindinfo', 'error', $taskname);
  40  }
  41  
  42  $returnurl = new moodle_url('/admin/tool/task/scheduledtasks.php',
  43          ['lastchanged' => get_class($task)]);
  44  
  45  // If actually doing the clear, then carry out the task and redirect to the scheduled task page.
  46  if (optional_param('confirm', 0, PARAM_INT)) {
  47      require_sesskey();
  48  
  49      \core\task\manager::clear_fail_delay($task);
  50  
  51      redirect($returnurl);
  52  }
  53  
  54  // Start output.
  55  $PAGE->set_url(new moodle_url('/admin/tool/task/schedule_task.php'));
  56  $PAGE->set_context($context);
  57  $PAGE->navbar->add(get_string('scheduledtasks', 'tool_task'), new moodle_url('/admin/tool/task/scheduledtasks.php'));
  58  $PAGE->navbar->add(s($task->get_name()));
  59  $PAGE->navbar->add(get_string('clear'));
  60  echo $OUTPUT->header();
  61  
  62  // The initial request just shows the confirmation page; we don't do anything further unless
  63  // they confirm.
  64  echo $OUTPUT->confirm(get_string('clearfaildelay_confirm', 'tool_task', $task->get_name()),
  65          new single_button(new moodle_url('/admin/tool/task/clear_fail_delay.php',
  66                  ['task' => $taskname, 'confirm' => 1, 'sesskey' => sesskey()]),
  67                  get_string('clear')),
  68          new single_button($returnurl, get_string('cancel'), false));
  69  
  70  echo $OUTPUT->footer();