function facebookBroadcastNotice($notice) { $facebook = getFacebook(); $flink = Foreign_link::getByUserID($notice->profile_id, FACEBOOK_SERVICE); if (isFacebookBound($notice, $flink)) { // Okay, we're good to go, update the FB status $fbuid = $flink->foreign_id; $user = $flink->getUser(); try { // Check permissions common_debug('FacebookPlugin - checking for publish_stream permission for user ' . "{$user->nickname} ({$user->id}), Facebook UID: {$fbuid}"); // NOTE: $facebook->api_client->users_hasAppPermission('publish_stream', $fbuid) // has been returning bogus results, so we're using FQL to check for // publish_stream permission now $fql = "SELECT publish_stream FROM permissions WHERE uid = {$fbuid}"; $result = $facebook->api_client->fql_query($fql); $canPublish = 0; if (!empty($result)) { $canPublish = $result[0]['publish_stream']; } if ($canPublish == 1) { common_debug("FacebookPlugin - {$user->nickname} ({$user->id}), Facebook UID: {$fbuid} " . 'has publish_stream permission.'); } else { common_debug("FacebookPlugin - {$user->nickname} ({$user->id}), Facebook UID: {$fbuid} " . 'does NOT have publish_stream permission. Facebook ' . 'returned: ' . var_export($result, true)); } common_debug('FacebookPlugin - checking for status_update permission for user ' . "{$user->nickname} ({$user->id}), Facebook UID: {$fbuid}. "); $canUpdate = $facebook->api_client->users_hasAppPermission('status_update', $fbuid); if ($canUpdate == 1) { common_debug("FacebookPlugin - {$user->nickname} ({$user->id}), Facebook UID: {$fbuid} " . 'has status_update permission.'); } else { common_debug("FacebookPlugin - {$user->nickname} ({$user->id}), Facebook UID: {$fbuid} " . 'does NOT have status_update permission. Facebook ' . 'returned: ' . var_export($canPublish, true)); } // Post to Facebook if ($notice->hasAttachments() && $canPublish == 1) { publishStream($notice, $user, $fbuid); } elseif ($canUpdate == 1 || $canPublish == 1) { statusUpdate($notice, $user, $fbuid); } else { $msg = "FacebookPlugin - Not sending notice {$notice->id} to Facebook " . "because user {$user->nickname} has not given the " . 'Facebook app \'status_update\' or \'publish_stream\' permission.'; common_log(LOG_WARNING, $msg); } // Finally, attempt to update the user's profile box if ($canPublish == 1 || $canUpdate == 1) { updateProfileBox($facebook, $flink, $notice, $user); } } catch (FacebookRestClientException $e) { return handleFacebookError($e, $notice, $flink); } } return true; }
static function getByForeignID($foreign_id, $service) { $flink = new Foreign_link(); $flink->service = $service; $flink->foreign_id = $foreign_id; $flink->limit(1); if ($flink->find(true)) { return $flink; } return null; }
static function getByForeignID($foreign_id, $service) { if (empty($foreign_id) || empty($service)) { return null; } else { $flink = new Foreign_link(); $flink->service = $service; $flink->foreign_id = $foreign_id; $flink->limit(1); $result = $flink->find(true); return empty($result) ? null : $flink; } }
static function getByForeignID($foreign_id, $service) { if (empty($foreign_id) || empty($service)) { throw new ServerException('Empty foreign_id or service for Foreign_link::getByForeignID'); } $flink = new Foreign_link(); $flink->service = $service; $flink->foreign_id = $foreign_id; $flink->limit(1); if (!$flink->find(true)) { throw new NoResultException($flink); } return $flink; }
function handle($data) { // JSON object with Twitter data $status = $data['status']; // Twitter user ID this incoming data belongs to. $receiver = $data['for_user']; $importer = new TwitterImport(); $notice = $importer->importStatus($status); if ($notice instanceof Notice) { try { $flink = Foreign_link::getByForeignID($receiver, TWITTER_SERVICE); common_log(LOG_DEBUG, "TweetInQueueHandler - Got flink so add notice " . $notice->id . " to attentions for user " . $flink->user_id); try { Attention::saveNew($notice, $flink->getProfile()); } catch (Exception $e) { // Log the exception, but make sure we don't bail out, we // still have a queue item to remove here-after. common_log(LOG_ERR, "Failed adding notice {$notice->id} to attentions for user {$flink->user_id}: " . $e->getMessage()); } } catch (NoResultException $e) { common_log(LOG_DEBUG, "TweetInQueueHandler - No flink found for foreign user " . $receiver); } } return true; }
/** * Handler method * * @param array $args is ignored since it's now passed in in prepare() */ function handle($args) { parent::handle($args); $data = $this->facebook->getSignedRequest(); if (isset($data['user_id'])) { $fbuid = $data['user_id']; $flink = Foreign_link::getByForeignID($fbuid, FACEBOOK_SERVICE); $user = $flink->getUser(); // Remove the link to Facebook $result = $flink->delete(); if (!$result) { common_log_db_error($flink, 'DELETE', __FILE__); common_log(LOG_WARNING, sprintf('Unable to delete Facebook foreign link ' . 'for %s (%d), fbuid %d', $user->nickname, $user->id, $fbuid), __FILE__); return; } common_log(LOG_INFO, sprintf('Facebook callback: %s (%d), fbuid %d has deauthorized ' . 'the Facebook application.', $user->nickname, $user->id, $fbuid), __FILE__); // Warn the user about being locked out of their account // if we can. if (empty($user->password) && !empty($user->email)) { Facebookclient::emailWarn($user); } else { common_log(LOG_WARNING, sprintf('%s (%d), fbuid %d has deauthorized his/her Facebook ' . 'connection but hasn\'t set a password so s/he ' . 'is locked out.', $user->nickname, $user->id, $fbuid), __FILE__); } } else { if (!empty($data)) { common_log(LOG_WARNING, sprintf('Facebook called the deauthorize callback ' . ' but didn\'t provide a user ID.'), __FILE__); } else { // It probably wasn't Facebook that hit this action, // so redirect to the public timeline common_redirect(common_local_url('public'), 303); } } }
function facebookBroadcastNotice($notice) { $facebook = getFacebook(); $flink = Foreign_link::getByUserID($notice->profile_id, FACEBOOK_SERVICE); $fbuid = $flink->foreign_id; if (isFacebookBound($notice, $flink)) { $status = null; // Get the status 'verb' (prefix) the user has set try { $prefix = $facebook->api_client->data_getUserPreference(FACEBOOK_NOTICE_PREFIX, $fbuid); $status = "{$prefix} {$notice->content}"; } catch (FacebookRestClientException $e) { common_log(LOG_ERR, $e->getMessage()); return false; } // Okay, we're good to go! try { $facebook->api_client->users_setStatus($status, $fbuid, false, true); updateProfileBox($facebook, $flink, $notice); } catch (FacebookRestClientException $e) { common_log(LOG_ERR, $e->getMessage()); return false; // Should we remove flink if this fails? } } return true; }
function handle($args) { parent::handle($args); $secret = common_config('facebook', 'secret'); $sig = ''; ksort($_POST); foreach ($_POST as $key => $val) { if (substr($key, 0, 7) == 'fb_sig_') { $sig .= substr($key, 7) . '=' . $val; } } $sig .= $secret; $verify = md5($sig); if ($verify == $this->arg('fb_sig')) { $flink = Foreign_link::getByForeignID($this->arg('fb_sig_user'), 2); common_debug("Removing foreign link to Facebook - local user ID: {$flink->user_id}, Facebook ID: {$flink->foreign_id}"); $result = $flink->delete(); if (!$result) { common_log_db_error($flink, 'DELETE', __FILE__); $this->serverError(_('Couldn\'t remove Facebook user.')); return; } } else { # Someone bad tried to remove facebook link? common_log(LOG_ERR, "Someone from {$_SERVER['REMOTE_ADDR']} " . 'unsuccessfully tried to remove a foreign link to Facebook!'); } }
/** * For initializing members of the class. * * @param array $argarray misc. arguments * * @return boolean true */ function prepare($args) { parent::prepare($args); $this->facebook = new Facebook(array('appId' => common_config('facebook', 'appid'), 'secret' => common_config('facebook', 'secret'), 'cookie' => true)); $this->user = common_current_user(); $this->flink = Foreign_link::getByUserID($this->user->id, FACEBOOK_SERVICE); return true; }
protected function doPreparation() { try { $this->flink = Foreign_link::getByUserID($this->scoped->getID(), TWITTER_SERVICE); $this->fuser = $this->flink->getForeignUser(); } catch (NoResultException $e) { // No foreign link found for this user! } }
/** * * @param User $user * @return TwitterOAuthClient */ function twitterAuthForUser(User $user) { $flink = Foreign_link::getByUserID($user->id, TWITTER_SERVICE); $token = TwitterOAuthClient::unpackToken($flink->credentials); if (!$token) { throw new ServerException("No Twitter OAuth credentials for this user."); } return new TwitterOAuthClient($token->key, $token->secret); }
function prepare($argarray) { parent::prepare($argarray); $this->facebook = getFacebook(); $this->fbuid = $this->facebook->require_login(); $this->action = $this->trimmed('action'); $app_props = $this->facebook->api_client->Admin_getAppProperties(array('canvas_name', 'application_name')); $this->app_uri = 'http://apps.facebook.com/' . $app_props['canvas_name']; $this->app_name = $app_props['application_name']; $this->flink = Foreign_link::getByForeignID($this->fbuid, FACEBOOK_SERVICE); return true; }
function broadcast_twitter($notice) { $flink = Foreign_link::getByUserID($notice->profile_id, TWITTER_SERVICE); if (is_twitter_bound($notice, $flink)) { if (TwitterOAuthClient::isPackedToken($flink->credentials)) { return broadcast_oauth($notice, $flink); } else { return broadcast_basicauth($notice, $flink); } } return true; }
/** * * @param Notice $notice the notice to manipulate * @param Profile $profile local user to act as; if left empty, the notice's poster will be used. */ function __construct($notice, $profile = null) { $this->facebook = self::getFacebook(); if (empty($this->facebook)) { throw new FacebookApiException("Could not create Facebook client! Bad application ID or secret?"); } $this->notice = $notice; $profile_id = $profile ? $profile->id : $notice->profile_id; $this->flink = Foreign_link::getByUserID($profile_id, FACEBOOK_SERVICE); if (!empty($this->flink)) { $this->user = $this->flink->getUser(); } }
function facebookBroadcastNotice($notice) { $facebook = getFacebook(); $flink = Foreign_link::getByUserID($notice->profile_id, FACEBOOK_SERVICE); if (isFacebookBound($notice, $flink)) { // Okay, we're good to go, update the FB status $status = null; $fbuid = $flink->foreign_id; $user = $flink->getUser(); $attachments = $notice->attachments(); try { // Get the status 'verb' (prefix) the user has set // XXX: Does this call count against our per user FB request limit? // If so we should consider storing verb elsewhere or not storing $prefix = trim($facebook->api_client->data_getUserPreference(FACEBOOK_NOTICE_PREFIX, $fbuid)); $status = "{$prefix} {$notice->content}"; $can_publish = $facebook->api_client->users_hasAppPermission('publish_stream', $fbuid); $can_update = $facebook->api_client->users_hasAppPermission('status_update', $fbuid); if (!empty($attachments) && $can_publish == 1) { $fbattachment = format_attachments($attachments); $facebook->api_client->stream_publish($status, $fbattachment, null, null, $fbuid); common_log(LOG_INFO, "Posted notice {$notice->id} w/attachment " . "to Facebook user's stream (fbuid = {$fbuid})."); } elseif ($can_update == 1 || $can_publish == 1) { $facebook->api_client->users_setStatus($status, $fbuid, false, true); common_log(LOG_INFO, "Posted notice {$notice->id} to Facebook " . "as a status update (fbuid = {$fbuid})."); } else { $msg = "Not sending notice {$notice->id} to Facebook " . "because user {$user->nickname} hasn't given the " . 'Facebook app \'status_update\' or \'publish_stream\' permission.'; common_log(LOG_WARNING, $msg); } // Finally, attempt to update the user's profile box if ($can_publish == 1 || $can_update == 1) { updateProfileBox($facebook, $flink, $notice); } } catch (FacebookRestClientException $e) { $code = $e->getCode(); $msg = "Facebook returned error code {$code}: " . $e->getMessage() . ' - ' . "Unable to update Facebook status (notice {$notice->id}) " . "for {$user->nickname} (user id: {$user->id})!"; common_log(LOG_WARNING, $msg); if ($code == 100 || $code == 200 || $code == 250) { // 100 The account is 'inactive' (probably - this is not well documented) // 200 The application does not have permission to operate on the passed in uid parameter. // 250 Updating status requires the extended permission status_update or publish_stream. // see: http://wiki.developers.facebook.com/index.php/Users.setStatus#Example_Return_XML remove_facebook_app($flink); } else { // Try sending again later. return false; } } } return true; }
/** * * @param Notice $notice the notice to manipulate * @param Profile $profile local user to act as; if left empty, the notice's poster will be used. */ function __construct($notice, $profile = null) { $this->facebook = self::getFacebook(); if (empty($this->facebook)) { throw new FacebookApiException("Could not create Facebook client! Bad application ID or secret?"); } $this->notice = $notice; $profile_id = $profile ? $profile->id : $notice->profile_id; try { $this->flink = Foreign_link::getByUserID($profile_id, FACEBOOK_SERVICE); $this->user = $this->flink->getUser(); } catch (NoResultException $e) { // at least $this->flink could've gotten set to something, // but the logic that was here before didn't care, so let's not care either } }
function handle($data) { // JSON object with Twitter data $status = $data['status']; // Twitter user ID this incoming data belongs to. $receiver = $data['for_user']; $importer = new TwitterImport(); $notice = $importer->importStatus($status); if ($notice) { $flink = Foreign_link::getByForeignID(TWITTER_SERVICE, $receiver); if ($flink) { // @fixme this should go through more regular channels? Inbox::insertNotice($flink->user_id, $notice->id); } } return true; }
function handle($data) { // JSON object with Twitter data $status = $data['status']; // Twitter user ID this incoming data belongs to. $receiver = $data['for_user']; $importer = new TwitterImport(); $notice = $importer->importStatus($status); if ($notice) { $flink = Foreign_link::getByForeignID($receiver, TWITTER_SERVICE); if ($flink) { common_log(LOG_DEBUG, "TweetInQueueHandler - Got flink so add notice " . $notice->id . " to inbox " . $flink->user_id); // @fixme this should go through more regular channels? Inbox::insertNotice($flink->user_id, $notice->id); } else { common_log(LOG_DEBUG, "TweetInQueueHandler - No flink found for foreign user " . $receiver); } } return true; }
function siteStreamForOwner(User $user) { // The user we auth as must be the owner of the application. $auth = twitterAuthForUser($user); if (have_option('apiroot')) { $stream = new TwitterSiteStream($auth, get_option_value('apiroot')); } else { $stream = new TwitterSiteStream($auth); } // Pull Twitter user IDs for all users we want to pull data for $userIds = array(); $flink = new Foreign_link(); $flink->service = TWITTER_SERVICE; $flink->find(); while ($flink->fetch()) { if (($flink->noticesync & FOREIGN_NOTICE_RECV) == FOREIGN_NOTICE_RECV) { $userIds[] = $flink->foreign_id; } } $stream->followUsers($userIds); return $stream; }
public function onEndShowHeadElements(Action $action) { if (!$action instanceof AttachmentAction) { return true; } /* Twitter card support. See https://dev.twitter.com/docs/cards */ /* @fixme: should we display twitter cards only for attachments posted * by local users ? Seems mandatory to display twitter:creator * * Author: jbfavre */ switch ($action->attachment->mimetype) { case 'image/pjpeg': case 'image/jpeg': case 'image/jpg': case 'image/png': case 'image/gif': $action->element('meta', array('name' => 'twitter:card', 'content' => 'photo'), null); $action->element('meta', array('name' => 'twitter:url', 'content' => common_local_url('attachment', array('attachment' => $action->attachment->id))), null); $action->element('meta', array('name' => 'twitter:image', 'content' => $action->attachment->url)); $action->element('meta', array('name' => 'twitter:title', 'content' => $action->attachment->title)); $ns = new AttachmentNoticeSection($action); $notices = $ns->getNotices(); $noticeArray = $notices->fetchAll(); // Should not have more than 1 notice for this attachment. if (count($noticeArray) != 1) { break; } $post = $noticeArray[0]; $flink = Foreign_link::getByUserID($post->profile_id, TWITTER_SERVICE); if ($flink) { // Our local user has registered Twitter Gateway $fuser = Foreign_user::getForeignUser($flink->foreign_id, TWITTER_SERVICE); if ($fuser) { // Got nickname for local user's Twitter account $action->element('meta', array('name' => 'twitter:creator', 'content' => '@' . $fuser->nickname)); } } break; default: break; } return true; }
function saveStatusMentions($notice, $status) { $mentions = array(); if (empty($status->entities) || empty($status->entities->user_mentions)) { return; } foreach ($status->entities->user_mentions as $mention) { $flink = Foreign_link::getByForeignID($mention->id, TWITTER_SERVICE); if (!empty($flink)) { $user = User::staticGet('id', $flink->user_id); if (!empty($user)) { $reply = new Reply(); $reply->notice_id = $notice->id; $reply->profile_id = $user->id; $reply->modified = $notice->created; common_log(LOG_INFO, __METHOD__ . ": saving reply: notice {$notice->id} to profile {$user->id}"); $id = $reply->insert(); } } } }
function flinkUser($user_id, $fbuid) { $flink = new Foreign_link(); $flink->user_id = $user_id; $flink->foreign_id = $fbuid; $flink->service = FACEBOOK_SERVICE; // Pull the access token from the Facebook cookies $flink->credentials = $this->facebook->getAccessToken(); $flink->created = common_sql_now(); $flink_id = $flink->insert(); return $flink_id; }
/** * Notify remote users when their notices get de-favorited. * * @param Profile $profile Profile person doing the de-faving * @param Notice $notice Notice being favored * * @return hook return value */ function onEndDisfavorNotice(Profile $profile, Notice $notice) { $flink = Foreign_link::getByUserID($profile->id, TWITTER_SERVICE); // twitter service if (empty($flink)) { return true; } if (!TwitterOAuthClient::isPackedToken($flink->credentials)) { $this->log(LOG_INFO, "Skipping fave processing for {$profile->id} since link is not OAuth."); return true; } $status_id = twitter_status_id($notice); if (empty($status_id)) { return true; } $token = TwitterOAuthClient::unpackToken($flink->credentials); $client = new TwitterOAuthClient($token->key, $token->secret); $client->favoritesDestroy($status_id); return true; }
/** * Handle post * * Disconnects the current Facebook user from the current user's account * * @return void */ function handlePost() { // CSRF protection $token = $this->trimmed('token'); if (!$token || $token != common_session_token()) { $this->showForm(_m('There was a problem with your session token. ' . 'Try again, please.')); return; } if ($this->arg('disconnect')) { $user = common_current_user(); $flink = Foreign_link::getByUserID($user->id, FACEBOOK_CONNECT_SERVICE); $result = $flink->delete(); if ($result === false) { common_log_db_error($user, 'DELETE', __FILE__); $this->serverError(_m('Couldn\'t delete link to Facebook.')); return; } try { // Clear FB Connect cookies out $facebook = getFacebook(); $facebook->clear_cookie_state(); } catch (Exception $e) { common_log(LOG_WARNING, 'Facebook Connect Plugin - ' . 'Couldn\'t clear Facebook cookies: ' . $e->getMessage()); } $this->showForm(_m('You have disconnected from Facebook.'), true); } else { $this->showForm(_m('Not sure what you\'re trying to do.')); return; } }
function subscribeTwitterFriends($flink) { $friends = $this->fetchTwitterFriends($flink); if (empty($friends)) { common_debug($this->name() . ' - Couldn\'t get friends from Twitter for ' . "Twitter user {$flink->foreign_id}."); return false; } $profile = $flink->getProfile(); foreach ($friends as $friend) { $friend_name = $friend->screen_name; $friend_id = (int) $friend->id; // Update or create the Foreign_user record for each // Twitter friend if (!save_twitter_user($friend_id, $friend_name)) { common_log(LOG_WARNING, $this->name() . " - Couldn't save {$screen_name}'s friend, {$friend_name}."); continue; } // Check to see if there's a related local user $friend_flink = Foreign_link::getByForeignID($friend_id, TWITTER_SERVICE); if (!empty($friend_flink)) { // Get associated user and subscribe her $friend_profile = Profile::getKV('id', $friend_flink->user_id); if ($friend_profile instanceof Profile) { try { $other = Profile::getKV('id', $invites->user_id); Subscription::start($profile, $friend_profile); common_log(LOG_INFO, $this->name() . ' - Subscribed ' . "{$friend_profile->nickname} to {$profile->nickname}."); } catch (Exception $e) { common_debug($this->name() . ' - Tried and failed subscribing ' . "{$friend_profile->nickname} to {$profile->nickname} - " . $e->getMessage()); } } } } return true; }
function broadcast_twitter($notice) { $success = true; $flink = Foreign_link::getByUserID($notice->profile_id, TWITTER_SERVICE); // XXX: Not sure WHERE to check whether a notice should go to // Twitter. Should we even put in the queue if it shouldn't? --Zach if (!is_null($flink) && is_twitter_bound($notice, $flink)) { $fuser = $flink->getForeignUser(); $twitter_user = $fuser->nickname; $twitter_password = $flink->credentials; $uri = 'http://www.twitter.com/statuses/update.json'; // XXX: Hack to get around PHP cURL's use of @ being a a meta character $statustxt = preg_replace('/^@/', ' @', $notice->content); $options = array(CURLOPT_USERPWD => "{$twitter_user}:{$twitter_password}", CURLOPT_POST => true, CURLOPT_POSTFIELDS => array('status' => $statustxt, 'source' => common_config('integration', 'source')), CURLOPT_RETURNTRANSFER => true, CURLOPT_FAILONERROR => true, CURLOPT_HEADER => false, CURLOPT_FOLLOWLOCATION => true, CURLOPT_USERAGENT => "Laconica", CURLOPT_CONNECTTIMEOUT => 120, CURLOPT_TIMEOUT => 120, CURLOPT_HTTPHEADER => array('Expect:')); $ch = curl_init($uri); curl_setopt_array($ch, $options); $data = curl_exec($ch); $errmsg = curl_error($ch); if ($errmsg) { common_debug("cURL error: {$errmsg} - " . "trying to send notice for {$twitter_user}.", __FILE__); $success = false; } curl_close($ch); if (!$data) { common_debug("No data returned by Twitter's " . "API trying to send update for {$twitter_user}", __FILE__); $success = false; } // Twitter should return a status $status = json_decode($data); if (!$status->id) { common_debug("Unexpected data returned by Twitter " . " API trying to send update for {$twitter_user}", __FILE__); $success = false; } } return $success; }
function flinkUser($user_id, $fbuid) { $flink = new Foreign_link(); $flink->user_id = $user_id; $flink->foreign_id = $fbuid; $flink->service = FACEBOOK_SERVICE; $flink->credentials = $this->accessToken; $flink->created = common_sql_now(); $flink_id = $flink->insert(); return $flink_id; }
function tryLogin() { common_debug('TwitterBridge Plugin - ' . "Trying login for Twitter user {$this->twuid}."); $flink = Foreign_link::getByForeignID($this->twuid, TWITTER_SERVICE); if (!empty($flink)) { $user = $flink->getUser(); if (!empty($user)) { common_debug('TwitterBridge Plugin - ' . "Logged in Twitter user {$flink->foreign_id} as user {$user->id} ({$user->nickname})"); common_set_user($user); common_real_login(true); $this->goHome($user->nickname); } } else { common_debug('TwitterBridge Plugin - ' . "No flink found for twuid: {$this->twuid} - new user"); $this->showForm(null, $this->bestNewNickname()); } }
/** * Is the user currently logged in with FB Connect? * * @return mixed $fbuid the Facebook ID of the logged in user, or null */ function loggedIn() { $user = common_current_user(); if (!empty($user)) { $flink = Foreign_link::getByUserId($user->id, FACEBOOK_CONNECT_SERVICE); $fbuid = 0; if (!empty($flink)) { try { $facebook = getFacebook(); $fbuid = getFacebook()->get_loggedin_user(); } catch (Exception $e) { common_log(LOG_WARNING, 'Problem getting Facebook client: ' . $e->getMessage()); } if ($fbuid > 0) { return $fbuid; } } } return null; }
/** * Save user's Twitter-bridging preferences * * @return void */ function savePreferences() { $noticesend = $this->boolean('noticesend'); $noticerecv = $this->boolean('noticerecv'); $friendsync = $this->boolean('friendsync'); $replysync = $this->boolean('replysync'); $user = common_current_user(); $flink = Foreign_link::getByUserID($user->id, TWITTER_SERVICE); if (empty($flink)) { common_log_db_error($flink, 'SELECT', __FILE__); $this->showForm(_m('Couldn\'t save Twitter preferences.')); return; } $original = clone $flink; $flink->set_flags($noticesend, $noticerecv, $replysync, $friendsync); $result = $flink->update($original); if ($result === false) { common_log_db_error($flink, 'UPDATE', __FILE__); $this->showForm(_m('Couldn\'t save Twitter preferences.')); return; } $this->showForm(_m('Twitter preferences saved.'), true); }