function destroy($id = false) { global $database; if ($id == false) { $id = $this->id; } //this will delete all history for this round as well as all games //destroy the games first $params = array('round_id' => $id); $jGame = new jGame($database); $jGames = forceArray($jGame->loadByParams($params)); if (!empty($jGames)) { foreach ($jGames as $game) { $game->destroy(); } } //now destroy the history $jHistory = new jHistory($database); $jHistories = forceArray($jHistory->loadByParams($params)); if (!empty($jHistories)) { foreach ($jHistories as $history) { $history->destroy(); } } //delete any comments for this round $jComment = new jComment($database); $jComments = forceArray($jComment->loadByParams($params)); if (!empty($jComments)) { jTipsLogger::_log('deleting comments'); foreach ($jComments as $comment) { $comment->destroy(); } } //finally, delete the round jTipsLogger::_log("Delete " . $this->_tbl . " record with id = '{$id}'"); return $this->delete($id); }
function destroy($id = false) { if ($id == FALSE) { $id = $this->id; } jTipsLogger::_log("Delete " . $this->_tbl . " record with id = '{$id}'"); //delete all history records for this user and season if (!$this->id) { $this->load($id); } // BUG 129 - Unsubscribing from season leaves history $params = array('user_id' => $id); //deleting history etc can take a while, so dont time out set_time_limit(0); $jHistory = new jHistory($this->_db); $jHistories = forceArray($jHistory->loadByParams($params)); jTipsLogger::_log('Found ' . count($jHistories) . ' history records for user ' . $id, 'INFO'); if (is_array($jHistories) and !empty($jHistories)) { foreach ($jHistories as $jHist) { jTipsLogger::_log('deleting history record', 'INFO'); $jHist->destroy(); } } //reset outof and ranks for remaining users //get the rounds to be updated firs $query = "SELECT id FROM #__jtips_rounds WHERE season_id = '" . $this->season_id . "' AND scored = 1"; $this->_db->setQuery($query); $rids = $this->_db->loadResultArray(); //die(implode(", ", $rids)); if (!empty($rids)) { foreach ($rids as $r) { $jHistory->setRanks($r); } } //Now delete the tips $tip = new jTip($this->_db); $tips = forceArray($tip->loadByParams($params)); if (!empty($tips)) { foreach ($tips as $t) { $t->destroy(); } } // BUG 402 - need to also delete any comments made $comment = new jComment($this->_db); $comments = $comment->loadByParams($params); if (!empty($comments)) { foreach ($comments as $c) { $c->destroy(); } } return $this->delete($id); }
jTipsLogger::_log('done saving jTip with id ' . $jTip->id . ' for game ' . $jGame->id); } if (jTipsGetParam($_REQUEST, 'doubleup', false) and empty($jTipsCurrentUser->doubleup)) { $jTipsCurrentUser->doubleup = jTipsGetParam($_REQUEST, 'doubleup', false); $jTipsCurrentUser->save(); } else { if (!empty($jTipsCurrentUser->doubleup) and $jTipsCurrentUser->doubleup == $jRound->id and !jTipsGetParam($_REQUEST, 'doubleup', false)) { $jTipsCurrentUser->doubleup = null; $jTipsCurrentUser->save(); } } $comment = trim(strip_tags(stripslashes(jTipsGetParam($_REQUEST, 'comment', '')))); $comment = cleanComment(str_replace('\\', '', $comment)); if ($jTips['EnableComments'] == 1 && !empty($comment)) { jTipsLogger::_log('saving comment'); $jComment = new jComment($database); $jCommentParams = array('user_id' => $jTipsCurrentUser->id, 'round_id' => $jRound->id); $jComment->loadByParams($jCommentParams); $jComment->user_id = $jTipsCurrentUser->id; $jComment->round_id = $jRound->id; $jComment->comment = $comment; $jComment->save(); jTipsLogger::_log('comment saved'); } $emailResult = ''; if ($jTips['TipsNotifyEnable'] and $jTipsCurrentUser->getPreference('tips_notifications')) { if (sendTipsConfirmation($jTipsCurrentUser, $myTips)) { $emailResult = '. ' . $jLang['_COM_TIPS_EMAIL_SUCCESS']; } else { $emailResult = '. ' . $jLang['_COM_TIPS_EMAIL_FAILURE']; }
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); }
function display($hideColumns = array(), $showThisRound = true) { global $database, $jTips, $jLang, $mosConfig_live_site, $mainframe, $jTipsCurrentUser, $Itemid; if (empty($this->jTipsUser->id)) { echo ""; return; } ?> <style type="text/css"> @import url(<?php echo $mosConfig_live_site; ?> /templates/<?php echo jTipsGetTemplateName(); ?> /css/template.css); @import url(<?php echo $mosConfig_live_site; ?> /components/com_jtips/css/jtips-popup.css); </style> <script type='text/javascript' src='<?php echo $mosConfig_live_site; ?> /components/com_jtips/js/mootools.js'></script> <script type='text/javascript' src='<?php echo $mosConfig_live_site; ?> /components/com_jtips/js/Popup.js'></script> <?php $width = $jTips['ShowTipsWidth'] - 40; if ($jTips['ShowTipsPadding']) { ?> <div style="padding-top:10px;padding-left:10px;padding-right:10px;padding-bottom:10px;width:<?php echo $width; ?> px;text-align:center;"> <?php } ?> <h2 style='text-align:center;'><?php echo $this->jSeason->name; ?> <?php echo $jLang['_COM_SHOWTIPS_ROUND']; ?> <?php echo $this->jRound->round; ?> </h2> <?php if ($jTips['SocialIntegration'] and $showThisRound) { if ($jTips['SocialIntegration'] == 'cb') { $imgSrc = getCommunityBuilderAvatar($this->jTipsUser->user_id); $link = jTipsRoute("index.php?option=com_comprofiler&task=userProfile&user={$this->jTipsUser->user_id}"); } else { $imgSrc = getJomSocialAvatar($this->jTipsUser->user_id); $link = getJomSocialProfileLink($this->jTipsUser->user_id); } ?> <div style="text-align:center;"> <a href="javascript:void(0);" onClick="parent.location='<?php echo $link; ?> ';" title='View Profile' id='userLadderLink_<?php echo $this->jTipsUser->id; ?> '> <img src="<?php echo $imgSrc; ?> " border="0" alt="" /> </a> </div> <?php } if ($this->stats) { $this->showStats(); } //BUG 189 - Which order should the tips panel be shown in if ($this->jSeason->tips_layout == 'away') { $left = 'away'; $right = 'home'; } else { $left = 'home'; $right = 'away'; } ?> <table align='center' width='100%' border='0' cellspacing='0' style="padding-top:25px;"> <thead> <tr class="sectiontableheader"> <?php if (!in_array($left, $hideColumns)) { ?> <th class="sectiontableheader TB_th"><?php echo $jLang['_COM_GAME_' . strtoupper($left)]; ?> </th><?php } if (!in_array($right, $hideColumns)) { ?> <th class="sectiontableheader TB_th"><?php echo $jLang['_COM_GAME_' . strtoupper($right)]; ?> </th><?php } if (!in_array('tipped', $hideColumns)) { ?> <th class="sectiontableheader TB_th"><?php echo $jLang['_COM_DASH_TIPPED']; ?> </th><?php } if (!in_array('result', $hideColumns)) { ?> <th class="sectiontableheader TB_th"><?php echo $jLang['_COM_TIPS_RESULT']; ?> </th><?php } if (!in_array('more', $hideColumns)) { ?> <th class="sectiontableheader TB_th"><?php echo $jLang['_COM_TIPS_MORE']; ?> </th><?php } ?> </tr> </thead> <tbody> <?php $rowIndex = 0; $i = 1; $hasTipped = $this->jTipsUser->hasTipped($this->jRound->id); $byeTeams = array(); // Might want to list the byes somewhere later foreach ($this->jGames as $jGame) { $leftTeam = new jTeam($database); $left_id = $left . '_id'; //$leftTeam->load($jGame->$left_id); $rightTeam = new jTeam($database); $right_id = $right . '_id'; //$rightTeam->load($jGame->$right_id); // Skip games with byes $leftLoaded = $rightLoaded = false; if ($jGame->{$left_id}) { $leftTeam->load($jGame->{$left_id}); $leftLoaded = true; } if ($jGame->{$right_id}) { $rightTeam->load($jGame->{$right_id}); $rightLoaded = true; } if (!$leftLoaded and $rightLoaded) { $byeTeams[] = $rightTeam; } if ($leftLoaded and !$rightLoaded) { $byeTeams[] = $leftTeam; } if (!$leftLoaded or !$rightLoaded) { continue; } $jTip = new jTip($database); $jTipParams = array('user_id' => $this->jTipsUser->id, 'game_id' => $jGame->id); $jTip->loadByParams($jTipParams); $overlib_text = ""; if ($jTip->tip_id == $leftTeam->id) { $tipName = $leftTeam->getName(); $tip = $leftTeam->getDisplayLogoName(); $nonName = $rightTeam->getName(); } else { if ($jTip->tip_id == $rightTeam->id) { $tipName = $rightTeam->getName(); $tip = $rightTeam->getDisplayLogoName(); $nonName = $leftTeam->getName(); } else { if ($jTip->tip_id == -1) { $tip = $jLang['_COM_GAME_DRAW']; $tipName = $leftTeam->getName(); $nonName = $rightTeam->getName(); } else { $tip = $jLang['_ADMIN_CONF_NONE']; } } } if ($jGame->winner_id == $jTip->tip_id) { $result = "<img src='" . $mosConfig_live_site . "/administrator/images/tick.png' alt='Y' border='0' align='middle' />"; } else { $result = "<img src='" . $mosConfig_live_site . "/administrator/images/publish_x.png' alt='N' border='0' align='middle' />"; } $onClick = "onClick='toggleMore(" . $jGame->id . ", this)'"; $more = "<img src='{$mosConfig_live_site}/components/com_jtips/images/show.gif' alt='more' border='0' {$onClick} style='cursor:pointer;' />"; $rowIndex++; ?> <tr class="sectiontableentry<?php echo $i % 2 + 1; ?> " valign='middle'> <?php if (!in_array($left, $hideColumns)) { if ($jGame->winner_id == $leftTeam->id) { $style = "style='font-weight:bold;'"; } else { if ($jGame->winner_id == -1) { $style = "style='font-style:italic;'"; } else { $style = ''; } } ?> <td class="sectiontableentry<?php echo $i % 2 + 1; ?> " align="left" <?php echo $style; ?> ><?php echo $leftTeam->getDisplayLogoName(); ?> </td><?php } if (!in_array($right, $hideColumns)) { if ($jGame->winner_id == $rightTeam->id) { $style = "style='font-weight:bold;'"; } else { if ($jGame->winner_id == -1) { $style = "style='font-style:italic;'"; } else { $style = ''; } } ?> <td class="sectiontableentry<?php echo $i % 2 + 1; ?> " align="left" <?php echo $style; ?> ><?php echo $rightTeam->getDisplayLogoName(); ?> </td><?php } if (!in_array('tipped', $hideColumns)) { ?> <td class="sectiontableentry<?php echo $i % 2 + 1; ?> " align="left"><?php echo $tip; ?> </td><?php } if (!in_array('result', $hideColumns)) { ?> <td class="sectiontableentry<?php echo $i % 2 + 1; ?> " style='text-align:center;'><?php echo $result; ?> </td><?php } if (!in_array('more', $hideColumns)) { ?> <td class="sectiontableentry<?php echo $i % 2 + 1; ?> " style='text-align:center;'><?php echo $more; ?> </td><?php } ?> </tr> <?php /* * Process the in-depth game analysis */ $left_score_field = $left . '_score'; $right_score_field = $right . '_score'; if ($jGame->winner_id == $leftTeam->id) { $winnerName = $leftTeam->getDisplayLogoName(); } else { if ($jGame->winner_id == $rightTeam->id) { $winnerName = $rightTeam->getDisplayLogoName(); } else { if ($jGame->winner_id == -1) { $winnerName = $jLang['_COM_GAME_DRAW']; } else { $winnerName = ''; } } } $gameTotal = 0; $tipWidth = 30; if (in_array('actual', $hideColumns)) { $tipWidth += 30; } if (in_array('awarded', $hideColumns)) { $tipWidth += 10; } ?> <tr> <td colspan="50" id="moreInfo<?php echo $jGame->id; ?> " style="display:none;"> <table width="100%" cellspacing="0"> <thead> <tr class="sectiontableheader"> <th class="sectiontableheader" width="30%"> </th> <th class="sectiontableheader" width="<?php echo $tipWidth; ?> %"><?php echo $jLang['_COM_SHOWTIPS_PREDICTED']; ?> </th> <?php if (!in_array('actual', $hideColumns)) { ?> <th class="sectiontableheader" width="30%"><?php echo $jLang['_COM_SHOWTIPS_ACTUAL']; ?> </th> <?php } if (!in_array('awarded', $hideColumns)) { ?> <th class="sectiontableheader" width="10%"><?php echo $jLang['_COM_SHOWTIPS_AWARDED']; ?> </th> <?php } ?> </tr> </thead> <tbody> <tr class="sectiontableentry1"> <th class="sectiontableentry1"><?php echo $jLang['_COM_DASH_TIPPED']; ?> </th> <td class="sectiontableentry1" align="left"><?php echo $tip; ?> </td> <?php if (!in_array('actual', $hideColumns)) { ?> <td class="sectiontableentry1" align="left"><?php echo $winnerName; ?> </td> <?php } if (!in_array('awarded', $hideColumns)) { ?> <td class="sectiontableentry1" style="text-align:right;"> <?php if ($hasTipped) { if ($jGame->winner_id == $jTip->tip_id) { // BUG 379 - Incorrect value displayed when draw correctly picked if ($jGame->winner_id == -1) { echo $this->jSeason->user_draw; $gameTotal += $this->jSeason->user_draw; } else { echo $this->jSeason->user_correct; $gameTotal += $this->jSeason->user_correct; } } else { echo '0'; } } else { //what were the default points here? if ($this->jSeason->user_none >= 0) { echo $this->jSeason->user_none; $gameTotal += $this->jSeason->user_none; } else { if ($this->jSeason->user_none == -1) { //holy crap! you got the lowest score equivalence! echo $jLang['_ADMIN_CONF_ACT_NA']; } else { if ($this->jSeason->user_none == -2) { //you got all the away teams if ($jGame->winner_id == $jGame->away_id) { echo $this->jSeason->user_correct; $gameTotal += $this->jSeason->user_correct; } else { echo '0'; } } } } } ?> </td> <?php } ?> </tr> <?php $subIndex = 1; if ($jGame->has_score) { ?> <tr class="sectiontableentry<?php echo $subIndex % 2 + 1; ?> "> <th class="sectiontableentry<?php echo $subIndex % 2 + 1; ?> "><?php echo $jLang['_COM_DASH_POINTS']; ?> </th> <td class="sectiontableentry<?php echo $subIndex % 2 + 1; ?> "><?php echo $jTip->{$left_score_field} + 0; ?> - <?php echo $jTip->{$right_score_field} + 0; ?> </td> <?php if (!in_array('actual', $hideColumns)) { ?> <td class="sectiontableentry<?php echo $subIndex % 2 + 1; ?> "><?php echo $jGame->{$left_score_field}; ?> - <?php echo $jGame->{$right_score_field}; ?> </td> <?php } if (!in_array('awarded', $hideColumns)) { ?> <td class="sectiontableentry<?php echo $subIndex % 2 + 1; ?> " style="text-align:right;"> <?php if ($jTip->{$left_score_field} == $jGame->{$left_score_field} and $jTip->{$right_score_field} == $jGame->{$right_score_field}) { echo $this->jSeason->user_pick_score; $gameTotal += $this->jSeason->user_pick_score; } else { echo '0'; } ?> </td> <?php } ?> </tr> <?php $subIndex++; } if ($jGame->has_margin) { ?> <tr class="sectiontableentry<?php echo $subIndex % 2 + 1; ?> "> <th class="sectiontableentry<?php echo $subIndex % 2 + 1; ?> "><?php echo $jLang['_COM_TIPS_MARGIN']; ?> </th> <td class="sectiontableentry<?php echo $subIndex % 2 + 1; ?> "><?php echo $jTip->margin + 0; ?> </td> <?php if (!in_array('actual', $hideColumns)) { ?> <td class="sectiontableentry<?php echo $subIndex % 2 + 1; ?> "><?php echo abs($jGame->{$left_score_field} - $jGame->{$right_score_field}); ?> </td> <?php } if (!in_array('awarded', $hideColumns)) { ?> <td class="sectiontableentry<?php echo $subIndex % 2 + 1; ?> " style="text-align:right;"> <?php if ($jTip->margin == abs($jGame->{$left_score_field} - $jGame->{$right_score_field})) { echo $this->jSeason->user_pick_margin; $gameTotal += $this->jSeason->user_pick_margin; } else { echo '0'; } ?> </td> <?php } ?> </tr> <?php $subIndex++; } if ($jGame->has_bonus) { if ($jGame->bonus_id == $leftTeam->id) { $bonusTeam = $leftTeam->getDisplayLogoName(); } else { if ($jGame->bonus_id == $rightTeam->id) { $bonusTeam = $rightTeam->getDisplayLogoName(); } else { if ($jGame->bonus_id == -2) { $bonusTeam = 'Both Teams'; } else { $bonusTeam = ""; } } } if ($jTip->bonus_id == $leftTeam->id) { $bonusTip = $leftTeam->getDisplayLogoName(); } else { if ($jTip->bonus_id == $rightTeam->id) { $bonusTip = $rightTeam->getDisplayLogoName(); } else { if ($jTip->bonus_id == -2) { $bonusTip = 'Both Teams'; } else { $bonusTip = $jLang['_ADMIN_CONF_NONE']; } } } ?> <tr class="sectiontableentry<?php echo $subIndex % 2 + 1; ?> "> <th class="sectiontableentry<?php echo $subIndex % 2 + 1; ?> "><?php echo $jLang['_COM_SHOWTIPS_BONUS_TEAM']; ?> </th> <td class="sectiontableentry<?php echo $subIndex % 2 + 1; ?> " align="left"><?php echo $bonusTip; ?> </td> <?php if (!in_array('actual', $hideColumns)) { ?> <td class="sectiontableentry<?php echo $subIndex % 2 + 1; ?> "><?php echo $bonusTeam; ?> </td> <?php } if (!in_array('awarded', $hideColumns)) { ?> <td class="sectiontableentry<?php echo $subIndex % 2 + 1; ?> " style="text-align:right;"> <?php if ($jGame->bonus_id == $jTip->bonus_id) { echo $this->jSeason->user_pick_bonus; $gameTotal += $this->jSeason->user_pick_bonus; } else { echo '0'; } ?> </td> <?php } ?> </tr> <?php } ?> </tbody> <?php if (!in_array('awarded', $hideColumns)) { ?> <tfoot> <tr class="sectiontableheader"> <th class="sectiontableheader" colspan="3"><?php echo $jLang['_COM_SHOWTIPS_TOTAL']; ?> </th> <th class="sectiontableheader" style="text-align:right;"><?php echo $gameTotal; ?> </th> </tr> </tfoot> <?php } ?> </table> </td> </tr> <?php $i++; } ?> </tbody> </table> <?php /* * Do we have a comment to show */ $jComment = new jComment($database); $jCommentParams = array('user_id' => $this->jTipsUser->id, 'round_id' => $this->jRound->id); $jComment->loadByParams($jCommentParams); if (isset($jComment->comment) && !empty($jComment->comment)) { ?> <hr /> <p align="center"><?php echo jTipsStripslashes($jComment->comment); ?> </p> <?php } /* * Show the Peek into Next Round link be shown and parsed */ if ($jTips['EnableShowTips'] == 1 and $showThisRound) { //getCurrentUser $current_round_id = $this->jSeason->getCurrentRound(); $showFuture = false; if (isset($jTipsCurrentUser->id) and !empty($jTipsCurrentUser->id)) { if ($jTips['ShowTipsAccess'] == 'any' or $jTips['ShowTipsAccess'] == 'processed' and $jTipsCurrentUser->hasTipped($current_round_id) or $jTips['ShowTipsAccess'] == 'inprogress' and $this->jRound->getStatus() !== false) { $showFuture = true; } } else { if ($jTips['ShowTipsAccess'] == 'any') { $showFuture = true; } } if ($current_round_id != $this->jRound->id and $current_round_id and $showFuture) { $hide = array('result', 'actual', 'awarded'); $colsToHide = json_encode($hide); $data = "&season={$this->jSeason->id}&hide=" . rawurlencode($colsToHide); if ($Itemid) { $data .= "&Itemid={$Itemid}"; } if (isJoomla15()) { ?> <p align="center"><a href="<?php echo jTipsRoute("index2.php?option=com_jtips&view=CompetitionLadder&menu=0&action=ShowTips&uid=" . $this->jTipsUser->id . "&rid=" . $current_round_id . $data); ?> "><?php echo $jLang['_POPUP_TIPS_PEEK']; ?> </a></p> <?php } else { ?> <p align="center"><a href="javascript:loadTipsPopup(<?php echo $this->jTipsUser->id; ?> , <?php echo $current_round_id; ?> , $('mb_caption'), '<?php echo $data; ?> ');"><?php echo $jLang['_POPUP_TIPS_PEEK']; ?> </a></p> <?php } } } if ($jTips['ShowTipsPadding']) { echo "</div>"; } }
function getLastRoundSummaryDetail(&$jTipsUser, $col) { global $jTips, $jLang, $database; $jSeason = new jSeason($database); $jSeason->load($jTipsUser->season_id); switch ($col) { case 'season': return $jSeason->name; break; case 'last_won': //return $jTipsUser->getName(); // BUG 313 - Social Integration on Last Round Summary dashlet if (isset($jTips['SocialIntegration']) and !empty($jTips['SocialIntegration'])) { // which type of integration if ($jTips['SocialIntegration'] == 'cb') { // Community Builder $link = jTipsRoute("index.php?option=com_comprofiler&task=userProfile&user="******"<img src='{$img}' alt='Avatar' title='" . $jTipsUser->getName() . "' align='absmiddle' /> <a href='{$link}'>" . $jTipsUser->getName() . "</a>"; return "<div style='text-align:left;'>{$html}</div>"; } else { return $jTipsUser->getName(); } break; case 'last_prec': $jHistory = new jHistory($database); return $jHistory->getLast($jTipsUser, 'precision'); break; case 'last_round': $jHistory = new jHistory($database); return $jHistory->getLast($jTipsUser); break; case 'last_prect': return $jTipsUser->getTotalScore('precision'); break; case 'last_tot': return $jTipsUser->getTotalScore('points'); break; case 'last_comm': $jComment = new jComment($database); $params = array('user_id' => $jTipsUser->id, 'round_id' => $jSeason->getLastRound()); $jComment->loadByParams($params); return jTipsStripslashes($jComment->comment); break; default: return '-'; } }
function loadAll($season_id = false) { global $database; if ($season_id) { $in = "WHERE round_id IN ("; $database->setQuery("SELECT roundid FROM #__jtips_rounds WHERE season_id = {$season_id};"); $rounds = $database->loadAssocList(); $in2 = ""; foreach ($rounds as $rid) { $in2 .= $rid['roundid'] . ","; } $in .= substr($in2, 0, -1) . ")"; } else { $in = ''; } $query = "SELECT id FROM #__jtips_comments {$in} ORDER BY updated DESC;"; $database->setQuery($query); $res = $database->loadAssocList(); $comments = array(); foreach ($res as $row) { $jComment = new jComment($database); $jComment->load($row['id']); $comments[] = $jComment; } return $comments; }
* * Description: build a paginated list of comments */ global $database, $jTips; require_once 'components/com_jtips/classes/jcomment.class.php'; require_once 'components/com_jtips/classes/jround.class.php'; $formData = array('title' => $jLang['_ADMIN_DASH_COMMENT_MANAGER'], 'editTask' => 'edit', 'module' => 'Comments', 'icon' => 'comments'); $currentDir = jTipsGetParam($_REQUEST, 'filter_order_Dir', 'asc'); if ($currentDir == 'asc') { $dir = 'desc'; } else { $dir = 'asc'; } //The header row $header = array('', "<a href='javascript:tableOrdering(\"comment\", \"{$dir}\", \"list\");'>" . $jLang['_COM_DASH_COMMENT'] . "</a>", $jLang['_COM_DASH_USER'], $jLang['_ADMIN_USERS_USERNAME'], $jLang['_ADMIN_ROUND_SEASON'], $jLang['_ADMIN_ROUND_ROUND'], "<a href='javascript:tableOrdering(\"updated\", \"{$dir}\", \"list\");'>" . $jLang['_ADMIN_COMM_POSTED'] . "</a>"); $jComment = new jComment($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', '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)); }
<?php defined('_JEXEC') or defined('_VALID_MOS') or die('Restricted Access'); /** * Website: www.jtips.com.au * @author Jeremy Roberts * @copyright Copyright © 2009, jTips * @license Commercial - See website for details * * @since 2.1 - 02/10/2008 * @version 2.1 * @package jTips * * Description: Updates a comment once edited */ //check for hack attempt jTipsSpoofCheck(); global $jTips, $database; require_once 'components/com_jtips/classes/jcomment.class.php'; $jComment = new jComment($database); if ($id = jTipsGetParam($_REQUEST, 'id', false)) { $jComment->load($id); } $jComment->bind($_POST); if ($jComment->save()) { $message = $jlang['_ADMIN_COMMENT_SAVE_SUCCESS']; } else { $message = $jlang['_ADMIN_COMMENT_SAVE_FAILURE'] . " " . $jComment->_error; } mosRedirect('index2.php?option=com_jtips&task=list&module=Comments', $message);
<?php defined('_JEXEC') or defined('_VALID_MOS') or die('Restricted Access'); /** * Website: www.jtips.com.au * @author Jeremy Roberts * @copyright Copyright © 2009, jTips * @license Commercial - See website for details * * @since 2.1 - 02/10/2008 * @version 2.1 * @package jTips * * Description: Delete the selected comments from the database */ //check for hack attempt jTipsSpoofCheck(); global $database; require_once 'components/com_jtips/classes/jcomment.class.php'; $ids = jTipsGetParam($_REQUEST, 'cid', array()); if (!is_array($ids) or empty($ids)) { //Should never get here mosRedirect('index2.php?option=com_jtips&task=list&module=Comments', 'Invalid Selection'); } $jComment = new jComment($database); $results = array(); foreach ($ids as $id) { $results[] = $jComment->destroy($id); } $message = 'Deleted ' . array_sum($results) . ' out of ' . count($results) . ' selected'; mosRedirect('index2.php?option=com_jtips&task=list&module=Comments', $message);
* @author Jeremy Roberts * @copyright Copyright © 2009, jTips * @license Commercial - See website for details * * @since 2.1 - 02/10/2008 * @version 2.1 * @package jTips * * Description: */ jTipsSpoofCheck(); global $database; require_once 'components/com_jtips/classes/jbadword.class.php'; require_once 'components/com_jtips/classes/jcomment.class.php'; $jBadWordFocus = new jBadWord($database); $jCommentFocus = new jComment($database); $badwords = forceArray($jBadWordFocus->loadByParams()); $comments = forceArray($jCommentFocus->loadByParams()); $count = $deleted = $replaced = 0; foreach ($comments as $jComment) { foreach ($badwords as $jBadWord) { $search = '/' . $jBadWord->badword . '/' . ($jBadWord->match_case == 1 ? 'i' : ''); $found = preg_match_all($search, $jComment->comment, $matches); if ($found > 0) { $count++; $found = $found + $jBadWord->hits; $jBadWord->hits = $found; if ($jBadWord->action == 'delete') { $jComment->delete($jComment->id); $deleted++; } else {
//Load the current user. //This should be done in the calling script and the jTipsUser object made a global /*$jTipsUser = new jTipsUser($database); $parameters = array( 'season_id' => $jSeason->id, 'user_id' => $id ); $jTipsUser->loadByParams($parameters);*/ $parameters = array(); $jSeasons = forceArray($jSeason->loadByParams($parameters)); for ($i = 0; $i < count($jSeasons); $i++) { if ($jSeasons[$i]->end_time < gmdate('Y-m-d')) { unset($jSeasons[$i]); } } //Load the current round info $jRound = new jRound($database); $rid = jTipsGetParam($_REQUEST, 'rid', false); if (!$rid) { $rid = $jSeason->getCurrentRound(); } $jRound->load($rid); $render->assign('jRound', $jRound); //Load the comment for this round $jComment = new jComment($database); $parameters = array('user_id' => $jTipsCurrentUser->id, 'round_id' => $jRound->id); $jComment->loadByParams($parameters); $render->assign('jComment', $jComment); $render->display(); } //jtips_HTML::jtips_addtips($jTipsUser, $jRound, $jSeason, $jSeasons, $jComment);
* @copyright Copyright © 2009, jTips * @license Commercial - See website for details * * @since 2.1 - 02/10/2008 * @version 2.1 * @package jTips * * Description: Allows editing of an existing comment */ jTipsSpoofCheck(); 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);