[Rt-commit] rt branch, 4.4/show-assets-action-menu, repushed
Dustin Graves
dustin at bestpractical.com
Fri Jun 24 14:40:20 EDT 2016
The branch 4.4/show-assets-action-menu was deleted and repushed:
was 19b90f0c880fde27b452dfda72421ebf3e3f1e6b
now 5cce23edbfef62c2f26e9ef0f94b2d1933b37e59
1: 755042f = 1: 755042f refactor RT menu building logic into own library module
2: a3a6fd5 ! 2: 16bdea4 refactor asset menu logic into separate functions
@@ -1,6 +1,6 @@
Author: Dustin Graves <dustin at bestpractical.com>
- refactor asset menu logic into own function
+ refactor asset menu logic into separate functions
diff --git a/lib/RT/Interface/Web/MenuBuilder.pm b/lib/RT/Interface/Web/MenuBuilder.pm
--- a/lib/RT/Interface/Web/MenuBuilder.pm
@@ -64,4 +64,76 @@
} elsif ($request_path =~ m{^/Asset/Search/}) {
my $page = HTML::Mason::Commands::PageMenu();
my %search = map @{$_},
+@@
+ $HTML::Mason::Commands::m->callback( CallbackName => 'Privileged', Path => $request_path, CallbackPage => '/Elements/Tabs' );
+ }
+
++sub _BuildAssetMenu {
++ my $page = HTML::Mason::Commands::PageMenu();
++ my $current_user = $HTML::Mason::Commands::session{CurrentUser};
++
++ my $id = $HTML::Mason::Commands::DECODED_ARGS->{id};
++ my $asset = RT::Asset->new( $current_user );
++ $asset->Load($id);
++
++ if ($asset->id) {
++ $page->child("display", title => HTML::Mason::Commands::loc("Display"), path => "/Asset/Display.html?id=$id");
++ $page->child("history", title => HTML::Mason::Commands::loc("History"), path => "/Asset/History.html?id=$id");
++ $page->child("basics", title => HTML::Mason::Commands::loc("Basics"), path => "/Asset/Modify.html?id=$id");
++ $page->child("links", title => HTML::Mason::Commands::loc("Links"), path => "/Asset/ModifyLinks.html?id=$id");
++ $page->child("people", title => HTML::Mason::Commands::loc("People"), path => "/Asset/ModifyPeople.html?id=$id");
++ $page->child("dates", title => HTML::Mason::Commands::loc("Dates"), path => "/Asset/ModifyDates.html?id=$id");
++
++ for my $grouping (RT::CustomField->CustomGroupings($asset)) {
++ my $cfs = $asset->CustomFields;
++ $cfs->LimitToGrouping( $asset => $grouping );
++ next unless $cfs->Count;
++ $page->child(
++ "cf-grouping-$grouping",
++ title => HTML::Mason::Commands::loc($grouping),
++ path => "/Asset/ModifyCFs.html?id=$id;Grouping=" . $HTML::Mason::Commands::m->interp->apply_escapes($grouping, 'u'),
++ );
++ }
++
++ _BuildAssetMenuActionSubmenu($asset);
++ }
++}
++
++sub _BuildAssetMenuActionSubmenu {
++ my $asset = shift;
++
++ my $page = HTML::Mason::Commands::PageMenu();
++ my $id = $asset->id;
++
++ my $actions = $page->child("actions", title => HTML::Mason::Commands::loc("Actions"));
++ $actions->child("create-linked-ticket", title => HTML::Mason::Commands::loc("Create linked ticket"), path => "/Asset/CreateLinkedTicket.html?Asset=$id");
++
++ my $status = $asset->Status;
++ my $lifecycle = $asset->LifecycleObj;
++ for my $action ( $lifecycle->Actions($status) ) {
++ my $next = $action->{'to'};
++ next unless $lifecycle->IsTransition( $status => $next );
++
++ my $check = $lifecycle->CheckRight( $status => $next );
++ next unless $asset->CurrentUserHasRight($check);
++
++ my $label = $action->{'label'} || ucfirst($next);
++ $actions->child(
++ $label,
++ title => HTML::Mason::Commands::loc($label),
++ path => "/Asset/Modify.html?id=$id;Update=1;DisplayAfter=1;Status="
++ . $HTML::Mason::Commands::m->interp->apply_escapes($next, 'u'),
++
++ class => "asset-lifecycle-action",
++ attributes => {
++ 'data-current-status' => $status,
++ 'data-next-status' => $next,
++ },
++ );
++ }
++}
++
+ sub _BuildAdminMenu {
+ my $request_path = shift;
+ my $top = shift;
3: 59e85e6 < -: ------- pass %ARGS to BuildMainNav and BuildSelfServiceNav
4: 214e52a < -: ------- replace repeated calls to HTML::Mason::Commands::Menu() with $top variable
5: 21e58a7 < -: ------- replace repeated calls to HTML::Mason::Commands::PageWidgets() with $widgets variable
6: 3033fd3 < -: ------- replace repeated calls to $HTML::Mason::Commands::session{CurrentUser} with $current_user variable
7: af2fc0a ! 3: ad11c4d clean up repeated calls to HTML::Mason::Commands with variables
@@ -1,20 +1,184 @@
Author: Dustin Graves <dustin at bestpractical.com>
- replace repeated calls to HTML::Mason::Commands::PageMenu() with $page variable
+ clean up repeated calls to HTML::Mason::Commands with variables
+
+ this replaces repeated calls to
+ HTML::Mason::Commands::Menu() with $top variable
+ HTML::Mason::Commands::PageWidgets() with $widgets variable
+ HTML::Mason::Commands::PageMenu() with $page variable
+ $HTML::Mason::Commands::session{CurrentUser} with $current_user variable
diff --git a/lib/RT/Interface/Web/MenuBuilder.pm b/lib/RT/Interface/Web/MenuBuilder.pm
--- a/lib/RT/Interface/Web/MenuBuilder.pm
+++ b/lib/RT/Interface/Web/MenuBuilder.pm
@@
-
- my $top = HTML::Mason::Commands::Menu();
- my $widgets = HTML::Mason::Commands::PageWidgets();
+ my $query_string = shift;
+ my $query_args = shift;
+
++ my $top = HTML::Mason::Commands::Menu();
++ my $widgets = HTML::Mason::Commands::PageWidgets();
+ my $page = HTML::Mason::Commands::PageMenu();
-
- my $current_user = $HTML::Mason::Commands::session{CurrentUser};
-
-@@
- my $obj = RT::Dashboard->new( $current_user );
++
++ my $current_user = $HTML::Mason::Commands::session{CurrentUser};
++
+ if ($request_path =~ m{^/Asset/}) {
+- HTML::Mason::Commands::PageWidgets()->child( asset_search => raw_html => $HTML::Mason::Commands::m->scomp('/Asset/Elements/Search') );
++ $widgets->child( asset_search => raw_html => $HTML::Mason::Commands::m->scomp('/Asset/Elements/Search') );
+ } else {
+- HTML::Mason::Commands::PageWidgets()->child( simple_search => raw_html => $HTML::Mason::Commands::m->scomp('SimpleSearch') );
+- HTML::Mason::Commands::PageWidgets()->child( create_ticket => raw_html => $HTML::Mason::Commands::m->scomp('CreateTicket') );
++ $widgets->child( simple_search => raw_html => $HTML::Mason::Commands::m->scomp('SimpleSearch') );
++ $widgets->child( create_ticket => raw_html => $HTML::Mason::Commands::m->scomp('CreateTicket') );
+ }
+
+- my $home = HTML::Mason::Commands::Menu()->child( home => title => loc('Homepage'), path => '/' );
++ my $home = $top->child( home => title => loc('Homepage'), path => '/' );
+ unless ($HTML::Mason::Commands::session{'dashboards_in_menu'}) {
+- my $dashboards_in_menu = $HTML::Mason::Commands::session{CurrentUser}->UserObj->Preferences(
++ my $dashboards_in_menu = $current_user->UserObj->Preferences(
+ 'DashboardsInMenu',
+ {},
+ );
+
+ unless ($dashboards_in_menu->{dashboards}) {
+ my ($default_dashboards) =
+- RT::System->new( $HTML::Mason::Commands::session{'CurrentUser'} )
++ RT::System->new( $current_user )
+ ->Attributes
+ ->Named('DashboardsInMenu');
+ if ($default_dashboards) {
+@@
+
+ my @dashboards;
+ for my $id ( @{$HTML::Mason::Commands::session{'dashboards_in_menu'}} ) {
+- my $dash = RT::Dashboard->new( $HTML::Mason::Commands::session{CurrentUser} );
++ my $dash = RT::Dashboard->new( $current_user );
+ my ( $status, $msg ) = $dash->LoadById($id);
+ if ( $status ) {
+ push @dashboards, $dash;
+@@
+ }
+ }
+
+- my $dashes = HTML::Mason::Commands::Menu()->child('home');
++ my $dashes = $top->child('home');
+ if (@dashboards) {
+ for my $dash (@dashboards) {
+ $home->child( 'dashboard-' . $dash->id,
+@@
+ }
+ $dashes->child( edit => title => loc('Update This Menu'), path => 'Prefs/DashboardsInMenu.html' );
+ $dashes->child( more => title => loc('All Dashboards'), path => 'Dashboards/index.html' );
+- my $dashboard = RT::Dashboard->new( $HTML::Mason::Commands::session{CurrentUser} );
++ my $dashboard = RT::Dashboard->new( $current_user );
+ if ( $dashboard->CurrentUserCanCreateAny ) {
+ $dashes->child('dashboard_create' => title => loc('New Dashboard'), path => "/Dashboards/Modify.html?Create=1" );
+ }
+
+- my $search = HTML::Mason::Commands::Menu()->child( search => title => loc('Search'), path => '/Search/Simple.html' );
++ my $search = $top->child( search => title => loc('Search'), path => '/Search/Simple.html' );
+
+ my $tickets = $search->child( tickets => title => loc('Tickets'), path => '/Search/Build.html' );
+ $tickets->child( simple => title => loc('Simple Search'), path => "/Search/Simple.html" );
+ $tickets->child( new => title => loc('New Search'), path => "/Search/Build.html?NewQuery=1" );
+
+ $search->child( articles => title => loc('Articles'), path => "/Articles/Article/Search.html" )
+- if $HTML::Mason::Commands::session{CurrentUser}->HasRight( Right => 'ShowArticlesMenu', Object => RT->System );
++ if $current_user->HasRight( Right => 'ShowArticlesMenu', Object => RT->System );
+
+ $search->child( users => title => loc('Users'), path => "/User/Search.html" );
+
+ $search->child( assets => title => loc("Assets"), path => "/Asset/Search/" )
+- if $HTML::Mason::Commands::session{CurrentUser}->HasRight( Right => 'ShowAssetsMenu', Object => RT->System );
++ if $current_user->HasRight( Right => 'ShowAssetsMenu', Object => RT->System );
+
+- if ($HTML::Mason::Commands::session{CurrentUser}->HasRight( Right => 'ShowArticlesMenu', Object => RT->System )) {
+- my $articles = HTML::Mason::Commands::Menu()->child( articles => title => loc('Articles'), path => "/Articles/index.html");
++ if ($current_user->HasRight( Right => 'ShowArticlesMenu', Object => RT->System )) {
++ my $articles = $top->child( articles => title => loc('Articles'), path => "/Articles/index.html");
+ $articles->child( articles => title => loc('Overview'), path => "/Articles/index.html" );
+ $articles->child( topics => title => loc('Topics'), path => "/Articles/Topics.html" );
+ $articles->child( create => title => loc('Create'), path => "/Articles/Article/PreCreate.html" );
+ $articles->child( search => title => loc('Search'), path => "/Articles/Article/Search.html" );
+ }
+
+- if ($HTML::Mason::Commands::session{CurrentUser}->HasRight( Right => 'ShowAssetsMenu', Object => RT->System )) {
+- my $assets = HTML::Mason::Commands::Menu()->child( "assets", title => loc("Assets"), path => "/Asset/Search/" );
++ if ($current_user->HasRight( Right => 'ShowAssetsMenu', Object => RT->System )) {
++ my $assets = $top->child( "assets", title => loc("Assets"), path => "/Asset/Search/" );
+ $assets->child( "create", title => loc("Create"), path => "/Asset/CreateInCatalog.html" );
+ $assets->child( "search", title => loc("Search"), path => "/Asset/Search/" );
+ }
+
+- my $tools = HTML::Mason::Commands::Menu()->child( tools => title => loc('Tools'), path => '/Tools/index.html' );
++ my $tools = $top->child( tools => title => loc('Tools'), path => '/Tools/index.html' );
+
+ $tools->child( my_day =>
+ title => loc('My Day'),
+@@
+ );
+ }
+
+- if ( $HTML::Mason::Commands::session{'CurrentUser'}->HasRight( Right => 'ShowApprovalsTab', Object => RT->System ) ) {
++ if ( $current_user->HasRight( Right => 'ShowApprovalsTab', Object => RT->System ) ) {
+ $tools->child( approval =>
+ title => loc('Approval'),
+ description => loc('My Approvals'),
+@@
+ );
+ }
+
+- if ( $HTML::Mason::Commands::session{'CurrentUser'}->HasRight( Right => 'ShowConfigTab', Object => RT->System ) )
++ if ( $current_user->HasRight( Right => 'ShowConfigTab', Object => RT->System ) )
+ {
+- _BuildAdminMenu($request_path, HTML::Mason::Commands::Menu());
++ _BuildAdminMenu($request_path, $top);
+ }
+
+ my $username = '<span class="current-user">'
+- . $HTML::Mason::Commands::m->interp->apply_escapes($HTML::Mason::Commands::session{'CurrentUser'}->Name, 'h')
++ . $HTML::Mason::Commands::m->interp->apply_escapes($current_user->Name, 'h')
+ . '</span>';
+- my $about_me = HTML::Mason::Commands::Menu()->child( 'preferences' =>
++ my $about_me = $top->child( 'preferences' =>
+ title => loc('Logged in as [_1]', $username),
+ escape_title => 0,
+- path => '/User/Summary.html?id=' . $HTML::Mason::Commands::session{CurrentUser}->id,
++ path => '/User/Summary.html?id=' . $current_user->id,
+ sort_order => 99,
+ );
+
+
+- if ( $HTML::Mason::Commands::session{'CurrentUser'}->UserObj
+- && $HTML::Mason::Commands::session{'CurrentUser'}->HasRight( Right => 'ModifySelf', Object => RT->System )) {
++ if ( $current_user->UserObj
++ && $current_user->HasRight( Right => 'ModifySelf', Object => RT->System )) {
+ my $settings = $about_me->child( settings => title => loc('Settings'), path => '/Prefs/Other.html' );
+ $settings->child( options => title => loc('Preferences'), path => '/Prefs/Other.html' );
+ $settings->child( about_me => title => loc('About me'), path => '/Prefs/AboutMe.html' );
+@@
+
+ my $search_menu = $settings->child( 'saved-searches' => title => loc('Saved Searches') );
+ my $searches = [ $HTML::Mason::Commands::m->comp( "/Search/Elements/SearchesForObject",
+- Object => RT::System->new( $HTML::Mason::Commands::session{'CurrentUser'} )) ];
++ Object => RT::System->new( $current_user )) ];
+ my $i = 0;
+
+ for my $search (@$searches) {
+@@
+
+ }
+ }
+- if ( $HTML::Mason::Commands::session{'CurrentUser'}->Name
++ if ( $current_user->Name
+ && ( !RT->Config->Get('WebRemoteUserAuth')
+ || RT->Config->Get('WebFallbackToRTLogin') )) {
+ $about_me->child( logout => title => loc('Logout'), path => '/NoAuth/Logout.html' );
+ }
+ if ( $request_path =~ m{^/Dashboards/(\d+)?}) {
+ if ( my $id = ( $1 || $HTML::Mason::Commands::DECODED_ARGS->{'id'} ) ) {
+- my $obj = RT::Dashboard->new( $HTML::Mason::Commands::session{'CurrentUser'} );
++ my $obj = RT::Dashboard->new( $current_user );
$obj->LoadById($id);
if ( $obj and $obj->id ) {
- my $tabs = HTML::Mason::Commands::PageMenu();
@@ -31,6 +195,11 @@
}
}
@@
+ if ( $request_path =~ m{^/Ticket/} ) {
+ if ( ( $HTML::Mason::Commands::DECODED_ARGS->{'id'} || '' ) =~ /^(\d+)$/ ) {
+ my $id = $1;
+- my $obj = RT::Ticket->new( $HTML::Mason::Commands::session{'CurrentUser'} );
++ my $obj = RT::Ticket->new( $current_user );
$obj->Load($id);
if ( $obj and $obj->id ) {
@@ -88,6 +257,33 @@
if ( $can->('ModifyTicket') or $can->('ReplyToTicket') ) {
@@
+ $actions->child( 'extract-article' =>
+ title => loc('Extract Article'),
+ path => "/Articles/Article/ExtractIntoClass.html?Ticket=".$obj->id,
+- ) if $HTML::Mason::Commands::session{CurrentUser}->HasRight( Right => 'ShowArticlesMenu', Object => RT->System );
++ ) if $current_user->HasRight( Right => 'ShowArticlesMenu', Object => RT->System );
+
+ if ( defined $HTML::Mason::Commands::session{"tickets"} ) {
+ # we have to update session data if we get new ItemMap
+@@
+ $HTML::Mason::Commands::session{"tickets"}->PrepForSerialization();
+ }
+
+- my $search = HTML::Mason::Commands::Menu()->child('search')->child('tickets');
++ my $search = $top->child('search')->child('tickets');
+ # Don't display prev links if we're on the first ticket
+ if ( $item_map->{$id}->{prev} ) {
+ $search->child( first =>
+@@
+ && $HTML::Mason::Commands::DECODED_ARGS->{'q'} )
+ )
+ {
+- my $search = HTML::Mason::Commands::Menu()->child('search')->child('tickets');
++ my $search = $top->child('search')->child('tickets');
+ my $args = '';
+ my $has_query = '';
+ my $current_search = $HTML::Mason::Commands::session{"CurrentSearchHash"} || {};
+@@
$current_search_menu = $search->child( current_search => title => loc('Current Search') );
$current_search_menu->path("/Search/Results.html$args") if $has_query;
} else {
@@ -96,6 +292,34 @@
}
$current_search_menu->child( edit_search =>
+@@
+ OrderBy => $rss_data{OrderBy}
+ );
+ my $RSSPath = join '/', map $HTML::Mason::Commands::m->interp->apply_escapes( $_, 'u' ),
+- $HTML::Mason::Commands::session{'CurrentUser'}->UserObj->Name,
+- $HTML::Mason::Commands::session{'CurrentUser'}
++ $current_user->UserObj->Name,
++ $current_user
+ ->UserObj->GenerateAuthString( $rss_data{Query}
+ . $rss_data{Order}
+ . $rss_data{OrderBy} );
+
+ $more->child( rss => title => loc('RSS'), path => "/NoAuth/rss/$RSSPath/$RSSQueryString");
+ my $ical_path = join '/', map $HTML::Mason::Commands::m->interp->apply_escapes($_, 'u'),
+- $HTML::Mason::Commands::session{'CurrentUser'}->UserObj->Name,
+- $HTML::Mason::Commands::session{'CurrentUser'}->UserObj->GenerateAuthString( $rss_data{Query} ),
++ $current_user->UserObj->Name,
++ $current_user->UserObj->GenerateAuthString( $rss_data{Query} ),
+ $rss_data{Query};
+ $more->child( ical => title => loc('iCal'), path => '/NoAuth/iCal/'.$ical_path);
+
+ if ($request_path =~ m{^/Search/Results.html}
+ && #XXX TODO better abstraction
+- $HTML::Mason::Commands::session{'CurrentUser'}->HasRight( Right => 'SuperUser', Object => RT->System )) {
++ $current_user->HasRight( Right => 'SuperUser', Object => RT->System )) {
+ my $shred_args = QueryString(
+ Search => 1,
+ Plugin => 'Tickets',
@@
if ( $request_path =~ m{^/Article/} ) {
if ( $HTML::Mason::Commands::DECODED_ARGS->{'id'} && $HTML::Mason::Commands::DECODED_ARGS->{'id'} =~ /^\d+$/ ) {
@@ -111,9 +335,13 @@
}
}
-@@
- $widgets->delete('create_ticket');
- $widgets->delete('simple_search');
+ if ( $request_path =~ m{^/Articles/} ) {
+- HTML::Mason::Commands::PageWidgets()->child( article_search => raw_html => $HTML::Mason::Commands::m->scomp('/Articles/Elements/GotoArticle') );
+- HTML::Mason::Commands::PageWidgets()->delete('create_ticket');
+- HTML::Mason::Commands::PageWidgets()->delete('simple_search');
++ $widgets->child( article_search => raw_html => $HTML::Mason::Commands::m->scomp('/Articles/Elements/GotoArticle') );
++ $widgets->delete('create_ticket');
++ $widgets->delete('simple_search');
- my $tabs = HTML::Mason::Commands::PageMenu();
- $tabs->child( search => title => loc("Search"), path => "/Articles/Article/Search.html" );
@@ -122,7 +350,8 @@
+ $page->child( create => title => loc("New Article" ), path => "/Articles/Article/PreCreate.html" );
if ( $request_path =~ m{^/Articles/Article/} and ( $HTML::Mason::Commands::DECODED_ARGS->{'id'} || '' ) =~ /^(\d+)$/ ) {
my $id = $1;
- my $obj = RT::Article->new( $current_user );
+- my $obj = RT::Article->new( $HTML::Mason::Commands::session{'CurrentUser'} );
++ my $obj = RT::Article->new( $current_user );
$obj->Load($id);
if ( $obj and $obj->id ) {
@@ -161,6 +390,15 @@
? $page
: $page->child("catalogs", title => loc("Catalogs"), path => "/Admin/Assets/Catalogs/");
@@
+ $actions->child("select", title => loc("Select"), path => "/Admin/Assets/Catalogs/");
+ $actions->child("create", title => loc("Create"), path => "/Admin/Assets/Catalogs/Create.html");
+
+- my $catalog = RT::Catalog->new( $HTML::Mason::Commands::session{CurrentUser} );
++ my $catalog = RT::Catalog->new( $current_user );
+ $catalog->Load($HTML::Mason::Commands::DECODED_ARGS->{id}) if $HTML::Mason::Commands::DECODED_ARGS->{id};
+
+ if ($catalog->id and $catalog->CurrentUserCanSee) {
+@@
}
if ( $request_path =~ m{^/User/(Summary|History)\.html} ) {
@@ -169,10 +407,11 @@
# Already set up from having AdminUser and ShowConfigTab;
# but rename "Basics" to "Edit" in this context
- HTML::Mason::Commands::PageMenu()->child( 'basics' )->title( loc('Edit') );
-+ $page->child( 'basics' )->title( loc('Edit') );
- } elsif ( $current_user->HasRight( Object => $RT::System, Right => 'ShowUserHistory' ) ) {
+- } elsif ( $HTML::Mason::Commands::session{'CurrentUser'}->HasRight( Object => $RT::System, Right => 'ShowUserHistory' ) ) {
- HTML::Mason::Commands::PageMenu()->child( display => title => loc('Summary'), path => '/User/Summary.html?id=' . $HTML::Mason::Commands::DECODED_ARGS->{'id'} );
- HTML::Mason::Commands::PageMenu()->child( history => title => loc('History'), path => '/User/History.html?id=' . $HTML::Mason::Commands::DECODED_ARGS->{'id'} );
++ $page->child( 'basics' )->title( loc('Edit') );
++ } elsif ( $current_user->HasRight( Object => $RT::System, Right => 'ShowUserHistory' ) ) {
+ $page->child( display => title => loc('Summary'), path => '/User/Summary.html?id=' . $HTML::Mason::Commands::DECODED_ARGS->{'id'} );
+ $page->child( history => title => loc('History'), path => '/User/History.html?id=' . $HTML::Mason::Commands::DECODED_ARGS->{'id'} );
}
@@ -189,9 +428,50 @@
my $top = shift;
+ my $page = HTML::Mason::Commands::PageMenu();
- my $current_user = $HTML::Mason::Commands::session{CurrentUser};
-
++ my $current_user = $HTML::Mason::Commands::session{CurrentUser};
++
my $admin = $top->child( admin => title => loc('Admin'), path => '/Admin/' );
+- if ( $HTML::Mason::Commands::session{'CurrentUser'}->HasRight( Object => RT->System, Right => 'AdminUsers' ) ) {
++ if ( $current_user->HasRight( Object => RT->System, Right => 'AdminUsers' ) ) {
+ my $users = $admin->child( users =>
+ title => loc('Users'),
+ description => loc('Manage users and passwords'),
+@@
+ $queues->child( select => title => loc('Select'), path => "/Admin/Queues/" );
+ $queues->child( create => title => loc('Create'), path => "/Admin/Queues/Modify.html?Create=1" );
+
+- if ( $HTML::Mason::Commands::session{'CurrentUser'}->HasRight( Object => RT->System, Right => 'AdminCustomField' ) ) {
++ if ( $current_user->HasRight( Object => RT->System, Right => 'AdminCustomField' ) ) {
+ my $cfs = $admin->child( 'custom-fields' =>
+ title => loc('Custom Fields'),
+ description => loc('Manage custom fields and custom field values'),
+@@
+ $cfs->child( create => title => loc('Create'), path => "/Admin/CustomFields/Modify.html?Create=1" );
+ }
+
+- if ( $HTML::Mason::Commands::session{'CurrentUser'}->HasRight( Object => RT->System, Right => 'AdminCustomRoles' ) ) {
++ if ( $current_user->HasRight( Object => RT->System, Right => 'AdminCustomRoles' ) ) {
+ my $roles = $admin->child( 'custom-roles' =>
+ title => loc('Custom Roles'),
+ description => loc('Manage custom roles'),
+@@
+ $roles->child( create => title => loc('Create'), path => "/Admin/CustomRoles/Modify.html?Create=1" );
+ }
+
+- if ( $HTML::Mason::Commands::session{'CurrentUser'}->HasRight( Object => RT->System, Right => 'ModifyScrips' ) ) {
++ if ( $current_user->HasRight( Object => RT->System, Right => 'ModifyScrips' ) ) {
+ my $scrips = $admin->child( 'scrips' =>
+ title => loc('Scrips'),
+ description => loc('Manage scrips'),
+@@
+ path => '/Admin/Tools/Theme.html',
+ );
+ if (RT->Config->Get('StatementLog')
+- && $HTML::Mason::Commands::session{'CurrentUser'}->HasRight( Right => 'SuperUser', Object => RT->System )) {
++ && $current_user->HasRight( Right => 'SuperUser', Object => RT->System )) {
+ $admin_tools->child( 'sql-queries' =>
+ title => loc('SQL Queries'),
+ description => loc('Browse the SQL queries made in this process'),
@@
if ( $request_path =~ m{^/Admin/(Queues|Users|Groups|CustomFields|CustomRoles)} ) {
@@ -214,6 +494,11 @@
}
@@
+ $HTML::Mason::Commands::DECODED_ARGS->{'Queue'} && $HTML::Mason::Commands::DECODED_ARGS->{'Queue'} =~ /^\d+$/
+ ) {
+ my $id = $HTML::Mason::Commands::DECODED_ARGS->{'Queue'} || $HTML::Mason::Commands::DECODED_ARGS->{'id'};
+- my $queue_obj = RT::Queue->new( $HTML::Mason::Commands::session{'CurrentUser'} );
++ my $queue_obj = RT::Queue->new( $current_user );
$queue_obj->Load($id);
if ( $queue_obj and $queue_obj->id ) {
@@ -223,6 +508,11 @@
$queue->child( people => title => loc('Watchers'), path => "/Admin/Queues/People.html?id=" . $id );
@@
+ if ( $request_path =~ m{^(/Admin/Users|/User/(Summary|History)\.html)} and $admin->child("users") ) {
+ if ( $HTML::Mason::Commands::DECODED_ARGS->{'id'} && $HTML::Mason::Commands::DECODED_ARGS->{'id'} =~ /^\d+$/ ) {
+ my $id = $HTML::Mason::Commands::DECODED_ARGS->{'id'};
+- my $obj = RT::User->new( $HTML::Mason::Commands::session{'CurrentUser'} );
++ my $obj = RT::User->new( $current_user );
$obj->Load($id);
if ( $obj and $obj->id ) {
@@ -250,6 +540,11 @@
}
@@
+ if ( $request_path =~ m{^/Admin/Groups} ) {
+ if ( $HTML::Mason::Commands::DECODED_ARGS->{'id'} && $HTML::Mason::Commands::DECODED_ARGS->{'id'} =~ /^\d+$/ ) {
+ my $id = $HTML::Mason::Commands::DECODED_ARGS->{'id'};
+- my $obj = RT::Group->new( $HTML::Mason::Commands::session{'CurrentUser'} );
++ my $obj = RT::Group->new( $current_user );
$obj->Load($id);
if ( $obj and $obj->id ) {
@@ -270,6 +565,11 @@
}
}
@@
+ if ( $request_path =~ m{^/Admin/CustomFields/} ) {
+ if ( $HTML::Mason::Commands::DECODED_ARGS->{'id'} && $HTML::Mason::Commands::DECODED_ARGS->{'id'} =~ /^\d+$/ ) {
+ my $id = $HTML::Mason::Commands::DECODED_ARGS->{'id'};
+- my $obj = RT::CustomField->new( $HTML::Mason::Commands::session{'CurrentUser'} );
++ my $obj = RT::CustomField->new( $current_user );
$obj->Load($id);
if ( $obj and $obj->id ) {
@@ -287,6 +587,11 @@
}
}
@@
+ if ( $request_path =~ m{^/Admin/CustomRoles} ) {
+ if ( $HTML::Mason::Commands::DECODED_ARGS->{'id'} && $HTML::Mason::Commands::DECODED_ARGS->{'id'} =~ /^\d+$/ ) {
+ my $id = $HTML::Mason::Commands::DECODED_ARGS->{'id'};
+- my $obj = RT::CustomRole->new( $HTML::Mason::Commands::session{'CurrentUser'} );
++ my $obj = RT::CustomRole->new( $current_user );
$obj->Load($id);
if ( $obj and $obj->id ) {
@@ -299,7 +604,11 @@
}
}
@@
- my $obj = RT::Scrip->new( $current_user );
+ if ( $request_path =~ m{^/Admin/Scrips/} ) {
+ if ( $HTML::Mason::Commands::m->request_args->{'id'} && $HTML::Mason::Commands::m->request_args->{'id'} =~ /^\d+$/ ) {
+ my $id = $HTML::Mason::Commands::m->request_args->{'id'};
+- my $obj = RT::Scrip->new( $HTML::Mason::Commands::session{'CurrentUser'} );
++ my $obj = RT::Scrip->new( $current_user );
$obj->Load($id);
- my $tabs = HTML::Mason::Commands::PageMenu();
@@ -345,7 +654,8 @@
if ( $request_path =~ m{^/Admin/Articles/Classes/} ) {
- my $tabs = HTML::Mason::Commands::PageMenu();
if ( my $id = $HTML::Mason::Commands::DECODED_ARGS->{'id'} ) {
- my $obj = RT::Class->new( $current_user );
+- my $obj = RT::Class->new( $HTML::Mason::Commands::session{'CurrentUser'} );
++ my $obj = RT::Class->new( $current_user );
$obj->Load($id);
if ( $obj and $obj->id ) {
@@ -376,15 +686,71 @@
}
}
@@
-
- my $top = HTML::Mason::Commands::Menu();
- my $widgets = HTML::Mason::Commands::PageWidgets();
+ sub BuildSelfServiceNav {
+ my $request_path = shift;
+
+- my $queues = RT::Queues->new( $HTML::Mason::Commands::session{'CurrentUser'} );
++ my $top = HTML::Mason::Commands::Menu();
++ my $widgets = HTML::Mason::Commands::PageWidgets();
+ my $page = HTML::Mason::Commands::PageMenu();
-
- my $current_user = $HTML::Mason::Commands::session{CurrentUser};
-
-@@
- $widgets->child( goto => raw_html => $HTML::Mason::Commands::m->scomp('/SelfService/Elements/GotoTicket') );
++
++ my $current_user = $HTML::Mason::Commands::session{CurrentUser};
++
++ my $queues = RT::Queues->new( $current_user );
+ $queues->UnLimit;
+
+ my $queue_count = 0;
+@@
+
+
+ if ( $queue_count > 1 ) {
+- HTML::Mason::Commands::Menu()->child( new => title => loc('New ticket'), path => '/SelfService/CreateTicketInQueue.html' );
++ $top->child( new => title => loc('New ticket'), path => '/SelfService/CreateTicketInQueue.html' );
+ } elsif ( $queue_id ) {
+- HTML::Mason::Commands::Menu()->child( new => title => loc('New ticket'), path => '/SelfService/Create.html?Queue=' . $queue_id );
++ $top->child( new => title => loc('New ticket'), path => '/SelfService/Create.html?Queue=' . $queue_id );
+ }
+- my $tickets = HTML::Mason::Commands::Menu()->child( tickets => title => loc('Tickets'), path => '/SelfService/' );
++ my $tickets = $top->child( tickets => title => loc('Tickets'), path => '/SelfService/' );
+ $tickets->child( open => title => loc('Open tickets'), path => '/SelfService/' );
+ $tickets->child( closed => title => loc('Closed tickets'), path => '/SelfService/Closed.html' );
+
+- HTML::Mason::Commands::Menu()->child( "assets", title => loc("Assets"), path => "/SelfService/Asset/" )
+- if $HTML::Mason::Commands::session{CurrentUser}->HasRight( Right => 'ShowAssetsMenu', Object => RT->System );
++ $top->child( "assets", title => loc("Assets"), path => "/SelfService/Asset/" )
++ if $current_user->HasRight( Right => 'ShowAssetsMenu', Object => RT->System );
+
+ my $username = '<span class="current-user">'
+- . $HTML::Mason::Commands::m->interp->apply_escapes($HTML::Mason::Commands::session{'CurrentUser'}->Name, 'h')
++ . $HTML::Mason::Commands::m->interp->apply_escapes($current_user->Name, 'h')
+ . '</span>';
+- my $about_me = HTML::Mason::Commands::Menu()->child( preferences =>
++ my $about_me = $top->child( preferences =>
+ title => loc('Logged in as [_1]', $username),
+ escape_title => 0,
+ sort_order => 99,
+ );
+
+- if ( $HTML::Mason::Commands::session{'CurrentUser'}->HasRight( Right => 'ModifySelf', Object => RT->System ) ) {
++ if ( $current_user->HasRight( Right => 'ModifySelf', Object => RT->System ) ) {
+ $about_me->child( prefs => title => loc('Preferences'), path => '/SelfService/Prefs.html' );
+ }
+
+- if ( $HTML::Mason::Commands::session{'CurrentUser'}->Name
++ if ( $current_user->Name
+ && ( !RT->Config->Get('WebRemoteUserAuth')
+ || RT->Config->Get('WebFallbackToRTLogin') )) {
+ $about_me->child( logout => title => loc('Logout'), path => '/NoAuth/Logout.html' );
+ }
+
+- if ($HTML::Mason::Commands::session{'CurrentUser'}->HasRight( Right => 'ShowArticle', Object => RT->System )) {
+- HTML::Mason::Commands::PageWidgets()->child( 'goto-article' => raw_html => $HTML::Mason::Commands::m->scomp('/SelfService/Elements/SearchArticle') );
++ if ($current_user->HasRight( Right => 'ShowArticle', Object => RT->System )) {
++ $widgets->child( 'goto-article' => raw_html => $HTML::Mason::Commands::m->scomp('/SelfService/Elements/SearchArticle') );
+ }
+
+- HTML::Mason::Commands::PageWidgets()->child( goto => raw_html => $HTML::Mason::Commands::m->scomp('/SelfService/Elements/GotoTicket') );
++ $widgets->child( goto => raw_html => $HTML::Mason::Commands::m->scomp('/SelfService/Elements/GotoTicket') );
if ($request_path =~ m{^/SelfService/Asset/} and $HTML::Mason::Commands::DECODED_ARGS->{id}) {
- my $page = HTML::Mason::Commands::PageMenu();
8: 6859056 ! 4: c50da43 define a new calling convention for menu building functions
@@ -15,22 +15,22 @@
sub BuildMainNav {
my $request_path = shift;
+- my $query_string = shift;
+- my $query_args = shift;
+ my $top = shift;
+ my $widgets = shift;
+ my $page = shift;
- my %args = ( @_ );
-
- my $query_string = $args{QueryString};
- my $query_args = $args{QueryArgs};
-
- my $top = HTML::Mason::Commands::Menu();
- my $widgets = HTML::Mason::Commands::PageWidgets();
- my $page = HTML::Mason::Commands::PageMenu();
--
++ my %args = ( @_ );
++
++ my $query_string = $args{QueryString};
++ my $query_args = $args{QueryArgs};
+
my $current_user = $HTML::Mason::Commands::session{CurrentUser};
- if ($request_path =~ m{^/Asset/}) {
@@
if ( $current_user->HasRight( Right => 'ShowConfigTab', Object => RT->System ) )
@@ -79,13 +79,13 @@
+ my $top = shift;
+ my $widgets = shift;
+ my $page = shift;
-
-- my $page = HTML::Mason::Commands::PageMenu();
++
+ my %args = (
+ Asset => undef,
+ @_
+ );
-+
+
+- my $page = HTML::Mason::Commands::PageMenu();
+ my $asset = $args{Asset};
my $id = $asset->id;
@@ -113,15 +113,13 @@
+ my $widgets = shift;
+ my $page = shift;
- my %args = ( @_ );
-
- my $top = HTML::Mason::Commands::Menu();
- my $widgets = HTML::Mason::Commands::PageWidgets();
- my $page = HTML::Mason::Commands::PageMenu();
--
++ my %args = ( @_ );
+
my $current_user = $HTML::Mason::Commands::session{CurrentUser};
- my $queues = RT::Queues->new( $current_user );
diff --git a/share/html/Elements/Tabs b/share/html/Elements/Tabs
--- a/share/html/Elements/Tabs
@@ -136,10 +134,10 @@
+
use RT::Interface::Web::MenuBuilder;
if ( $request_path !~ m{^/SelfService/} ) {
-- RT::Interface::Web::MenuBuilder::BuildMainNav( $request_path, %ARGS );
+- RT::Interface::Web::MenuBuilder::BuildMainNav( $request_path, $QueryString, $QueryArgs );
+ RT::Interface::Web::MenuBuilder::BuildMainNav( $request_path, $top, $widgets, $page, %ARGS );
} else {
-- RT::Interface::Web::MenuBuilder::BuildSelfServiceNav( $request_path, %ARGS );
+- RT::Interface::Web::MenuBuilder::BuildSelfServiceNav( $request_path );
+ RT::Interface::Web::MenuBuilder::BuildSelfServiceNav( $request_path, $top, $widgets, $page, %ARGS );
}
</%INIT>
9: 19b90f0 = 5: 5cce23e add asset display menu actions to ShowAssets template
More information about the rt-commit
mailing list