]> git.mxchange.org Git - quix0rs-gnu-social.git/blob - actions/facebookinvite.php
uiredesign + phpdocs
[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->showHeader('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->showFooter();
64     }
65
66     function showInviteForm()
67     {
68
69         $facebook = get_facebook();
70         $fbuid = $facebook->require_login();
71
72         $this->showHeader();
73         $this->showNav('Invite');
74
75         // Get a list of users who are already using the app for exclusion
76         $exclude_ids = $facebook->api_client->friends_getAppUsers();
77
78         $content = _('You have been invited to Identi.ca!') .
79             htmlentities('<fb:req-choice url="http://apps.facebook.com/identica_app/" label="Add"/>');
80
81         $this->elementStart('fb:request-form', array('action' => 'invite.php',
82                                                       'method' => 'post',
83                                                       'invite' => 'true',
84                                                       'type' => 'Identi.ca',
85                                                       'content' => $content));
86         $this->hidden('invite', 'true');
87         $actiontext = 'Invite your friends to use Identi.ca.';
88         $this->element('fb:multi-friend-selector', array('showborder' => 'false',
89                                                                'actiontext' => $actiontext,
90                                                                'exclude_ids' => implode(',', $exclude_ids),
91                                                                'bypass' => 'cancel'));
92
93         $this->elementEnd('fb:request-form');
94
95         $this->element('h2', null, _('Friends already using Identi.ca:'));
96         $this->elementStart("ul");
97
98         foreach ($exclude_ids as $friend) {
99             $this->elementStart('li');
100             $this->element('fb:profile-pic', array('uid' => $friend));
101             $this->element('fb:name', array('uid' => $friend,
102                                             'capitalize' => 'true'));
103             $this->elementEnd('li');
104         }
105
106         $this->elementEnd("ul");
107
108         $this->showFooter();
109
110     }
111
112 }