<?php
/**
* CB Link 2 author mambot
* @package Community Builder
* @subpackage CB Link 2 author mambot
* @Copyright (C) MamboJoe
* @ All rights reserved
* @ Released under GNU/GPL License : http://www.gnu.org/copyleft/gpl.html
* @version $Revision: 1 $
* modified by ccdog then phleum to add author avatars and captions
* -- this version requires a CB field "cb_bio" to function properly
**/
defined( '_VALID_MOS' ) or die( 'Direct Access to this location is not allowed.' );
$_MAMBOTS->registerFunction( 'onBeforeDisplayContent', 'CBAuthorBot');
function CBAuthorBot (&$row, &$params, $page) {
global $database, $mosConfig_live_site;
// a few configs
$query = "SELECT cb_bio FROM #__comprofiler WHERE user_id = $row->created_by";
$database->setQuery( $query );
$cb_bio = $database->loadResult();
$caption = $cb_bio; // caption below author image
$show_all = false; // set to true to show author image everywhere
// Do not show general admin-- hardcoded to admin id
if ($row->created_by != 62) {
// allow usage of <!-- !Bio! --> to NOT show the author bot details
if(strstr($row->text, "!Bio!")){
print str_replace("{!Bio!}", "", $row->text);
return;
}
// allow usage of <!-- !bio! --> to NOT show the author bot details
if(strstr($row->text, "nobio!")){
print str_replace("{nobio!}", "", $row->text);
return;
}
$task = mosGetParam($_REQUEST, 'task', false);
$option = mosGetParam($_REQUEST, 'option', false);
//var_dump($row);
if ( ( ($option == 'com_content' || $option == 'content') && $task == 'view') || $show_all) {
$query = "SELECT avatar FROM #__comprofiler WHERE user_id = $row->created_by AND avatarapproved = '1'";
$database->setQuery( $query );
$avatar = $database->loadResult();
$avatarlink = "";
$txt = "";
if ( $avatar || $cb_bio ) {
$avatarlink = $mosConfig_live_site.'/images/comprofiler/tn'.$avatar;
$txt = "<div class=\"author_profile\"><a href=\"".sefRelToAbs('index.php?option=com_comprofiler&task=userProfile&user='.$row->
created_by)."\" align=\"left\"><img src=\"$avatarlink\" border=\"0\" align=\"left\" hspace=\"10\" vspace=\"5\" /><div class=\"authorimg_caption\">$caption</div></a></div>";
}
$row->text = $txt.$row->text;
}
$row->created_by_alias="<a href=\"".sefRelToAbs('index.php?option=com_comprofiler&task=userProfile&user='.$row->created_by)
."\">".($row->created_by_alias!='' ? $row->created_by_alias : $row->author)."</a>";
}
}
?>
|