Example #1
0
                 if ($jTip->home_score == $jTip->away_score) {
                     $jTip->tip_id = -1;
                 } else {
                     $jTip->tip_id = null;
                 }
             }
         }
     }
 } else {
     $jTip->home_score = 0;
     $jTip->away_score = 0;
 }
 //if nothing has been selected by now, delete the tip record if it exists
 if (!$jTip->tip_id) {
     if ($jTip->exists()) {
         $jTip->destroy();
     }
     continue;
 }
 //Set the margin value is enabled
 if ($jSeason->pick_margin == 1 and $jGame->has_margin == 1) {
     $margin = 'margin' . $jGame->id;
     $jTip->margin = jTipsGetParam($_REQUEST, $margin, null);
 } else {
     $jTip->margin = 0;
 }
 //Set the bonus team value if enabled
 if ($jSeason->pick_bonus == 1 and $jGame->has_bonus == 1) {
     $bonus = 'bonus' . $jGame->id;
     $jTip->bonus_id = jTipsGetParam($_REQUEST, $bonus, null);
 } else {
Example #2
0
 function destroy($id = false)
 {
     global $database;
     if ($id == false) {
         $id = $this->id;
     }
     jTipsLogger::_log("Delete " . $this->_tbl . " record with id = '{$id}'");
     //delete all games and tips where this team was involved
     //first, the games
     $query = "SELECT id FROM #__jtips_games WHERE home_id = " . $database->Quote($id) . " OR away_id = " . $database->Quote($id);
     jTipsLogger::_log('loading games to delete');
     $database->setQuery($query);
     $ids = $database->loadResultArray();
     if (!empty($ids)) {
         $jGame = new jGame($database);
         foreach ($ids as $id) {
             $jGame->destroy($id);
         }
     }
     //now the tips
     $query = "SELECT id FROM #__jtips_tips WHERE game_id IN ('" . implode("', '", $ids) . "')";
     jTipsLogger::_log('loading tips to delete');
     $database->setQuery($query);
     $ids = $database->loadResultArray();
     if (!empty($ids)) {
         $jTip = new jTip($database);
         foreach ($ids as $id) {
             $jTip->destroy($id);
         }
     }
     return $this->delete($id);
 }