From 7eef970cd1ba8331ff0391b2c4bc7249d6f2b6c8 Mon Sep 17 00:00:00 2001 From: JT Smith Date: Mon, 8 Aug 2005 14:28:04 +0000 Subject: [PATCH] fixing versioning bugs --- docs/upgrades/upgrade_6.6.5-6.7.0.pl | 10 ++++- lib/WebGUI/Asset.pm | 8 ++-- lib/WebGUI/Asset/File.pm | 60 +++++++++++++++------------ lib/WebGUI/Icon.pm | 26 +++++++++++- lib/WebGUI/i18n/English/Icon.pm | 5 +++ www/extras/adminConsole/locked.gif | Bin 0 -> 606 bytes www/extras/adminConsole/unlocked.gif | Bin 0 -> 580 bytes www/extras/toolbar/metal/locked.gif | Bin 0 -> 594 bytes 8 files changed, 78 insertions(+), 31 deletions(-) create mode 100644 www/extras/adminConsole/locked.gif create mode 100644 www/extras/adminConsole/unlocked.gif create mode 100644 www/extras/toolbar/metal/locked.gif 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 = '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 = 'unlocked'; } $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 .= ''.WebGUI::International::get('locked','Icon').''; + 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 0000000000000000000000000000000000000000..fc744f227eedc82bdaf24560944aa212da6b5508 GIT binary patch literal 606 zcmZ?wbhEHb6krfwcoxlY?%cWa=g(ifcya2~sRs@mC@wB;Y;3HruP-kzU$J7vh7B7g zOqg)^@Zm|5CbhP{aU|%{pHJ-w{G3q*Vi{=#*Djn?`CIbmz9;}=jSh4w5Xw>;nk~GVPRn_ zSFVhSi76^7YH4XvS65F-Nl8sj-Lz>FCnx9Y*RLl}p8W9P!|LklWy_X*`}Qp=D(cUl zKaU?j{`c=+US8hQr%yL-+}PCA)ZEXU|@_a^>U4kJqkUTf27c#EBDQV`J~% zzkl!Ez5V<5@7=q1&YU?@rc9}=t?lpcU$tu0mMvR4Iyw>(5)K_Ybmz{UoSd9BYu5b# z{~zd0x&g(XEQ|~c(F{5u8$ofxz`na7x+&V)or#gb)vdWFS}fe(iCd9V&aAh|hF3|p z$xl7XwpWaW-LfajLb_Mli@ldg(!NKQQIJ{2M7cwN*+r(=N5p|eo{38+(#npTt2u(l zBZNVeMT#v1H5{Klf2knB!OzO~;YCx#y%2E$W0eHs z<@wzE^F{M)G#dL8thAUkcp8cn?k`YeFfutfLCJwh+%QUIqTvbWMkWq555t5eR~AtN KDGn|c25SHyAnM!z literal 0 HcmV?d00001 diff --git a/www/extras/adminConsole/unlocked.gif b/www/extras/adminConsole/unlocked.gif new file mode 100644 index 0000000000000000000000000000000000000000..e4b8f77982dd8e3bb82806c98c8f1c3ed2838e46 GIT binary patch literal 580 zcmZ?wbhEHb6krfwc*eqT{rdGid-nYO`?sg3=ik47j~+dmIB{ZjcJ}1SlTV#G_51hl zvuDrVx^-*m(xnXz4eQpeD=I3wdGqGOhY!!3In&$Q+u7NhJHbs;b(&d2>=y(v&GvE?l_a-qENPoF-mt*t$I^5nsT2QOZ{xMt0oxpU{rf@&D7n*|AGa)QY*T-G`PEMIPJy79h_wZ_?+f9 z^Z5CSF*x!wo62eOc6l9OWN?uZ4e;?^-h9TFQIJhf6(f_HcE}sBdhUJAd`Q z15wrW&9mk%UAnY#+Kht!Nwu}LMYVNlMaA_qW*1b~W;ZlXUbN)O&07-|E-sxgxp2bd z3sR^Hgy zxM}Ck%}0(sdHy21sim{CGp43t*7{Aa-@diBuw1rm*}D%PrY&4_?$YJFzDec%lL{wJ zNzO0mTC`;U=`-7p9INc^%_*;V`1o;tOM6l8g!bOPr8{>!IXZ3Fwr$a(Md|73>(;IN z`ST|O=|J%(3nK$V9)k`@D=1DF*w;7YHD#MJIRz=PW;gY4S!YEtFz6aNbM-I@_=QIB z^QX8l2r%Vkvpebs@PKxMrrCX>oJpFblKjv5ASX*|7*S=j3oI zsOMj~>fy$DUR+1&N^b5I2Y2xtQQ7D~k^K8tQe%Tfc_b9QU%kmsGPK|kinEuyy6U5W yvs05ayHD5!2j<6|>{_-yE(s!uK9hvZ_vJh=TEwaBD9@$A>2T?ws9PfggEavE)A0WQ literal 0 HcmV?d00001