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=2b11ac08960213231417795c2f3cb02fb953f709;hb=7322f2afedcc2f427e997d1535a503613a83f088;hpb=45d35d5739d05e602bc317739485693e0e9ff0b5 diff --git a/rt/share/html/Articles/Article/PreCreate.html b/rt/share/html/Articles/Article/PreCreate.html index 2b11ac089..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-2014 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; +