Exemplo n.º 1
0
 function perform($edit, $datestamp)
 {
     $dataInvalid = $this->isDataInvalid($edit);
     if ($dataInvalid) {
         error_exit($dataInvalid . "<br>Please use your back button to return to the form, fix these errors, and try again");
     }
     for ($i = 0; $i < $edit['repeat_for']; $i++) {
         $slot = new GameSlot();
         $slot->set('fid', $this->field->fid);
         $slot->set('game_date', strftime("%Y-%m-%d", $datestamp));
         $slot->set('game_start', $edit['start_time']);
         if ($edit['end_time'] != '---') {
             $slot->set('game_end', $edit['end_time']);
         }
         foreach ($edit['availability'] as $league_id) {
             $slot->add_league($league_id);
         }
         if (!$slot->save()) {
             // if we fail, bail
             return false;
         }
         $datestamp += 7 * 24 * 60 * 60;
         // advance by a week
     }
     return true;
 }