Esempio n. 1
0
 *
 */
require_once '../../../config.php';
require_once $CFG->dirroot . '/local/elisreports/runschedule.php';
require_once $CFG->dirroot . '/local/elisreports/sharedlib.php';
$PAGE->set_context(context_system::instance());
//database record id of the schedule to run
$scheduleid = required_param('scheduleid', PARAM_INT);
//represents the schedule name / label
$schedulename = required_param('schedulename', PARAM_ALPHAEXT);
//how far we currently are in processing the jobs (1 to n)
$current = required_param('current', PARAM_INT);
//total number of jobs
$total = required_param('total', PARAM_INT);
//determine the ELIS scheduled task name from the PHP report schedule id
$taskname = local_elisreports_get_taskname_from_id($scheduleid);
//used to update the UI with errors that have taken place
$error_string = '';
//obtain information about the scheduled PHP report task, if possible
if ($report_schedule = php_report_schedule_get_instance($taskname)) {
    //run the export
    $export_result = php_report_schedule_export_instance($report_schedule);
    if (!$export_result) {
        //export failure, so return a helpful error string
        $error_string = get_string('schedule_user_access_error', 'local_elisreports', $schedulename);
    }
}
//spit out information regarding the current position
$a = new stdClass();
$a->current = $current;
$a->total = $total;
Esempio n. 2
0
/**
 * Deletes a PHP report schedule instance and all associated
 * scheduled ELIS tasks
 *
 * @param   int      $id  The record id of the PHP report schedule to delete
 *
 * @return  boolean       true on success, otherwise false
 *
 * @uses    $DB
 */
function local_elisreports_delete_schedule_instance($id) {
    global $DB;

    //make sure the record is valid
    if ($DB->record_exists('local_elisreports_schedule', array('id' => $id))) {
        //delete all associated ELIS scheduled tasks
        $taskname = local_elisreports_get_taskname_from_id($id);
        $DB->delete_records('local_eliscore_sched_tasks', array('taskname' => $taskname));
        //delete the task itself
        $DB->delete_records('local_elisreports_schedule', array('id' => $id));
        return true;
    }

    //couldn't find the record, so signal failure
    return false;
}