Exemple #1
0
$jRound->season_id = $season_id;
$jRound->round = jTipsGetParam($_REQUEST, 'roundnum', 0);
if (!is_numeric($jRound->scored)) {
    $jRound->scored = 0;
}
if ($jRound->save()) {
    $message = 'Round Saved!';
} else {
    $message = 'Save Failed: ' . $jRound->_error;
}
$games = jTipsGetParam($_REQUEST, 'game', array());
for ($i = 0; $i < count($games); $i++) {
    $jGame = new jGame($database);
    if (jTipsGetParam($_REQUEST, 'id', false)) {
        $game_id = jTipsGetParam($games, $i, -1);
        $jGame->load($game_id);
        $newRound = false;
    } else {
        $newRound = true;
        //BUG 253 - save past rounds easily
    }
    $jGame->round_id = $jRound->id;
    if ($jRound->getStatus() === false or $newRound) {
        $jGame->home_id = jTipsGetParam($_REQUEST['home_id'], $i, -1);
        $jGame->away_id = jTipsGetParam($_REQUEST['away_id'], $i, -1);
        $jGame->position = jTipsGetParam($_REQUEST['position'], $i, null);
    }
    if ($jSeason->pick_score == 1 and jTipsGetParam($_REQUEST['has_score'], $i, false)) {
        $jGame->has_score = 1;
    } else {
        if ($jRound->getStatus() === false) {
Exemple #2
0
$id = jTipsGetParam($_REQUEST, 'id', false);
if (!$id or !is_numeric($id)) {
    // BUG 373 - Round fails to copy
    jTipsLogger::_log('No round id specified to copy!', 'ERROR');
    mosRedirect('index2.php?option=com_jtips&task=list&module=Rounds', $jLang['_ADMIN_ROUND_COPY_FAIL']);
}
$focus = new jRound($database);
$focus->load($id);
$focus->id = null;
$focus->round = jTipsGetParam($_REQUEST, 'round', '');
$focus->scored = 0;
if (!$focus->round) {
    jTipsLogger::_log('No Round number entered when copying round, determine next one.', 'ERROR');
    $query = "SELECT MAX(round)+1 AS nextround FROM #__jtips_rounds WHERE season_id = '" . $focus->season_id . "'";
    $database->setQuery($query);
    $focus->round = $database->loadResult();
}
$focus->save();
$query = "SELECT id FROM #__jtips_games WHERE round_id = '" . $database->getEscaped($id) . "'";
$database->setQuery($query);
$game_ids = $database->loadResultArray();
if (!empty($game_ids)) {
    foreach ($game_ids as $gid) {
        $jGame = new jGame($database);
        $jGame->load($gid);
        $jGame->round_id = $focus->id;
        $jGame->id = null;
        $jGame->save();
    }
}
mosRedirect('index2.php?option=com_jtips&task=list&module=Rounds', $jLang['_ADMIN_ROUND_COPY_SUCCESS']);
                    ?>
<th class="sectiontableheader" align="center">Margin</th><?php 
                }
                ?>
					<th class="sectiontableheader">&nbsp;</th>
					</tr>
					</thead>
					<tbody>
				<?php 
                $k = 0;
                foreach ($tips as $tip) {
                    $tipped = new jTeam($database);
                    $tipped->load($tip->tip_id);
                    $popupUrl = "view=TeamLadder&Itemid={$Itemid}&action=ShowTeam&id=" . $tipped->id . "&season_id=" . $jSeason->id;
                    $game = new jGame($database);
                    $game->load($tip->game_id);
                    $otherTeam = new jTeam($database);
                    if ($tip->tip_id == $game->home_id) {
                        $otherTeam->load($game->away_id);
                    } else {
                        if ($tip->tip_id == $game->away_id) {
                            $otherTeam->load($game->home_id);
                        }
                    }
                    if ($params->get('show_logo')) {
                        $teamname = $tipped->getLogo();
                    } else {
                        $teamname = '';
                    }
                    $callback = $params->get('display', 'getDisplayLogoName');
                    if ($callback == 'getLogo') {
Exemple #4
0
/**
 * Sends an email to the user confirming their selections
 * TODO: Make the email customisable
 *
 * @param object The jTipsUser to send to
 * @param array The set of tips for the user
 */
function sendTipsConfirmation($jTipsUser, $tips)
{
    global $database, $jTips;
    if (!$jTips['TipsNotifyEnable']) {
        jTipsLogger::_log('tips confirmation email disabled', 'INFO');
        return true;
    }
    jTipsLogger::_log('building tips confirmation email');
    $jSeason = new jSeason($database);
    $jSeason->load($jTipsUser->season_id);
    $from_name = $jTips['UserNotifyFromName'];
    $from_email = $jTips['UserNotifyFromEmail'];
    if ($jTips['DisplayName'] == 'user') {
        $name = 'username';
    } else {
        $name = 'name';
    }
    $subject = "Selection Confirmation";
    $content = "Hi " . $jTipsUser->getUserField($name) . ",<br /><br />" . "Thanks for submitting your tips!<br /><br />" . "You picked:<br /><br />";
    foreach ($tips as $jTip) {
        $jGame = new jGame($database);
        $jGame->load($jTip->game_id);
        $home = new jTeam($database);
        $away = new jTeam($database);
        $home->load($jGame->home_id);
        $away->load($jGame->away_id);
        $phrase = 'to defeat';
        if ($jTip->tip_id == $home->id or $jTip->tip_id == '-1') {
            $tipped =& $home;
            $notTipped =& $away;
        } else {
            $tipped =& $away;
            $notTipped =& $home;
        }
        if ($jTip->tip_id == '-1') {
            $phrase = 'to draw with';
        }
        $content .= $tipped->getName() . " {$phrase} " . $notTipped->getName();
        if ($jSeason->pick_margin == 1 and $jGame->has_margin == 1) {
            $content .= " by " . ($jTip->margin ? $jTip->margin : '0');
        }
        if ($jSeason->pick_score == 1 and $jGame->has_score == 1) {
            $content .= " with a final score of ";
            if ($jTip->tip_id == $home->id or $jTip->tip_id == '-1') {
                $content .= $jTip->home_score . " to " . $jTip->away_score;
            } else {
                $content .= $jTip->away_score . " to " . $jTip->home_score;
            }
        }
        $content .= "<br />";
    }
    $content .= "<br />";
    $content .= "Good Luck!<br />";
    $content .= $from_name;
    //BUG 223 - Send the email in plaintext for best compatibility, so convert the line breaks
    $content = str_replace('<br />', "\n", $content);
    jTipsLogger::_log($content, 'ERROR');
    jTipsLogger::_log('sending tips confirmation email to ' . $jTipsUser->getUserField('email') . ' from <' . $from_email . '>');
    if (jTipsMail($from_email, $from_name, $jTipsUser->getUserField('email'), $subject, $content)) {
        jTipsLogger::_log('tips email confirmation sent', 'INFO');
        return true;
    } else {
        jTipsLogger::_log('failed to sent tips confirmation email', 'ERROR');
        return false;
    }
}
Exemple #5
0
 function fillInAdditionalFields()
 {
     global $database;
     $jTipsUser = new jTipsUser($database);
     $jTipsUser->load($this->user_id);
     $this->user =& $jTipsUser;
     $jTeam = new jTeam($database);
     if ($this->tip_id > 0) {
         $jTeam->load($this->tip_id);
     }
     $this->team =& $jTeam;
     $jGame = new jGame($database);
     $jGame->load($this->game_id);
     $jRound = new jRound($database);
     $jRound->load($jGame->round_id);
     $this->round =& $jRound;
     $this->round_num = $jRound->round;
     $jSeason = new jSeason($database);
     $jSeason->load($jRound->season_id);
     $this->season =& $jSeason;
 }
Exemple #6
0
 function loadAll($round_id = FALSE)
 {
     global $database;
     $query = "SELECT id FROM #__jtips_games" . (is_numeric($round_id) ? " WHERE round_id = {$round_id}" : "") . ";";
     $database->setQuery($query);
     $list = (array) $database->loadAssocList();
     $gamesObjects = array();
     foreach ($list as $id) {
         $jGame = new jGame($database);
         $jGame->load($id['gameid']);
         $gamesObjects[] = $jGame;
     }
     return $gamesObjects;
 }