[Rt-commit] rt branch, 4.2/article-create, created. rt-4.2.10-100-g4e4eda1
Alex Vandiver
alexmv at bestpractical.com
Wed Mar 4 15:53:59 EST 2015
The branch, 4.2/article-create has been created
at 4e4eda15f8e6dabb0eac1e3cb962e56265fb6028 (commit)
- Log -----------------------------------------------------------------
commit c1226479415e133d13b0bab6487270674ca28935
Author: Alex Vandiver <alexmv at bestpractical.com>
Date: Mon Oct 6 16:49:30 2014 -0400
Distinguish between "no classes exist" and "none visible to user"
Fixes: I#30638
diff --git a/share/html/Articles/Article/PreCreate.html b/share/html/Articles/Article/PreCreate.html
index 8d0de96..bdd7a94 100644
--- a/share/html/Articles/Article/PreCreate.html
+++ b/share/html/Articles/Article/PreCreate.html
@@ -47,16 +47,22 @@
%# END BPS TAGGED BLOCK }}}
<& /Elements/Header, Title => loc('Create an article in class...') &>
<& /Elements/Tabs &>
+
+% if (not $classes_configured) {
+<& /Articles/Elements/NeedsSetup &>
+% } else {
<ul>
-% my $Classes = RT::Classes->new($session{'CurrentUser'});
-% $Classes->LimitToEnabled();
-% my $have_classes = 0;
% while (my $Class = $Classes->Next) {
-% $have_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 ) {
-<& /Articles/Elements/NeedsSetup &>
% }
+<%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;
+</%init>
diff --git a/share/html/Articles/Article/Search.html b/share/html/Articles/Article/Search.html
index d5800e7..8aec368 100644
--- a/share/html/Articles/Article/Search.html
+++ b/share/html/Articles/Article/Search.html
@@ -49,23 +49,20 @@
<& /Elements/Tabs &>
% unless ( keys %ARGS ) {
-% my $Classes = RT::Classes->new($session{'CurrentUser'});
-% $Classes->LimitToEnabled();
<table width="100%" border="0">
<tr>
<td valign="top" width="50%">
-<%perl>
-if (not $Classes->First) {
- $m->comp("/Articles/Elements/NeedsSetup");
-} else {
- $Classes->GotoFirstItem; # Reset for loop below
-}
-</%perl>
+% if (not $classes_configured) {
+<& /Articles/Elements/NeedsSetup &>
+% } elsif (not @classes) {
+<i><&|/l&>You don't have permission to view Articles in any Class</&></i>
+% } else {
<ul>
-% while (my $class = $Classes->Next) {
+% for my $class (@classes) {
<li><a href="<%RT->Config->Get('WebPath')%>/Articles/Article/Search.html?<% $m->comp('/Elements/QueryString', %filtered, Class => $class->id) %>"><&|/l, $class->Name&>in class [_1]</&></a></li>
-% }
+% }
</ul>
+% }
</td>
<td valign="top" width="50%">
<form action="Search.html" method="get">
@@ -114,6 +111,14 @@ if (not $Classes->First) {
<a href="<%RT->Config->Get('WebPath')%>/Articles/Article/Search.html<%$QueryString%>"><&|/l&>Bookmarkable link for this search</&></a><br />
</div>
<%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;
+my @classes = @{ $Classes->ItemsArrayRef };
+
use RT::SavedSearch;
my @results;
my $articles = RT::Articles->new( $session{'CurrentUser'} );
diff --git a/share/html/Articles/Elements/MaybeNeedsSetup b/share/html/Articles/Elements/MaybeNeedsSetup
index a283487..40f1d48 100644
--- a/share/html/Articles/Elements/MaybeNeedsSetup
+++ b/share/html/Articles/Elements/MaybeNeedsSetup
@@ -48,7 +48,8 @@
<%init>
my $Classes = RT::Classes->new( $session{'CurrentUser'} );
$Classes->LimitToEnabled();
-$Classes->RowsPerPage(1);
-return if $Classes->First;
+# 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.
+return if $Classes->Count;
</%init>
<& NeedsSetup &>
commit 5209d26d3f7cf5b591660ef0c03415d14a38db95
Author: Alex Vandiver <alexmv at bestpractical.com>
Date: Mon Oct 6 16:53:22 2014 -0400
Limit the listing to classes with CreateArticle
diff --git a/share/html/Articles/Article/PreCreate.html b/share/html/Articles/Article/PreCreate.html
index bdd7a94..a62d7a8 100644
--- a/share/html/Articles/Article/PreCreate.html
+++ b/share/html/Articles/Article/PreCreate.html
@@ -52,7 +52,7 @@
<& /Articles/Elements/NeedsSetup &>
% } else {
<ul>
-% while (my $Class = $Classes->Next) {
+% 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>
% }
@@ -65,4 +65,10 @@ $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");
+}
</%init>
commit c41f11b0b1f3823ac8ffb5dc9860a04923f5eb64
Author: Alex Vandiver <alexmv at bestpractical.com>
Date: Mon Oct 6 16:53:39 2014 -0400
Provide a better message if there are no potential classes to create in
diff --git a/share/html/Articles/Article/PreCreate.html b/share/html/Articles/Article/PreCreate.html
index a62d7a8..dc37ef2 100644
--- a/share/html/Articles/Article/PreCreate.html
+++ b/share/html/Articles/Article/PreCreate.html
@@ -50,6 +50,8 @@
% 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>
% for my $Class (@classes) {
commit 4e4eda15f8e6dabb0eac1e3cb962e56265fb6028
Author: Alex Vandiver <alexmv at bestpractical.com>
Date: Mon Oct 6 16:54:32 2014 -0400
Skip the Class selection page if there is only one valid option
Fixes: I#29975
diff --git a/share/html/Articles/Article/PreCreate.html b/share/html/Articles/Article/PreCreate.html
index dc37ef2..6daa232 100644
--- a/share/html/Articles/Article/PreCreate.html
+++ b/share/html/Articles/Article/PreCreate.html
@@ -73,4 +73,11 @@ 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>
diff --git a/share/html/Articles/Article/Search.html b/share/html/Articles/Article/Search.html
index 8aec368..4b8745a 100644
--- a/share/html/Articles/Article/Search.html
+++ b/share/html/Articles/Article/Search.html
@@ -118,6 +118,7 @@ $Classes->LimitToEnabled();
# the warning if there are classes, but the user can't see them.
my $classes_configured = $Classes->Count;
my @classes = @{ $Classes->ItemsArrayRef };
+$ARGS{Class} = $classes[0]->id if @classes == 1;
use RT::SavedSearch;
my @results;
-----------------------------------------------------------------------
More information about the rt-commit
mailing list