X-Git-Url: http://git.freeside.biz/gitweb/?p=freeside.git;a=blobdiff_plain;f=rt%2Fshare%2Fhtml%2FArticles%2FArticle%2FPreCreate.html;h=fc7ff7f280e90c1f42cc7b6d8705beb5180ee503;hp=7a8c05e2203152f2f6ab39a3eec20a5b974afc0d;hb=7322f2afedcc2f427e997d1535a503613a83f088;hpb=919e930aa9279b3c5cd12b593889cd6de79d67bf diff --git a/rt/share/html/Articles/Article/PreCreate.html b/rt/share/html/Articles/Article/PreCreate.html index 7a8c05e22..fc7ff7f28 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-2015 Best Practical Solutions, LLC +%# This software is Copyright (c) 1996-2016 Best Practical Solutions, LLC %# %# %# (Except where explicitly superseded by other copyright notices) @@ -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) { +<&|/l&>You don't have permission to create Articles in any Class +% } else { -% unless ( $have_classes ) { -<&|/l&>Permission Denied -

<&|/l&>To create an Article, you must first create a Class and have access to that Class.

% } +<%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; +