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();
38 function save_settings() {
40 $noticesync = $this->arg('noticesync');
41 $replysync = $this->arg('replysync');
43 $facebook = get_facebook();
44 $fbuid = $facebook->require_login();
46 $flink = Foreign_link::getByForeignID($fbuid, FACEBOOK_SERVICE);
48 $original = clone($flink);
49 $flink->set_flags($noticesync, $replysync, false);
50 $result = $flink->update($original);
53 $this->show_form('Sync preferences saved.', true);
55 $this->show_form('There was a problem saving your sync preferences!');
59 function show_form($msg = null, $success = false) {
61 $facebook = get_facebook();
62 $fbuid = $facebook->require_login();
64 $flink = Foreign_link::getByForeignID($fbuid, FACEBOOK_SERVICE);
66 $this->show_header('Settings', $msg, $success);
68 common_element_start('fb:if-section-not-added', array('section' => 'profile'));
69 common_element('h2', null, _('Add an Identi.ca box to my profile'));
70 common_element_start('p');
71 common_element('fb:add-section-button', array('section' => 'profile'));
72 common_element_end('p');
73 common_element_end('fb:if-section-not-added');
75 common_element_start('p');
76 common_element_start('fb:prompt-permission', array('perms' => 'status_update'));
77 common_element('h2', null, _('Allow Identi.ca to update my Facebook status'));
78 common_element_end('fb:prompt-permission');
79 common_element_end('p');
81 if ($facebook->api_client->users_hasAppPermission('status_update')) {
83 common_element_start('form', array('method' => 'post',
84 'id' => 'facebook_settings'));
86 common_element('h2', null, _('Sync preferences'));
88 common_checkbox('noticesync', _('Automatically update my Facebook status with my notices.'),
89 ($flink) ? ($flink->noticesync & FOREIGN_NOTICE_SEND) : true);
91 common_checkbox('replysync', _('Send local "@" replies to Facebook.'),
92 ($flink) ? ($flink->noticesync & FOREIGN_NOTICE_SEND_REPLY) : true);
94 common_submit('save', _('Save'));
96 common_element_end('form');
100 $this->show_footer();