Add edit and delete icons to the Story Topic. Update tests. Adjust both

sets of templates.  Use the correct privileges for displaying the icons.
Help and i18n.
This commit is contained in:
Colin Kuskie 2009-06-01 16:53:22 +00:00
parent 6844ef4559
commit 8f09dc062d
9 changed files with 58 additions and 12 deletions

View file

@ -553,10 +553,10 @@ sub viewTemplateVariables {
title => $story->getTitle,
creationDate => $creationDate,
};
if ($userUiLevel >= $uiLevels->{delete}) {
if ($story->canEdit && $userUiLevel >= $uiLevels->{delete} && !$exporting) {
$storyVars->{deleteIcon} = $icon->delete('func=delete', $story->get('url'), $i18n->get(43));
}
if ($userUiLevel >= $uiLevels->{edit}) {
if ($story->canEdit && $userUiLevel >= $uiLevels->{edit} && !$exporting) {
$storyVars->{editIcon} = $icon->edit('func=edit', $story->get('url'));
}
push @{$datePointer->{story_loop}}, $storyVars;

View file

@ -174,17 +174,30 @@ sub viewTemplateVariables {
});
my $storyIds = $p->getPageData();
$var->{story_loop} = [];
my $icon = $session->icon;
my $userUiLevel = $session->user->profileField("uiLevel");
my $uiLevels = $session->config->get('assetToolbarUiLevel');
my $i18n = WebGUI::International->new($session);
##Only build objects for the assets that we need
STORY: foreach my $storyId (@{ $storyIds }) {
my $story = WebGUI::Asset->new($session, $storyId->{assetId}, $storyId->{className}, $storyId->{revisionDate});
next STORY unless $story;
push @{$var->{story_loop}}, {
my $storyVars = {
url => ( $exporting
? $story->getUrl
: $session->url->append($self->getUrl, 'func=viewStory;assetId='.$storyId->{assetId}) ),
title => $story->getTitle,
creationDate => $story->get('creationDate'),
};
if ($story->canEdit && $userUiLevel >= $uiLevels->{delete} && !$exporting) {
$storyVars->{deleteIcon} = $icon->delete('func=delete', $story->get('url'), $i18n->get(43));
}
if ($story->canEdit && $userUiLevel >= $uiLevels->{edit} && !$exporting) {
$storyVars->{editIcon} = $icon->edit('func=edit', $story->get('url'));
}
push @{$var->{story_loop}}, $storyVars;
}
if ($self->{_standAlone}) {

View file

@ -27,11 +27,11 @@ our $HELP = {
{ 'name' => 'epochDate' },
{ 'name' => 'story_loop',
'variables' => [
{ 'name' => 'url' },
{ 'name' => 'title' },
{ 'name' => 'creationDate' },
{ 'name' => 'deleteIcon' },
{ 'name' => 'editIcon' },
{ name => 'url' },
{ name => 'title' },
{ name => 'creationDate' },
{ name => 'deleteIcon' },
{ name => 'editIcon' },
],
},
]

View file

@ -25,6 +25,8 @@ our $HELP = {
{ name => 'url' },
{ name => 'title' },
{ name => 'creationDate' },
{ name => 'deleteIcon' },
{ name => 'editIcon' },
],
},
{ name => 'topStoryTitle' },

View file

@ -214,13 +214,13 @@ our $I18N = {
},
'deleteIcon' => {
message => q|An icon to delete this story.|,
message => q|An icon to delete this story. If the user is not allowed to delete the icon, or their UI level is set too low, this variable will be empty.|,
context => q|Template variable.|,
lastUpdated => 0,
},
'editIcon' => {
message => q|An icon to edit this story.|,
message => q|An icon to edit this story. If the user is not allowed to edit the icon, or their UI level is set too low, this variable will be empty.|,
context => q|Template variable.|,
lastUpdated => 0,
},

View file

@ -81,6 +81,18 @@ our $I18N = {
lastUpdated => 0,
},
'deleteIcon' => {
message => q|An icon to delete this story. If the user is not allowed to delete the icon, or their UI level is set too low, this variable will be empty.|,
context => q|Template variable.|,
lastUpdated => 0,
},
'editIcon' => {
message => q|An icon to edit this story. If the user is not allowed to edit the icon, or their UI level is set too low, this variable will be empty.|,
context => q|Template variable.|,
lastUpdated => 0,
},
'topStoryUrl' => {
message => q|The URL to view the top story.|,
context => q|Template variable.|,