Changeset 2751

Show
Ignore:
Timestamp:
07/10/08 22:23:01 (2 months ago)
Author:
bchoate
Message:

Added 'type' attribute to IfRegistrationAllowed tag to test whether a particular type of registration is enabled for the blog. BugId:80625

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • branches/release-41/lib/MT/Template/ContextHandlers.pm

    r2742 r2751  
    42144214permit user registration. 
    42154215 
     4216B<Attributes:> 
     4217 
     4218=over 4 
     4219 
     4220=item * type (optional) 
     4221 
     4222If specified, can be used to test if a particular type of registration 
     4223is enabled. The core types include "OpenID", "Vox", "LiveJournal", "TypeKey" 
     4224and "MovableType". The identifier is case-insensitive. 
     4225 
     4226=back 
     4227 
    42164228=for tags comments 
    42174229 
     
    42194231 
    42204232sub _hdlr_reg_allowed { 
    4221     my ($ctx) = @_; 
     4233    my ($ctx, $args) = @_; 
    42224234    my $blog = $ctx->stash('blog'); 
    42234235    if ($blog->allow_reg_comments && $blog->commenter_authenticators) { 
     4236        if (my $type = $args->{type}) { 
     4237            my %types = map { lc($_) => 1 } 
     4238                split /,/, $blog->commenter_authenticators; 
     4239            return $types{lc $type} ? 1 : 0; 
     4240        } 
    42244241        return 1; 
    42254242    } else { 
  • branches/release-41/php/lib/block.mtifregistrationallowed.php

    r1174 r2751  
    99    if (!isset($content)) { 
    1010        $blog = $ctx->stash('blog'); 
    11         return $ctx->_hdlr_if($args, $content, $ctx, $repeat, $blog['blog_allow_reg_comments'] && $blog['blog_commenter_authenticators']); 
     11        $allowed = $blog['blog_allow_reg_comments'] && $blog['blog_commenter_authenticators']; 
     12        if ($args['type']) 
     13            $allowed = in_array(strtolower($args['type']), 
     14                preg_split('/,/', strtolower($blog['blog_commenter_authenticators']))); 
     15        return $ctx->_hdlr_if($args, $content, $ctx, $repeat, $allowed); 
    1216    } else { 
    1317        return $ctx->_hdlr_if($args, $content, $ctx, $repeat); 
    1418    } 
    1519} 
    16 ?>