本文整理汇总了PHP中Foreign_link::set_flags方法的典型用法代码示例。如果您正苦于以下问题:PHP Foreign_link::set_flags方法的具体用法?PHP Foreign_link::set_flags怎么用?PHP Foreign_link::set_flags使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Foreign_link
的用法示例。
在下文中一共展示了Foreign_link::set_flags方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: saveForeignLink
/**
* Saves a Foreign_link between Twitter user and local user,
* which includes the access token and secret.
*
* @param int $user_id StatusNet user ID
* @param int $twuid Twitter user ID
* @param OAuthToken $token the access token to save
*
* @return nothing
*/
function saveForeignLink($user_id, $twuid, $access_token)
{
$flink = new Foreign_link();
$flink->user_id = $user_id;
$flink->service = TWITTER_SERVICE;
// delete stale flink, if any
$result = $flink->find(true);
if (!empty($result)) {
$flink->safeDelete();
}
$flink->user_id = $user_id;
$flink->foreign_id = $twuid;
$flink->service = TWITTER_SERVICE;
$creds = TwitterOAuthClient::packToken($access_token);
$flink->credentials = $creds;
$flink->created = common_sql_now();
// Defaults: noticesync on, everything else off
$flink->set_flags(true, false, false, false);
$flink_id = $flink->insert();
if (empty($flink_id)) {
common_log_db_error($flink, 'INSERT', __FILE__);
// TRANS: Server error displayed when linking to a Twitter account fails.
$this->serverError(_m('Could not link your Twitter account.'));
}
return $flink_id;
}
示例2: addTwitterAccount
/**
* Associate a Twitter account with the user's account
*
* Validates post input; verifies it against Twitter; and if
* successful stores in the database.
*
* @return void
*/
function addTwitterAccount()
{
$screen_name = $this->trimmed('twitter_username');
$password = $this->trimmed('twitter_password');
$noticesync = $this->boolean('noticesync');
$replysync = $this->boolean('replysync');
$friendsync = $this->boolean('friendsync');
if (!Validate::string($screen_name, array('min_length' => 1, 'max_length' => 15, 'format' => VALIDATE_NUM . VALIDATE_ALPHA . '_'))) {
$this->showForm(_('Username must have only numbers, ' . 'upper- and lowercase letters, ' . 'and underscore (_). 15 chars max.'));
return;
}
if (!$this->verifyCredentials($screen_name, $password)) {
$this->showForm(_('Could not verify your Twitter credentials!'));
return;
}
$twit_user = twitter_user_info($screen_name, $password);
if (!$twit_user) {
$this->showForm(sprintf(_('Unable to retrieve account information ' . 'For "%s" from Twitter.'), $screen_name));
return;
}
if (!save_twitter_user($twit_user->id, $screen_name)) {
$this->showForm(_('Unable to save your Twitter settings!'));
return;
}
$user = common_current_user();
$flink = new Foreign_link();
$flink->user_id = $user->id;
$flink->foreign_id = $twit_user->id;
$flink->service = TWITTER_SERVICE;
$flink->credentials = $password;
$flink->created = common_sql_now();
$flink->set_flags($noticesync, $replysync, $friendsync);
$flink_id = $flink->insert();
if (!$flink_id) {
common_log_db_error($flink, 'INSERT', __FILE__);
$this->showForm(_('Unable to save your Twitter settings!'));
return;
}
if ($friendsync) {
save_twitter_friends($user, $twit_user->id, $screen_name, $password);
}
$this->showForm(_('Twitter settings saved.'), true);
}