You are here

function oauth_common_list_context in OAuth 1.0 6.3

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

Output a list of contexts.

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

File

./oauth_common.admin.inc, line 36

Code

function oauth_common_list_context($js = NULL) {
  $header = array(
    array(
      'data' => t('Title'),
      'class' => 'oauth-common-contexts-title',
    ),
    array(
      'data' => t('Storage'),
      'class' => 'oauth-common-contexts-storage',
    ),
    array(
      'data' => t('Operations'),
      'class' => 'oauth-common-contexts-operations',
    ),
  );
  $contexts = oauth_common_context_load_all();
  $rows = array();
  if (!$contexts) {
    $contexts = array();
  }
  foreach ($contexts as $context) {
    $operations = array();
    if (empty($context->disabled)) {
      $operations[] = array(
        'title' => t('Edit'),
        'href' => 'admin/settings/oauth/' . $context->name . '/edit',
      );
      $operations[] = array(
        'title' => t('Export'),
        'href' => 'admin/settings/oauth/' . $context->name . '/export',
      );
    }
    if ($context->export_type == (EXPORT_IN_CODE | EXPORT_IN_DATABASE)) {
      $operations[] = array(
        'title' => t('Revert'),
        'href' => 'admin/settings/oauth/' . $context->name . '/delete',
      );
    }
    elseif ($context->export_type != EXPORT_IN_CODE) {
      $operations[] = array(
        'title' => t('Delete'),
        'href' => 'admin/settings/oauth/' . $context->name . '/delete',
      );
    }
    elseif (empty($context->disabled)) {
      $operations[] = array(
        'title' => t('Disable'),
        'href' => 'admin/settings/oauth/' . $context->name . '/disable',
        'query' => drupal_get_destination(),
      );
    }
    else {
      $operations[] = array(
        'title' => t('Enable'),
        'href' => 'admin/settings/oauth/' . $context->name . '/enable',
        'query' => drupal_get_destination(),
      );
    }
    $rows[$context->name] = array(
      'data' => array(
        'title' => array(
          'data' => check_plain($context->title),
          'class' => 'oauth-common-contexts-title',
        ),
        'storage' => array(
          'data' => $context->export_type == EXPORT_IN_CODE ? t('In code') : t('In database'),
          'class' => 'oauth-common-contexts-storage',
        ),
        'operations' => array(
          'data' => theme('links', $operations),
          'class' => 'oauth-common-contexts-operations',
        ),
      ),
      'class' => 'oauth-common-contexts-' . $context->name . (!empty($context->disabled) ? ' oauth-common-contexts-disabled' : ''),
    );
  }
  $table = theme('table', $header, $rows, array(
    'id' => 'oauth-common-list-contexts',
  ));
  return $table;
}