function oauth_common_form_consumer_submit in OAuth 1.0 6.3
Same name and namespace in other branches
- 7.4 oauth_common.consumers.inc \oauth_common_form_consumer_submit()
- 7.3 oauth_common.consumers.inc \oauth_common_form_consumer_submit()
Submit handler for oauth_common_form_consumer.
File
- ./
oauth_common.consumers.inc, line 169
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';
}
else {
if ($values['callback_url'] != 'oob' && preg_match('/^http:\\/\\/|https:\\/\\//', $values['callback_url']) === 0) {
//TODO: What about custom callback url:s used by eg iphone-apps? We should allow them - right?
$values['callback_url'] = 'http://' . $values['callback_url'];
}
}
// 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));
}