function oauth_common_form_consumer in OAuth 1.0 6.3
Same name and namespace in other branches
- 7.4 oauth_common.consumers.inc \oauth_common_form_consumer()
- 7.3 oauth_common.consumers.inc \oauth_common_form_consumer()
The consumer form that is shared by the add and edit page.
2 string references to 'oauth_common_form_consumer'
- oauth_common_add_consumer in ./
oauth_common.consumers.inc - Menu system callback for the add consumer page.
- oauth_common_edit_consumer in ./
oauth_common.consumers.inc - Menu system callback for the edit consumer page.
File
- ./
oauth_common.consumers.inc, line 86
Code
function oauth_common_form_consumer(&$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'),
'#value' => 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'),
'#value' => $consumer->key,
);
$form['secret'] = array(
'#type' => 'item',
'#prefix' => '<div id="consumer-secret-wrapper">',
'#title' => t('Secret'),
'#value' => substr($consumer->secret, 0, 6) . '...',
);
$form['show_secret'] = array(
'#type' => 'button',
'#value' => t('Show secret'),
'#ahah' => array(
'path' => "user/{$consumer->uid}/oauth/consumer/{$consumer->csid}/ahah/secret",
'wrapper' => 'consumer-secret-wrapper',
'method' => 'replace',
),
'#suffix' => '</div>',
);
}
$form['submit'] = array(
'#type' => 'submit',
'#value' => t('Save'),
);
return $form;
}