summaryrefslogtreecommitdiff
path: root/actions/facebooksettings.php
diff options
context:
space:
mode:
Diffstat (limited to 'actions/facebooksettings.php')
-rw-r--r--actions/facebooksettings.php97
1 files changed, 79 insertions, 18 deletions
diff --git a/actions/facebooksettings.php b/actions/facebooksettings.php
index 4d7000d60..d28b1aa5c 100644
--- a/actions/facebooksettings.php
+++ b/actions/facebooksettings.php
@@ -10,43 +10,104 @@
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Affero General Public License for more details.
*
* You should have received a copy of the GNU Affero General Public License
- * along with this program. If not, see <http://www.gnu.org/licenses/>.
+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
if (!defined('LACONICA')) { exit(1); }
require_once(INSTALLDIR.'/lib/facebookaction.php');
-class FacebooksettingsAction extends FacebookAction {
+class FacebooksettingsAction extends FacebookAction
+{
- function handle($args) {
- parent::handle($args);
+ function handle($args)
+ {
+ parent::handle($args);
- $this->display();
- }
+ if ($this->arg('save')) {
+ $this->save_settings();
+ } else {
+ $this->show_form();
+ }
+ }
- function display() {
- $facebook = $this->get_facebook();
+ function save_settings() {
- $fbuid = $facebook->require_login();
+ $noticesync = $this->arg('noticesync');
+ $replysync = $this->arg('replysync');
- $fbml = '<fb:if-section-not-added section="profile">'
- .'<h2>Add an Identi.ca box to your profile!</h2>'
- .'<fb:add-section-button section="profile"/>'
- .'</fb:if-section-not-added>';
+ $facebook = get_facebook();
+ $fbuid = $facebook->require_login();
+ $flink = Foreign_link::getByForeignID($fbuid, 2); // 2 == Facebook
- $this->show_header('Settings');
+ $original = clone($flink);
+ $flink->set_flags($noticesync, $replysync, false);
+ $result = $flink->update($original);
- echo $fbml;
+ if ($result) {
+ echo '<fb:success message="Sync preferences saved." />';
+ }
- $this->show_footer();
+ $this->show_form();
- }
+ }
+
+ function show_form() {
+
+ $facebook = get_facebook();
+ $fbuid = $facebook->require_login();
+
+ $flink = Foreign_link::getByForeignID($fbuid, 2); // 2 == Facebook
+
+ $this->show_header('Settings');
+
+ $fbml = '<fb:if-section-not-added section="profile">'
+ .'<h2>Add an Identi.ca box to my profile</h2>'
+ .'<p><fb:add-section-button section="profile"/></p>'
+ .'</fb:if-section-not-added>';
+
+ $fbml .= '<p><fb:prompt-permission perms="status_update"><h2>Allow Identi.ca to update my Facebook status</h2></fb:prompt-permission></p>';
+
+ if ($facebook->api_client->users_hasAppPermission('status_update')) {
+
+ $fbml .= '<form method="post" id="facebook_settings">'
+ .'<h2>Sync preferences</h2>'
+ .'<p>';
+
+ if ($flink->noticesync & FOREIGN_NOTICE_SEND) {
+ $fbml .= '<input name="noticesync" type="checkbox" class="checkbox" id="noticesync" checked="checked"/>';
+ } else {
+ $fbml .= '<input name="noticesync" type="checkbox" class="checkbox" id="noticesync">';
+ }
+
+ $fbml .= '<label class="checkbox_label" for="noticesync">Automatically update my Facebook status with my notices.</label>'
+ .'</p>'
+ .'<p>';
+
+ if ($flink->noticesync & FOREIGN_NOTICE_SEND_REPLY) {
+ $fbml .= '<input name="replysync" type="checkbox" class="checkbox" id="replysync" checked="checked"/>';
+ } else {
+ $fbml .= '<input name="replysync" type="checkbox" class="checkbox" id="replysync"/>';
+ }
+
+ $fbml .= '<label class="checkbox_label" for="replysync">Send &quot;@&quot; replies to Facebook.</label>'
+ .'</p>'
+ .'<p>'
+ .'<input type="submit" id="save" name="save" class="submit" value="Save"/>'
+ .'</p>'
+ .'</form>';
+
+ }
+
+ echo $fbml;
+
+ $this->show_footer();
+ }
}