"Fossies" - the Fresh Open Source Software Archive 
Member "RT-Extension-Assets-1.05/html/Callbacks/RT-Extension-Assets/Elements/Tabs/Privileged" (17 Mar 2015, 9279 Bytes) of package /linux/misc/RT-Extension-Assets-1.05.tar.gz:
As a special service "Fossies" has tried to format the requested text file into HTML format (style:
standard) with prefixed line numbers.
Alternatively you can here
view or
download the uninterpreted source code file.
See also the last
Fossies "Diffs" side-by-side code changes report for "Privileged":
1.01_vs_1.02.
1 %# BEGIN BPS TAGGED BLOCK {{{
2 %#
3 %# COPYRIGHT:
4 %#
5 %# This software is Copyright (c) 1996-2014 Best Practical Solutions, LLC
6 %# <sales@bestpractical.com>
7 %#
8 %# (Except where explicitly superseded by other copyright notices)
9 %#
10 %#
11 %# LICENSE:
12 %#
13 %# This work is made available to you under the terms of Version 2 of
14 %# the GNU General Public License. A copy of that license should have
15 %# been provided with this software, but in any event can be snarfed
16 %# from www.gnu.org.
17 %#
18 %# This work is distributed in the hope that it will be useful, but
19 %# WITHOUT ANY WARRANTY; without even the implied warranty of
20 %# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
21 %# General Public License for more details.
22 %#
23 %# You should have received a copy of the GNU General Public License
24 %# along with this program; if not, write to the Free Software
25 %# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
26 %# 02110-1301 or visit their web page on the internet at
27 %# http://www.gnu.org/licenses/old-licenses/gpl-2.0.html.
28 %#
29 %#
30 %# CONTRIBUTION SUBMISSION POLICY:
31 %#
32 %# (The following paragraph is not intended to limit the rights granted
33 %# to you to modify and distribute this software under the terms of
34 %# the GNU General Public License and is only of importance to you if
35 %# you choose to contribute your changes and enhancements to the
36 %# community by submitting them to Best Practical Solutions, LLC.)
37 %#
38 %# By intentionally submitting any modifications, corrections or
39 %# derivatives to this work, or any other work intended for use with
40 %# Request Tracker, to Best Practical Solutions, LLC, you confirm that
41 %# you are the copyright holder for those contributions and you grant
42 %# Best Practical Solutions, LLC a nonexclusive, worldwide, irrevocable,
43 %# royalty-free, perpetual, license to use, copy, create derivative
44 %# works based on those contributions, and sublicense and distribute
45 %# those contributions and any derivatives thereof.
46 %#
47 %# END BPS TAGGED BLOCK }}}
48 <%args>
49 $Path
50 </%args>
51 <%init>
52
53 my $query_string = sub {
54 my %args = @_;
55 my $u = URI->new();
56 $u->query_form(map { $_ => $args{$_} } sort keys %args);
57 return $u->query || '';
58 };
59
60 # Top level Assets menu
61 my $assets = Menu->child("tools")->add_before(
62 "assets", title => loc("Assets"), path => "/Asset/Search/");
63 $assets->child("create", title => loc("Create"), path => "/Asset/CreateInCatalog.html");
64 $assets->child("search", title => loc("Search"), path => "/Asset/Search/");
65
66 Menu->child("search")->child("assets", title => loc("Assets"), path => "/Asset/Search/");
67
68 # Add global Assets custom field admin page
69 my $global_cfs = Menu();
70 $global_cfs = $global_cfs->child($_) or last
71 for "admin" => "global" => "custom-fields";
72 $global_cfs->child("assets", title => loc("Assets"), path => "/Admin/Global/CustomFields/Catalog-Assets.html")
73 if $global_cfs;
74
75 # Add a Catalog admin menu
76 my $config = Menu()->child("admin");
77 if ($config) {
78 my $assets = $config->child("tools")->add_before("assets", title => loc("Assets"), path => "/Admin/Assets/");
79 my $catalogs = $assets->child("catalogs",
80 title => loc("Catalogs"),
81 description => loc("Modify asset catalogs"),
82 path => "/Admin/Assets/Catalogs/");
83 $catalogs->child("select", title => loc("Select"), path => $catalogs->path);
84 $catalogs->child("create", title => loc("Create"), path => "Create.html");
85
86 my $cfs = $assets->child("cfs",
87 title => loc("Custom Fields"),
88 description => loc("Modify asset custom fields"),
89 path => "/Admin/CustomFields/?Type=" . RT::Asset->CustomFieldLookupType);
90 $cfs->child("select", title => loc("Select"), path => $cfs->path);
91 $cfs->child("create", title => loc("Create"), path => "/Admin/CustomFields/Modify.html?Create=1&LookupType=" . RT::Asset->CustomFieldLookupType);
92 }
93
94 # Asset search
95 if ($Path =~ m{^/Asset/}) {
96 PageWidgets()->child( asset_search => raw_html => $m->scomp('/Elements/Assets/Search') );
97 PageWidgets()->delete('create_ticket');
98 PageWidgets()->delete('simple_search');
99 }
100
101 # Page menus
102 my $page = PageMenu();
103
104 if ($Path =~ m{^/Asset/} and $DECODED_ARGS->{id} and $DECODED_ARGS->{id} !~ /\D/) {
105 my $id = $DECODED_ARGS->{id};
106 my $asset = RT::Asset->new( $session{CurrentUser} );
107 $asset->Load($id);
108
109 if ($asset->id) {
110 $page->child("display", title => loc("Display"), path => "/Asset/Display.html?id=$id");
111 $page->child("history", title => loc("History"), path => "/Asset/History.html?id=$id");
112 $page->child("basics", title => loc("Basics"), path => "/Asset/Modify.html?id=$id");
113 $page->child("links", title => loc("Links"), path => "/Asset/ModifyLinks.html?id=$id");
114 $page->child("people", title => loc("People"), path => "/Asset/ModifyPeople.html?id=$id");
115 $page->child("dates", title => loc("Dates"), path => "/Asset/ModifyDates.html?id=$id");
116
117 for my $grouping (RT::CustomField->CustomGroupings($asset)) {
118 my $cfs = $asset->CustomFields;
119 $cfs->LimitToGrouping( $asset => $grouping );
120 next unless $cfs->Count;
121 $page->child(
122 "cf-grouping-$grouping",
123 title => loc($grouping),
124 path => "/Asset/ModifyCFs.html?id=$id;Grouping=" . $m->interp->apply_escapes($grouping, 'u'),
125 );
126 }
127
128 my $actions = $page->child("actions", title => loc("Actions"));
129 $actions->child("create-linked-ticket", title => loc("Create linked ticket"), path => "/Asset/CreateLinkedTicket.html?Asset=$id");
130
131 my $status = $asset->Status;
132 my $lifecycle = $asset->LifecycleObj;
133 for my $action ( $lifecycle->Actions($status) ) {
134 my $next = $action->{'to'};
135 next unless $lifecycle->IsTransition( $status => $next );
136
137 my $check = $lifecycle->CheckRight( $status => $next );
138 next unless $asset->CurrentUserHasRight($check);
139
140 my $label = $action->{'label'} || ucfirst($next);
141 $actions->child(
142 $label,
143 title => loc($label),
144 path => "/Asset/Modify.html?id=$id;Update=1;DisplayAfter=1;Status="
145 . $m->interp->apply_escapes($next, 'u'),
146
147 class => "asset-lifecycle-action",
148 attributes => {
149 'data-current-status' => $status,
150 'data-next-status' => $next,
151 },
152 );
153 }
154 }
155 }
156 elsif ($Path =~ m{^/Asset/Search/}) {
157 my %search = map @{$_},
158 grep defined $_->[1] && length $_->[1],
159 map {ref $DECODED_ARGS->{$_} ? [$_, $DECODED_ARGS->{$_}[0]] : [$_, $DECODED_ARGS->{$_}] }
160 grep /^(?:q|SearchAssets|!?(Name|Description|Catalog|Status|Role\..+|CF\..+)|Order(?:By)?|Page)$/,
161 keys %$DECODED_ARGS;
162 if ( $Path =~ /Bulk/) {
163 $page->child('search',
164 title => loc('Show Results'),
165 path => '/Asset/Search/?'. $query_string->(%search),
166 );
167 } else {
168 $page->child('bulk',
169 title => loc('Bulk Update'),
170 path => '/Asset/Search/Bulk.html?'. $query_string->(%search),
171 );
172 }
173 $page->child('csv',
174 title => loc('Download Spreadsheet'),
175 path => '/Asset/Search/Results.tsv?' . $query_string->(%search),
176 );
177 }
178 elsif ($Path =~ m{^/Admin/Global/CustomFields/Catalog-Assets\.html$}) {
179 $page->child("create", title => loc("Create New"), path => "/Admin/CustomFields/Modify.html?Create=1;LookupType=" . RT::Asset->CustomFieldLookupType);
180 }
181 elsif ($Path =~ m{^/Admin/CustomFields(/|/index\.html)?$}
182 and $DECODED_ARGS->{'Type'} and $DECODED_ARGS->{'Type'} eq RT::Asset->CustomFieldLookupType) {
183 $page->child("create")->path( $page->child("create")->path . "&LookupType=" . RT::Asset->CustomFieldLookupType );
184 }
185 elsif ($Path =~ m{^/Admin/Assets/Catalogs/}) {
186 my $actions = $Path =~ m{/((index|Create)\.html)?$}
187 ? $page
188 : $page->child("catalogs", title => loc("Catalogs"), path => "/Admin/Assets/Catalogs/");
189
190 $actions->child("select", title => loc("Select"), path => "/Admin/Assets/Catalogs/");
191 $actions->child("create", title => loc("Create"), path => "/Admin/Assets/Catalogs/Create.html");
192
193 my $catalog = RT::Catalog->new( $session{CurrentUser} );
194 $catalog->Load($DECODED_ARGS->{id}) if $DECODED_ARGS->{id};
195
196 if ($catalog->id and $catalog->CurrentUserCanSee) {
197 my $query = "id=" . $catalog->id;
198 $page->child("modify", title => loc("Basics"), path => "/Admin/Assets/Catalogs/Modify.html?$query");
199 $page->child("people", title => loc("Roles"), path => "/Admin/Assets/Catalogs/Roles.html?$query");
200
201 $page->child("cfs", title => loc("Asset Custom Fields"), path => "/Admin/Assets/Catalogs/CustomFields.html?$query");
202
203 $page->child("group-rights", title => loc("Group Rights"), path => "/Admin/Assets/Catalogs/GroupRights.html?$query");
204 $page->child("user-rights", title => loc("User Rights"), path => "/Admin/Assets/Catalogs/UserRights.html?$query");
205 }
206 }
207 </%init>