diff options
| author | Ivan Kohler <ivan@freeside.biz> | 2015-07-09 22:18:55 -0700 |
|---|---|---|
| committer | Ivan Kohler <ivan@freeside.biz> | 2015-07-09 22:27:04 -0700 |
| commit | e131b1f71f08b69abb832c1687d1f29682d171f8 (patch) | |
| tree | 490167e41d9fe05b760e7b21a96ee35a86f8edda /rt/share/html/Articles/Article/PreCreate.html | |
| parent | d05d7346bb2387fd9d0354923d577275c5c7f019 (diff) | |
RT 4.2.11, ticket#13852
Diffstat (limited to 'rt/share/html/Articles/Article/PreCreate.html')
| -rw-r--r-- | rt/share/html/Articles/Article/PreCreate.html | 36 |
1 files changed, 28 insertions, 8 deletions
diff --git a/rt/share/html/Articles/Article/PreCreate.html b/rt/share/html/Articles/Article/PreCreate.html index 7a8c05e22..6daa23246 100644 --- a/rt/share/html/Articles/Article/PreCreate.html +++ b/rt/share/html/Articles/Article/PreCreate.html @@ -47,17 +47,37 @@ %# END BPS TAGGED BLOCK }}} <& /Elements/Header, Title => loc('Create an article in class...') &> <& /Elements/Tabs &> + +% if (not $classes_configured) { +<& /Articles/Elements/NeedsSetup &> +% } elsif (not @classes) { +<i><&|/l&>You don't have permission to create Articles in any Class</&></i> +% } else { <ul> -% my $Classes = RT::Classes->new($session{'CurrentUser'}); -% $Classes->LimitToEnabled(); -% my $have_classes = 0; -% while (my $Class = $Classes->Next) { -% $have_classes++; +% for my $Class (@classes) { % my $qs = $m->comp("/Elements/QueryString", %ARGS, Class=> $Class->Id); <li><a href="Edit.html?<% $qs|n %>"><&|/l, $Class->Name &>in class [_1]</&></a></li> % } </ul> -% unless ( $have_classes ) { -<span><&|/l&>Permission Denied</&></span> -<p><span><&|/l&>To create an Article, you must first create a Class and have access to that Class.</&></span></p> % } +<%init> +my $Classes = RT::Classes->new($session{'CurrentUser'}); +$Classes->LimitToEnabled(); + +# This is a COUNT(), which doesn't apply ACLs; as such, we don't display +# the warning if there are classes, but the user can't see them. +my $classes_configured = $Classes->Count; + +# ->Next applies SeeClass, but we also want to check CreateArticle +my @classes; +while (my $class = $Classes->Next) { + push @classes, $class if $class->CurrentUserHasRight("CreateArticle"); +} + +# If there is only one, redirect to it +MaybeRedirectForResults( + Path => "/Articles/Article/Edit.html", + Force => 1, + Arguments => { Class => $classes[0]->id }, +) if @classes == 1; +</%init> |
