]> git.mxchange.org Git - quix0rs-gnu-social.git/blobdiff - actions/facebooksettings.php
Merge branch '0.9.x' of git@gitorious.org:statusnet/mainline into 0.9.x
[quix0rs-gnu-social.git] / actions / facebooksettings.php
index 236460c1c9a42f1f15463aa69959fddb802fbf97..b2b1d68071a050ea7d34a02ed61227ad08220c50 100644 (file)
@@ -1,7 +1,7 @@
 <?php
 /*
- * Laconica - a distributed open-source microblogging tool
- * Copyright (C) 2008, Controlez-Vous, Inc.
+ * StatusNet - the distributed open-source microblogging tool
+ * Copyright (C) 2008, 2009, StatusNet, Inc.
  *
  * This program is free software: you can redistribute it and/or modify
  * it under the terms of the GNU Affero General Public License as published by
@@ -17,7 +17,7 @@
  * along with this program.     If not, see <http://www.gnu.org/licenses/>.
  */
 
-if (!defined('LACONICA')) { exit(1); }
+if (!defined('STATUSNET') && !defined('LACONICA')) { exit(1); }
 
 require_once INSTALLDIR.'/lib/facebookaction.php';
 
@@ -55,11 +55,18 @@ class FacebooksettingsAction extends FacebookAction
         $prefix = $this->trimmed('prefix');
 
         $original = clone($this->flink);
-        $this->flink->set_flags($noticesync, $replysync, false);
+        $this->flink->set_flags($noticesync, $replysync, false, false);
         $result = $this->flink->update($original);
 
+        if ($prefix == '' || $prefix == '0') {
+               // Facebook bug: saving empty strings to prefs now fails
+               // http://bugs.developers.facebook.com/show_bug.cgi?id=7110
+               $trimmed = $prefix . ' ';
+        } else {
+               $trimmed = substr($prefix, 0, 128);
+           }
         $this->facebook->api_client->data_setUserPreference(FACEBOOK_NOTICE_PREFIX,
-            substr($prefix, 0, 128));
+            $trimmed);
 
         if ($result === false) {
             $this->showForm(_('There was a problem saving your sync preferences!'));
@@ -78,7 +85,7 @@ class FacebooksettingsAction extends FacebookAction
             }
         }
 
-        if ($this->facebook->api_client->users_hasAppPermission('status_update')) {
+        if ($this->facebook->api_client->users_hasAppPermission('publish_stream')) {
 
             $this->elementStart('form', array('method' => 'post',
                                                'id' => 'facebook_settings'));
@@ -101,7 +108,7 @@ class FacebooksettingsAction extends FacebookAction
 
             $this->elementStart('li');
 
-            $prefix = $this->facebook->api_client->data_getUserPreference(FACEBOOK_NOTICE_PREFIX);
+            $prefix = trim($this->facebook->api_client->data_getUserPreference(FACEBOOK_NOTICE_PREFIX));
 
             $this->input('prefix', _('Prefix'),
                          ($prefix) ? $prefix : null,
@@ -131,7 +138,7 @@ class FacebooksettingsAction extends FacebookAction
 
             $this->elementStart('ul', array('id' => 'fb-permissions-list'));
             $this->elementStart('li', array('id' => 'fb-permissions-item'));
-            $this->elementStart('fb:prompt-permission', array('perms' => 'status_update',
+            $this->elementStart('fb:prompt-permission', array('perms' => 'publish_stream',
                 'next_fbjs' => 'document.setLocation(\'' . "$this->app_uri/settings.php" . '\')'));
             $this->element('span', array('class' => 'facebook-button'),
                 sprintf(_('Allow %s to update my Facebook status'), common_config('site', 'name')));