Esempio n. 1
0
 function validation($data, $files)
 {
     $errors = parent::validation($data, $files);
     if (!isset($data['period']) || rlip_schedule_period_minutes($data['period']) < 5) {
         $errors['period'] = get_string('rlip_form_period_error', 'local_datahub');
     }
     return $errors;
 }
Esempio n. 2
0
 /**
  * Test library function: rlip_schedule_period_minutes()
  * @dataProvider period_minutes_provider
  */
 public function test_rlip_schedule_period_minutes($a, $b)
 {
     $this->assertEquals(rlip_schedule_period_minutes($a), $b);
 }
Esempio n. 3
0
/**
* Calculate the next runtime
*
* @param    int    $targetstarttime Ideal start time for a job
* @param    string $period          How often a job runs
* @param    int    $currenttime     Optional current time
* @return   int                     The next runtime
*/
function rlip_calc_next_runtime($targetstarttime, $period, $currenttime = 0)
{
    $time = $currenttime == 0 ? time() : $currenttime;
    $period = (int) rlip_schedule_period_minutes($period) * 60;
    $iterations = ceil(($time - $targetstarttime + 59) / $period);
    $nextruntime = $iterations * $period + $targetstarttime;
    return $nextruntime;
}