]> git.mxchange.org Git - quix0rs-gnu-social.git/blob - plugins/FacebookBridge/actions/facebooklogin.php
Merge branch '1.0.x' of git://gitorious.org/statusnet/mainline
[quix0rs-gnu-social.git] / plugins / FacebookBridge / actions / facebooklogin.php
1 <?php
2 /**
3  * StatusNet - the distributed open-source microblogging tool
4  * Copyright (C) 2010, StatusNet, Inc.
5  *
6  * An action for logging in with Facebook
7  *
8  * PHP version 5
9  *
10  * This program is free software: you can redistribute it and/or modify
11  * it under the terms of the GNU Affero General Public License as published by
12  * the Free Software Foundation, either version 3 of the License, or
13  * (at your option) any later version.
14  *
15  * This program is distributed in the hope that it will be useful,
16  * but WITHOUT ANY WARRANTY; without even the implied warranty of
17  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
18  * GNU Affero General Public License for more details.
19  *
20  * You should have received a copy of the GNU Affero General Public License
21  * along with this program.  If not, see <http://www.gnu.org/licenses/>.
22  *
23  * @category  Plugin
24  * @package   StatusNet
25  * @author    Zach Copley <zach@status.net>
26  * @copyright 2010 StatusNet, Inc.
27  * @license   http://www.fsf.org/licensing/licenses/agpl-3.0.html AGPL 3.0
28  * @link      http://status.net/
29  */
30
31 if (!defined('STATUSNET')) {
32     exit(1);
33 }
34
35 class FacebookloginAction extends Action
36 {
37
38     function handle($args)
39     {
40         parent::handle($args);
41
42         if (common_is_real_login()) {
43             $this->clientError(_m('Already logged in.'));
44         } else {
45             $this->showPage();
46         }
47     }
48
49     function getInstructions()
50     {
51         // TRANS: Instructions.
52         return _m('Login with your Facebook Account');
53     }
54
55     function showPageNotice()
56     {
57         $instr = $this->getInstructions();
58         $output = common_markup_to_html($instr);
59         $this->elementStart('div', 'instructions');
60         $this->raw($output);
61         $this->elementEnd('div');
62     }
63
64     function title()
65     {
66         // TRANS: Page title.
67         return _m('Login with Facebook');
68     }
69
70     function showContent() {
71
72         $this->elementStart('fieldset');
73
74         $facebook = Facebookclient::getFacebook();
75
76         // Degrade to plain link if JavaScript is not available
77         $this->elementStart(
78             'a',
79             array(
80                 'href' => $facebook->getLoginUrl(
81                     array(
82                         'next'       => common_local_url('facebookfinishlogin'),
83                         'cancel'     => common_local_url('facebooklogin'),
84                         'req_perms'  => 'read_stream,publish_stream,offline_access,user_status,user_location,user_website,email'
85                     )
86                  ),
87                 'id'    => 'facebook_button'
88             )
89         );
90
91         $attrs = array(
92             'src' => Plugin::staticPath('FacebookBridge', 'images/login-button.png'),
93             'alt'   => 'Login with Facebook',
94             'title' => 'Login with Facebook'
95         );
96
97         $this->element('img', $attrs);
98
99         $this->elementEnd('a');
100
101         /*
102         $this->element('div', array('id' => 'fb-root'));
103         $this->script(
104             sprintf(
105                 'http://connect.facebook.net/en_US/all.js#appId=%s&xfbml=1',
106                 common_config('facebook', 'appid')
107             )
108         );
109         $this->element('fb:facepile', array('max-rows' => '2', 'width' =>'300'));
110         */
111         $this->elementEnd('fieldset');
112     }
113
114     function showLocalNav()
115     {
116         $nav = new LoginGroupNav($this);
117         $nav->show();
118     }
119 }
120