added karma to collaboration ratings

This commit is contained in:
JT Smith 2005-05-04 03:04:39 +00:00
parent b631cbb2f4
commit 404830aa6c
6 changed files with 66 additions and 2 deletions

View file

@ -59,6 +59,9 @@
- Internationalized a bunch of stuff that was previously uninternationalized. - Internationalized a bunch of stuff that was previously uninternationalized.
- Fixed a bug in the survey that caused users to not be able to submit - Fixed a bug in the survey that caused users to not be able to submit
survey's. survey's.
- Attached the karma system to the ratings system in the Collaboration
system.
6.5.6 6.5.6
- Fixed a bunch of mostly cosmetic issues with the commerce system. - Fixed a bunch of mostly cosmetic issues with the commerce system.

View file

@ -76,4 +76,7 @@ alter table Collaboration add column richEditor varchar(22) not null default 'PB
delete from userProfileField where fieldName like 'richEditor%'; delete from userProfileField where fieldName like 'richEditor%';
delete from userProfileData where fieldName like 'richEditor%'; delete from userProfileData where fieldName like 'richEditor%';
alter table Layout add column assetsToHide text; alter table Layout add column assetsToHide text;
alter table Collaboration add column karmaRatingMultiplier int not null default 0;
alter table Collaboration add column karmaSpentToRate int not null default 0;

View file

@ -2415,7 +2415,6 @@ Adds a new Asset based upon the class of the current form. Returns the Asset cal
sub www_add { sub www_add {
my $self = shift; my $self = shift;
return WebGUI::Privilege::insufficient() unless ($self->canAdd);
my %prototypeProperties; my %prototypeProperties;
if ($session{form}{'prototype'}) { if ($session{form}{'prototype'}) {
my $prototype = WebGUI::Asset->newByDynamicClass($session{form}{'prototype'},$session{form}{class}); my $prototype = WebGUI::Asset->newByDynamicClass($session{form}{'prototype'},$session{form}{class});
@ -2443,6 +2442,7 @@ sub www_add {
$properties{isHidden} = 1 unless (WebGUI::Utility::isIn($session{form}{class}, @{$session{config}{assetContainers}})); $properties{isHidden} = 1 unless (WebGUI::Utility::isIn($session{form}{class}, @{$session{config}{assetContainers}}));
my $newAsset = WebGUI::Asset->newByDynamicClass("new",$session{form}{class},\%properties); my $newAsset = WebGUI::Asset->newByDynamicClass("new",$session{form}{class},\%properties);
$newAsset->{_parent} = $self; $newAsset->{_parent} = $self;
return WebGUI::Privilege::insufficient() unless ($newAsset->canAdd);
return $newAsset->www_edit(); return $newAsset->www_edit();
} }

View file

@ -461,6 +461,12 @@ sub rate {
where Post.threadId=".quote($self->getId)." and Post.rating>0"); where Post.threadId=".quote($self->getId)." and Post.rating>0");
my $average = round($sum/$count); my $average = round($sum/$count);
$self->update({rating=>$average}); $self->update({rating=>$average});
if ($session{setting}{useKarma}) {
my $poster = WebGUI::User->new($self->get("ownerUserId"));
$poster->karma($rating*$self->getParent->get("karmaRatingMultiplier"),"collaboration rating","someone rated post ".$self->getId);
my $rater = WebGUI::User->new($session{user}{userId});
$rater->karma(-$self->getParent->get("karmaSpentToRate"),"collaboration rating","spent karma to rate post ".$self->getId);
}
$self->getParent->recalculateRating; $self->getParent->recalculateRating;
} }
} }

View file

@ -377,6 +377,14 @@ sub definition {
fieldType=>"integer", fieldType=>"integer",
defaultValue=>0 defaultValue=>0
}, },
karmaSpentToRate => {
fieldType => "integer",
defaultValue=> 0
},
karmaRatingMultiplier => {
fieldType => "integer",
defaultValue=> 0
},
moderatePosts =>{ moderatePosts =>{
fieldType=>"yesNo", fieldType=>"yesNo",
defaultValue=>0 defaultValue=>0
@ -469,8 +477,29 @@ sub getEditForm {
-label=>WebGUI::International::get('karma/post', 'Asset_Collaboration'), -label=>WebGUI::International::get('karma/post', 'Asset_Collaboration'),
-value=>$self->getValue("karmaPerPost") -value=>$self->getValue("karmaPerPost")
); );
$tabform->getTab("properties")->integer(
-name=>"karmaSpentToRate",
-label=>WebGUI::International::get('karma spent to rate', 'Asset_Collaboration'),
-value=>$self->getValue("karmaSpentToRate")
);
$tabform->getTab("properties")->integer(
-name=>"karmaRatingMultiplier",
-label=>WebGUI::International::get('karma rating multiplier', 'Asset_Collaboration'),
-value=>$self->getValue("karmaRatingMultiplier")
);
} else { } else {
$tabform->getTab("properties")->hidden("karmaPerPost",$self->getValue("karmaPerPost")); $tabform->getTab("properties")->hidden(
-name=>"karmaPerPost",
-value=>$self->getValue("karmaPerPost")
);
$tabform->getTab("properties")->hidden(
-name=>"karmaSpentToRate",
-value=>$self->getValue("karmaSpentToRate")
);
$tabform->getTab("properties")->hidden(
-name=>"karmaRatingMultiplier",
-value=>$self->getValue("karmaRatingMultiplier")
);
} }
$tabform->getTab("security")->filterContent( $tabform->getTab("security")->filterContent(
-value=>$self->getValue("filterCode"), -value=>$self->getValue("filterCode"),

View file

@ -1,6 +1,21 @@
package WebGUI::i18n::English::Asset_Collaboration; package WebGUI::i18n::English::Asset_Collaboration;
our $I18N = { our $I18N = {
'preview' => {
message => q|preview|,
lastUpdated => 0,
},
'karma spent to rate' => {
message => q|Karma Spent To Rate|,
lastUpdated => 0,
},
'karma rating multiplier' => {
message => q|Karma Rating Multiplier|,
lastUpdated => 0,
},
'delete file warning' => { 'delete file warning' => {
message => q|Are you sure you wish to delete this file?|, message => q|Are you sure you wish to delete this file?|,
lastUpdated => 1109618544, lastUpdated => 1109618544,
@ -849,6 +864,14 @@ Setting this number very high can slow the generation of the page.
If Karma is enabled on your site, the amount of Karma added for each Post If Karma is enabled on your site, the amount of Karma added for each Post
submitted by a user. submitted by a user.
<p>
<b>^International("karma spent to rate","Asset_Collaboration");</b><br />
If karma is enabled on your site, this amount will be subtracted from the user rating a post as sort of a cost of rating posts. It is meant to keep users in check from just rating everything without thinking about the rating.
<p>
<b>^International("karma rating multiplier","Asset_Collaboration");</b><br />
If karma is enabled on your site, this amount multiplied by the rating the user gives a post will be the amount of karma the original author of the post receives.
<p> <p>
<b>^International("filter code","Asset_Collaboration");</b><br> <b>^International("filter code","Asset_Collaboration");</b><br>
Sets the level of HTML filtering done on each Post. Sets the level of HTML filtering done on each Post.