From 689be142158dae5af1516cb38b947f0364d725dd Mon Sep 17 00:00:00 2001 From: Zach Copley Date: Sun, 11 Jan 2009 07:03:59 +0000 Subject: trac750 - Facebook app now uses XMLWriter for output (much cleaner!) --- actions/facebooksettings.php | 66 +++++++++++++++++++------------------------- 1 file changed, 28 insertions(+), 38 deletions(-) (limited to 'actions/facebooksettings.php') diff --git a/actions/facebooksettings.php b/actions/facebooksettings.php index d28b1aa5c..88364c797 100644 --- a/actions/facebooksettings.php +++ b/actions/facebooksettings.php @@ -35,7 +35,6 @@ class FacebooksettingsAction extends FacebookAction } } - function save_settings() { $noticesync = $this->arg('noticesync'); @@ -44,68 +43,59 @@ class FacebooksettingsAction extends FacebookAction $facebook = get_facebook(); $fbuid = $facebook->require_login(); - $flink = Foreign_link::getByForeignID($fbuid, 2); // 2 == Facebook + $flink = Foreign_link::getByForeignID($fbuid, FACEBOOK_SERVICE); $original = clone($flink); $flink->set_flags($noticesync, $replysync, false); $result = $flink->update($original); if ($result) { - echo ''; + $this->show_form('Sync preferences saved.', true); + } else { + $this->show_form('There was a problem saving your sync preferences!'); } - - $this->show_form(); - } - function show_form() { + function show_form($msg = null, $success = false) { $facebook = get_facebook(); $fbuid = $facebook->require_login(); - $flink = Foreign_link::getByForeignID($fbuid, 2); // 2 == Facebook + $flink = Foreign_link::getByForeignID($fbuid, FACEBOOK_SERVICE); - $this->show_header('Settings'); + $this->show_header('Settings', $msg, $success); - $fbml = '' - .'

Add an Identi.ca box to my profile

' - .'

' - .'
'; + common_element_start('fb:if-section-not-added', array('section' => 'profile')); + common_element('h2', null, _('Add an Identi.ca box to my profile')); + common_element_start('p'); + common_element('fb:add-section-button', array('section' => 'profile')); + common_element_end('p'); + common_element_end('fb:if-section-not-added'); - $fbml .= '

Allow Identi.ca to update my Facebook status

'; + common_element_start('p'); + common_element_start('fb:prompt-permission', array('perms' => 'status_update')); + common_element('h2', null, _('Allow Identi.ca to update my Facebook status')); + common_element_end('fb:prompt-permission'); + common_element_end('p'); if ($facebook->api_client->users_hasAppPermission('status_update')) { - $fbml .= '
' - .'

Sync preferences

' - .'

'; + common_element_start('form', array('method' => 'post', + 'id' => 'facebook_settings')); - if ($flink->noticesync & FOREIGN_NOTICE_SEND) { - $fbml .= ''; - } else { - $fbml .= ''; - } + common_element('h2', null, _('Sync preferences')); - $fbml .= '' - .'

' - .'

'; + common_checkbox('noticesync', _('Automatically update my Facebook status with my notices.'), + ($flink) ? ($flink->noticesync & FOREIGN_NOTICE_SEND) : true); - if ($flink->noticesync & FOREIGN_NOTICE_SEND_REPLY) { - $fbml .= ''; - } else { - $fbml .= ''; - } + common_checkbox('replysync', _('Send local "@" replies to Facebook.'), + ($flink) ? ($flink->noticesync & FOREIGN_NOTICE_SEND_REPLY) : true); - $fbml .= '' - .'

' - .'

' - .'' - .'

' - .'
'; + common_submit('save', _('Save')); - } + common_element_end('form'); - echo $fbml; + } $this->show_footer(); } -- cgit v1.2.3-54-g00ecf