You are here

function dropbox_client_sucess in Dropbox Client 7.2

Same name and namespace in other branches
  1. 7 dropbox_client.module \dropbox_client_sucess()
1 string reference to 'dropbox_client_sucess'
dropbox_client_menu in ./dropbox_client.module
Implements hook_menu().

File

./dropbox_client.module, line 116

Code

function dropbox_client_sucess() {
  global $user;
  module_load_include('php', 'dropbox_client', 'oauth');
  module_load_include('php', 'dropbox_client', 'dropbox');

  //Credential for App Dropbox Client For Drupal
  $params['key'] = D4D_KEY;
  $params['secret'] = D4D_SECRECT;
  $params['access'] = array(
    'oauth_token' => urlencode($_SESSION['oauth_token']),
    'oauth_token_secret' => urlencode($_SESSION['oauth_token_secret']),
  );
  $dropbox = new dropbox($params);
  $dbobj = $dropbox
    ->account();

  #$metadata = $dropbox->metadata('/');
  if (is_object($dbobj) and property_exists($dbobj, 'uid') and is_numeric($dbobj->uid)) {
    $_SESSION['dropbox_client_installed'] = TRUE;
    if (variable_get('dropbox_client_account_type', 0) == 1) {
      variable_set('dropbox_client_website_token_secret', $_SESSION['dropbox_client_token_secret']);
      variable_set('dropbox_client_website_oauth_token', $_SESSION['oauth_token']);
      variable_set('dropbox_client_website_oauth_token_secret', $_SESSION['oauth_token_secret']);
      drupal_goto('admin/dropbox_client/settings');
    }
    else {
      if (variable_get('dropbox_client_account_type', 0) == 2) {
        $dropbox_client = array(
          'token_secret' => $_SESSION['dropbox_client_token_secret'],
          'oauth_token' => $_SESSION['oauth_token'],
          'oauth_token_secret' => $_SESSION['oauth_token_secret'],
        );
        if (is_array($user->data)) {
          $user->data = array_merge($user->data, array(
            'dropbox' => $dropbox_client,
          ));
          user_save($user);
        }
        else {
          $user->data = array(
            'dropbox' => $dropbox_client,
          );
          user_save($user);
        }
        return "Dropbox Client For Drupal installed Successfully";
      }
    }
  }
  else {
    return "Error: Dropbox Client For Drupal can't be installed";
  }
}