[Rt-commit] rt branch, 4.2/article-create, created. rt-4.2.8-10-g3b35d73
Alex Vandiver
alexmv at bestpractical.com
Mon Oct 6 16:55:18 EDT 2014
The branch, 4.2/article-create has been created
at 3b35d737121f95746e09a90da11707129c44d867 (commit)
- Log -----------------------------------------------------------------
commit bcf0ba43bae17d62340a904084e8a36da14f558c
Author: Alex Vandiver <alexmv at bestpractical.com>
Date: Mon Oct 6 16:46:54 2014 -0400
Simplify ->Next logic
diff --git a/lib/RT/Classes.pm b/lib/RT/Classes.pm
index fd3a3aa..656e93a 100644
--- a/lib/RT/Classes.pm
+++ b/lib/RT/Classes.pm
@@ -73,23 +73,10 @@ Returns the next Object that this user can see.
sub Next {
my $self = shift;
-
my $Object = $self->SUPER::Next();
- if ((defined($Object)) and (ref($Object))) {
- if ( $Object->CurrentUserHasRight('SeeClass') ) {
- return($Object);
- }
-
- #If the user doesn't have the right to show this Object
- else {
- return($self->Next());
- }
- }
- #if there never was any Object
- else {
- return(undef);
- }
-
+ return undef unless defined $Object;
+ return $self->Next unless $Object->CurrentUserHasRight('SeeClass');
+ return $Object;
}
sub _SingularClass { "RT::Class" }
commit f6454b93b93b0a9f605f8ac7723819f98019089e
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"
diff --git a/share/html/Articles/Article/PreCreate.html b/share/html/Articles/Article/PreCreate.html
index 305d935..aca5bf2 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>
commit a3c49b3150b5b58eb32656bd8afd70deb028a276
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 aca5bf2..5d4dc64 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 8bde325b9be6fc2ce2be6d93fecf2aef59a7fe5b
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 5d4dc64..1ae1d84 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 3b35d737121f95746e09a90da11707129c44d867
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
Partially resolves I#29975
diff --git a/share/html/Articles/Article/PreCreate.html b/share/html/Articles/Article/PreCreate.html
index 1ae1d84..30c3be3 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>
-----------------------------------------------------------------------
More information about the rt-commit
mailing list