[Bps-public-commit] RT-BugTracker-Public branch, rt4, created. 93c328b1521a39123720839fe28769c359acc9f5
? sunnavy
sunnavy at bestpractical.com
Sun May 13 13:15:35 EDT 2012
The branch, rt4 has been created
at 93c328b1521a39123720839fe28769c359acc9f5 (commit)
- Log -----------------------------------------------------------------
commit 93c328b1521a39123720839fe28769c359acc9f5
Author: sunnavy <sunnavy at bestpractical.com>
Date: Sun May 13 20:58:30 2012 +0800
make it work with RT 4
includes:
* use RT 4's new menu framework
* move /Public/ out of NoAuth regex(load the public user automatically)
diff --git a/etc/RT_SiteConfig.pm b/etc/RT_SiteConfig.pm
index 6d1152d..3fae53c 100644
--- a/etc/RT_SiteConfig.pm
+++ b/etc/RT_SiteConfig.pm
@@ -1,8 +1,4 @@
# Read more about options in lib/RT/BugTracker/Public.pm
-Set($WebNoAuthRegex, qr!^(?:/+NoAuth/|
- /+Public/|
- /+REST/\d+\.\d+/NoAuth/)!x );
-
Set($WebPublicUser, 'public');
diff --git a/html/Elements/PersonalQuickbar b/html/Elements/PersonalQuickbar
deleted file mode 100644
index 806ac20..0000000
--- a/html/Elements/PersonalQuickbar
+++ /dev/null
@@ -1,44 +0,0 @@
-<div id="quick-personal">
- <span class="hide"><a href="#skipnav"><&|/l&>Skip Menu</&></a> | </span>
-% if ( $public_user ) {
- <&|/l&>You are currently an anonymous guest.</&>
- | <a href="<% RT->Config->Get('WebPath') %>/NoAuth/Logout.html?URL=<% $return_url %>"><&|/l&>Login</&></a>
- | <a href="<% RT->Config->Get('WebPath') %>/NoAuth/Logout.html"><&|/l&>Return to Main</&></a>
-% } elsif ( $logged_in ) {
- <&|/l, "<span>".$session{'CurrentUser'}->Name."</span>" &>Logged in as [_1]</&>
-% } else {
- <&|/l&>Not logged in.</&>
-% }
-% if ( $can_modify_self ) {
- | <a href="<%RT->Config->Get('WebPath')%><% $Prefs %>"><&|/l&>Preferences</&></a>
-% }
-% $m->callback( %ARGS );
-% if ( $logged_in && !$public_user ) {
-<& Logout, %ARGS &>
-% }
-</div>
-<%ARGS>
-$Prefs => '/Prefs/Other.html'
-</%ARGS>
-<%INIT>
-my $logged_in = $session{'CurrentUser'} && $session{'CurrentUser'}->Name;
-my ($can_modify_self, $public_user, $return_url) = (0, 0, '');
-if ( $logged_in ) {
- $can_modify_self = $session{'CurrentUser'}->HasRight(
- Right => 'ModifySelf', Object => $RT::System,
- ) if $Prefs;
- $public_user = $logged_in eq RT->Config->Get('WebPublicUser');
-}
-
-if ( $public_user ) {
- $return_url =
- RT->Config->Get('WebPath')
- . '/index.html?goto='
- . URI::Escape::uri_escape( URI::Escape::uri_escape(
- RT->Config->Get('WebPath')
- . $m->request_path
- . '?'
- . $m->comp('/Elements/QueryString', %{$r->args})
- ) );
-}
-</%INIT>
diff --git a/html/Public/Elements/Tabs b/html/Public/Elements/Tabs
index 218a457..139bd7a 100755
--- a/html/Public/Elements/Tabs
+++ b/html/Public/Elements/Tabs
@@ -46,102 +46,146 @@
%#
%# END BPS TAGGED BLOCK }}}
<& /Elements/PageLayout,
- toptabs => $toptabs,
- current_toptab => $current_toptab,
-
- tabs => $tabs,
- current_tab => $current_tab,
-
- topactions => $topactions,
- actions => $actions,
- subactions => $subactions,
-
title => $Title
&>
<a name="skipnav" id="skipnav" accesskey="8"></a>
<%INIT>
-my $basetopactions = {
- A => { html => $m->scomp(
- '/Elements/CreateTicket',
- SendTo => '/Public/Bug/Report.html'
- ) },
- B => { html => $m->scomp(
- '/Elements/SimpleSearch',
- SendTo => '/Public/Search/Simple.html',
- ) },
+my $query_string = sub {
+ my %args = @_;
+ my $u = URI->new();
+ $u->query_form(%args);
+ return $u->query;
};
-$basetopactions->{'0'} = {
- html => $m->scomp('/Elements/ContactInfo')
-} if $m->comp_exists('/Elements/ContactInfo');
-
-my $basetabs = {
- A => {
- title => loc('Search Distributions'),
- path => 'Public/',
- },
- C => {
- title => loc('Browse Distributions'),
- path => 'Public/Dist/Browse.html',
- },
-};
-$toptabs ||= $basetabs;
-$topactions ||= $basetopactions;
+PageWidgets()->child( simple_search => raw_html => $m->scomp(
+ '/Elements/SimpleSearch', SendTo => '/Public/Search/Simple.html'
+ )
+);
+
+PageWidgets()->child( create_ticket => raw_html =>
+ $m->scomp( '/Elements/CreateTicket', SendTo => '/Public/Bug/Report.html' ) );
+
+PageWidgets()->child( contact_info => raw_html =>
+ $m->scomp( '/Elements/ContactInfo' ) ) if $m->comp_exists('/Elements/ContactInfo');
+
+Menu()->child(
+ search_dist => title => loc('Search Distributions'),
+ path => '/Public/',
+);
+
+Menu()->child(
+ browse_dist => title => loc('Browse Distributions'),
+ path => '/Public/Dist/Browse.html',
+);
+
+my $username =
+ '<span class="current-user">'
+ . $m->interp->apply_escapes( RT::BugTracker::Public->IsPublicUser ?
+ 'anonymous guest' : $session{'CurrentUser'}->Name, 'h' )
+ . '</span>';
+
+my $about_me = Menu()->child(
+ 'preferences' => title => loc( 'Logged in as [_1]', $username ),
+ escape_title => 0,
+ sort_order => 99,
+);
+
+if ( $session{'CurrentUser'}->UserObj
+ && $session{'CurrentUser'}
+ ->HasRight( Right => 'ModifySelf', Object => RT->System ) )
+{
+ my $settings = $about_me->child(
+ settings => title => loc('Settings'),
+ path => '/Prefs/Other.html'
+ );
+ $settings->child(
+ options => title => loc('Options'),
+ path => '/Prefs/Other.html'
+ );
+ $settings->child(
+ about_me => title => loc('About me'),
+ path => '/User/Prefs.html'
+ );
+ $settings->child(
+ search_options => title => loc('Search options'),
+ path => '/Prefs/SearchOptions.html'
+ );
+ $settings->child(
+ myrt => title => loc('RT at a glance'),
+ path => '/Prefs/MyRT.html'
+ );
+ $settings->child(
+ quicksearch => title => loc('Quick search'),
+ path => '/Prefs/Quicksearch.html'
+ );
+
+ my $search_menu =
+ $settings->child( 'saved-searches' => title => loc('Saved Searches') );
+ my $searches = [
+ $m->comp(
+ "/Search/Elements/SearchesForObject",
+ Object => RT::System->new( $session{'CurrentUser'} )
+ )
+ ];
+ my $i = 0;
+
+ for my $search (@$searches) {
+ $search_menu->child(
+ "search-" . $i++ => title => $search->[0],
+ path => "/Prefs/Search.html?"
+ . $query_string->(
+ name => ref( $search->[1] ) . '-' . $search->[1]->Id
+ ),
+ );
+ }
+}
+
+if (
+ $session{'CurrentUser'}->Name
+ && ( !RT->Config->Get('WebExternalAuth')
+ || RT->Config->Get('WebFallbackToInternalAuth') )
+ )
+{
+ $about_me->child(
+ logout => title => loc('Logout'),
+ path => '/NoAuth/Logout.html'
+ );
+}
+
+Menu()->child(
+ browse_dist => title => loc('Browse Distributions'),
+ path => '/Public/Dist/Browse.html',
+);
$queue ||= $ticket->QueueObj->Name if $ticket;
if ( $queue ) {
my $escaped = $m->interp->apply_escapes($queue, 'u');
- $current_toptab = 'Public/Dist/Browse.html';
- $tabs = {
- A => {
- title => loc("Active bugs"),
- path => "Public/Dist/Display.html?Status=Active&Name=". $escaped,
- },
- Ab => {
+ PageMenu()->child(
+ active_bugs => title => loc("Active bugs"),
+ path => "/Public/Dist/Display.html?Status=Active&Name=" . $escaped,
+ );
+
+ PageMenu()->child( resolved_bugs =>
title => loc("Resolved bugs"),
- path => "Public/Dist/Display.html?Status=Resolved&Name=". $escaped,
- },
- Ac => {
+ path => "/Public/Dist/Display.html?Status=Resolved&Name=". $escaped,
+ );
+
+ PageMenu()->child( rejected_bugs =>
title => loc("Rejected bugs"),
- path => "Public/Dist/Display.html?Status=Rejected&Name=". $escaped,
- },
- B => {
+ path => "/Public/Dist/Display.html?Status=Rejected&Name=". $escaped,
+ );
+
+ PageMenu()->child( report =>
title => loc("Report a new bug"),
- path => 'Public/Bug/Report.html?Queue='. $escaped,
- },
- };
- if ( $ticket && !$current_tab ) {
- my $status = $ticket->Status;
- if ( $ticket->QueueObj->IsActiveStatus( $status ) ) {
- $current_tab = "Public/Dist/Display.html?Status=Active&Name=". $escaped;
- } elsif ( $status eq 'rejected' || $status eq 'deleted' ) {
- $current_tab = "Public/Dist/Display.html?Status=Rejected&Name=". $escaped;
- } else {
- $current_tab = "Public/Dist/Display.html?Status=Resolved&Name=". $escaped;
-
- }
- }
+ path => '/Public/Bug/Report.html?Queue='. $escaped,
+ );
}
-$m->callback(
- topactions => $topactions,
- toptabs => $toptabs,
- %ARGS
-);
+$m->callback( %ARGS );
</%INIT>
<%ARGS>
-$toptabs => undef
-$current_toptab => undef
-
-$tabs => undef
-$current_tab => undef
-
-$topactions => undef
-$actions => undef
-$subactions => undef
-
$Title => undef
$ticket => undef
$queue => undef
diff --git a/lib/RT/BugTracker/Public.pm b/lib/RT/BugTracker/Public.pm
index 1ce7164..6110d65 100644
--- a/lib/RT/BugTracker/Public.pm
+++ b/lib/RT/BugTracker/Public.pm
@@ -64,18 +64,6 @@ You can find F<local/etc/BugTracker-Public/RT_SiteConfig.pm> with example of
configuration and sane defaults. Add require in the main F<RT_SiteConfig.pm> or
define options there.
-=head2 NoAuthRegexp
-
-As public shouldn't require authentication then you should add '/Public/' path
-to NoAuthRegexp option, something like:
-
- Set($WebNoAuthRegex, qr!^(?:/+NoAuth/|
- /+Public/|
- /+REST/\d+\.\d+/NoAuth/)!x );
-
-Note that if you have multiple extensions that want to change this option then
-you have to merge them manually into one perl regular expression.
-
=head2 WebPublicUser
Make sure to create the public user in your RT system and add the line below
-----------------------------------------------------------------------
More information about the Bps-public-commit
mailing list