Hi guys,
attached you will find the integration for jomsocial avatars and linking for com_resource 1.5.8 Build 6285
HowTo:
File Url: components/com_resource/helpers/community.php
- Backup your actual community.php
- create a new community.php
- Copy all of the code above into new community.php
- have fun
cheers jan
<?php
if(MECommunityHelper::isEnabled())
{
require_once JPATH_ROOT.DS.'components'.DS.'com_community'.DS.'api.php';
}
class MECommunityHelper
{
function isEnabled()
{
static $result = null;
if($result !== null)
return $result;
jimport('joomla.filesystem.file');
require_once (JPATH_ADMINISTRATOR.DS.'components'.DS.'com_resource'.DS.'controllers'.DS.'config.php');
ResControllerConfig::initialyze();
if(!defined('RES_COMMUNITY'))
{
$result = FALSE;
return $result;
}
if(substr(RES_COMMUNITY, 0, -4) != 'com_resource') {
$result = false;
return $result;
}
if(JFile::exists(JPATH_ROOT.DS.'components'.DS.'com_community'.DS.'api.php'))
{
include_once JPATH_ROOT.DS.'components'.DS.'com_community'.DS.'api.php';
$result = true;
return $result;
}
$result = false;
return $result;
}
function loadApi()
{
static $loaded = false;
if( !$loaded && MECommunityHelper::isEnabled()){
require_once JPATH_ROOT.DS.'components'.DS.'com_community'.DS.'api.php';
$loaded = true;
}
}
function getKarma($user_id)
{
if(!MECommunityHelper::isEnabled()) return;
if($user_id == 0) return;
$karma = JSCommunityApi::getUserCarma($user_id);
return $karma;
}
function increasKarma($user_id, $amount, $increas = 1)
{
if(!MECommunityHelper::isEnabled()) return;
if($increas == 0) return;
if((int)$amount === 0) return;
if(!$user_id) return;
JSCommunityApi::increaseKarma($user_id, $amount);
}
function registerActivity($param, $client)
{
if(!MECommunityHelper::isEnabled()) return;
$icon = 'components/com_resource/images/activity/'.$param['icon'];
if($client)
{
$gicon = 'components/com_resource/images/activity/g.'.$param['icon'];
$mode = 'community';
if(JFile::exists($gicon))
{
$icon = $gicon;
}
}
else
{
$mode = 'user';
}
if(!key_exists('user_id', $param))
{
$user = &JFactory::getUser();
if(!$user->get('id')) return;
$param['user_id'] = $user->get('id');
}
JSCommunityApi::registerActivity($client, $param['text'], $param['user_id'], $icon, $mode, null, 'com_resource', '', $param['type']);
}
function getAvatar($id, $params = null, $prefix = '')
{
if(!$id) return JHTML::image(JURI::root().'/components/com_resource/images/avatar0.gif','avatar');
$db = & JFactory::getDBO();
$avatar = JHTML::image(JURI::base().'/components/com_resource/images/avatar.gif','avatar');
$user = JFactory::getUser($id);
$dir = JPATH_ADMINISTRATOR.DS.'components'.DS.'com_juser'.DS.'avatars'.DS.$user->get('username');
//HS for JomSocial Begins
$jspath = JPATH_BASE.DS.'components'.DS.'com_community';
include_once($jspath.DS.'libraries'.DS.'core.php');
$link = CRoute::_('index.php?option=com_community&view=profile&userid='.$user->get('id'));
if(is_dir(JPATH_ADMINISTRATOR.DS.'components'.DS.'com_community')){
$sql = "SELECT thumb FROM #__community_users WHERE userid = ".$user->get('id')."";
$db->setQuery($sql);
$fname = $db->loadResult();
if($fname) $avatar = '<a href="'. $link .'">'.JHTML::image(JURI::base().''.$fname, $user->get('username'). JText::_('Avatar')).'</a>';
}
//HS for JomSocial Ends
if(file_exists($dir.'.gif'))
$avatar = JHTML::image(JURI::root().'/administrator/components/com_juser/avatars/'.
$user->get('username').'.gif', $user->get('username'). JText::_('Avatar'));
if(file_exists($dir.'.png'))
$avatar = JHTML::image(JURI::root().'/administrator/components/com_juser/avatars/'.
$user->get('username').'.png', $user->get('username'). JText::_('Avatar'));
if(file_exists($dir.'.jpg'))
$avatar = JHTML::image(JURI::root().'/administrator/components/com_juser/avatars/'.
$user->get('username').'.jpg', $user->get('username'). JText::_('Avatar'));
return $avatar;
}
}
?>

Special



Profile of pdmunich
Add a Friend
All User Extensions (3)
Send Message 
+1 (209) 800 1209