diff --git a/docs/changelog/6.x.x.txt b/docs/changelog/6.x.x.txt index d9b11f776..d2fdcfe02 100644 --- a/docs/changelog/6.x.x.txt +++ b/docs/changelog/6.x.x.txt @@ -59,6 +59,9 @@ - Internationalized a bunch of stuff that was previously uninternationalized. - Fixed a bug in the survey that caused users to not be able to submit survey's. + - Attached the karma system to the ratings system in the Collaboration + system. + 6.5.6 - Fixed a bunch of mostly cosmetic issues with the commerce system. diff --git a/docs/upgrades/upgrade_6.5.6-6.6.0.sql b/docs/upgrades/upgrade_6.5.6-6.6.0.sql index c1d9822b7..a2088fe93 100644 --- a/docs/upgrades/upgrade_6.5.6-6.6.0.sql +++ b/docs/upgrades/upgrade_6.5.6-6.6.0.sql @@ -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 userProfileData where fieldName like 'richEditor%'; 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; + diff --git a/lib/WebGUI/Asset.pm b/lib/WebGUI/Asset.pm index d3611f2b0..dab012312 100644 --- a/lib/WebGUI/Asset.pm +++ b/lib/WebGUI/Asset.pm @@ -2415,7 +2415,6 @@ Adds a new Asset based upon the class of the current form. Returns the Asset cal sub www_add { my $self = shift; - return WebGUI::Privilege::insufficient() unless ($self->canAdd); my %prototypeProperties; if ($session{form}{'prototype'}) { 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}})); my $newAsset = WebGUI::Asset->newByDynamicClass("new",$session{form}{class},\%properties); $newAsset->{_parent} = $self; + return WebGUI::Privilege::insufficient() unless ($newAsset->canAdd); return $newAsset->www_edit(); } diff --git a/lib/WebGUI/Asset/Post/Thread.pm b/lib/WebGUI/Asset/Post/Thread.pm index 809156341..80ae7e1fa 100644 --- a/lib/WebGUI/Asset/Post/Thread.pm +++ b/lib/WebGUI/Asset/Post/Thread.pm @@ -461,6 +461,12 @@ sub rate { where Post.threadId=".quote($self->getId)." and Post.rating>0"); my $average = round($sum/$count); $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; } } diff --git a/lib/WebGUI/Asset/Wobject/Collaboration.pm b/lib/WebGUI/Asset/Wobject/Collaboration.pm index aff558e2a..d9be16040 100644 --- a/lib/WebGUI/Asset/Wobject/Collaboration.pm +++ b/lib/WebGUI/Asset/Wobject/Collaboration.pm @@ -377,6 +377,14 @@ sub definition { fieldType=>"integer", defaultValue=>0 }, + karmaSpentToRate => { + fieldType => "integer", + defaultValue=> 0 + }, + karmaRatingMultiplier => { + fieldType => "integer", + defaultValue=> 0 + }, moderatePosts =>{ fieldType=>"yesNo", defaultValue=>0 @@ -469,8 +477,29 @@ sub getEditForm { -label=>WebGUI::International::get('karma/post', 'Asset_Collaboration'), -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 { - $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( -value=>$self->getValue("filterCode"), diff --git a/lib/WebGUI/i18n/English/Asset_Collaboration.pm b/lib/WebGUI/i18n/English/Asset_Collaboration.pm index 8147d3111..05ed33b74 100644 --- a/lib/WebGUI/i18n/English/Asset_Collaboration.pm +++ b/lib/WebGUI/i18n/English/Asset_Collaboration.pm @@ -1,6 +1,21 @@ package WebGUI::i18n::English::Asset_Collaboration; 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' => { message => q|Are you sure you wish to delete this file?|, 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 submitted by a user. +

+^International("karma spent to rate","Asset_Collaboration");
+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. + +

+^International("karma rating multiplier","Asset_Collaboration");
+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. +

^International("filter code","Asset_Collaboration");
Sets the level of HTML filtering done on each Post.