3 * Laconica - a distributed open-source microblogging tool
4 * Copyright (C) 2008, Controlez-Vous, Inc.
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.
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.
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/>.
20 if (!defined('LACONICA')) { exit(1); }
22 require_once(INSTALLDIR.'/lib/facebookaction.php');
24 class FacebookinviteAction extends FacebookAction
27 function handle($args)
29 parent::handle($args);
31 if ($this->arg('ids')) {
32 $this->showThankYou();
34 $this->showInviteForm();
39 function showThankYou()
41 $facebook = get_facebook();
42 $fbuid = $facebook->require_login();
44 $this->show_header('Invite');
46 common_element('h2', null, _('Thanks for inviting your friends to use Identi.ca!'));
47 common_element('p', null, _('Invitations have been sent to the following users:'));
49 $friend_ids = $_POST['ids']; // Hmm... $this->arg('ids') doesn't seem to work
51 common_element_start("ul");
53 foreach ($friend_ids as $friend) {
54 common_element_start('li');
55 common_element('fb:profile-pic', array('uid' => $friend));
56 common_element('fb:name', array('uid' => $friend,
57 'capitalize' => 'true'));
58 common_element_end('li');
61 common_element_end("ul");
66 function showInviteForm()
69 $facebook = get_facebook();
70 $fbuid = $facebook->require_login();
72 $this->show_header('Invite');
74 // Get a list of users who are already using the app for exclusion
75 $exclude_ids = $facebook->api_client->friends_getAppUsers();
77 $content = _('You have been invited to Identi.ca!') .
78 htmlentities('<fb:req-choice url="http://apps.facebook.com/identica_app/" label="Add"/>');
80 common_element_start('fb:request-form', array('action' => 'invite.php',
83 'type' => 'Identi.ca',
84 'content' => $content));
85 common_hidden('invite', 'true');
86 $actiontext = 'Invite your friends to use Identi.ca.';
87 common_element('fb:multi-friend-selector', array('showborder' => 'false',
88 'actiontext' => $actiontext,
89 'exclude_ids' => implode(',', $exclude_ids),
90 'bypass' => 'cancel'));
92 common_element_end('fb:request-form');
94 common_element('h2', null, _('Friends already using Identi.ca:'));
95 common_element_start("ul");
97 foreach ($exclude_ids as $friend) {
98 common_element_start('li');
99 common_element('fb:profile-pic', array('uid' => $friend));
100 common_element('fb:name', array('uid' => $friend,
101 'capitalize' => 'true'));
102 common_element_end('li');
105 common_element_end("ul");
107 $this->show_footer();