A A A

Please consider registering
guest

Log In Register

Register | Lost password?
Advanced Search:

— Forum Scope —



— Match —



— Forum Options —




Wildcard usage:
*  matches any number of characters    %  matches exactly one character

Minimum search word length is 4 characters - maximum search word length is 84 characters

Topic RSS
Integrating "Cubepoints" into Simple:Press 4.0
Jan 5, 2009
4:17 pm
Member
Forum Posts: 43
Member Since:
Mar 12, 2007
Offline

Hey Andy, Papa..

First of all, let me thank you for another major step in SF-Development! Although there were some bugs (the already “well known” bug within Firefox and some others) I successfully mastered to get my forums up to 4.0.

So far, our users are really happy with it! Some really nice addons, redone functions etc.pp. Me as an admin at least – i’m very happy to tell that we could finally re-activate RSS for our forums again as it contains also an “internal” forum, which contains confidential data und could be read by ANY user knowing (or testing out) the correct ID of the forum/s. Now everything works just fine!

What i’m looking for now are some – probably – very simple things: I’m trying to integrate the new “CubePoints” Plugin into the whole WP-System. Means: Not only comments and articles, but forums also.

The Plan:

  1. Topic Starter receives – let’s say – 5 Points for opening a new topic
  2. Follow up posts receive 1 point for each post
  3. Upon deletion of a topic/posting points get deducted from achieved score again

Just an example to give you a picture.

What i need now:

  1. Name/Location of the script/s and function/s that execute a new topic posting
  2. Name/Location of the script/s and function/s that execute a new follow up posting
  3. Name/Location of the script/s and function/s that execute a new postings deletion
  4. Name/Location of the script/s and function/s that execute a topics deletion
    (Question: Does that delete every post ONE by ONE? Then it would know every users ID etc. pp – and therefore be ideal to deduct the according score from every users account? Or is there any possible workaround?)
  5. If you could name the exact lines that would have to be edited/where code would need to be inserted – that would be just perfect, but maybe too much asked for?!

I’m quite willing to give you something back in exchange, like a full documentation of what has to be done to achieve the above mentioned or whatever to get a full community thing up and running.. Deal?[Edit: PS – a little donation to show respect and support further development has just been done..)

Jan 5, 2009
5:10 pm

SP Master
Forum Posts: 23587
Member Since:
Dec 10, 2006
Offline

wow, ambitious endeavor… we have a points type system on our list for future consideration, but it likely wont be using that plugin though when the time comes, will take a look.

I would start in two places:

sf-database.php – most actions like you ask about are handled in there, or at least the db manipulation

sf-hook-template.txt – read the online help about hooks, but there may be some (save post) in there that could help you.

Thanks for the donation!

Jan 6, 2009
8:42 am
Member
Forum Posts: 43
Member Since:
Mar 12, 2007
Offline

Thanks for the quick reply though i'm a bit disappointed about it's richness of details. Or the lack of it ;)

However, after some research I can now answer most of my questions. Actually it's already working ~90% already now.

  1. Post creation – score can easily be increased.
    File: sf-hook-template.txt – File has to be renamed to *.php to make it work. Lines to be edited as follows, beginning at line #294:

    function sf_hook_post_save($permalink, $content)
    {
    /* Additional CubePoints integration */
    if( function_exists('cp_alterPoints') && is_user_logged_in() ){
    cp_alterPoints(cp_currentUser(), 1);
    }
    return;
    }

    This will add just one point at post creation.

  2. The editable hook-thingie is really a nice idea. Just a pity that it lacks some functions for post deletion, topic creation etc. So we have to mingle with the core-files confused
    To deduct a point upon TOPIC deletion:
    File: sf-database.php. Lines to be edited as follows, beginning at line #2634:

    if($wpdb === false)
    {
    if($show) update_sfnotice('sfmessage', '1@'.__("Deletion Failed", "sforum"));
    return;
    } else { # CubePoints integration
    if( function_exists('cp_alterPoints') && is_user_logged_in() )
    {
    cp_alterPoints(cp_currentUser(), -1);
    }
    }
  3. To deduct a point upon POST deletion:
    File: sf-database.php. Lines to be edited as follows, beginning at (with the lines above already inserted) line #2684:

    if($wpdb === false)
    {
    if($show) update_sfnotice('sfmessage', '1@'.__("Deletion Failed", "sforum"));
    } else {
    if( function_exists('cp_alterPoints') && is_user_logged_in() )
    {
    cp_alterPoints(cp_currentUser(), -1);
    }
    if($show) update_sfnotice('sfmessage', '0@'.__("Post Deleted", "sforum"));
    }

Works like a charm now – with just small deductions from my original plan as follows:

  • It does not seem possible to distinguish a TOPIC and a POST creation. So also not possible to give like 5 points for topic creation and just 1 for topic postings.
  • It does not decrease the score of any follow up posters when a complete TOPIC is removed. Points will just be removed from the original topic poster. I have an idea on how to fix that, but any input/quick solution/code would be nice.

Any further input on these things would be really nice!

Besides: Why i prefer CubePoints or any other system over a just simple-press internal function is that CubePoints already integrates flawlessly with article and comment creation as well as deletion. So it's a more global approach to a real community rather than just a forum-community thingie..

Jan 6, 2009
8:52 am
Member
Forum Posts: 43
Member Since:
Mar 12, 2007
Offline

*DANG* Bug :P

#2 and #3 do remove the points from the accordings admins/moderators account..
Can anyone shed some light on how to find out the users id of the creator that need to be parsed to CubePoints for the above mentioned?!

Jan 6, 2009
10:49 am

SP Master
Forum Posts: 23587
Member Since:
Dec 10, 2006
Offline

you can distinguish a post and a topic by looking at the number of posts in the topic where the post is being made. If its one, then its the start of the topic. Just add a db query to the hook routine to get the number of posts. You can do this in any of the hooks as you have complete access to the db.

for removing a topic, you will need to modify the core spf code. I will also open a new ticket for consideration of adding a few more specialized hooks to tell when certain actions occur.

As I mentioned, when we get around to implementing a points type system (and its tentatively on the books for 4.1) we will consider cubepoints. But it will globally have to meet our needs. For example, some users will ONLY want a points system for the forum, so could cubepoints be turned off for posts and/or comments? you dont need to answer, but just trying to point out that no one solution is likely to make everyone happy.

Jan 6, 2009
11:36 am
Member
Forum Posts: 43
Member Since:
Mar 12, 2007
Offline

Cubepoint was just released so i think its a long way to go til perfection.. anyway – works like a charm so far and does everything as its supposed to. And yes – you can freely adjust if and how many points you will add for a comment or even totally disable it. Same goes for articles. You can also subtract a freely adjustable amount of points for deletion of a comment, so if you want to "punish" a user for some comment you may give him one point for each comment and like -5 points for its deletion.. And yes – you can also donate points from user to user.. Really nice thing. Anyway, i'm not trying to convince anyone, that's not my job..

Back to topic: Just for now i could live with the fact that only the topic poster will get one point subtracted and not the follow-up posters. I think that could be done though through a query for the PostID.
Exactly, that would be line #2646:

$wpdb->query("DELETE FROM ".SFPOSTS." WHERE topic_id=".$topicid);

Guess i would have to walk through every post with that TopicID and deduct points from the according user of that posting.

But my main concern remains unanswered again: Is there any way to get access to the userID in my codesnippets #2 and #3? I need to replace cp_currentUser() with the userID of the poster as the above mentioned code will deduct the point/s from MY or the moderators account..

Personal note: sf-hook-template.php is a brilliant idea as it allows everyone to do whatever one individually wants. It just lacks some features as the deletion of posts, topics (including all followup-posts), access to the userID (as it seems) and last but not least the option to display anything in the Userbox that appears left to every posting. Just sharing some thoughts..

Jan 6, 2009
5:40 pm

SP Master
Forum Posts: 23587
Member Since:
Dec 10, 2006
Offline

you want the user id of the person who started the topic?

$starter =  $wpdb->get_var("SELECT user_id FROM ".SFTOPICS." WHERE topic_id = ".$topicid);

Assume this would go in the two locations in sf-database.php that you modified…

Jan 7, 2009
3:16 am
Member
Forum Posts: 43
Member Since:
Mar 12, 2007
Offline

YES! Thanks very very much, Papa! Seems to work now as expected. Just need to walk through the follow-up posts on a topic now, then it would be perfect, i guess

And it would be nice to have a hook to display whatever in the Userbox left to every post without hacking the core-code. If that could be added within the next release, i`d be totally happy!

An updated and bugfixed version of Cubepoints is expected within the next 2 days, btw..

Jan 24, 2009
8:46 am
Ted
Guest

I am also interested in using cubepoints with simplepress. I am not as technically savy as the original poster.

Is there a way you could integrate it into the next update for those of us who wish to use it as a points system, till you come up with your own. Just keep in mind that many sites are now starting to use Cubepoints and they might not want 2 point systems.

I would try the coding listed above, but again I am not that tech savy.

Thanks.

Jan 24, 2009
9:08 am

SP Master
Forum Posts: 23587
Member Since:
Dec 10, 2006
Offline

it will not be in the upcoming 4.0.1.

We have a ticket open for a points system to be considered in 4.1. At this time, no clue if it will get it in or if it will be standalone (our own thing) or use some other plugin (such as cubepoints).

Forum Timezone: America/Chicago

Most Users Ever Online: 444

Currently Online:
58 Guest(s)

Currently Browsing this Page:
1 Guest(s)

See All Online Activity

Top Posters:

-Radio-: 1251

Lee H: 606

Luffer: 535

Conrad_Farlow: 485

jim: 478

neon: 263

ovizii: 240

Tal: 240

Member Stats:

Guest Posters: 2616

Members: 7328

Moderators: 1

Admins: 2

Forum Stats:

Groups: 5

Forums: 16

Topics: 10839

Posts: 79131

Moderators: Brandon C (158)

Administrators: Yellow Swordfish (22131), Mr Papa (23587)