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 [Solved] Report to moderator through the PM-system not email

More
14 years 4 months ago - 14 years 1 day ago #1 by john7p
Hello,

Like others I found that it would be usefull to use the "report to moderator" function through the installed PM system.

After some digging in the source i found that the funtionality is there.
At least for the "Clexus PM" system. I don't know if it is active tough.

For the PM-system I am using "UddeIM" the prepwork has been done. But the final function is not in place.

As seen in the file "\components\com_kunena\template\default\plugin\report\report.php"

at line 184
Code:
case 'uddeim': SendUddeIM(); break;


Below that at line 283 the funtion SendClexusPM() is there.


Is there a wizzard aboard who likes to finish or create the final funtion SendUddeIM()? I am no scriptkiddy outherwise I would finnish it.

Thanks for reading my boring msg :laugh:


Greetings from a rainy :( Holland


John


___________


I am trying myself now. :S

Is there progres? Oh yes.....

I have changed at line 31 the $type to '1' and the function is executed.
I just have to get the query to the database right.

I will post further progres later :lol:
Last edit: 14 years 1 day ago by sozzled. Reason: Changed subject to improve search relevance

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

More
14 years 4 months ago - 14 years 4 months ago #2 by john7p
Just to let you know B)

I made great progress. After some trail and error I got a report out.
UddeIM 1.9 has an API onboard so you can send an IM with just a little coding.

Attached is my \components\com_kunena\template\default\plugin\report\report.php

My coding is not that spectacular, and I had to leave out some blocks of code that didn't respond correctly for my situation.

I am running a localhost to learn. I got some 20 users and the admin is the moderator.


I made the next changes:

At line 32 I added:
Code:
$type = '1';

I did this because I could not find the place where "type" (line 31) was set

At line 162 I changed:
$sender into $reporter

Because UddeIM uses the id-number and not the name. otherwise the IM originates from "Public-Users" (ID=0)

At line 185 I changed for the correct funtion-call:
Code:
SendUddeIM($reporter, $subject, $message, $msglink, $mods, $admins);


This is the function:
Code:
Function SendUddeIM($reporter, $subject, $message, $msglink, $mods, $admins){ require_once(JPATH_SITE.'/components/com_uddeim/uddeim.api.php'); $uddeim = new uddeIMAPI(); $admin = 62; if (!$uddeim->isInboxLimitReached($toid)){ $uddeim->sendNewMessage($reporter, $admin, $message, 1, 1); } }

When executing collecting the admins-list and the moderators-list from line 99, they turn up empty so there is no recipient. So I hardcoded $admin here.


Perhaps de Devs could incorparate this in the next release. And cleanup some of my coding. B)


It was a nice puzzle.

Greetings John

File Attachment:

File Name: report.zip
File Size:3 KB
Attachments:
Last edit: 14 years 4 months ago by john7p. Reason: Upload file

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

More
14 years 4 months ago #3 by john7p
Replied by john7p on topic Another question.
New development:

I tracked down the way $mod en $admin work.

I could not get the IM out for them.

I found that $mod uses $mod->userid, and $admin uses $amdin->id.
That was one to produce a headacke.

I came up with the next function:
Code:
Function SendUddeIM($reporter, $subject, $message, $msglink, $mods, $admins){ require_once(JPATH_SITE.'/components/com_uddeim/uddeim.api.php'); $uddeim = new uddeIMAPI(); // to each admin foreach ($admins as $admin) { if (!$uddeim->isInboxLimitReached($admin->id)){ $uddeim->sendNewMessage($reporter, $admin->id, $message, 1, 1); } } // to each mod foreach ($mods as $mod) { if (!$uddeim->isInboxLimitReached($mod->userid)){ $uddeim->sendNewMessage($reporter, $mod->userid, $message, 1, 1); } } }

And now where is the catch?

If a mod is an admin too, then he gets a message as mod and one as admin. One message is enough.

How do I check if a mod is or is not an admin?
I have tryed using array_search() but i could not get it to work.

Does anybody have any idee on how to fix this ???


Greetings John

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

More
14 years 4 months ago - 14 years 4 months ago #4 by xillibit
Hello,

This is a good thing what you are develloping, i have not tested your code, i have just tried to modify a bit your function SendUddeIM(). I do a check on the file uddeim.api.php because in uddeim version before the 1.9, this file doesn't exist. I test if the user if a moderator and like that the pm is send, but i don't know if by default the administrator is set moderator too.
Code:
function SendUddeIM($reporter, $subject, $message, $msglink, $mods, $admins){ if(file_exists(JPATH_SITE.'/components/com_uddeim/uddeim.api.php')) { require_once(JPATH_SITE.'/components/com_uddeim/uddeim.api.php'); } $uddeim = new uddeIMAPI(); $kunena_db->setQuery("SELECT userid, moderator FROM #__fb_users"); $kunena_db->query(); $datas = $kunena_db->loadObjectList(); // to each users with moderator=1 this depends on the settings in the table jos_fb_users foreach ($datas as $row) { if($row->moderator == "1") { if (!$uddeim->isInboxLimitReached($row->userid)){ $uddeim->sendNewMessage($reporter, $row->userid, $message, 1, 1); } } } }

I don't provide support by PM, because this can be useful for someone else.
Last edit: 14 years 4 months ago by xillibit.

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

More
14 years 4 months ago #5 by john7p
Thanks xillibit,

Thank you for the help.

I think my question is not that clear. I will try to explain:

Half of the work has already been done by the original code.

The moderators for the current forum catagory are already known through $mods
The administrators for the site are known through $admins

These two array's are handed down through the code originating from line 100

I need to compare the $mods->userid against the $admin->id

I created a foreach to send to the $admins

I now need a foreach to send to the $mods except if he is an admin.

Otherwise this mod gets double messages.

It should look somthing like this:

Code:
foreach admin {sendmessage} foreach mod if (mod = admin { //do nothing else { sendmessage}

This is very simplified but this is what I need. Or rather what I think is needed.

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

More
14 years 4 months ago - 14 years 4 months ago #6 by john7p
Hello

How could I be so dumb. :blush: :blush: :blush:
Trying to develop something with the display-errors off at the serverside.
I noticed it after messing with array-functions.

Meanwhile I already wrote my own search function. B)
It was a good practice for a former dbase III plus/clipper programmer.

Here it is my solution. If someone can do it simpler using array() stuf be my guest :lol:
Code:
Function SendUddeIM($reporter, $subject, $message, $msglink, $mods, $admins){ require_once(JPATH_SITE.'/components/com_uddeim/uddeim.api.php'); $uddeim = new uddeIMAPI(); // to each Joomla admin foreach ($admins as $admin) { if (!$uddeim->isInboxLimitReached($admin->id)){ $uddeim->sendNewMessage($reporter, $admin->id, $message, 1, 1);} } // to each mod foreach ($mods as $mod) { // If this moderator is NOT a Joomla administrator then proceed to sending msg if (!is_admin($mod->userid, $admins)){ if (!$uddeim->isInboxLimitReached($mod->userid)){ $uddeim->sendNewMessage($reporter, $mod->userid, $message, 1, 1); }} } }//end of sendudeIM Function is_admin($moderator,$admins){ foreach ($admins as $isadmin){ IF ($isadmin->id = $moderator){return true;} } return false;// moderator is not an Admin } //end of is_admin

The question now is, do you want a Joomla Administrator to receive reports if he is NOT a Moderator. IF not, then cut-out the code you don't need.

@xillibit,

Thanks for your reply. Kick de Devs if you feel like it :lol: , and ask them if they would like to use this in a next release.

One question though:
Where is $type configured in line 31?
Is it hardcoded "0" somwhere or is it changed in the backend?

John
Last edit: 14 years 4 months ago by john7p. Reason: typo

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

More
14 years 4 months ago #7 by xillibit
john7p wrote:


@xillibit,

Thanks for your reply. Kick de Devs if you feel like it :lol: , and ask them if they would like to use this in a next release.

One question though:
Where is $type configured in line 31?
Is it hardcoded "0" somwhere or is it changed in the backend?

John

In Kunena 1.5.x series there will have no new features, this thing can be added to Kunena 1.6.0. For the variable $type in line 31, is got by url. But i don't know if it's set in somewhere.

I haven't yet tested your code.

I don't provide support by PM, because this can be useful for someone else.

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

More
14 years 4 months ago #8 by john7p
No problem I was just curious about $type. ;)

And about testing, it works for me so take your time. :cheer:
I hope others will find it useful to B)

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

More
14 years 1 day ago - 14 years 1 day ago #9 by Cerberus
any news on this hack cause i tried it and as an admin i dnt recieve the report :(


EDIT: dw i fixed it :D
Last edit: 14 years 1 day ago by Cerberus.

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

More
14 years 1 day ago #10 by john7p
Cerberus,

What was your problem and your fix?


John

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

Time to create page: 0.464 seconds