Skip to Content Skip to Menu

how to make post-content-creation user update

16 years 10 months ago #52285 by twinkiestar
I want to build a simple point system: I created a new column in cb user table to store his/her point, and then whenever create a new article or comment, then I update the db table... my question is where should I put my db update code, should it be a mambot (if so, which event I should register an event handler) or somewhere else (I cannot think of a logical place to put this code)..

a bit of sample code will help here..

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

  • mikko
  • mikko
  • OFFLINE
  • Posts: 703
  • Thanks: 0
  • Karma: 115
16 years 10 months ago #52289 by mikko
There are two approaches to this:
-add points when user submits an article
-calculate the points based on submitted articles periodically or when needed

I would probably go like this: create the points field (cb_points) as read only. Also create a new column (cb_points_temp) to the jos_comprofiler table.

Create a set of SQL queries that
-sets cb_points_temp to zero
-adds the number of articles submited by the use to cb_points_temp
-adds the number of comments submited by the use to cb_points_temp
...perhaps more things...
-copy the value of cb_points_temp over cb_points

Run this SQL script in cron or any other system that you use to schedule commands.

Mikko

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

16 years 10 months ago #52337 by twinkiestar
Replied by twinkiestar on topic Re:how to make post-content-creation user update
thank Mikko for your thought..

problem with approach 2 is the point update will not be real time, i.e user who just published a new article may wait for a while before he saw his/her points updated.that said, I am more leaning toward option 1, but then where is the code get called after user created a new content? (I think just tracking the save button on the authoring page is not enough, because use may just update the article, in that case, we don't want to add point when user click save button...) I guess there must be an event corresponding to new article added...

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

Moderators: beatnantkrileon
Powered by Kunena Forum