]> git.mxchange.org Git - quix0rs-gnu-social.git/blobdiff - actions/twittersettings.php
Added configuration options to enable/disable SMS and Twitter integration.
[quix0rs-gnu-social.git] / actions / twittersettings.php
index 45725d3ff44e289cdef8b7c1ed80399c30db5ede..3343dba95a20d240a0a42f1ab14ae97e650e6223 100644 (file)
@@ -85,6 +85,12 @@ class TwittersettingsAction extends ConnectSettingsAction
 
     function showContent()
     {
+        if (!common_config('twitter', 'enabled')) {
+            $this->element('div', array('class' => 'error'),
+                           _('Twitter is not available.'));
+            return;
+        }
+
         $user = common_current_user();
 
         $profile = $user->getProfile();
@@ -138,7 +144,7 @@ class TwittersettingsAction extends ConnectSettingsAction
 
         $this->elementStart('ul', 'form_data');
         $this->elementStart('li');
-        $this->checkbox('noticesync',
+        $this->checkbox('noticesend',
                         _('Automatically send my notices to Twitter.'),
                         ($flink) ?
                         ($flink->noticesync & FOREIGN_NOTICE_SEND) :
@@ -158,6 +164,22 @@ class TwittersettingsAction extends ConnectSettingsAction
                         ($flink->friendsync & FOREIGN_FRIEND_RECV) :
                         false);
         $this->elementEnd('li');
+
+        if (common_config('twitterbridge','enabled')) {
+            $this->elementStart('li');
+            $this->checkbox('noticerecv',
+                            _('Import my Friends Timeline.'),
+                            ($flink) ?
+                            ($flink->noticesync & FOREIGN_NOTICE_RECV) :
+                            false);
+            $this->elementEnd('li');
+        } else {
+            // preserve setting even if bidrection bridge toggled off
+            if ($flink && ($flink->noticesync & FOREIGN_NOTICE_RECV)) {
+                $this->hidden('noticerecv', true, 'noticerecv');
+            }
+        }
+
         $this->elementEnd('ul');
 
         if ($flink) {
@@ -261,7 +283,7 @@ class TwittersettingsAction extends ConnectSettingsAction
                                             'alt' =>  ($other->fullname) ?
                                             $other->fullname :
                                             $other->nickname));
-                
+
                 $this->element('span', 'fn nickname', $other->nickname);
                 $this->elementEnd('a');
                 $this->elementEnd('li');
@@ -320,7 +342,8 @@ class TwittersettingsAction extends ConnectSettingsAction
     {
         $screen_name = $this->trimmed('twitter_username');
         $password    = $this->trimmed('twitter_password');
-        $noticesync  = $this->boolean('noticesync');
+        $noticesend  = $this->boolean('noticesend');
+        $noticerecv  = $this->boolean('noticerecv');
         $replysync   = $this->boolean('replysync');
         $friendsync  = $this->boolean('friendsync');
 
@@ -363,7 +386,7 @@ class TwittersettingsAction extends ConnectSettingsAction
         $flink->credentials = $password;
         $flink->created     = common_sql_now();
 
-        $flink->set_flags($noticesync, $replysync, $friendsync);
+        $flink->set_flags($noticesend, $noticerecv, $replysync, $friendsync);
 
         $flink_id = $flink->insert();
 
@@ -375,6 +398,8 @@ class TwittersettingsAction extends ConnectSettingsAction
 
         if ($friendsync) {
             save_twitter_friends($user, $twit_user->id, $screen_name, $password);
+            $flink->last_friendsync = common_sql_now();
+            $flink->update();
         }
 
         $this->showForm(_('Twitter settings saved.'), true);
@@ -419,7 +444,8 @@ class TwittersettingsAction extends ConnectSettingsAction
 
     function savePreferences()
     {
-        $noticesync = $this->boolean('noticesync');
+        $noticesend = $this->boolean('noticesend');
+        $noticerecv = $this->boolean('noticerecv');
         $friendsync = $this->boolean('friendsync');
         $replysync  = $this->boolean('replysync');
 
@@ -448,7 +474,7 @@ class TwittersettingsAction extends ConnectSettingsAction
 
         $original = clone($flink);
 
-        $flink->set_flags($noticesync, $replysync, $friendsync);
+        $flink->set_flags($noticesend, $noticerecv, $replysync, $friendsync);
 
         $result = $flink->update($original);