matrix upgrade and privileging fixes
This commit is contained in:
parent
cc1c1d165a
commit
03dce77e90
7 changed files with 133 additions and 11 deletions
|
|
@ -1,5 +1,6 @@
|
|||
7.7.0
|
||||
- fixed: Template parser cannot be set
|
||||
- fixed #9836: Matrix: Group to Add Listings is missing
|
||||
|
||||
7.6.14
|
||||
- fixed: IE6 shows Admin Bar over Asset Manager
|
||||
|
|
|
|||
|
|
@ -254,7 +254,7 @@ sub upgradeMatrix {
|
|||
my $session = shift;
|
||||
print "\tUpgrading matrix assets... \n" unless $quiet;
|
||||
my $db = $session->db;
|
||||
$db->write("alter table Matrix drop column groupToRate, drop column groupToAdd, drop column privilegedGroup,
|
||||
$db->write("alter table Matrix drop column groupToRate, drop column privilegedGroup,
|
||||
drop column ratingTimeout, drop column ratingTimeoutPrivileged, drop column ratingDetailTemplateId,
|
||||
drop column visitorCacheTimeout");
|
||||
$db->write("alter table Matrix add column defaultSort char(22) not null default 'score',
|
||||
|
|
@ -337,6 +337,7 @@ sub upgradeMatrix {
|
|||
$listing->{title} = $listing->{productName};
|
||||
$listing->{version} = $listing->{versionNumber};
|
||||
$listing->{screenshots} = $listing->{storageId};
|
||||
$listing->{ownerUserId} = $listing->{maintainerId};
|
||||
$listing->{productURL} = $listing->{productUrl};
|
||||
$listing->{manufacturerURL} = $listing->{manufacturerUrl};
|
||||
my $newMatrixListing = $matrix->addChild($listing,undef,undef,{skipAutoCommitWorkflows=>1});
|
||||
|
|
|
|||
|
|
@ -32,8 +32,20 @@ my $session = start(); # this line required
|
|||
|
||||
# upgrade functions go here
|
||||
|
||||
addGroupToAddToMatrix( $session );
|
||||
|
||||
finish($session); # this line required
|
||||
|
||||
#----------------------------------------------------------------------------
|
||||
sub addGroupToAddToMatrix {
|
||||
my $session = shift;
|
||||
print "\tAdding groupToAdd to Matrix table, if needed... \n" unless $quiet;
|
||||
my $sth = $session->db->read('describe Matrix groupToAdd');
|
||||
if (! defined $sth->hashRef) {
|
||||
$session->db->write("alter table Matrix add column groupToAdd char(22) default 2");
|
||||
}
|
||||
print "Done.\n" unless $quiet;
|
||||
}
|
||||
|
||||
#----------------------------------------------------------------------------
|
||||
# Describe what our function does
|
||||
|
|
|
|||
|
|
@ -61,7 +61,7 @@ sub upgradeMatrix {
|
|||
my $session = shift;
|
||||
print "\tUpgrading matrix assets... \n" unless $quiet;
|
||||
my $db = $session->db;
|
||||
$db->write("alter table Matrix drop column groupToRate, drop column groupToAdd, drop column privilegedGroup,
|
||||
$db->write("alter table Matrix drop column groupToRate, drop column privilegedGroup,
|
||||
drop column ratingTimeout, drop column ratingTimeoutPrivileged, drop column ratingDetailTemplateId,
|
||||
drop column visitorCacheTimeout");
|
||||
$db->write("alter table Matrix add column defaultSort char(22) not null default 'score',
|
||||
|
|
@ -144,6 +144,7 @@ sub upgradeMatrix {
|
|||
$listing->{title} = $listing->{productName};
|
||||
$listing->{version} = $listing->{versionNumber};
|
||||
$listing->{screenshots} = $listing->{storageId};
|
||||
$listing->{ownerUserId} = $listing->{maintainerId};
|
||||
$listing->{productURL} = $listing->{productUrl};
|
||||
$listing->{manufacturerURL} = $listing->{manufacturerUrl};
|
||||
my $newMatrixListing = $matrix->addChild($listing,undef,undef,{skipAutoCommitWorkflows=>1});
|
||||
|
|
|
|||
|
|
@ -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