removed start/end dates from assets in favor of workflows that can do the same thing only better
This commit is contained in:
parent
8b6198220d
commit
103969816e
25 changed files with 316 additions and 251 deletions
|
|
@ -1,4 +1,5 @@
|
|||
6.99.0
|
||||
- Removed start/end dates from assets in favor of the workflow system.
|
||||
- Readded the purge option to the trash manager.
|
||||
- Added archive/unarchive options to CS threads.
|
||||
- Added a database cache option as an alternative to memcached.
|
||||
|
|
|
|||
|
|
@ -109,7 +109,7 @@ sub addWorkflow {
|
|||
description text,
|
||||
enabled int not null default 0,
|
||||
isSerial int not null default 0,
|
||||
type varchar(255) not null default 'none'
|
||||
type varchar(255) not null default 'None'
|
||||
)");
|
||||
$session->db->write("create table WorkflowActivity (
|
||||
activityId varchar(22) binary not null primary key,
|
||||
|
|
@ -129,7 +129,7 @@ sub addWorkflow {
|
|||
title=>"Daily Maintenance Tasks",
|
||||
description=>"This workflow runs daily maintenance tasks such as cleaning up old temporary files and cache.",
|
||||
enabled=>1,
|
||||
type=>"none"
|
||||
type=>"None"
|
||||
}, "pbworkflow000000000001");
|
||||
my $activity = $workflow->addActivity("WebGUI::Workflow::Activity::CleanTempStorage", "pbwfactivity0000000001");
|
||||
$activity->set("title","Delete temp files older than 24 hours");
|
||||
|
|
@ -147,16 +147,19 @@ sub addWorkflow {
|
|||
workflowId=>$workflow->getId
|
||||
}, "pbcron0000000000000001");
|
||||
$session->config->set("workflowActivities", {
|
||||
none=>["WebGUI::Workflow::Activity::DecayKarma", "WebGUI::Workflow::Activity::TrashClipboard", "WebGUI::Workflow::Activity::CleanTempStorage",
|
||||
None=>["WebGUI::Workflow::Activity::DecayKarma", "WebGUI::Workflow::Activity::TrashClipboard", "WebGUI::Workflow::Activity::CleanTempStorage",
|
||||
"WebGUI::Workflow::Activity::CleanFileCache", "WebGUI::Workflow::Activity::CleanLoginHistory", "WebGUI::Workflow::Activity::ArchiveOldThreads"],
|
||||
user=>[],
|
||||
versiontag=>["WebGUI::Workflow::Activity::CommitVersionTag", "WebGUI::Workflow::Activity::RollbackVersionTag"]
|
||||
User=>[],
|
||||
VersionTag=>["WebGUI::Workflow::Activity::CommitVersionTag", "WebGUI::Workflow::Activity::RollbackVersionTag",
|
||||
"WebGUI::Workflow::Activity::TrashVersionTag"]
|
||||
});
|
||||
$session->db->write("alter table assetData drop column startDate");
|
||||
$session->db->write("alter table assetData drop column endDate");
|
||||
$workflow = WebGUI::Workflow->create($session, {
|
||||
title=>"Weekly Maintenance Tasks",
|
||||
description=>"This workflow runs once per week to perform maintenance tasks like cleaning up log files.",
|
||||
enabled=>1,
|
||||
type=>"none"
|
||||
type=>"None"
|
||||
}, "pbworkflow000000000002");
|
||||
$activity = $workflow->addActivity("WebGUI::Workflow::Activity::CleanLoginHistory", "pbwfactivity0000000003");
|
||||
$activity->set("title", "Delete login entries older than 90 days");
|
||||
|
|
@ -183,6 +186,14 @@ sub addWorkflow {
|
|||
$session->config->delete("DecayKarma_minimumKarma");
|
||||
$session->config->delete("DecayKarma_decayFactor");
|
||||
$session->config->delete("DeleteExpiredClipboard_offset");
|
||||
$workflow = WebGUI::Workflow->create($session, {
|
||||
title=>"Commit Without Approval",
|
||||
description=>"This workflow commits all the assets in this version tag without asking for any approval.",
|
||||
enabled=>1,
|
||||
type=>"VersionTag"
|
||||
}, "pbworkflow000000000003");
|
||||
$activity = $workflow->addActivity("WebGUI::Workflow::Activity::CommitVersionTag", "pbwfactivity0000000006");
|
||||
$activity->set("title", "Commit Assets");
|
||||
}
|
||||
|
||||
#-------------------------------------------------
|
||||
|
|
@ -465,6 +476,9 @@ sub removeFiles {
|
|||
unlink '../../lib/WebGUI/i18n/Asset_IndexedSearch.pm';
|
||||
unlink '../../sbin/Hourly/IndexedSearch_buildIndex.pm';
|
||||
rmtree('../../lib/WebGUI/Asset/Wobject/IndexedSearch');
|
||||
# uncomment this after they've all been converted
|
||||
#rmtree('../../sbin/Hourly');
|
||||
#unlink('../../sbin/runHourly.pl');
|
||||
}
|
||||
|
||||
#-------------------------------------------------
|
||||
|
|
|
|||
|
|
@ -130,9 +130,7 @@ sub canView {
|
|||
return 0 unless ($self->get("state") eq "published");
|
||||
if ($userId eq $self->get("ownerUserId")) {
|
||||
return 1;
|
||||
} elsif ( $self->get("startDate") <$self->session->datetime->time() &&
|
||||
$self->get("endDate") >$self->session->datetime->time() &&
|
||||
$self->session->user->isInGroup($self->get("groupIdView"),$userId)) {
|
||||
} elsif ($self->session->user->isInGroup($self->get("groupIdView"),$userId)) {
|
||||
return 1;
|
||||
}
|
||||
return $self->canEdit($userId);
|
||||
|
|
@ -195,14 +193,6 @@ sub definition {
|
|||
fieldType=>'selectBox',
|
||||
defaultValue=>'3'
|
||||
},
|
||||
startDate=>{
|
||||
fieldType=>'dateTime',
|
||||
defaultValue=>997995720
|
||||
},
|
||||
endDate=>{
|
||||
fieldType=>'dateTime',
|
||||
defaultValue=>4294967294
|
||||
},
|
||||
status=>{
|
||||
noFormPost=>1,
|
||||
fieldType=>'hidden',
|
||||
|
|
@ -316,7 +306,7 @@ Returns a reference to a list of properties (or specified property) of an Asset.
|
|||
|
||||
=head3 propertyName
|
||||
|
||||
Any of the values associated with the properties of an Asset. Default choices are "title", "menutTitle", "synopsis", "url", "groupIdEdit", "groupIdView", "ownerUserId", "startDate", "endDate", and "assetSize".
|
||||
Any of the values associated with the properties of an Asset. Default choices are "title", "menutTitle", "synopsis", "url", "groupIdEdit", "groupIdView", "ownerUserId", and "assetSize".
|
||||
|
||||
=cut
|
||||
|
||||
|
|
@ -560,20 +550,6 @@ sub getEditForm {
|
|||
-hoverHelp=>$i18n->get('encrypt page description'),
|
||||
-uiLevel=>6
|
||||
);
|
||||
$tabform->getTab("security")->dateTime(
|
||||
-name=>"startDate",
|
||||
-label=>$i18n->get(497),
|
||||
-hoverHelp=>$i18n->get('497 description'),
|
||||
-value=>$self->get("startDate"),
|
||||
-uiLevel=>6
|
||||
);
|
||||
$tabform->getTab("security")->dateTime(
|
||||
-name=>"endDate",
|
||||
-label=>$i18n->get(498),
|
||||
-hoverHelp=>$i18n->get('498 description'),
|
||||
-value=>$self->get("endDate"),
|
||||
-uiLevel=>6
|
||||
);
|
||||
my $subtext;
|
||||
if ($self->session->user->isInGroup(3)) {
|
||||
$subtext = $self->session->icon->manage('op=listUsers');
|
||||
|
|
@ -1706,8 +1682,6 @@ sub www_add {
|
|||
styleTemplateId => $self->get("styleTemplateId"),
|
||||
printableStyleTemplateId => $self->get("printableStyleTemplateId"),
|
||||
isHidden => $self->get("isHidden"),
|
||||
startDate => $self->get("startDate"),
|
||||
endDate => $self->get("endDate"),
|
||||
className=>$class,
|
||||
assetId=>"new"
|
||||
);
|
||||
|
|
|
|||
|
|
@ -84,20 +84,6 @@ sub edit {
|
|||
-uiLevel=>6
|
||||
);
|
||||
$tabform->addTab("security",$i18n->get(107,"Asset"),6);
|
||||
$tabform->getTab("security")->dateTime(
|
||||
-name=>"startDate",
|
||||
-label=>$i18n->get(497),
|
||||
-hoverHelp=>$i18n->get('497 description'),
|
||||
-value=>$self->get("startDate"),
|
||||
-uiLevel=>6
|
||||
);
|
||||
$tabform->getTab("security")->dateTime(
|
||||
-name=>"endDate",
|
||||
-label=>$i18n->get(498),
|
||||
-hoverHelp=>$i18n->get('498 description'),
|
||||
-value=>$self->get("endDate"),
|
||||
-uiLevel=>6
|
||||
);
|
||||
my $subtext;
|
||||
if ($self->session->user->isInGroup(3)) {
|
||||
$subtext = $self->session->icon->manage('op=listUsers');
|
||||
|
|
|
|||
|
|
@ -693,8 +693,6 @@ sub processPropertiesFromFormPost {
|
|||
}
|
||||
$data{groupIdView} =$self->getThread->getParent->get("groupIdView");
|
||||
$data{groupIdEdit} = $self->getThread->getParent->get("groupIdEdit");
|
||||
$data{startDate} = $self->getThread->getParent->get("startDate") unless ($self->session->form->process("startDate"));
|
||||
$data{endDate} = $self->getThread->getParent->get("endDate") unless ($self->session->form->process("endDate"));
|
||||
($data{synopsis}, $data{content}) = $self->getSynopsisAndContentFromFormPost;
|
||||
if ($self->getThread->getParent->get("addEditStampToPosts")) {
|
||||
$data{content} .= "\n\n --- (".$i18n->get('Edited_on','Asset_Post')." ".$self->session->datetime->epochToHuman(undef,"%z %Z [GMT%O]").$i18n->get('By','Asset_Post').$self->session->user->profileField("alias").") --- \n";
|
||||
|
|
@ -1147,18 +1145,6 @@ sub www_edit {
|
|||
name=>'contentType',
|
||||
value=>$self->getValue("contentType") || "mixed"
|
||||
});
|
||||
my $startDate = $self->get("startDate");
|
||||
$startDate = $self->session->datetime->setToEpoch($self->session->form->process("startDate")) if ($self->session->form->process("startDate"));
|
||||
$var{'startDate.form'} = WebGUI::Form::dateTime($self->session, {
|
||||
name => 'startDate',
|
||||
value => $startDate
|
||||
});
|
||||
my $endDate = $self->get("endDate");
|
||||
$endDate = $self->session->datetime->setToEpoch($self->session->form->process("endDate")) if ($self->session->form->process("endDate"));
|
||||
$var{'endDate.form'} = WebGUI::Form::dateTime($self->session, {
|
||||
name => 'endDate',
|
||||
value => $endDate
|
||||
});
|
||||
$self->getThread->getParent->appendTemplateLabels(\%var);
|
||||
return $self->getThread->getParent->processStyle($self->processTemplate(\%var,$self->getThread->getParent->get("postFormTemplateId")));
|
||||
}
|
||||
|
|
|
|||
|
|
@ -42,12 +42,6 @@ sub appendPostListTemplateVars {
|
|||
$controls .= $self->session->icon->moveUp('func=promote',$post->get("url")).$self->session->icon->moveDown('func=demote',$post->get("url"));
|
||||
}
|
||||
}
|
||||
my $inDateRange;
|
||||
if ($post->get("startDate") < $self->session->datetime->time() && $post->get("endDate") > $self->session->datetime->time()) {
|
||||
$inDateRange = 1;
|
||||
} else {
|
||||
$inDateRange = 0;
|
||||
}
|
||||
my @rating_loop;
|
||||
for (my $i=0;$i<=$post->get("rating");$i++) {
|
||||
push(@rating_loop,{'rating_loop.count'=>$i});
|
||||
|
|
@ -90,7 +84,6 @@ sub appendPostListTemplateVars {
|
|||
"user.isVisitor"=>$post->get("ownerUserId") eq "1",
|
||||
"edit.url"=>$post->getEditUrl,
|
||||
'controls'=>$controls,
|
||||
'inDateRange'=>$inDateRange,
|
||||
"isSecond"=>(($i+1)%2==0),
|
||||
"isThird"=>(($i+1)%3==0),
|
||||
"isFourth"=>(($i+1)%4==0),
|
||||
|
|
@ -127,7 +120,6 @@ sub appendTemplateLabels {
|
|||
$var->{'description.label'} = $i18n->get("description");
|
||||
$var->{"deny.label"} = $i18n->get("deny");
|
||||
$var->{"edit.label"} = $i18n->get("edit");
|
||||
$var->{'endDate.label'} = $i18n->get("endDate");
|
||||
$var->{'exactphrase.label'} = $i18n->get("exactPhrase");
|
||||
$var->{'image.label'} = $i18n->get("image");
|
||||
$var->{"job.header.label"} = $i18n->get("edit job");
|
||||
|
|
@ -160,7 +152,6 @@ sub appendTemplateLabels {
|
|||
$var->{'subject.label'} = $i18n->get("subject");
|
||||
$var->{"subscribe.label"} = $i18n->get("subscribe");
|
||||
$var->{'submission.header.label'} = $i18n->get("edit submission");
|
||||
$var->{'startDate.label'} = $i18n->get("start date");
|
||||
$var->{"stick.label"} = $i18n->get("sticky");
|
||||
$var->{"status.label"} = $i18n->get("status");
|
||||
$var->{"synopsis.label"} = $i18n->get("synopsis");
|
||||
|
|
|
|||
|
|
@ -613,8 +613,6 @@ sub www_editListingSave {
|
|||
url=>$self->session->form->process("productName"),
|
||||
groupIdView=>7,
|
||||
groupIdEdit=>3,
|
||||
startDate=>$self->session->datetime->time(),
|
||||
endDate=>$self->session->datetime->time()+60*60*24*365*15,
|
||||
displayLastReply => 0,
|
||||
allowReplies => 1,
|
||||
threadsPerPage => 30,
|
||||
|
|
|
|||
|
|
@ -183,22 +183,6 @@ sub www_editBranch {
|
|||
-uiLevel=>6,
|
||||
-subtext=>'<br />'.$i18n->get("change").' '.WebGUI::Form::yesNo($self->session,{name=>"change_encryptPage"})
|
||||
);
|
||||
$tabform->getTab("security")->dateTime(
|
||||
-name=>"startDate",
|
||||
-label=>$i18n->get(497),
|
||||
-hoverHelp=>$i18n->get('497 description',"Asset"),
|
||||
-value=>$self->get("startDate"),
|
||||
-uiLevel=>6,
|
||||
-subtext=>'<br />'.$i18n->get("change").' '.WebGUI::Form::yesNo($self->session,{name=>"change_startDate"})
|
||||
);
|
||||
$tabform->getTab("security")->dateTime(
|
||||
-name=>"endDate",
|
||||
-label=>$i18n->get(498),
|
||||
-hoverHelp=>$i18n->get('498 description',"Asset"),
|
||||
-value=>$self->get("endDate"),
|
||||
-uiLevel=>6,
|
||||
-subtext=>'<br />'.$i18n->get("change").' '.WebGUI::Form::yesNo($self->session,{name=>"change_endDate"})
|
||||
);
|
||||
my $subtext;
|
||||
if ($self->session->user->isInGroup(3)) {
|
||||
$subtext = $self->session->icon->manage('op=listUsers');
|
||||
|
|
@ -296,8 +280,6 @@ sub www_editBranchSave {
|
|||
$data{cacheTimeout} = $self->session->form->interval("cacheTimeout") if ($self->session->form->yesNo("change_cacheTimeout"));
|
||||
$data{cacheTimeoutVisitor} = $self->session->form->interval("cacheTimeoutVisitor") if ($self->session->form->yesNo("change_cacheTimeoutVisitor"));
|
||||
$data{encryptPage} = $self->session->form->yesNo("encryptPage") if ($self->session->form->yesNo("change_encryptPage"));
|
||||
$data{startDate} = $self->session->form->dateTime("startDate") if ($self->session->form->yesNo("change_startDate"));
|
||||
$data{endDate} = $self->session->form->dateTime("endDate") if ($self->session->form->yesNo("change_endDate"));
|
||||
$data{ownerUserId} = $self->session->form->selectBox("ownerUserId") if ($self->session->form->yesNo("change_ownerUserId"));
|
||||
$data{groupIdView} = $self->session->form->group("groupIdView") if ($self->session->form->yesNo("change_groupIdView"));
|
||||
$data{groupIdEdit} = $self->session->form->group("groupIdEdit") if ($self->session->form->yesNo("change_groupIdEdit"));
|
||||
|
|
|
|||
|
|
@ -220,8 +220,6 @@ sub www_createShortcut () {
|
|||
menuTitle=>$self->getMenuTitle,
|
||||
isHidden=>$self->get("isHidden"),
|
||||
newWindow=>$self->get("newWindow"),
|
||||
startDate=>$self->get("startDate"),
|
||||
endDate=>$self->get("endDate"),
|
||||
ownerUserId=>$self->get("ownerUserId"),
|
||||
groupIdEdit=>$self->get("groupIdEdit"),
|
||||
groupIdView=>$self->get("groupIdView"),
|
||||
|
|
|
|||
|
|
@ -58,9 +58,9 @@ sub addRevision {
|
|||
my $now = shift ||$self->session->datetime->time();
|
||||
my $versionTag = $self->session->scratch->get("versionTag") || 'pbversion0000000000002';
|
||||
my $status = $self->session->setting->get("autoCommit") ? 'approved' : 'pending';
|
||||
$self->session->db->write("insert into assetData (assetId, revisionDate, revisedBy, tagId, status, url, startDate, endDate,
|
||||
$self->session->db->write("insert into assetData (assetId, revisionDate, revisedBy, tagId, status, url,
|
||||
ownerUserId, groupIdEdit, groupIdView) values (".$self->session->db->quote($self->getId).",".$now.", ".$self->session->db->quote($self->session->user->userId).",
|
||||
".$self->session->db->quote($versionTag).", ".$self->session->db->quote($status).", ".$self->session->db->quote($self->getId).", 997995720, 32472169200,'3','3','7')");
|
||||
".$self->session->db->quote($versionTag).", ".$self->session->db->quote($status).", ".$self->session->db->quote($self->getId).", '3','3','7')");
|
||||
foreach my $definition (@{$self->definition($self->session)}) {
|
||||
unless ($definition->{tableName} eq "assetData") {
|
||||
$self->session->db->write("insert into ".$definition->{tableName}." (assetId,revisionDate) values (".$self->session->db->quote($self->getId).",".$now.")");
|
||||
|
|
|
|||
|
|
@ -95,9 +95,11 @@ sub www_editCronJob {
|
|||
hoverHelp=>$i18n->get("run once help")
|
||||
);
|
||||
my $value = $cron->get("workflowId") if defined $cron;
|
||||
my $type = "None" unless defined $cron;
|
||||
$f->workflow(
|
||||
name=>"workflowId",
|
||||
value=>$value,
|
||||
type=>$type,
|
||||
label=>$i18n->get("workflow"),
|
||||
hoverHelp=>$i18n->get("workflow help")
|
||||
);
|
||||
|
|
|
|||
|
|
@ -45,15 +45,15 @@ sub www_addWorkflow {
|
|||
name=>"op",
|
||||
value=>"addWorkflowSave"
|
||||
);
|
||||
my %options = ();
|
||||
foreach my $object (keys %{$session->config->get("workflowActivities")}) {
|
||||
$options{$object} = $object;
|
||||
}
|
||||
$f->selectBox(
|
||||
name=>"type",
|
||||
label=>$i18n->get("object type"),
|
||||
options=>{
|
||||
none=>$i18n->get("none"),
|
||||
versiontag=>$i18n->get("versiontag"),
|
||||
user=>$i18n->get("user")
|
||||
},
|
||||
value=>"none",
|
||||
options=>\%options,
|
||||
value=>"None",
|
||||
hoverHelp=>$i18n->get("object type help")
|
||||
);
|
||||
$f->submit;
|
||||
|
|
@ -154,7 +154,7 @@ sub www_editWorkflow {
|
|||
);
|
||||
$f->readOnly(
|
||||
label=>$i18n->get("object type"),
|
||||
value=>$workflow->getTypeName
|
||||
value=>$workflow->get("type")
|
||||
);
|
||||
$f->text(
|
||||
name=>"title",
|
||||
|
|
|
|||
|
|
@ -89,10 +89,8 @@ Commits all assets edited under a version tag, and then sets the version tag to
|
|||
|
||||
sub commit {
|
||||
my $self = shift;
|
||||
my $tagId = $self->getId;
|
||||
my $sth = $self->session->db->read("select asset.assetId,asset.className,assetData.revisionDate from assetData left join asset on asset.assetId=assetData.assetId where assetData.tagId=?", [$tagId]);
|
||||
while (my ($id,$class,$version) = $sth->array) {
|
||||
WebGUI::Asset->new($self->session,$id,$class,$version)->commit;
|
||||
foreach my $asset (@{$self->getAssets}) {
|
||||
$asset->commit;
|
||||
}
|
||||
$self->{_data}{isCommited} = 1;
|
||||
$self->{_data}{commitedBy} = $self->session->user->userId;
|
||||
|
|
@ -118,6 +116,24 @@ sub get {
|
|||
|
||||
#-------------------------------------------------------------------
|
||||
|
||||
=head2 getAssets ( )
|
||||
|
||||
Returns a list of asset objects that are part of this version tag.
|
||||
|
||||
=cut
|
||||
|
||||
sub getAssets {
|
||||
my $self = shift;
|
||||
my @assets = ();
|
||||
my $sth = $self->session->db->read("select asset.assetId,asset.className,assetData.revisionDate from assetData left join asset on asset.assetId=assetData.assetId where assetData.tagId=?", [$self->getId]);
|
||||
while (my ($id,$class,$version) = $sth->array) {
|
||||
push(@assets, WebGUI::Asset->new($self->session,$id,$class,$version));
|
||||
}
|
||||
return \@assets;
|
||||
}
|
||||
|
||||
#-------------------------------------------------------------------
|
||||
|
||||
=head2 getId ( )
|
||||
|
||||
Returns the ID of this version tag.
|
||||
|
|
|
|||
|
|
@ -268,25 +268,6 @@ sub getNextActivity {
|
|||
}
|
||||
|
||||
|
||||
#-------------------------------------------------------------------
|
||||
|
||||
=head2 getTypeName ( [ type ] )
|
||||
|
||||
Returns a human readable name for the object type this workflow supports.
|
||||
|
||||
=head3 type
|
||||
|
||||
Optionally override the type by specifying it here.
|
||||
|
||||
=cut
|
||||
|
||||
sub getTypeName {
|
||||
my $self = shift;
|
||||
my $type = shift || $self->get("type");
|
||||
my $i18n = WebGUI::International->new($self->session,"Workflow");
|
||||
return $i18n->get($type);
|
||||
}
|
||||
|
||||
#-------------------------------------------------------------------
|
||||
|
||||
=head2 new ( session, workflowId )
|
||||
|
|
@ -349,7 +330,7 @@ A boolean indicating whether this workflow may be executed right now.
|
|||
|
||||
=head4 type
|
||||
|
||||
A string indicating the type of object this workflow will be operating on. Valid values are "none", "versiontag" and "user".
|
||||
A string indicating the type of object this workflow will be operating on. Valid values are "None", "VersionTag" and "User".
|
||||
|
||||
=head4 isSerial
|
||||
|
||||
|
|
@ -372,7 +353,7 @@ sub set {
|
|||
}
|
||||
$self->{_data}{title} = $properties->{title} || $self->{_data}{title} || "Untitled";
|
||||
$self->{_data}{description} = (exists $properties->{description}) ? $properties->{description} : $self->{_data}{description};
|
||||
$self->{_data}{type} = $properties->{type} || $self->{_data}{type} || "none";
|
||||
$self->{_data}{type} = $properties->{type} || $self->{_data}{type} || "None";
|
||||
$self->session->db->setRow("Workflow","workflowId",$self->{_data});
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -26,7 +26,7 @@ Package WebGUI::Workflow::Activity::CommitVersionTag
|
|||
|
||||
=head1 DESCRIPTION
|
||||
|
||||
This activity commmits an open version tag.
|
||||
This activity commits an open version tag.
|
||||
|
||||
=head1 SYNOPSIS
|
||||
|
||||
|
|
|
|||
155
lib/WebGUI/Workflow/Activity/CreateCronJob.pm
Normal file
155
lib/WebGUI/Workflow/Activity/CreateCronJob.pm
Normal file
|
|
@ -0,0 +1,155 @@
|
|||
package WebGUI::Workflow::Activity::CreateCronJob;
|
||||
|
||||
|
||||
=head1 LEGAL
|
||||
|
||||
-------------------------------------------------------------------
|
||||
WebGUI is Copyright 2001-2006 Plain Black Corporation.
|
||||
-------------------------------------------------------------------
|
||||
Please read the legal notices (docs/legal.txt) and the license
|
||||
(docs/license.txt) that came with this distribution before using
|
||||
this software.
|
||||
-------------------------------------------------------------------
|
||||
http://www.plainblack.com info@plainblack.com
|
||||
-------------------------------------------------------------------
|
||||
|
||||
=cut
|
||||
|
||||
use strict;
|
||||
use base 'WebGUI::Workflow::Activity';
|
||||
use WebGUI::Workflow::Cron;
|
||||
|
||||
|
||||
=head1 NAME
|
||||
|
||||
Package WebGUI::Workflow::Activity::CreateCronJob
|
||||
|
||||
=head1 DESCRIPTION
|
||||
|
||||
Creates a new cron job passing the object that is current running to the new workflow instance created by the cron job.
|
||||
|
||||
=head1 SYNOPSIS
|
||||
|
||||
See WebGUI::Workflow::Activity for details on how to use any activity.
|
||||
|
||||
=head1 METHODS
|
||||
|
||||
These methods are available from this class:
|
||||
|
||||
=cut
|
||||
|
||||
#-------------------------------------------------------------------
|
||||
|
||||
=head2 definition ( session, definition )
|
||||
|
||||
See WebGUI::Workflow::Activity::defintion() for details.
|
||||
|
||||
=cut
|
||||
|
||||
sub definition {
|
||||
my $class = shift;
|
||||
my $session = shift;
|
||||
my $definition = shift;
|
||||
my $i18n = WebGUI::International->new($session, "Workflow_Cron");
|
||||
my %priorities = ();
|
||||
tie %priorities, 'Tie::IxHash';
|
||||
%priorities = (1=>$i18n->get("high"), 2=>$i18n->get("medium"), 3=>$i18n->get("low"));
|
||||
push(@{$definition}, {
|
||||
name=>$i18n->get("create cron job"),
|
||||
properties=> {
|
||||
enabled=>{
|
||||
fieldType=>"yesNo",
|
||||
defaultValue=>0,
|
||||
label=>$i18n->get("is enabled"),
|
||||
hoverHelp=>$i18n->get("is enabled help")
|
||||
},
|
||||
runOnce=>{
|
||||
fieldType=>"yesNo",
|
||||
defaultValue=>1,
|
||||
label=>$i18n->get("run once"),
|
||||
hoverHelp=>$i18n->get("run once help")
|
||||
},
|
||||
workflowId=>{
|
||||
fieldType=>"workflow",
|
||||
defaultValue=>undef,
|
||||
label=>$i18n->get("workflow"),
|
||||
hoverHelp=>$i18n->get("workflow help")
|
||||
},
|
||||
priority=>{
|
||||
fieldType=>"radioList",
|
||||
vertical=>1,
|
||||
defaultValue=>2,
|
||||
options=>\%priorities,
|
||||
label=>$i18n->get("priority"),
|
||||
hoverHelp=>$i18n->get("priority help")
|
||||
},
|
||||
minuteOfHour=>{
|
||||
fieldType=>"text",
|
||||
defaultValue=>0,
|
||||
label=>$i18n->get("minute of hour"),
|
||||
hoverHelp=>$i18n->get("minute of hour help")
|
||||
},
|
||||
hourOfDay=>{
|
||||
fieldType=>"text",
|
||||
defaultValue=>"*",
|
||||
label=>$i18n->get("hour of day"),
|
||||
hoverHelp=>$i18n->get("hour of day help")
|
||||
},
|
||||
dayOfMonth=>{
|
||||
fieldType=>"text",
|
||||
defaultValue=>"*",
|
||||
label=>$i18n->get("day of month"),
|
||||
hoverHelp=>$i18n->get("day of month help")
|
||||
},
|
||||
monthOfYear=>{
|
||||
fieldType=>"text",
|
||||
defaultValue=>"*",
|
||||
label=>$i18n->get("month of year"),
|
||||
hoverHelp=>$i18n->get("month of year")
|
||||
},
|
||||
dayOfWeek=>{
|
||||
fieldType=>"text",
|
||||
defaultValue=>"*",
|
||||
label=>$i18n->get("day of week"),
|
||||
hoverHelp=>$i18n->get("day of week help")
|
||||
}
|
||||
}
|
||||
});
|
||||
return $class->SUPER::definition($session,$definition);
|
||||
}
|
||||
|
||||
#-------------------------------------------------------------------
|
||||
|
||||
=head2 execute ( )
|
||||
|
||||
See WebGUI::Workflow::Activity::execute() for details.
|
||||
|
||||
=cut
|
||||
|
||||
sub execute {
|
||||
my $self = shift;
|
||||
my $object = shift;
|
||||
my $cron = WebGUI::Workflow::Cron->create($self->session, {
|
||||
title=>"Generated by workflow ".$self->getId." (".$self->get("title").")",
|
||||
enabled=>$self->get("enabled"),
|
||||
runOnce=>$self->get("runOnce"),
|
||||
workflowId=>$self->get("workflowId"),
|
||||
priority=>$self->get("priority"),
|
||||
minuteOfHour=>$self->get("minuteOfHour"),
|
||||
hourOfDay=>$self->get("hourOfDay"),
|
||||
dayOfMonth=>$self->get("dayOfMonth"),
|
||||
monthOfYear=>$self->get("monthOfYear"),
|
||||
dayOfWeek=>$self->get("dayOfWeek"),
|
||||
className=>$self->get("className"),
|
||||
methodName=>$self->get("methodName"),
|
||||
parameters=>$self->get("parameters")
|
||||
});
|
||||
return defined $cron ? 1 : 0;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
1;
|
||||
|
||||
|
||||
85
lib/WebGUI/Workflow/Activity/TrashVersionTag.pm
Normal file
85
lib/WebGUI/Workflow/Activity/TrashVersionTag.pm
Normal file
|
|
@ -0,0 +1,85 @@
|
|||
package WebGUI::Workflow::Activity::TrashVersionTag;
|
||||
|
||||
|
||||
=head1 LEGAL
|
||||
|
||||
-------------------------------------------------------------------
|
||||
WebGUI is Copyright 2001-2006 Plain Black Corporation.
|
||||
-------------------------------------------------------------------
|
||||
Please read the legal notices (docs/legal.txt) and the license
|
||||
(docs/license.txt) that came with this distribution before using
|
||||
this software.
|
||||
-------------------------------------------------------------------
|
||||
http://www.plainblack.com info@plainblack.com
|
||||
-------------------------------------------------------------------
|
||||
|
||||
=cut
|
||||
|
||||
use strict;
|
||||
use base 'WebGUI::Workflow::Activity';
|
||||
use WebGUI::VersionTag;
|
||||
|
||||
|
||||
=head1 NAME
|
||||
|
||||
Package WebGUI::Workflow::Activity::TrashVersionTag
|
||||
|
||||
=head1 DESCRIPTION
|
||||
|
||||
This activity trashes all content attached to a version tag.
|
||||
|
||||
=head1 SYNOPSIS
|
||||
|
||||
See WebGUI::Workflow::Activity for details on how to use any activity.
|
||||
|
||||
=head1 METHODS
|
||||
|
||||
These methods are available from this class:
|
||||
|
||||
=cut
|
||||
|
||||
#-------------------------------------------------------------------
|
||||
|
||||
=head2 definition ( session, definition )
|
||||
|
||||
See WebGUI::Workflow::Activity::defintion() for details.
|
||||
|
||||
=cut
|
||||
|
||||
sub definition {
|
||||
my $class = shift;
|
||||
my $session = shift;
|
||||
my $definition = shift;
|
||||
my $i18n = WebGUI::International->new($session, "Workflow_Activity_TrashVersionTag");
|
||||
push(@{$definition}, {
|
||||
name=>$i18n->get("topicName"),
|
||||
properties=> { }
|
||||
});
|
||||
return $class->SUPER::definition($session,$definition);
|
||||
}
|
||||
|
||||
|
||||
#-------------------------------------------------------------------
|
||||
|
||||
=head2 execute ( )
|
||||
|
||||
See WebGUI::Workflow::Activity::execute() for details.
|
||||
|
||||
=cut
|
||||
|
||||
sub execute {
|
||||
my $self = shift;
|
||||
my $versionTag = shift;
|
||||
foreach my $asset (@{$versionTag->getAssets}) {
|
||||
$asset->trash;
|
||||
}
|
||||
$versionTag->lock;
|
||||
$versionTag->clearWorking;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
1;
|
||||
|
||||
|
||||
|
|
@ -309,20 +309,6 @@ a URL will be made from the parent's URL and the <b>Menu Title</b>.<br />
|
|||
lastUpdated => 1127426194,
|
||||
},
|
||||
|
||||
'497 description' => {
|
||||
message => q|<p>The date when users may begin viewing this asset. Before this date only Content Managers with the rights to edit this asset will see it<br />
|
||||
<i>UI level: 6</i>.
|
||||
</p>|,
|
||||
lastUpdated => 1127426192,
|
||||
},
|
||||
|
||||
'498 description' => {
|
||||
message => q|<p>The date when users will stop viewing this asset. After this date only Content Managers with the rights to edit this asset will see it.<br />
|
||||
<i>UI level: 6</i>
|
||||
</p>|,
|
||||
lastUpdated => 1127426188,
|
||||
},
|
||||
|
||||
'108 description' => {
|
||||
message => q|The owner of a asset is usually the person who created the asset. This user always has full edit and viewing rights on the asset.<br>
|
||||
<i>UI level: 6</i>
|
||||
|
|
@ -709,14 +695,6 @@ each asset under the tab "Meta" in the asset properties.</p>
|
|||
lastUpdated => 1031514049,
|
||||
message => q|Data Type|
|
||||
},
|
||||
'497' => {
|
||||
lastUpdated => 1031514049,
|
||||
message => q|Start Date|
|
||||
},
|
||||
'498' => {
|
||||
lastUpdated => 1031514049,
|
||||
message => q|End Date|
|
||||
},
|
||||
'949' => {
|
||||
lastUpdated => 1052850265,
|
||||
message => q|Manage clipboard.|
|
||||
|
|
|
|||
|
|
@ -186,11 +186,6 @@ our $I18N = {
|
|||
lastUpdated => 1109618544,
|
||||
},
|
||||
|
||||
'endDate' => {
|
||||
message => q|End Date|,
|
||||
lastUpdated => 1109618544,
|
||||
},
|
||||
|
||||
'exactPhrase' => {
|
||||
message => q|Exact Phrase|,
|
||||
lastUpdated => 1109618544,
|
||||
|
|
@ -361,11 +356,6 @@ our $I18N = {
|
|||
lastUpdated => 1109696029,
|
||||
},
|
||||
|
||||
'start date' => {
|
||||
message => q|Start Date|,
|
||||
lastUpdated => 1109696029,
|
||||
},
|
||||
|
||||
'sticky' => {
|
||||
message => q|Make Sticky|,
|
||||
lastUpdated => 1109697033,
|
||||
|
|
@ -635,10 +625,6 @@ our $I18N = {
|
|||
^International("word","Asset_Collaboration"); "^International("edit","Asset_Collaboration");".
|
||||
<p>
|
||||
|
||||
<b>endDate.label</b><br>
|
||||
^International("phrase","Asset_Collaboration"); "^International("endDate","Asset_Collaboration");".
|
||||
<p>
|
||||
|
||||
<b>exactphrase.label</b><br>
|
||||
^International("phrase","Asset_Collaboration"); "^International("exactPhrase","Asset_Collaboration");".
|
||||
<p>
|
||||
|
|
@ -767,10 +753,6 @@ our $I18N = {
|
|||
^International("phrase","Asset_Collaboration"); "^International("edit submission","Asset_Collaboration");".
|
||||
<p>
|
||||
|
||||
<b>startDate.label</b><br>
|
||||
^International("phrase","Asset_Collaboration"); "^International("start date","Asset_Collaboration");".
|
||||
<p>
|
||||
|
||||
<b>stick.label</b><br>
|
||||
^International("phrase","Asset_Collaboration"); "^International("sticky","Asset_Collaboration");".
|
||||
<p>
|
||||
|
|
@ -1070,11 +1052,6 @@ The URL to edit this Post.
|
|||
<b>controls</b><br>
|
||||
A set of editing icons to delete or re-order this Post.
|
||||
|
||||
<p>
|
||||
<b>inDateRange</b><br>
|
||||
A conditional indicating that the current time is greater than the start date and less than
|
||||
the end date.
|
||||
|
||||
<p>
|
||||
<b>isSecond</b><br>
|
||||
A conditional indicating that is true if this Post is the second in this Collaboration Asset.
|
||||
|
|
|
|||
|
|
@ -141,14 +141,6 @@ A form field that will describe how the content of the post is formatted, HTML,
|
|||
Defaults to mixed.
|
||||
<p>
|
||||
|
||||
<b>startDate.form</b><br>
|
||||
A form that will set when the post starts to be available.
|
||||
<p>
|
||||
|
||||
<b>endDate.form</b><br>
|
||||
A form that will set when the post stops being available.
|
||||
<p>
|
||||
|
||||
|,
|
||||
lastUpdated => 1134670945,
|
||||
},
|
||||
|
|
@ -365,14 +357,6 @@ The ID of the group with permission to view this Post.
|
|||
An alias for <b>userId</b>.
|
||||
<p>
|
||||
|
||||
<b>startDate</b><br>
|
||||
The date when the Post is first available, in epoch format.
|
||||
<p>
|
||||
|
||||
<b>endDate</b><br>
|
||||
The date when the Post is stops being available, in epoch format.
|
||||
<p>
|
||||
|
||||
<b>assetSize</b><br>
|
||||
The formatted size of this Post.
|
||||
<p>
|
||||
|
|
|
|||
|
|
@ -998,11 +998,6 @@ removed from the system after a set period of time. That period of time is set
|
|||
lastUpdated => 1127337912,
|
||||
},
|
||||
|
||||
'498' => {
|
||||
message => q|End Date|,
|
||||
lastUpdated => 1031514049
|
||||
},
|
||||
|
||||
'483' => {
|
||||
message => q|Yes or No|,
|
||||
lastUpdated => 1031514049
|
||||
|
|
@ -2543,11 +2538,6 @@ The headings of columns on things like message boards and user contributions.
|
|||
lastUpdated => 1058092984
|
||||
},
|
||||
|
||||
'497' => {
|
||||
message => q|Start Date|,
|
||||
lastUpdated => 1031514049
|
||||
},
|
||||
|
||||
'518' => {
|
||||
message => q|Inbox Notifications|,
|
||||
lastUpdated => 1031514049
|
||||
|
|
|
|||
|
|
@ -13,24 +13,6 @@ our $I18N = {
|
|||
lastUpdated => 0,
|
||||
},
|
||||
|
||||
'none' => {
|
||||
message => q|None|,
|
||||
context => q|Workflow doesn't work on objects.|,
|
||||
lastUpdated => 0,
|
||||
},
|
||||
|
||||
'versiontag' => {
|
||||
message => q|Version Tag|,
|
||||
context => q|Workflow can work on version tag objects.|,
|
||||
lastUpdated => 0,
|
||||
},
|
||||
|
||||
'user' => {
|
||||
message => q|User|,
|
||||
context => q|Workflow can work on user objects.|,
|
||||
lastUpdated => 0,
|
||||
},
|
||||
|
||||
'object type help' => {
|
||||
message => q|What type of objects do you want this workflow to be able to handle?|,
|
||||
context => q|the hover help for the object type field|,
|
||||
|
|
|
|||
13
lib/WebGUI/i18n/English/Workflow_Activity_TrashVersionTag.pm
Normal file
13
lib/WebGUI/i18n/English/Workflow_Activity_TrashVersionTag.pm
Normal file
|
|
@ -0,0 +1,13 @@
|
|||
package WebGUI::i18n::English::Workflow_Activity_TrashVersionTag;
|
||||
|
||||
our $I18N = {
|
||||
|
||||
'topicName' => {
|
||||
message => q|Trash Version Tag|,
|
||||
context => q|The name of this workflow activity.|,
|
||||
lastUpdated => 0,
|
||||
},
|
||||
|
||||
};
|
||||
|
||||
1;
|
||||
|
|
@ -169,6 +169,12 @@ our $I18N = {
|
|||
lastUpdated => 0,
|
||||
},
|
||||
|
||||
'create cron job' => {
|
||||
message => q|Create a Scheduled Event|,
|
||||
context => q|the title of the CreateCronJob workflow activity|,
|
||||
lastUpdated => 0,
|
||||
},
|
||||
|
||||
'topicName' => {
|
||||
message => q|Scheduler|,
|
||||
context => q|The title of the cron/scheduler interface.|,
|
||||
|
|
|
|||
|
|
@ -1,34 +0,0 @@
|
|||
package Hourly::TrashExpiredContent;
|
||||
|
||||
#-------------------------------------------------------------------
|
||||
# WebGUI is Copyright 2001-2006 Plain Black Corporation.
|
||||
#-------------------------------------------------------------------
|
||||
# Please read the legal notices (docs/legal.txt) and the license
|
||||
# (docs/license.txt) that came with this distribution before using
|
||||
# this software.
|
||||
#-------------------------------------------------------------------
|
||||
# http://www.plainblack.com info@plainblack.com
|
||||
#-------------------------------------------------------------------
|
||||
|
||||
use strict;
|
||||
use WebGUI::Asset;
|
||||
use WebGUI::Session;
|
||||
use WebGUI::SQL;
|
||||
|
||||
#-----------------------------------------
|
||||
sub process {
|
||||
my $offset = $session{config}{TrashExpiredContent_offset};
|
||||
if ($offset ne "") {
|
||||
my $now = time();
|
||||
$offset = 86400*$offset;
|
||||
my $sth = WebGUI::SQL->read("select asset.assetId, asset.className from assetData left join asset on assetData.assetId=asset.assetId where asset.state='published' and assetData.endDate + $offset < $now");
|
||||
while (my ($assetId,$class) = $sth->array) {
|
||||
my $asset = WebGUI::Asset->new($assetId,$class);
|
||||
$asset->trash if ($asset->get("endDate")+$offset < $now); # verify end date of most recent revision
|
||||
}
|
||||
$sth->finish;
|
||||
}
|
||||
}
|
||||
|
||||
1;
|
||||
|
||||
Loading…
Add table
Add a link
Reference in a new issue