Changeset 1480 for trunk/mixiComment

Show
Ignore:
Timestamp:
03/02/09 08:35:18 (9 months ago)
Author:
auno
Message:

Merged changes from internal. #99460

Location:
trunk/mixiComment/plugins/mixiComment
Files:
6 added
4 modified

Legend:

Unmodified
Added
Removed
  • trunk/mixiComment/plugins/mixiComment/lib/mixiComment/App.pm

    r971 r1480  
    5252} 
    5353 
     54sub openid_commenter_condition { 
     55    eval "require Digest::SHA1;"; 
     56    return 0 if $@; 
     57    eval "require Crypt::SSLeay;"; 
     58    return 0 if $@; 
     59    return 1; 
     60} 
     61 
     62sub commenter_auth_params { 
     63    my ($key, $blog_id, $entry_id, $static) = @_; 
     64 
     65    my %param; 
     66    my $plugin = MT->component('mixicomment'); 
     67    $plugin->load_config(\%param, "blog:$blog_id"); 
     68    my $url; 
     69    if ( my $mixi_id = $param{mixi_id} ) { 
     70        $url = "https://id.mixi.jp/$mixi_id/friends"; 
     71    } 
     72    else { 
     73        $url = "http://mixi.jp/"; 
     74    } 
     75    my $params = { 
     76        blog_id => $blog_id, 
     77        static  => $static, 
     78        url     => $url, 
     79    }; 
     80    $params->{entry_id} = $entry_id if defined $entry_id; 
     81    return $params; 
     82} 
     83 
    54841; 
    5585__END__ 
  • trunk/mixiComment/plugins/mixiComment/lib/mixiComment/Auth/mixi.pm

    r1066 r1480  
    1515        my $return_to = $path . '?__mode=mixicomment_verify_blog_owner' 
    1616            . '&blog_id='  . $blog->id; 
    17         return ( trust_root => $path, return_to => $return_to ); 
     17        return ( trust_root => $path, return_to => $return_to, delayed_return => 1 ); 
    1818    } 
    1919    else { 
    20         return $class->SUPER::check_url_params(@_); 
     20        my %params = $class->SUPER::check_url_params(@_); 
     21        $params{delayed_return} = 1; 
     22        return %params; 
    2123    } 
    2224} 
     
    3335} 
    3436 
    35 # TODO: remove these once core code supports SREG - BugID:71011 
    36 sub NS_OPENID_SREG { "http://openid.net/extensions/sreg/1.1" } 
     37sub set_extension_args { 
     38    my $class = shift; 
     39    my ( $claimed_identity ) = @_; 
    3740 
    38 sub login { 
    39     my $class = shift; 
    40     my ($app) = @_; 
    41     my $q = $app->{query}; 
    42     return $app->errtrans("Invalid request.") 
    43         unless $q->param('blog_id'); 
    44     my $blog = MT::Blog->load(scalar $q->param('blog_id')); 
    45     my %param = $app->param_hash; 
    46     my $csr = MT::Auth::OpenID::_get_csr(\%param, $blog) or return; 
    47     my $identity = $q->param('openid_url'); 
    48     if (!$identity && 
    49         (my $u = $q->param('openid_userid')) && $class->can('url_for_userid')) { 
    50         $identity = $class->url_for_userid($u); 
    51     } 
    52     my $claimed_identity = $csr->claimed_identity($identity); 
    53     if (!$claimed_identity) { 
    54         my ($err_code, $err_msg) = ($csr->errcode, $csr->errtext); 
    55         if ($err_code eq 'no_head_tag' || $err_code eq 'no_identity_server' || $err_code eq 'url_gone') { 
    56             $err_msg = $app->translate('The address entered does not appear to be an OpenID'); 
    57         } 
    58         elsif ($err_code eq 'empty_url' || $err_code eq 'bogus_url') { 
    59             $err_msg = $app->translate('The text entered does not appear to be a web address'); 
    60         } 
    61         elsif ($err_code eq 'url_fetch_error') { 
    62             $err_msg =~ s{ \A Error \s fetching \s URL: \s }{}xms; 
    63             $err_msg = $app->translate('Unable to connect to [_1]: [_2]', $identity, $err_msg); 
    64         } 
    65         return $app->error($app->translate("Could not verify the OpenID provided: [_1]", $err_msg)); 
    66     } 
    67  
    68     my %params = $class->check_url_params( $app, $blog ); 
    69  
    70     $claimed_identity->set_extension_args(NS_OPENID_SREG(), { 
     41    $claimed_identity->set_extension_args(MT::Auth::OpenID::NS_OPENID_SREG(), { 
    7142        optional => join(",", qw/email nickname fullname/) 
    7243    }); 
    73  
    74     my $check_url = $claimed_identity->check_url( 
    75         ( %params, delayed_return => 1 ) 
    76     ); 
    77  
    78     return $app->redirect($check_url); 
    7944} 
    8045 
     
    8449 
    8550    # Try SREG extension first 
    86     my $fields = $vident->extension_fields(NS_OPENID_SREG); 
     51    my $fields = $vident->extension_fields(MT::Auth::OpenID::NS_OPENID_SREG()); 
    8752    my $nick = $fields->{nickname} if exists $fields->{nickname}; 
    8853    $nick ||= $fields->{fullname} if exists $fields->{fullname}; 
  • trunk/mixiComment/plugins/mixiComment/lib/mixiComment/L10N/ja.pm

    r971 r1480  
    66 
    77%Lexicon = ( 
    8     'Allows commenters to sign in to Movable Type 4 using their own mixi username and password via OpenID.' => 'mixiのアカりントを䜿っおMovable Type 4にコメントするこずができるようにしたす。', 
    9     'mixi reported that you failed to login.  Try again.' => 'ログむンに倱敗したした。', 
    10     'A mixi ID has already been registered in this blog.  If you want to change the mixi ID for the blog, <a href="[_1]">click here</a> to sign in using your mixi account.  If you want all of the mixi users to comment to your blog (not only your my mixi users), click the reset button to remove the setting.' => 'すでにmixiのIDを登録しおありたす。ブログに関連付けるmixiのIDを倉えたい堎合は、<a href="[_1]">ここをクリックしおmixiにログむン</a>しおください。マむミクだけでなくすべおのmixiナヌザヌからのコメントを受け付けたいずきは、初期化ボタンをクリックしお蚭定を消去しおください。', 
    11     'If you want to restrict comments only from your my mixi users, <a href="[_1]">click here</a> to sign in using your mixi account.' => 'マむミクからのみコメントを受け付ける蚭定にするには、<a href="[_1]">ここをクリックしおたずmixiにログむン</a>しおください。', 
    12     'Click the button to sign in using your mixi ID' => 'ボタンをクリックしおmixiにログむンしおください。', 
    13     'Sign in using your mixi ID' => 'mixiのIDでログむンする', 
     8 
     9## plugins/mixiComment/mixiComment.pl 
     10        'Allows commenters to sign in to Movable Type 4 using their own mixi username and password via OpenID.' => 'mixiのアカりントを䜿っおMovable Type 4にコメントするこずができるようにしたす。', 
     11        'Sign in using your mixi ID' => 'mixiのIDでログむンする', 
     12        'Click the button to sign in using your mixi ID' => 'ボタンをクリックしおmixiにログむンしおください。', 
     13        'mixi' => 'ミクシィ', 
     14 
     15## plugins/mixiComment/lib/mixiComment/App.pm 
     16        'mixi reported that you failed to login.  Try again.' => 'ログむンに倱敗したした。', 
     17 
     18## plugins/mixiComment/tmpl/config.tmpl 
     19        'A mixi ID has already been registered in this blog.  If you want to change the mixi ID for the blog, <a href="[_1]">click here</a> to sign in using your mixi account.  If you want all of the mixi users to comment to your blog (not only your my mixi users), click the reset button to remove the setting.' => 'すでにmixiのIDを登録しおありたす。ブログに関連付けるmixiのIDを倉えたい堎合は、<a href="[_1]">ここをクリックしおmixiにログむン</a>しおください。マむミクだけでなくすべおのmixiナヌザヌからのコメントを受け付けたいずきは、初期化ボタンをクリックしお蚭定を消去しおください。', 
     20        'If you want to restrict comments only from your my mixi users, <a href="[_1]">click here</a> to sign in using your mixi account.' => 'マむミクからのみコメントを受け付ける蚭定にするには、<a href="[_1]">ここをクリックしおたずmixiにログむン</a>しおください。', 
     21 
    1422); 
    1523 
  • trunk/mixiComment/plugins/mixiComment/mixiComment.pl

    r971 r1480  
    1313    author_url => 'http://www.movabletype.jp/', 
    1414    description => '<MT_TRANS phrase="Allows commenters to sign in to Movable Type 4 using their own mixi username and password via OpenID.">', 
    15     version => '1.0', 
     15    version => '1.1', 
    1616    settings => new MT::PluginSettings([ 
    1717        ['mixi_id', { Scope => 'blog' }], 
     
    6969</__trans_section> 
    7070EOT 
    71                 login_form_params => sub { 
    72                     my ($key, $blog_id, $entry_id, $static) = @_; 
    73  
    74                     my %param; 
    75                     $plugin->load_config(\%param, "blog:$blog_id"); 
    76                     my $url; 
    77                     if ( my $mixi_id = $param{mixi_id} ) { 
    78                         $url = "https://id.mixi.jp/$mixi_id/friends"; 
    79                     } 
    80                     else { 
    81                         $url = "http://mixi.jp/"; 
    82                     } 
    83                     my $params = { 
    84                         blog_id => $blog_id, 
    85                         static  => $static, 
    86                         url     => $url, 
    87                     }; 
    88                     $params->{entry_id} = $entry_id if defined $entry_id; 
    89                     return $params; 
    90                 }, 
     71                condition => '$mixicomment::mixiComment::App::openid_commenter_condition', 
     72                login_form_params => '$mixicomment::mixiComment::App::commenter_auth_params', 
    9173                logo => 'plugins/mixiComment/images/signin_mixi.png', 
    9274                logo_small => 'plugins/mixiComment/images/signin_mixi_small.gif'