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; }
/** * Method is called after user data is stored in the database * * @param array holds the new user data * @param boolean true if a new user is stored * @param boolean true if user was succesfully stored in the database * @param string message */ function onAfterStoreUser($user, $isnew, $success, $msg) { global $mainframe, $database, $mosConfig_absolute_path; if (!JFolder::exists(JPATH_ADMINISTRATOR . '/components/com_jtips')) { return JText::_('jTips is not currently installed'); } if (!$success) { return JText::_('Failed to save user. Aborted'); } //Make sure this variable is available for use in included classes if (!$mosConfig_absolute_path) { $mosConfig_absolute_path = JPATH_SITE; } //now we can load the right jTips classes require_once JPATH_ADMINISTRATOR . '/components/com_jtips/utils/logger.php'; require_once JPATH_ADMINISTRATOR . '/components/com_jtips/utils/compat.php'; require_once JPATH_ADMINISTRATOR . '/components/com_jtips/utils/timedate.php'; require_once JPATH_ADMINISTRATOR . '/components/com_jtips/utils/functions.inc.php'; require_once JPATH_ADMINISTRATOR . '/components/com_jtips/classes/juser.class.php'; // convert the user parameters passed to the event // to a format the external application $args = array(); $args['id'] = $user['id']; $args['username'] = $user['username']; $args['email'] = $user['email']; $args['fullname'] = $user['name']; $args['password'] = $user['password']; if ($isnew) { //which season to subscribe to if ($this->params->get('auto_all')) { // add to all current competitions $query = "SELECT id FROM #__jtips_seasons WHERE start_time <= DATE(NOW()) AND end_time > DATE(NOW())"; $db =& JFactory::getDBO(); $db->setQuery($query); $list = $db->loadResultArray(); foreach ($list as $id) { $jTipsUser = new jTipsUser($database); $jTipsUser->user_id = $args['id']; $jTipsUser->season_id = $id; //$this->params->get('season_id'); $jTipsUser->status = $this->params->get('approve'); $jTipsUser->save(); } return; } $jTipsUser = new jTipsUser($database); $jTipsUser->user_id = $args['id']; $jTipsUser->season_id = $this->params->get('season_id'); $jTipsUser->status = $this->params->get('approve'); $jTipsUser->paid = 0; //Mark as unpaid by default if ($jTipsUser->save()) { return JText::_('User added to competition!'); } else { return JText::_('Error adding user to competition: ' . $jTipsUser->_db->getErrorMsg()); } } }
/** * Website: www.jtips.com.au * @author Jeremy Roberts * @copyright Copyright © 2009, jTips * @license Commercial - See website for details * * @since 2.1 - 01/10/2008 * @version 2.1 * @package jTips * * Description: */ require_once 'components/com_jtips/classes/juser.class.php'; global $database, $jLicence; if (!is_array(jTipsGetParam($_REQUEST, 'cid', array()))) { //Should never get here mosRedirect('index2.php?option=com_jtips&task=list&module=Users', 'Invalid Selection!'); } $results = array(); foreach (jTipsGetParam($_REQUEST, 'cid', array()) as $id) { $jTipsUser = new jTipsUser($database); $jTipsUser->load($id); $res = $jTipsUser->destroy(); $results[] = $res; } // BUG 382 - recount the number of users and update licence if (!empty($results)) { $jLicence->revalidate(true); } $message = 'Deleted ' . array_sum($results) . ' users out of ' . count($results) . ' selected'; mosRedirect('index2.php?option=com_jtips&task=list&module=Users', $message);
function inSeason(&$jSeason) { global $database; $params = array('user_id' => $this->user_id, 'season_id' => $jSeason->id); $jTipsUser = new jTipsUser($database); $jTipsUser->loadByParams($params); if (isset($jTipsUser->season_id) && !empty($jTipsUser->season_id) && $jTipsUser->season_id == $jSeason->id) { return TRUE; } else { return FALSE; } }
*/ global $database, $jTips, $mainframe; require_once 'components/com_jtips/classes/jround.class.php'; require_once 'components/com_jtips/classes/jhistory.class.php'; require_once 'components/com_jtips/classes/juser.class.php'; $mainframe->addCustomHeadTag("<script type='text/javascript' src='components/com_jtips/modules/Users/Users.js'></script>"); $formData = array('title' => $jLang['_ADMIN_USERS_TITLE'], 'editTask' => 'edit', 'module' => 'Users', 'icon' => 'user'); $currentDir = jTipsGetParam($_REQUEST, 'filter_order_Dir', 'asc'); if ($currentDir == 'asc') { $dir = 'desc'; } else { $dir = 'asc'; } //The header row $header = array('', "<a href='javascript:tableOrdering(\"name\", \"{$dir}\", \"list\");'>" . $jLang['_ADMIN_USERS_NAME'] . "</a>", "<a href='javascript:tableOrdering(\"username\", \"{$dir}\", \"list\");'>" . $jLang['_ADMIN_USERS_USERNAME'] . "</a>", $jLang['_ADMIN_ROUND_SEASON'], $jLang['_ADMIN_USERS_DOUBLE'], $jLang['_ADMIN_USERS_AVERAGE'], $jLang['_ADMIN_USERS_TOTAL'], $jLang['_ADMIN_USERS_PAID'], $jLang['_ADMIN_USERS_APPROVED']); $jTipsUser = new jTipsUser($database); $limitstart = jTipsGetParam($_REQUEST, 'limitstart', 0); $limit = jTipsGetParam($_REQUEST, 'limit', 25); $direction = jTipsGetParam($_REQUEST, 'filter_order_Dir', 'asc'); if (empty($direction)) { $direction = 'asc'; } $orderby = jTipsGetParam($_REQUEST, 'filter_order', 'name'); if (empty($orderby)) { $orderby = 'name'; } $params = array('order' => array('type' => 'order', 'direction' => $direction, 'by' => $orderby), 'join_users' => array('type' => 'join', 'join_table' => '#__users', 'lhs_table' => '#__jtips_users', 'lhs_key' => 'user_id', 'rhs_table' => '#__users', 'rhs_key' => 'id')); if ($season_id = jTipsGetParam($_REQUEST, 'season_id', false)) { $params['season_id'] = $season_id; } $jTipsUsers = forceArray($jTipsUser->loadByParams($params, $limit, $limitstart));
require_once $mosConfig_absolute_path . '/administrator/components/com_jtips/classes/jround.class.php'; require_once $mosConfig_absolute_path . '/administrator/components/com_jtips/classes/jteam.class.php'; require_once $mosConfig_absolute_path . '/administrator/components/com_jtips/classes/jtip.class.php'; if (jTipsFileExists($mosConfig_absolute_path . '/components/com_jtips/custom/views/CompetitionLadder/ShowTipsRender.ext.php')) { require_once $mosConfig_absolute_path . '/components/com_jtips/custom/views/CompetitionLadder/ShowTipsRender.ext.php'; } else { require_once $mosConfig_absolute_path . '/components/com_jtips/views/CompetitionLadder/ShowTipsRender.php'; } if (!isJoomla15()) { //Trash anything we have so far ob_clean(); ob_start(); } $render = new jTipsRenderShowTips(); $user_id = jTipsGetParam($_REQUEST, 'uid', ''); $jTipsUser = new jTipsUser($database); $jTipsUser->load($user_id); $render->assign('jTipsUser', $jTipsUser); $round_id = jTipsGetParam($_REQUEST, 'rid', ''); $jSeason = new jSeason($database); $jSeason->load($jTipsUser->season_id); $render->assign('jSeason', $jSeason); $jRound = new jRound($database); if ($round_id == false) { $complete = 0; while ($complete !== 1) { $tempRound = new jRound($database); if ($round_id == false) { $round_id = $jSeason->getCurrentRound(); } $tempRound->load($round_id);
function getUserLadder($num_to_show, $page = 0, $field = 'points', $dir = 'desc', $round_id = FALSE) { global $database, $jTips; $org_round_id = $round_id; if ($round_id === FALSE) { $round_id = $this->getLatestRound(); } $jHistory = new jHistory($database); $this->getUsers($round_id); $jTipsUsers = array(); $start_from = $num_to_show * $page; $go_to = min($start_from + $num_to_show, count($this->users)); for ($i = $start_from; $i < $go_to; $i++) { $jTipsUser =& $this->users[$i]; $params = array('user_id' => $this->users[$i]->id, 'round_id' => $round_id, 'left_join' => array('type' => 'left_join', 'join_table' => '#__jtips_rounds', 'lhs_table' => '#__jtips_history', 'rhs_table' => '#__jtips_rounds', 'lhs_key' => 'round_id', 'rhs_key' => 'id', 'supplement' => 'AND #__jtips_rounds.scored = 1')); $jHistory->loadByParams($params); if (is_property($jHistory, $field)) { $jTipsUser->{$field} = $jHistory->{$field}; } else { if ($field == 'pointst') { $jTipsUser->{$field} = $jTipsUser->getTotalScore('points'); } else { if ($field == 'prect') { $jTipsUser->{$field} = $jTipsUser->getTotalScore('precision'); } else { if ($field == 'rank') { $jTipsUser->{$field} = $jTipsUser->getRank($org_round_id); } else { if ($field == 'comment') { $jComment = new jComment($database); $params = array('user_id' => $jTipsUser->id, 'round_id' => $round_id); $jComment->loadByParams($params); $jTipsUser->{$field} = !empty($jComment->comment) ? $jComment->comment : ""; } else { $jTipsUser->{$field} = $jTipsUser->getName(); } } } } } array_push($jTipsUsers, $jTipsUser); } //jTipsSortArrayObjects($jTipsUsers, $field, $dir); //return $jTipsUsers; return jTipsUser::sort($jTipsUsers, $field, $dir); }
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) . " "; } } $query .= "GROUP BY #__jtips_tips.tip_id ORDER BY times_picked DESC"; $database->setQuery($query, 0, 1); $team = $database->loadRow(); if ($team) { $jTeam = new jTeam($database); $jTeam->load($team[0]); ?> <div style="text-align:center;"><?php $popupUrl = "view=TeamLadder&action=ShowTeam&menu=0&id=" . $jTeam->id . "&season_id=" . $jTeam->season_id; if (isJoomla15()) {
<h1 class='componentheading jmain_heading'><?php echo $jTips['Title']; ?> </h1> <?php } if (jTipsGetParam($_REQUEST, 'tmpl') != 'component') { // show the page title jtips_HTML::title(); } jTips_HTML::expired(); /* * Load the current user object */ global $jTipsCurrentUser, $mainframe; $jTipsCurrentUser = new jTipsUser($database); if (jTipsGetParam($_REQUEST, 'user_id', false)) { $jTipsCurrentUser->load(jTipsGetParam($_REQUEST, 'user_id', false)); } else { $my =& $mainframe->getUser(); $parameters = array('season_id' => getSeasonID(), 'user_id' => $my->id); //BUG 219 - simplify user loading // BUG 348 - when somehow multiple users exist for the same competition, load only one. $usersArray = forceArray($jTipsCurrentUser->loadByParams($parameters)); if (!count($usersArray)) { $jTipsCurrentUser->loadByParams($parameters); } else { $jTipsCurrentUser = array_shift($usersArray); } unset($parameters); }
* @license Commercial - See website for details * * @since 2.1 - 01/10/2008 * @version 2.1 * @package jTips * * Description: */ require_once 'components/com_jtips/classes/juser.class.php'; global $database, $jLicence; $season_id = jTipsGetParam($_REQUEST, 'season_id', false); $result = array(); $success = $fail = 0; if (is_numeric($season_id)) { foreach (jTipsGetParam($_REQUEST, 'cid', array()) as $uid) { $jTipsUser = new jTipsUser($database); $params = array('user_id' => $uid, 'season_id' => $season_id); $jTipsUser->loadByParams($params); if ($jTipsUser->exists() === false) { $jTipsUser->user_id = $uid; $jTipsUser->season_id = $season_id; $jTipsUser->status = 1; $saved = $jTipsUser->save(); if ($saved !== false) { $success++; array_push($result, 1); } else { $fail++; array_push($result, 0); } } else {
$jTip = new jTip($database); $limitstart = jTipsGetParam($_REQUEST, 'limitstart', 0); $limit = jTipsGetParam($_REQUEST, 'limit', $jTips['NumMax']); $params = array('join' => array('type' => 'join', 'join_table' => '#__jtips_games', 'lhs_table' => '#__jtips_tips', 'lhs_key' => 'game_id', 'rhs_table' => '#__jtips_games', 'rhs_key' => 'id'), 'group' => array('type' => 'group', 'by' => 'round_id`, `user_id'), 'order' => array('type' => 'order', 'by' => 'round_id', 'direction' => 'DESC')); if ($user_id = jTipsGetParam($_REQUEST, 'user_id', false)) { $params['user_id'] = $user_id; } $jTipArray = forceArray($jTip->loadByParams($params, $limit, $limitstart)); unset($params['order']); $pageNav = new mosPageNav($jTip->getCount($params, true), $limitstart, $limit); $header = array('', 'User', 'Round', 'Season'); $data = array(); $i = 0; foreach ($jTipArray as $tip) { $tip->fillInAdditionalFields(); $data[$tip->id] = array(makeListLink($tip->user->getName(), $i++), $tip->round_num, $tip->season->name); } $jSeason = new jSeason($database); $jSeasons = forceArray($jSeason->loadByParams(array())); $seasons = objectsToSelectList($jSeasons, 'name'); $jTipsUser = new jTipsUser($database); $jTipsUsers = forceArray($jTipsUser->loadByParams(array())); foreach ($jTipsUsers as $u) { $u->name = $u->getName() . " (" . $seasons[$u->season_id] . ")"; $jTipsUsersArray[] = $u; } $users = objectsToSelectList($jTipsUsersArray, 'name'); asort($users); $formData = array('title' => $jLang['_ADMIN_DASH_TIPS_MANAGER'], 'editTask' => 'edit', 'module' => 'Tips', 'icon' => 'tips'); $filters = array($jLang['_ADMIN_USERS_SELECT'] => makeSelectList($users, 'user_id', "id='user_id' onChange='this.form.submit();'", jTipsGetParam($_REQUEST, 'user_id', '')), $jLang['_ADMIN_SEASON_SELECT'] => makeSelectList($seasons, 'season_id', "id='season_id' onChange='this.form.submit();'", jTipsGetParam($_REQUEST, 'season_id', ''))); jTipsAdminDisplay::ListView($formData, $header, $data, $pageNav, 'list', $filters);
$query = "SELECT id FROM #__jtips_rounds WHERE season_id = " . $database->Quote($jSeason->id) . " AND scored = 1"; $database->setQuery($query); $rids = $database->loadResultArray(); //find the user $query = "SELECT user_id, AVG(points) pointsa, AVG(`precision`) preca FROM #__jtips_history " . "WHERE round_id IN ('" . implode("', '", $rids) . "') GROUP BY user_id "; if ($params->get('type') == 'worst') { $query .= " ORDER BY pointsa ASC, preca DESC, RAND()"; } else { $query .= " ORDER BY pointsa DESC, preca ASC, RAND()"; } //jTipsDebug($query); $database->setQuery($query, 0, 1); $result = $database->loadAssocList(); if (!empty($result) and count($result)) { $row = array_shift($result); $jTipsUser = new jTipsUser($database); //jTipsDebug($row); $jTipsUser->load($row['user_id']); //get the user avator if enabled $name = $jTipsUser->getName(); if ($params->get('socimage')) { if ($params->get('socimage') == 'cb') { // Link is to CB Pofile $img = getCommunityBuilderAvatar($jTipsUser->user_id); $link = "index.php?option=com_comprofiler&task=userProfile&user=" . $jTipsUser->user_id; } else { if ($params->get('socimage') == 'js') { $img = getJomSocialAvatar($jTipsUser->user_id); $link = getJomSocialProfileLink($jTipsUser->user_id); } }
$jSeasons = forceArray($jSeason->loadByParams(array())); //make a set of options for a select list $season_options = objectsToSelectList($jSeasons, 'name'); $filters = array('Select Season' => makeSelectList($season_options, 'season_id', "id='season_id' onChange='this.form.submit();'", $season_id)); //Load the Rounds if ($season_id) { $params = array('season_id' => $season_id); $jRound = new jRound($database); $jRounds = forceArray($jRound->loadByParams($params)); $round_options = objectsToSelectList($jRounds, 'round'); $filters['Select Round'] = makeSelectList($round_options, 'round_id', "id='round_id' onChange='this.form.submit();'", $round_id); } //Load the users if ($round_id and $season_id) { $params = array('season_id' => $season_id); $jTipsUser = new jTipsUser($database); $jTipsUsers = forceArray($jTipsUser->loadByParams($params)); $user_options = objectsToSelectList($jTipsUsers, 'getName', true); asort($user_options); $filters['Select User'] = makeSelectList($user_options, 'user_id', "id='user_id' onChange='this.form.submit();'", $user_id); } $tpl->selectLists = $filters; $data = array(); //Now we have the preliminary options, get the set of games if ($season_id and $round_id and $user_id) { $params = array('round_id' => $round_id); $jGame = new jGame($database); $jGames = forceArray($jGame->loadByParams($params)); foreach ($jGames as $game) { $params = array('game_id' => $game->id, 'user_id' => $user_id); $jTip = new jTip($database);
* * @since 2.1 - 16/10/2008 * @version 2.1 * @package jTips * * Description: */ global $database, $jTips, $mainframe; $season_id = getSeasonID(); require_once $mosConfig_absolute_path . '/administrator/components/com_jtips/classes/juser.class.php'; $my =& $mainframe->getUser(); //make sure we have a logged in user if (!$my->id or !isset($my->id) or empty($my->id)) { jTipsRedirect('index.php?option=com_jtips&Itemid=' . jTipsGetParam($_REQUEST, 'Itemid', '') . '&season=' . $season_id, 'Please register first'); } $jTipsUser = new jTipsUser($database); $jTipsUser->user_id = $my->id; //jTipsGetParam($_REQUEST, 'user_id', $my->id); $jTipsUser->status = $jTips['AutoReg']; $jTipsUser->season_id = $season_id; jTipsLogger::_log('current token: ' . $_SESSION['paypalToken'], 'INFO'); jTipsLogger::_log('returned token: ' . jTipsGetParam($_REQUEST, 'token', ''), 'INFO'); if ($jTips['Payments'] == 'paypal' and jTipsGetParam($_REQUEST, 'token', '') == $_SESSION['paypalToken']) { $jTipsUser->paid = 1; } $jTipsUser->save(); if ($jTips['UserNotifyEnable']) { $jTipsUser->sendNotificationEmail(''); } if ($jTips['RegisterAllCompetitions']) { $query = "SELECT id FROM #__jtips_seasons WHERE end_time > NOW() AND id <> " . $database->quote($season_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()); } $jTipsUser = new jTipsUser($database); $jTipsUsers = $jTipsUser->loadByParams($params); if (!is_array($jTipsUsers)) { if ($jTipsUser->exists()) { $jTipsUsers = array($jTipsUser); } else { $jTipsUsers = array(); } } jTipsLogger::_log('deleting users from season'); foreach ($jTipsUsers as $jTipsUser) { array_push($destroyed, $jTipsUser->destroy()); } array_push($destroyed, $jSeason->destroy()); if (in_array(FALSE, $destroyed)) { $message = 'Season(s) not cleanly removed!';
/** * 31 July 2007 * This function should now be deprecated */ function getOverallLadder($num_to_show, $round_id, $page = 0, $field = 'points', $dir = 'desc') { global $database; if ($field == 'pointst') { $field = 'points'; } else { if ($field == 'prect') { $field = 'precision'; } } $offset = $page * $num_to_show; //$query = "SELECT user_id, SUM(`$field`) AS total FROM #__jtips_history GROUP BY user_id ORDER BY total $dir"; $query = "SELECT #__jtips_history.user_id, SUM(`{$field}`) AS total" . " FROM #__jtips_history JOIN #__jtips_users ON #__jtips_history.user_id = #__jtips_users.id" . " JOIN #__users ON #__jtips_users.user_id = #__users.id" . " GROUP BY #__jtips_history.user_id ORDER BY total {$dir}"; if ($num_to_show) { $query .= " LIMIT {$num_to_show} OFFSET {$offset}"; } // BUG 368 - Call to undefined function jTipsDebug - not called as part of static class jTipsLogger::jTipsDebug($query, "jHistory::getOverallLadder"); $database->setQuery($query); $row = $database->loadResultArray(); $users = array(); foreach ($row as $user_id) { $jTipsUser = new jTipsUser($database); $jTipsUser->load($user_id); array_push($users, $jTipsUser); } return $users; }
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; }
$orderby = jTipsGetParam($_REQUEST, 'filter_order', 'comment'); if (empty($orderby)) { $orderby = 'comment'; } $params = array('order' => array('type' => 'order', 'direction' => $direction, 'by' => $orderby)); //has the season select been used? if ($season_id = jTipsGetParam($_REQUEST, 'season_id', false)) { $params['season_id'] = array('type' => 'join', 'join_table' => '#__jtips_rounds', 'lhs_table' => '#__jtips_comments', 'lhs_key' => 'round_id', 'rhs_table' => '#__jtips_rounds', 'rhs_key' => 'id', 'supplement' => 'AND #__jtips_rounds.season_id = ' . $jComment->_db->Quote($season_id)); } $jComments = forceArray($jComment->loadByParams($params, $limit, $limitstart)); $pageNav = new mosPageNav($jComment->getCount($params), $limitstart, $limit); $data = array(); $i = 0; foreach ($jComments as $comment) { //get the comment poster details $jTipsUser = new jTipsUser($database); $jTipsUser->load($comment->user_id); //Which round is it for $jRound = new jRound($database); $jRound->load($comment->round_id); if (strlen($comment->comment) > 100) { $suffix = '...'; } else { $suffix = ''; } $data[$comment->id] = array(makeListLink(substr(jTipsStripslashes($comment->comment), 0, 100) . $suffix, $i++), $jTipsUser->getUserField('name'), $jTipsUser->getUserField('username'), $comment->getSeasonName(), $jRound->round, TimeDate::toDisplayDateTime($comment->updated)); } $jSeason = new jSeason($database); $jSeasons = forceArray($jSeason->loadByParams()); $options = array(jTipsHTML::makeOption('', $jLang['_ADMIN_USERS_SELECT_SEASON'])); foreach ($jSeasons as $season) {
* @copyright Copyright © 2009, jTips * @license Commercial - See website for details * * @since 2.1 - 16/10/2008 * @version 2.1 * @package jTips * * Description: */ global $database, $jTips, $mainframe; require_once $mosConfig_absolute_path . '/administrator/components/com_jtips/classes/juser.class.php'; $my =& $mainframe->getUser(); $season_id = getSeasonID(); if (!$season_id or empty($my->id)) { jTipsRedirect('index.php?option=com_jtips&Itemid=' . jTipsGetParam($_REQUEST, 'Itemid')); } $jTipsUser = new jTipsUser($database); $parameters = array('user_id' => $my->id, 'season_id' => $season_id); $jTipsUser->loadByParams($parameters); if ($jTipsUser->exists()) { jTipsLogger::_log('removing user ' . $jTipsUser->id . ' from competition ' . $jTipsUser->season_id); $jTipsUser->destroy(); } $message = $jLang['_COM_UNSUBSCRIBE_SUCCESS']; //do we need to stop any paypal subscriptions? if ($jTips['Payments'] == 'paypal' and $jTips['PayPalIsSub'] and !empty($jTips['PayPalUnSub'])) { //Yes! redirect to paypal cancel page jTipsRedirect(stripslashes($jTips['PayPalUnSub']), $message); } else { jTipsRedirect('index.php?option=com_jtips&Itemid=' . jTipsGetParam($_REQUEST, 'Itemid') . '&season=' . $season_id, $message); }
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/jround.class.php'; require_once $include_path . 'classes/jseason.class.php'; 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);
/** * Website: www.jtips.com.au * @author Jeremy Roberts * @copyright Copyright © 2009, jTips * @license Commercial - See website for details * * @since 2.1.14 - 31/08/2009 * @version 1.0.0 * @package jTips * * Description: apply the changes and reload the configuration page */ global $database; jTipsSpoofCheck(); require_once 'components/com_jtips/classes/juser.class.php'; jTipsLogger::_log('Cleaning users', 'info'); // find out which users are not in the #__users table $query = "SELECT j.id FROM #__jtips_users j LEFT JOIN #__users u ON j.user_id = u.id WHERE u.id IS NULL"; $database->setQuery($query); $database->query(); $total = $database->getNumRows(); jTipsLogger::_log('Found ' . $total . ' users to be removed'); if ($total > 1) { $ids = (array) $database->loadResultArray(); foreach ($ids as $id) { $jTipsUser = new jTipsUser($database); $jTipsUser->destroy($id); } } $message = sprintf($jLang['_COM_ADMIN_USERS_CLEANED_MESSAGE'], $total); mosRedirect('index2.php?option=com_jtips&module=Users&task=list', $message);
<?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: Saves the User Preferences */ global $database, $Itemid; $jTipsUsers = new jTipsUser($database); $jTipsUserParams = array('user_id' => jTipsGetParam($_REQUEST, 'id', 0)); $jTipsUserArr = forceArray($jTipsUsers->loadByParams($jTipsUserParams)); foreach ($jTipsUserArr as $jTipsUser) { $jTipsUser->setPreference('default_season', jTipsGetParam($_REQUEST, 'default_season', -1)); $jTipsUser->setPreference('timezone', jTipsGetParam($_REQUEST, 'timezone', null)); $jTipsUser->setPreference('email_reminder', jTipsGetParam($_REQUEST, 'email_reminder', '0')); $jTipsUser->setPreference('tips_notifications', jTipsGetParam($_REQUEST, 'tips_notifications', '0')); } $return_view = jTipsGetParam($_REQUEST, 'return', 'Dashboard'); if (!$return_view) { $return_view = 'Dashboard'; } jTipsRedirect('index.php?option=com_jtips&view=' . jTipsGetParam($_REQUEST, 'return', 'Dashboard') . '&Itemid=' . $Itemid . '&season=' . getSeasonID());
/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; ?> competition!</p><?php } else { // valid user and season, get their tips $round_id = $jSeason->getCurrentRound(); if (!$round_id) { ?> <p class="message">Competition has ended.</p><?php } else { // valid everything, get the tips
} //MySQL 4 fix (no sub selects) $query = "SELECT user_id FROM #__jtips_remind WHERE round_id = " . $round[0]['id'] . " AND notified = 1"; //echo $query; $database->setQuery($query); $user_ids = (array) $database->loadResultArray(); //Get all active users in this season // BUG 397 - placeholders unavailable for email template. Fix supplied by James Butler $query = "SELECT ju.*, u.email, u.name, u.username FROM #__jtips_users ju JOIN #__users u ON ju.user_id = u.id WHERE ju.status = 1 AND season_id = {$season_id} AND ju.id NOT IN ('" . implode("', '", $user_ids) . "') AND u.block = 0"; //echo $query; $database->setQuery($query); $rows = (array) $database->loadAssocList(); jTipsLogger::_log('found ' . count($rows) . ' users to try to send to ', 'info'); foreach ($rows as $user) { ksort($user); $jTipsUser = new jTipsUser($database); $jTipsUser->load($user['id']); //jTipsLogger::_log($jTipsUser); if ($jTipsUser->getPreference('email_reminder')) { $recipient = $user['email']; $user['round'] = $round[0]['round']; $user['competition'] = $round[0]['season']; $user['season'] = $round[0]['season']; $body = parseTemplate($body, $variables, $user); $record = array('round_id' => $round[0]['id'], 'user_id' => $user['id'], 'notified' => 0); $attempted++; if (jTipsMail($from, $fromname, $recipient, $subject, $body)) { $record['notified'] = 1; jTipsLogger::_log('sent reminder email to ' . $recipient . ' subject: ' . $subject . ' from: ' . $fromname . ' <' . $from . '>', 'info'); $sent++; } else {
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; }
* @author Jeremy Roberts * @copyright Copyright © 2009, jTips * @license Commercial - See website for details * * @since 2.1 - 16/10/2008 * @version 2.1 * @package jTips * * Description: */ global $database; ob_clean(); require_once 'components/com_jtips/classes/juser.class.php'; $user_id = jTipsGetParam($_REQUEST, 'user_id', ''); $field = jTipsGetParam($_REQUEST, 'field', ''); $jTipsUser = new jTipsUser($database); $jTipsUser->load($user_id); $jTipsUser->{$field} = intval(!$jTipsUser->{$field}); $jTipsUser->save(); if ($jTipsUser->{$field}) { if ($field == 'status') { //send notification email $jTipsUser->sendNotificationEmail('Approval'); } die('tick'); } else { if ($field == 'status') { //send notification email $jTipsUser->sendNotificationEmail('Reject'); } die('publish_x');
global $database, $jTips, $jLang; 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/juser.class.php'; $jComment = new jComment($database); $ids = jTipsGetParam($_REQUEST, 'cid', array()); //Do we have an existing Season? $id = array_shift($ids); if (is_numeric($id)) { $jComment->load($id); } if (!$jComment->exists()) { mosRedirect('index2.php?option=com_jtips&task=list&module=Comments', $jLang['_ADMIN_COMMENT_LOAD_ERROR']); } $jTipsUser = new jTipsUser($database); $jTipsUser->load($jComment->user_id); $title = $jLang['_ADMIN_DASH_COMMENT_MANAGER'] . ": " . $jLang['_ADMIN_OTHER_EDIT']; $mainframe->addCustomHeadTag("<script type='text/javascript' src='components/com_jtips/modules/Comments/Comments.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); } //which season is this in? $jRound = new jRound($database); $jRound->load($jComment->round_id); $jRounds = forceArray($jRound->loadByParams(array('season_id' => $jRound->season_id)));