matrix upgrade and privileging fixes
This commit is contained in:
parent
cc1c1d165a
commit
03dce77e90
7 changed files with 133 additions and 11 deletions
|
|
@ -58,6 +58,43 @@ sub addRevision {
|
|||
return $newSelf;
|
||||
}
|
||||
|
||||
#----------------------------------------------------------------------------
|
||||
|
||||
=head2 canAdd ( )
|
||||
|
||||
Override canAdd to ignore its permissions check. Permissions are handled
|
||||
by the parent Matrix.
|
||||
|
||||
=cut
|
||||
|
||||
sub canAdd {
|
||||
return 1;
|
||||
}
|
||||
|
||||
#----------------------------------------------------------------------------
|
||||
|
||||
=head2 canEdit ( )
|
||||
|
||||
Returns true if the user can edit this asset. C<userId> is a WebGUI user ID.
|
||||
|
||||
Users can edit this Matrix listing if they are the owner, or if they can edit
|
||||
the parent Matrix.
|
||||
|
||||
=cut
|
||||
|
||||
sub canEdit {
|
||||
my $self = shift;
|
||||
|
||||
if ( $self->session->form->process("assetId") eq "new" ) {
|
||||
return $self->getParent->canAddMatrixListing();
|
||||
}
|
||||
else {
|
||||
return 1 if $self->session->user->userId eq $self->get("ownerUserId");
|
||||
|
||||
return $self->getParent->canEdit();
|
||||
}
|
||||
}
|
||||
|
||||
#-------------------------------------------------------------------
|
||||
|
||||
=head2 definition ( session, definition )
|
||||
|
|
@ -327,7 +364,7 @@ sub getEditForm {
|
|||
|
||||
$form->raw(
|
||||
'<tr><td COLSPAN=2>'.
|
||||
WebGUI::Form::Button($session, {}).
|
||||
WebGUI::Form::Submit($session, {}).
|
||||
WebGUI::Form::Button($session, {
|
||||
-value => $i18n->get('cancel', 'WebGUI'),
|
||||
-extras => q|onclick="history.go(-1);" class="backwardButton"|
|
||||
|
|
@ -580,6 +617,14 @@ sub view {
|
|||
if ($emailSent){
|
||||
$var->{emailSent} = 1;
|
||||
}
|
||||
|
||||
unless($self->hasBeenCommitted){
|
||||
my $workflowInstanceId = $db->quickScalar("select workflowInstanceId from assetVersionTag where tagId =?"
|
||||
,[$self->get('tagId')]);
|
||||
$var->{canApprove} = $self->getParent->canEdit;
|
||||
$var->{approveOrDenyUrl} = $self->getUrl("op=manageRevisionsInTag;workflowInstanceId=".$workflowInstanceId
|
||||
.";tagId=".$self->get('tagId'));
|
||||
}
|
||||
$var->{canEdit} = $self->canEdit;
|
||||
$var->{editUrl} = $self->getUrl("func=edit");
|
||||
$var->{controls} = $self->getToolbar;
|
||||
|
|
@ -835,12 +880,14 @@ Web facing method which is the default edit page
|
|||
|
||||
sub www_edit {
|
||||
my $self = shift;
|
||||
|
||||
return $self->session->privilege->noAccess() unless $self->getParent->canAddMatrixListing();
|
||||
|
||||
my $i18n = WebGUI::International->new($self->session, "Asset_MatrixListing");
|
||||
return $self->session->privilege->insufficient() unless $self->canEdit;
|
||||
return $self->session->privilege->locked() unless $self->canEditIfLocked;
|
||||
|
||||
if($self->session->form->process('func') eq 'add'){
|
||||
return $self->session->privilege->noAccess() unless $self->getParent->canAddMatrixListing();
|
||||
}else{
|
||||
return $self->session->privilege->insufficient() unless $self->canEdit;
|
||||
return $self->session->privilege->locked() unless $self->canEditIfLocked;
|
||||
}
|
||||
|
||||
my $var = $self->get;
|
||||
my $matrix = $self->getParent;
|
||||
|
|
|
|||
|
|
@ -30,10 +30,46 @@ Returns true if able to add MatrixListings.
|
|||
|
||||
sub canAddMatrixListing {
|
||||
my $self = shift;
|
||||
my $user = $self->session->user;
|
||||
|
||||
return 0 if $self->session->user->isVisitor;
|
||||
# Users in the groupToAdd group can add listings
|
||||
if ( $user->isInGroup( $self->get("groupToAdd") ) ) {
|
||||
return 1;
|
||||
}
|
||||
# Users who can edit matrix can add listings
|
||||
else {
|
||||
return $self->canEdit;
|
||||
}
|
||||
|
||||
return 1;
|
||||
}
|
||||
|
||||
#----------------------------------------------------------------------------
|
||||
|
||||
=head2 canEdit ( [userId] )
|
||||
|
||||
Returns true if the user can edit this Matrix.
|
||||
|
||||
Also checks if a user is adding a Matrix Listing and allows them to if they are
|
||||
part of the C<groupToAdd> group.
|
||||
|
||||
=cut
|
||||
|
||||
sub canEdit {
|
||||
my $self = shift;
|
||||
my $userId = shift || $self->session->user->userId;
|
||||
|
||||
my $form = $self->session->form;
|
||||
if ( $form->get('func') eq "editSave" && $form->get('assetId') eq "new" && $form->get( 'class' )->isa(
|
||||
'WebGUI::Asset::MatrixListing' ) ) {
|
||||
return $self->canAddMatrixListing();
|
||||
}
|
||||
else {
|
||||
if ($userId eq $self->get("ownerUserId")) {
|
||||
return 1;
|
||||
}
|
||||
my $user = WebGUI::User->new($self->session, $userId);
|
||||
return $user->isInGroup($self->get("groupIdEdit"));
|
||||
}
|
||||
}
|
||||
|
||||
#-------------------------------------------------------------------
|
||||
|
|
@ -164,6 +200,13 @@ sub definition {
|
|||
hoverHelp =>$i18n->get('max comparisons privileged description'),
|
||||
label =>$i18n->get('max comparisons privileged label'),
|
||||
},
|
||||
groupToAdd=>{
|
||||
fieldType =>"group",
|
||||
tab =>"security",
|
||||
defaultValue =>2,
|
||||
hoverHelp =>$i18n->get('group to add description'),
|
||||
label =>$i18n->get('group to add label'),
|
||||
},
|
||||
submissionApprovalWorkflowId=>{
|
||||
fieldType =>"workflow",
|
||||
tab =>"security",
|
||||
|
|
@ -543,7 +586,8 @@ sub view {
|
|||
}) };
|
||||
foreach my $pendingListing (@pendingListings){
|
||||
push (@{ $var->{pending_loop} }, {
|
||||
url => $pendingListing->getUrl,
|
||||
url => $pendingListing->getUrl
|
||||
."?func=view;revision=".$pendingListing->get('revisionDate'),
|
||||
name => $pendingListing->get('title'),
|
||||
});
|
||||
}
|
||||
|
|
|
|||
|
|
@ -372,6 +372,11 @@ listing,|,
|
|||
lastUpdated => 0,
|
||||
},
|
||||
|
||||
'group to add description' => {
|
||||
message => q|Select the group that is allowed to add listings to this matrix.|,
|
||||
lastUpdated => 0,
|
||||
},
|
||||
|
||||
'ratings duration description' => {
|
||||
message => q|Select the interval after which old ratings are cleaned out.|,
|
||||
lastUpdated => 0,
|
||||
|
|
@ -487,6 +492,11 @@ listing,|,
|
|||
lastUpdated => 0,
|
||||
},
|
||||
|
||||
'group to add label' => {
|
||||
message => q|Group To Add|,
|
||||
lastUpdated => 0,
|
||||
},
|
||||
|
||||
'ratings duration label' => {
|
||||
message => q|Ratings Duration|,
|
||||
lastUpdated => 0,
|
||||
|
|
@ -750,6 +760,12 @@ selectBox.</p>|
|
|||
message => q|Hide/show stickied|,
|
||||
},
|
||||
|
||||
'approve or deny label' => {
|
||||
lastUpdated => 0,
|
||||
message => q|Approve/Deny|,
|
||||
context => q|Label for the approve or deny link on the matrix listing detail screen.|,
|
||||
},
|
||||
|
||||
'matrix asset template variables title' => {
|
||||
lastUpdated => 0,
|
||||
message => q|Matrix Asset Template Variables|,
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue