You are here

function lti_tool_provider_consumers_admin in LTI Tool Provider 7

Generate the consumer admin form.

Return value

array The form array.

1 string reference to 'lti_tool_provider_consumers_admin'
lti_tool_provider_menu in ./lti_tool_provider.module
Implements hook_menu().

File

./lti_tool_provider.admin.inc, line 194
Admin forms for LTI Tool Provider module.

Code

function lti_tool_provider_consumers_admin() {
  $content = array();
  $content[] = array(
    '#type' => 'item',
    '#markup' => t('Administration page for LTI Tool Consumers.'),
  );
  $content[] = array(
    '#type' => 'item',
    '#markup' => l(t('Add a new LTI Tool Consumer'), 'lti_tool_provider_consumer/add'),
  );
  $content['table'] = array();

  // Load all of our entities.
  $consumers = lti_tool_provider_consumer_load_multiple();
  $content['consumer_table'] = array(
    '#theme' => 'table',
    '#rows' => array(),
    '#header' => array(
      t('ID'),
      t('Consumer'),
      t('Key'),
      t('Secret'),
      t('Domain'),
      t('Dummy Account'),
      t('Date Joined'),
      t('Operations'),
    ),
  );
  $destination = drupal_get_destination();
  $loop_counter = 0;
  foreach ($consumers as $key => $consumer) {

    // Create tabular rows for our entities.
    $id = $consumer->lti_tool_provider_consumer_id;

    // This statement can create url to view individual keys.
    $consumer_name = array(
      '#type' => 'link',
      '#title' => t('@consumer', array(
        '@consumer' => $consumer->lti_tool_provider_consumer_consumer,
      )),
      '#href' => 'lti_tool_provider_consumer/' . $consumer->lti_tool_provider_consumer_id . '/view',
      '#options' => array(
        'query' => $destination,
      ),
    );
    $key = $consumer->lti_tool_provider_consumer_key;
    $secret = $consumer->lti_tool_provider_consumer_secret;
    $domain = $consumer->lti_tool_provider_consumer_domain;
    $dummy_pref = lti_tool_provider_trans_bool($consumer->lti_tool_provider_consumer_dummy_pref);
    $date_joined = format_date($consumer->date_joined);

    // Build a list of all the operations for the current consumer.
    $operations = array(
      'edit' => array(
        '#type' => 'link',
        '#title' => t('edit'),
        '#href' => 'lti_tool_provider_consumer/' . $consumer->lti_tool_provider_consumer_id . '/edit',
        '#options' => array(
          'query' => $destination,
        ),
      ),
      'nbsp' => array(
        '#markup' => '  ',
      ),
      'delete' => array(
        '#type' => 'link',
        '#title' => t('delete'),
        '#href' => 'lti_tool_provider_consumer/' . $consumer->lti_tool_provider_consumer_id . '/delete',
        '#options' => array(
          'query' => $destination,
        ),
      ),
    );
    $content['consumer_table'][] = array(
      'id' => &$id,
      'Consumer' => &$consumer_name,
      'Key' => &$key,
      'Secret' => &$secret,
      'Domain' => &$domain,
      'Dummy_Pref' => &$dummy_pref,
      'Date Joined' => &$date_joined,
      'operations' => &$operations,
    );
    $content['consumer_table']['#rows'][] = array(
      array(
        'data' => &$id,
      ),
      array(
        'data' => &$consumer_name,
      ),
      array(
        'data' => &$key,
      ),
      array(
        'data' => &$secret,
      ),
      array(
        'data' => &$domain,
      ),
      array(
        'data' => &$dummy_pref,
      ),
      array(
        'data' => &$date_joined,
      ),
      array(
        'data' => &$operations,
      ),
    );
    unset($id);
    unset($consumer_name);
    unset($key);
    unset($secret);
    unset($domain);
    unset($dummy_pref);
    unset($date_joined);
    unset($operations);
  }
  $content['consumer_table']['#empty'] = t('No LTITP Consumer entities currently exist.');
  return $content;
}