Skip to content

Commit

Permalink
Swept the use of $app->param from numerous modules that only used tha…
Browse files Browse the repository at this point in the history
…t method occasionally.
  • Loading branch information
tima committed Aug 31, 2009
1 parent 0441304 commit 51c15ef
Show file tree
Hide file tree
Showing 14 changed files with 67 additions and 57 deletions.
2 changes: 1 addition & 1 deletion lib/MT/Asset/Image.pm
Original file line number Diff line number Diff line change
Expand Up @@ -262,7 +262,7 @@ sub as_html {
my $text = '';

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

if ( $param->{include} ) {
Expand Down
9 changes: 5 additions & 4 deletions lib/MT/Auth/MT.pm
Original file line number Diff line number Diff line change
Expand Up @@ -54,11 +54,12 @@ sub login_credentials {
my ($ctx) = @_;

my $app = $ctx->{app} or return;
if ($app->param('username') && $app->param('password')) {
my $q = $app->query;
if ($q->param('username') && $q->param('password')) {
my ($user, $pass, $remember);
$user = $app->param('username');
$pass = $app->param('password');
$remember = $app->param('remember') ? 1 : 0;
$user = $q->param('username');
$pass = $q->param('password');
$remember = $q->param('remember') ? 1 : 0;
return { %$ctx, username => $user, password => $pass, permanent => $remember, auth_type => 'MT' };
}
return undef;
Expand Down
4 changes: 2 additions & 2 deletions lib/MT/Auth/OpenID.pm
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ sub handle_sign_in {
my $cmntr;
my $session;

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

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

my %param = $app->param_hash;
my %param = $app->query->Vars;
my $csr = $class->get_csr(\%param, $blog);
unless ( $csr ) {
$app->errtrans('Could not load Net::OpenID::Consumer.');
Expand Down
9 changes: 5 additions & 4 deletions lib/MT/CMS/AddressBook.pm
Original file line number Diff line number Diff line change
Expand Up @@ -227,16 +227,17 @@ sub can_save {
sub save_filter {
my $eh = shift;
my ($app) = @_;
my $email = lc $app->param('email');
my $q = $app->query;
my $email = lc $q->param('email');
$email =~ s/(^\s+|\s+$)//gs;
my $blog_id = $app->param('blog_id');
my $blog_id = $q->param('blog_id');
if ( !is_valid_email($email) ) {
return $eh->error(
$app->translate(
"The value you entered was not a valid email address")
);
}
my $url = $app->param('url');
my $url = $q->param('url');
if ( $url && ( !is_url($url) ) ) {
return $eh->error(
$app->translate(
Expand All @@ -250,7 +251,7 @@ sub save_filter {
MT::Notification->load_iter( { blog_id => $blog_id } );
while ( my $obj = $notification_iter->() ) {
if ( ( lc( $obj->email ) eq $email )
&& ( $obj->id ne $app->param('id') ) )
&& ( $obj->id ne $q->param('id') ) )
{
return $eh->error(
$app->translate(
Expand Down
7 changes: 4 additions & 3 deletions lib/MT/CMS/BanList.pm
Original file line number Diff line number Diff line change
Expand Up @@ -12,16 +12,17 @@ sub can_save {
sub save_filter {
my $eh = shift;
my ($app) = @_;
my $ip = $app->param('ip');
my $q = $app->query;
my $ip = $q->param('ip');
$ip =~ s/(^\s+|\s+$)//g;
return $eh->error(
MT->translate("You did not enter an IP address to ban.") )
if ( '' eq $ip );
my $blog_id = $app->param('blog_id');
my $blog_id = $q->param('blog_id');
require MT::IPBanList;
my $existing =
MT::IPBanList->load( { 'ip' => $ip, 'blog_id' => $blog_id } );
my $id = $app->param('id');
my $id = $q->param('id');

if ( $existing && ( !$id || $existing->id != $id ) ) {
return $eh->error(
Expand Down
13 changes: 7 additions & 6 deletions lib/MT/CMS/Dashboard.pm
Original file line number Diff line number Diff line change
Expand Up @@ -5,26 +5,27 @@ use MT::Util qw( epoch2ts encode_html );

sub dashboard {
my $app = shift;
my $q = $app->query;
my (%param) = @_;

if ( $app->request('fresh_login') ) {
if ( !$app->param('blog_id') ) {
if ( !$q->param('blog_id') ) {

# return to the last blog they visted, if any
my $fav_blogs = $app->user->favorite_blogs || [];
my $blog_id = $fav_blogs->[0] if @$fav_blogs;
$app->param( 'blog_id', $blog_id ) if $blog_id;
$q->param( 'blog_id', $blog_id ) if $blog_id;
$app->delete_param('blog_id') unless $app->is_authorized;
}
}

my $param = \%param;

$param->{redirect} ||= $app->param('redirect');
$param->{permission} ||= $app->param('permission');
$param->{saved} ||= $app->param('saved');
$param->{redirect} ||= $q->param('redirect');
$param->{permission} ||= $q->param('permission');
$param->{saved} ||= $q->param('saved');

$param->{system_overview_nav} = $app->param('blog_id') ? 0 : defined($app->param('blog_id')) ? 1 : 0;
$param->{system_overview_nav} = $q->param('blog_id') ? 0 : defined($q->param('blog_id')) ? 1 : 0;
$param->{quick_search} = 0;
$param->{no_breadcrumbs} = 1;
$param->{screen_class} = "dashboard";
Expand Down
8 changes: 5 additions & 3 deletions lib/MT/CMS/Export.pm
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,9 @@ use MT::Util qw( dirify );

sub start_export {
my $app = shift;
my $q = $app->query;
my %param;
my $blog_id = $app->param('blog_id');
my $blog_id = $q->param('blog_id');

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

sub export {
my $app = shift;
my $q = $app->query;
my $charset = $app->charset;
require MT::Blog;
my $blog_id = $app->param('blog_id')
my $blog_id = $q->param('blog_id')
or return $app->error( $app->translate("Please select a blog.") );
my $blog = MT::Blog->load($blog_id)
or return $app->error(
Expand All @@ -38,7 +40,7 @@ sub export {
if ( $file eq ".txt" ) {
my @ts = localtime(time);
$file = sprintf "export-%06d-%04d%02d%02d%02d%02d%02d.txt",
$app->param('blog_id'), $ts[5] + 1900, $ts[4] + 1, @ts[ 3, 2, 1, 0 ];
$q->param('blog_id'), $ts[5] + 1900, $ts[4] + 1, @ts[ 3, 2, 1, 0 ];
}

$app->{no_print_body} = 1;
Expand Down
5 changes: 3 additions & 2 deletions lib/MT/CMS/Folder.pm
Original file line number Diff line number Diff line change
Expand Up @@ -71,9 +71,10 @@ sub post_save {
sub save_filter {
my $eh = shift;
my ($app) = @_;
my $q = $app->query;
return $app->errtrans( "The name '[_1]' is too long!",
$app->param('label') )
if ( length( $app->param('label') ) > 100 );
$q->param('label') )
if ( length( $q->param('label') ) > 100 );
return 1;
}

Expand Down
2 changes: 1 addition & 1 deletion lib/MT/CMS/Import.pm
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ use MT::I18N qw( const );

sub start_import {
my $app = shift;
my $blog_id = $app->param('blog_id');
my $blog_id = $app->query->param('blog_id');

my $perms = $app->permissions;
return $app->return_to_dashboard( permission => 1 )
Expand Down
13 changes: 7 additions & 6 deletions lib/MT/CMS/Log.pm
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,9 @@ use MT::I18N qw( const break_up_text encode_text );

sub view {
my $app = shift;
my $q = $app->query;
my $user = $app->user;
my $blog_id = $app->param('blog_id');
my $blog_id = $q->param('blog_id');
my $perms = $app->permissions;
if ($blog_id) {
return $app->error( $app->translate("Permission denied.") )
Expand All @@ -22,15 +23,15 @@ sub view {
my $blog_class = $app->model('blog');
my $list_pref = $app->list_pref('log');
my $limit = $list_pref->{rows};
my $offset = $app->param('offset') || 0;
my $offset = $q->param('offset') || 0;
my $terms = { $blog_id ? ( blog_id => $blog_id ) : () };
my $cfg = $app->config;
my %param = (%$list_pref);
my ( $filter_col, $val );
$param{filter_args} = "";

if ( ( $filter_col = $app->param('filter') )
&& ( $val = $app->param('filter_val') ) )
if ( ( $filter_col = $q->param('filter') )
&& ( $val = $q->param('filter_val') ) )
{
$param{filter} = $filter_col;
$param{filter_val} = $val;
Expand Down Expand Up @@ -115,7 +116,7 @@ sub view {
$param{prev_offset_val} = $offset - $limit;
$param{prev_offset_val} = 0 if $param{prev_offset_val} < 0;
}
$param{'reset'} = $app->param('reset');
$param{'reset'} = $q->param('reset');
$param{nav_log} = 1;
$param{feed_name} = $app->translate("System Activity Feed");
$param{screen_class} = "list-log";
Expand All @@ -128,7 +129,7 @@ sub view {
$param{feed_url} .= $param{filter_args};
}
$app->add_breadcrumb( $app->translate('Activity Log') );
unless ( $app->param('blog_id') ) {
unless ( $q->param('blog_id') ) {
$param{system_overview_nav} = 1;
}
$app->load_tmpl( 'view_log.tmpl', \%param );
Expand Down
2 changes: 1 addition & 1 deletion lib/MT/CMS/Page.pm
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ sub edit {
}
sub list {
my $app = shift;
$app->param( 'type', 'page' );
$app->query->param( 'type', 'page' );
return $app->forward('list_entry', { type => 'page' } );
}

Expand Down
12 changes: 6 additions & 6 deletions lib/MT/CMS/Plugin.pm
Original file line number Diff line number Diff line change
Expand Up @@ -24,9 +24,9 @@ sub cfg_plugins {
$param{nav_config} = 1;
$param{nav_settings} = 1;
$param{nav_plugins} = 1;
$param{switched} = 1 if $app->param('switched');
$param{'reset'} = 1 if $app->param('reset');
$param{saved} = 1 if $app->param('saved');
$param{switched} = 1 if $q->param('switched');
$param{'reset'} = 1 if $q->param('reset');
$param{saved} = 1 if $q->param('saved');
$param{mod_perl} = 1 if $ENV{MOD_PERL};
$app->add_breadcrumb( $app->translate("Plugin Settings") );
$param{screen_id} = "list-plugins";
Expand Down Expand Up @@ -95,12 +95,12 @@ sub reset_config {

sub plugin_control {
my $app = shift;

my $q = $app->query;
$app->validate_magic or return;
return unless $app->user->can_manage_plugins;

my $plugin_sig = $app->param('plugin_sig') || '';
my $state = $app->param('state') || '';
my $plugin_sig = $q->param('plugin_sig') || '';
my $state = $q->param('state') || '';

my $cfg = $app->config;
if ( $plugin_sig eq '*' ) {
Expand Down
9 changes: 5 additions & 4 deletions lib/MT/CMS/RptLog.pm
Original file line number Diff line number Diff line change
Expand Up @@ -7,14 +7,15 @@ use MT::I18N qw( const break_up_text encode_text );

sub view {
my $app = shift;
my $q = $app->query;
my $user = $app->user;
my $blog_id = $app->param('blog_id');
my $blog_id = $q->param('blog_id');
my $perms = $app->permissions;
my $log_class = $app->model('log');
my $blog_class = $app->model('blog');
my $list_pref = $app->list_pref('rptlog');
my $limit = $list_pref->{rows};
my $offset = $app->param('offset') || 0;
my $offset = $q->param('offset') || 0;
my $terms = { $blog_id ? ( blog_id => $blog_id ) : () };
my $cfg = $app->config;
my %param = (%$list_pref);
Expand Down Expand Up @@ -65,13 +66,13 @@ sub view {
$param{next_offset} = $param{next_offset_val} < $param{list_total} ? 1 : 0;
$param{next_max} = $param{list_total} - $limit;
$param{next_max} = 0 if ( $param{next_max} || 0 ) < $offset + 1;
$param{'reset'} = $app->param('reset');
$param{'reset'} = $q->param('reset');
$param{nav_log} = 1;
$param{feed_name} = $app->translate("System RPT Feed");
$param{screen_class} = "list-log";
$param{screen_id} = "list-log";
$param{listing_screen} = 1;
$param{system_overview_nav} = 1 unless ( $app->param('blog_id') );
$param{system_overview_nav} = 1 unless ( $q->param('blog_id') );

# dude, if this is not 0 then do pagination stuff
if ( $offset > 0 ) {
Expand Down
29 changes: 15 additions & 14 deletions lib/MT/CMS/Search.pm
Original file line number Diff line number Diff line change
Expand Up @@ -160,10 +160,10 @@ sub core_search_apis {
'setup_terms_args' => sub {
my ($terms, $args, $blog_id) = @_;
$terms->{class}
= ( $app->param('filter')
&& $app->param('filter_val')
&& $app->param('filter') eq 'class'
&& $app->param('filter_val') eq 'image' ) ? 'image' : '*';
= ( $q->param('filter')
&& $q->param('filter_val')
&& $q->param('filter') eq 'class'
&& $q->param('filter_val') eq 'image' ) ? 'image' : '*';
$terms->{blog_id} = $blog_id if $blog_id;
}
},
Expand All @@ -188,10 +188,10 @@ sub core_search_apis {
'setup_terms_args' => sub {
my ($terms, $args, $blog_id) = @_;
$terms->{class}
= ( $app->param('filter')
&& $app->param('filter_val')
&& $app->param('filter') eq 'class'
&& $app->param('filter_val') eq 'image' ) ? 'image' : '*';
= ( $q->param('filter')
&& $q->param('filter_val')
&& $q->param('filter') eq 'class'
&& $q->param('filter_val') eq 'image' ) ? 'image' : '*';
$terms->{blog_id} = $blog_id if $blog_id;
}
},
Expand Down Expand Up @@ -267,17 +267,18 @@ sub core_search_apis {

sub search_replace {
my $app = shift;
my $q = $app->query;
my $param = do_search_replace($app, @_) or return;
my $blog_id = $app->param('blog_id');
my $blog_id = $q->param('blog_id');
$app->add_breadcrumb( $app->translate('Search & Replace') );
$param->{nav_search} = 1;
$param->{screen_class} = "search-replace";
$param->{screen_id} = "search-replace";
$param->{search_tabs} = $app->search_apis($blog_id ? 'blog' : 'system');
$param->{entry_type} = $app->param('entry_type');
$param->{entry_type} = $q->param('entry_type');

if ($app->param('_type') =~ /entry|page|comment|template/) {
if ($app->param('blog_id')) {
if ($q->param('_type') =~ /entry|page|comment|template/) {
if ($q->param('blog_id')) {
my $perms = $app->permissions;
$param->{can_republish} = $perms->can_rebuild || $app->user->is_superuser;
$param->{can_empty_junk} = $perms->can_rebuild || $app->user->is_superuser;
Expand Down Expand Up @@ -318,7 +319,7 @@ sub do_search_replace {

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

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

0 comments on commit 51c15ef

Please sign in to comment.