Пример #1
0
 function process($now)
 {
     $start_time = explode(" ", microtime());
     $start_time = $start_time[1] + $start_time[0];
     // Start the run process
     $this->start_run($now);
     // Before we start processing, we have to truncate the sport users
     CoursePrefsSport::truncateSportUsers();
     // Parse the files
     foreach ($this->files as $key => $file) {
         $this->parse_file($now, $key, $this->function_map[$key]);
     }
     // Clear the run flag
     unblock_process('running');
     // Check the line numbers processed
     if ($this->empty_files($now)) {
         // Houston, we have a problem
         // Send an email to our moodle admin friends
         report_errors(array('The Mainframe sent empty files.', 'This is not a weekend.'), __FILE__, 'Course Preferences Mainframe Processor', 'EMERGENCY Read Me');
     }
     $end_time = explode(" ", microtime());
     $end_time = $end_time[1] + $end_time[0];
     //Force an email to be sent
     $this->errorlog[] = 'Preprocessor finished.';
     $this->errorlog[] = 'Clocked in at: ' . ($end_time - $start_time) . ' seconds';
 }
Пример #2
0
require_login();
if ($user = CoursePrefsUser::findByUnique($USER->username)) {
    error("You already exist in the system!");
}
$action = optional_param('action', '', PARAM_ACTION);
$strcourseprefs = get_string('blockname', 'block_courseprefs');
$navigation = array(array('name' => $strcourseprefs, 'link' => '', 'type' => 'title'));
print_header_simple($strcourseprefs, '', build_navigation($navigation));
switch ($action) {
    case "success":
        print_heading(get_string('request_email', 'block_courseprefs'));
        $user = new CoursePrefsUser($USER->username, $USER->firstname, $USER->lastname, '');
        $message = array();
        $message[] = get_string('request_email_message', 'block_courseprefs');
        $message[] = "Fullname: {$user->getFirstname()} {$user->getLastname()}";
        $message[] = "LogonID: {$user->getUsername()}";
        $message[] = "E-mail: {$USER->email}";
        try {
            $user->save();
        } catch (Exception $e) {
            $message[] = get_string('request_error', 'block_courseprefs');
        }
        report_errors($message, __FILE__, "Course Request Service", 'Course Request @ ' . date("F j, Y, g:i a"), false);
        redirect($CFG->wwwroot, get_string('request_thank_you', 'block_courseprefs'));
        break;
    default:
        print_heading('Request a Course');
        notice_yesno(get_string('request_warning', 'block_courseprefs'), "request.php?action=success", $CFG->wwwroot);
        break;
}
print_footer();
Пример #3
0
    $pass = optional_param('password', '', PARAM_RAW);
    if ($pass != $CFG->cronremotepassword) {
        // wrong password.
        print_error('cronerrorpassword', 'admin');
        exit;
    }
}
/**
 * Script constants
 *
 * FROM_DESCRIPTION - email addressed notified of any issues during processing
 * INPUT_PATH - path to mainframe data files to process
 */
define('FROM_DESCRIPTION', 'Course Preferences Mainframe Processor');
//Get the file locations from the config table
/*
 * $user_file - fully qualified path to user data file
 * $date_file - fully qualified path to semester data file
 * $course_file - fully qualified path to course/section/instructor data file
 * $enroll_file - fully qualified path to student enrollment data file
 */
$iteration = array('inputpath' => 'base root path', 'userfile' => 'user filename', 'coursefile' => 'course filename', 'enrollfile' => 'enrollment filename', 'datesfile' => 'dates filename', 'sportsfile' => 'sports filename');
$preprocess = new FilePreprocess();
try {
    $preprocess->setFiles($iteration);
    $preprocess->process(time());
} catch (Exception $e) {
    $preprocess->errorlog[] = $e->getMessage();
}
report_errors($preprocess->errorlog, __FILE__, FROM_DESCRIPTION, 'File preprocessor errors');
Пример #4
0
 function reportErrors($file, $description, $subject)
 {
     report_errors($this->errorlog, $file, $description, $subject);
 }