- Fixed a bug where password field was not being displayed in the user manager.

- Fixed a bug in version management where you couldn't see the list of things
   changed under a specific tag.
 - Fixed a bug in versioning that would allow a user not using the same tag as
   the original editor to edit a locked asset.
 - Fixed a bug that would not allow an editor to commit an individual asset
   revision.
This commit is contained in:
JT Smith 2005-08-26 15:35:06 +00:00
parent a9f26c1c87
commit 223078c666
4 changed files with 70 additions and 12 deletions

View file

@ -808,18 +808,20 @@ Returns a toolbar with a set of icons that hyperlink to functions that delete, e
sub getToolbar {
my $self = shift;
my $toolbar = deleteIcon('func=delete',$self->get("url"),WebGUI::International::get(43,"Asset"));
if (!$self->isLocked || $self->get("isLockedBy") eq $session{user}{userId}) {
my $commit;
my $i18n = WebGUI::International->new("Asset");
if (($self->canEditIfLocked && $session{scratch}{versionTag} eq $self->get("tagId")) || !$self->isLocked) {
$toolbar .= editIcon('func=edit',$self->get("url"));
} else {
$toolbar .= lockedIcon('func=manageRevisions',$self->get("url"));
}
$commit = 'contextMenu.addLink("'.$self->getUrl("func=commitRevision").'","'.$i18n->get("commit").'");' if ($self->canEditIfLocked);
$toolbar .= cutIcon('func=cut',$self->get("url"))
.copyIcon('func=copy',$self->get("url"));
$toolbar .= shortcutIcon('func=createShortcut',$self->get("url")) unless ($self->get("className") =~ /Shortcut/);
$toolbar .= exportIcon('func=export',$self->get("url")) if defined ($session{config}{exportPath});
WebGUI::Style::setLink($session{config}{extrasURL}.'/contextMenu/contextMenu.css', {rel=>"stylesheet",type=>"text/css"});
WebGUI::Style::setScript($session{config}{extrasURL}.'/contextMenu/contextMenu.js', {type=>"text/javascript"});
my $i18n = WebGUI::International->new("Asset");
return '<script type="text/javascript" language="javascript">
var contextMenu = new contextMenu_createWithImage("'.$self->getIcon(1).'","'.$self->getId.'","'.$self->getName.'");
contextMenu.addLink("'.$self->getUrl("func=editBranch").'","'.$i18n->get("edit branch").'");
@ -827,6 +829,7 @@ sub getToolbar {
contextMenu.addLink("'.$self->getUrl("func=demote").'","'.$i18n->get("demote").'");
contextMenu.addLink("'.$self->getUrl("func=manageAssets").'","'.$i18n->get("manage").'");
contextMenu.addLink("'.$self->getUrl("func=manageRevisions").'","'.$i18n->get("revisions").'");
'.$commit.'
contextMenu.addLink("'.$self->getUrl.'","'.$i18n->get("view").'");
contextMenu.print();
</script>'.$toolbar;
@ -1209,13 +1212,13 @@ sub publish {
=head2 purgeCache ( )
Purges all cache entries associated with this revision.
Purges all cache entries associated with this asset.
=cut
sub purgeCache {
my $self = shift;
WebGUI::Cache->new(["asset",$self->getId,$self->get("revisionDate")])->delete;
WebGUI::Cache->new(["asset",$self->getId])->delete;
}
@ -1392,7 +1395,7 @@ sub www_editSave {
$object = $self->addChild({className=>$session{form}{class}});
$object->{_parent} = $self;
} else {
return $self->getContainer->www_view if ($self->isLocked && $self->get("isLockedBy") ne $session{user}{userId});
return $self->getContainer->www_view if ($self->canEditIfLocked || !$self->isLocked);
$object = $self->addRevision;
}
$object->processPropertiesFromFormPost;
@ -1445,10 +1448,12 @@ sub www_manageAssets {
assetManager.AddColumn('".$i18n->get("size")."','','right','');
assetManager.AddColumn('".$i18n->get("locked")."','','center','');\n";
foreach my $child (@{$self->getLineage(["children"],{returnObjects=>1})}) {
my $commit = 'contextMenu.addLink("'.$child->getUrl("func=commitRevision").'","'.$i18n->get("commit").'");' if ($child->canEditIfLocked);
$output .= 'var contextMenu = new contextMenu_createWithLink("'.$child->getId.'","More");
contextMenu.addLink("'.$child->getUrl("func=editBranch").'","'.$i18n->get("edit branch").'");
contextMenu.addLink("'.$child->getUrl("func=createShortcut;proceed=manageAssets").'","'.$i18n->get("create shortcut").'");
contextMenu.addLink("'.$child->getUrl("func=manageRevisions").'","'.$i18n->get("revisions").'");
'.$commit.'
contextMenu.addLink("'.$child->getUrl.'","'.$i18n->get("view").'"); '."\n";
my $title = $child->getTitle;
$title =~ s/\'/\\\'/g;
@ -1456,7 +1461,7 @@ sub www_manageAssets {
my $edit;
if ($child->isLocked) {
$locked = '<img src="'.$session{config}{extrasURL}.'/assetManager/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->canEditIfLocked && $session{scratch}{versionTag} eq $self->get("tagId"));
} else {
$edit = "'<a href=\"".$child->getUrl("func=edit;proceed=manageAssets")."\">Edit</a> | '+";
$locked = '<img src="'.$session{config}{extrasURL}.'/assetManager/unlocked.gif" alt="unlocked" border="0" />';

View file

@ -102,6 +102,27 @@ sub addVersionTag {
#-------------------------------------------------------------------
=head2 canEditIfLocked ( )
Returns a boolean indicating whether this asset is locked and if the current user can edit it in that state.
=cut
sub canEditIfLocked {
my $self = shift;
return 0 unless ($self->isLocked);
return ($self->get("isLockedBy") eq $session{user}{userId});
}
#-------------------------------------------------------------------
=head2 commit ( )
Unlock's the asset and sets it to approved.
=cut
sub commit {
my $self = shift;
$self->unsetVersionLock;
@ -111,6 +132,16 @@ sub commit {
#-------------------------------------------------------------------
=head2 commitVersionTag ( tagId )
Commits all assets edited under a version tag, and then sets the version tag to committed.
=head3 tagId
The unique id of the tag to be committed.
=cut
sub commitVersionTag {
my $class = shift;
my $tagId = shift;
@ -349,7 +380,16 @@ sub www_addVersionTagSave {
}
#-------------------------------------------------------------------A
#-------------------------------------------------------------------
sub www_commitRevision {
my $self = shift;
return WebGUI::Privilege::adminOnly() unless $self->canEdit;
$self->commit;
return $self->getContainer->www_manageAssets if ($session{form}{proceed} eq "manageAssets");
return $self->getContainer->www_view;
}
#-------------------------------------------------------------------
sub www_commitVersionTag {
my $self = shift;
@ -417,7 +457,8 @@ sub www_manageRevisions {
$output .= '<tr><td>'.WebGUI::Icon::deleteIcon("func=purgeRevision;revisionDate=".$date,$self->get("url"),$i18n->get("purge revision prompt")).'</td>
<td><a href="'.$self->getUrl("func=viewRevision;revisionDate=".$date).'">'.WebGUI::DateTime::epochToHuman($date).'</a></td>
<td>'.$by.'</td>
<td><a href="'.$self->getUrl("func=manageRevisionsInTag;tagId=".$tagId).'">'.$tag.'</a></td></tr>';
<td><a href="'.$self->getUrl("func=manageRevisionsInTag;tagId=".$tagId).'">'.$tag.'</a></td>
</tr>';
}
$sth->finish;
$output .= '</table>';
@ -449,16 +490,17 @@ sub www_manageVersions {
my $rollbackPrompt = $i18n->get("rollback version tag confirm");
my $commitPrompt = $i18n->get("commit version tag confirm");
my $output = '<p>You are currently working under a tag called: <b>'.$tag.'</b>.</p><table width=100% class="content">
<tr><th>Tag Name</th><th>Created On</th><th>Created By</th><th></th></tr> ';
<tr><th></th><th>Tag Name</th><th>Created On</th><th>Created By</th><th></th></tr> ';
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 .= '<tr><td><a href="'.$self->getUrl("func=setVersionTag;tagId=".$id).'">'.$name.'</a></td>
$output .= '<tr>
<td>'.WebGUI::Icon::deleteIcon("func=rollbackVersionTag;tagId=".$id,$self->get("url"),$rollbackPrompt).'</td>
<td><a href="'.$self->getUrl("func=manageRevisionsInTag;tagId=".$id).'">'.$name.'</a></td>
<td>'.WebGUI::DateTime::epochToHuman($date).'</td>
<td>'.$u->username.'</td>
<td>
<a href="'.$self->getUrl("func=setVersionTag;tagId=".$id).'">'.$setTag.'</a> |
<a href="'.$self->getUrl("func=rollbackVersionTag;tagId=".$id).'" onclick="return confirm(\''.$rollbackPrompt.'\');">'.$rollback.'</a> |
<a href="'.$self->getUrl("func=commitVersionTag;tagId=".$id).'" onclick="return confirm(\''.$commitPrompt.'\');">'.$commit.'</a></td></tr>';
}
$sth->finish;

View file

@ -82,7 +82,11 @@ sub addUserForm {
my $self = shift;
my $userData = $self->getParams;
my $f = WebGUI::HTMLForm->new;
$f->password("authWebGUI.identifier",WebGUI::International::get(51),"password");
$f->password(
name=>"authWebGUI.identifier",
label=>WebGUI::International::get(51),
value=>"password"
);
$f->interval(
-name=>"authWebGUI.passwordTimeout",
-label=>WebGUI::International::get(16,'AuthWebGUI'),