summaryrefslogtreecommitdiff
path: root/rt/share/html/Articles/Article/PreCreate.html
diff options
context:
space:
mode:
authorMark Wells <mark@freeside.biz>2015-07-10 18:15:08 -0700
committerMark Wells <mark@freeside.biz>2015-07-10 18:15:08 -0700
commit88bf5db0cca989c51237c661a13078eef08b3674 (patch)
tree0a84e1b5e7fd239f57fab678bf40c5311b0064a0 /rt/share/html/Articles/Article/PreCreate.html
parent9c15ffe3a5ee987e30e10c6a0ad1b5bf0b2a12e3 (diff)
parente7eb845db1afab1cbdbc34ff9c387c5ac554659e (diff)
Merge branch 'FREESIDE_4_BRANCH' of git.freeside.biz:/home/git/freeside into 4.x
Diffstat (limited to 'rt/share/html/Articles/Article/PreCreate.html')
-rw-r--r--rt/share/html/Articles/Article/PreCreate.html38
1 files changed, 29 insertions, 9 deletions
diff --git a/rt/share/html/Articles/Article/PreCreate.html b/rt/share/html/Articles/Article/PreCreate.html
index 2b11ac089..6daa23246 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-2015 Best Practical Solutions, LLC
%# <sales@bestpractical.com>
%#
%# (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) {
+<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>