Show
Ignore:
Timestamp:
10/03/08 01:07:01 (14 months ago)
Author:
bchoate
Message:

Merging fireball branch changes to-date to trunk: svn merge -r2974:3081 http://code.sixapart.com/svn/movabletype/branches/fireball .

Files:
1 modified

Legend:

Unmodified
Added
Removed
  • trunk/lib/MT/Permission.pm

    r2099 r3082  
    8585} 
    8686 
     87sub global_perms { 
     88    my $perm = shift; 
     89 
     90    return undef unless $perm->author_id; 
     91    return $perm unless $perm->blog_id; 
     92 
     93    $perm->cache_property( 
     94        'global_perms', 
     95        sub { 
     96            __PACKAGE__->load( { author_id => $perm->author_id, blog_id => 0 }); 
     97        } 
     98    ); 
     99} 
     100 
    87101# Legend: 
    88102# author_id || blog_id || permissions 
     
    289303                        && $author->is_superuser ); 
    290304                    return 1 
    291                       if ( ( $set eq 'blog' ) 
     305                      if ( ( $_[0]->blog_id ) 
    292306                        && $_[0]->has('administer_blog') ); 
    293307                } 
    294308            } 
     309            # return negative if a restriction is present 
    295310            return undef 
    296311              if $_[0]->restrictions && $_[0]->restrictions =~ /'$perm'/i; 
    297             ( defined($cur_perm) && $cur_perm =~ /'$perm'/i ) ? 1 : undef; 
     312            # return positive if permission is set in this permission set 
     313            return 1 if defined($cur_perm) && $cur_perm =~ /'$perm'/i; 
     314            # test for global-level permission 
     315            return 1 
     316              if $_[0]->author_id 
     317              && $_[0]->blog_id 
     318              && $_[0]->global_perms 
     319              && $_[0]->global_perms->has($perm); 
     320            return undef; 
    298321        }; 
    299322    }