rfe #640: Refactored autocommit and autocomment
Autocommit assets like CS posts or Calendar Events can now be added before the parent is committed. They will go into the same version tag as their parent.
This commit is contained in:
parent
71fc839c83
commit
99a9da626d
22 changed files with 218 additions and 259 deletions
|
|
@ -25,6 +25,9 @@
|
|||
- rfe #746: use the menu title in asset manager
|
||||
- rfe #549: New macro for checking spectre status. VersionTag::RequestCommit and Operation::VestionTag::www_commitVertionTag now both check for spectre status before trying to commit.
|
||||
- rfe #637: Alphabetize wiki items under a keyword?
|
||||
- Autocommit assets like CS posts or Calendar Events can now be added before the
|
||||
parent is committed. They will go into the same version tag as their parent.
|
||||
- rfe #640: Refactored autocommit and autocomment
|
||||
|
||||
|
||||
7.6.1
|
||||
|
|
|
|||
|
|
@ -2550,35 +2550,17 @@ sub www_editSave {
|
|||
|
||||
$object->updateHistory("edited");
|
||||
|
||||
# Handle Save & Commit button
|
||||
if ($self->session->form->process("saveAndCommit") ne "") {
|
||||
if ($self->session->setting->get("skipCommitComments")) {
|
||||
$self->session->http->setRedirect(
|
||||
$self->getUrl("op=commitVersionTagConfirm;tagId=".WebGUI::VersionTag->getWorking($self->session)->getId)
|
||||
);
|
||||
}
|
||||
else {
|
||||
$self->session->http->setRedirect(
|
||||
$self->getUrl("op=commitVersionTag;tagId=".WebGUI::VersionTag->getWorking($self->session)->getId)
|
||||
);
|
||||
}
|
||||
return undef;
|
||||
# we handle auto commit assets here in case they didn't handle it themselves
|
||||
if ($object->getAutoCommitWorkflowId && $self->hasBeenCommitted) {
|
||||
$object->requestAutoCommit;
|
||||
}
|
||||
|
||||
# Handle Auto Request Commit setting
|
||||
if ($self->session->setting->get("autoRequestCommit")) {
|
||||
# Make sure version tag hasn't already been committed by another process
|
||||
my $versionTag = WebGUI::VersionTag->getWorking($self->session, "nocreate");
|
||||
|
||||
if ($versionTag && $self->session->setting->get("skipCommitComments")) {
|
||||
$versionTag->requestCommit;
|
||||
}
|
||||
elsif ($versionTag) {
|
||||
$self->session->http->setRedirect(
|
||||
$self->getUrl("op=commitVersionTag;tagId=".WebGUI::VersionTag->getWorking($self->session)->getId)
|
||||
);
|
||||
return undef;
|
||||
}
|
||||
# else, try to to auto commit
|
||||
elsif(WebGUI::VersionTag->autoCommitWorkingIfEnabled($self->session, {
|
||||
override => scalar $self->session->form->process('saveAndCommit'),
|
||||
allowComments => 1,
|
||||
returnUrl => $self->getUrl,
|
||||
})) {
|
||||
return undef;
|
||||
}
|
||||
|
||||
# Handle "saveAndReturn" button
|
||||
|
|
@ -2600,12 +2582,11 @@ sub www_editSave {
|
|||
$self->session->asset($object);
|
||||
return $self->session->asset->$method();
|
||||
}
|
||||
|
||||
|
||||
$self->session->asset($object->getContainer);
|
||||
return $self->session->asset->www_view;
|
||||
}
|
||||
|
||||
|
||||
|
||||
#-------------------------------------------------------------------
|
||||
|
||||
|
|
|
|||
|
|
@ -16,12 +16,12 @@ our $VERSION = "0.0.0";
|
|||
|
||||
use Tie::IxHash;
|
||||
use Carp qw(croak);
|
||||
use Storable qw(nfreeze thaw);
|
||||
|
||||
use WebGUI::International;
|
||||
use WebGUI::Asset::Template;
|
||||
use WebGUI::Form;
|
||||
use WebGUI::Storage::Image;
|
||||
use Storable;
|
||||
|
||||
use base 'WebGUI::Asset';
|
||||
|
||||
|
|
@ -275,8 +275,7 @@ sub generateRecurringEvents {
|
|||
$properties->{startTime} = $startDate->toDatabaseTime;
|
||||
$properties->{endTime} = $endDate->toDatabaseTime;
|
||||
}
|
||||
my $newEvent = $parent->addChild($properties);
|
||||
$newEvent->requestAutoCommit;
|
||||
my $newEvent = $parent->addChild($properties, undef, undef, { skipAutoCommitWorkflows => 1 });
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -298,8 +297,12 @@ By specifying this method, you activate this feature.
|
|||
|
||||
sub getAutoCommitWorkflowId {
|
||||
my $self = shift;
|
||||
return $self->getParent->get('workflowIdCommit')
|
||||
|| $self->session->setting->get('defaultVersionTagWorkflow');
|
||||
my $parent = $self->getParent;
|
||||
if ($parent->hasBeenCommitted) {
|
||||
return $parent->get('workflowIdCommit')
|
||||
|| $self->session->setting->get('defaultVersionTagWorkflow');
|
||||
}
|
||||
return undef;
|
||||
}
|
||||
|
||||
|
||||
|
|
@ -1469,7 +1472,7 @@ sub processPropertiesFromFormPost {
|
|||
my $self = shift;
|
||||
$self->SUPER::processPropertiesFromFormPost; # Updates the event
|
||||
my $session = $self->session;
|
||||
my $form = $self->session->form;
|
||||
my $form = $session->form;
|
||||
|
||||
### Verify the form was filled out correctly...
|
||||
my @errors;
|
||||
|
|
@ -1489,6 +1492,17 @@ sub processPropertiesFromFormPost {
|
|||
return \@errors;
|
||||
}
|
||||
|
||||
# Since we may be adding more events, set out version tag to be active if needed
|
||||
# Leave the original version tag available, we will need to reactivate it before returning
|
||||
warn "trying to activate version tag\n";
|
||||
my $activeVersionTag = WebGUI::VersionTag->getWorking($session, 'nocreate');
|
||||
# if our version tag is active, we don't need a new one, and don't need to reactivate anything later
|
||||
if ($activeVersionTag && $activeVersionTag->getId eq $self->get('tagId')) {
|
||||
undef $activeVersionTag;
|
||||
}
|
||||
else {
|
||||
WebGUI::VersionTag->new($session, $self->get('tagId'))->setWorking;
|
||||
}
|
||||
|
||||
### Form is verified
|
||||
# Events are always hidden from navigation
|
||||
|
|
@ -1518,16 +1532,16 @@ sub processPropertiesFromFormPost {
|
|||
my $dtStart
|
||||
= WebGUI::DateTime->new($session,
|
||||
mysql => $self->get("startDate") . " " . $self->get("startTime"),
|
||||
time_zone => $tz,
|
||||
time_zone => $tz,
|
||||
);
|
||||
|
||||
my $dtEnd
|
||||
= WebGUI::DateTime->new($session,
|
||||
mysql => $self->get("endDate") . " " . $self->get("endTime"),
|
||||
time_zone => $tz,
|
||||
time_zone => $tz,
|
||||
);
|
||||
|
||||
$self->update({
|
||||
$self->update({
|
||||
startDate => $dtStart->toDatabaseDate,
|
||||
startTime => $dtStart->toDatabaseTime,
|
||||
endDate => $dtEnd->toDatabaseDate,
|
||||
|
|
@ -1603,7 +1617,6 @@ sub processPropertiesFromFormPost {
|
|||
|
||||
$self->setRelatedLinks(\@rel_link_saves);
|
||||
|
||||
|
||||
# Determine if the pattern has changed
|
||||
if ($form->param("recurType")) {
|
||||
# Create the new recurrence hash
|
||||
|
|
@ -1617,16 +1630,19 @@ sub processPropertiesFromFormPost {
|
|||
|
||||
|
||||
# Pattern keys
|
||||
if (nfreeze(\%recurrence_new) ne nfreeze(\%recurrence_old)) {
|
||||
if (Storable::freeze(\%recurrence_new) ne Storable::freeze(\%recurrence_old)) {
|
||||
# Delete all old events and create new ones
|
||||
my $old_id = $self->get("recurId");
|
||||
|
||||
# Set the new recurrence pattern
|
||||
if (%recurrence_new) {
|
||||
my $new_id = $self->setRecurrence(\%recurrence_new);
|
||||
return ["There is something wrong with your recurrence pattern."]
|
||||
unless $new_id;
|
||||
|
||||
if (! $new_id) {
|
||||
$activeVersionTag->setWorking
|
||||
if $activeVersionTag;
|
||||
return ["There is something wrong with your recurrence pattern."];
|
||||
}
|
||||
|
||||
# Generate the new recurring events
|
||||
$self->generateRecurringEvents();
|
||||
}
|
||||
|
|
@ -1649,7 +1665,7 @@ sub processPropertiesFromFormPost {
|
|||
# TODO: Give users a form property to decide what events to update
|
||||
# TODO: Make a workflow activity to do this, so that updating
|
||||
# 1 million events doesn't kill the server.
|
||||
# Just update related events
|
||||
# Just update related events
|
||||
my %properties = %{ $self->get };
|
||||
delete $properties{startDate};
|
||||
delete $properties{endDate};
|
||||
|
|
@ -1663,23 +1679,21 @@ sub processPropertiesFromFormPost {
|
|||
});
|
||||
|
||||
for my $eventId (@{$events}) {
|
||||
my $event = WebGUI::Asset->newByDynamicClass($session,$eventId);
|
||||
my $event = WebGUI::Asset->newByDynamicClass($session, $eventId);
|
||||
|
||||
# Add a revision
|
||||
$properties{ startDate } = $event->get("startDate");
|
||||
$properties{ endDate } = $event->get("endDate");
|
||||
|
||||
# addRevision returns the new revision
|
||||
$event = $event->addRevision(\%properties);
|
||||
$event->requestAutoCommit();
|
||||
$event = $event->addRevision(\%properties, undef, { skipAutoCommitWorkflows => 1 });
|
||||
}
|
||||
}
|
||||
}
|
||||
$activeVersionTag->setWorking
|
||||
if $activeVersionTag;
|
||||
|
||||
# Finally, commit this event
|
||||
delete $self->{_storageLocation};
|
||||
$self->requestAutoCommit;
|
||||
|
||||
return undef;
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -281,7 +281,12 @@ Returns the workflowId of the Gallery's approval workflow.
|
|||
|
||||
sub getAutoCommitWorkflowId {
|
||||
my $self = shift;
|
||||
return $self->getGallery->get("workflowIdCommit");
|
||||
my $gallery = $self->getGallery;
|
||||
if ($gallery->hasBeenCommitted) {
|
||||
return $gallery->get("workflowIdCommit")
|
||||
|| $self->session->setting->get('defaultVersionTagWorkflow');
|
||||
}
|
||||
return undef;
|
||||
}
|
||||
|
||||
#----------------------------------------------------------------------------
|
||||
|
|
@ -683,8 +688,6 @@ sub processPropertiesFromFormPost {
|
|||
} );
|
||||
}
|
||||
|
||||
$self->requestAutoCommit;
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -195,25 +195,13 @@ sub editSave {
|
|||
}
|
||||
$tempStorage->delete;
|
||||
|
||||
# deal with special commit rules
|
||||
if ($self->session->form->process("saveAndCommit") ne "") {
|
||||
if ($self->session->setting->get("skipCommitComments")) {
|
||||
$self->session->http->setRedirect($self->getUrl("op=commitVersionTagConfirm;tagId=".WebGUI::VersionTag->getWorking($self->session)->getId));
|
||||
}
|
||||
else {
|
||||
$self->session->http->setRedirect($self->getUrl("op=commitVersionTag;tagId=".WebGUI::VersionTag->getWorking($self->session)->getId));
|
||||
}
|
||||
return undef;
|
||||
}
|
||||
if ($self->session->setting->get("autoRequestCommit")) {
|
||||
if ($self->session->setting->get("skipCommitComments")) {
|
||||
WebGUI::VersionTag->getWorking($self->session)->requestCommit;
|
||||
}
|
||||
else {
|
||||
$self->session->http->setRedirect($self->getUrl("op=commitVersionTag;tagId=".WebGUI::VersionTag->getWorking($self->session)->getId));
|
||||
return undef;
|
||||
}
|
||||
}
|
||||
if (WebGUI::VersionTag->autoCommitWorkingIfEnabled($self->session, {
|
||||
override => scalar $self->session->form->process("saveAndCommit"),
|
||||
allowComments => 1,
|
||||
returnUrl => $self->getUrl,
|
||||
})) {
|
||||
return undef;
|
||||
};
|
||||
|
||||
return $self->getParent->www_manageAssets if ($self->session->form->process("proceed") eq "manageAssets");
|
||||
return $self->getParent->www_view;
|
||||
|
|
|
|||
|
|
@ -332,8 +332,13 @@ sub getContentLastModified {
|
|||
|
||||
#-------------------------------------------------------------------
|
||||
sub getAutoCommitWorkflowId {
|
||||
my $self = shift;
|
||||
return $self->getThread->getParent->get("approvalWorkflow");
|
||||
my $self = shift;
|
||||
my $cs = $self->getThread->getParent;
|
||||
if ($cs->hasBeenCommitted) {
|
||||
return $cs->get('approvalWorkflow')
|
||||
|| $self->session->setting->get('defaultVersionTagWorkflow');
|
||||
}
|
||||
return undef;
|
||||
}
|
||||
|
||||
#-------------------------------------------------------------------
|
||||
|
|
@ -879,7 +884,6 @@ sub postProcess {
|
|||
$size += $storage->getFileSize($file);
|
||||
}
|
||||
$self->setSize($size);
|
||||
$self->requestAutoCommit;
|
||||
}
|
||||
|
||||
#-------------------------------------------------------------------
|
||||
|
|
|
|||
|
|
@ -582,6 +582,14 @@ sub postProcess {
|
|||
$self->SUPER::postProcess;
|
||||
}
|
||||
|
||||
sub processPropertiesFromFormPost {
|
||||
my $self = shift;
|
||||
if ($self->isNew && $self->getParent->getValue('useCaptcha')) {
|
||||
my $captcha = $self->session->form->process("captcha","Captcha");
|
||||
return [ 'invalid captcha' ];
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
#-------------------------------------------------------------------
|
||||
sub purge {
|
||||
|
|
|
|||
|
|
@ -467,10 +467,7 @@ sub www_editDuplicate {
|
|||
|
||||
# Auto-commit our revision if necessary
|
||||
# TODO: This needs to be handled automatically somehow...
|
||||
if ($session->setting->get("autoRequestCommit")) {
|
||||
my $tag = WebGUI::VersionTag->getWorking($session)->requestCommit;
|
||||
}
|
||||
|
||||
WebGUI::VersionTag->autoCommitWorkingIfEnabled($self->session);
|
||||
last DEF;
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -117,7 +117,12 @@ sub definition {
|
|||
#-------------------------------------------------------------------
|
||||
sub getAutoCommitWorkflowId {
|
||||
my $self = shift;
|
||||
return $self->getWiki->get("approvalWorkflow");
|
||||
my $wiki = $self->getWiki;
|
||||
if ($wiki->hasBeenCommitted) {
|
||||
return $wiki->get('approvalWorkflow')
|
||||
|| $self->session->setting->get('defaultVersionTagWorkflow');
|
||||
}
|
||||
return undef;
|
||||
}
|
||||
|
||||
|
||||
|
|
@ -266,9 +271,7 @@ sub processPropertiesFromFormPost {
|
|||
}
|
||||
}
|
||||
|
||||
# wiki pages are auto committed
|
||||
$self->requestAutoCommit;
|
||||
}
|
||||
}
|
||||
|
||||
#-------------------------------------------------------------------
|
||||
|
||||
|
|
|
|||
|
|
@ -425,7 +425,7 @@ sub canAddEvent {
|
|||
: $self->session->user
|
||||
;
|
||||
|
||||
return 1 if (
|
||||
return 1 if (
|
||||
$user->isInGroup( $self->get("groupIdEventEdit") )
|
||||
);
|
||||
}
|
||||
|
|
@ -1755,26 +1755,6 @@ sub wrapIcal {
|
|||
return join "\r\n ",@text;
|
||||
}
|
||||
|
||||
#-------------------------------------------------------------------
|
||||
|
||||
=head2 www_add ( )
|
||||
|
||||
Returns an error message if the collaboration system has not yet been posted.
|
||||
|
||||
=cut
|
||||
|
||||
sub www_add {
|
||||
my $self = shift;
|
||||
|
||||
#Check to see if the asset has been committed
|
||||
unless ($self->hasBeenCommitted ) {
|
||||
my $i18n = WebGUI::International->new($self->session,"Asset_Calendar");
|
||||
return $self->processStyle($i18n->get("asset not committed"));
|
||||
}
|
||||
return $self->SUPER::www_add( @_ );
|
||||
}
|
||||
|
||||
|
||||
#----------------------------------------------------------------------------
|
||||
|
||||
=head2 www_edit ( )
|
||||
|
|
|
|||
|
|
@ -1388,55 +1388,6 @@ sub view {
|
|||
|
||||
#-------------------------------------------------------------------
|
||||
|
||||
=head2 www_add ( )
|
||||
|
||||
Returns an error message if the collaboration system has not yet been posted.
|
||||
|
||||
=cut
|
||||
|
||||
sub www_add {
|
||||
my $self = shift;
|
||||
|
||||
#Check to see if the asset has been committed
|
||||
unless ( $self->hasBeenCommitted ) {
|
||||
my $i18n = WebGUI::International->new($self->session,"Asset_Collaboration");
|
||||
return $self->processStyle($i18n->get("asset not committed"));
|
||||
}
|
||||
return $self->SUPER::www_add( @_ );
|
||||
}
|
||||
|
||||
|
||||
#-------------------------------------------------------------------
|
||||
|
||||
=head2 www_editSave ( )
|
||||
|
||||
We're extending www_editSave() here to deal with editing a post that has been denied by the approval process. Our change will reassign the old working tag of this post to the user so that they can edit it.
|
||||
|
||||
=cut
|
||||
|
||||
sub www_editSave {
|
||||
my $self = shift;
|
||||
my $session = $self->session;
|
||||
|
||||
my $className = $session->form->param("class");
|
||||
|
||||
#my $assetId = $self->session->form->param("assetId");
|
||||
if($className eq "WebGUI::Asset::Post::Thread") {
|
||||
my $assetId = $session->form->param("assetId");
|
||||
|
||||
if($assetId eq "new" && $self->getValue("useCaptcha")) {
|
||||
my $captcha = $self->session->form->process("captcha","Captcha");
|
||||
unless ($captcha) {
|
||||
return $self->www_add;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return $self->SUPER::www_editSave();
|
||||
}
|
||||
|
||||
#-------------------------------------------------------------------
|
||||
|
||||
=head2 www_search ( )
|
||||
|
||||
The web method to display and use the forum search interface.
|
||||
|
|
|
|||
|
|
@ -361,7 +361,12 @@ Returns the workflowId of the Gallery's approval workflow.
|
|||
|
||||
sub getAutoCommitWorkflowId {
|
||||
my $self = shift;
|
||||
return $self->getParent->get("workflowIdCommit");
|
||||
my $gallery = $self->getParent;
|
||||
if ($gallery->hasBeenCommitted) {
|
||||
return $gallery->get("workflowIdCommit")
|
||||
|| $self->session->setting->get('defaultVersionTagWorkflow');
|
||||
}
|
||||
return undef;
|
||||
}
|
||||
|
||||
#----------------------------------------------------------------------------
|
||||
|
|
@ -708,8 +713,6 @@ sub processPropertiesFromFormPost {
|
|||
return $errors if @$errors;
|
||||
|
||||
### Passes all checks
|
||||
|
||||
$self->requestAutoCommit;
|
||||
}
|
||||
|
||||
#----------------------------------------------------------------------------
|
||||
|
|
|
|||
|
|
@ -303,9 +303,7 @@ sub www_setContentPositions {
|
|||
$self->addRevision({
|
||||
contentPositions=>$self->session->form->process("map")
|
||||
});
|
||||
if ($self->session->setting->get("autoRequestCommit")) {
|
||||
WebGUI::VersionTag->getWorking($self->session)->requestCommit;
|
||||
}
|
||||
WebGUI::VersionTag->autoCommitWorkingIfEnabled($self->session);
|
||||
return "Map set: ".$self->session->form->process("map");
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -385,21 +385,12 @@ sub www_importProducts {
|
|||
}
|
||||
else {
|
||||
$status_message = $i18n->get('import successful');
|
||||
##Copy and paste from WebGUI::Asset, www_editSave
|
||||
if ($self->session->setting->get("autoRequestCommit")) {
|
||||
# Make sure version tag hasn't already been committed by another process
|
||||
my $versionTag = WebGUI::VersionTag->getWorking($self->session, "nocreate");
|
||||
|
||||
if ($versionTag && $self->session->setting->get("skipCommitComments")) {
|
||||
$versionTag->requestCommit;
|
||||
}
|
||||
elsif ($versionTag) {
|
||||
$self->session->http->setRedirect(
|
||||
$self->getUrl("op=commitVersionTag;tagId=".WebGUI::VersionTag->getWorking($self->session)->getId)
|
||||
);
|
||||
return undef;
|
||||
}
|
||||
}
|
||||
if (WebGUI::VersionTag->autoCommitWorkingIfEnabled($self->session, {
|
||||
allowComments => 1,
|
||||
returnUrl => $self->getUrl,
|
||||
})) {
|
||||
return undef;
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -392,26 +392,6 @@ sub view {
|
|||
return $self->processTemplate($var, undef, $template);
|
||||
}
|
||||
|
||||
#-------------------------------------------------------------------
|
||||
|
||||
=head2 www_add ( )
|
||||
|
||||
Returns an error message if the collaboration system has not yet been posted.
|
||||
|
||||
=cut
|
||||
|
||||
sub www_add {
|
||||
my $self = shift;
|
||||
|
||||
#Check to see if the asset has been committed
|
||||
unless ($self->hasBeenCommitted ) {
|
||||
my $i18n = WebGUI::International->new($self->session,"Asset_WikiMaster");
|
||||
return $self->processStyle($i18n->get("asset not committed"));
|
||||
}
|
||||
return $self->SUPER::www_add( @_ );
|
||||
}
|
||||
|
||||
|
||||
|
||||
#-------------------------------------------------------------------
|
||||
sub www_byKeyword {
|
||||
|
|
|
|||
|
|
@ -304,14 +304,12 @@ sub www_editBranchSave {
|
|||
}
|
||||
}
|
||||
}
|
||||
if ($self->session->setting->get("autoRequestCommit")) {
|
||||
if ($self->session->setting->get("skipCommitComments")) {
|
||||
WebGUI::VersionTag->getWorking($self->session)->requestCommit;
|
||||
} else {
|
||||
$self->session->http->setRedirect($self->getUrl("op=commitVersionTag;tagId=".WebGUI::VersionTag->getWorking($self->session)->getId));
|
||||
return undef;
|
||||
}
|
||||
}
|
||||
if (WebGUI::VersionTag->autoCommitWorkingIfEnabled($self->session, {
|
||||
allowComments => 1,
|
||||
returnUrl => $self->getUrl,
|
||||
})) {
|
||||
return undef;
|
||||
};
|
||||
delete $self->{_parent};
|
||||
$self->session->asset($self->getParent);
|
||||
return $self->getParent->www_manageAssets;
|
||||
|
|
|
|||
|
|
@ -219,16 +219,12 @@ sub www_copy {
|
|||
my $i18n = WebGUI::International->new($self->session, 'Asset');
|
||||
$newAsset->update({ title=>sprintf("%s (%s)",$self->getTitle,$i18n->get('copy'))});
|
||||
$newAsset->cut;
|
||||
if ($self->session->setting->get("autoRequestCommit")) {
|
||||
if ($self->session->setting->get("skipCommitComments")) {
|
||||
WebGUI::VersionTag->getWorking($self->session)->requestCommit;
|
||||
} else {
|
||||
$self->session->http->setRedirect($self->getUrl(
|
||||
"op=commitVersionTag;tagId=".WebGUI::VersionTag->getWorking($self->session)->getId
|
||||
));
|
||||
return undef;
|
||||
}
|
||||
}
|
||||
if (WebGUI::VersionTag->autoCommitWorkingIfEnabled($self->session, {
|
||||
allowComments => 1,
|
||||
returnUrl => $self->getUrl,
|
||||
})) {
|
||||
return undef;
|
||||
};
|
||||
return $self->session->asset($self->getContainer)->www_view;
|
||||
}
|
||||
|
||||
|
|
@ -287,17 +283,14 @@ sub www_createShortcut {
|
|||
if (! $isOnDashboard) {
|
||||
$child->cut;
|
||||
}
|
||||
if ($self->session->setting->get("autoRequestCommit")) {
|
||||
if ($self->session->setting->get("skipCommitComments")) {
|
||||
WebGUI::VersionTag->getWorking($self->session)->requestCommit;
|
||||
} else {
|
||||
$self->session->http->setRedirect($self->getUrl(
|
||||
"op=commitVersionTag;tagId=".WebGUI::VersionTag->getWorking($self->session)->getId
|
||||
));
|
||||
return 1;
|
||||
}
|
||||
}
|
||||
if ($isOnDashboard) {
|
||||
if (WebGUI::VersionTag->autoCommitWorkingIfEnabled($self->session, {
|
||||
allowComments => 1,
|
||||
returnUrl => $self->getUrl,
|
||||
})) {
|
||||
return undef;
|
||||
};
|
||||
|
||||
if ($isOnDashboard) {
|
||||
return $self->getParent->www_view;
|
||||
} else {
|
||||
$self->session->asset($self->getContainer);
|
||||
|
|
|
|||
|
|
@ -336,15 +336,12 @@ sub www_importPackage {
|
|||
}
|
||||
}
|
||||
# Handle autocommit workflows
|
||||
if ($self->session->setting->get("autoRequestCommit")) {
|
||||
if ($self->session->setting->get("skipCommitComments")) {
|
||||
WebGUI::VersionTag->getWorking($self->session)->requestCommit;
|
||||
}
|
||||
else {
|
||||
$self->session->http->setRedirect($self->getUrl("op=commitVersionTag;tagId=".WebGUI::VersionTag->getWorking($self->session)->getId));
|
||||
return undef;
|
||||
}
|
||||
}
|
||||
if (WebGUI::VersionTag->autoCommitWorkingIfEnabled($self->session, {
|
||||
allowComments => 1,
|
||||
returnUrl => $self->getUrl,
|
||||
})) {
|
||||
return undef;
|
||||
};
|
||||
|
||||
return $self->www_manageAssets();
|
||||
}
|
||||
|
|
|
|||
|
|
@ -371,21 +371,13 @@ sub www_manage {
|
|||
}
|
||||
}
|
||||
|
||||
# Handle Auto Request Commit setting
|
||||
if ($session->setting->get("autoRequestCommit")) {
|
||||
# Make sure version tag hasn't already been committed by another process
|
||||
my $versionTag = WebGUI::VersionTag->getWorking($session, "nocreate");
|
||||
|
||||
if ($versionTag && $session->setting->get("skipCommitComments")) {
|
||||
$versionTag->requestCommit;
|
||||
}
|
||||
elsif ($versionTag) {
|
||||
$session->http->setRedirect(
|
||||
$currentAsset->getUrl("op=commitVersionTag;tagId=".WebGUI::VersionTag->getWorking($session)->getId)
|
||||
);
|
||||
return undef;
|
||||
}
|
||||
}
|
||||
# Handle autocommit workflows
|
||||
if (WebGUI::VersionTag->autoCommitWorkingIfEnabled($session, {
|
||||
allowComments => 1,
|
||||
returnUrl => $currentAsset->getUrl,
|
||||
})) {
|
||||
return undef;
|
||||
};
|
||||
|
||||
# Show the page
|
||||
# i18n we'll need later
|
||||
|
|
|
|||
|
|
@ -315,9 +315,7 @@ sub www_upload {
|
|||
$asset->getStorageLocation->addFileFromFilesystem($storage->getPath($filename));
|
||||
$asset->applyConstraints;
|
||||
push(@assetIds, $asset->getId);
|
||||
if ($session->setting->get("autoRequestCommit")) {
|
||||
WebGUI::VersionTag->getWorking($session)->requestCommit;
|
||||
}
|
||||
WebGUI::VersionTag->autoCommitWorkingIfEnabled($session);
|
||||
$storage->delete;
|
||||
return www_show($session, \@assetIds);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -37,6 +37,60 @@ These methods are available from this class:
|
|||
=cut
|
||||
|
||||
|
||||
#-------------------------------------------------------------------
|
||||
|
||||
=head2 autoCommitWorkingIfEnabled ( $session, $options )
|
||||
|
||||
A class method that automatically commits the working version tag if auto commit is
|
||||
enabled. Returns true if the version tag was committed.
|
||||
|
||||
=head3 $options
|
||||
|
||||
Hashref with options for how to do auto commit
|
||||
|
||||
=head4 override
|
||||
|
||||
Do autocommit even if not enabled for the site
|
||||
|
||||
=head4 allowComments
|
||||
|
||||
Whether to allow comments to be added. If enabled, instead of
|
||||
committing directly, will set a redirect for the user to enter
|
||||
a comment.
|
||||
|
||||
=head4 returnUrl
|
||||
|
||||
If allowComments is enabled, the URL to return to after committing
|
||||
|
||||
=cut
|
||||
|
||||
sub autoCommitWorkingIfEnabled {
|
||||
my $class = shift;
|
||||
my $session = shift;
|
||||
my $options = shift || {};
|
||||
# need a version tag to do any auto commit
|
||||
my $versionTag = $class->getWorking($session, "nocreate");
|
||||
return
|
||||
unless $versionTag;
|
||||
# auto commit assets
|
||||
# save and commit button and site wide auto commit work the same
|
||||
if (
|
||||
$options->{override}
|
||||
|| $session->setting->get("autoRequestCommit")
|
||||
) {
|
||||
if ($session->setting->get("skipCommitComments") || !$options->{allowComments}) {
|
||||
$versionTag->requestCommit;
|
||||
return 1;
|
||||
}
|
||||
else {
|
||||
my $url = $options->{returnUrl} || $session->url->page;
|
||||
$url = $session->url->append($url, "op=commitVersionTag;tagId=" . $versionTag->getId);
|
||||
$session->http->setRedirect($url);
|
||||
return 1;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#-------------------------------------------------------------------
|
||||
|
||||
=head2 clearWorking ( )
|
||||
|
|
|
|||
|
|
@ -25,7 +25,7 @@ use WebGUI::DateTime;
|
|||
use DateTime::TimeZone;
|
||||
|
||||
use LWP::UserAgent;
|
||||
use JSON qw(encode_json decode_json);
|
||||
use JSON ();
|
||||
|
||||
=head1 NAME
|
||||
|
||||
|
|
@ -91,8 +91,8 @@ sub execute {
|
|||
my $eventList = [];
|
||||
my $feedList;
|
||||
if ($instance->getScratch('events')) {
|
||||
$eventList = decode_json($instance->getScratch('events'));
|
||||
$feedList = decode_json($instance->getScratch('feeds'));
|
||||
$eventList = JSON::from_json($instance->getScratch('events'));
|
||||
$feedList = JSON::from_json($instance->getScratch('feeds'));
|
||||
}
|
||||
else {
|
||||
my $ua = LWP::UserAgent->new(agent => "WebGUI");
|
||||
|
|
@ -353,11 +353,22 @@ sub execute {
|
|||
}
|
||||
}
|
||||
}
|
||||
my $currentVersionTag = WebGUI::VersionTag->getWorking($self->session, 1);
|
||||
if ($currentVersionTag) {
|
||||
$currentVersionTag->clearWorking;
|
||||
}
|
||||
my $ttl = $self->getTTL;
|
||||
while (@$eventList) {
|
||||
if ($startTime + $ttl < time()) {
|
||||
$instance->setScratch('events', encode_json($eventList));
|
||||
$instance->setScratch('feeds', encode_json($feedList));
|
||||
$instance->setScratch('events', JSON::to_json($eventList));
|
||||
$instance->setScratch('feeds', JSON::to_json($feedList));
|
||||
my $newVersionTag = WebGUI::VersionTag->getWorking($self->session, 1);
|
||||
if ($newVersionTag) {
|
||||
$newVersionTag->requestCommit;
|
||||
}
|
||||
if ($currentVersionTag) {
|
||||
$currentVersionTag->setWorking;
|
||||
}
|
||||
return $self->WAITING;
|
||||
}
|
||||
my $eventData = shift @$eventList;
|
||||
|
|
@ -376,7 +387,6 @@ sub execute {
|
|||
|
||||
if ($event) {
|
||||
$event->update($properties);
|
||||
$event->requestAutoCommit;
|
||||
$feed->{updated}++;
|
||||
}
|
||||
}
|
||||
|
|
@ -384,10 +394,16 @@ sub execute {
|
|||
my $calendar = WebGUI::Asset->newByDynamicClass($self->session,$feed->{assetId});
|
||||
if (!defined $calendar) {
|
||||
$self->session->errorHandler->error("CalendarUpdateFeeds Activity: Calendar object failed to instanciate. Did you commit the calendar wobject?");
|
||||
my $newVersionTag = WebGUI::VersionTag->getWorking($self->session, 1);
|
||||
if ($newVersionTag) {
|
||||
$newVersionTag->requestCommit;
|
||||
}
|
||||
if ($currentVersionTag) {
|
||||
$currentVersionTag->setWorking;
|
||||
}
|
||||
return $self->ERROR;
|
||||
}
|
||||
my $event = $calendar->addChild($properties);
|
||||
$event->requestAutoCommit;
|
||||
my $event = $calendar->addChild($properties, { skipAutoCommitWorkflows => 1});
|
||||
$feed->{added}++;
|
||||
if ($recur) {
|
||||
$event->setRecurrence($recur);
|
||||
|
|
@ -398,6 +414,13 @@ sub execute {
|
|||
# TODO: Only update if last-updated field is
|
||||
# greater than the event's lastUpdated property
|
||||
}
|
||||
my $newVersionTag = WebGUI::VersionTag->getWorking($self->session, 1);
|
||||
if ($newVersionTag) {
|
||||
$newVersionTag->requestCommit;
|
||||
}
|
||||
if ($currentVersionTag) {
|
||||
$currentVersionTag->setWorking;
|
||||
}
|
||||
for my $feedId (keys %$feedList) {
|
||||
my $feed = $feedList->{$feedId};
|
||||
$self->session->db->write("update Calendar_feeds set lastResult=?,lastUpdated=? where feedId=?",
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue