Report abuse

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
Index: /branches/slapshot/lib/MT/CMS/Template.pm
===================================================================
--- /branches/slapshot/lib/MT/CMS/Template.pm (revision 3798)
+++ /branches/slapshot/lib/MT/CMS/Template.pm (revision 4008)
@@ -33,5 +33,5 @@
     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;
 
@@ -1299,5 +1299,5 @@
 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);
 }
@@ -1305,5 +1305,5 @@
 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);
 }
@@ -1312,5 +1312,5 @@
     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);
 }
@@ -1328,7 +1328,9 @@
 
     $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');
@@ -1617,5 +1619,5 @@
 
     # 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 ||
@@ -1637,5 +1639,5 @@
 
     # 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()
@@ -1924,5 +1926,5 @@
 
     my $user = $app->user;
-    my $perms = $app->permissions;
+    my $perms = $app->blog ? $app->permissions : $app->user->permissions;
     return $app->error(
         $app->translate(
@@ -2038,5 +2040,5 @@
 
     my $user = $app->user;
-    my $perms = $app->permissions;
+    my $perms = $app->blog ? $app->permissions : $app->user->permissions;
     return $app->error(
         $app->translate(
@@ -2083,5 +2085,5 @@
 
     # 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 ||
@@ -2117,5 +2119,5 @@
 
     # 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