Hi!
As far as I was able to understand from the code to assign karma to a user for node insertion we execute the following query:
$query = "SELECT COUNT(*) FROM {node} n WHERE n.uid = %d $node_types_sql ". user_karma_sql_duration($days, "n.created");
So basically this query counts the number of nodes in db which is authored by specific user id, then multiplies it by karma multiplier for node insertion and we get the amount of karma assigned.
But before that, "earlier" in code, the module checks whether we insert or update the node. So why check for node updating since it doesn't matter if we update or insert a node - the karma will be counted in accordance with the number of nodes authored by specific user in the db?
But my point is not in that. I wrote this just to make myself clearer and ask whether I understood correctly. My point is if there is a possibility to separate node insertion and node updating for karma calculations? I'm searching for a way to assign karma when a node is not simply inserted but also when it is updated. So is there a way to do it?
Comments
Comment #1
mercmobily commentedHi,
First of all, it would be helpful if you reposted your whole entry with precise file names and line numbers every time you refer to ANYTHING in the code...
As far as the actual question:
------------------------------
My point is if there is a possibility to separate node insertion and node updating for karma calculations? I'm searching for a way to assign karma when a node is not simply inserted but also when it is updated. So is there a way to do it?
-------------------------------
The module implements the hook_nodeapi() hook with this:
So, the recalculation IS happening both when a node is added, or is edited.
If this doesn't answer your question, please clarify!
Merc.
Comment #2
alex-and-r commentedHi,
Sorry for my mistakes. Unfortunately I don't know how to edit my entry so I just correct myself here, in my comment.
In my first post, when I'm talking about the code, I refer to "user_karma_insert_node.module" file and to line 148 in this file, which says:
$query = "SELECT COUNT(*) FROM {node} n WHERE n.uid = %d $node_types_sql ". user_karma_sql_duration($days, "n.created");And now concerning my question itself.
So I was right and was able to read the code correctly. But its RECALCULATION, so actual karma is only awarded when a new node is added by a user. When a user updates a node no karma is awarded. The karma is recalculated but remains the same. Am I right?
And my primary question is:
Is it possible to add functionality to this module so that karma is added not only when a node is added but also when a node is updated?
As for now no karma is awarded when node is edited, the karma is only being recalculated. And my feature request is that a karma being awarded for node editing too.
And please have a mercy on me if I'm not making my point clear. I'm trying but if I still wasn't able to clarify something I'll be happy to answer all the questions!
Comment #3
mercmobily commentedHi,
Ah! I see!
It's entirely possible to do that. but, it would be a brand new karma plugin which counts the node revisions rather than the node inserts.
It's *possible* but it's definitely a bit of work.
Please feel free to add it to the queue. but keep in mind that it won't get much priority...
(Specify that you'd like a new karma plugin that awards extra karma for multiple versions of a node by the user)
I have to be honest, and say that it feels like a bit of an overkill but...
Bye,
Merc.
Comment #4
mercmobily commentedHi,
Marked as "fixed" since the specific question was answered!
Merc.
Comment #5
alex-and-r commentedAn overkill? May be, may be...
But in my situation it's no overkill at all but rather one of the most significant pieces of the puzzle which I don't have.
And anyway, thanks for answers, I aprciate it very much!
Comment #6
mercmobily commentedHi,
If you know even a little bit of PHP programming, it will be easy for you to adapt code from one of the existing plugins to do exactly what you need.
Testing, however, will take a lot of time. Hint: disable Javascript, and enable debugging in the karma module. And maybe do a bit of meditation before testing.
If you do come up with such a plugin, please send it our way.
Merc.
Comment #7
Anonymous (not verified) commentedAutomatically closed -- issue fixed for two weeks with no activity.