root/trunk/mixiComment/plugins/mixiComment/mixiComment.pl @ 971

Revision 971, 3.3 kB (checked in by fumiakiy, 15 months ago)

Importing mixiComment plugin. This plugin enables Movable Type to levarage mixi OpenID Provider as another commenter authenticator.

Line 
1package MT::Plugin::mixiComment;
2
3use strict;
4use warnings;
5
6use MT;
7use base qw(MT::Plugin);
8
9my $plugin = MT::Plugin::mixiComment->new({
10    id => 'mixicomment',
11    name => 'mixiComment',
12    author_name => 'Six Apart K.K.',
13    author_url => 'http://www.movabletype.jp/',
14    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',
16    settings => new MT::PluginSettings([
17        ['mixi_id', { Scope => 'blog' }],
18    ]),
19    l10n_class => 'mixiComment::L10N',
20        blog_config_template => 'config.tmpl',
21});
22MT->add_plugin($plugin);
23
24sub load_config {
25    my $plugin = shift;
26    my ($args, $scope) = @_;
27
28    $plugin->SUPER::load_config(@_);
29
30    if ( $scope =~ /blog:(\d+)/ ) {
31        my $blog_id = $1;
32        $args->{blog_id} = $blog_id;
33    }
34}
35
36sub init_registry {
37    my $plugin = shift;
38    $plugin->registry({
39        applications => {
40            cms => {
41                methods => {
42                    mixicomment_login_blog_owner => '$mixicomment::mixiComment::App::login_blog_owner',
43                    mixicomment_verify_blog_owner => '$mixicomment::mixiComment::App::verify_blog_owner',
44                }
45            }
46        },
47        commenter_authenticators => {
48            'mixicomment' => {
49                label => 'mixi',
50                class => 'mixiComment::Auth::mixi',
51                login_form => <<EOT,
52<__trans_section component="mixicomment">
53<form method="post" action="<mt:var name="script_url">">
54<input type="hidden" name="__mode" value="login_external" />
55<input type="hidden" name="openid_url" value="<mt:var name="url">" />
56<input type="hidden" name="blog_id" value="<mt:var name="blog_id">" />
57<input type="hidden" name="entry_id" value="<mt:var name="entry_id">" />
58<input type="hidden" name="static" value="<mt:var name="static" escape="html">" />
59<input type="hidden" name="key" value="mixicomment" />
60<fieldset>
61<mtapp:setting
62    id="mixiComment_display"
63    hint="<__trans phrase="Sign in using your mixi ID">">
64    <input type="image" src="<mt:var name="static_uri">plugins/mixiComment/images/mixi_button.gif" width="150" height="30" />
65    <p><__trans phrase="Click the button to sign in using your mixi ID"></p>
66</mtapp:setting>
67</fieldset>
68</form>
69</__trans_section>
70EOT
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                },
91                logo => 'plugins/mixiComment/images/signin_mixi.png',
92                logo_small => 'plugins/mixiComment/images/signin_mixi_small.gif'
93            },
94        },
95    });
96}
97
98sub instance { $plugin }
99
1001;
101__END__
Note: See TracBrowser for help on using the browser.