diff --git a/docs/upgrades/upgrade_6.6.5-6.7.0.pl b/docs/upgrades/upgrade_6.6.5-6.7.0.pl
index f0f7284ea..6127ef9b5 100644
--- a/docs/upgrades/upgrade_6.6.5-6.7.0.pl
+++ b/docs/upgrades/upgrade_6.6.5-6.7.0.pl
@@ -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");
}
#-------------------------------------------------
diff --git a/lib/WebGUI/Asset.pm b/lib/WebGUI/Asset.pm
index d8f086e7c..d075488b2 100644
--- a/lib/WebGUI/Asset.pm
+++ b/lib/WebGUI/Asset.pm
@@ -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 = '
';
$edit = "'getUrl("func=edit&proceed=manageAssets")."\">Edit | '+" if ($child->get("isLockedBy") eq $session{user}{userId});
} else {
$edit = "'getUrl("func=edit&proceed=manageAssets")."\">Edit | '+";
- $locked = WebGUI::International::get("139");
+ $locked = '
';
}
$output .= "assetManager.AddLine('"
.WebGUI::Form::checkbox({
@@ -1457,7 +1459,7 @@ sub www_manageAssets {
."','".WebGUI::DateTime::epochToHuman($child->get("revisionDate"))
."','".formatBytes($child->get("assetSize"))."','getUrl("func=manageRevisions")."\">".$locked."');\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 .= '
diff --git a/lib/WebGUI/Asset/File.pm b/lib/WebGUI/Asset/File.pm
index 33df19120..b4be37169 100644
--- a/lib/WebGUI/Asset/File.pm
+++ b/lib/WebGUI/Asset/File.pm
@@ -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
diff --git a/lib/WebGUI/Icon.pm b/lib/WebGUI/Icon.pm
index 8ab2f250a..fe1498eb9 100644
--- a/lib/WebGUI/Icon.pm
+++ b/lib/WebGUI/Icon.pm
@@ -22,7 +22,7 @@ use WebGUI::URL;
our @ISA = qw(Exporter);
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);
=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 = '';
+ $output .= '
';
+ return $output;
+}
+
+#-------------------------------------------------------------------
+
=head2 manageIcon ( urlParameters [, pageURL ] )
Generates a button that represents a management function.
diff --git a/lib/WebGUI/i18n/English/Icon.pm b/lib/WebGUI/i18n/English/Icon.pm
index 9092827fd..f6506d17f 100755
--- a/lib/WebGUI/i18n/English/Icon.pm
+++ b/lib/WebGUI/i18n/English/Icon.pm
@@ -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
diff --git a/www/extras/adminConsole/locked.gif b/www/extras/adminConsole/locked.gif
new file mode 100644
index 000000000..fc744f227
Binary files /dev/null and b/www/extras/adminConsole/locked.gif differ
diff --git a/www/extras/adminConsole/unlocked.gif b/www/extras/adminConsole/unlocked.gif
new file mode 100644
index 000000000..e4b8f7798
Binary files /dev/null and b/www/extras/adminConsole/unlocked.gif differ
diff --git a/www/extras/toolbar/metal/locked.gif b/www/extras/toolbar/metal/locked.gif
new file mode 100644
index 000000000..5878e431c
Binary files /dev/null and b/www/extras/toolbar/metal/locked.gif differ