]> git.mxchange.org Git - quix0rs-gnu-social.git/blob - actions/facebookinvite.php
Update favorited for new layout and framework
[quix0rs-gnu-social.git] / actions / facebookinvite.php
1 <?php
2 /*
3  * Laconica - a distributed open-source microblogging tool
4  * Copyright (C) 2008, Controlez-Vous, 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('LACONICA')) { exit(1); }
21
22 require_once(INSTALLDIR.'/lib/facebookaction.php');
23
24 class FacebookinviteAction extends FacebookAction
25 {
26
27     function handle($args)
28     {
29         parent::handle($args);
30
31         if ($this->arg('ids')) {
32             $this->showThankYou();
33         } else {
34             $this->showInviteForm();
35         }
36     }
37
38
39     function showThankYou()
40     {
41         $facebook = get_facebook();
42         $fbuid = $facebook->require_login();
43
44         $this->show_header('Invite');
45
46         $this->element('h2', null, _('Thanks for inviting your friends to use Identi.ca!'));
47         $this->element('p', null, _('Invitations have been sent to the following users:'));
48
49         $friend_ids = $_POST['ids']; // Hmm... $this->arg('ids') doesn't seem to work
50
51         $this->elementStart("ul");
52
53         foreach ($friend_ids as $friend) {
54             $this->elementStart('li');
55             $this->element('fb:profile-pic', array('uid' => $friend));
56             $this->element('fb:name', array('uid' => $friend,
57                                             'capitalize' => 'true'));
58             $this->elementEnd('li');
59         }
60
61         $this->elementEnd("ul");
62
63         $this->show_footer();
64     }
65
66     function showInviteForm()
67     {
68
69         $facebook = get_facebook();
70         $fbuid = $facebook->require_login();
71
72         $this->show_header('Invite');
73
74         // Get a list of users who are already using the app for exclusion
75         $exclude_ids = $facebook->api_client->friends_getAppUsers();
76
77         $content = _('You have been invited to Identi.ca!') .
78             htmlentities('<fb:req-choice url="http://apps.facebook.com/identica_app/" label="Add"/>');
79
80         $this->elementStart('fb:request-form', array('action' => 'invite.php',
81                                                       'method' => 'post',
82                                                       'invite' => 'true',
83                                                       'type' => 'Identi.ca',
84                                                       'content' => $content));
85         $this->hidden('invite', 'true');
86         $actiontext = 'Invite your friends to use Identi.ca.';
87         $this->element('fb:multi-friend-selector', array('showborder' => 'false',
88                                                                'actiontext' => $actiontext,
89                                                                'exclude_ids' => implode(',', $exclude_ids),
90                                                                'bypass' => 'cancel'));
91
92         $this->elementEnd('fb:request-form');
93
94         $this->element('h2', null, _('Friends already using Identi.ca:'));
95         $this->elementStart("ul");
96
97         foreach ($exclude_ids as $friend) {
98             $this->elementStart('li');
99             $this->element('fb:profile-pic', array('uid' => $friend));
100             $this->element('fb:name', array('uid' => $friend,
101                                             'capitalize' => 'true'));
102             $this->elementEnd('li');
103         }
104
105         $this->elementEnd("ul");
106
107         $this->show_footer();
108
109     }
110
111 }