--- /dev/null
+package Newslash::Model::Moderations;
+use Newslash::Model::Base -base;
+
+# parameters
+
+my $karma_posting_penalty_style = 0;
+my $badkarma = -10;
+my $goodkarma = 25;
+my $comment_minscore = -1;
+my $comment_maxscore = 5;
+
+
+#========================================================================
+
+=head2 score_for_comment_post(\%user)
+
+calculate score for comment post
+
+=over 4
+
+=item Parameters
+
+=over 4
+
+=item \%user
+
+user
+
+=back
+
+=item Return value
+
+HASH of scores
+
+=back
+
+=cut
+
+sub score_for_comment_post {
+ my ($self, $user) = @_;
+
+ my $users = $self->new_instance_of("Newslash::Model::Users");
+ my $user_comment = $users->select(uid => $user->{uid}, 'comments');
+ my $user_info = $users->select(uid => $user->{uid}, 'info');
+
+ my $pts = $user_comment->{defaultpoints};
+ my $karma_bonus = 'no';
+ my $tweak = 0;
+
+
+ if ($user->{login}) {
+ my $karma = $user_info->{karma};
+ if ($karma_posting_penalty_style == 0) {
+ $pts-- if $karam < 0;
+ $pts-- if $karma < $badkarma;
+ }
+ else {
+ $tweak-- if $karma < 0;
+ $tweak-- if $karma < $badkarma;
+ }
+
+ # check if point is valid range
+ if ($pts < $comment_minscore) {
+ $pts = $comment_minscore;
+ }
+ elsif ($pts > $comment_maxscore) {
+ $pts = $comment_maxscore;
+ }
+
+ if ($pts >= 1 && $karma > $goodkarma) {
+ $karma_bonus = 'yes';
+ }
+ }
+
+ return {points => $pts, karma_bonus => $karma_bonus, tweak => $tweak};
+}
+
+1;