function oauth_common_form_consumer_submit in OAuth 1.0 7.3
Same name and namespace in other branches
- 6.3 oauth_common.consumers.inc \oauth_common_form_consumer_submit()
- 7.4 oauth_common.consumers.inc \oauth_common_form_consumer_submit()
Submit handler for oauth_common_form_consumer.
File
- ./
oauth_common.consumers.inc, line 198
Code
function oauth_common_form_consumer_submit($form, &$form_state) {
$values = $form_state['values'];
$consumer = $values['consumer_object'];
// Translate empty callback url to oob (out of band).
if (empty($values['callback_url'])) {
$values['callback_url'] = 'oob';
}
if (substr($values['callback_url'], strlen($values['callback_url']) - 2) != '//') {
// Remove trailing slash
$values['callback_url'] = rtrim($values['callback_url'], '/');
}
// Transfer editable attributes to the consumer.
$names = array(
'name',
'callback_url',
'context',
);
foreach ($names as $name) {
if (isset($values[$name])) {
$consumer->{$name} = $values[$name];
}
}
// Update or create the consumer.
$update = $consumer->in_database;
$consumer
->write();
if ($update) {
drupal_set_message(t('Updated the consumer @name', array(
'@name' => $values['name'],
)));
}
else {
drupal_set_message(t('Added the consumer @name', array(
'@name' => $values['name'],
)));
}
drupal_goto(sprintf('user/%d/oauth/consumers', $consumer->uid));
}