root/trunk/CommentByGoogleAccount/CommentByGoogleAccount.pl

Revision 697, 2.4 kB (checked in by mpaschal, 18 months ago)

Move CommentByGoogleAccount? plugin from mt extras to mtplugins repo

Line 
1# Movable Type (r) Open Source (C) 2005-2008 Six Apart, Ltd.
2# This program is distributed under the terms of the
3# GNU General Public License, version 2.
4#
5# $Id: CommentByGoogleAccount.pl 1174 2008-01-08 21:02:50Z bchoate $
6
7# CommentByGoogleAccount plugin for Movable Type
8# Author: Six Apart (http://www.sixapart.com)
9# Released under the Artistic and GPLv2 License
10
11package MT::Plugin::CommentByGoogleAccount;
12
13use strict;
14use base qw( MT::Plugin );
15use MT::Util qw( encode_url );
16
17my $plugin = new MT::Plugin::CommentByGoogleAccount({
18    name => "Comment by Google Account",
19    version => '0.1',
20    description => "<MT_TRANS phrase=\"You can allow readers to authenticate themselves via Google Account to comment on posts.\">",
21    author_name => "Six Apart, Ltd.",
22    author_link => "http://www.sixapart.com/",
23    settings => new MT::PluginSettings([
24        ['google_commenter_nickname'],
25    ]),
26    config_template => 'config.tmpl',
27    #l10n_class => 'CommentByGoogleAccount::L10N',
28});
29MT->add_plugin($plugin);
30
31sub init_registry {
32    my $plugin = shift;
33    $plugin->registry({
34        'commenter_authenticators' => {
35            'google' => {
36                label => 'Google',
37                class => 'CommentByGoogleAccount',
38                login_form => <<Google,
39<p><a href="<TMPL_VAR NAME=URL>">Click here</a> to sign in via your Google account.</p>
40Google
41                login_form_params => sub {
42        my ($key, $blog_id, $entry_id, $static) = @_;
43
44        require MT::Template::Context;
45        my $ctx = MT::Template::Context->new;
46        require MT::Blog;
47        $ctx->stash('blog', MT::Blog->load($blog_id));
48        my $path = MT::Template::Context::_hdlr_cgi_path($ctx);
49        $path .= MT::ConfigMgr->instance->CommentScript;
50        my $next = "$path?__mode=handle_sign_in&key=google&blog_id=$blog_id&entry_id=$entry_id&static=$static";
51        $next = encode_url($next);
52
53        ## temporarily use Google Base as our scope.  TODO: determine how to correctly do this
54        my $url = "http://www.google.com/accounts/AuthSubRequest?scope=http%3A%2F%2Fwww.google.com%2Fbase&next=$next&session=0";
55        return {
56            url => $url,
57        };
58                },
59            },
60        },
61    });
62}
63
64sub instance { $plugin }
65
66sub load_config {
67    my $plugin = shift;
68    my ($param, $scope) = @_;
69
70    $plugin->SUPER::load_config(@_);
71    $param->{Caption} = $plugin->translate("Commenter's nickname to be used:");
72}
73
741;
Note: See TracBrowser for help on using the browser.