X-Git-Url: http://git.freeside.biz/gitweb/?p=freeside.git;a=blobdiff_plain;f=rt%2Fshare%2Fhtml%2FArticles%2FArticle%2FPreCreate.html;h=c55cac5b25d2732fd64d8e24845eb7df2ee1a8cd;hp=49507d4a869a4936a518d1676110eee64bb2a89c;hb=de9d037528895f7151a9aead6724ce2df95f9586;hpb=a6fe07e49e3fc12169e801b1ed6874c3a5bd8500 diff --git a/rt/share/html/Articles/Article/PreCreate.html b/rt/share/html/Articles/Article/PreCreate.html index 49507d4a8..c55cac5b2 100644 --- a/rt/share/html/Articles/Article/PreCreate.html +++ b/rt/share/html/Articles/Article/PreCreate.html @@ -2,7 +2,7 @@ %# %# COPYRIGHT: %# -%# This software is Copyright (c) 1996-2012 Best Practical Solutions, LLC +%# This software is Copyright (c) 1996-2017 Best Practical Solutions, LLC %# %# %# (Except where explicitly superseded by other copyright notices) @@ -46,17 +46,38 @@ %# %# END BPS TAGGED BLOCK }}} <& /Elements/Header, Title => loc('Create an article in class...') &> -<& /Elements/Tabs, Title => loc('Create an article in class...') &> +<& /Elements/Tabs &> + +% if (not $classes_configured) { +<& /Articles/Elements/NeedsSetup &> +% } elsif (not @classes) { +<&|/l&>You don't have permission to create Articles in any Class +% } else { -% unless ( $have_classes ) { -<&|/l&>Permission Denied % } +<%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; +