You are here

function tweet_feed_accounts_table in Tweet Feed 7.2

Same name and namespace in other branches
  1. 7.3 tweet_feed_admin.inc \tweet_feed_accounts_table()

Accounts Table

A table to list the Twitter accounts associated with this install that can be used to bring in feeds to the database.

1 string reference to 'tweet_feed_accounts_table'
tweet_feed_menu in ./tweet_feed.module
Implements hook_menu().

File

./tweet_feed_admin.inc, line 9

Code

function tweet_feed_accounts_table() {

  // Set up the right breadcrumbs
  $breadcrumbs = array();
  $breadcrumbs[] = l('Home', '<front>');
  $breadcrumbs[] = l('Administration', 'admin');
  $breadcrumbs[] = l('Configuration', 'admin/config');
  $breadcrumbs[] = l('Web Services', 'admin/config/services');
  $breadcrumbs[] = l('Tweet Feed Accounts', 'admin/config/services/tweet_feed/accounts');
  drupal_set_breadcrumb($breadcrumbs);
  $rows = array();
  $header = array(
    'account_name' => array(
      'data' => t('Account name'),
      'style' => 'text-align: center;',
    ),
    'uses' => array(
      'data' => t('# Uses'),
      'style' => 'text-align: center;',
    ),
    'consumer_key' => array(
      'data' => t('Consumer Key'),
      'style' => 'text-align: center;',
    ),
    'oauth_token' => array(
      'data' => t('Oauth Token'),
      'style' => 'text-align: center;',
    ),
    'edit' => array(
      'data' => t('Edit'),
      'style' => 'text-align: center;',
    ),
    'delete' => array(
      'data' => t('Delete'),
      'style' => 'text-align: center;',
    ),
  );
  $result = db_select('tweet_accounts', 'a')
    ->fields('a')
    ->orderBy('account_name', 'ASC')
    ->execute();
  while ($data = $result
    ->fetchObject()) {

    // Determine how many queries this feed is responsible for
    $cresult = db_select('tweet_feeds', 'f')
      ->fields('f')
      ->condition('f.aid', $data->aid)
      ->execute();
    $count = $cresult
      ->rowCount();
    $row = array();
    $row[] = $data->account_name;
    $row[] = array(
      'data' => $count,
      'align' => 'center',
    );
    $row[] = array(
      'data' => $data->consumer_key,
      'align' => 'center',
    );
    $row[] = array(
      'data' => $data->oauth_token,
      'align' => 'center',
    );
    $row[] = array(
      'data' => l(t('Edit'), 'admin/config/services/tweet_feed/accounts/edit/' . $data->aid),
      'align' => 'center',
    );
    $row[] = array(
      'data' => l(t('Delete'), 'admin/config/services/tweet_feed/accounts/delete/' . $data->aid),
      'align' => 'center',
    );
    $rows[] = $row;
  }
  if (count($rows) == 0) {
    $rows = array(
      array(
        'data' => array(
          array(
            'align' => 'center',
            'colspan' => 6,
            'data' => t('THERE ARE CURRENTLY NO CONFIGURED TWITTER ACCOUNTS.'),
          ),
        ),
      ),
    );
  }
  $output = theme('table', array(
    'header' => $header,
    'rows' => $rows,
  ));
  return $output;
}