fixing versioning bugs

This commit is contained in:
JT Smith 2005-08-08 14:28:04 +00:00
parent 6c16aa1577
commit 7eef970cd1
8 changed files with 78 additions and 31 deletions

View file

@ -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)) {
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");
}
#-------------------------------------------------

View file

@ -795,6 +795,8 @@ sub getToolbar {
my $toolbar = deleteIcon('func=delete',$self->get("url"),WebGUI::International::get(43,"Asset"));
if (!$self->isLocked || $self->get("isLockedBy") eq $session{user}{userId}) {
$toolbar .= editIcon('func=edit',$self->get("url"));
} else {
$toolbar .= lockedIcon('func=manageRevisions',$self->get("url"));
}
$toolbar .= cutIcon('func=cut',$self->get("url"))
.copyIcon('func=copy',$self->get("url"));
@ -1439,11 +1441,11 @@ sub www_manageAssets {
my $locked;
my $edit;
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});
} else {
$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('"
.WebGUI::Form::checkbox({
@ -1457,7 +1459,7 @@ sub www_manageAssets {
."','".WebGUI::DateTime::epochToHuman($child->get("revisionDate"))
."','".formatBytes($child->get("assetSize"))."','<a href=\"".$child->getUrl("func=manageRevisions")."\">".$locked."</a>');\n";
$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";
}
$output .= '

View file

@ -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 )
@ -74,11 +92,6 @@ sub definition {
fieldType=>'hidden',
defaultValue=>undef
},
olderVersions=>{
noFormPost=>1,
fieldType=>'hidden',
defaultValue=>undef
},
templateId=>{
fieldType=>'template',
defaultValue=>'PBtmpl0000000000000024'
@ -95,7 +108,7 @@ sub duplicate {
my $self = shift;
my $newAsset = $self->SUPER::duplicate(shift);
my $newStorage = $self->getStorageLocation->copy;
$newAsset->update({storageId=>$newStorage->getId,olderVersions=>''});
$newAsset->update({storageId=>$newStorage->getId});
return $newAsset;
}
@ -182,54 +195,49 @@ sub getStorageLocation {
sub processPropertiesFromFormPost {
my $self = shift;
$self->SUPER::processPropertiesFromFormPost;
# might have to create a new storage location for versioning
my $storage = ($self->get("storageId") eq "") ? $self->getStorageLocation : $self->getStorageLocation->create;
my $storage = $self->getStorageLocation;
my $filename = $storage->addFileFromFormPost("file");
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;
$data{filename} = $filename;
$data{storageId} = $storage->getId;
$data{olderVersions} = $oldVersions;
$data{title} = $filename unless ($session{form}{title});
$data{menuTitle} = $filename unless ($session{form}{menuTitle});
$data{url} = $self->getParent->get('url').'/'.$filename unless ($session{form}{url});
$self->update(\%data);
$self->setSize($storage->getFileSize($filename));
$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 {
my $self = shift;
my @old = split("\n",$self->get("olderVersions"));
foreach my $oldone (@old) {
my ($storageId, $filename) = split("|",$oldone);
$self->getStorageLocation->delete;
my $sth = WebGUI::SQL->read("select storageId from FileAsset where assetId=".quote($self->getId));
while (my ($storageId) = $sth->array) {
WebGUI::Storage->get($storageId)->delete;
}
$self->getStorageLocation->delete;
$sth->finish;
return $self->SUPER::purge;
}
#-------------------------------------------------------------------
sub purgeRevision {
my $self = shift;
$self->getStorageLocation->delete;
return $self->SUPER::purgeRevision;
}
#-------------------------------------------------------------------
=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

View file

@ -22,7 +22,7 @@ use WebGUI::URL;
our @ISA = qw(Exporter);
our @EXPORT = qw(&helpIcon &becomeIcon &cutIcon &copyIcon &deleteIcon &editIcon &manageIcon
&moveBottomIcon &moveDownIcon &moveLeftIcon &moveRightIcon &moveTopIcon &moveUpIcon
&moveBottomIcon &moveDownIcon &moveLeftIcon &moveRightIcon &moveTopIcon &moveUpIcon &lockedIcon
&pageIcon &dragIcon &shortcutIcon &pasteIcon &wobjectIcon &viewIcon &exportIcon);
=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 ] )
Generates a button that represents a management function.

View file

@ -1,6 +1,11 @@
package WebGUI::i18n::English::Icon;
our $I18N = {
'locked' => {
message => q|Locked|,
lastUpdated => 1096319549
},
'Move Up' => {
message => q|Move Up|,
lastUpdated => 1096319549

Binary file not shown.

After

Width:  |  Height:  |  Size: 606 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 580 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 594 B