Example #1
0
 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!');
     }
 }
 function handle($args)
 {
     parent::handle($args);
     $this->error = $error;
     if ($this->flink) {
         if (!$this->facebook->api_client->users_hasAppPermission('publish_stream') && $this->facebook->api_client->data_getUserPreference(FACEBOOK_PROMPTED_UPDATE_PREF) == 'true') {
             echo '<h1>REDIRECT TO HOME</h1>';
         }
     } else {
         $this->showPage();
     }
 }
Example #3
0
 function handle($args)
 {
     parent::handle($args);
     // If the user has opted not to initially allow the app to have
     // Facebook status update permission, store that preference. Only
     // promt the user the first time she uses the app
     if ($this->arg('skip') || $args['fb_sig_request_method'] == 'GET') {
         $this->facebook->api_client->data_setUserPreference(FACEBOOK_PROMPTED_UPDATE_PREF, 'true');
     }
     if ($this->flink) {
         $this->user = $this->flink->getUser();
         // If this is the first time the user has started the app
         // prompt for Facebook status update permission
         if (!$this->facebook->api_client->users_hasAppPermission('publish_stream')) {
             if ($this->facebook->api_client->data_getUserPreference(FACEBOOK_PROMPTED_UPDATE_PREF) != 'true') {
                 $this->getUpdatePermission();
                 return;
             }
         }
         // Make sure the user's profile box has the lastest notice
         $notice = $this->user->getCurrentNotice();
         if ($notice) {
             $this->updateProfileBox($notice);
         }
         if ($this->arg('status_submit') == 'Send') {
             $this->saveNewNotice();
         }
         // User is authenticated and has already been prompted once for
         // Facebook status update permission? Then show the main page
         // of the app
         $this->showPage();
     } else {
         // User hasn't authenticated yet, prompt for creds
         $this->login();
     }
 }
Example #4
0
 function handle($args)
 {
     parent::handle($args);
     $this->showPage();
 }
 function handle($args)
 {
     parent::handle($args);
     $this->showForm();
 }
Example #6
0
function updateProfileBox($facebook, $flink, $notice, $user)
{
    $facebook = getFacebook();
    $fbaction = new FacebookAction($output = 'php://output', $indent = null, $facebook, $flink);
    $fbuid = $flink->foreign_id;
    common_debug('FacebookPlugin - Attempting to update profile box with ' . "content from notice {$notice->id} for {$user->nickname} ({$user->id}), " . "Facebook UID: {$fbuid}");
    $fbaction->updateProfileBox($notice);
    common_debug('FacebookPlugin - finished updating profile box for ' . "{$user->nickname} ({$user->id}) Facebook UID: {$fbuid}");
}
function updateProfileBox($facebook, $flink, $notice)
{
    $fbaction = new FacebookAction($output = 'php://output', $indent = null, $facebook, $flink);
    $fbaction->updateProfileBox($notice);
}