View Single Post
  #5  
Old 01-07-2010, 12:35 PM
ragarcia87's Avatar
ragarcia87 ragarcia87 is offline
 
Join Date: Jun 2009
Location: Fort Smith
Posts: 65
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

I am sorry. Thank you consolegaming for the links I am reading them now. Oh yes I have seen these. Thanks though.

Here is the page, view_rep.php

PHP Code:
<?php
/**
 *@todo clean up
 */

// ####################### SET PHP ENVIRONMENT ###########################
error_reporting(E_ALL & ~E_NOTICE);

// #################### DEFINE IMPORTANT CONSTANTS #######################

define('THIS_SCRIPT''view_rep');
define('CSRF_PROTECTION'true);  
// change this depending on your filename

// ################### PRE-CACHE TEMPLATES AND DATA ######################
// get special phrase groups
$phrasegroups = array();

// get special data templates from the datastore
$specialtemplates = array();

// pre-cache templates used by all actions
$globaltemplates = array('view_userrep',
);

// pre-cache templates used by specific actions
$actiontemplates = array();

// ######################### REQUIRE BACK-END ############################
// if your page is outside of your normal vb forums directory, you should change directories by uncommenting the next line
// chdir ('/path/to/your/forums');
require_once('./global.php');

// #######################################################################
// ######################## START MAIN SCRIPT ############################
// #######################################################################


// ###### YOUR CUSTOM CODE GOES HERE #####
$pagetitle 'Viewing rep';
global 
$vbulletin;
$vbulletin->input->clean_array_gpc('g', array('userid' => TYPE_INT)); 
$db $vbulletin->db;

$UserID $vbulletin->GPC['userid'];
// Get username
$UserResult $db->query_read("SELECT username FROM user WHERE userid = {$UserID} LIMIT 1"); 
$Username current($db->fetch_array($UserResult)); // No need for array to cached in php since it only has one value.
  

$result $db->query_read("SELECT repping_userid,rep_value,message,reason,thread_link FROM userrep WHERE repped_userid = {$UserID} ORDER BY timestamp DESC"); 

$arRep = array();

while (
$array $db->fetch_array($result))
{
  
// this code sucks!
  
if ($array['rep_value'] == 1){
      
// Postive show + img
      
$RatedIMG "/images/pos-rep.png";
      
$RatedText "Postive";
  }
  elseif (
$array['rep_value'] == -1) {
      
// Negative show - img
      
$RatedIMG "/images/neg-rep.png";
      
$RatedText "Negative";
  }
 
  if ( empty(
$array['thread_link']) ){
      
$array['thread_link'] = 0;
  }
  

  
$UserLinkResult $db->query_read("SELECT username FROM user WHERE userid = {$array['repping_userid']} LIMIT 1"); // get a link to user who did the rating.
  
$arUsername =  $db->fetch_array($UserLinkResult);
  if ( empty(
$arUsername) ){
    
$strUsername "System"
    
$UserLink "/";
  }
  else{
    
$strUsername current($arUsername); // No need for array to cached in php since it only has one value.
    
$UserLink "/member.php?{$array['repping_userid']}-{$strUsername}";
  }
  
  
$arRep[] = array('ratedimg' => $RatedIMG,
           
'ratedtext' => $RatedText,
           
'message' => $array['message'],
           
'reason' => $array['reason'],
           
'thread' => $array['thread_link'],
           
'userlink' => $UserLink,
           
'username' => $strUsername);




// ###### NOW YOUR TEMPLATE IS BEING RENDERED ######
$navbits construct_navbits(array("view_rep.php?$session[sessionurl]u={$UserID}=> $vbphrase['irep'],'' => $Username));
$navbar render_navbar_template($navbits);
$templater vB_Template::create('view_userrep');
$templater->register_page_templates();
$templater->register('navbar'$navbar);
$templater->register('reparray'$arRep);
$templater->register('username'$Username);
$templater->register('pagetitle'$pagetitle);
print_output($templater->render());

?>


And here is the whole template page: view_userrep

HTML Code:
{vb:stylevar htmldoctype}
<html xmlns="https://www.w3.org/1999/xhtml" dir="{vb:stylevar textdirection}" lang="{vb:stylevar languagecode}">
<head>
	<!-- no cache headers -->
	<meta http-equiv="Pragma" content="no-cache" />
	<meta http-equiv="Expires" content="-1" />
	<meta http-equiv="Cache-Control" content="no-cache" />
	<!-- end no cache headers -->
	{vb:raw headinclude}
	<title>{vb:raw pagetitle}</title>
</head>
<body>

{vb:raw header}
{vb:raw navbar}
    
    <div class="blockhead">{$username}'s iRep Profile</div>
    <div class="blockbody">
      <div class="blockrow">
	<table cellpadding="5" cellspacing="1" border="1" width="100%" style="border: 1px solid #333333;">
	  <tr>
	    <th width="10%" style="text-align: center; font-weight: bold;">From</th>
	    <th width="20" style="text-align: center; font-weight: bold;">Rating</th>
	    <th width="10%" style="text-align: center; font-weight: bold;">Reason</th>
	    <th width="10%" style="text-align: center; font-weight: bold;">Thread URL</th>
	    <th width="70%" style="text-align: center; font-weight: bold;">Comment</th>
	  </tr>
	<vb:each from="reparray" value="rep">
	  <tr>
	 
	    <vb:if condition="$rep.username">
	      <td  style="padding : 3px;"><a href="{vb:var rep.userlink}" title="{$rep.username} user profile">{$rep.username}</a></td>
	    <vb:else />
	      <td  style="padding : 3px;font-weight:bold;text-align:center;">System</td>
	    </vb:if> 
	    
	    
	    <td style="text-align: center;"><img src="{vb:var rep.ratedimg}" alt="{vb:var rep.ratedtext}" /></td>
	    <td style="padding : 3px;">{vb:var rep.reason}</td>
	    
	  <vb:if condition="$rep.thread != 0">
		<td  style="padding : 3px;"><a href="{$rep.thread}">View</a></td>
	  <vb:else />	
	    <td  style="padding : 3px;">n/a</td>
	 </vb:if>
	    
	    <td>{vb:var rep.message}</td>

	  </tr>
	</vb:each>
	</table>

      </div>
    </div>
    
    {vb:raw footer}
  </body>
</html>

If I change it to:
HTML Code:
	  <vb:if condition="$rep.thread">
		<td  style="padding : 3px;"><a href="{$rep.thread}">View</a></td>
	 </vb:if>
then it works and shows the thread link but some of them do not have values and need to show "n/a"
Reply With Quote
 
X vBulletin 3.8.12 by vBS Debug Information
  • Page Generation 0.01180 seconds
  • Memory Usage 1,853KB
  • Queries Executed 11 (?)
More Information
Template Usage:
  • (1)SHOWTHREAD_SHOWPOST
  • (1)ad_footer_end
  • (1)ad_footer_start
  • (1)ad_header_end
  • (1)ad_header_logo
  • (1)ad_navbar_below
  • (2)bbcode_html
  • (1)bbcode_php
  • (1)footer
  • (1)gobutton
  • (1)header
  • (1)headinclude
  • (6)option
  • (1)post_thanks_box
  • (1)post_thanks_button
  • (1)post_thanks_javascript
  • (1)post_thanks_navbar_search
  • (1)post_thanks_postbit_info
  • (1)postbit
  • (1)postbit_onlinestatus
  • (1)postbit_wrapper
  • (1)spacer_close
  • (1)spacer_open 

Phrase Groups Available:
  • global
  • postbit
  • reputationlevel
  • showthread
Included Files:
  • ./showpost.php
  • ./global.php
  • ./includes/init.php
  • ./includes/class_core.php
  • ./includes/config.php
  • ./includes/functions.php
  • ./includes/class_hook.php
  • ./includes/modsystem_functions.php
  • ./includes/functions_bigthree.php
  • ./includes/class_postbit.php
  • ./includes/class_bbcode.php
  • ./includes/functions_reputation.php
  • ./includes/functions_post_thanks.php 

Hooks Called:
  • init_startup
  • init_startup_session_setup_start
  • init_startup_session_setup_complete
  • cache_permissions
  • fetch_postinfo_query
  • fetch_postinfo
  • fetch_threadinfo_query
  • fetch_threadinfo
  • fetch_foruminfo
  • style_fetch
  • cache_templates
  • global_start
  • parse_templates
  • global_setup_complete
  • showpost_start
  • bbcode_fetch_tags
  • bbcode_create
  • postbit_factory
  • showpost_post
  • postbit_display_start
  • post_thanks_function_post_thanks_off_start
  • post_thanks_function_post_thanks_off_end
  • post_thanks_function_fetch_thanks_start
  • post_thanks_function_fetch_thanks_end
  • post_thanks_function_thanked_already_start
  • post_thanks_function_thanked_already_end
  • fetch_musername
  • postbit_imicons
  • bbcode_parse_start
  • bbcode_parse_complete_precache
  • bbcode_parse_complete
  • postbit_display_complete
  • post_thanks_function_can_thank_this_post_start
  • showpost_complete