Social Web CMS
February 09, 2010, 06:42:37 am *
Welcome, Guest. Please login or register.
Did you miss your activation email?

Login with username, password and session length
News: For the latest news and updates, please follow us on Twitter! http://twitter.com/HotaruCMS
 
   Home   Help Search Login Register  
Pages: 1 [2] 3
  Print  
Author Topic: Points Module  (Read 4463 times)
seriestv
Newbie
*
Offline Offline

Posts: 11


View Profile
« Reply #15 on: September 20, 2008, 12:15:24 pm »

Hi longcountdowm

I did it, wasnt so difficult as I assumed. I achieved it by only editing and adding querys.
I would use your settings for actions.

This night I'll work on add functionality for change the values from de Admin Section.

Thanks dude
Logged
chrisgaunt
Newbie
*
Offline Offline

Posts: 5



View Profile
« Reply #16 on: October 15, 2008, 11:36:09 am »

Just so everyone knows, I currently have this module under development as well...Expect it sometime next week.
Dave.

I was looking at doing something like this on my site. Any progress on the points module?
Logged
davemackey
Administrator
Sr. Member
*****
Offline Offline

Posts: 271



View Profile WWW
« Reply #17 on: October 15, 2008, 04:24:43 pm »

Well, no guarantees...But this is the module and it works on my site...My site has been somewhat heavily modded...Please let me know if you install it and encounter any problems/if it works. Smiley
Dave.

* points.zip (10.62 KB - downloaded 90 times.)
Logged

- http://www.informednetworker.com/ - Informed Networker - Social News for IT Professionals.
chrisgaunt
Newbie
*
Offline Offline

Posts: 5



View Profile
« Reply #18 on: October 17, 2008, 07:38:42 am »

Thanks Dave.

It doesn't seem to be working for me. When I regenerate the points they stay at zero and also when I comment or add a story it doesn't update the total.
I think it's not picking up the point config values from the config table so the values are being multiplied by nothing which equals 0.

I'm not sure how to fix the config table problem (I had this using the pligg xml sitemap module too).
A quick fix is just to hard code the values into the regenarate_points function.

I'm a little confused as to how it actually manages to update the total when someone comments. I can't see where it hooks into the site. I'm going to spend a little while looking around SWCMS and trying to work things out.
Logged
Nick
Administrator
Hero Member
*****
Offline Offline

Posts: 668



View Profile WWW
« Reply #19 on: October 17, 2008, 10:40:36 am »

In the points/points_init.php file there's this line:

Code:
module_add_action('points', 'points_Show_page', '');

...which means you need a hook in one of the core files, something like this:

Code:
check_actions('points', $vars);

Dave, can you check to see if you have something like this? Thanks! Smiley
Logged

Reinventing SWCMS at HotaruCMS.org - testers, designers and developers wanted!
davemackey
Administrator
Sr. Member
*****
Offline Offline

Posts: 271



View Profile WWW
« Reply #20 on: October 17, 2008, 11:26:05 am »

Ahh, there we go. Okay, I'll give you the line numbers + the code, including some surrounding code to give context. As I said, my codebase has been heavily modified, so the line numbers I give may not match up with your line numbers. :-/ I am working on getting all of my custom code moved into modules, that way it will be much easier to compare code...but that is still a work in progress.
comment.php line 65:
Code:
$vars = array('user_id' => $comment_author,'operation' => '1');
check_actions('points', $vars);

$link='';

$vars = array('comment'=>&$this);
check_actions('comment_post_save', $vars);
comment.php line 273:
Code:
$vars = array('user_id' => $this->author,'operation' => '5');
check_actions('points', $vars);
$link='';
libs\comment.php line 69:
Code:
$vars = array('user_id' => $comment_author,'operation' => '1');
check_actions('points', $vars);

$link='';

$vars = array('comment'=>&$this);
check_actions('comment_post_save', $vars);
libs\comment.php line 285:
Code:
$link->read();
//$link->update_karma($this->author,5);
$vars = array('user_id' => $this->author,'operation' => '5');
check_actions('points', $vars);
$link='';
lib\link.php line 956/958:
Code:
$vars = array('user_id' => $this->author,'operation' => '4');
check_actions('points', $vars);
$vars = array('user_id' => $user,'operation' => '3');
check_actions('points', $vars);
return $vote->reports();
lib\link.php line 1055:
Code:
$this->store_basic();
$this->check_should_publish();
//$this->update_karma($current_user->user_id,2);
$vars = array('user_id' => $current_user->user_id,'operation' => '2');
check_actions('points', $vars);
submit.php line 341:
Code:
$vars = array('user_id' => $linkres->author,'operation' => '0');
check_actions('points', $vars);
Dave.
Logged

- http://www.informednetworker.com/ - Informed Networker - Social News for IT Professionals.
Nick
Administrator
Hero Member
*****
Offline Offline

Posts: 668



View Profile WWW
« Reply #21 on: October 18, 2008, 02:43:07 am »

Cheers Dave, that should do the trick. Hopefully Chris will let us know if it works and then you can get this module "released". I do wonder, though, if the goal is to move everything into modules so people don't have to edit core files, all these hooks need to be added to the core by the developers so module-makers can use existing hooks instead of making new ones. Otherwise, when it comes to upgrading, the user has to put all the hooks back in.  Undecided
Logged

Reinventing SWCMS at HotaruCMS.org - testers, designers and developers wanted!
chrisgaunt
Newbie
*
Offline Offline

Posts: 5



View Profile
« Reply #22 on: October 18, 2008, 03:59:57 am »

Thanks Dave, I can see how this will work, but I think I've got something wrong somewhere because it's not picking up the points values that were set in the config table. So even if it does try to add the points it's still just 0. I added "Vote_points" to the line being echoed in the regenarate_points function which output:

Code:
Vote_points

So either I have something missing or I've not set up the site correctly. The points values are in the config table and I'm using PHP 5.2.6 with register_globals on

I agree about the modules not editing the core. That would be ideal.
Logged
catchpen
Administrator
Sr. Member
*****
Offline Offline

Posts: 399



View Profile WWW
« Reply #23 on: November 26, 2008, 06:19:46 pm »

I'm guessing Chris didn't get it working. Any ideas for working points module for swcms 1?
Logged

Nick
Administrator
Hero Member
*****
Offline Offline

Posts: 668



View Profile WWW
« Reply #24 on: November 27, 2008, 10:42:19 am »

Scores v.0.1

It's not a module, but an extra file that when loaded in the browser calculates scores for each user from all past activity.

Important: Although the file is different, Scores uses Karma's database field and variables. Use this instead of Karma, not in addition to it.

Instructions:
1. Download the attached scores.php file and upload it to your /libs/ directory.
2. Generate scores by loading http://your_swcms_site.com/libs/scores.php in your browser.

Optional:
- Open scores.php file in a text editor and change the point values at the top.
- Automate the process by setting up a cron job on your server, or use a paid service like http://www.webbasedcron.com/

Small problems:
1. Since this uses Karma, all references to the scores will still be labeled "Karma" in your template. You'll need to change "Karma" to "Points" or "Score" in languages/lang.conf.
2. The database field for Karma uses data type decimal. That means your scores will have .00 on the end of them. If you can, change the data type to int with length 20 in the users table in the database.

* scores.php (2.73 KB - downloaded 67 times.)
Logged

Reinventing SWCMS at HotaruCMS.org - testers, designers and developers wanted!
catchpen
Administrator
Sr. Member
*****
Offline Offline

Posts: 399



View Profile WWW
« Reply #25 on: December 03, 2008, 02:37:16 pm »

Scores v.0.1

It works, thanks LCD.

One extra thing I had to do in my database was default row remove the .00 off the end of the number
Logged

nothingman
Full Member
***
Offline Offline

Posts: 111


View Profile
« Reply #26 on: December 17, 2008, 07:57:23 am »

Thanks LCD, so how do I display the scores, usernames, avatars etc on the sidebar and is this similar to this --> http://forums.pligg.com/general-help/14563-new-way-generate-karma.html
Do we use it like the way Andtony has suggested here --> http://forums.pligg.com/general-help/14563-new-way-generate-karma-2.html


Scores v.0.1

It's not a module, but an extra file that when loaded in the browser calculates scores for each user from all past activity.

Important: Although the file is different, Scores uses Karma's database field and variables. Use this instead of Karma, not in addition to it.

Instructions:
1. Download the attached scores.php file and upload it to your /libs/ directory.
2. Generate scores by loading http://your_swcms_site.com/libs/scores.php in your browser.

Optional:
- Open scores.php file in a text editor and change the point values at the top.
- Automate the process by setting up a cron job on your server, or use a paid service like http://www.webbasedcron.com/

Small problems:
1. Since this uses Karma, all references to the scores will still be labeled "Karma" in your template. You'll need to change "Karma" to "Points" or "Score" in languages/lang.conf.
2. The database field for Karma uses data type decimal. That means your scores will have .00 on the end of them. If you can, change the data type to int with length 20 in the users table in the database.
Logged

I don't know, that's why I ask...
Nick
Administrator
Hero Member
*****
Offline Offline

Posts: 668



View Profile WWW
« Reply #27 on: December 17, 2008, 09:33:29 am »

I don't know about that Pligg stuff, but this should work:

1. Set up a sidebar box as explained here: http://forums.socialwebcms.com/index.php?topic=184.msg1666#msg1666
2. In the second part of the box, put this code:

Code:
{php}

$sql="SELECT user_login, user_karma from " . table_users . " order by user_karma desc limit 0,10";
$result = @mysql_query ($sql);
$rowCount = 0;
echo "<table style='border:0'><tr>\n";
echo "<td>&nbsp;</td><td style='color: #000; font-size: 10pt;'><b>User</b></td><td style='color: #000; font-size: 10pt;'><b>Points</b></td></tr>\n";
while($row = mysql_fetch_array($result, MYSQL_ASSOC))
{
$uname=$row['user_login'];
$ukarma=$row['user_karma'];
echo "<tr><td><a href='" . getmyurl('user2', $uname, 'profile') . "' title='View profile for " . $uname . "'><img src='". get_avatar('large', "", "$uname","","")."' class='align-middle' style='border:0px;' title='View profile for " . $uname . "'></a></td><td style='color: #000; font-size: 10pt;'>$uname</td><td style='color: #000; font-size: 10pt;'>$ukarma</td></tr>";
}
echo "</table>\n";
{/php}

Let us know if it works for you.
« Last Edit: February 13, 2009, 08:28:43 am by Nick » Logged

Reinventing SWCMS at HotaruCMS.org - testers, designers and developers wanted!
nothingman
Full Member
***
Offline Offline

Posts: 111


View Profile
« Reply #28 on: December 18, 2008, 02:23:38 am »

Thanks LCD, this works. I however prefer displaying the recently active users  say for the last 7 days (with a link to their blog/website as shown in that Karma2 implementation). This, I believe encourages newly registered members Smiley. There are so many users on my site who aren't active anymore but their nick shows up in the karma list.  Thanks anyways. Smiley
« Last Edit: December 18, 2008, 02:30:12 am by nothingman » Logged

I don't know, that's why I ask...
landshark
Newbie
*
Offline Offline

Posts: 36


View Profile
« Reply #29 on: December 18, 2008, 01:03:51 pm »

LCD, thank you for this i got it installed. I also wanted to be able to sort the Top Users by points so i found this http://forums.pligg.com/55906-post18.html and was able to get that working.

Future feature that would be nice would be able to get a monthly "Top User" and I see that nothingman is looking for weekly.

We are giving a prize for the top user as of the end of this month. Seeing that we just started the site this is easy to figure but future months might be difficult.

Anyway not a demand just a thought. Thanks for your hard work I am really impressed with the help and friendly atmosphere of the SWCMS community so far. Hopefully as time goes on i'll be able to contribute as much as I've been helped.
Logged
Pages: 1 [2] 3
  Print  
 
Jump to:  

Powered by MySQL Powered by PHP Powered by SMF 1.1.9 | SMF © 2006-2009, Simple Machines LLC Valid XHTML 1.0! Valid CSS!