uid); $header = array( array('data' => t('Name'), 'class' => array('oauth-common-consumer-name')), array('data' => t('Key'), 'class' => array('oauth-common-consumer-key')), array('data' => t('Created'), 'class' => array('oauth-common-consumer-created')), array('data' => t('Operations'), 'class' => array('oauth-common-consumer-operations')), ); $rows = array(); foreach ($ci as $consumer) { $data = array( 'name' => array( 'data' => $consumer->name, 'class' => array('oauth-common-consumer-name'), ), 'key' => array( 'data' => substr($consumer->key, 0, 6) . '...', 'class' => array('oauth-common-consumer-key'), ), 'created' => array( 'data' => format_date($consumer->created), 'class' => array('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', array('links' => $operations)), 'class' => array('oauth-common-consumer-operations'), ), ), 'class' => array('oauth-common-consumer'), ); } $table = theme('table', array( 'header' => $header, 'rows' => $rows, 'attributes' => array('id' => 'oauth-common-list-consumers') )); return $table; } /** * Menu system callback for the add consumer page. */ function oauth_common_add_consumer($account) { $consumer = new DrupalOAuthConsumer(user_password(32), user_password(32), array( 'callback_url' => '', 'uid' => $account->uid, 'provider_consumer' => TRUE, )); return drupal_get_form('oauth_common_form_consumer', $consumer); } /** * Menu system callback for the edit consumer page. */ function oauth_common_edit_consumer($consumer) { return drupal_get_form('oauth_common_form_consumer', $consumer); } /** * The consumer form that is shared by the add and edit page. */ function oauth_common_form_consumer($form, &$form_state, $consumer) { $form = array(); $form['consumer_object'] = array( '#type' => 'value', '#value' => $consumer, ); $form['name'] = array( '#type' => 'textfield', '#title' => t('Consumer name'), '#required' => TRUE, '#default_value' => $consumer->name, ); $form['callback_url'] = array( '#type' => 'textfield', '#title' => t('Callback url'), '#required' => FALSE, '#default_value' => $consumer->callback_url, ); if ($consumer->in_database) { $contexts = oauth_common_context_list(); $form['context'] = array( '#type' => 'item', '#title' => t('Application context'), '#markup' => isset($contexts[$consumer->context]) ? $contexts[$consumer->context] : $consumer->context, ); } else { $allowed_contexts = array(); foreach (oauth_common_context_list() as $context => $title) { if (user_access(sprintf('oauth register consumers in %s', $context))) { $allowed_contexts[$context] = $title; } } $form['context'] = array( '#type' => 'select', '#title' => t('Application context'), '#options' => $allowed_contexts, '#default_value' => $consumer->context, ); } if ($consumer->in_database) { $form['key'] = array( '#type' => 'item', '#title' => t('Key'), '#markup' => $consumer->key, ); $form['secret'] = array( '#type' => 'item', '#prefix' => '