Example #1
0
 function revalidate($force = false)
 {
     global $database, $jTips, $mosConfig_absolute_path;
     $this_file = $mosConfig_absolute_path . '/administrator/components/com_jtips/licence.php';
     $jTipsUser = new jTipsUser($database);
     $jSeason = new jSeason($database);
     $seasons = array('end_time' => array('type' => 'query', 'query' => ">= '" . gmdate('Y-m-d') . "'"));
     //BUG 127 - Optionally use an unsecure connection
     if ($jTips['SSLValidation'] == 0 or $jTips['SSLValidation'] == '0') {
         $this->host = preg_replace('/https/', 'http', $this->host);
         jTipsLogger::_log('validating license through unsecure connection');
     }
     $params = array('total_users' => $this->getActiveUserCount(), 'total_seasons' => $jSeason->getCount($seasons), 'license_key' => $jTips['ActivationKey'], 'activation_email' => $jTips['ActivationEmail'], 'domain_name' => preg_replace('/(www\\.)|(www)/i', '', $_SERVER['SERVER_NAME']), 'current_version' => getFullVersion());
     $encoded = serialize($params);
     jTipsLogger::_log('Preparing to revalidate license', 'INFO');
     if ($this->hasError() or $this->licence['license_expiry'] <= gmdate('Y-m-d H:i:s', time() - 3600 * 24) or $force) {
         jTipsLogger::_log('connecting to ' . $this->host);
         $curl = new jTipsCurl($this->host);
         $licence_params = array('data' => $params, 'license' => base64_encode(serialize($this->licence)));
         $data['key'] = base64_encode(serialize($licence_params));
         //$fields = $curl->asPostString($licence_params);
         $fields = $curl->asPostString($data);
         //jTipsDebug($fields);
         $curl->setopt(CURLOPT_POST, TRUE);
         $curl->setopt(CURLOPT_POSTFIELDS, $fields);
         $curl->setopt(CURLOPT_CONNECTTIMEOUT, 60);
         jTipsLogger::_log('Sending validation request', 'INFO');
         $result = $curl->exec();
         if ($curl->hasError()) {
             jTipsLogger::_log('curl error validation license: ' . $curl->hasError(), 'ERROR');
             //Return the current license data if there was an error in the connection
             return $curl->hasError();
         }
         jTipsLogger::_log('License validation request result:');
         jTipsLogger::_log($result);
         //jTipsDebug($result);
         //die();
         jTipsLogger::_log('Decoding license response', 'INFO');
         $decoded = $result == '-1' ? -1 : @unserialize(base64_decode($result));
         //jTipsDebug($result);
         //die();
         if ($decoded == -1) {
             jTipsLogger::_log('error in response', 'ERROR');
             return false;
         } else {
             jTipsLogger::_log('all is well with license ', 'INFO');
             $this->licence = $decoded;
             $this->writeLicenceFile();
             //jTipsDebug($this->licence);
             return $this->licence;
         }
     } else {
         jTipsLogger::_log('license still current', 'INFO');
         return $this->licence;
     }
 }
Example #2
0
 function &getUser($season_id, $rounds, $show_detail)
 {
     // load the season
     $db =& JFactory::getDBO();
     $season = new jSeason($db);
     $season->load($season_id);
     $current_round_id = $season->getCurrentRound();
     //		echo "<br>CURRENT ROUND ID: " .$current_round_id;
     // get the round number for the current round
     $query = "SELECT round FROM #__jtips_rounds WHERE id = " . $db->Quote($current_round_id);
     $db->setQuery($query);
     $current_round_number = $db->loadResult();
     //		echo "<br>CURRENT ROUND NUM: " .$current_round_number;
     // is the current round a multiple of $rounds?
     $mod = $current_round_number % $rounds;
     //		echo "<br>MOD = " .$mod;
     // upper limit
     $upper = $current_round_number - $mod;
     if ($upper < 0) {
         $upper = 0;
     }
     //		echo "<br>UPPER = " .$upper;
     // lower limit
     $lower = $upper - $rounds + 1;
     if ($lower < 0) {
         $lower = 0;
     }
     //		echo "<br>LOWER = " .$lower;
     // get the round numbers for all the rounds between
     $round_numbers = array();
     for ($i = $lower; $i <= $upper; $i++) {
         $round_numbers[] = $i;
     }
     // get the ids for these rounds
     $query = "SELECT id FROM #__jtips_rounds WHERE round IN (" . implode(", ", $round_numbers) . ") AND season_id = " . $db->Quote($season_id);
     $db->setQuery($query);
     $ids = $db->loadResultArray();
     // get the scores for the rounds between the lower and upper limits
     $query = " SELECT user_id, SUM(points) AS total FROM #__jtips_history " . " WHERE round_id IN (" . implode(", ", $ids) . ") " . " GROUP BY user_id ORDER BY total DESC";
     //		echo $query;
     $db->setQuery($query, 0, 1);
     $win = $db->loadObject();
     $jTipsUser = new jTipsUser($db);
     $jTipsUser->load($win->user_id);
     $data = array('who' => $jTipsUser, 'points' => $win->total);
     if ($show_detail) {
         $query = "SELECT #__jtips_rounds.round, #__jtips_history.points, #__jtips_history.rank FROM #__jtips_history " . " JOIN #__jtips_rounds ON #__jtips_history.round_id = #__jtips_rounds.id " . " WHERE user_id = {$win->user_id} AND #__jtips_history.round_id IN (" . implode(", ", $ids) . ") " . " ORDER BY #__jtips_rounds.round ASC";
         $db->setQuery($query);
         $data['results'] = $db->loadAssocList();
     } else {
         $data['results'] = array();
     }
     return $data;
 }
Example #3
0
require_once $include_path . 'classes/juser.class.php';
require_once $include_path . 'classes/jteam.class.php';
require_once $include_path . 'classes/jgame.class.php';
include $include_path . 'config.jtips.php';
/*
 * quick check to make the xml file the right one so it appears
 * properly in the list of modules
 */
if (isJoomla15() and jTipsFileExists(dirname(__FILE__) . '/installer.xml')) {
    jimport('joomla.filesystem.file');
    $data = JFile::read(dirname(__FILE__) . '/installer.xml');
    JFile::write(dirname(__FILE__) . '/mod_jtips_dash_teams.xml', $data);
    JFile::delete(dirname(__FILE__) . '/installer.xml');
}
//Get the season
$jSeason = new jSeason($database);
$jSeason->load(getSeasonID());
if (isset($jSeason->id) and !empty($jSeason->id)) {
    //parse info here
    $fieldOptions = array('-1' => '--None--', 'points' => 'Points', 'wins' => 'Wins', 'played' => 'Played', 'points_for' => 'GF', 'points_against' => 'GA');
    ?>
	<table width="100%" border="0" id="mod_jtips_team_table" cellspacing="0">
		<thead>
		<tr class="sectiontableheader jtableheader">
			<th>#</th>
			<th><?php 
    echo $jLang['_COM_TLD_TEAM'];
    ?>
</th>
	<?php 
    if ($team_field != '-1') {
Example #4
0
/**
 * Website: www.jtips.com.au
 * @author Jeremy Roberts
 * @copyright Copyright &copy; 2009, jTips
 * @license Commercial - See website for details
 * 
 * @since 2.1 - 09/10/2008
 * @version 2.1
 * @package jTips
 * 
 * Description: 
 */
global $database;
if (!class_exists('jSeason')) {
    require_once 'components/com_jtips/classes/jseason.class.php';
}
ob_clean();
$season_id = jTipsGetParam($_REQUEST, 'season_id', false);
if (!$season_id) {
    die(@json_encode(new stdClass()));
}
$jSeason = new jSeason($database);
$jSeason->load($season_id);
//$season = json_encode($jSeason);
foreach ($jSeason as $key => $val) {
    if (!property_exists($jSeason, $key) or substr($key, 0, 1) == '_') {
        unset($jSeason->{$key});
    }
}
//suppress errors for unsupported types
die(@json_encode($jSeason));
Example #5
0
global $database;
require_once 'components/com_jtips/classes/jseason.class.php';
require_once 'components/com_jtips/classes/jteam.class.php';
$jTeam = new jTeam($database);
$ids = jTipsGetParam($_REQUEST, 'cid', array());
//Do we have an existing Season?
$id = array_shift($ids);
if (is_numeric($id)) {
    $jTeam->load($id);
}
//set the page title
$title = $jLang['_ADMIN_TEAM_TITLE'] . ": " . ($jTeam->exists() ? $jLang['_ADMIN_OTHER_EDIT'] : $jLang['_ADMIN_OTHER_NEW']);
//set the custom javascripts
$mainframe->addCustomHeadTag("<script type='text/javascript' src='components/com_jtips/modules/Teams/Teams.js'></script>");
//what seasons are there
$jSeason = new jSeason($database);
$jSeasons = forceArray($jSeason->loadByParams(array()));
$jSeasonOptions = array(jTipsHTML::makeOption('', $jLang['_ADMIN_CONF_NONE']));
jTipsSortArrayObjects($jSeasons, 'name', 'ASC');
foreach ($jSeasons as $season) {
    $jSeasonOptions[] = jTipsHTML::makeOption($season->id, $season->name);
}
//build the field definitions
$formData = array('basic' => array('legend' => '_ADMIN_BASIC_INFORMATION', 'fields' => array('id' => array('field' => array('type' => 'hidden', 'attributes' => array('type' => 'hidden', 'name' => 'id', 'id' => 'id', 'value' => $jTeam->id))), 'season' => array('label' => '_ADMIN_TEAM_SEASON', 'field' => array('type' => 'select', 'attributes' => array('name' => 'season_id', 'id' => 'season_id', 'class' => 'inputbox'), 'options' => $jSeasonOptions, 'selected' => $jTeam->season_id)), 'name' => array('label' => '_ADMIN_TEAM_NAME', 'field' => array('type' => 'text', 'attributes' => array('name' => 'name', 'id' => 'name', 'class' => 'inputbox', 'size' => '50', 'type' => 'text', 'value' => $jTeam->name))), 'location' => array('label' => '_ADMIN_TEAM_LOCATION', 'field' => array('type' => 'text', 'attributes' => array('name' => 'location', 'id' => 'location', 'class' => 'inputbox', 'size' => '50', 'type' => 'text', 'value' => $jTeam->location))), 'website' => array('label' => '_ADMIN_TEAM_URL', 'field' => array('type' => 'text', 'attributes' => array('name' => 'url', 'id' => 'url', 'class' => 'inputbox', 'size' => '50', 'type' => 'text', 'value' => $jTeam->url))), 'about' => array('label' => '_ADMIN_TEAM_ABOUT', 'field' => array('type' => 'editor', 'attributes' => array('name' => 'about', 'id' => 'about', 'class' => 'inputbox', 'value' => jTipsStripslashes($jTeam->about)))))));
$formData['image'] = array('legend' => '_ADMIN_TEAM_LOGO', 'fields' => array('logo' => array('label' => '_ADMIN_TEAM_LOGO', 'field' => array('type' => 'file', 'attributes' => array('size' => '50', 'type' => 'file', 'class' => 'inputbox', 'name' => 'logo', 'id' => 'logo')))));
if ($jTeam->logo) {
    $formData['image']['fields']['current_logo'] = array('label' => '_ADMIN_TEAM_CURRENT_LOGO', 'field' => array('type' => 'img', 'attributes' => array('alt' => 'Logo', 'id' => 'current_logo', 'src' => $mosConfig_live_site . '/' . getJtipsImage($jTeam->logo, 100))));
    $formData['image']['fields']['remove_logo'] = array('label' => '_ADMIN_TEAM_REMOVE_LOGO', 'field' => array('type' => 'checkbox', 'attributes' => array('class' => 'inputbox', 'name' => 'remove_logo', 'value' => '1', 'type' => 'checkbox', 'onClick' => 'if (this.checked){$("logo").disabled=true;}else{$("logo").disabled=false}')), 'description' => '_ADMIN_TEAM_REMOVE_LOGO_DEF');
}
// BUG 287 - can no longer edit team points
/*$formData['points'] = array(
Example #6
0
            $jTipsVersion = getFullVersion();
            //BUG 262 - AutoUpgrade to version message corrected
            $newVersion = jTipsGetParam($_SESSION, 'jtips_upgraded_version', 'Latest Version');
            $message = 'System Upgraded!';
            // to ' .$jTipsVersion;
            unset($_SESSION['jtips_upgraded_version']);
        } else {
            if ($autoUpgradeResult == 0) {
                //upgrade not required
            } else {
                if (is_string($autoUpgradeResult)) {
                    //display the error message
                    //Auto Update Failed: [message]
                    $message = 'System Upgrade Failed: ' . $autoUpgradeResult;
                }
            }
        }
        if ($message) {
            mosRedirect('index2.php?option=com_jtips&module=Dashboard&nu=1&task=Validate', $message);
        }
    }
}
$jSeason = new jSeason($database);
$parameters = array('end_time' => array('type' => 'query', 'query' => "> '" . gmdate('Y-m-d') . "'"), 'start_time' => array('type' => 'query', 'query' => "< '" . gmdate('Y-m-d') . "'"));
$jSeasons = forceArray($jSeason->loadByParams($parameters));
$tpl->jSeasons = $jSeasons;
$dashboard = array();
include 'components/com_jtips/modules/Dashboard/dashboard.php';
$tpl->menu = $dashboard;
//jdash_HTML::dashboard($jSeasons, $dashboard);
$tpl->display();
require_once $include_path . 'classes/jgame.class.php';
require_once $include_path . 'classes/jteam.class.php';
require_once $include_path . 'classes/juser.class.php';
include $include_path . 'config.jtips.php';
//BUG
if (!$jTipsCurrentUser) {
    $jTipsCurrentUser = new jTipsUser($database);
    $my =& $mainframe->getUser();
    $parameters = array('user_id' => $my->id);
    $temp = forceArray($jTipsCurrentUser->loadByParams($parameters));
    $jTipsCurrentUser = array_shift($temp);
    unset($parameters);
}
//Get the season
$jtips_params = array('name' => trim($season_name));
$jSeason = new jSeason($database);
$jSeason->loadByParams($jtips_params);
if (isset($jSeason->id) and !empty($jSeason->id)) {
    //parse the info here
    $hasData = true;
    $round_id = $jSeason->getCurrentRound();
    $jRound = new jRound($database);
    if (!$round_id) {
        $hasData = false;
    } else {
        $jRound->load($round_id);
    }
    $data = array('round_id' => $round_id);
    $game = new jGame($database);
    $jGames = forceArray($game->loadByParams($data));
    if (empty($jGames)) {
Example #8
0
 function _getTotalPoints()
 {
     $jSeason = new jSeason($this->_db);
     $jSeason->load($this->season_id);
     $winPoints = $this->wins * (isset($jSeason->team_win) ? $jSeason->team_win : 1);
     $losePoints = $this->losses * (isset($jSeason->team_lose) ? $jSeason->team_lose : 0);
     $drawPoints = $this->draws * (isset($jSeason->team_draw) ? $jSeason->team_draw : 0);
     //handle the bonus points
     if ($jSeason->team_bonus) {
         $bonusPoints = $this->_getBonusPoints($jSeason);
     } else {
         $bonusPoints = 0;
     }
     return $winPoints + $losePoints + $drawPoints + $bonusPoints;
 }
Example #9
0
    ?>
/components/com_jtips/js/moodalbox.js"></script>
	<script type="text/javascript" src="<?php 
    echo $mosConfig_live_site;
    ?>
/components/com_jtips/js/Popup.js"></script>
	<link rel='stylesheet' href='<?php 
    echo $mosConfig_live_site;
    ?>
/components/com_jtips/css/moodalbox.css' type='text/css' media='screen' />
	<?php 
} else {
    JHTML::_('behavior.modal');
}
// load the selected season
$jSeason = new jSeason($database);
$jSeason->loadByParams(array('name' => $params->get('season')));
if (!$jSeason->id) {
    // show an error message
    ?>
<p class="error">No competition selected. Please update module configuration.</p><?php 
} else {
    $my =& $mainframe->getUser();
    //do we have a valid user?
    $jTipsMyTipsUser = new jTipsUser($database);
    $jTipsMyTipsUser->loadByParams(array('user_id' => $my->id, 'season_id' => $jSeason->id));
    if (!$jTipsMyTipsUser->id) {
        ?>
<p class="message">Join the <?php 
        echo $jSeason->name;
        ?>
Example #10
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;
    }
}
Example #11
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;
 }
Example #12
0
<?php

if (!defined('_JEXEC') and !defined('_VALID_MOS')) {
    die('Restricted Access');
}
/**
 * Author: Jeremy Roberts
 * Package: jTicket
 * Website: www.jtips.com.au
 * Created: 30/09/2008
 * 
 * Description: List the available seasons
 */
global $jTips, $database, $jLang, $mosConfig_absolute_path;
require_once $mosConfig_absolute_path . '/administrator/components/com_jtips/classes/jseason.class.php';
$jSeason = new jSeason($database);
//can add in an ordering field here in the params
$direction = jTipsGetParam($_REQUEST, 'filter_order_Dir', 'asc');
if (empty($direction)) {
    $direction = 'asc';
}
$orderby = jTipsGetParam($_REQUEST, 'filter_order', 'name');
if (empty($orderby)) {
    $orderby = 'name';
}
$parameters = array('order' => array('type' => 'order', 'direction' => $direction, 'by' => $orderby));
$limit = jTipsGetParam($_REQUEST, 'limit', 25);
$limitstart = jTipsGetParam($_REQUEST, 'limitstart', 0);
$pageNav = new mosPageNav($jSeason->getCount(), $limitstart, $limit);
$jSeasons = forceArray($jSeason->loadByParams($parameters, $limit, $limitstart));
$formData = array('title' => $jLang['_ADMIN_SEASON_TITLE'], 'editTask' => 'edit', 'module' => 'Seasons', 'icon' => 'seasons');
Example #13
0
}
$include_path = $mosConfig_absolute_path . '/administrator/components/com_jtips/';
require_once $include_path . 'utils/compat.php';
//$include_path = $mosConfig_absolute_path. '/administrator/components/com_jtips/';
//Include required files
require_once $include_path . 'utils/timedate.php';
require_once $include_path . 'utils/functions.inc.php';
require_once $include_path . 'classes/jseason.class.php';
require_once $include_path . 'classes/juser.class.php';
require_once $include_path . 'classes/jteam.class.php';
require_once $include_path . 'classes/jgame.class.php';
loadLanguage();
include $include_path . 'config.jtips.php';
//Get the season
$jtips_params = array('name' => trim($season_name));
$jSeason = new jSeason($database);
$jSeason->loadByParams($jtips_params);
if (isset($jSeason->id) and !empty($jSeason->id)) {
    //parse info here
    if (!isJoomla15()) {
        if ($load_mootools) {
            ?>
			<script type="text/javascript" src="<?php 
            echo $mosConfig_live_site;
            ?>
/components/com_jtips/js/mootools.js"></script>
			<?php 
        }
        ?>
		<script type="text/javascript" src="<?php 
        echo $mosConfig_live_site;
Example #14
0
 function loadByParams($params = array(), $limit = FALSE, $offset = FALSE)
 {
     global $database;
     $extra_clause = "";
     if ($limit !== FALSE and !empty($limit)) {
         $extra_clause .= " LIMIT {$limit}";
     }
     if ($offset !== FALSE and !empty($offset)) {
         $extra_clause .= " OFFSET {$offset}";
     }
     $query = "SELECT " . $this->_tbl . ".id FROM " . $this->_tbl . " " . buildWhere($params) . " {$extra_clause};";
     jTipsLogger::_log($params, 'jSeason->loadByParams:');
     $database->setQuery($query);
     $database->query();
     if ($database->getNumRows() > 1) {
         $jObjs = array();
         $list = (array) $database->loadResultArray();
         foreach ($list as $id) {
             $jObj = new jSeason($database);
             $jObj->load($id);
             array_push($jObjs, $jObj);
         }
         return $jObjs;
     } else {
         if ($database->getNumRows() == 1) {
             $load_id = $database->loadResult();
             $this->load($load_id);
             return $this;
         } else {
             return FALSE;
         }
     }
 }
Example #15
0
 * Package: jTicket
 * Website: www.jtips.com.au
 * Created: 09/09/2008
 * 
 * Description: 
 * 
 * 
 */
global $jLang, $database, $jTips;
//This breaks the shortcuts on the dashboard
//jTipsSpoofCheck();
require_once 'components/com_jtips/classes/jseason.class.php';
$ids = jTipsGetParam($_REQUEST, 'cid', array());
//Do we have an existing Season?
$id = array_shift($ids);
$jSeason = new jSeason($database);
if (is_numeric($id)) {
    $jSeason->load($id);
} else {
    $jSeason->start_time = $jSeason->end_time = gmdate('Y-m-d H:i:s');
}
$title = $jLang['_ADMIN_SEASON_MANAGER'] . ": " . ($jSeason->exists() ? $jLang['_ADMIN_OTHER_EDIT'] : $jLang['_ADMIN_OTHER_NEW']);
$formData = array('core' => array('legend' => '_ADMIN_SEASON_CORE_FIELDS_FS', 'fields' => array('id' => array('field' => array('type' => 'hidden', 'attributes' => array('type' => 'hidden', 'name' => 'id', 'id' => 'id', 'value' => $jSeason->id))), 'name' => array('label' => '_ADMIN_SEASON_NAME', 'field' => array('type' => 'text', 'attributes' => array('size' => '50', 'type' => 'text', 'class' => 'inputbox', 'name' => 'name', 'id' => 'name', 'value' => $jSeason->name))), 'url' => array('label' => '_ADMIN_SEASON_LINKURL', 'field' => array('type' => 'text', 'attributes' => array('type' => 'text', 'size' => '50', 'class' => 'inputbox', 'name' => 'url', 'id' => 'url', 'value' => $jSeason->url))), 'tip_display' => array('label' => '_ADMIN_SEASON_TIPSDISPLAY', 'field' => array('type' => 'select', 'attributes' => array('class' => 'inputbox', 'name' => 'tip_display', 'id' => 'tip_display'), 'options' => array(jTipsHTML::makeOption(0, $jLang['_ADMIN_SEASON_NAMEONLY']), jTipsHTML::makeOption(1, $jLang['_ADMIN_SEASON_LOGOONLY']), jTipsHTML::makeOption(2, $jLang['_ADMIN_SEASON_NAMELOGO'])), 'selected' => $jSeason->tip_display)), 'tips_layout' => array('label' => '_ADMIN_CONF_TIPS_PANEL_LAYOUT', 'field' => array('type' => 'select', 'attributes' => array('class' => 'inputbox', 'name' => 'tips_layout', 'id' => 'tips_layout'), 'options' => array(jTipsHTML::makeOption('home', $jLang['_ADMIN_CONF_HOME']), jTipsHTML::makeOption('away', $jLang['_ADMIN_CONF_AWAY'])), 'selected' => $jSeason->tips_layout), 'description' => '_ADMIN_CONF_TIPS_PANEL_LAYOUT_DEF'), 'start_time' => array('label' => '_ADMIN_SEASON_START_DATE', 'field' => array('type' => 'date', 'attributes' => array('name' => 'start_time', 'id' => 'start_time', 'value' => TimeDate::toDisplayDate($jSeason->start_time), 'class' => 'inputbox', 'type' => 'text')), 'description' => '_ADMIN_SEASON_START_DATE_DEF'), 'end_time' => array('label' => '_ADMIN_SEASON_END_DATE', 'field' => array('type' => 'date', 'attributes' => array('name' => 'end_time', 'id' => 'end_time', 'value' => TimeDate::toDisplayDate($jSeason->end_time), 'class' => 'inputbox', 'type' => 'text')), 'description' => '_ADMIN_SEASON_END_DATE_DEF'), 'rounds' => array('label' => '_ADMIN_SEASON_ROUNDS', 'field' => array('type' => 'text', 'attributes' => array('class' => 'inputbox', 'name' => 'rounds', 'id' => 'rounds', 'style' => 'text-align:center', 'size' => 10, 'value' => $jSeason->rounds))), 'disable_tips' => array('label' => '_ADMIN_SEASON_DISABLE_TIPS', 'description' => '_ADMIN_SEASON_DISABLE_TIPS_DEF', 'field' => array('type' => 'bool', 'attributes' => array('class' => 'inputbox', 'name' => 'disable_tips', 'id' => 'disable_tips'), 'selected' => $jSeason->disable_tips)), 'scorer_id' => array('label' => '_ADMIN_SEASON_SCORER', 'description' => '_ADMIN_SEASON_SCORER_DEF', 'field' => array('type' => 'select', 'attributes' => array('id' => 'scorer_id', 'name' => 'scorer_id', 'class' => 'inputbox'), 'selected' => $jSeason->scorer_id, 'options' => jTipsGetAvailableScorers())), 'description' => array('label' => '_ADMIN_SEASON_DESCR', 'field' => array('type' => 'editor', 'attributes' => array('name' => 'description', 'id' => 'description', 'rows' => 10, 'cols' => 50, 'value' => jTipsStripslashes($jSeason->description)))))));
$formData['image'] = array('legend' => '_ADMIN_SEASON_LOGO_PATH', 'fields' => array('imageupload' => array('label' => '_ADMIN_SEASON_LOGO_PATH', 'field' => array('type' => 'file', 'attributes' => array('size' => '50', 'type' => 'file', 'class' => 'inputbox', 'name' => 'image', 'id' => 'image', 'value' => $jSeason->image)))));
if ($jSeason->image) {
    $formData['image']['fields']['current_image'] = array('label' => '_ADMIN_TEAM_CURRENT_LOGO', 'field' => array('type' => 'img', 'attributes' => array('alt' => 'Logo', 'id' => 'current_logo', 'src' => $mosConfig_live_site . '/' . $jSeason->image)));
    $formData['image']['fields']['remove_image'] = array('label' => '_ADMIN_TEAM_REMOVE_LOGO', 'field' => array('type' => 'checkbox', 'attributes' => array('class' => 'inputbox', 'name' => 'remove_image', 'value' => '1', 'type' => 'checkbox', 'onClick' => 'if (this.checked){$("image").disabled=true;}else{$("image").disabled=false}')), 'description' => '_ADMIN_TEAM_REMOVE_LOGO_DEF');
}
$formData['team_points'] = array('legend' => '_ADMIN_SEASON_TEAM_POINTS_FS', 'fields' => array('team_win' => array('label' => '_ADMIN_SEASON_TWP', 'field' => array('type' => 'text', 'attributes' => array('class' => 'inputbox', 'name' => 'team_win', 'id' => 'team_win', 'style' => 'text-align:center', 'size' => 10, 'value' => $jSeason->team_win)), 'description' => '_ADMIN_SEASON_TWP_DEF'), 'team_draw' => array('label' => '_ADMIN_SEASON_TDP', 'field' => array('type' => 'text', 'attributes' => array('class' => 'inputbox', 'name' => 'team_draw', 'id' => 'team_draw', 'style' => 'text-align:center', 'size' => 10, 'value' => $jSeason->team_draw)), 'description' => '_ADMIN_SEASON_TDP_DEF'), 'team_lose' => array('label' => '_ADMIN_SEASON_TLP', 'field' => array('type' => 'text', 'attributes' => array('class' => 'inputbox', 'name' => 'team_lose', 'id' => 'team_lose', 'style' => 'text-align:center', 'size' => 10, 'value' => $jSeason->team_lose)), 'description' => '_ADMIN_SEASON_TLP_DEF'), 'team_bye' => array('label' => '_ADMIN_SEASON_TBP', 'field' => array('type' => 'text', 'attributes' => array('class' => 'inputbox', 'name' => 'team_bye', 'id' => 'team_bye', 'style' => 'text-align:center', 'size' => 10, 'value' => $jSeason->team_bye)), 'description' => '_ADMIN_SEASON_TBP_DEF'), 'team_bonus' => array('label' => '_ADMIN_SEASON_BONUS_TEAM', 'field' => array('type' => 'text', 'attributes' => array('class' => 'inputbox', 'name' => 'team_bonus', 'id' => 'team_bonus', 'style' => 'text-align:center', 'size' => 10, 'value' => $jSeason->team_bonus))), 'team_starts' => array('label' => '_ADMIN_SEASON_ETS', 'description' => '_ADMIN_SEASON_ETS_DEF', 'field' => array('type' => 'bool', 'attributes' => array('class' => 'inputbox', 'name' => 'team_starts', 'id' => 'team_starts'), 'selected' => $jSeason->team_starts))));
$formData['points_configuration'] = array('legend' => '_ADMIN_SEASON_TIPS_CONFIG_FS', 'fields' => array('pick_score' => array('label' => '_ADMIN_SEASON_EPTS', 'description' => '_ADMIN_SEASON_EPTS_DEF', 'field' => array('type' => 'bool', 'attributes' => array('class' => 'inputbox', 'name' => 'pick_score', 'id' => 'pick_score'), 'selected' => $jSeason->pick_score)), 'pick_margin' => array('label' => '_ADMIN_SEASON_EPTM', 'description' => '_ADMIN_SEASON_EPTM_DEF', 'field' => array('type' => 'bool', 'attributes' => array('class' => 'inputbox', 'name' => 'pick_margin', 'id' => 'pick_margin'), 'selected' => $jSeason->pick_margin)), 'pick_draw' => array('label' => '_ADMIN_SEASON_EPTD', 'description' => '_ADMIN_SEASON_EPTD_DEF', 'field' => array('type' => 'bool', 'attributes' => array('class' => 'inputbox', 'name' => 'pick_draw', 'id' => 'pick_draw'), 'selected' => $jSeason->pick_draw)), 'pick_bonus' => array('label' => '_ADMIN_SEASON_EPTB', 'description' => '_ADMIN_SEASON_EPTB_DEF', 'field' => array('type' => 'select', 'attributes' => array('class' => 'inputbox', 'name' => 'pick_bonus', 'id' => 'pick_bonus'), 'selected' => $jSeason->pick_bonus, 'options' => array(jTipsHTML::makeOption(0, $jLang['_ADMIN_SEASON_EPTB_DIS']), jTipsHTML::makeOption(1, $jLang['_ADMIN_SEASON_EPTB_SIN']), jTipsHTML::makeOption(2, $jLang['_ADMIN_SEASON_EPTB_BOT'])))), 'game_times' => array('label' => '_ADMIN_SEASON_GAME_TIMES', 'description' => '_ADMIN_SEASON_GAME_TIMES_DEF', 'field' => array('type' => 'bool', 'attributes' => array('class' => 'inputbox', 'name' => 'game_times', 'id' => 'game_times'), 'selected' => $jSeason->game_times)), 'tough_score' => array('label' => '_ADMIN_SEASON_TOUGH_SCORE', 'description' => '_ADMIN_SEASON_TOUGH_SCORE_DEF', 'field' => array('type' => 'bool', 'attributes' => array('class' => 'inputbox', 'name' => 'tough_score', 'id' => 'tough_score'), 'selected' => $jSeason->tough_score))));
$formData['user_points'] = array('legend' => '_ADMIN_SEASON_USER_POINTS_FS', 'fields' => array('user_correct' => array('label' => '_ADMIN_SEASON_UCORR', 'description' => '_ADMIN_SEASON_UCORR_DEF', 'field' => array('type' => 'text', 'attributes' => array('class' => 'inputbox', 'name' => 'user_correct', 'id' => 'user_correct', 'style' => 'text-align:center', 'size' => 10, 'value' => $jSeason->user_correct))), 'user_draw' => array('label' => '_ADMIN_SEASON_UDRAW', 'field' => array('type' => 'text', 'attributes' => array('class' => 'inputbox', 'name' => 'user_draw', 'id' => 'user_draw', 'style' => 'text-align:center', 'size' => 10, 'value' => $jSeason->user_draw))), 'user_none' => array('label' => '_ADMIN_SEASON_UNONE', 'description' => '_ADMIN_SEASON_UNONE_DEF', 'field' => array('type' => 'text', 'attributes' => array('class' => 'inputbox', 'name' => 'user_none', 'id' => 'user_none', 'style' => 'text-align:center', 'size' => 10, 'value' => $jSeason->user_none))), 'precision_score' => array('label' => '_ADMIN_SEASON_PRECISION', 'description' => '_ADMIN_SEASON_PRECISION_DEF', 'field' => array('type' => 'bool', 'attributes' => array('name' => 'precision_score', 'id' => 'precision_score'), 'selected' => $jSeason->precision_score)), 'user_bonus' => array('label' => '_ADMIN_SEASON_UPERF', 'field' => array('type' => 'text', 'attributes' => array('class' => 'inputbox', 'name' => 'user_bonus', 'id' => 'user_bonus', 'style' => 'text-align:center', 'size' => 10, 'value' => $jSeason->user_bonus))), 'user_pick_score' => array('label' => '_ADMIN_SEASON_USCOR', 'field' => array('type' => 'text', 'attributes' => array('class' => 'inputbox', 'name' => 'user_pick_score', 'id' => 'user_pick_score', 'style' => 'text-align:center', 'size' => 10, 'value' => $jSeason->user_pick_score))), 'user_pick_margin' => array('label' => '_ADMIN_SEASON_UMARG', 'field' => array('type' => 'text', 'attributes' => array('class' => 'inputbox', 'name' => 'user_pick_margin', 'id' => 'user_pick_margin', 'style' => 'text-align:center', 'size' => 10, 'value' => $jSeason->user_pick_margin))), 'user_pick_bonus' => array('label' => '_ADMIN_SEASON_UBONU', 'field' => array('type' => 'text', 'attributes' => array('class' => 'inputbox', 'name' => 'user_pick_bonus', 'id' => 'user_pick_bonus', 'style' => 'text-align:center', 'size' => 10, 'value' => $jSeason->user_pick_bonus))), 'default_points' => array('label' => '_ADMIN_SEASON_DEFAULT_POINTS', 'description' => '_ADMIN_SEASON_DEFAULT_POINTS_DEF', 'field' => array('type' => 'select', 'attributes' => array('name' => 'default_points', 'id' => 'default_points', 'class' => 'inputbox'), 'options' => array(jTipsHTML::makeOption('', $jLang['_ADMIN_CONF_NONE']), jTipsHTML::makeOption('low', $jLang['_ADMIN_SEASON_DEFAULT_POINTS_LOW']), jTipsHTML::makeOption('avg', $jLang['_ADMIN_SEASON_DEFAULT_POINTS_AVG'])), 'selected' => $jSeason->default_points))));
Example #16
0
 * Website: www.jtips.com.au
 * Created: 30/09/2008
 * 
 * @since 2.1 - 30/09/2008
 * @copyright Copyright &copy; 2009, jTips
 * @author Jeremy Roberts
 * @package jTips
 * @version 2.1
 * 
 * Description: Save the season data from the posted form
 */
global $mainframe, $database, $mosConfig_absolute_path;
//Make sure this is not a hack job
jTipsSpoofCheck();
require_once 'components/com_jtips/classes/jseason.class.php';
$jSeason = new jSeason($database);
if ($id = jTipsGetParam($_REQUEST, 'id', FALSE)) {
    $jSeason->load($id);
}
$jSeason->bind($_REQUEST);
//BUG 263 - set the date fields if we are in J1.0
if (!isJoomla15()) {
    $jSeason->start_time = TimeDate::toDisplayDate($jSeason->start_time);
    $jSeason->end_time = TimeDate::toDisplayDate($jSeason->end_time);
}
if ($_FILES['image']['name'] and imageDirCheck()) {
    $logofile = 'images/jtips/' . $_FILES['image']['name'];
    if (isJoomla15()) {
        jimport('joomla.filesystem.file');
        jTipsLogger::_log('MOVING ' . $_FILES['image']['tmp_name'] . ' TO ' . $logofile, 'ERROR');
        //JFile::move($_FILES['image']['tmp_name'], $mosConfig_absolute_path.'/'.$logofile);
Example #17
0
 function process()
 {
     global $database, $jTips, $mosConfig_absolute_path;
     $this->clearHistory();
     $params = array('round_id' => $this->id);
     $jSeason = new jSeason($database);
     $jSeason->load($this->season_id);
     $jGame = new jGame($database);
     $jGames = forceArray($jGame->loadByParams($params));
     $params = array('season_id' => $this->season_id);
     $jTipsUser = new jTipsUser($database);
     $jTipsUsers = forceArray($jTipsUser->loadByParams($params));
     $noTips = $scores = $worst_precision = array();
     $played = count($jGames);
     foreach ($jTipsUsers as $jTipsUser) {
         jTipsLogger::_log("Processing scores for user " . $jTipsUser->id);
         $score = $matching = $precision = $allAwayScore = 0;
         if ($jTipsUser->hasTipped($this->id)) {
             jTipsLogger::_log($jTipsUser->id . " has tipped in round " . $this->id);
             foreach ($jGames as $jGame) {
                 jTipsLogger::_log("Processing game " . $jGame->id);
                 $params = array('user_id' => $jTipsUser->id, 'game_id' => $jGame->id);
                 $jTip = new jTip($database);
                 $jTip->loadByParams($params);
                 // make sure this is not a bye game
                 if (!$jGame->home_id or !$jGame->away_id or !$jGame->winner_id) {
                     jTipsLogger::_log('attempting to process tips on a bye game, skipping', 'INFO');
                     continue;
                 }
                 /*
                  * Feature Request 101 - Team Starts
                  * Determine the winner when we take the starts into account
                  * We only care about the starts for picking the winner/draw
                  * For picking the margins and scores, use the actual winner
                  */
                 if ($jSeason->team_starts) {
                     jTipsLogger::_log('processing team starts');
                     $homeScore = $awayScore = 0;
                     $homeScore = $jGame->home_score + ($jGame->home_start + 0);
                     $awayScore = $jGame->away_score + ($jGame->away_start + 0);
                     if ($homeScore > $awayScore) {
                         $winnerID = $jGame->home_id;
                     } else {
                         if ($homeScore < $awayScore) {
                             $winnerID = $jGame->away_id;
                         } else {
                             if ($homeScore == $awayScore) {
                                 $winnerID = -1;
                             }
                         }
                     }
                     jTipsLogger::_log('feature 101: With starts, the winner is ' . $winnerID . ', otherwise the winner is ' . $jGame->winner_id . " HOME {$homeScore} v AWAY {$awayScore}");
                 } else {
                     $winnerID = $jGame->winner_id;
                 }
                 if ($jTip->tip_id == $winnerID) {
                     //User tipped right!
                     jTipsLogger::_log("CORRECT TIP by " . $jTipsUser->id . " in round_id " . $this->id . " in game_id " . $jGame->id);
                     //BUG 248 - Add ToughScore if enabled
                     if ($jSeason->tough_score and $jGame->tough_score) {
                         $score += $jGame->tough_score;
                     }
                     if ($winnerID == -1) {
                         $score += isset($jSeason->user_draw) ? $jSeason->user_draw : 0;
                         jTipsLogger::_log("Draw correctly picked!");
                     } else {
                         $score += isset($jSeason->user_correct) ? $jSeason->user_correct : 0;
                     }
                     $matching++;
                 }
                 if ($winnerID == $jGame->away_id) {
                     $allAwayScore += $jSeason->user_correct;
                 }
                 //Check for correct margins and handle precision score gathering
                 if ($jSeason->pick_margin == 1 and $jGame->has_margin == 1) {
                     $margin = abs($jGame->home_score - $jGame->away_score);
                     if ($jTip->margin == $margin) {
                         $score += isset($jSeason->user_pick_margin) ? $jSeason->user_pick_margin : 0;
                         jTipsLogger::_log("correct margin picked!");
                     }
                     if ($jSeason->precision_score == 1) {
                         if ($jGame->winner_id == $jTip->tip_id) {
                             $margin_offset = abs($margin - $jTip->margin);
                         } else {
                             $margin_offset = abs($margin + $jTip->margin);
                         }
                         if (isset($worst_precision[$jGame->id]) && $margin_offset > $worst_precision[$jGame->id] || empty($worst_precision[$jGame->id])) {
                             $worst_precision[$jGame->id] = $margin_offset;
                         }
                         $precision += $margin_offset;
                         jTipsLogger::_log("PICK_MARGIN: Adding {$margin_offset} to precision of {$precision}");
                     }
                 }
                 //Check for correct scores and handle precision score gathering
                 if ($jSeason->pick_score == 1 and $jGame->has_score == 1) {
                     $margin = abs($jGame->home_score - $jGame->away_score);
                     if ($jTip->home_score == $jGame->home_score and $jTip->away_score == $jGame->away_score) {
                         $score += isset($jSeason->user_pick_score) ? $jSeason->user_pick_score : 0;
                         jTipsLogger::_log("Correct scores picked!");
                     }
                     if ($jSeason->precision_score == 1) {
                         $pickedScoreMargin = abs($jTip->home_score - $jTips->away_score);
                         if ($jGame->winner_id == $jTip->tip_id) {
                             $score_offset = abs($margin - $pickedScoreMargin);
                         } else {
                             $score_offset = abs($margin + $pickedScoreMargin);
                         }
                         if (isset($worst_precision[$jGame->id]) and $score_offset > $worst_precision[$jGame->id] or empty($worst_precision[$jGame->id])) {
                             $worst_precision[$jGame->id] = $score_offset;
                         }
                         $precision += $score_offset;
                         jTipsLogger::_log("PICK_SCORE: Adding {$score_offset} to precision of {$precision}");
                         jTipsLogger::_log("PREC DEBUG: {$jTipsUser->id}-{$jTipsUser->user_id} Picked Margin: {$pickedScoreMargin}. Actual Margin: {$margin}. Applied Precision: {$score_offset}. Running Precision: {$precision}", 'INFO');
                     }
                 }
                 //Check for a bonus team selection
                 if ($jSeason->pick_bonus >= 1 and $jGame->has_bonus == 1) {
                     if ($jTip->bonus_id == $jGame->bonus_id && $jGame->bonus_id != -1) {
                         $score += isset($jSeason->user_pick_bonus) ? $jSeason->user_pick_bonus : 0;
                     }
                 }
             }
             //was a perfect round picked?
             if ($matching == $played) {
                 $score += isset($jSeason->user_bonus) ? $jSeason->user_bonus : 0;
             }
             //did the user use their 'doubleup'
             if ($jTipsUser->doubleup == $this->id and $jTips['DoubleUp'] == 1) {
                 $score = $score * 2;
             }
             $scores[] = $score;
             //Save the data to the history object
             $jHistory = new jHistory($database);
             $jHistory->user_id = $jTipsUser->id;
             $jHistory->round_id = $this->id;
             jTipsLogger::_log("Score for user_id " . $jTipsUser->id . " in round_id " . $this->id . " is {$score}");
             $jHistory->points = $score;
             //Update rank after all users have been saved
             $jHistory->outof = count($jTipsUsers);
             //$jHistory->comment	= $jTipsUser->comment;
             if ($jSeason->precision_score == 1) {
                 jTipsLogger::_log("setting precision to {$precision} for user_id " . $jTipsUser->id . " in round_id " . $this->id);
                 $jHistory->precision = $precision;
             } else {
                 $jHistory->precision = 0;
             }
             if ($jHistory->save() !== false) {
                 $results[] = 1;
             } else {
                 jTipsLogger::_log("Error saving history: " . $jHistory->_error);
                 $results[] = 0;
             }
             //remove the current comment
             $jTipsUser->comment = null;
             $jTipsUser->save();
             // Check if the AlphaUserPoints config option is set
             if (isJoomla15()) {
                 $api_AUP = JPATH_SITE . DS . 'components' . DS . 'com_alphauserpoints' . DS . 'helper.php';
             } else {
                 $api_AUP = $mosConfig_absolute_path . 'components/com_alphauserpoints/helper.php';
             }
             if (!$this->scored and $jTips['AlphaUserPoints'] and jTipsFileExists($api_AUP)) {
                 require_once $api_AUP;
                 jTipsLogger::_log('sending ' . $score . ' points for user ' . $jTipsUser->user_id, 'INFO');
                 $refID = AlphaUserPointsHelper::getAnyUserReferreID($jTipsUser->user_id);
                 AlphaUserPointsHelper::newpoints('plgaup_jtips_total_points', $refID, '', '', $score);
             }
             if (!$this->scored and $jTips['JomSocialActivities'] and $jTips['JomSocialUserResults']) {
                 global $mosConfig_absolute_path;
                 require_once $mosConfig_absolute_path . '/administrator/components/com_jtips/utils/jTipsJomSocial.php';
                 jTipsJomSocial::writeRoundResult($jSeason, $this, $jTipsUser->user_id, $score);
             }
         } else {
             $noTips[] = $jTipsUser;
         }
     }
     if (count($noTips) > 0) {
         /////////////////////////////////////////////////
         // Feature Request 71
         // Allow users that did not to be assigned
         // all the away teams
         //
         /*if ($jSeason->user_none != -1) {
         		$thisRound = $jSeason->user_none;
         		} else if (is_array($scores) && count($scores) > 0) {
         		$thisRound = min($scores);
         		} else {
         		$thisRound = 0;
         		}*/
         if ($jSeason->user_none == -2) {
             //handle all away teams
             $thisRound = $allAwayScore;
             jTipsLogger::_log("didn't tip? You'll be stuck with the away teams. You got {$thisRound}");
         } else {
             if ($jSeason->user_none == -1) {
                 //handle lowest possible score
                 if (is_array($scores) and count($scores) > 0) {
                     $thisRound = min($scores);
                     jTipsLogger::_log("didn't tip? You'll be stuck with the lowest score this round, {$thisRound}");
                 } else {
                     $thisRound = 0;
                     jTipsLogger::_log("didn't tip? You'll be stuck {$thisRound}");
                 }
             } else {
                 //handle allocated score
                 $thisRound = $jSeason->user_none;
                 jTipsLogger::_log("didn't tip? You're getting {$thisRound}");
             }
         }
         //
         // END Feature Request 71
         ////////////////////////////////////////////////////
         foreach ($noTips as $jTipsUser) {
             $jHistory = new jHistory($database);
             $jHistory->user_id = $jTipsUser->id;
             $jHistory->round_id = $this->id;
             $jHistory->points = $thisRound;
             $jHistory->precision = array_sum($worst_precision);
             //$jHistory->outof		= count($jTipsUsers);
             //$jHistory->comment	= $jTipsUser->comment;
             if ($jHistory->save() !== false) {
                 $results[] = 1;
             } else {
                 $results[] = 0;
             }
             $jTipsUser->save();
             // Check if the AlphaUserPoints config option is set
             if (isJoomla15()) {
                 $api_AUP = JPATH_SITE . DS . 'components' . DS . 'com_alphauserpoints' . DS . 'helper.php';
             } else {
                 $api_AUP = $mosConfig_absolute_path . 'components/com_alphauserpoints/helper.php';
             }
             if (!$this->scored and $jTips['AlphaUserPoints'] and jTipsFileExists($api_AUP)) {
                 require_once $api_AUP;
                 jTipsLogger::_log('sending ' . $score . ' points for user ' . $jTipsUser->user_id, 'INFO');
                 $refID = AlphaUserPointsHelper::getAnyUserReferreID($jTipsUser->user_id);
                 AlphaUserPointsHelper::newpoints('plgaup_jtips_total_points', $refID, '', '', $thisRound);
             }
             if (!$this->scored and $jTips['JomSocialActivities']) {
                 global $mosConfig_absolute_path;
                 require_once $mosConfig_absolute_path . '/administrator/components/com_jtips/utils/jTipsJomSocial.php';
                 if ($jTips['JomSocialUserResults']) {
                     jTipsJomSocial::writeRoundResult($jSeason, $this, $jTipsUser->user_id, $score);
                 }
                 if ($jTips['JomSocialOnNoTips']) {
                     jTipsJomSocial::writeOnNoTips($jTipsUser->user_id, $jSeason, $this);
                 }
             }
         }
     }
     $jHistory = new jHistory($database);
     $jHistory->setRanks($this->id, true);
     if (!$this->scored and $jTips['JomSocialActivities']) {
         // find out who won the round and write it to the JomSocial stream
         $winners = $this->getRoundWinners();
         jTipsJomSocial::writeRoundWinners($winners, $this, $jSeason);
     }
     $this->scored = 1;
     $result = $this->save();
     //if ($this->scored != 1) {
     jTeam::updateLadder($this, $jSeason);
     //}
     //$this->scored = 1;
     //return $this->save();
     return $result;
 }
Example #18
0
require_once $mosConfig_absolute_path . '/administrator/components/com_jtips/classes/jseason.class.php';
require_once $mosConfig_absolute_path . '/administrator/components/com_jtips/classes/jtip.class.php';
jTipsLogger::_log('about to start saving tips');
//TODO: remove this
if (empty($jTipsCurrentUser->id)) {
    die('No jTips User!');
}
$jRound = new jRound($database);
$jRound->load(jTipsGetParam($_REQUEST, 'round_id', 0));
// BUG 389 - Can save tips by hacking HTML with Firebug
if (!$jRound->id or $jRound->getStatus() !== false) {
    // trying to post to an invalid round or round in progress
    jTipsRedirect('index.php?option=com_jtips&Itemid=' . $Itemid, $jLang['_COM_CANNOT_POST_CLOSED']);
    exit;
}
$jSeason = new jSeason($database);
$jSeason->load($jRound->season_id);
$jGame = new jGame($database);
$jGameParams = array('round_id' => $jRound->id);
$jGames = forceArray($jGame->loadByParams($jGameParams));
$myTips = array();
$isUpdate = null;
foreach ($jGames as $jGame) {
    $game_id = 'game' . $jGame->id;
    jTipsLogger::_log('saving tips for game ' . $jGame->id);
    $jTip = new jTip($database);
    $jTipParams = array('user_id' => $jTipsCurrentUser->id, 'game_id' => $jGame->id);
    $jTip->loadByParams($jTipParams);
    if ($jTip->exists() === false || empty($jTip->user_id) || empty($jTip->game_id)) {
        $jTip->user_id = $jTipsCurrentUser->id;
        $jTip->game_id = $jGame->id;
Example #19
0
 * 
 * Description: 
 */
global $database;
jTipsSpoofCheck();
require_once 'components/com_jtips/classes/jcomment.class.php';
require_once 'components/com_jtips/classes/jround.class.php';
require_once 'components/com_jtips/classes/jseason.class.php';
require_once 'components/com_jtips/classes/jtip.class.php';
require_once 'components/com_jtips/classes/juser.class.php';
$ids = jTipsGetParam($_REQUEST, 'cid', array());
$destroyed = array();
if (!empty($ids)) {
    foreach ($ids as $id) {
        if (is_numeric($id)) {
            $jSeason = new jSeason($database);
            $jSeason->load($id);
            jTipsLogger::_log('Deleting season ' . $jSeason->name);
            $params = array('season_id' => $id);
            $jRound = new jRound($database);
            $jRounds = $jSeason->loadByParams($params);
            if (!is_array($jRounds)) {
                if ($jRound->exists()) {
                    $jRounds = array($jRound);
                } else {
                    $jRounds = array();
                }
            }
            jTipsLogger::_log('deleting rounds from season');
            foreach ($jRounds as $jRound) {
                array_push($destroyed, $jRound->destroy());
Example #20
0
 * 
 * @since 2.1 - 08/10/2008
 * @version 2.1
 * @package jTips
 * 
 * Description: Store the games and setup
 */
jTipsSpoofCheck();
global $database, $jTips;
//jTipsDebug($_REQUEST);
//die();
require_once 'components/com_jtips/classes/jgame.class.php';
require_once 'components/com_jtips/classes/jround.class.php';
require_once 'components/com_jtips/classes/jseason.class.php';
$jRound = new jRound($database);
$jSeason = new jSeason($database);
if ($round_id = jTipsGetParam($_REQUEST, 'id', false)) {
    $jRound->load($round_id);
}
$season_id = jTipsGetParam($_REQUEST, 'season_id', false);
$jSeason->load($season_id);
$results = $games_to_keep = array();
//jTipsLogger::_log($_REQUEST);
jTipsLogger::_log('about to save round and games');
//first, save the round info
$start_time_date = jTipsGetParam($_REQUEST, 'date_start_date', strftime($jTips['DateFormat'])) . " ";
$start_minute = jTipsGetParam($_REQUEST, 'date_start_time_minute', '');
$start_time_time = jTipsGetParam($_REQUEST, 'date_start_time_hour', '') . ":" . str_pad($start_minute, 2, '0', STR_PAD_LEFT) . jTipsGetParam($_REQUEST, 'date_start_time_meridiem', '');
if (!preg_match('/\\d/', $start_time_time)) {
    $start_time_time = strftime($jTips['TimeFormat']);
}
Example #21
0
 function getLast(&$jTipsUser, $field = 'points')
 {
     global $database;
     $jSeason = new jSeason($database);
     $jSeason->load($jTipsUser->season_id);
     $jRound = new jRound($database);
     $jRound->load($jSeason->getLatestRound());
     if ($jRound->scored != 1) {
         $jRound->load($jRound->getPrev());
     }
     //$prev_id = $jRound->getPrev();
     //$jRound->load($prev_id);
     $query = "SELECT `{$field}` FROM #__jtips_history WHERE user_id = " . $jTipsUser->id . " AND round_id = " . $jRound->id . ";";
     //jTipsDebug($query);
     $database->setQuery($query);
     $res = $database->loadResult();
     return is_numeric($res) ? floatval($res) : 0;
 }
Example #22
0
 function getSeasonName()
 {
     global $database;
     if (!isset($this->season_name)) {
         $jSeason = new jSeason($database);
         $jSeason->load($this->season_id);
         $this->season_name = $jSeason->name;
     }
     return $this->season_name;
 }
Example #23
0
 * @copyright Copyright &copy; 2009, jTips
 * @license Commercial - See website for details
 * 
 * @since 2.1.9 - 06/04/2009
 * @version 1.0.0
 * @package jTips
 * 
 * Description: 
 */
require_once 'components/com_jtips/classes/jround.class.php';
require_once 'components/com_jtips/classes/jseason.class.php';
require_once 'components/com_jtips/modules/Rounds/copy.tmpl.php';
global $database, $jTips, $jLang;
$tpl = new CopyMode();
$tpl->formData['title'] = $jLang['_ADMIN_ROUND_COPY'];
// load the round id being copied
$focus = new jRound($database);
$ids = jTipsGetParam($_REQUEST, 'cid', array());
if (!empty($ids)) {
    $id = array_shift($ids);
    $focus->load($id);
} else {
    mosRedirect('index2.php?option=com_jtips&module=Rounds&task=list', $jLang['_ADMIN_ROUND_COPY_NOROUND']);
}
$tpl->round = $focus->round;
$tpl->round_id = $focus->id;
// load the season info
$jSeason = new jSeason($database);
$jSeason->load($focus->season_id);
$tpl->season_name = $jSeason->name;
$tpl->display();
Example #24
0
if (jTipsFileExists($mosConfig_absolute_path . '/components/com_jtips/custom/views/TeamLadder/ShowTeamRender.ext.php')) {
    require_once $mosConfig_absolute_path . '/components/com_jtips/custom/views/TeamLadder/ShowTeamRender.ext.php';
} else {
    require_once $mosConfig_absolute_path . '/components/com_jtips/views/TeamLadder/ShowTeamRender.php';
}
if (!isJoomla15()) {
    //Trash anything we have so far
    ob_clean();
    ob_start();
}
$render = new jTipsRenderShowTeam();
$id = jTipsGetParam($_REQUEST, 'id', '');
$jTeam = new jTeam($database);
$jTeam->load($id);
$render->assign('jTeam', $jTeam);
$jSeason = new jSeason($database);
$jSeason->load($jTeam->season_id);
$render->assign('jSeason', $jSeason);
$render->display();
if (!isJoomla15()) {
    die;
}
/*
$my = $mainframe->getUser();
$jTipsUser = new jTipsUser($database);
$jTipsUserParams = array(
	'user_id' => $my->id,
	'season_id' => $jTeam->season_id
);
$jTipsUser = $jTipsUser->loadByParams($jTipsUserParams);
*/
Example #25
0
$mosConfig_lang = $mainframe->getCfg('lang');
include $include_path . 'i18n/english.php';
if (file_exists($include_path . 'i18n/' . $mosConfig_lang . '.php')) {
    include $include_path . 'i18n/' . $mosConfig_lang . '.php';
}
$include_path = $mosConfig_absolute_path . '/administrator/components/com_jtips/';
//Include required files
require_once $include_path . 'utils/timedate.php';
require_once $include_path . 'utils/functions.inc.php';
require_once $include_path . 'classes/jseason.class.php';
require_once $include_path . 'classes/jteam.class.php';
require_once $include_path . 'classes/juser.class.php';
include $include_path . 'config.jtips.php';
//Get the season
$jtips_params = array('name' => trim($season_name));
$jSeason = new jSeason($database);
$jSeason->loadByParams($jtips_params);
if (isset($jSeason->id) and !empty($jSeason->id)) {
    //parse the info here
    if (!$my) {
        $my =& $mainframe->getUser();
    }
    $query = "SELECT tip_id AS team_id, COUNT(*) times_picked " . "FROM #__jtips_tips JOIN #__jtips_users ON " . "#__jtips_tips.user_id = #__jtips_users.id ";
    if ($params->get('user') and $my->id) {
        $jTipsUserParams = array('season_id' => $jSeason->id, 'user_id' => $my->id, 'status' => 1);
        $jTipsFTModuleUser = new jTipsUser($database);
        $jTipsFTModuleUser->loadByParams($jTipsUserParams);
        if ($jTipsFTModuleUser->id) {
            $query .= "WHERE #__jtips_users.user_id = " . $database->Quote($my->id) . " ";
        }
    }
require_once $mosConfig_absolute_path . '/administrator/components/com_jtips/classes/jround.class.php';
require_once $mosConfig_absolute_path . '/administrator/components/com_jtips/classes/jseason.class.php';
if ($params->get('load_mootools')) {
    $mainframe->addCustomHeadTag("<script type='text/javascript' src='" . $mosConfig_live_site . "/components/com_jtips/js/mootools.js'></script>");
}
/*
 * quick check to make the xml file the right one so it appears
 * properly in the list of modules
 */
if (isJoomla15() and jTipsFileExists(dirname(__FILE__) . '/installer.xml')) {
    jimport('joomla.filesystem.file');
    $data = JFile::read(dirname(__FILE__) . '/installer.xml');
    JFile::write(dirname(__FILE__) . '/mod_jtips_dash_comp_ladder.xml', $data);
    JFile::delete(dirname(__FILE__) . '/installer.xml');
}
$jSeason = new jSeason($database);
$season_id = getSeasonID();
if (is_numeric($season_id)) {
    $jSeason->load($season_id);
} else {
    $date = gmdate('Y-m-d');
    //Bug 33.4 - Extended params array to default to season for current user
    $objParams = array('end_time' => array('type' => 'query', 'query' => "> '{$date}'"), 'left_join' => array('type' => 'left_join', 'join_table' => '#__jtips_users', 'lhs_table' => '#__jtips_seasons', 'lhs_key' => 'id', 'rhs_table' => '#__jtips_users', 'rhs_key' => 'season_id'));
    if (isset($jTipsUser->user_id) and !empty($jTipsUser->user_id)) {
        $objParams['#__jtips_users.user_id'] = $jTipsUser->user_id;
    }
    $jSeasons = forceArray($jSeason->loadByParams($objParams));
    if (count($jSeasons) > 0) {
        $jSeason =& array_shift($jSeasons);
    }
}
Example #27
0
 * 
 * Description: 
 */
global $database, $mosConfig_absolute_path;
ob_clean();
require_once $mosConfig_absolute_path . '/administrator/components/com_jtips/classes/jround.class.php';
require_once $mosConfig_absolute_path . '/administrator/components/com_jtips/classes/jseason.class.php';
$element_id = jTipsGetParam($_REQUEST, 'element', '');
$season_id = jTipsGetParam($_REQUEST, 'season_id', null);
$preselected = jTipsGetParam($_REQUEST, 'round_id', false);
if (empty($season_id) or !isset($preselected)) {
    $js = "document.getElementById('{$element_id}').length = 0;\n";
    $js .= "document.getElementById('{$element_id}').options[0] = new Option('--None--', '-1');\n";
    die($js . "document.getElementById('{$element_id}').disabled = true;");
}
$jSeason = new jSeason($database);
$jSeason->load($season_id);
$curr = $jSeason->getLatestRound();
$jRound = new jRound($database);
$parameters = array('season_id' => $season_id, 'scored' => 1);
$jRounds = forceArray($jRound->loadByParams($parameters));
$js = "document.getElementById('{$element_id}').length = 0;\n";
$selected = 0;
$roundsArr = array();
for ($i = 0; $i < count($jRounds); $i++) {
    if ($jRounds[$i]->id == $curr and !$preselected) {
        $selected = $i;
    }
    $js .= "document.getElementById('{$element_id}').options[{$i}] = new Option('" . $jRounds[$i]->round . "', '" . $jRounds[$i]->id . "');\n";
    $roundsArr[$jRounds[$i]->id] = $i;
}