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 FacebooksettingsAction extends FacebookAction
27 function handle($args)
29 parent::handle($args);
31 if ($this->arg('save')) {
32 $this->save_settings();
39 function save_settings() {
41 $noticesync = $this->arg('noticesync');
42 $replysync = $this->arg('replysync');
44 $facebook = get_facebook();
45 $fbuid = $facebook->require_login();
47 $flink = Foreign_link::getByForeignID($fbuid, 2); // 2 == Facebook
49 $original = clone($flink);
50 $flink->set_flags($noticesync, $replysync, false);
51 $result = $flink->update($original);
54 echo '<fb:success message="Sync preferences saved." />';
61 function show_form() {
63 $facebook = get_facebook();
64 $fbuid = $facebook->require_login();
66 $flink = Foreign_link::getByForeignID($fbuid, 2); // 2 == Facebook
68 $this->show_header('Settings');
70 $fbml = '<fb:if-section-not-added section="profile">'
71 .'<h2>Add an Identi.ca box to my profile</h2>'
72 .'<p><fb:add-section-button section="profile"/></p>'
73 .'</fb:if-section-not-added>';
75 $fbml .= '<p><fb:prompt-permission perms="status_update"><h2>Allow Identi.ca to update my Facebook status</h2></fb:prompt-permission></p>';
77 if ($facebook->api_client->users_hasAppPermission('status_update')) {
79 $fbml .= '<form method="post" id="facebook_settings">'
80 .'<h2>Sync preferences</h2>'
83 if ($flink->noticesync & FOREIGN_NOTICE_SEND) {
84 $fbml .= '<input name="noticesync" type="checkbox" class="checkbox" id="noticesync" checked="checked"/>';
86 $fbml .= '<input name="noticesync" type="checkbox" class="checkbox" id="noticesync">';
89 $fbml .= '<label class="checkbox_label" for="noticesync">Automatically update my Facebook status with my notices.</label>'
93 if ($flink->noticesync & FOREIGN_NOTICE_SEND_REPLY) {
94 $fbml .= '<input name="replysync" type="checkbox" class="checkbox" id="replysync" checked="checked"/>';
96 $fbml .= '<input name="replysync" type="checkbox" class="checkbox" id="replysync"/>';
99 $fbml .= '<label class="checkbox_label" for="replysync">Send "@" replies to Facebook.</label>'
102 .'<input type="submit" id="save" name="save" class="submit" value="Save"/>'
110 $this->show_footer();