added manual thread archive/unarchive options

This commit is contained in:
JT Smith 2006-02-26 20:31:46 +00:00
parent 357794959a
commit 5fe11ed251
6 changed files with 137 additions and 11 deletions

View file

@ -1,4 +1,5 @@
6.99.0
- Added archive/unarchive options to CS threads.
- Added a workflow system.
- Added a workflow scheduler system.
- Converted the runHourly.pl scripts to run as scheduled workflows.

View file

@ -126,7 +126,7 @@ sub addWorkflow {
}, "pbcron0000000000000001");
$session->config->set("workflowActivities", {
none=>["WebGUI::Workflow::Activity::DecayKarma", "WebGUI::Workflow::Activity::TrashClipboard", "WebGUI::Workflow::Activity::CleanTempStorage",
"WebGUI::Workflow::Activity::CleanFileCache", "WebGUI::Workflow::Activity::CleanLoginHistory"],
"WebGUI::Workflow::Activity::CleanFileCache", "WebGUI::Workflow::Activity::CleanLoginHistory", "WebGUI::Workflow::Activity::ArchiveOldThreads"],
user=>[],
versiontag=>["WebGUI::Workflow::Activity::CommitVersionTag", "WebGUI::Workflow::Activity::RollbackVersionTag"]
});
@ -142,8 +142,8 @@ sub addWorkflow {
$activity = $workflow->addActivity("WebGUI::Workflow::Activity::TrashClipboard", "pbwfactivity0000000004");
$activity->set("title", "Move clipboard items older than 30 days to trash");
$activity->set("trashAfter", 60*60*24*30);
$activity = $workflow->addActivity("WebGUI::Workflow::Activity::ArchiveOldPosts", "pbwfactivity0000000005");
$activity->set("title", "Archive old CS posts");
$activity = $workflow->addActivity("WebGUI::Workflow::Activity::ArchiveOldThreads", "pbwfactivity0000000005");
$activity->set("title", "Archive old CS threads");
WebGUI::Workflow::Cron->create($session, {
title=>'Weekly Maintenance Maintenance',
enabled=>1,

View file

@ -689,6 +689,7 @@ sub processPropertiesFromFormPost {
$self->getThread->lock if ($self->session->form->process('lock'));
$self->getThread->stick if ($self->session->form->process("stick"));
}
$self->getThread->unarchive if ($self->getThread->get("status") eq "archived");
}
$data{groupIdView} =$self->getThread->getParent->get("groupIdView");
$data{groupIdEdit} = $self->getThread->getParent->get("groupIdEdit");
@ -828,14 +829,14 @@ sub setStatusApproved {
=head2 setStatusArchived ( )
Sets the status of this post to archived.
Sets the status of this post to archived. This will only happen if the post status is approved.
=cut
sub setStatusArchived {
my ($self) = @_;
$self->update({status=>'archived'});
$self->update({status=>'archived'}) if ($self->get("status") eq "approved");
}
@ -873,6 +874,20 @@ sub setStatusPending {
}
#-------------------------------------------------------------------
=head2 setStatusUnarchived ( )
Sets the status of this post to approved, but does so without any of the normal notifications and other stuff.
=cut
sub setStatusUnarchived {
my ($self) = @_;
$self->update({status=>'approved'}) if ($self->get("status") eq "archived");
}
#-------------------------------------------------------------------
=head2 trash

View file

@ -22,6 +22,13 @@ use WebGUI::Utility;
our @ISA = qw(WebGUI::Asset::Post);
#-------------------------------------------------------------------
sub archive {
my $self = shift;
foreach my $post (@{$self->getPosts}) {
$post->setStatusArchived;
}
}
#-------------------------------------------------------------------
sub canReply {
@ -121,6 +128,19 @@ sub DESTROY {
#-------------------------------------------------------------------
=head2 getArchiveUrl ( )
Formats the url to set the status of a thread archived.
=cut
sub getArchiveUrl {
my $self = shift;
$self->getUrl("func=archive");
}
#-------------------------------------------------------------------
sub getLastPost {
my $self = shift;
@ -204,6 +224,19 @@ sub getNextThread {
#-------------------------------------------------------------------
=head2 getPosts ( )
Returns a list of the post objects in this thread, including the thread post itself.
=cut
sub getPosts {
my $self = shift;
$self->getLineage(["self","descendants"], {returnObjects=>1});
}
#-------------------------------------------------------------------
=head2 getPreviousThread ( )
@ -274,6 +307,19 @@ sub getThread {
#-------------------------------------------------------------------
=head2 getUnarchiveUrl ( )
Formats the url to set the status of a thread unarchived.
=cut
sub getUnarchiveUrl {
my $self = shift;
$self->getUrl("func=unarchive");
}
#-------------------------------------------------------------------
=head2 getUnlockUrl ( )
Formats the url to unlock the thread
@ -590,6 +636,21 @@ sub trash {
}
#-------------------------------------------------------------------
=head2 unarchive ( )
Unarchives this thread.
=cut
sub unarchive {
my $self = shift;
foreach my $post (@{$self->getPosts}) {
$post->setStatusUnarchived;
}
}
#-------------------------------------------------------------------
=head2 unlock ( )
@ -657,6 +718,10 @@ sub view {
$var->{'subscribe.url'} = $self->getSubscribeUrl;
$var->{'unsubscribe.url'} = $self->getUnsubscribeUrl;
$var->{'isArchived'} = $self->get("status") eq "archived";
$var->{'archive.url'} = $self->getArchivedUrl;
$var->{'unarchive.url'} = $self->getUnarchivedUrl;
$var->{'isSticky'} = $self->isSticky;
$var->{'stick.url'} = $self->getStickUrl;
$var->{'unstick.url'} = $self->getUnstickUrl;
@ -720,6 +785,20 @@ sub view {
}
#-------------------------------------------------------------------
=head2 www_archive ( )
The web method to archive all the posts in this thread.
=cut
sub www_archive {
my $self = shift;
$self->archive if ($self->canEdit);
return $self->www_view;
}
#-------------------------------------------------------------------
=head2 www_lock ( )
@ -764,6 +843,20 @@ sub www_subscribe {
#-------------------------------------------------------------------
=head2 www_unarchive ( )
The web method to unarchive all the posts in this thread.
=cut
sub www_unarchive {
my $self = shift;
$self->unarchive if ($self->canEdit);
return $self->www_view;
}
#-------------------------------------------------------------------
=head2 www_unlock ( )
The web method to unlock a thread.

View file

@ -1,4 +1,4 @@
package WebGUI::Workflow::Activity::ArchiveOldPosts;
package WebGUI::Workflow::Activity::ArchiveOldThreads;
=head1 LEGAL
@ -17,6 +17,7 @@ package WebGUI::Workflow::Activity::ArchiveOldPosts;
use strict;
use base 'WebGUI::Workflow::Activity';
use WebGUI::Asset;
=head1 NAME
@ -71,16 +72,20 @@ sub execute {
my $epoch = $self->session->datetime->time();
my $a = $self->session->db->read("select assetId from asset where className='WebGUI::Asset::Wobject::Collaboration'");
while (my ($assetId) = $a->array) {
my $cs = WebGUI::Asset::Wobject::Collaboration->new($assetId);
my $cs = WebGUI::Asset->new($assetId, "WebGUI::Asset::Wobject::Collaboration");
my $archiveDate = $epoch - $cs->get("archiveAfter");
my $sql = "select asset.assetId, assetData.revisionDate from Post left join asset on asset.assetId=Post.assetId
left join assetData on Post.assetId=assetData.assetId and Post.revisionDate=assetData.revisionDate
where Post.dateUpdated<? and assetData.status='approved' and asset.state='published'
and asset.lineage like ?";
and Post.threadId=Post.assetId and asset.lineage like ?";
my $b = $self->session->db->read($sql,[$archiveDate, $cs->get("lineage").'%']);
while (my ($id, $version) = $b->array) {
my $post = WebGUI::Asset::Post->new($id,undef,$version);
$post->setStatusArchived if (defined $post && $post->get("dateUpdated") < $archiveDate);
my $thread = WebGUI::Asset->new($id, "WebGUI::Asset::Post::Thread", $version);
my $archiveIt = 1;
foreach my $post (@{$thread->getPosts}) {
$archiveIt = 0 if (defined $post && $post->get("dateUpdated") > $archiveDate);
}
$thread->archive if ($archiveIt);
}
$b->finish;
}

View file

@ -73,6 +73,18 @@ A URL to subscribe the current user to the thread.
A URL to subscribe the current user from the thread.
<p>
<b>isArchived</b><br>
A conditional indicating if the current thread is archived.
<p>
<b>archive.url</b><br>
The URL to archive this thread.
<p>
<b>unarchive.url</b><br>
The URL to unarchive this thread.
<p>
<b>isSticky</b><br>
A conditional indicating if the current thread is sticky.
<p>
@ -163,7 +175,7 @@ The description of the collaboration system that this post is a part of.
<p>
|,
lastUpdated => 1111768115,
lastUpdated => 1140982574,
},
'assetName' => {