Skip to content

Commit 51c15ef

Browse files
committed
Swept the use of $app->param from numerous modules that only used that method occasionally.
1 parent 0441304 commit 51c15ef

File tree

14 files changed

+67
-57
lines changed

14 files changed

+67
-57
lines changed

lib/MT/Asset/Image.pm

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -262,7 +262,7 @@ sub as_html {
262262
my $text = '';
263263

264264
my $app = MT->instance;
265-
$param->{enclose} = 0 unless ($app->param('edit_field') =~ /^customfield/);
265+
$param->{enclose} = 0 unless ($app->query->param('edit_field') =~ /^customfield/);
266266
$param->{enclose} = 1 unless exists $param->{enclose};
267267

268268
if ( $param->{include} ) {

lib/MT/Auth/MT.pm

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -54,11 +54,12 @@ sub login_credentials {
5454
my ($ctx) = @_;
5555

5656
my $app = $ctx->{app} or return;
57-
if ($app->param('username') && $app->param('password')) {
57+
my $q = $app->query;
58+
if ($q->param('username') && $q->param('password')) {
5859
my ($user, $pass, $remember);
59-
$user = $app->param('username');
60-
$pass = $app->param('password');
61-
$remember = $app->param('remember') ? 1 : 0;
60+
$user = $q->param('username');
61+
$pass = $q->param('password');
62+
$remember = $q->param('remember') ? 1 : 0;
6263
return { %$ctx, username => $user, password => $pass, permanent => $remember, auth_type => 'MT' };
6364
}
6465
return undef;

lib/MT/Auth/OpenID.pm

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,7 @@ sub handle_sign_in {
5353
my $cmntr;
5454
my $session;
5555

56-
my %param = $app->param_hash;
56+
my %param = $app->query->Vars;
5757
my $csr = $class->get_csr(\%param, $blog) or return 0;
5858

5959
if(my $setup_url = $csr->user_setup_url( post_grant => 'return' )) {
@@ -157,7 +157,7 @@ sub check_openid {
157157
my ( $app, $blog, $identity ) = @_;
158158
my $q = $app->query;
159159

160-
my %param = $app->param_hash;
160+
my %param = $app->query->Vars;
161161
my $csr = $class->get_csr(\%param, $blog);
162162
unless ( $csr ) {
163163
$app->errtrans('Could not load Net::OpenID::Consumer.');

lib/MT/CMS/AddressBook.pm

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -227,16 +227,17 @@ sub can_save {
227227
sub save_filter {
228228
my $eh = shift;
229229
my ($app) = @_;
230-
my $email = lc $app->param('email');
230+
my $q = $app->query;
231+
my $email = lc $q->param('email');
231232
$email =~ s/(^\s+|\s+$)//gs;
232-
my $blog_id = $app->param('blog_id');
233+
my $blog_id = $q->param('blog_id');
233234
if ( !is_valid_email($email) ) {
234235
return $eh->error(
235236
$app->translate(
236237
"The value you entered was not a valid email address")
237238
);
238239
}
239-
my $url = $app->param('url');
240+
my $url = $q->param('url');
240241
if ( $url && ( !is_url($url) ) ) {
241242
return $eh->error(
242243
$app->translate(
@@ -250,7 +251,7 @@ sub save_filter {
250251
MT::Notification->load_iter( { blog_id => $blog_id } );
251252
while ( my $obj = $notification_iter->() ) {
252253
if ( ( lc( $obj->email ) eq $email )
253-
&& ( $obj->id ne $app->param('id') ) )
254+
&& ( $obj->id ne $q->param('id') ) )
254255
{
255256
return $eh->error(
256257
$app->translate(

lib/MT/CMS/BanList.pm

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -12,16 +12,17 @@ sub can_save {
1212
sub save_filter {
1313
my $eh = shift;
1414
my ($app) = @_;
15-
my $ip = $app->param('ip');
15+
my $q = $app->query;
16+
my $ip = $q->param('ip');
1617
$ip =~ s/(^\s+|\s+$)//g;
1718
return $eh->error(
1819
MT->translate("You did not enter an IP address to ban.") )
1920
if ( '' eq $ip );
20-
my $blog_id = $app->param('blog_id');
21+
my $blog_id = $q->param('blog_id');
2122
require MT::IPBanList;
2223
my $existing =
2324
MT::IPBanList->load( { 'ip' => $ip, 'blog_id' => $blog_id } );
24-
my $id = $app->param('id');
25+
my $id = $q->param('id');
2526

2627
if ( $existing && ( !$id || $existing->id != $id ) ) {
2728
return $eh->error(

lib/MT/CMS/Dashboard.pm

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -5,26 +5,27 @@ use MT::Util qw( epoch2ts encode_html );
55

66
sub dashboard {
77
my $app = shift;
8+
my $q = $app->query;
89
my (%param) = @_;
910

1011
if ( $app->request('fresh_login') ) {
11-
if ( !$app->param('blog_id') ) {
12+
if ( !$q->param('blog_id') ) {
1213

1314
# return to the last blog they visted, if any
1415
my $fav_blogs = $app->user->favorite_blogs || [];
1516
my $blog_id = $fav_blogs->[0] if @$fav_blogs;
16-
$app->param( 'blog_id', $blog_id ) if $blog_id;
17+
$q->param( 'blog_id', $blog_id ) if $blog_id;
1718
$app->delete_param('blog_id') unless $app->is_authorized;
1819
}
1920
}
2021

2122
my $param = \%param;
2223

23-
$param->{redirect} ||= $app->param('redirect');
24-
$param->{permission} ||= $app->param('permission');
25-
$param->{saved} ||= $app->param('saved');
24+
$param->{redirect} ||= $q->param('redirect');
25+
$param->{permission} ||= $q->param('permission');
26+
$param->{saved} ||= $q->param('saved');
2627

27-
$param->{system_overview_nav} = $app->param('blog_id') ? 0 : defined($app->param('blog_id')) ? 1 : 0;
28+
$param->{system_overview_nav} = $q->param('blog_id') ? 0 : defined($q->param('blog_id')) ? 1 : 0;
2829
$param->{quick_search} = 0;
2930
$param->{no_breadcrumbs} = 1;
3031
$param->{screen_class} = "dashboard";

lib/MT/CMS/Export.pm

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,9 @@ use MT::Util qw( dirify );
55

66
sub start_export {
77
my $app = shift;
8+
my $q = $app->query;
89
my %param;
9-
my $blog_id = $app->param('blog_id');
10+
my $blog_id = $q->param('blog_id');
1011

1112
my $perms = $app->permissions;
1213
return $app->return_to_dashboard( permission => 1 )
@@ -18,9 +19,10 @@ sub start_export {
1819

1920
sub export {
2021
my $app = shift;
22+
my $q = $app->query;
2123
my $charset = $app->charset;
2224
require MT::Blog;
23-
my $blog_id = $app->param('blog_id')
25+
my $blog_id = $q->param('blog_id')
2426
or return $app->error( $app->translate("Please select a blog.") );
2527
my $blog = MT::Blog->load($blog_id)
2628
or return $app->error(
@@ -38,7 +40,7 @@ sub export {
3840
if ( $file eq ".txt" ) {
3941
my @ts = localtime(time);
4042
$file = sprintf "export-%06d-%04d%02d%02d%02d%02d%02d.txt",
41-
$app->param('blog_id'), $ts[5] + 1900, $ts[4] + 1, @ts[ 3, 2, 1, 0 ];
43+
$q->param('blog_id'), $ts[5] + 1900, $ts[4] + 1, @ts[ 3, 2, 1, 0 ];
4244
}
4345

4446
$app->{no_print_body} = 1;

lib/MT/CMS/Folder.pm

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -71,9 +71,10 @@ sub post_save {
7171
sub save_filter {
7272
my $eh = shift;
7373
my ($app) = @_;
74+
my $q = $app->query;
7475
return $app->errtrans( "The name '[_1]' is too long!",
75-
$app->param('label') )
76-
if ( length( $app->param('label') ) > 100 );
76+
$q->param('label') )
77+
if ( length( $q->param('label') ) > 100 );
7778
return 1;
7879
}
7980

lib/MT/CMS/Import.pm

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ use MT::I18N qw( const );
66

77
sub start_import {
88
my $app = shift;
9-
my $blog_id = $app->param('blog_id');
9+
my $blog_id = $app->query->param('blog_id');
1010

1111
my $perms = $app->permissions;
1212
return $app->return_to_dashboard( permission => 1 )

lib/MT/CMS/Log.pm

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,9 @@ use MT::I18N qw( const break_up_text encode_text );
77

88
sub view {
99
my $app = shift;
10+
my $q = $app->query;
1011
my $user = $app->user;
11-
my $blog_id = $app->param('blog_id');
12+
my $blog_id = $q->param('blog_id');
1213
my $perms = $app->permissions;
1314
if ($blog_id) {
1415
return $app->error( $app->translate("Permission denied.") )
@@ -22,15 +23,15 @@ sub view {
2223
my $blog_class = $app->model('blog');
2324
my $list_pref = $app->list_pref('log');
2425
my $limit = $list_pref->{rows};
25-
my $offset = $app->param('offset') || 0;
26+
my $offset = $q->param('offset') || 0;
2627
my $terms = { $blog_id ? ( blog_id => $blog_id ) : () };
2728
my $cfg = $app->config;
2829
my %param = (%$list_pref);
2930
my ( $filter_col, $val );
3031
$param{filter_args} = "";
3132

32-
if ( ( $filter_col = $app->param('filter') )
33-
&& ( $val = $app->param('filter_val') ) )
33+
if ( ( $filter_col = $q->param('filter') )
34+
&& ( $val = $q->param('filter_val') ) )
3435
{
3536
$param{filter} = $filter_col;
3637
$param{filter_val} = $val;
@@ -115,7 +116,7 @@ sub view {
115116
$param{prev_offset_val} = $offset - $limit;
116117
$param{prev_offset_val} = 0 if $param{prev_offset_val} < 0;
117118
}
118-
$param{'reset'} = $app->param('reset');
119+
$param{'reset'} = $q->param('reset');
119120
$param{nav_log} = 1;
120121
$param{feed_name} = $app->translate("System Activity Feed");
121122
$param{screen_class} = "list-log";
@@ -128,7 +129,7 @@ sub view {
128129
$param{feed_url} .= $param{filter_args};
129130
}
130131
$app->add_breadcrumb( $app->translate('Activity Log') );
131-
unless ( $app->param('blog_id') ) {
132+
unless ( $q->param('blog_id') ) {
132133
$param{system_overview_nav} = 1;
133134
}
134135
$app->load_tmpl( 'view_log.tmpl', \%param );

lib/MT/CMS/Page.pm

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ sub edit {
99
}
1010
sub list {
1111
my $app = shift;
12-
$app->param( 'type', 'page' );
12+
$app->query->param( 'type', 'page' );
1313
return $app->forward('list_entry', { type => 'page' } );
1414
}
1515

lib/MT/CMS/Plugin.pm

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -24,9 +24,9 @@ sub cfg_plugins {
2424
$param{nav_config} = 1;
2525
$param{nav_settings} = 1;
2626
$param{nav_plugins} = 1;
27-
$param{switched} = 1 if $app->param('switched');
28-
$param{'reset'} = 1 if $app->param('reset');
29-
$param{saved} = 1 if $app->param('saved');
27+
$param{switched} = 1 if $q->param('switched');
28+
$param{'reset'} = 1 if $q->param('reset');
29+
$param{saved} = 1 if $q->param('saved');
3030
$param{mod_perl} = 1 if $ENV{MOD_PERL};
3131
$app->add_breadcrumb( $app->translate("Plugin Settings") );
3232
$param{screen_id} = "list-plugins";
@@ -95,12 +95,12 @@ sub reset_config {
9595

9696
sub plugin_control {
9797
my $app = shift;
98-
98+
my $q = $app->query;
9999
$app->validate_magic or return;
100100
return unless $app->user->can_manage_plugins;
101101

102-
my $plugin_sig = $app->param('plugin_sig') || '';
103-
my $state = $app->param('state') || '';
102+
my $plugin_sig = $q->param('plugin_sig') || '';
103+
my $state = $q->param('state') || '';
104104

105105
my $cfg = $app->config;
106106
if ( $plugin_sig eq '*' ) {

lib/MT/CMS/RptLog.pm

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -7,14 +7,15 @@ use MT::I18N qw( const break_up_text encode_text );
77

88
sub view {
99
my $app = shift;
10+
my $q = $app->query;
1011
my $user = $app->user;
11-
my $blog_id = $app->param('blog_id');
12+
my $blog_id = $q->param('blog_id');
1213
my $perms = $app->permissions;
1314
my $log_class = $app->model('log');
1415
my $blog_class = $app->model('blog');
1516
my $list_pref = $app->list_pref('rptlog');
1617
my $limit = $list_pref->{rows};
17-
my $offset = $app->param('offset') || 0;
18+
my $offset = $q->param('offset') || 0;
1819
my $terms = { $blog_id ? ( blog_id => $blog_id ) : () };
1920
my $cfg = $app->config;
2021
my %param = (%$list_pref);
@@ -65,13 +66,13 @@ sub view {
6566
$param{next_offset} = $param{next_offset_val} < $param{list_total} ? 1 : 0;
6667
$param{next_max} = $param{list_total} - $limit;
6768
$param{next_max} = 0 if ( $param{next_max} || 0 ) < $offset + 1;
68-
$param{'reset'} = $app->param('reset');
69+
$param{'reset'} = $q->param('reset');
6970
$param{nav_log} = 1;
7071
$param{feed_name} = $app->translate("System RPT Feed");
7172
$param{screen_class} = "list-log";
7273
$param{screen_id} = "list-log";
7374
$param{listing_screen} = 1;
74-
$param{system_overview_nav} = 1 unless ( $app->param('blog_id') );
75+
$param{system_overview_nav} = 1 unless ( $q->param('blog_id') );
7576

7677
# dude, if this is not 0 then do pagination stuff
7778
if ( $offset > 0 ) {

lib/MT/CMS/Search.pm

Lines changed: 15 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -160,10 +160,10 @@ sub core_search_apis {
160160
'setup_terms_args' => sub {
161161
my ($terms, $args, $blog_id) = @_;
162162
$terms->{class}
163-
= ( $app->param('filter')
164-
&& $app->param('filter_val')
165-
&& $app->param('filter') eq 'class'
166-
&& $app->param('filter_val') eq 'image' ) ? 'image' : '*';
163+
= ( $q->param('filter')
164+
&& $q->param('filter_val')
165+
&& $q->param('filter') eq 'class'
166+
&& $q->param('filter_val') eq 'image' ) ? 'image' : '*';
167167
$terms->{blog_id} = $blog_id if $blog_id;
168168
}
169169
},
@@ -188,10 +188,10 @@ sub core_search_apis {
188188
'setup_terms_args' => sub {
189189
my ($terms, $args, $blog_id) = @_;
190190
$terms->{class}
191-
= ( $app->param('filter')
192-
&& $app->param('filter_val')
193-
&& $app->param('filter') eq 'class'
194-
&& $app->param('filter_val') eq 'image' ) ? 'image' : '*';
191+
= ( $q->param('filter')
192+
&& $q->param('filter_val')
193+
&& $q->param('filter') eq 'class'
194+
&& $q->param('filter_val') eq 'image' ) ? 'image' : '*';
195195
$terms->{blog_id} = $blog_id if $blog_id;
196196
}
197197
},
@@ -267,17 +267,18 @@ sub core_search_apis {
267267

268268
sub search_replace {
269269
my $app = shift;
270+
my $q = $app->query;
270271
my $param = do_search_replace($app, @_) or return;
271-
my $blog_id = $app->param('blog_id');
272+
my $blog_id = $q->param('blog_id');
272273
$app->add_breadcrumb( $app->translate('Search & Replace') );
273274
$param->{nav_search} = 1;
274275
$param->{screen_class} = "search-replace";
275276
$param->{screen_id} = "search-replace";
276277
$param->{search_tabs} = $app->search_apis($blog_id ? 'blog' : 'system');
277-
$param->{entry_type} = $app->param('entry_type');
278+
$param->{entry_type} = $q->param('entry_type');
278279

279-
if ($app->param('_type') =~ /entry|page|comment|template/) {
280-
if ($app->param('blog_id')) {
280+
if ($q->param('_type') =~ /entry|page|comment|template/) {
281+
if ($q->param('blog_id')) {
281282
my $perms = $app->permissions;
282283
$param->{can_republish} = $perms->can_rebuild || $app->user->is_superuser;
283284
$param->{can_empty_junk} = $perms->can_rebuild || $app->user->is_superuser;
@@ -318,7 +319,7 @@ sub do_search_replace {
318319

319320
# trim 'search' parameter
320321
$search =~ s/(^\s+|\s+$)//g;
321-
$app->param('search', $search);
322+
$app->query->param('search', $search);
322323

323324
if ( !$type || ( 'category' eq $type ) || ( 'folder' eq $type ) ) {
324325
$type = 'entry';
@@ -432,7 +433,7 @@ sub do_search_replace {
432433
my %args;
433434
## we need to search all user/group for 'grant permissions',
434435
## if $blog_id is specified. it affects the setup_terms_args.
435-
if ( $app->param('__mode') eq 'dialog_grant_role' ) {
436+
if ( $app->query->param('__mode') eq 'dialog_grant_role' ) {
436437
if ($blog_id) {
437438
my $perm = $author->permissions($blog_id);
438439
return $app->errtrans('Permission denied.')

0 commit comments

Comments
 (0)