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
|
|
@ -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 ( )
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue