×

Notice

The forum is in read only mode.
Welcome, Guest
Username: Password: Remember me
  • Page:
  • 1

TOPIC: Linking JomSocial profile + Avatar

Linking JomSocial profile + Avatar 11 years 7 months ago #9946

  • Steve Burke
  • Steve Burke's Avatar Topic Author
  • Offline
  • Junior Boarder
  • Junior Boarder
  • Posts: 38
  • Thank you received: 0
I've seen this asked a few times, but I'm having trouble figuring it out myself. I have compojoom comments (upgraded from JoomlaComment) installed and configured... finally fixed up my template to look pretty :) now I just have to link the username to their JomSocial profile, and also make their JomSocial avatar appear.

I found this post: compojoom.com/blog/8-news/97-joomlacomme...integration#josc8816

But I can't find the file to modify, if it even exists in compojoomcomment. Can anyone tell me where to start? Thanks!
www.GamersNexus.net is the site, if you want to see a test article w/ comments it is here. (just scroll down).

I should probably start a new topic for this, but I also can't get the MyBlog plugin working... it's just not even showing up on the blog pages. I have added the content item in settings and enabled the plugin, any input?

Linking JomSocial profile + Avatar 11 years 7 months ago #9948

  • Daniel Dimitrov
  • Daniel Dimitrov's Avatar
  • Offline
  • Administrator
  • Administrator
  • Posts: 9618
  • Karma: 155
  • Thank you received: 1081
Hey Steve,
the code from the blog post is now located in this file: components/com_comment/classes/joomlacomment/JOSC_post.php - the next version will have this code in place and you will have to just enable jomsocial support from the backend.

About the myblog plugin. Could you perhaps give me admin access to your website? Also did you follow the documentation steps?

Linking JomSocial profile + Avatar 11 years 7 months ago #9949

  • Steve Burke
  • Steve Burke's Avatar Topic Author
  • Offline
  • Junior Boarder
  • Junior Boarder
  • Posts: 38
  • Thank you received: 0
I made the changes to Josc_post, but I ended up reverting them due to bugs. I received a white screen on pages with comments enabled with these changes. There are some differences in the code, I wonder if that is the problem? You say to find the following:
if ($this->_avatar) {
 if(JString::strpos($this->_avatar,"gallery/")===false) {
 $path = JURI::base()."/images/comprofiler/tn$this->_avatar";
 } else {
 
 $path = JURI::base()."/images/comprofiler/$this->_avatar";
 }
 
 $html     = str_replace('{avatar_picture}', $this->profileLink("<img class='avatar' src='$path' alt='avatar' />", $this->_user_id), $html);
 } else if ($this->_gravatar) {
 $gravatar_email = $this->_item['email'];
 $default = JURI::base().'components/com_comment/assets/images/nophoto.jpg';
 $size = 60;
 // Prepare the gravatar image
 $path = "http://www.gravatar.com/avatar.php?gravatar_id=".md5(strtolower($gravatar_email)).
 "&default=".urlencode($default)."&size=".$size;
 
 $html = str_replace('{avatar_picture}', $this->profileLink("<img class='avatar' src='$path' alt='avatar' />", $this->_user_id), $html);
 }

but this no longer exists, instead it looks like this:
if ($this->_avatar) {
			$display = $this->_avatar;
		} else if($this->_gravatar) {
			$display = $this->_gravatar;
		} else {
			$display = 0;
		}
		$html 		= JOSC_utils::checkBlock('BLOCK-avatar_picture', $display, $html);
		if ($this->_avatar) {
			if(JString::strpos($this->_avatar,"gallery/")===false) {
				$path = JURI::base()."/images/comprofiler/tn$this->_avatar";
			} else {
 
				$path = JURI::base()."/images/comprofiler/$this->_avatar";
			}
 
			$html 	= str_replace('{avatar_picture}', $this->profileLink("<img class='avatar' src='$path' alt='avatar' />", $this->_user_id), $html);
		} else if ($this->_gravatar) {
			$gravatar_email = $this->_item['email'];
			if (file_exists(JPATH_BASE.DS.'components'.DS.'com_comment'.DS.'joscomment'.DS.'templates'.DS.$this->_template_name.DS.'images'.DS.'nophoto.png')) {
				$default = "$this->_template_path/$this->_template_name/images/nophoto.png";
			} else {
				$default = JURI::base().'components/com_comment/assets/images/nophoto.jpg';
			}
			$size = 64;
			// Prepare the gravatar image
			$path = "http://www.gravatar.com/avatar.php?gravatar_id=".md5(strtolower($gravatar_email)).
					"&amp;default=".urlencode($default)."&amp;size=".$size;
 
			$html = str_replace('{avatar_picture}', $this->profileLink("<img class='avatar' src='$path' alt='avatar' />", $this->_user_id), $html);
		}

Also, assuming these changes work, which avatar option do I enable in the back-end? CB? Gravatar? Or should a new one appear?

I will research the myblog stuff some more later tonight, I'll focus on the above issue for now :) one at a time :) I look forward to the next release!

Sorry for asking so many questions, but if it makes you feel better... I plan to leave a glowing review on JED. You, JFusion, and JReviews have the best support out of all of the extensions I have used; it's really remarkable how great you guys are. I think the better groups understand that answering questions today will save them time tomorrow, if you know what I mean :) Thanks!

Linking JomSocial profile + Avatar 11 years 7 months ago #9950

  • Daniel Dimitrov
  • Daniel Dimitrov's Avatar
  • Offline
  • Administrator
  • Administrator
  • Posts: 9618
  • Karma: 155
  • Thank you received: 1081
Steve - this is the way to do it! Just tell me that I offer great support and you have to watch me getting up at 5:30 in the morning and looking what is wrong with the code :D

In matter of facts - nothing is wrong, I just tested it.
You have to uncomment those lines:
		if ($this->_avatar) {
			if(JString::strpos($this->_avatar,"gallery/")===false) {
				$path = JURI::base()."/images/comprofiler/tn$this->_avatar";
			} else {
 
				$path = JURI::base()."/images/comprofiler/$this->_avatar";
			}
 
			$html 	= str_replace('{avatar_picture}', $this->profileLink("<img class='avatar' src='$path' alt='avatar' />", $this->_user_id), $html);
		} else if ($this->_gravatar) {
			$gravatar_email = $this->_item['email'];
			if (file_exists(JPATH_BASE.DS.'components'.DS.'com_comment'.DS.'joscomment'.DS.'templates'.DS.$this->_template_name.DS.'images'.DS.'nophoto.png')) {
				$default = "$this->_template_path/$this->_template_name/images/nophoto.png";
			} else {
				$default = JURI::base().'components/com_comment/assets/images/nophoto.jpg';
			}
			$size = 64;
			// Prepare the gravatar image
			$path = "http://www.gravatar.com/avatar.php?gravatar_id=".md5(strtolower($gravatar_email)).
					"&amp;default=".urlencode($default)."&amp;size=".$size;
 
			$html = str_replace('{avatar_picture}', $this->profileLink("<img class='avatar' src='$path' alt='avatar' />", $this->_user_id), $html);
		}
or just delete them, as you wish.

and add this after them:
	$path = JURI::root() . $this->jomSocialAvatar($this->_item['userid']);
		$html = str_replace('{avatar_picture}', $this->jomSocialProfileLink("<img class='avatar' src='$path' alt='avatar' />", $this->_item['userid']), $html);
 
and after the closing bracet of the post_htmlCode function add those 2:
private function jomSocialProfileLink($s, $id) {
		if ($id) {
			$link = JRoute::_('index.php?option=com_community&view=profile&userid='.$id);
			return "<a href='$link'>".$s."</a>";
		} else {
			return $s;
		}
 
	}
	private function jomSocialAvatar ($id) {
		if($id) {
			$database =& JFactory::getDBO();
 
			$query = 'SELECT thumb FROM jos_community_users WHERE userid = ' . $id;
			$database->setQuery($query);
			$result = $database->loadObject();
			return $result->thumb;
		} else {
			return 'components/com_community/assets/default_thumb.jpg';
		}
	}
I've tested this and it works - no blank pages, just jomsocial avatars :)
If it is still not working for you, I would ask you to wait till next week. You will have an option in the backend - avatars from CB or jomsocial and you will have to choose just jomsocial.
Cheers,
Daniel

P.S. If myblog is still not working for you, please make another thread and we will look into it.

Linking JomSocial profile + Avatar 11 years 7 months ago #9951

  • Steve Burke
  • Steve Burke's Avatar Topic Author
  • Offline
  • Junior Boarder
  • Junior Boarder
  • Posts: 38
  • Thank you received: 0
Well it's very late every time I get to work on my site (only time I can work on it is after midnight!), so maybe it's just a stupid mistake. I will gladly wait til the next release :) Will post a new topic if myblog is still not working.

BTW - check your signature, the link to JED doesn't work (JoomlaComment is 'no longer supported') ->should fix that :)

Linking JomSocial profile + Avatar 11 years 7 months ago #9952

  • Daniel Dimitrov
  • Daniel Dimitrov's Avatar
  • Offline
  • Administrator
  • Administrator
  • Posts: 9618
  • Karma: 155
  • Thank you received: 1081
Link in signature fixed - thanks for the note :)

Linking JomSocial profile + Avatar 11 years 7 months ago #9953

  • Daniel Dimitrov
  • Daniel Dimitrov's Avatar
  • Offline
  • Administrator
  • Administrator
  • Posts: 9618
  • Karma: 155
  • Thank you received: 1081
That was much more complicated then expected.
I've deleted around 150 lines of code and wrote some 250 lines of code :)

I've figured out that the code we have right now (part of it is 4+ years old) can cause problems with big website and CB. There was a query that had no limit. So if the website has some 100 000 users, we will get those 100 000 users and do a foreach and find out the avatars. That was crazy! I've changed this and now we get only the users profile that have commented on the article and are on the actual page.

with JomSocial - we didn't have this problem, but there was also something tricky. This select query was called for every single comment. So if we have 50 comments, we will have 50 select queries and that can really slow down a server.

All this is fixed now. And Compojoomcomment users that use it together with CB should feel the speed improvement :)

Anyway anyone wishing to test this before I release it?

Linking JomSocial profile + Avatar 11 years 7 months ago #9954

  • Steve Burke
  • Steve Burke's Avatar Topic Author
  • Offline
  • Junior Boarder
  • Junior Boarder
  • Posts: 38
  • Thank you received: 0
I'll test the JomSocial part, my site is relatively small (~300 users, maybe ~100 active / week). Awesome news about fixing all of that :)

BTW, will this update include activity stream updates for comments? What about points?

Before I forget, whenever I subscribe to a topic (this one), I get an email when you post that says "Compojoom Subscription Subject", but it doesn't link to the forum or anything. I forwarded the email to your support email for your info. Left a review on JED for you :)

Linking JomSocial profile + Avatar 11 years 7 months ago #9955

  • Daniel Dimitrov
  • Daniel Dimitrov's Avatar
  • Offline
  • Administrator
  • Administrator
  • Posts: 9618
  • Karma: 155
  • Thank you received: 1081
Which support e-mail??? Forward it to This email address is being protected from spambots. You need JavaScript enabled to view it. please :)

Thanks for the awesome review!!!

Linking JomSocial profile + Avatar 11 years 7 months ago #9963

  • Steve Burke
  • Steve Burke's Avatar Topic Author
  • Offline
  • Junior Boarder
  • Junior Boarder
  • Posts: 38
  • Thank you received: 0
Looks like you got that sorted out. So, I found the JomSocial documentation on how to add a new rule for point gain for the users, even how to add items to an activity stream, but for the life of me I can't figure out which file to edit. With your experience, do you think I would edit a com_comment file or a com_community file?

Updated my template to fix padding for avatars, so far I have one bug. I tried to edit one of my old comments, an error popped up and said: "Request failed."

Then the following text appeared in my post comment box:
Notice: Undefined variable: avatar in ***/joomlacomment/JOSC_post.php on line 376
<?xml version="1.0" standalone="yes"?><post><published>1</published><noerror>1</noerror><debug></debug><id>200</id><body><![CDATA[
<ul id='post200' style='margin-left:0;'>
    <li class='post'>
        <a name='josc200'></a>
        <div class='posthead'>
            <span class='postinfo'>
                <span class='postdate'>2010-06-17 12:57:25</span>
 
				<span class='postnotify0' title='do not notify if new post'></span>
            	|<span class='postusertype'>Administrator</span>|
            </span>
                <a title=' Registered user' class='username' href='/nexus/profile?userid=63'>Lelldorianx</a>
 
        </div>
        <div class='postcontent'>
            <div class='comment_content'><p>threaded test</p>
<p>edit.: edit test</p>
</div>
        </div>
 
        <div class='postfooter'>
            <ul class='voting'><li><div id='yes200' class='voting_yes' onclick='JOSC_voting(200,"yes")'><span>0</span></div></li><li><div id='no200' class='voting_no' onclick='JOSC_voting(200,"no")'><span>0</span></div></li></ul>
                <span>
                    <a href = 'javascript:JOSC_quote(200)'>Quote</a><a href='javascript:JOSC_editComment(200)'>Edit</a><a href='javascript:JOSC_deleteComment(200)'>Delete</a>
				</span>
        </div>
 
        <div class="josc_clear"></div>
    </li>
</ul>
]]></body></post>

When I tried to submit this, it responded with "Request failed" again. Thoughts?

Linking JomSocial profile + Avatar 11 years 7 months ago #9964

  • Daniel Dimitrov
  • Daniel Dimitrov's Avatar
  • Offline
  • Administrator
  • Administrator
  • Posts: 9618
  • Karma: 155
  • Thank you received: 1081
that is such a stupid notice :(
Open josc_post and go to line 371 and change the getUserAvatarJomSocial to this
	public function getUserAvatarJomSocial() {
		$profile = '';
		$avatar = '';
		if(is_array($this->_profiles[$this->_item['userid']])) {
			$avatar = $this->_profiles[$this->_item['userid']]['avatar'];
		}
		if($avatar) {
			$path = JURI::base() . $avatar;
			$profile = $this->profileLink("<img class='avatar' src='$path' alt='avatar' />", $this->_user_id);
		} else {
			$profile = $this->getUserGravatar();
		}
		return $profile;
	}

Linking JomSocial profile + Avatar 11 years 7 months ago #9965

  • Steve Burke
  • Steve Burke's Avatar Topic Author
  • Offline
  • Junior Boarder
  • Junior Boarder
  • Posts: 38
  • Thank you received: 0
Now I can't go to page 2 of the comments :/ here's a link:

www.gamersnexus.net/news/370-e3-2010-fear3-video

Click page 2 or next. It doesn't show the other 5 comments. My fault, or the code above? Worked before I implemented the changes.

Linking JomSocial profile + Avatar 11 years 7 months ago #9966

  • Daniel Dimitrov
  • Daniel Dimitrov's Avatar
  • Offline
  • Administrator
  • Administrator
  • Posts: 9618
  • Karma: 155
  • Thank you received: 1081
Yep, I fixed this together with above error, but you didn't say that this way also not workign for you.
so go to JOSC_visual.php line 333 and change the function buildUserAvatarJomSocial to this
	private function buildUserAvatarJomSocial($userIds) {
		if($userIds) {
			$db =& JFactory::getDBO();
			$query = 'SELECT userid, thumb FROM #__community_users WHERE userid IN (' . implode(',',$userIds) . ')';
			$db->setQuery($query);
			$userList = $db->loadAssocList();
			$this->_profiles = array();
			foreach ($userList as $item) {
				if ($this->_avatar)
					$this->_profiles[$item['userid']]['avatar'] = $item['thumb'];
				else
					$this->_profiles[$item['userid']]['avatar'] = false;
 
			}
		}
	}
now it should work
  • Page:
  • 1
Time to create page: 0.159 seconds