Skip to Content Skip to Menu

CBAuthorBot Hack - Show CB Avatar in articles

16 years 5 months ago #64232 by that1bander
Replied by that1bander on topic Re:CBAuthorBot Hack - Show CB Avatar in articles
Hey, does this work in 1.5? I have been looking for a way to have an avatar/gravatar/anything show up in an article's heading forever now. There is a bot called "Avatar/gravatar," but it screws up the css of your site.

Please Log in or Create an account to join the conversation.

  • studee
  • studee
  • OFFLINE
  • Posts: 2
  • Thanks: 0
  • Karma: 0
16 years 5 months ago #64629 by studee
mediaguru wrote:

I'm so proud of myself. I figured out my own question.

Line 55:

[code:1] $avatarlink = $mosConfig_live_site.'/images/comprofiler/'.$avatar;
[/code:1]

Change to:
[code:1] $avatarlink = $mosConfig_live_site.'/images/comprofiler/tn'.$avatar;
[/code:1]

This loads the thumbnail instead of the full sized avatar.



Hi mediaguru!!,

it works well but adding the "tn" solves the problem only for the users with uploaded avatar , the users who selected a avatar from the avatar gallery available the path is "gallery/filename.gif" , how to fix this any solutions !!!


thanks for any help

Please Log in or Create an account to join the conversation.

  • fwd
  • fwd
  • OFFLINE
  • Posts: 6
  • Thanks: 0
  • Karma: 2
16 years 5 months ago #64645 by fwd
Here is a class I wrote a while back that retrieves the CB avatar among other thihngs:

[code:1]

<?php

/**
* @author gabe@fijiwebdesign.com
* @copyright (c) fijiwebdesign.com
* @license fijiwebdesign.com/ajaxchat/license/
* @package ajaxchats
* @name ajaxchat
*/

defined('_VALID_MOS') or die('Direct Access to this location is not allowed.');

/**
* Ajax Chat Comprofiler integration class
* @package ajaxchat
*/
class ajc_comprofilerProfile {

var $_db; // db object
var $query; // sql
var $err; // error
var $img_dir; // image base dir
var $lang; // configured language

/**
* Constructor
*/
function ajc_comprofilerProfile($db) {
$this->_db = $db;
$this->img_dir = $GLOBALS.'/images/comprofiler/';
$this->lang = 'english';
}

/**
* Returns the cb fields
*/
function userFields($sensitive = array('user_id')) {
$this->query = "SELECT * FROM #__comprofiler_fields AS cf"
."\n WHERE cf.table = '#__comprofiler' AND cf.name != 'NA'";
$this->_db->setQuery($this->query);
$all_fields = $this->_db->loadObjectList();
$this->err = $this->_db->stderr();

// avoid sensitive info
$fields = array();
$tbl = 'cb.';
$n = count($all_fields);
for ($i = 0; $i < $n; $i++) {
/*if (in_array($all_fields[$i]->name, $sensitive)) {
continue; // sensitive data, skip
}*/
$fields[$i]->Field = $tbl.$all_fields[$i]->name;
$fields[$i]->Com = 'com_comprofiler';
}

return $fields;
}

/**
* Set a new Image base dir
*/
function setImgDir($dir) {
$this->img_dir = $dir;
}

/**
* Returns the img src for comprofiler user avatar
* @param string avatar url in db
* @param int comprofiler user id
*/
function avatarUrlByEntry($avatar, $userid) { // internal

if ($avatar && $avatar != '') {
if (!stristr($avatar, 'gallery/')) {
$thumb_url = sefRelToAbs($this->img_dir.'tn'.$avatar);
} else {
$thumb_url = sefRelToAbs($this->img_dir.$avatar);
}
} else {
$thumb_url = sefRelToAbs($GLOBALS.'/components/com_comprofiler/images/'.$this->lang.'/tnnophoto.jpg');
}
return $thumb_url;
}

/**
* Returns the img src for comprofiler user avatar given the user id
* @param int comprofiler user id
*/
function avatarUrlById($userid) { // internal

$this->query = "SELECT c.avatar FROM #__comprofiler as c "
."\n WHERE c.user_id = ".intval($userid)." LIMIT 1";
$this->_db->setQuery($this->query);
$avatar = $this->_db->loadResult();
$this->err = $this->_db->stderr();

return $this->avatarUrlByEntry($avatar, $userid); // return avatar url
}

/**
* Returns the comprofiler details for user by userid
* @param int comprofiler user id
*/
function userDetailsById($userid) {

// allow only published fields
require_once( $GLOBALS.'/components/com_ajaxchat/ajaxchat.config.php' );
global $ajaxChat_config;
$fields = $ajaxChat_config;
if (count($fields) > 0) {
$query = implode(',', $fields);
}
print_r($query);
return;

$this->query = "SELECT u.id, u.name, u.username, u.email, u.usertype, u.gid, u.registerDate, u.lastvisitDate, "
."\n s.guest, s.time, "
."\n a.is_ban, a.ban_by, a.ban_reason, a.last_login, a.karma, a.is_mod, "
."\n c.*, ct.*, aa.* "
."\n FROM #__comprofiler AS c "
."\n LEFT JOIN #__users AS u ON (u.id = c.user_id)"
."\n LEFT JOIN #__session AS s ON (s.userid = u.id)"
."\n LEFT JOIN #__ajax_chat_users as a ON (a.userid = u.id)"
."\n LEFT JOIN #__contact_details as ct ON (ct.user_id = u.id)"
."\n LEFT JOIN #__ajax_chat_connections as aa ON (aa.userid = u.id)"
."\n WHERE c.user_id = ".intval($userid)." LIMIT 1";
$this->_db->setQuery($this->query);
$this->_db->loadObject($row);
$this->err = $this->_db->stderr();

return $row;

}
}

?>
[/code:1]

The part of interest is: avatarUrlById() and avatarUrlByEntry():

[code:1] /**
* Returns the img src for comprofiler user avatar
* @param string avatar url in db
* @param int comprofiler user id
*/
function avatarUrlByEntry($avatar, $userid) { // internal

if ($avatar && $avatar != '') {
if (!stristr($avatar, 'gallery/')) {
$thumb_url = sefRelToAbs($this->img_dir.'tn'.$avatar);
} else {
$thumb_url = sefRelToAbs($this->img_dir.$avatar);
}
} else {
$thumb_url = sefRelToAbs($GLOBALS.'/components/com_comprofiler/images/'.$this->lang.'/tnnophoto.jpg');
}
return $thumb_url;
}

/**
* Returns the img src for comprofiler user avatar given the user id
* @param int comprofiler user id
*/
function avatarUrlById($userid) { // internal

$this->query = "SELECT c.avatar FROM #__comprofiler as c "
."\n WHERE c.user_id = ".intval($userid)." LIMIT 1";
$this->_db->setQuery($this->query);
$avatar = $this->_db->loadResult();
$this->err = $this->_db->stderr();

return $this->avatarUrlByEntry($avatar, $userid); // return avatar url
}[/code:1]

documentation inline...

Please Log in or Create an account to join the conversation.

  • beat
  • beat
  • ONLINE
  • Posts: 2169
  • Thanks: 463
  • Karma: 352
16 years 5 months ago #64687 by beat
Cool :)

Thanks for sharing, could you please clarify the licensing terms, as the referenced licencing page is not avaliable ?

Beat - Community Builder Team Member

Before posting on forums: Read FAQ thoroughly -- Help us spend more time coding by helping others in this forum, many thanks :)
CB links: Our membership - CBSubs - Templates - Hosting - Forge - Send me a Private Message (PM) only for private/confidential info

Please Log in or Create an account to join the conversation.

16 years 5 months ago #66337 by artketubah
Replied by artketubah on topic Re:CBAuthorBot Hack - Positioning???
How do I position the authorbot so that it isn't inside a <td id=contentpanelopen">

What if I want the avatar and bio to be on the bottom of the page or side by side with the content?

Right now, that can't happen because it is placed inside a <table> with the content of the article directly underneath.

I went over the mambot's code but that's not where the <table> is being added...

Please Log in or Create an account to join the conversation.

  • fwd
  • fwd
  • OFFLINE
  • Posts: 6
  • Thanks: 0
  • Karma: 2
16 years 5 months ago #66354 by fwd
The code I posted is GPL. :)

Please Log in or Create an account to join the conversation.

Moderators: beatnantkrileon
Powered by Kunena Forum