]> git.mxchange.org Git - quix0rs-gnu-social.git/blob - plugins/Facebook/facebooklogin.php
Merge branch '1.0.x' into schema-x
[quix0rs-gnu-social.git] / plugins / Facebook / facebooklogin.php
1 <?php
2 /*
3  * StatusNet - the distributed open-source microblogging tool
4  * Copyright (C) 2008, 2009, StatusNet, Inc.
5  *
6  * This program is free software: you can redistribute it and/or modify
7  * it under the terms of the GNU Affero General Public License as published by
8  * the Free Software Foundation, either version 3 of the License, or
9  * (at your option) any later version.
10  *
11  * This program is distributed in the hope that it will be useful,
12  * but WITHOUT ANY WARRANTY; without even the implied warranty of
13  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.     See the
14  * GNU Affero General Public License for more details.
15  *
16  * You should have received a copy of the GNU Affero General Public License
17  * along with this program.     If not, see <http://www.gnu.org/licenses/>.
18  */
19
20 if (!defined('STATUSNET') && !defined('LACONICA')) {
21     exit(1);
22 }
23
24 require_once INSTALLDIR . '/plugins/Facebook/facebookaction.php';
25
26 class FacebookinviteAction extends FacebookAction
27 {
28     function handle($args)
29     {
30         parent::handle($args);
31
32         $this->error = $error;
33
34         if ($this->flink) {
35             if (!$this->facebook->api_client->users_hasAppPermission('publish_stream') &&
36                 $this->facebook->api_client->data_getUserPreference(
37                      FACEBOOK_PROMPTED_UPDATE_PREF) == 'true') {
38
39                 // @todo FIXME: Missing i18n?
40                 echo '<h1>REDIRECT TO HOME</h1>';
41             }
42         } else {
43             $this->showPage();
44         }
45     }
46
47     function showContent()
48     {
49         // If the user has opted not to initially allow the app to have
50         // Facebook status update permission, store that preference. Only
51         // promt the user the first time she uses the app
52         if ($this->arg('skip')) {
53             $this->facebook->api_client->data_setUserPreference(
54                 FACEBOOK_PROMPTED_UPDATE_PREF, 'true');
55         }
56
57         if ($this->flink) {
58             $this->user = $this->flink->getUser();
59
60             // If this is the first time the user has started the app
61              // prompt for Facebook status update permission
62              if (!$this->facebook->api_client->users_hasAppPermission('publish_stream')) {
63
64                  if ($this->facebook->api_client->data_getUserPreference(
65                          FACEBOOK_PROMPTED_UPDATE_PREF) != 'true') {
66                      $this->getUpdatePermission();
67                      return;
68                  }
69              }
70         } else {
71             $this->showLoginForm();
72         }
73
74     }
75
76     function showSuccessContent()
77     {
78
79     }
80
81     function showFormContent()
82     {
83
84     }
85
86     function title()
87     {
88         // @todo FIXME: Give a more precise description? Suggestion: "Login with Facebook Connect"
89         // TRANS: Page title.
90         return sprintf(_m('Login'));
91     }
92
93     function redirectHome()
94     {
95
96     }
97 }