示例#1
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}";
     $database->setQuery($query);
     $database->query();
     if ($database->getNumRows() > 1) {
         $jObjs = array();
         $list = (array) $database->loadResultArray();
         foreach ($list as $id) {
             $jObj = new jTipsUser($database);
             $jObj->load($id);
             array_push($jObjs, $jObj);
         }
         return $jObjs;
     } else {
         if ($database->getNumRows() == 1) {
             $this->load($database->loadResult());
             return $this;
         } else {
             return FALSE;
         }
     }
 }
示例#2
0
文件: helper.php 项目: joomux/jTips
 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;
 }
示例#3
0
 * @copyright Copyright &copy; 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');
}
示例#4
0
文件: MailMan.php 项目: joomux/jTips
 //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 {
             jTipsLogger::_log('failed to send reminder email to ' . $recipient, 'error');
示例#5
0
 function getRoundWinners()
 {
     global $database, $jTips;
     //$jSeason = new jSeason($database);
     //$jSeason->load($this->season_id);
     //Bug 209 - late entrants appear as last round winners
     //get the users that have tipped for this round
     $query = "SELECT user_id FROM #__jtips_tips t JOIN #__jtips_games g ON t.game_id = g.id AND g.round_id = " . $database->Quote($this->getPrev(false, true, true)) . " GROUP BY t.user_id";
     $database->setQuery($query);
     $user_ids = $database->loadResultArray();
     //Get the best score
     $query = "SELECT MAX(points) AS points FROM #__jtips_history WHERE round_id = " . $database->Quote($this->getPrev(false, true, true)) . " AND user_id IN ('" . implode("', '", $user_ids) . "')";
     //jTipsDebug($query);
     $database->setQuery($query);
     $max = $database->loadResult();
     if (is_null($max)) {
         return array();
     }
     $num_to_show = $jTips['NumDefault'];
     $query = "SELECT user_id FROM #__jtips_history WHERE points = {$max} AND round_id = " . $database->Quote($this->getPrev(false, true, true)) . " ORDER BY `precision` ASC" . ($num_to_show ? " LIMIT {$num_to_show}" : "");
     $database->setQuery($query);
     $row = $database->loadResultArray();
     $users = array();
     if (is_array($row) and !empty($row)) {
         foreach ($row as $id) {
             $jTipsUser = new jTipsUser($database);
             $jTipsUser->load($id);
             array_push($users, $jTipsUser);
         }
     }
     return $users;
 }
示例#6
0
 /**
  * 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;
 }
示例#7
0
文件: list.php 项目: joomux/jTips
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) {
    $options[] = jTipsHTML::makeOption($season->id, $season->name);
示例#8
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;
 }
示例#9
0
文件: jtips.php 项目: joomux/jTips
    ?>
</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);
}
if (jTipsGetParam($_REQUEST, 'menu', 1)) {
    $_REQUEST['season'] = $jTipsCurrentUser->season_id;
示例#10
0
 $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);
             }
         }
         $alt = $name;
         if (!empty($img)) {
示例#11
0
文件: remove.php 项目: joomux/jTips
/**
 * Website: www.jtips.com.au
 * @author Jeremy Roberts
 * @copyright Copyright &copy; 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);