Kunena 6.2.5 & module Kunena Latest 6.0.7 released

The Kunena team has announce the arrival of Kunena 6.2.5 [K 6.2.5] which is now available for download as a native Joomla extension for J! 4.3.x/4.4.x/5.0.x. This version addresses most of the issues that were discovered in K 6.1 / K 6.2 and issues discovered during the last development stages of K 6.2

Question Guide: Avatar Integration / Profile Links - 1.6

More
13 years 5 months ago - 13 years 5 months ago #1 by wabugi
Things you should know before you take a look at the guide:

Two weeks ago I started a new thread in the Kunena 1.5 forums because I wanted to know how to change the avatar path. I'm working on a new Joomla website with many custom components including user profiles and avatars. I didn't get an answer, but that wasn't a big problem because just a week later Kunena 1.6 stable was released.
I switched to Kunena 1.6 and created my own "plugin" for both avatar and profile link integration. Today, someone wrote me a pm and asked if I would share my integration plugin. Maybe someone else is interested in this, so I decided to share my solution with you :)

You should know, that I'm far away from being a good programmer. I just try to help myself by using my beginner php skills and tying my best to achieve my goals. If you have any suggestions concerning my code, please let me know.

Avatar Integration:

Browse to Your_Joomla_Folder/administrator/components/com_kunena/libraries/integration/ and create a new folder. Let's call it "wabugi" for this guide ^^
Open the folder and create 3 new files: index.html, avatar.php and profile.php.

The content of index.html:
Code:
<html><body></body></html>

The content of avatar.php:
Code:
<?php // Dont allow direct linking defined( '_JEXEC' ) or die(''); jimport( 'joomla.filesystem.file'); class KunenaAvatarWABUGI extends KunenaAvatar { public function __construct() { // Check if your component is really installed. $this->integration = KunenaIntegration::getInstance ('wabugi'); if (! $this->integration || ! $this->integration->isLoaded()) return; $this->priority = 50; } public function getEditURL() { // Path to the page where your avatar can be uploaded/deleted/edited. You will have to modify this! return JRoute::_('index.php?option=com_wabugi&view=settings'); } protected function _getURL($user, $sizex, $sizey) { // Get the user id $user = KunenaFactory::getUser($user); $uid = $user->userid; // The path to where your avatars are stored. In this case this is Joomla_Root/images/profiles/ID_of_the_User.jpg $avatarcheck = 'images' .DS. 'profiles' .DS. $uid. '.jpg'; // Check if there is an avatar available for the user. if(file_exists($avatarcheck)) { // If yes, set the avatar path. $avatar = JURI::base().'images/profiles/'.$uid.'.jpg'; } else { // If no, set the path to the default avatar. $avatar = JURI::base().'images/profiles/avatar.png'; } return $avatar; } }

Profile Links Integration:
The content of profile.php:
Code:
<?php // Dont allow direct linking defined( '_JEXEC' ) or die(''); class KunenaProfileWABUGI extends KunenaProfile { public function __construct() { // Check if your component is really installed. $this->integration = KunenaIntegration::getInstance ('wabugi'); if (! $this->integration || ! $this->integration->isLoaded()) return; $this->priority = 50; } public function getUserListURL($action='', $xhtml = true) { // This is the link to the user list. If you have a custom component for the userlist, you can set the link here. In my case it's still the Kunena user list. return JRoute::_('index.php?option=com_kunena&func=userlist'.$action, $xhtml); } public function getProfileURL($userid, $task='', $xhtml = true) { if ($userid == 0) return false; // Set your path to the user profiles of your custom component here. You will have to modify this! return JRoute::_('index.php?option=com_wabugi&view=profile&uid='.$userid, $xhtml); } public function showProfile($userid, &$msg_params) {} }

Save everything and log into the admininistration of your Joomla-Installation. Go to the configuration of your Kunena forum and open the "Integration" tab. You should now be able to choose "wabugi" (or whatever name you have chosen for your integration) from the "Avatars" and the "Profiles and User List" drop-downs. Don't forget to save your configuration!

If everything went right, you should now have your own avatars integrated into Kunena 1.6. Profile links should now be redirected to the profile page of your custom component. If you need the avatar integration only, you can just leave away the profile.php file. If you need the profile link integration only, just leave away the avatar.php file.

Again, I'd like to say that I'm no good programmer. I'm sure there are better and cleaner solutions to integrate avatars and profiles into Kunena 1.6. But for the moment, I'm happy with my solution, because it works perfectly for me :)

UPDATE October 14. 2010: Optimised the code. Special thanks to Matias :)
Last edit: 13 years 5 months ago by wabugi.
The following user(s) said Thank You: fxstein, bzzik, traticodo

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

More
13 years 5 months ago #2 by Matias
Few notes:

* In __construct() you should have check if your component is really installed. If not, just return..

* Don't use KunenaRoute for other components. There's JRoute::_() in Joomla + variations in some components.

* You do not need to edit admin.kunena.php -- those are leftover code and should be removed. All integration options should appear automatically without any changes. So Part2 is not needed. ;)

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

More
13 years 5 months ago #3 by bzzik
Thanks for tutorial. I made my own integration :)

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

More
13 years 5 months ago #4 by wabugi
I updated the guide. Thanks for your suggestions Matias :)

I'm glad I was able to help you bzzik!

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

More
13 years 5 months ago #5 by bzzik
What is the purpose of method showProfile($userid, &$msg_params) ?

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

More
13 years 5 months ago #6 by traticodo
Thank you Wabugi!
It works for me!

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

Time to create page: 0.424 seconds