You are here

function oauth_common_page_user_consumers in OAuth 1.0 6.3

Same name and namespace in other branches
  1. 7.4 oauth_common.consumers.inc \oauth_common_page_user_consumers()
  2. 7.3 oauth_common.consumers.inc \oauth_common_page_user_consumers()

Menu system callback for listing a users consumers.

Parameters

object $account:

1 string reference to 'oauth_common_page_user_consumers'
oauth_common_providerui_menu in ./oauth_common_providerui.module
Implementation of hook_menu().

File

./oauth_common.consumers.inc, line 8

Code

function oauth_common_page_user_consumers($account) {
  module_load_include('inc', 'oauth_common');
  $ci = oauth_common_user_consumers($account->uid);
  $header = array(
    array(
      'data' => t('Name'),
      'class' => 'oauth-common-consumer-name',
    ),
    array(
      'data' => t('Key'),
      'class' => 'oauth-common-consumer-key',
    ),
    array(
      'data' => t('Created'),
      'class' => 'oauth-common-consumer-created',
    ),
    array(
      'data' => t('Operations'),
      'class' => 'oauth-common-consumer-operations',
    ),
  );
  $rows = array();
  foreach ($ci as $consumer) {
    $data = array(
      'name' => array(
        'data' => $consumer->name,
        'class' => 'oauth-common-consumer-name',
      ),
      'key' => array(
        'data' => substr($consumer->key, 0, 6) . '...',
        'class' => 'oauth-common-consumer-key',
      ),
      'created' => array(
        'data' => format_date($consumer->created),
        'class' => 'oauth-common-consumer-created',
      ),
    );
    $operations = array();
    if (oauth_common_can_edit_consumer($consumer)) {
      $operations[] = array(
        'title' => t('Edit'),
        'href' => sprintf('user/%d/oauth/consumer/%s', $account->uid, $consumer->csid),
      );
      $operations[] = array(
        'title' => t('Delete'),
        'href' => sprintf('user/%d/oauth/consumer/%s', $account->uid, $consumer->csid) . '/delete',
      );
    }
    $rows[] = array(
      'data' => $data + array(
        'operations' => array(
          'data' => theme('links', $operations),
          'class' => 'oauth-common-consumer-operations',
        ),
      ),
      'class' => 'oauth-common-consumer',
    );
  }
  $table = theme('table', $header, $rows, array(
    'id' => 'oauth-common-list-consumers',
  ));
  return $table;
}