Skip to content

Commit

Permalink
[#103 state:committed] Fixed a bug where display preferences for the …
Browse files Browse the repository at this point in the history
…template editing screen of the system overview were not being preserved. The patch applied to Melody was also approved and incorporated into MT and will be in the next release.
  • Loading branch information
jayallen committed Jul 13, 2009
1 parent 7d8309a commit 43ab76b
Showing 1 changed file with 14 additions and 12 deletions.
26 changes: 14 additions & 12 deletions lib/MT/CMS/Template.pm
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ sub edit {
my $type = $q->param('_type');
my $blog = $app->blog;
my $cfg = $app->config;
my $perms = $app->permissions;
my $perms = $app->blog ? $app->permissions : $app->user->permissions;
my $can_preview = 0;

if ($blog) {
Expand Down Expand Up @@ -1298,20 +1298,20 @@ sub add_map {

sub can_view {
my ( $eh, $app, $id ) = @_;
my $perms = $app->permissions;
my $perms = $app->blog ? $app->permissions : $app->user->permissions;
return !$id || ($perms && $perms->can_edit_templates) || (!$app->blog && $app->user->can_edit_templates);
}

sub can_save {
my ( $eh, $app, $id ) = @_;
my $perms = $app->permissions;
my $perms = $app->blog ? $app->permissions : $app->user->permissions;
return ($perms && $perms->can_edit_templates) || (!$perms && $app->user->can_edit_templates);
}

sub can_delete {
my ( $eh, $app, $obj ) = @_;
return 1 if $app->user->is_superuser();
my $perms = $app->permissions;
my $perms = $app->blog ? $app->permissions : $app->user->permissions;
return ($perms && $perms->can_edit_templates) || (!$perms && $app->user->can_edit_templates);
}

Expand All @@ -1327,9 +1327,11 @@ sub pre_save {
}

$obj->text($text);


my $perms = $app->blog ? $app->permissions : $app->user->permissions;

# update text heights if necessary
if ( my $perms = $app->permissions ) {
if ( $perms ) {
my $prefs = $perms->template_prefs || '';
my $text_height = $app->param('text_height');
if ( defined $text_height ) {
Expand Down Expand Up @@ -1616,7 +1618,7 @@ sub dialog_publishing_profile {
$app->assert( $blog ) or return;

# permission check
my $perms = $app->permissions;
my $perms = $app->blog ? $app->permissions : $app->user->permissions;
return $app->errtrans("Permission denied.")
unless $app->user->is_superuser ||
$perms->can_administer_blog ||
Expand All @@ -1636,7 +1638,7 @@ sub dialog_refresh_templates {
$app->validate_magic or return;

# permission check
my $perms = $app->permissions;
my $perms = $app->blog ? $app->permissions : $app->user->permissions;
return $app->errtrans("Permission denied.")
unless $app->user->is_superuser()
|| $app->user->can_edit_templates()
Expand Down Expand Up @@ -1923,7 +1925,7 @@ sub refresh_individual_templates {
require MT::Util;

my $user = $app->user;
my $perms = $app->permissions;
my $perms = $app->blog ? $app->permissions : $app->user->permissions;
return $app->error(
$app->translate(
"Permission denied.")
Expand Down Expand Up @@ -2037,7 +2039,7 @@ sub clone_templates {
my ($app) = @_;

my $user = $app->user;
my $perms = $app->permissions;
my $perms = $app->blog ? $app->permissions : $app->user->permissions;
return $app->error(
$app->translate(
"Permission denied.")
Expand Down Expand Up @@ -2091,7 +2093,7 @@ sub publish_index_templates {
$app->validate_magic or return;

# permission check
my $perms = $app->permissions;
my $perms = $app->blog ? $app->permissions : $app->user->permissions;
return $app->errtrans("Permission denied.")
unless $app->user->is_superuser ||
$perms->can_administer_blog ||
Expand Down Expand Up @@ -2119,7 +2121,7 @@ sub publish_archive_templates {
$app->validate_magic or return;

# permission check
my $perms = $app->permissions;
my $perms = $app->blog ? $app->permissions : $app->user->permissions;
return $app->errtrans("Permission denied.")
unless $app->user->is_superuser
|| $perms->can_administer_blog
Expand Down

0 comments on commit 43ab76b

Please sign in to comment.