Esempio n. 1
0
function save_twitter_user($twitter_id, $screen_name)
{
    // Check to see whether the Twitter user is already in the system,
    // and update its screen name and uri if so.
    try {
        $fuser = Foreign_user::getForeignUser($twitter_id, TWITTER_SERVICE);
        // Delete old record if Twitter user changed screen name
        if ($fuser->nickname != $screen_name) {
            $oldname = $fuser->nickname;
            $fuser->delete();
            common_log(LOG_INFO, sprintf('Twitter bridge - Updated nickname (and URI) ' . 'for Twitter user %1$d - %2$s, was %3$s.', $fuser->id, $screen_name, $oldname));
        }
    } catch (NoResultException $e) {
        // No old users exist for this id
        // Kill any old, invalid records for this screen name
        // XXX: Is this really only supposed to be run if the above getForeignUser fails?
        try {
            $fuser = Foreign_user::getByNickname($screen_name, TWITTER_SERVICE);
            $fuser->delete();
            common_log(LOG_INFO, sprintf('Twitter bridge - deteted old record for Twitter ' . 'screen name "%s" belonging to Twitter ID %d.', $screen_name, $fuser->id));
        } catch (NoResultException $e) {
            // No old users exist for this screen_name
        }
    }
    return add_twitter_user($twitter_id, $screen_name);
}
function save_twitter_user($twitter_id, $screen_name)
{
    // Check to see whether the Twitter user is already in the system,
    // and update its screen name and uri if so.
    $fuser = Foreign_user::getForeignUser($twitter_id, TWITTER_SERVICE);
    if (!empty($fuser)) {
        $result = true;
        // Delete old record if Twitter user changed screen name
        if ($fuser->nickname != $screen_name) {
            $oldname = $fuser->nickname;
            $fuser->delete();
            common_log(LOG_INFO, sprintf('Twitter bridge - Updated nickname (and URI) ' . 'for Twitter user %1$d - %2$s, was %3$s.', $fuser->id, $screen_name, $oldname));
        }
    }
    return add_twitter_user($twitter_id, $screen_name);
}
Esempio n. 3
0
function save_twitter_user($twitter_id, $screen_name)
{
    // Check to see whether the Twitter user is already in the system,
    // and update its screen name and uri if so.
    $fuser = Foreign_user::getForeignUser($twitter_id, TWITTER_SERVICE);
    if (!empty($fuser)) {
        // Delete old record if Twitter user changed screen name
        if ($fuser->nickname != $screen_name) {
            $oldname = $fuser->nickname;
            $fuser->delete();
            common_log(LOG_INFO, sprintf('Twitter bridge - Updated nickname (and URI) ' . 'for Twitter user %1$d - %2$s, was %3$s.', $fuser->id, $screen_name, $oldname));
        }
    } else {
        // Kill any old, invalid records for this screen name
        $fuser = Foreign_user::getByNickname($screen_name, TWITTER_SERVICE);
        if (!empty($fuser)) {
            $fuser->delete();
            common_log(LOG_INFO, sprintf('Twitter bridge - deteted old record for Twitter ' . 'screen name "%s" belonging to Twitter ID %d.', $screen_name, $fuser->id));
        }
    }
    return add_twitter_user($twitter_id, $screen_name);
}
Esempio n. 4
0
function save_twitter_user($twitter_id, $screen_name)
{
    // Check to see whether the Twitter user is already in the system,
    // and update its screen name and uri if so.
    $fuser = Foreign_user::getForeignUser($twitter_id, 1);
    if ($fuser) {
        // Only update if Twitter screen name has changed
        if ($fuser->nickname != $screen_name) {
            common_debug('Twitter bridge - Updated nickname (and URI) for Twitter user ' . "{$fuser->id} to {$screen_name}, was {$fuser->nickname}");
            return update_twitter_user($fuser, $twitter_id, $screen_name);
        }
    } else {
        return add_twitter_user($twitter_id, $screen_name);
    }
    return true;
}