fixing versioning bugs
This commit is contained in:
parent
6c16aa1577
commit
7eef970cd1
8 changed files with 78 additions and 31 deletions
|
|
@ -293,7 +293,15 @@ sub addAssetVersioning {
|
||||||
foreach my $field (qw(url groupIdView title menuTitle startDate endDate ownerUserId groupIdEdit synopsis newWindow isHidden isSystem encryptPage assetSize lastUpdated lastUpdatedBy isPackage extraHeadTags isPrototype)) {
|
foreach my $field (qw(url groupIdView title menuTitle startDate endDate ownerUserId groupIdEdit synopsis newWindow isHidden isSystem encryptPage assetSize lastUpdated lastUpdatedBy isPackage extraHeadTags isPrototype)) {
|
||||||
WebGUI::SQL->write("alter table asset drop column $field");
|
WebGUI::SQL->write("alter table asset drop column $field");
|
||||||
}
|
}
|
||||||
|
# clean up the psuedo version tracking in files
|
||||||
|
$sth = WebGUI::SQL->read("select olderVersions from FileAsset");
|
||||||
|
while (my ($old) = $sth->array) {
|
||||||
|
foreach my $storageId (split("\n",$old)) {
|
||||||
|
WebGUI::Storage->get($storageId)->delete;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
$sth->finish;
|
||||||
|
WebGUI::SQL->write("alter table FileAsset drop column olderVersions");
|
||||||
}
|
}
|
||||||
|
|
||||||
#-------------------------------------------------
|
#-------------------------------------------------
|
||||||
|
|
|
||||||
|
|
@ -795,6 +795,8 @@ sub getToolbar {
|
||||||
my $toolbar = deleteIcon('func=delete',$self->get("url"),WebGUI::International::get(43,"Asset"));
|
my $toolbar = deleteIcon('func=delete',$self->get("url"),WebGUI::International::get(43,"Asset"));
|
||||||
if (!$self->isLocked || $self->get("isLockedBy") eq $session{user}{userId}) {
|
if (!$self->isLocked || $self->get("isLockedBy") eq $session{user}{userId}) {
|
||||||
$toolbar .= editIcon('func=edit',$self->get("url"));
|
$toolbar .= editIcon('func=edit',$self->get("url"));
|
||||||
|
} else {
|
||||||
|
$toolbar .= lockedIcon('func=manageRevisions',$self->get("url"));
|
||||||
}
|
}
|
||||||
$toolbar .= cutIcon('func=cut',$self->get("url"))
|
$toolbar .= cutIcon('func=cut',$self->get("url"))
|
||||||
.copyIcon('func=copy',$self->get("url"));
|
.copyIcon('func=copy',$self->get("url"));
|
||||||
|
|
@ -1439,11 +1441,11 @@ sub www_manageAssets {
|
||||||
my $locked;
|
my $locked;
|
||||||
my $edit;
|
my $edit;
|
||||||
if ($child->isLocked) {
|
if ($child->isLocked) {
|
||||||
$locked = WebGUI::International::get("138");
|
$locked = '<img src="'.$session{config}{extrasURL}.'/adminConsole/locked.gif" alt="locked" border="0" />';
|
||||||
$edit = "'<a href=\"".$child->getUrl("func=edit&proceed=manageAssets")."\">Edit</a> | '+" if ($child->get("isLockedBy") eq $session{user}{userId});
|
$edit = "'<a href=\"".$child->getUrl("func=edit&proceed=manageAssets")."\">Edit</a> | '+" if ($child->get("isLockedBy") eq $session{user}{userId});
|
||||||
} else {
|
} else {
|
||||||
$edit = "'<a href=\"".$child->getUrl("func=edit&proceed=manageAssets")."\">Edit</a> | '+";
|
$edit = "'<a href=\"".$child->getUrl("func=edit&proceed=manageAssets")."\">Edit</a> | '+";
|
||||||
$locked = WebGUI::International::get("139");
|
$locked = '<img src="'.$session{config}{extrasURL}.'/adminConsole/unlocked.gif" alt="unlocked" border="0" />';
|
||||||
}
|
}
|
||||||
$output .= "assetManager.AddLine('"
|
$output .= "assetManager.AddLine('"
|
||||||
.WebGUI::Form::checkbox({
|
.WebGUI::Form::checkbox({
|
||||||
|
|
@ -1457,7 +1459,7 @@ sub www_manageAssets {
|
||||||
."','".WebGUI::DateTime::epochToHuman($child->get("revisionDate"))
|
."','".WebGUI::DateTime::epochToHuman($child->get("revisionDate"))
|
||||||
."','".formatBytes($child->get("assetSize"))."','<a href=\"".$child->getUrl("func=manageRevisions")."\">".$locked."</a>');\n";
|
."','".formatBytes($child->get("assetSize"))."','<a href=\"".$child->getUrl("func=manageRevisions")."\">".$locked."</a>');\n";
|
||||||
$output .= "assetManager.AddLineSortData('','','','".$title."','".$child->getName
|
$output .= "assetManager.AddLineSortData('','','','".$title."','".$child->getName
|
||||||
."','".$child->get("revisionDate")."','".$child->get("assetSize")."','".$locked."');
|
."','".$child->get("revisionDate")."','".$child->get("assetSize")."','');
|
||||||
assetManager.addAssetMetaData('".$child->getUrl."', '".$child->getRank."', '".$title."');\n";
|
assetManager.addAssetMetaData('".$child->getUrl."', '".$child->getRank."', '".$title."');\n";
|
||||||
}
|
}
|
||||||
$output .= '
|
$output .= '
|
||||||
|
|
|
||||||
|
|
@ -44,6 +44,24 @@ These methods are available from this class:
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
#-------------------------------------------------------------------
|
||||||
|
|
||||||
|
=head2 addRevision
|
||||||
|
|
||||||
|
Override the default method in order to deal with attachments.
|
||||||
|
|
||||||
|
=cut
|
||||||
|
|
||||||
|
sub addRevision {
|
||||||
|
my $self = shift;
|
||||||
|
my $newSelf = $self->addRevision(@_);
|
||||||
|
if ($self->get("storageId")) {
|
||||||
|
my $newStorage = WebGUI::Storage->get($self->get("storageId"))->copy;
|
||||||
|
$newSelf->update({storageId=>$newStorage->getId});
|
||||||
|
}
|
||||||
|
return $newSelf;
|
||||||
|
}
|
||||||
|
|
||||||
#-------------------------------------------------------------------
|
#-------------------------------------------------------------------
|
||||||
|
|
||||||
=head2 definition ( definition )
|
=head2 definition ( definition )
|
||||||
|
|
@ -74,11 +92,6 @@ sub definition {
|
||||||
fieldType=>'hidden',
|
fieldType=>'hidden',
|
||||||
defaultValue=>undef
|
defaultValue=>undef
|
||||||
},
|
},
|
||||||
olderVersions=>{
|
|
||||||
noFormPost=>1,
|
|
||||||
fieldType=>'hidden',
|
|
||||||
defaultValue=>undef
|
|
||||||
},
|
|
||||||
templateId=>{
|
templateId=>{
|
||||||
fieldType=>'template',
|
fieldType=>'template',
|
||||||
defaultValue=>'PBtmpl0000000000000024'
|
defaultValue=>'PBtmpl0000000000000024'
|
||||||
|
|
@ -95,7 +108,7 @@ sub duplicate {
|
||||||
my $self = shift;
|
my $self = shift;
|
||||||
my $newAsset = $self->SUPER::duplicate(shift);
|
my $newAsset = $self->SUPER::duplicate(shift);
|
||||||
my $newStorage = $self->getStorageLocation->copy;
|
my $newStorage = $self->getStorageLocation->copy;
|
||||||
$newAsset->update({storageId=>$newStorage->getId,olderVersions=>''});
|
$newAsset->update({storageId=>$newStorage->getId});
|
||||||
return $newAsset;
|
return $newAsset;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -182,54 +195,49 @@ sub getStorageLocation {
|
||||||
sub processPropertiesFromFormPost {
|
sub processPropertiesFromFormPost {
|
||||||
my $self = shift;
|
my $self = shift;
|
||||||
$self->SUPER::processPropertiesFromFormPost;
|
$self->SUPER::processPropertiesFromFormPost;
|
||||||
# might have to create a new storage location for versioning
|
my $storage = $self->getStorageLocation;
|
||||||
my $storage = ($self->get("storageId") eq "") ? $self->getStorageLocation : $self->getStorageLocation->create;
|
|
||||||
my $filename = $storage->addFileFromFormPost("file");
|
my $filename = $storage->addFileFromFormPost("file");
|
||||||
if (defined $filename) {
|
if (defined $filename) {
|
||||||
my $oldVersions = $self->get("olderVersions");
|
|
||||||
if ($self->get("filename")) { # do file versioning
|
|
||||||
$oldVersions .= "\n".$self->get("storageId")."|".$self->get("filename");
|
|
||||||
}
|
|
||||||
my %data;
|
my %data;
|
||||||
$data{filename} = $filename;
|
$data{filename} = $filename;
|
||||||
$data{storageId} = $storage->getId;
|
$data{storageId} = $storage->getId;
|
||||||
$data{olderVersions} = $oldVersions;
|
|
||||||
$data{title} = $filename unless ($session{form}{title});
|
$data{title} = $filename unless ($session{form}{title});
|
||||||
$data{menuTitle} = $filename unless ($session{form}{menuTitle});
|
$data{menuTitle} = $filename unless ($session{form}{menuTitle});
|
||||||
$data{url} = $self->getParent->get('url').'/'.$filename unless ($session{form}{url});
|
$data{url} = $self->getParent->get('url').'/'.$filename unless ($session{form}{url});
|
||||||
$self->update(\%data);
|
$self->update(\%data);
|
||||||
$self->setSize($storage->getFileSize($filename));
|
$self->setSize($storage->getFileSize($filename));
|
||||||
$self->{_storageLocation} = $storage;
|
$self->{_storageLocation} = $storage;
|
||||||
} else {
|
|
||||||
$storage->delete;
|
|
||||||
$self->getStorageLocation->setPrivileges($self->get("ownerUserId"), $self->get("groupIdView"), $self->get("groupIdEdit"));
|
|
||||||
}
|
}
|
||||||
|
$storage->setPrivileges($self->get("ownerUserId"), $self->get("groupIdView"), $self->get("groupIdEdit"));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
#-------------------------------------------------------------------
|
#-------------------------------------------------------------------
|
||||||
|
|
||||||
=head2 purge
|
|
||||||
|
|
||||||
=cut
|
|
||||||
|
|
||||||
sub purge {
|
sub purge {
|
||||||
my $self = shift;
|
my $self = shift;
|
||||||
my @old = split("\n",$self->get("olderVersions"));
|
my $sth = WebGUI::SQL->read("select storageId from FileAsset where assetId=".quote($self->getId));
|
||||||
foreach my $oldone (@old) {
|
while (my ($storageId) = $sth->array) {
|
||||||
my ($storageId, $filename) = split("|",$oldone);
|
WebGUI::Storage->get($storageId)->delete;
|
||||||
$self->getStorageLocation->delete;
|
|
||||||
}
|
}
|
||||||
$self->getStorageLocation->delete;
|
$sth->finish;
|
||||||
return $self->SUPER::purge;
|
return $self->SUPER::purge;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#-------------------------------------------------------------------
|
||||||
|
|
||||||
|
sub purgeRevision {
|
||||||
|
my $self = shift;
|
||||||
|
$self->getStorageLocation->delete;
|
||||||
|
return $self->SUPER::purgeRevision;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
#-------------------------------------------------------------------
|
#-------------------------------------------------------------------
|
||||||
|
|
||||||
=head2 update
|
=head2 update
|
||||||
|
|
||||||
We overload the update method from WebGUI::Asset in order to handle file system privileges.
|
We override the update method from WebGUI::Asset in order to handle file system privileges.
|
||||||
|
|
||||||
=cut
|
=cut
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -22,7 +22,7 @@ use WebGUI::URL;
|
||||||
|
|
||||||
our @ISA = qw(Exporter);
|
our @ISA = qw(Exporter);
|
||||||
our @EXPORT = qw(&helpIcon &becomeIcon &cutIcon ©Icon &deleteIcon &editIcon &manageIcon
|
our @EXPORT = qw(&helpIcon &becomeIcon &cutIcon ©Icon &deleteIcon &editIcon &manageIcon
|
||||||
&moveBottomIcon &moveDownIcon &moveLeftIcon &moveRightIcon &moveTopIcon &moveUpIcon
|
&moveBottomIcon &moveDownIcon &moveLeftIcon &moveRightIcon &moveTopIcon &moveUpIcon &lockedIcon
|
||||||
&pageIcon &dragIcon &shortcutIcon &pasteIcon &wobjectIcon &viewIcon &exportIcon);
|
&pageIcon &dragIcon &shortcutIcon &pasteIcon &wobjectIcon &viewIcon &exportIcon);
|
||||||
|
|
||||||
=head1 NAME
|
=head1 NAME
|
||||||
|
|
@ -276,6 +276,30 @@ sub helpIcon {
|
||||||
|
|
||||||
#-------------------------------------------------------------------
|
#-------------------------------------------------------------------
|
||||||
|
|
||||||
|
=head2 lockedIcon ( urlParameters [, pageURL ] )
|
||||||
|
|
||||||
|
Generates a button that represents a management function. Is toggled out in place of the edit icon when an asset is locked.
|
||||||
|
|
||||||
|
=head3 urlParameters
|
||||||
|
|
||||||
|
Any URL parameters that need to be tacked on to the current URL to accomplish whatever function this button represents.
|
||||||
|
|
||||||
|
=head3 pageURL
|
||||||
|
|
||||||
|
The URL to any page. Defaults to the current page.
|
||||||
|
|
||||||
|
=cut
|
||||||
|
|
||||||
|
sub lockedIcon {
|
||||||
|
my ($output, $pageURL);
|
||||||
|
$pageURL = $_[1] || $session{env}{PATH_INFO};
|
||||||
|
$output = '<a href="'.WebGUI::URL::gateway($pageURL,$_[0]).'">';
|
||||||
|
$output .= '<img src="'._getBaseURL().'locked.gif" align="middle" border="0" alt="'.WebGUI::International::get('locked','Icon').'" title="'.WebGUI::International::get('locked','Icon').'" /></a>';
|
||||||
|
return $output;
|
||||||
|
}
|
||||||
|
|
||||||
|
#-------------------------------------------------------------------
|
||||||
|
|
||||||
=head2 manageIcon ( urlParameters [, pageURL ] )
|
=head2 manageIcon ( urlParameters [, pageURL ] )
|
||||||
|
|
||||||
Generates a button that represents a management function.
|
Generates a button that represents a management function.
|
||||||
|
|
|
||||||
|
|
@ -1,6 +1,11 @@
|
||||||
package WebGUI::i18n::English::Icon;
|
package WebGUI::i18n::English::Icon;
|
||||||
|
|
||||||
our $I18N = {
|
our $I18N = {
|
||||||
|
'locked' => {
|
||||||
|
message => q|Locked|,
|
||||||
|
lastUpdated => 1096319549
|
||||||
|
},
|
||||||
|
|
||||||
'Move Up' => {
|
'Move Up' => {
|
||||||
message => q|Move Up|,
|
message => q|Move Up|,
|
||||||
lastUpdated => 1096319549
|
lastUpdated => 1096319549
|
||||||
|
|
|
||||||
BIN
www/extras/adminConsole/locked.gif
Normal file
BIN
www/extras/adminConsole/locked.gif
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 606 B |
BIN
www/extras/adminConsole/unlocked.gif
Normal file
BIN
www/extras/adminConsole/unlocked.gif
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 580 B |
BIN
www/extras/toolbar/metal/locked.gif
Normal file
BIN
www/extras/toolbar/metal/locked.gif
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 594 B |
Loading…
Add table
Add a link
Reference in a new issue