Fix Story permissions so that admin need not be turned on.
canEdit is now determined by the Story and the parent StoryArchive. With tests, and template changes.
This commit is contained in:
parent
1e6d9b7d18
commit
83497b773e
6 changed files with 83 additions and 17 deletions
|
|
@ -85,6 +85,25 @@ sub addRevision {
|
|||
|
||||
#-------------------------------------------------------------------
|
||||
|
||||
=head2 canEdit ( )
|
||||
|
||||
You can't add children to a Story.
|
||||
|
||||
=cut
|
||||
|
||||
sub canEdit {
|
||||
my $self = shift;
|
||||
my $userId = shift || $self->session->user->userId;
|
||||
if ($userId eq $self->get("ownerUserId")) {
|
||||
return 1;
|
||||
}
|
||||
my $user = WebGUI::User->new($self->session, $userId);
|
||||
return $self->SUPER::canEdit($userId)
|
||||
|| $self->getArchive->canPostStories($userId);
|
||||
}
|
||||
|
||||
#-------------------------------------------------------------------
|
||||
|
||||
=head2 definition ( session, definition )
|
||||
|
||||
defines asset properties for New Asset instances. You absolutely need
|
||||
|
|
@ -839,6 +858,7 @@ sub viewTemplateVariables {
|
|||
}
|
||||
$var->{hasPhotos} = $photoCounter;
|
||||
$var->{singlePhoto} = $photoCounter == 1;
|
||||
$var->{canEdit} = $self->canEdit;
|
||||
return $var;
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -55,6 +55,7 @@ our $HELP = {
|
|||
],
|
||||
fields => [],
|
||||
variables => [
|
||||
{ name => 'canEdit', },
|
||||
{ name => 'highlights_loop',
|
||||
'variables' => [
|
||||
{ name => 'highlight', },
|
||||
|
|
|
|||
|
|
@ -446,6 +446,11 @@ our $I18N = {
|
|||
lastUpdated => 0,
|
||||
},
|
||||
|
||||
'canEdit' => {
|
||||
message => q|A boolean which will be true if the current user can edit this story.|,
|
||||
lastUpdated => 0,
|
||||
},
|
||||
|
||||
};
|
||||
|
||||
1;
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue