You are here

function dropbox_client_block_view in Dropbox Client 7.2

Same name and namespace in other branches
  1. 7.4 dropbox_client.module \dropbox_client_block_view()
  2. 7 dropbox_client.module \dropbox_client_block_view()
  3. 7.3 dropbox_client.module \dropbox_client_block_view()

Return a rendered or renderable view of a block.

Parameters

$delta: Which block to render. This is a unique identifier for the block within the module, defined in hook_block_info().

Return value

An array containing the following elements:

  • subject: The default localized title of the block. If the block does not have a default title, this should be set to NULL.
  • content: The content of the block's body. This may be a renderable array (preferable) or a string containing rendered HTML content.

File

./dropbox_client.module, line 260

Code

function dropbox_client_block_view($delta = '') {
  global $user;
  $block = '';
  switch ($delta) {
    case 'dropbox_files':
      $block['subject'] = t('');
      $dpath = isset($_GET['dpath']) ? $_GET['dpath'] : '/';
      $links = '<div class="documents-controls"><div class="documents-top">top</div><div class="documents-bottom">bottom</div></div>';
      if ($user->uid && variable_get('dropbox_client_account_type', 0) == 2 && isset($user->data['dropbox']['token_secret'])) {
        $block['content'] = dropbox_client_metadata($dpath) . $links . l('Link Dropbox to Website with another account', 'dropbox_client/install') . '</span>';
      }
      elseif (variable_get('dropbox_client_account_type', 0) == 1 && is_string(variable_get('dropbox_client_website_oauth_token', 0))) {
        $block['content'] = dropbox_client_metadata($dpath) . $links;
      }
      elseif (variable_get('dropbox_client_account_type', 0) == 2) {
        $block['content'] = l('Click here to add drop box folder', 'dropbox_client/install');
      }
      break;
    case 'dropbox_upload':
      $block['subject'] = t('documents');
      if ($user->uid && variable_get('dropbox_client_account_type', 0) == 2 && isset($user->data['dropbox']['token_secret'])) {
        $block['content'] = drupal_get_form('dropbox_client_upload_form');
      }
      elseif (variable_get('dropbox_client_account_type', 0) == 1 && is_string(variable_get('dropbox_client_website_oauth_token', 0))) {
        $block['content'] = drupal_get_form('dropbox_client_upload_form');
      }
      break;
    case 'dropbox_search':
      $block['subject'] = t('search');
      if ($user->uid && variable_get('dropbox_client_account_type', 0) == 2 && isset($user->data['dropbox']['token_secret'])) {
        if (isset($_SESSION['dropbox_client_results'])) {
          $block['content'] = dropbox_client_search_results();
        }
        else {
          $block['content'] = drupal_get_form('dropbox_client_search_form');
        }
      }
      elseif (variable_get('dropbox_client_account_type', 0) == 1 && is_string(variable_get('dropbox_client_website_oauth_token', 0))) {
        if (isset($_SESSION['dropbox_client_results'])) {
          $block['content'] = dropbox_client_search_results();
        }
        else {
          $block['content'] = drupal_get_form('dropbox_client_search_form');
        }
      }
      break;
  }
  return $block;
}