×

Notice

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

TOPIC: Writing own plugin

Writing own plugin 11 years 5 months ago #21238

  • Lennart
  • Lennart's Avatar Topic Author
  • Offline
  • Junior Boarder
  • Junior Boarder
  • Posts: 22
  • Thank you received: 0
Hi Daniel,

I really, really like your extensions. After CMC, I'm testing CComment Core.
I know you support some integrations out-of-the-box, but I will use it for my sportclub, where I can't spend any money :)

I have a social login extension - HS_Users ( extensions.joomla.org/extensions/access-...on-cloud-based/23098 ), based on HybridAuth (Open Source, I like!).

By changing the getUserGravatar function, I'm able to load the user images from hs_users into the comments. But it's not very tidy: it will disappear with every update of CComment.

Can I extend the functionality with an external file, so that's not affected with an update?

I don't know if this is possible and/or allowed. Thanks :)

Writing own plugin 11 years 5 months ago #21239

  • Daniel Dimitrov
  • Daniel Dimitrov's Avatar
  • Away
  • Administrator
  • Administrator
  • Posts: 9618
  • Karma: 155
  • Thank you received: 1081
So you want to load the user avatar out of the HS_users extension? Right now the avatar/profile system that we have is not extensible (this is maybe one of the first things that I need to improve with 5.1 :))

But why not give me the code that needs to be inserted in ccomment and I can add this to the extension - this way you won't loose the changes with each update :)

Writing own plugin 11 years 5 months ago #21241

  • Lennart
  • Lennart's Avatar Topic Author
  • Offline
  • Junior Boarder
  • Junior Boarder
  • Posts: 22
  • Thank you received: 0
Well, I modified getUserGravatar, and changed the parameter (it's an userId here):
public static function getUserGravatar($userId=null)
	{
			$default = self::noAvatar();
			if($userId == null)
			{
				$user = JFactory::getUser();
 
				if($user->guest){
					return $default;
				}
				$userId = $user->get('id');
			}
 
 
			$db = JFactory::getDbo();
			$query = $db->getQuery(true);
		        $query->select('image_folder, image_name');
		        $query->from('#__users_extended');
		        $query->where('user_id='.$db->quote($userId)); 
 
			$db->setQuery($query,0,1);			
			$r = $db->loadObject();
 
			if(empty($r)){
				return $default;
			}	
		        if(mb_strlen($r->image_folder)>0&&mb_strlen($r->image_name)>0){
			return '/images/hsu/'.$r->image_folder.'/'.$r->image_name;		
		        }else{
			return $default;
 
		      }
 
	}

Writing own plugin 11 years 5 months ago #21242

  • Daniel Dimitrov
  • Daniel Dimitrov's Avatar
  • Away
  • Administrator
  • Administrator
  • Posts: 9618
  • Karma: 155
  • Thank you received: 1081
Actually you should not modify the getUserGravatar as this function gets a gravatar image. Right now what you should do is add a new case to buildUserAvatars and createa a new function buildUserAvatarHSuser($userIds)

And once you have this function you can just add an option to models/forms/settings.xml to support_avatars

there is a components parameter components="com_k2,com_community,com_comprofiler,com_kunena"

add com_hsuser to it and this option will be available then in the backend.

Writing own plugin 11 years 5 months ago #21244

  • Lennart
  • Lennart's Avatar Topic Author
  • Offline
  • Junior Boarder
  • Junior Boarder
  • Posts: 22
  • Thank you received: 0
I know, but
1) I don't know how to write components for Joomla
2) I'm not familiar with your internal structure

So, this is the answer I was looking for! :) Do you have a public repo where I can make a pull request?

Writing own plugin 11 years 3 months ago #22087

  • Lennart
  • Lennart's Avatar Topic Author
  • Offline
  • Junior Boarder
  • Junior Boarder
  • Posts: 22
  • Thank you received: 0
Hmm, I made the changes, but I'm unable to test it.

Is 'Support_Avatars' exclusively for CComment Pro?

Writing own plugin 11 years 3 months ago #22104

  • Daniel Dimitrov
  • Daniel Dimitrov's Avatar
  • Away
  • Administrator
  • Administrator
  • Posts: 9618
  • Karma: 155
  • Thank you received: 1081
yes, the core version supports only gravatar.

Writing own plugin 11 years 3 months ago #22107

  • Lennart
  • Lennart's Avatar Topic Author
  • Offline
  • Junior Boarder
  • Junior Boarder
  • Posts: 22
  • Thank you received: 0
Well, that's a pity. Looks like I have to keep my "gravatar" solution. Thanks anyway :)
  • Page:
  • 1
Time to create page: 0.109 seconds