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 7167553fa..25aa7afff 100644 --- a/docs/upgrades/upgrade_6.6.5-6.7.0.pl +++ b/docs/upgrades/upgrade_6.6.5-6.7.0.pl @@ -168,6 +168,7 @@ sub updateConfigFile { #------------------------------------------------- sub addAssetVersioning { print "\tMaking changes for asset versioning\n" unless ($quiet); + WebGUI::SQL->write("insert into settings ('autoCommit','1')"); WebGUI::SQL->write("create table assetVersionTag ( tagId varchar(22) not null primary key, name varchar(255) not null, diff --git a/lib/WebGUI/Asset.pm b/lib/WebGUI/Asset.pm index bace93ff7..061ff38b0 100644 --- a/lib/WebGUI/Asset.pm +++ b/lib/WebGUI/Asset.pm @@ -2252,6 +2252,69 @@ sub purgeTree { return 1; } +#------------------------------------------------------------------- + +=head2 rollbackSiteToTime ( time ) + +A class method. Rollback the entire site to a specific point in time. Returns 1 if successful. + +=head3 time + +The epoch time to rollback to. Anything after this time will be permanently deleted. + +=cut + +sub rollbackToTime { + my $class = shift; + my $toTime = shift; + unless ($toTime) { + return 0; + WebGUI::ErrorHandler::warn("You must specify a time when you call rollbackSiteToTime()."); + } + my $sth = WebGUI::SQL->read("select asset.className, asset.assetId, assetData.revisionDate from assetData left join asset on asset.assetId=assetData.assetId where assetData.revisionDate > ".$toTime." order by assetData.revisionDate desc"); + while (my ($class, $id, $revisionDate) = $sth->array) { + my $revision = WebGUI::Asset->new($id, $class, $revisionDate); + $revision->purgeRevision; + } + $sth->finish; + return 1; +} + +#------------------------------------------------------------------- + +=head2 rollbackVersionTag ( tagId ) + +A class method. Eliminates all revisions of all assets created under a specific version tag. Also removes the version tag. + +=head3 tagId + +The unique identifier of the version tag to be purged. + +=cut + +sub rollbackVersionTag { + my $class = shift; + my $tagId = shift; + unless ($tagId) { + return 0; + WebGUI::ErrorHandler::warn("You must specify a tag ID when you call rollbackVersionTag()."); + } + if ($tagId eq "pbversion0000000000001" || $tagId eq "pbversion0000000000002") { + return 0; + WebGUI::ErrorHandler::warn("You cannot rollback a tag that is required for the system to operate."); + } + my $sth = WebGUI::SQL->read("select asset.className, asset.assetId, assetData.revisionDate from assetData left join asset on asset.assetId=assetData.assetId where assetData.tagId = ".quote($tagId)." order by assetData.revisionDate desc"); + while (my ($class, $id, $revisionDate) = $sth->array) { + my $revision = WebGUI::Asset->new($id, $class, $revisionDate); + $revision->purgeRevision; + } + $sth->finish; + WebGUI::SQL->write("delete from assetVersionTag where tagId=".quote($tagId)); + WebGUI::SQL->write("delete from userSessionScratch where name='versionTag' and value=".quote($tagId)); + return 1; +} + + #------------------------------------------------------------------- =head2 setParent ( newParent ) @@ -3580,6 +3643,8 @@ sub www_manageCommittedVersions { my $ac = WebGUI::AdminConsole->new("versions"); return WebGUI::Privilege::insufficient() unless (WebGUI::Grouping::isInGroup(3)); my $i18n = WebGUI::International->new("Asset"); + my $rollback = $i18n->get('rollback'); + my $rollbackPrompt = $i18n->get('rollback version tag confirm'); $ac->addSubmenuItem($self->getUrl('func=addVersionTag'), $i18n->get("add a version tag")); $ac->addSubmenuItem($self->getUrl('func=manageVersions'), $i18n->get("manage versions")); my $output = ' @@ -3587,7 +3652,7 @@ sub www_manageCommittedVersions { my $sth = WebGUI::SQL->read("select tagId,name,commitDate,committedBy from assetVersionTag where isCommitted=1"); while (my ($id,$name,$date,$by) = $sth->array) { my $u = WebGUI::User->new($by); - $output .= ''; + $output .= ''; } $sth->finish; $output .= '
'.$name.''.WebGUI::DateTime::epochToHuman($date).''.$u->username.'[rollback]
'.$name.''.WebGUI::DateTime::epochToHuman($date).''.$u->username.''.$rollback.'
'; @@ -3634,16 +3699,16 @@ sub www_manageRevisions { #$ac->addSubmenuItem($self->getUrl('func=addVersionTag'), $i18n->get("add a version tag")); #$ac->addSubmenuItem($self->getUrl('func=manageVersions'), $i18n->get("manage versions")); my $output = ' - '; + '; my $sth = WebGUI::SQL->read("select assetData.revisionDate, users.username, assetVersionTag.name from assetData left join assetVersionTag on assetData.tagId=assetVersionTag.tagId left join users on assetData.revisedBy=users.userId where assetData.assetId=".quote($self->getId)); while (my ($date,$by,$tag) = $sth->array) { - $output .= ''; + $output .= ''; } $sth->finish; $output .= '
Revision DateRevised ByTag Name
Revision DateRevised ByTag Name
'.WebGUI::DateTime::epochToHuman($date).''.$by.''.$tag.'[rollback]
'.WebGUI::Icon::deleteIcon("func=rollbackAssetRevision",$self->get("url"),$i18n->get("purge revision prompt")).''.WebGUI::DateTime::epochToHuman($date).''.$by.''.$tag.'
'; - return $ac->render($output,$i18n->get("committed versions")); + return $ac->render($output,$i18n->get("committed versions").": ".$self->getTitle); } #------------------------------------------------------------------- @@ -3719,18 +3784,21 @@ sub www_manageVersions { my $self = shift; my $ac = WebGUI::AdminConsole->new("versions"); return WebGUI::Privilege::insufficient() unless (WebGUI::Grouping::isInGroup(12)); + my $i18n = WebGUI::International->new("Asset"); $ac->setHelp("versions manage"); my $i18n = WebGUI::International->new("Asset"); $ac->addSubmenuItem($self->getUrl('func=addVersionTag'), $i18n->get("add a version tag")); $ac->addSubmenuItem($self->getUrl('func=manageCommittedVersions'), $i18n->get("manage committed versions")); my ($tag) = WebGUI::SQL->quickArray("select name from assetVersionTag where tagId=".quote($session{scratch}{versionTag})); $tag ||= "None"; + my $rollback = $i18n->get("rollback"); + my $rollbackPrompt = $i18n->get("rollback version tag confirm"); my $output = '

You are currently working under a tag called: '.$tag.'.

'; my $sth = WebGUI::SQL->read("select tagId,name,creationDate,createdBy from assetVersionTag where isCommitted=0"); while (my ($id,$name,$date,$by) = $sth->array) { my $u = WebGUI::User->new($by); - $output .= ''; + $output .= ''; } $sth->finish; $output .= '
Tag NameCreated OnCreated By
'.$name.''.WebGUI::DateTime::epochToHuman($date).''.$u->username.'[cancel] [commit]
'.$name.''.WebGUI::DateTime::epochToHuman($date).''.$u->username.''.$rollback.' [commit]
'; @@ -3785,6 +3853,17 @@ sub www_promote { } +#-------------------------------------------------------------------A + +sub www_purgeAssetRevision { + my $self = shift; + return WebGUI::Privilege::insufficient() unless $self->canEdit; + my $revisionDate = $session{form}{revisionDate}; + return undef unless $revisionDate; + WebGUI::Asset->new($self->getId,$self->get("className"),$revisionDate)->purgeRevision; + return $self->www_manageRevisions; +} + #------------------------------------------------------------------- =head2 www_restoreList ( ) @@ -3808,6 +3887,29 @@ sub www_restoreList { } +#-------------------------------------------------------------------A + +sub www_rollbackVersionTag { + my $self = shift; + return WebGUI::Privilege::adminOnly() unless WebGUI::Grouping::isInGroup(3); + my $tagId = $session{form}{tagId}; + if ($tagId) { + $self->rollbackVersionTag($tagId); + } + return $self->www_manageVersions; +} + +#-------------------------------------------------------------------A + +sub www_rollbackSiteToTime { + my $self = shift; + return WebGUI::Privilege::adminOnly() unless WebGUI::Grouping::isInGroup(3); + +} + + + + #------------------------------------------------------------------- =head2 www_setParent ( ) diff --git a/lib/WebGUI/Asset/Wobject/SQLReport.pm b/lib/WebGUI/Asset/Wobject/SQLReport.pm index 7310cb915..ec8d4b13a 100644 --- a/lib/WebGUI/Asset/Wobject/SQLReport.pm +++ b/lib/WebGUI/Asset/Wobject/SQLReport.pm @@ -290,7 +290,7 @@ sub _parsePlaceholderParams { my $param; if($type =~ /^form/) { $param = $session{form}{$field}; - } elsif ($param =~ /^query(\d)/) { + } elsif ($type =~ /^query(\d)/) { $param = $self->{_query}{$1}{rowData}{$field}; } $param = WebGUI::Macro::process($param); diff --git a/lib/WebGUI/Operation/Settings.pm b/lib/WebGUI/Operation/Settings.pm index 023faae5a..abb598cc9 100644 --- a/lib/WebGUI/Operation/Settings.pm +++ b/lib/WebGUI/Operation/Settings.pm @@ -101,6 +101,11 @@ sub www_editSettings { -label=>$i18n->get(406), -value=>$session{setting}{thumbnailSize} ); + $tabform->getTab("content")->yesNo( + -name=>"autoCommit", + -label=>WebGUI::International::get("enable autocommit of asset versioning","Asset"), + -value=>$session{setting}{autoCommit} + ); $tabform->getTab("content")->yesNo( -name=>"metaDataEnabled", -label=>$i18n->get("Enable Metadata ?"), diff --git a/lib/WebGUI/i18n/English/Asset.pm b/lib/WebGUI/i18n/English/Asset.pm index 5a7657116..cf15d98cf 100644 --- a/lib/WebGUI/i18n/English/Asset.pm +++ b/lib/WebGUI/i18n/English/Asset.pm @@ -1,6 +1,30 @@ package WebGUI::i18n::English::Asset; our $I18N = { + 'purge revision prompt' => { + message => q|Are you certain you wish to delete this revision of this asset? It CANNOT be restored if you delete it.|, + lastUpdated => 0, + context => q|The prompt for purging a revision from the asset tree.| + }, + + 'rollback version tag confirm' => { + message => q|Are you certain you wish to delete this version tag and all content created under it? It CANNOT be restored if you delete it.|, + lastUpdated => 0, + context => q|The prompt for purging a version tag from the asset tree.| + }, + + 'enable autocommit of asset versioning' => { + message => q|Enable autocommit of asset versioning?|, + lastUpdated => 0, + context => q|A label for the toggle for asset versioning.| + }, + + 'rollback' => { + message => q|Rollback|, + lastUpdated => 0, + context => q|The label for purging a revision from the asset tree.| + }, + 'revisions' => { message => q|Revisions|, lastUpdated => 0, diff --git a/www/extras/adminConsole/adminConsole.css b/www/extras/adminConsole/adminConsole.css index 5e4466514..891275b73 100644 --- a/www/extras/adminConsole/adminConsole.css +++ b/www/extras/adminConsole/adminConsole.css @@ -4,6 +4,12 @@ body{ border: 5px #4E8AAB solid; margin:0px; } + +th { + text-align: left; + font-family: "Lucida Grande", "Lucida Sans Unicode", Tahoma, Verdana, Arial, sans-serif; +} + .adminConsoleTitleIcon { position: absolute; top: 12px;