diff --git a/docs/changelog/7.x.x.txt b/docs/changelog/7.x.x.txt index 47e0e1c79..b0331e894 100644 --- a/docs/changelog/7.x.x.txt +++ b/docs/changelog/7.x.x.txt @@ -6,7 +6,7 @@ - fixed #10361: Shortcuts duplicate extra header tags - fixed #10356: SQL report is cached too long - fixed #10313: extra head elements appear twice - - fixed missing edit story and delete story icons in the Story Manager. + - fixed missing edit story and delete story icons in the Story Archive and Story Topic. 7.7.8 - fixed: Basic Auth doesn't work if password contains colon (Arjan Widlak, diff --git a/docs/upgrades/packages-7.7.9/root_import_storymanager.wgpkg b/docs/upgrades/packages-7.7.9/root_import_storymanager.wgpkg index a32213b80..55de932f3 100644 Binary files a/docs/upgrades/packages-7.7.9/root_import_storymanager.wgpkg and b/docs/upgrades/packages-7.7.9/root_import_storymanager.wgpkg differ diff --git a/lib/WebGUI/Asset/Wobject/StoryArchive.pm b/lib/WebGUI/Asset/Wobject/StoryArchive.pm index 9bf1b14b5..54ab891e6 100644 --- a/lib/WebGUI/Asset/Wobject/StoryArchive.pm +++ b/lib/WebGUI/Asset/Wobject/StoryArchive.pm @@ -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; diff --git a/lib/WebGUI/Asset/Wobject/StoryTopic.pm b/lib/WebGUI/Asset/Wobject/StoryTopic.pm index f20bfd9e1..f8ec46286 100644 --- a/lib/WebGUI/Asset/Wobject/StoryTopic.pm +++ b/lib/WebGUI/Asset/Wobject/StoryTopic.pm @@ -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}) { diff --git a/lib/WebGUI/Help/Asset_StoryArchive.pm b/lib/WebGUI/Help/Asset_StoryArchive.pm index 20eb49f4f..312d76c93 100644 --- a/lib/WebGUI/Help/Asset_StoryArchive.pm +++ b/lib/WebGUI/Help/Asset_StoryArchive.pm @@ -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' }, ], }, ] diff --git a/lib/WebGUI/Help/Asset_StoryTopic.pm b/lib/WebGUI/Help/Asset_StoryTopic.pm index d9bd1ba62..510c6d4a1 100644 --- a/lib/WebGUI/Help/Asset_StoryTopic.pm +++ b/lib/WebGUI/Help/Asset_StoryTopic.pm @@ -25,6 +25,8 @@ our $HELP = { { name => 'url' }, { name => 'title' }, { name => 'creationDate' }, + { name => 'deleteIcon' }, + { name => 'editIcon' }, ], }, { name => 'topStoryTitle' }, diff --git a/lib/WebGUI/i18n/English/Asset_StoryArchive.pm b/lib/WebGUI/i18n/English/Asset_StoryArchive.pm index 3a1fe006c..7b1a02f55 100644 --- a/lib/WebGUI/i18n/English/Asset_StoryArchive.pm +++ b/lib/WebGUI/i18n/English/Asset_StoryArchive.pm @@ -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, }, diff --git a/lib/WebGUI/i18n/English/Asset_StoryTopic.pm b/lib/WebGUI/i18n/English/Asset_StoryTopic.pm index 9e9cf3f73..4605e91d7 100644 --- a/lib/WebGUI/i18n/English/Asset_StoryTopic.pm +++ b/lib/WebGUI/i18n/English/Asset_StoryTopic.pm @@ -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.|, diff --git a/t/Asset/Wobject/StoryArchive.t b/t/Asset/Wobject/StoryArchive.t index 2fc6013bb..f6ed25953 100644 --- a/t/Asset/Wobject/StoryArchive.t +++ b/t/Asset/Wobject/StoryArchive.t @@ -225,6 +225,7 @@ KEY: foreach my $key (keys %{ $templateVars }) { delete $templateVars->{$key}; } +$session->user({userId => 1}); cmp_deeply( $templateVars, { @@ -258,7 +259,7 @@ cmp_deeply( }, ] }, - 'viewTemplateVariables: returns expected template variables with 3 stories in different folders' + 'viewTemplateVariables: returns expected template variables with 3 stories in different folders, user is cannot edit stories' ); my $story2 = $folder->addChild({ className => 'WebGUI::Asset::Story', title => 'Story 2', keywords => "roger,foxtrot"}); @@ -292,16 +293,22 @@ cmp_deeply( creationDate => ignore(), url => re('first-story'), title => 'First Story', + editIcon => ignore(), + deleteIcon => ignore(), }, { creationDate => ignore(), url => ignore(), title => 'Story 2', + editIcon => ignore(), + deleteIcon => ignore(), }, { creationDate => ignore(), url => ignore(), title => 'Story 3', + editIcon => ignore(), + deleteIcon => ignore(), }, ], }, @@ -336,11 +343,15 @@ cmp_deeply( creationDate => ignore(), url => ignore(), title => 'Story 2', + editIcon => ignore(), + deleteIcon => ignore(), }, { creationDate => ignore(), url => ignore(), title => 'Story 3', + editIcon => ignore(), + deleteIcon => ignore(), }, ], }, @@ -351,6 +362,8 @@ cmp_deeply( creationDate => ignore(), url => ignore(), title => 'WebGUI is released', + editIcon => ignore(), + deleteIcon => ignore(), }, ], }, @@ -383,11 +396,15 @@ cmp_bag( creationDate => ignore(), url => ignore(), title => 'Story 3', + editIcon => ignore(), + deleteIcon => ignore(), }, { creationDate => ignore(), url => ignore(), title => 'Story 4', + editIcon => ignore(), + deleteIcon => ignore(), }, ], }, @@ -398,6 +415,8 @@ cmp_bag( creationDate => ignore(), url => ignore(), title => 'WebGUI is released', + editIcon => ignore(), + deleteIcon => ignore(), }, ], },