Twitter
JomSocial Avatar and Profile Link for Resource 1.5.8 Build 6285

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;
}

}
?>

Version 1.5.8 Build 6285
License Other
Type Non-Commercial
Extension type Special
Complaint Click to send e-mail online
pdmunichAvatar

pdmunich VIP
 
Votes: 0
Answers: 1
Hits: 2455
Modified: 28 May 2011

In Comment section you can leave only reviews. If you have questions or support requests ask in Support Desk / 3DP Extensions category or send Personal Message.

Comments
maikkauneAvatar
Quote
- -
Written by maikkaune VIP on 28 May 2011

Correct me if I am wrong, but why did it not work to add a file in

com_resource > library > php > community > my_integration.php

I thought this is the place for the integration files. At least CB and MEregistration can be found there!?

-
Add New Comment
Name:
Email:
Comment:
Attachment
Hide Comment
Security code:
Enter text as you see on image
 
 

Latest Extensions

What is best way for Download/Installation MightyExtensions?
 


Member Area



Member Activity

We have 1188 guests and 6 members online


MightyTemplate - Professional Joomla Templates