Kunena 6.3.0 released

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

This category contains miscellaneous, uncategorised user contributions, (templates, modules, plugins and hacks) relating to older versions of Kunena that are no longer supported.

The topics in this category are for historical interest only. Owing to the structural changes that occurred in K 2.0, many of the ideas in these topics will not work with later versions and, for that reason, the topics are locked.

Question Tutorial: Member Legend

More
11 years 10 months ago - 11 years 10 months ago #1 by Sovaka
This has been posted a couple times and never has there been a definite reply informing those on how to do it.

::WARNING::
The folks who Develop Kunena do NOT support base file modifications. ALWAYS make back-ups of files you intend to modify!

So here it is;

To change the Legend to add or modify what is listed open;
/components/com_kunena/template/default/plugin/who/whoisonline.php

From line 93;
<span class = "kwho-admin" title = "<?php echo JText::_('COM_KUNENA_COLOR_ADMINISTRATOR'); ?>"> <?php echo JText::_('COM_KUNENA_COLOR_ADMINISTRATOR'); ?></span>,&nbsp;

There are three sections here that needs to be noted and to allow 'Additions' or 'Modifications'.
Span Class - 'kwho-admin'
Title - '<?php echo JText::_('COM_KUNENA_COLOR_ADMINISTRATOR'); ?>'
Span Text - '<?php echo JText::_('COM_KUNENA_COLOR_ADMINISTRATOR'); ?>'

The Span Class refers to your CSS file that will dictate all attributes to the text contained in the CSS files.
Which is located here: /components/com_kunena/template/default/css/kunena.default-min.css
Look for: #Kunena .kwho-admin, #Kunena a.kwho-admin
Change what you like here, be it colour, size, font et c.

The Title points to the Kunena Language file.
Which is located here: /components/com_kunena/language/en-GB/en-GB.com_kunena.ini
Look for: 'COM_KUNENA_COLOR_ADMINISTRATOR'
Or locate Line 60.
You can modify it here if you wish, or you can just remove '<?php echo JText::_('COM_KUNENA_COLOR_ADMINISTRATOR'); ?>' and put your own text there instead.

For Span Text, see above information about Title.

With these two changes, you should be able to 'Add' or 'Modify' existing Groups to suit your needs :)


::NOTE::
This won't add in an Ability for Kunena to automatically apply Users to this group in the 'Who's Online' list.

That fix coming up in the following post hopefully.

::ETA::
A side way of getting around that is by changing the Moderator or Global Moderator text and colour.
This will only work however, if the group of people you are assigning this to, you're happy with having moderator abilities.
Last edit: 11 years 10 months ago by Sovaka.

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

More
11 years 10 months ago - 11 years 10 months ago #2 by Sovaka
Replied by Sovaka on topic Tutorial: Member Legend
Well this is a rabbit hole indeed.

I may need help with this one...

These are the files modified so far;
/components/com_kunena/class.kunena.php
/components/com_kunena/template/default/plugin/who/whoisonline.php
/administrator/components/com_kunena/libraries/tables/kunenauser.php
/administrator/components/com_kunena/libraries/integration/access.php
/administrator/components/com_kunena/libraries/user.php
::ETA::
Added 2 more files;
/administrator/components/com_kunena/libraries/integration/joomla15/access.php
/administrator/components/com_kunena/libraries/integration/joomla16/access.php

Making the new class check errors in this file;
/components/com_kunena/lib/kunena.link.class.php

It starts linking back to Joomla User database but Errors 500.
From the logic I saw in the code, I was making it reference the User Group.
So making it check a group I created didn't work.
At least that is what I think it was doing, maybe someone can provide some light on this.


Ok, I have traced the issue down to;

File: /administrator/components/com_kunena/libraries/integration/access.php
Code:
public function isDeveloper($user = null, $catid = 0) { $user = KunenaFactory::getUser($user); // Visitors cannot be developers if (!$user->exists()) return false; // In backend every logged in user has global admin rights (for now) //if (JFactory::getApplication()->isDeveloper() && $user->userid == KunenaFactory::getUser()->userid) // return true; // Load developers list if ($this->developersByUserid === false) { $this->loadDevelopers(); } // If $catid is not numeric: Is user administrator in ANY category? if (!is_numeric($catid)) return !empty($this->developersByUserid[$user->userid]); // Is user a global administrator? if (!empty($this->adminsByUserid[$user->userid][0])) return true; // Is user a category administrator? if (!empty($this->adminsByUserid[$user->userid][$catid])) return true; return false; }

The commented section shows where it is breaking.
If I change the last line to 'return true;'
It all works fine and applies the colouring to the names in the list.

I've followed 'getApplication' through and I can't see why it is breaking.

:: WORKING CODE ::
Code:
public function isDeveloper($user = null, $catid = 0) { $user = KunenaFactory::getUser($user); // Visitors cannot be developers if (!$user->exists()) return false; // Check Forum Rank if ($user->rank = 13 && $user->userid == KunenaFactory::getUser()->userid) return true; // Load developers list if ($this->developersByUserid === false) { $this->loadDevelopers(); } // If $catid is not numeric: Is user administrator in ANY category? if (!is_numeric($catid)) return !empty($this->developersByUserid[$user->userid]); // Is user a global administrator? if (!empty($this->adminsByUserid[$user->userid][0])) return true; // Is user a category administrator? if (!empty($this->adminsByUserid[$user->userid][$catid])) return true; return false; }

I've simply had it check the Forum Rank of the User and match it against the User ID table of Joomla and Kunena (For what ever good that does).

Obviously in the Code above, you'd change "$user->rank = 13" to what ever number corresponds to the rank you wish to reflect.

This is a dirty Hack no doubt, but it gets the job done.
Should be more than fine for a couple extra groups.

The main downside that I have found with this method and how Joomla handles 'Usertypes' in the Database is that it isn't what is displayed in the User Manager or User Groups.
Just be careful of that also, you may need to change the UserType in the Database directly.

See next post for complete File codes and sections.
Last edit: 11 years 10 months ago by Sovaka.

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

More
11 years 10 months ago - 11 years 10 months ago #3 by Sovaka
Replied by Sovaka on topic Tutorial: Member Legend
File: /administrator/components/com_kunena/libraries/integration/joomla15/access.php
Code:
protected function loadDevelopers() { $db = JFactory::getDBO (); $query = "SELECT u.id AS userid, 0 AS catid FROM #__users AS u WHERE u.block='0' AND u.usertype IN ('Developer')"; $db->setQuery ( $query ); $list = (array) $db->loadObjectList (); KunenaError::checkDatabaseError (); return parent::loadDevelopers($list); }
Added to Line 34, directly after section: protected function loadAdmins()

File: /components/com_kunena/lib/kunena.link.class.php
Code:
function GetProfileLink($userid, $name = null, $title ='', $rel = 'nofollow', $class = '') { if (!$name) { $profile = KunenaFactory::getUser($userid); $name = htmlspecialchars($profile->getName(), ENT_COMPAT, 'UTF-8'); } if ($userid == 0) { $uclass = 'kwho-guest'; } else if (CKunenaTools::isAdmin ( $userid )) { $uclass = 'kwho-admin'; } else if (CKunenaTools::isModerator ( $userid, false )) { $uclass = 'kwho-globalmoderator'; } else if (CKunenaTools::isModerator ( $userid )) { $uclass = 'kwho-moderator'; } else if (CKunenaTools::isDeveloper ( $userid )) { $uclass = 'kwho-developer'; } else { $uclass = 'kwho-user'; } if ($userid > 0) { $link = CKunenaLink::GetProfileURL ( $userid ); if (! empty ( $link )) return CKunenaLink::GetHrefLink ( $link, $name, $title, $rel, $uclass ); } return "<span class=\"{$uclass}\">{$name}</span>"; }
Added Section: else if (CKunenaTools::isDeveloper ( $userid ))

File: /administrator/components/com_kunena/libraries/tables/kunenauser.php
Code:
/** * Is developer? * @var int **/ var $developer = null;
Added to Line 44, directly after section: * Is moderator?

File: /administrator/components/com_kunena/libraries/integration/access.php
Code:
protected $developersByCatid = false; //Added at Line 29 protected $developersByUserid = false; //Added at Line 30 public function clearCache() { $this->adminsByCatid = false; $this->adminsByUserid = false; $this->moderatorsByCatid = false; $this->moderatorsByUserid = false; $this->developersByCatid = false; $this->developersByUserid = false; $db = JFactory::getDBO (); $db->setQuery ( "UPDATE #__kunena_sessions SET allowed='na'" ); $db->query (); KunenaError::checkDatabaseError(); } public function getDevelopers($catid = 0) { if ($this->developersByCatid === false) { $this->loadDevelopers(); } return !empty($this->developersByCatid[$catid]) ? $this->developersByCatid[$catid] : array(); } public function isDeveloper($user = null, $catid = 0) { $user = KunenaFactory::getUser($user); // Visitors cannot be developers if (!$user->exists()) return false; // Check Forum Rank if ($user->rank = 13 && $user->userid == KunenaFactory::getUser()->userid) return true; // Load developers list if ($this->developersByUserid === false) { $this->loadDevelopers(); } // If $catid is not numeric: Is user administrator in ANY category? if (!is_numeric($catid)) return !empty($this->developersByUserid[$user->userid]); // Is user a global administrator? if (!empty($this->adminsByUserid[$user->userid][0])) return true; // Is user a category administrator? if (!empty($this->adminsByUserid[$user->userid][$catid])) return true; return false; }
Find and Replace Sections
Added to Line 108: public function getDevelopers($catid = 0)
Added to Line 141: public function isDeveloper($user = null, $catid = 0)

File: /administrator/components/com_kunena/libraries/user.php
Code:
public function isDeveloper($catid = 0) { $acl = KunenaFactory::getAccessControl (); return $acl->isDeveloper ( $this, $catid ); }
Added on Line 334, after section: public function isModerator($catid = 0)


[strike]I believe that was it.
If you run into any issues, let me know :)[/strike]

Well son of b*!
That only works for the viewing user :(
It doesn't change the other users that aren't viewing.

Back to drawing board.
Last edit: 11 years 10 months ago by Sovaka.

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

Time to create page: 0.480 seconds