From 404749e32b12f170ada9f255c469b21b0655b98e Mon Sep 17 00:00:00 2001 From: JT Smith Date: Sat, 15 Apr 2006 15:36:02 +0000 Subject: [PATCH] updated thread templates to remove approve/deny links and add archive/unarchive links fixed unarchive bug changed post rating system to thumbs up/down --- docs/changelog/6.x.x.txt | 2 ++ .../wgtemplate_default_submission.tmpl | 18 +++++------------- .../wgtemplate_default_thread.tmpl | 10 +++------- .../templates-6.99.0/wgtemplate_job.tmpl | 16 ++++------------ .../templates-6.99.0/wgtemplate_link.tmpl | 14 +++----------- docs/upgrades/upgrade_6.8.8-6.99.0.pl | 3 +++ lib/WebGUI/Asset/Post.pm | 15 +++++---------- lib/WebGUI/Asset/Post/Thread.pm | 11 ++++++----- lib/WebGUI/Asset/Wobject/Collaboration.pm | 2 ++ lib/WebGUI/AssetLineage.pm | 9 +++++++-- lib/WebGUI/i18n/English/Asset_Collaboration.pm | 12 ++++++++++++ lib/WebGUI/i18n/English/Asset_Post.pm | 10 +++++++--- lib/WebGUI/i18n/English/Asset_Thread.pm | 10 +++++++++- 13 files changed, 68 insertions(+), 64 deletions(-) diff --git a/docs/changelog/6.x.x.txt b/docs/changelog/6.x.x.txt index 9262a79d3..c8f9bc9cd 100644 --- a/docs/changelog/6.x.x.txt +++ b/docs/changelog/6.x.x.txt @@ -30,6 +30,8 @@ - Added archive/unarchive options to CS threads. - Added a mechanism to send emails to a CS which will accept them as posts. - Increased the performance of CS Thread viewing by 500%. + - Changed the CS post rating mechinism to thumbs up/down to be less + confusing. - Added install/uninstall functions to the asset and wobject skeletons to make custom assets easier to distribute. - Added a mechanism for importing and exporting packages. This is useful for diff --git a/docs/upgrades/templates-6.99.0/wgtemplate_default_submission.tmpl b/docs/upgrades/templates-6.99.0/wgtemplate_default_submission.tmpl index fcec085df..97fd6cf9e 100644 --- a/docs/upgrades/templates-6.99.0/wgtemplate_default_submission.tmpl +++ b/docs/upgrades/templates-6.99.0/wgtemplate_default_submission.tmpl @@ -19,11 +19,11 @@ :
: -     [ 1, 2, 3, 4, 5 ] +     [

+

|

-

]

- :     [ | ]
+ :     [ ]
:
@@ -117,16 +117,12 @@ :
: -     [ 1, 2, 3, 4, 5 ] +     [

+

|

-

]

- - :     [ | ]
- :
-
@@ -180,16 +176,12 @@ :
: -     [ 1, 2, 3, 4, 5 ] +     [

+

|

-

]

- - :     [ | ]
- :
-
@@ -360,4 +352,4 @@ { height:auto; min-height:100px; -} \ No newline at end of file +} diff --git a/docs/upgrades/templates-6.99.0/wgtemplate_default_thread.tmpl b/docs/upgrades/templates-6.99.0/wgtemplate_default_thread.tmpl index e7e4c44e5..3c548d599 100755 --- a/docs/upgrades/templates-6.99.0/wgtemplate_default_thread.tmpl +++ b/docs/upgrades/templates-6.99.0/wgtemplate_default_thread.tmpl @@ -41,11 +41,11 @@ :
: -     [ 1, 2, 3, 4, 5 ] +     [

+

|

-

]

- :     [ | ]
+ :     [ ]
:
@@ -101,16 +101,12 @@ :
: -     [ 1, 2, 3, 4, 5 ] +     [

+

|

-

]

- - :     [ | ]
- :
-
diff --git a/docs/upgrades/templates-6.99.0/wgtemplate_job.tmpl b/docs/upgrades/templates-6.99.0/wgtemplate_job.tmpl index 2f5427cd4..225835575 100644 --- a/docs/upgrades/templates-6.99.0/wgtemplate_job.tmpl +++ b/docs/upgrades/templates-6.99.0/wgtemplate_job.tmpl @@ -9,7 +9,7 @@
- :     [ | ]
+ :     [ ]
@@ -105,16 +105,12 @@ :
: -     [ 1, 2, 3, 4, 5 ] +     [

+

|

-

]

- - :     [ | ]
- :
-
@@ -168,16 +164,12 @@ :
: -     [ 1, 2, 3, 4, 5 ] +     [

+

|

-

]

- - :     [ | ]
- :
-
@@ -328,4 +320,4 @@ border:solid #DADADA 1px; font-family:arial; font-size:9pt; -} \ No newline at end of file +} diff --git a/docs/upgrades/templates-6.99.0/wgtemplate_link.tmpl b/docs/upgrades/templates-6.99.0/wgtemplate_link.tmpl index 1a8da7287..91847c16d 100644 --- a/docs/upgrades/templates-6.99.0/wgtemplate_link.tmpl +++ b/docs/upgrades/templates-6.99.0/wgtemplate_link.tmpl @@ -9,7 +9,7 @@
- :     [ | ]
+ :     [ ]
@@ -88,16 +88,12 @@ :
: -     [ 1, 2, 3, 4, 5 ] +     [

+

|

-

]

- - :     [ | ]
- :
-
@@ -149,16 +145,12 @@ :
: -     [ 1, 2, 3, 4, 5 ] +     [

+

|

-

]

- - :     [ | ]
- :
-
diff --git a/docs/upgrades/upgrade_6.8.8-6.99.0.pl b/docs/upgrades/upgrade_6.8.8-6.99.0.pl index 4523c5792..36fc27c12 100644 --- a/docs/upgrades/upgrade_6.8.8-6.99.0.pl +++ b/docs/upgrades/upgrade_6.8.8-6.99.0.pl @@ -238,6 +238,9 @@ sub updateCs { }, "csworkflow000000000001"); my $activity = $workflow->addActivity("WebGUI::Workflow::Activity::GetCsMail","csactivity000000000001"); $activity->set("title","Get the mail"); + print "\t\tDeleteing old ratings due to new rating system.\n"; + $session->db->write("delete from Post_rating"); + $session->db->write("update Post set rating=0"); } #------------------------------------------------- diff --git a/lib/WebGUI/Asset/Post.pm b/lib/WebGUI/Asset/Post.pm index 30aa54109..5d2eeb8b7 100644 --- a/lib/WebGUI/Asset/Post.pm +++ b/lib/WebGUI/Asset/Post.pm @@ -447,11 +447,8 @@ sub getTemplateVars { $var{'reply.withquote.url'} = $self->getReplyUrl(1); $var{'url'} = $self->getUrl.'#id'.$self->getId; $var{'rating.value'} = $self->get("rating")+0; - $var{'rate.url.1'} = $self->getRateUrl(1); - $var{'rate.url.2'} = $self->getRateUrl(2); - $var{'rate.url.3'} = $self->getRateUrl(3); - $var{'rate.url.4'} = $self->getRateUrl(4); - $var{'rate.url.5'} = $self->getRateUrl(5); + $var{'rate.url.thumbsUp'} = $self->getRateUrl(1); + $var{'rate.url.thumbsDown'} = $self->getRateUrl(-1); $var{'hasRated'} = $self->hasRated; my $gotImage; my $gotAttachment; @@ -773,16 +770,14 @@ An integer between 1 and 5 (5 being best) to rate this post with. sub rate { my $self = shift; - my $rating = shift || 3; + my $rating = shift; + return undef unless ($rating == -1 || $rating == 1); unless ($self->hasRated) { $self->session->db->write("insert into Post_rating (assetId,userId,ipAddress,dateOfRating,rating) values (" .$self->session->db->quote($self->getId).", ".$self->session->db->quote($self->session->user->userId).", ".$self->session->db->quote($self->session->env->get("REMOTE_ADDR")).", ".$self->session->datetime->time().", ".$self->session->db->quote($rating).")"); - my ($count) = $self->session->db->quickArray("select count(*) from Post_rating where assetId=".$self->session->db->quote($self->getId)); - $count = $count || 1; my ($sum) = $self->session->db->quickArray("select sum(rating) from Post_rating where assetId=".$self->session->db->quote($self->getId)); - my $average = WebGUI::Utility::round($sum/$count); - $self->update({rating=>$average}); + $self->update({rating=>$sum}); $self->getThread->rate($rating); } } diff --git a/lib/WebGUI/Asset/Post/Thread.pm b/lib/WebGUI/Asset/Post/Thread.pm index 089327dfc..bfcc4d866 100644 --- a/lib/WebGUI/Asset/Post/Thread.pm +++ b/lib/WebGUI/Asset/Post/Thread.pm @@ -249,7 +249,7 @@ Returns a list of the post objects in this thread, including the thread post its sub getPosts { my $self = shift; - $self->getLineage(["self","descendants"], {returnObjects=>1}); + $self->getLineage(["self","descendants"], {returnObjects=>1, includeArchived=>1}); } #------------------------------------------------------------------- @@ -548,15 +548,13 @@ An integer between 1 and 5 (5 being best) to rate this post with. sub rate { my $self = shift; my $rating = shift; + return undef unless ($rating == -1 || $rating == 1); unless ($self->hasRated) { $self->session->db->write("insert into Post_rating (assetId,userId,ipAddress,dateOfRating,rating) values (" .$self->session->db->quote($self->getId).", ".$self->session->db->quote($self->session->user->userId).", ".$self->session->db->quote($self->session->env->get("REMOTE_ADDR")).", ".$self->session->datetime->time().", ".$self->session->db->quote($rating).")"); - my ($count) = $self->session->db->quickArray("select count(*) from Post left join asset on Post.assetId=asset.assetId where Post.threadId=".$self->session->db->quote($self->getId)." and Post.rating>0"); - $count = $count || 1; my ($sum) = $self->session->db->quickArray("select sum(Post.rating) from Post left join asset on Post.assetId=asset.assetId where Post.threadId=".$self->session->db->quote($self->getId)." and Post.rating>0"); - my $average = round($sum/$count); - $self->update({rating=>$average}); + $self->update({rating=>$sum}); if ($self->session->setting->get("useKarma")) { my $poster = WebGUI::User->new($self->session, $self->get("ownerUserId")); $poster->karma($rating*$self->getParent->get("karmaRatingMultiplier"),"collaboration rating","someone rated post ".$self->getId); @@ -761,6 +759,9 @@ sub view { $var->{'subscribe.url'} = $self->getSubscribeUrl; $var->{'unsubscribe.url'} = $self->getUnsubscribeUrl; + $var->{'thumbsUp.icon.url'} = $self->session->config->get("extrasURL").'/thumbup.gif'; + $var->{'thumbsDown.icon.url'} = $self->session->config->get("extrasURL").'/thumbdown.gif'; + $var->{'isArchived'} = $self->get("status") eq "archived"; $var->{'archive.url'} = $self->getArchiveUrl; $var->{'unarchive.url'} = $self->getUnarchiveUrl; diff --git a/lib/WebGUI/Asset/Wobject/Collaboration.pm b/lib/WebGUI/Asset/Wobject/Collaboration.pm index 09e66da31..4f8c5efc6 100644 --- a/lib/WebGUI/Asset/Wobject/Collaboration.pm +++ b/lib/WebGUI/Asset/Wobject/Collaboration.pm @@ -110,6 +110,8 @@ sub appendTemplateLabels { $var->{"addquestion.label"} = $i18n->get("addquestion"); $var->{'answer.label'} = $i18n->get("answer"); $var->{'attachment.label'} = $i18n->get("attachment"); + $var->{'archive.label'} = $i18n->get("archive"); + $var->{'unarchive.label'} = $i18n->get("unarchive"); $var->{"by.label"} = $i18n->get("by"); $var->{'body.label'} = $i18n->get("body"); $var->{"back.label"} = $i18n->get("back"); diff --git a/lib/WebGUI/AssetLineage.pm b/lib/WebGUI/AssetLineage.pm index e9ac4af60..e0c812205 100644 --- a/lib/WebGUI/AssetLineage.pm +++ b/lib/WebGUI/AssetLineage.pm @@ -249,6 +249,10 @@ A boolean indicating whether the resulting asset tree should be returned in reve An array reference containing a list of asset classes to include in the result. If this is specified then no other classes except these will be returned. The opposite of the excludeClasses rule. +=head4 includeArchived + +A boolean indicating that we should include archived assets in the result set. + =head4 joinClass An array reference containing asset classes to join in. There is no real reason to use a joinClass without a whereClause, but it's trivial to use a whereClause if you don't use a joinClass. You will only be able to filter on the asset table, however. @@ -340,7 +344,8 @@ sub getLineage { $where = "asset.state='published'"; } ## get only approved items or those that i'm currently working on - $where .= " and (assetData.status='approved' or assetData.tagId=".$self->session->db->quote($self->session->scratch->get("versionTag")).")"; + my $archived = " or assetData.status='archived' " if ($rules->{includeArchived}); + $where .= " and (assetData.status='approved' $archived or assetData.tagId=".$self->session->db->quote($self->session->scratch->get("versionTag")).")"; ## class exclusions if (exists $rules->{excludeClasses}) { my @set; @@ -360,7 +365,7 @@ sub getLineage { } # based upon all available criteria, let's get some assets my $columns = "asset.assetId, asset.className, asset.parentId, assetData.revisionDate"; - $where .= " and assetData.revisionDate=(SELECT max(revisionDate) from assetData where assetData.assetId=asset.assetId and (assetData.status='approved' or assetData.tagId=".$self->session->db->quote($self->session->scratch->get("versionTag")).")) "; + $where .= " and assetData.revisionDate=(SELECT max(revisionDate) from assetData where assetData.assetId=asset.assetId and (assetData.status='approved' $archived or assetData.tagId=".$self->session->db->quote($self->session->scratch->get("versionTag")).")) "; my $sortOrder = ($rules->{invertTree}) ? "asset.lineage desc" : "asset.lineage asc"; if (exists $rules->{orderByClause}) { $sortOrder = $rules->{orderByClause}; diff --git a/lib/WebGUI/i18n/English/Asset_Collaboration.pm b/lib/WebGUI/i18n/English/Asset_Collaboration.pm index bcb414d0a..caf94916b 100644 --- a/lib/WebGUI/i18n/English/Asset_Collaboration.pm +++ b/lib/WebGUI/i18n/English/Asset_Collaboration.pm @@ -2,6 +2,18 @@ package WebGUI::i18n::English::Asset_Collaboration; our $I18N = { + 'archive' => { + message => q|Archive|, + lastUpdated => 0, + context => q|thread link| + }, + + 'unarchive' => { + message => q|Unarchive|, + lastUpdated => 0, + context => q|thread link| + }, + 'mail prefix' => { message => q|Prefix|, lastUpdated => 0, diff --git a/lib/WebGUI/i18n/English/Asset_Post.pm b/lib/WebGUI/i18n/English/Asset_Post.pm index d71c0768f..be4709d3c 100644 --- a/lib/WebGUI/i18n/English/Asset_Post.pm +++ b/lib/WebGUI/i18n/English/Asset_Post.pm @@ -216,8 +216,12 @@ The URL for this Post. The current rating for this Post.

-rate.url.N
-URLs that are used to rate this post. N goes from 1 to 5. +rate.url.thumbsUp
+A positive rating. +

+ +rate.url.thumbsDown
+A negative rating.

hasRated
@@ -388,7 +392,7 @@ back the data with a simple <tmpl_var userDefined1>.

|, - lastUpdated => 1134670360, + lastUpdated => 1145111051, }, 'post received' => { diff --git a/lib/WebGUI/i18n/English/Asset_Thread.pm b/lib/WebGUI/i18n/English/Asset_Thread.pm index 2c2404158..d906ae75c 100644 --- a/lib/WebGUI/i18n/English/Asset_Thread.pm +++ b/lib/WebGUI/i18n/English/Asset_Thread.pm @@ -27,6 +27,14 @@ A weighting factor for difficulty, complexity, or handicap in contests. This is karma divided by karma scale.

+thumbsUp.icon.url
+The URL to the thumbs up icon. +

+ +thumbsDown.icon.url
+The URL to the thumbs down icon. +

+ user.isVisitor
A conditional indicating that the current user is a Visitor.

@@ -191,7 +199,7 @@ The description of the collaboration system that this post is a part of.

|, - lastUpdated => 1141142205, + lastUpdated => 1145111313, }, 'assetName' => {