X-Git-Url: https://git.mxchange.org/?a=blobdiff_plain;f=actions%2Ftwittersettings.php;h=2b742788eee55419112a718d271f6e4285960163;hb=b4e649fe906a793cd5e62d6390065ea5d41c40db;hp=0c109ab53aa962f1c086a0c83b01b0ec6cabaa0a;hpb=843358be44b9b107441cbc2e35d7794343762fb0;p=quix0rs-gnu-social.git diff --git a/actions/twittersettings.php b/actions/twittersettings.php index 0c109ab53a..2b742788ee 100644 --- a/actions/twittersettings.php +++ b/actions/twittersettings.php @@ -32,6 +32,7 @@ if (!defined('LACONICA')) { } require_once INSTALLDIR.'/lib/connectsettingsaction.php'; +require_once INSTALLDIR.'/lib/twitter.php'; define('SUBSCRIPTIONS', 80); @@ -57,7 +58,7 @@ class TwittersettingsAction extends ConnectSettingsAction function title() { - _('Twitter settings'); + return _('Twitter settings'); } /** @@ -90,7 +91,7 @@ class TwittersettingsAction extends ConnectSettingsAction $fuser = null; - $flink = Foreign_link::getByUserID($user->id, 1); // 1 == Twitter + $flink = Foreign_link::getByUserID($user->id, TWITTER_SERVICE); if ($flink) { $fuser = $flink->getForeignUser(); @@ -104,18 +105,20 @@ class TwittersettingsAction extends ConnectSettingsAction $this->elementStart('fieldset', array('id' => 'settings_twitter_account')); $this->element('legend', null, _('Twitter Account')); $this->hidden('token', common_session_token()); - $this->elementStart('ul', 'form_data'); if ($fuser) { - $this->elementStart('li'); + $this->elementStart('ul', 'form_data'); + $this->elementStart('li', array('id' => 'settings_twitter_remove')); $this->element('span', 'twitter_user', $fuser->nickname); $this->element('a', array('href' => $fuser->uri), $fuser->uri); - $this->element('p', 'form_guide', + $this->element('p', 'form_note', _('Current verified Twitter account.')); $this->hidden('flink_foreign_id', $flink->foreign_id); - $this->submit('remove', _('Remove')); $this->elementEnd('li'); + $this->elementEnd('ul'); + $this->submit('remove', _('Remove')); } else { - $this->elementStart('li'); + $this->elementStart('ul', 'form_data'); + $this->elementStart('li', array('id' => 'settings_twitter_login')); $this->input('twitter_username', _('Twitter user name'), ($this->arg('twitter_username')) ? $this->arg('twitter_username') : @@ -125,8 +128,8 @@ class TwittersettingsAction extends ConnectSettingsAction $this->elementStart('li'); $this->password('twitter_password', _('Twitter password')); $this->elementend('li'); + $this->elementEnd('ul'); } - $this->elementEnd('ul'); $this->elementEnd('fieldset'); $this->elementStart('fieldset', @@ -135,7 +138,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) : @@ -155,6 +158,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) { @@ -183,12 +202,12 @@ class TwittersettingsAction extends ConnectSettingsAction $current_user = common_current_user(); - $qry = 'SELECT user.* ' . + $qry = 'SELECT "user".* ' . 'FROM subscription ' . - 'JOIN user ON subscription.subscribed = user.id ' . - 'JOIN foreign_link ON foreign_link.user_id = user.id ' . + 'JOIN "user" ON subscription.subscribed = "user".id ' . + 'JOIN foreign_link ON foreign_link.user_id = "user".id ' . 'WHERE subscriber = %d ' . - 'ORDER BY user.nickname'; + 'ORDER BY "user".nickname'; $user = new User(); @@ -224,10 +243,10 @@ class TwittersettingsAction extends ConnectSettingsAction $friends_count = count($friends); if ($friends_count > 0) { - - $this->element('h3', null, _('Twitter Friends')); - $this->elementStart('div', array('id' => 'subscriptions')); - $this->elementStart('ul', array('id' => 'subscriptions_avatars')); + $this->elementStart('div', array('id' => 'entity_subscriptions', + 'class' => 'section')); + $this->element('h2', null, _('Twitter Friends')); + $this->elementStart('ul', 'entities users xoxo'); for ($i = 0; $i < min($friends_count, SUBSCRIPTIONS); $i++) { @@ -238,27 +257,28 @@ class TwittersettingsAction extends ConnectSettingsAction continue; } - $this->elementStart('li'); + $this->elementStart('li', 'vcard'); $this->elementStart('a', array('title' => ($other->fullname) ? $other->fullname : $other->nickname, 'href' => $other->profileurl, - 'rel' => 'contact', - 'class' => 'subscription')); + 'class' => 'url')); $avatar = $other->getAvatar(AVATAR_MINI_SIZE); $avatar_url = ($avatar) ? - common_avatar_display_url($avatar) : - common_default_avatar(AVATAR_MINI_SIZE); + $avatar->displayUrl() : + Avatar::defaultImage(AVATAR_MINI_SIZE); $this->element('img', array('src' => $avatar_url, 'width' => AVATAR_MINI_SIZE, 'height' => AVATAR_MINI_SIZE, - 'class' => 'avatar mini', + 'class' => 'avatar photo', 'alt' => ($other->fullname) ? $other->fullname : $other->nickname)); + + $this->element('span', 'fn nickname', $other->nickname); $this->elementEnd('a'); $this->elementEnd('li'); @@ -316,7 +336,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'); @@ -355,11 +376,11 @@ class TwittersettingsAction extends ConnectSettingsAction $flink->user_id = $user->id; $flink->foreign_id = $twit_user->id; - $flink->service = 1; // Twitter + $flink->service = TWITTER_SERVICE; $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(); @@ -371,6 +392,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); @@ -415,7 +438,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'); @@ -444,7 +468,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);