added skipNotification flag to addRevision method
This commit is contained in:
parent
bca4e95cc2
commit
52e413ad71
1 changed files with 33 additions and 14 deletions
|
|
@ -70,29 +70,48 @@ A hash reference of options that change the behavior of this method.
|
||||||
|
|
||||||
If this is set to 1 then assets that would normally autocommit their workflow (like CS Posts) will instead add themselves to the normal working version tag.
|
If this is set to 1 then assets that would normally autocommit their workflow (like CS Posts) will instead add themselves to the normal working version tag.
|
||||||
|
|
||||||
|
=head4 skipNotification
|
||||||
|
|
||||||
|
If this is set to 1 then assets that normally send notifications will (like CS Posts) will know not to send them under certain conditions.
|
||||||
|
|
||||||
=cut
|
=cut
|
||||||
|
|
||||||
sub addRevision {
|
sub addRevision {
|
||||||
my $self = shift;
|
my $self = shift;
|
||||||
my $properties = shift;
|
my $properties = shift;
|
||||||
my $now = shift || $self->session->datetime->time();
|
my $now = shift || $self->session->datetime->time();
|
||||||
my $options = shift;
|
my $options = shift;
|
||||||
|
|
||||||
my $autoCommitId = $self->getAutoCommitWorkflowId() unless ($options->{skipAutoCommitWorkflows});
|
my $autoCommitId = $self->getAutoCommitWorkflowId() unless ($options->{skipAutoCommitWorkflows});
|
||||||
|
|
||||||
|
#Handle skip notifications
|
||||||
|
my $skipNotification = $options->{skipNotification} || 0;
|
||||||
|
$properties->{skipNotification} = $skipNotification;
|
||||||
|
|
||||||
my $workingTag
|
my $workingTag
|
||||||
= ($autoCommitId)
|
= ($autoCommitId)
|
||||||
? WebGUI::VersionTag->create($self->session, {groupToUse=>'12', workflowId=>$autoCommitId})
|
? WebGUI::VersionTag->create($self->session, {groupToUse=>'12', workflowId=>$autoCommitId})
|
||||||
: WebGUI::VersionTag->getWorking($self->session)
|
: WebGUI::VersionTag->getWorking($self->session)
|
||||||
;
|
;
|
||||||
|
|
||||||
$self->session->db->beginTransaction;
|
#Create a dummy revision to be updated with real data later
|
||||||
$self->session->db->write(
|
$self->session->db->beginTransaction;
|
||||||
"insert into assetData "
|
|
||||||
. "(assetId, revisionDate, revisedBy, tagId, status, url, ownerUserId, groupIdEdit, groupIdView) "
|
my $sql = "insert into assetData"
|
||||||
. "values (?, ?, ?, ?, 'pending', ?, '3','3','7')",
|
. " (assetId, revisionDate, revisedBy, tagId, status, url, ownerUserId, groupIdEdit, groupIdView, skipNotification)"
|
||||||
[$self->getId, $now, $self->session->user->userId, $workingTag->getId, $self->getId]
|
. " values (?, ?, ?, ?, 'pending', ?, '3','3','7',?)"
|
||||||
|
;
|
||||||
|
|
||||||
|
$self->session->db->write($sql,[
|
||||||
|
$self->getId,
|
||||||
|
$now,
|
||||||
|
$self->session->user->userId,
|
||||||
|
$workingTag->getId,
|
||||||
|
$self->getId,
|
||||||
|
$skipNotification,
|
||||||
|
]
|
||||||
);
|
);
|
||||||
|
|
||||||
foreach my $definition (@{$self->definition($self->session)}) {
|
foreach my $definition (@{$self->definition($self->session)}) {
|
||||||
unless ($definition->{tableName} eq "assetData") {
|
unless ($definition->{tableName} eq "assetData") {
|
||||||
$self->session->db->write(
|
$self->session->db->write(
|
||||||
|
|
@ -101,9 +120,9 @@ sub addRevision {
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
$self->session->db->commit;
|
$self->session->db->commit;
|
||||||
|
|
||||||
|
#Instantiate new revision and fill with real data
|
||||||
my $newVersion = WebGUI::Asset->new($self->session,$self->getId, $self->get("className"), $now);
|
my $newVersion = WebGUI::Asset->new($self->session,$self->getId, $self->get("className"), $now);
|
||||||
$newVersion->updateHistory("created revision");
|
$newVersion->updateHistory("created revision");
|
||||||
$newVersion->update($self->get);
|
$newVersion->update($self->get);
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue