Fireboard integration

Armin Hornung edited this page Feb 28, 2015 · 1 revision
Clone this wiki locally

The following hack integrates jAwards into Fireboard, just like it was possible previously with Simple- and Joomlaboard. All you need to do is insert the following lines beginning with <?php and ending with ?> in your template in the file message.php. In the "default" Fireboard template, the best place is right after line 158, so the whole block is placed after:

<?php
if ($msg_birthdate) {
    echo $msg_birthdate;
}
?>

and before:

 </div>
    </td>

    <td class = "fb-msgview-right">

Here is the code to insert:

<?php
                // Hack for jAwards integration, displays some medals of the user
                $number_medals = 3;  // number of medals to show
                $query = "SELECT b.image, b.name"
			. "\n FROM #__jawards_awards AS a"
			. "\n LEFT JOIN #__jawards_medals AS b ON b.id = a.award"
			. "\n WHERE a.userid=". $fmessage->userid
			. "\n ORDER BY RAND() LIMIT ".$number_medals;
	
	    $database->setQuery( $query );
                $medals = $database->loadObjectList();
                
                // URL links to the jAwards-Tab for Community Builder which displays all
                // medals of the user - change to another URL of needed
                $awards_url=sefRelToAbs('index.php?option=com_comprofiler&task=userProfile&user='.$fmessage->userid."&tab=getawardstab");
                
                // CSS-class "ja_medals" allows individual styling of medal images and
                // container. "nobr" keeps the medals from breaking apart, display them 
                // in one row.
                $msg_jawards = "<div class=\"ja_medals\"><nobr>";
            foreach ($medals as $medal){
		$msg_jawards.= "<a href=\"$awards_url\" title=\"$medal->name (Click to see more)\">" 
			. "<img style='border:0px;padding:0px;' src=\"".JB_JLIVEURL."/images/medals/".$medal->image ."\" alt=\"".$medal->name."\" />"
			. "</a>";	
	    }
	
	    $msg_jawards.="</nobr></div>";
	    unset($medals);
	    echo $msg_jawards;
                
?>

Alternatively, you can use the code block below. It does not display the actual medals but small icons corresponding to the number of medals a user got. It is also more efficiently regarding the DB-query.

<?php
                // Hack for jAwards integration, displays number of medals of the user
	    // as small icons, w. link to CB-profile
                $query = "SELECT count(id) FROM #__jawards_awards"
			. "\n WHERE userid=". $fmessage->userid;
	    $database->setQuery( $query );
                $nummedals = $database->loadResult();

	    if ($nummedals){
                
		// URL links to the jAwards-Tab for Community Builder which displays all
		// medals of the user - change to another URL of needed
		$awards_url=sefRelToAbs('index.php?option=com_comprofiler&task=userProfile&user='.$fmessage->userid."&tab=getawardstab");
		
		//URL of image to use as icon
		$medal_img= JB_JLIVEURL."/administrator/components/com_jawards/images/medal_silver.png";
		
		// CSS-class "ja_medals" allows individual styling of medal images and
		// container. 
		$msg_jawards = "<div class=\"ja_medals\">";
		$msg_jawards .="<a href=\"$awards_url\" title=\"Click to see more\">";
		for($i=0; $i< $nummedals;$i++){
		    $msg_jawards.= "<img style='border:0px;padding:0px;' src=\"".$medal_img ."\" />";
		}
	    
		$msg_jawards.="</a></div>";
		unset($nummedals);
		echo $msg_jawards;
	    }
                
?>