//should columns be hidden? $hideRaw = jTipsGetParam($_REQUEST, 'hide'); if ($hideRaw) { //BUG 231 - Add a fallback in case we are using PHP < 5.2.0 if (!function_exists('json_decode')) { $hideColumns = array('result', 'actual', 'awarded'); } else { // TODO: need to ensure json_decode returns an array here $hideColumns = json_decode(jTipsStripslashes(rawurldecode($hideRaw))); } // BUG 371 - use a fallback if something went wrong if (!$hideColumns) { $hideColumns = array('result', 'actual', 'awarded'); } $render->assign('stats', false); } else { $hideColumns = array(); //should the extra stats be calculated $jHistory = new jHistory($database); if ($jTips['ShowTipsStats']) { //ok, here we go! $stats = array('tips' => array('round' => $jTipsUser->getTipsAccuracy($jRound->id), 'overall' => $jTipsUser->getTipsAccuracy()), 'score' => array('round' => $jTipsUser->getRoundScore('precision', $jRound->id), 'overall' => $jHistory->getProgressScore($jTipsUser, $jRound->id, 'precision'))); $render->assign('stats', $stats); } else { $render->assign('stats', false); } } $render->display($hideColumns); if (!isJoomla15()) { die; }
/** * For the given user and column, fetch the correct data to be displayed. * Returns the details from the users history for the selected column, eg, total score * * @param $jTipsUser The jTipsUser object to access data from/for * @param $jRound The round to be used as a reference for locating scores * @param $column The name of the column to fetch data for * @param $isModule True is being called from a module, false otherwise. Default is false * @return string The data for the user and field */ function getUserLadderField(&$jTipsUser, &$jRound, $column, $isModule = false) { global $mainframe, $database, $jTips, $jLang, $mosConfig_live_site, $Itemid, $mosConfig_absolute_path; jTipsLogger::_log('fetching user ladder data for user ' . $jTipsUser->id . ' and column ' . $column, 'INFO'); switch ($column) { case 'rank': //return $jTipsUser->getRank($jRound->id); $params = array('round_id' => $jRound->id, 'user_id' => $jTipsUser->id); $jHistory = new jHistory($database); $jHistory->loadByParams($params); return $jHistory->rank; break; case 'user': global $option; global $Itemid; if ($option == 'com_jtips') { $suffix = '&Itemid=' . $Itemid; } else { $suffix = '&season=' . $jTipsUser->season_id; } $name = $jTipsUser->getName(); if ($jTips['EnableShowTips'] == 1 and $jRound->roundOver() and (!isset($jTips['SocialIntegration']) or empty($jTips['SocialIntegration']))) { //Link is to popup if (isJoomla15()) { $width = $jTips['ShowTipsWidth']; $height = $jTips['ShowTipsHeight']; $title = $jLang['_LADDER_VIEW_TIPS_FOR'] . " " . $name; //$showTipsUrl = jTipsRoute("index2.php?option=com_jtips&view=CompetitionLadder&menu=0&action=ShowTips&uid={$jTipsUser->id}&rid={$jRound->id}".$suffix); /*$link = <<<EOF <a class="modal" rel="{handler: 'iframe', size: {x: {$width}, y: {$height}}}" title="$title" href="$showTipsUrl">{$name}</a> EOF;*/ // load the modal popul helper JHTML::_('behavior.modal'); $showTipsUrl = jTipsRoute("index.php?option=com_jtips&view=CompetitionLadder&Itemid={$Itemid}&tmpl=component&menu=0&action=ShowTips&uid={$jTipsUser->id}&rid={$jRound->id}" . $suffix); $rel = json_encode(array('size' => array('x' => $width, 'y' => $height))); $attribs = array('class' => 'modal', 'rel' => str_replace('"', "'", $rel), 'title' => $title); $link = JHTML::link($showTipsUrl, $name, $attribs); } else { global $Itemid; $data = "&Itemid={$Itemid}"; $link = "<a href='javascript:void(0);' onclick='loadTipsPopup(" . $jTipsUser->id . ", " . $jRound->id . ", this, \"{$data}\");' title='" . $jLang['_LADDER_VIEW_TIPS_FOR'] . " " . $name . "' id='userLadderLink_" . $jTipsUser->id . "'>" . $name . "</a>"; } } else { //BUG 283 - Better fallback when CB enabled but not installed if (isset($jTips['SocialIntegration']) and !empty($jTips['SocialIntegration'])) { if ($jTips['SocialIntegration'] == 'cb') { // Link is to CB Pofile $img = getCommunityBuilderAvatar($jTipsUser->user_id); } else { // Link to JomSocial Profile and get avatar $img = getJomSocialAvatar($jTipsUser->user_id); } $alt = $name; if (!empty($img)) { //$img = preg_replace('/>|\/>/', "align='absmiddle' />", $img); $name = "<img src='{$img}' border='0' align='absmiddle' /> {$name}"; } if ($jTips['EnableShowTips'] == 1) { if (isJoomla15()) { $width = $jTips['ShowTipsWidth']; $height = $jTips['ShowTipsHeight']; // BUG 312 - only display the user's name in the title of the link $title = $jLang['_LADDER_VIEW_TIPS_FOR'] . " " . $jTipsUser->getName(); $showTipsUrl = jTipsRoute("index.php?option=com_jtips&view=CompetitionLadder&Itemid={$Itemid}&menu=0&action=ShowTips&uid={$jTipsUser->id}&rid={$jRound->id}" . $suffix); $link = <<<EOF \t\t\t\t\t\t\t <a class="modal" rel="{handler: 'iframe', size: {x: {$width}, y: {$height}}}" title="{$title}" href="{$showTipsUrl}">{$name}</a> EOF; } else { $data = "&Itemid={$Itemid}"; $link = "<a href='javascript:void(0);' onclick='loadTipsPopup(" . $jTipsUser->id . ", " . $jRound->id . ", this, \"{$data}\");' title='" . $jLang['_LADDER_VIEW_TIPS_FOR'] . " " . $alt . "' id='userLadderLink_" . $jTipsUser->id . "'>" . $name . "</a>"; } } else { // Get Community Builder Link if ($jTips['SocialIntegration'] == 'cb') { $link = "<a href='" . jTipsRoute("index.php?option=com_comprofiler&task=userProfile&user="******"'"; } else { $ccLink = getJomSocialProfileLink($jTipsUser->user_id); $link = "<a href='" . jTipsRoute($ccLink) . "'"; } $link .= " title='View Profile' id='userLadderLink_" . $jTipsUser->id . "'>" . $name . "</a>"; } } else { $link = $name; } } return $link; break; case 'points': return $jTipsUser->getRoundScore('points', $jRound->id); break; case 'pointst': //return $jTipsUser->getTotalScore('points'); $jHistory = new jHistory($database); return $jHistory->getProgressScore($jTipsUser, $jRound->id); break; case 'prec': return $jTipsUser->getRoundScore('precision', $jRound->id); break; case 'prect': //return $jTipsUser->getTotalScore('precision'); $jHistory = new jHistory($database); return $jHistory->getProgressScore($jTipsUser, $jRound->id, 'precision'); break; case 'comment': $params = array('user_id' => $jTipsUser->id, 'round_id' => $jRound->id); $jComment = new jComment($database); $jComment->loadByParams($params); /*if (strlen($jComment->comment) > 40) { $name = $jTipsUser->getName(). "'s Comment"; $comment = "<span style='cursor:pointer; cursor:hand;' " .AddOverlibCall($jComment->comment, $name). ">" .substr($jComment->comment, 0, 40). "...</span>"; } else */ if (!empty($jComment->comment)) { $comment = "<div style='font-weight:normal;text-align:left;'>" . jTipsStripslashes($jComment->comment) . "</div>"; } else { return ""; } return $comment; break; case 'moved': $prev_id = $jRound->getPrev(); //BUG 171 & 172 Don't know why this is here... was causing problems /*if (!jTipsGetParam($_REQUEST, 'round_id', false)) { $prevRound = new jRound($database); $prevRound->load($prev_id); $prev_id = $prevRound->getPrev(); }*/ if ($prev_id < 0) { $prev_id = 0; } $params = array('round_id' => $jRound->id, 'user_id' => $jTipsUser->id); $jHistory = new jHistory($database); $jHistory->loadByParams($params); $curr_rank = $jHistory->rank; jTipsLogger::_log('CURRENT: ' . $curr_rank . ' HID: ' . $jHistory->id, 'ERROR'); $params['round_id'] = $prev_id; $jHistory->loadByParams($params); $prev_rank = $jHistory->rank; jTipsLogger::_log('PREV: ' . $prev_rank . ' HID: ' . $jHistory->id, 'ERROR'); if ($curr_rank > $prev_rank) { $arrow = 'down'; } else { if ($curr_rank < $prev_rank) { $arrow = 'up'; } else { $arrow = 'none'; return ' '; } } //Bug 125 - Added mosConfig_live_site to path return "<img src='" . $mosConfig_live_site . "/components/com_jtips/images/" . $arrow . ".png' alt='" . $arrow . "' border='0' title='" . ucfirst($arrow) . " " . abs($curr_rank - $prev_rank) . "' />"; break; case 'doubleup': if ($jTipsUser->doubleup == $jRound->id) { return "<img src='{$mosConfig_live_site}/administrator/images/tick.png' border='0' alt='Yes' align='absmiddle' />"; } else { return " "; } break; default: return '-'; break; } }