コード例 #1
0
 * @copyright  (C) 2008-2012 Remote Learner.net Inc http://www.remote-learner.net
 *
 */
require_once '../../../config.php';
require_once $CFG->dirroot . '/blocks/php_report/runschedule.php';
require_once $CFG->dirroot . '/blocks/php_report/sharedlib.php';
//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 = block_php_report_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', 'block_php_report', $schedulename);
    }
}
//spit out information regarding the current position
$a->current = $current;
$a->total = $total;
//send back status and error
コード例 #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
 */
function block_php_report_delete_schedule_instance($id)
{
    //make sure the record is valid
    if (record_exists('php_report_schedule', 'id', $id)) {
        //delete all associated ELIS scheduled tasks
        $taskname = block_php_report_get_taskname_from_id($id);
        delete_records('elis_scheduled_tasks', 'taskname', $taskname);
        //delete the task itself
        delete_records('php_report_schedule', 'id', $id);
        return true;
    }
    //couldn't find the record, so signal failure
    return false;
}