Пример #1
0
//store all the schedule ids that are valid
$valid_scheduleids = array();
$test_scheduleids = json_decode($scheduleids);
//error checking
if (!is_array($test_scheduleids) || count($test_scheduleids) == 0) {
    print_error('popup_jobs_error', 'local_elisreports');
}
//create a page for permissions checking
require_once $CFG->dirroot . '/local/elisreports/lib/schedulelib.php';
$page = new scheduling_page();
foreach ($test_scheduleids as $scheduleid) {
    //retrieve the schedule name
    $config = $DB->get_field('local_elisreports_schedule', 'config', array('id' => $scheduleid));
    $config = unserialize($config);
    //check permissions
    if ($page->can_do_schedule_action($scheduleid, $config['report'])) {
        $valid_scheduleids[] = $scheduleid;
        // urlencode config label
        $schedulenames[] = urlencode($config['label']);
    }
}
// Calculate the labels to display.
$runninglabel = get_string('popup_running_label', 'local_elisreports');
$donerunninglabel = get_string('popup_done_running_label', 'local_elisreports');
$a = new stdClass();
$a->current = 0;
$a->total = count($test_scheduleids);
$progress_text = get_string('popup_status', 'local_elisreports', $a);
//trigger the scheduled jobs to run as soon as this page is loaded
$params = array($CFG->wwwroot, $valid_scheduleids, $schedulenames, 0, $runninglabel, $donerunninglabel, $progress_text);
$PAGE->requires->js_function_call('php_report_schedule_run_jobs', $params, true, 0);