function fb_admin_app_select_form_validate in Drupal for Facebook 7.4
1 string reference to 'fb_admin_app_select_form_validate'
- fb_admin_app_select_form in ./fb.admin.inc
File
- ./fb.admin.inc, line 1329
Code
function fb_admin_app_select_form_validate($form, &$form_state) {
extract($form_state['fb']);
$values = $form_state['values'];
if (!empty($values['client_id']) && !empty($values['client_id_new'])) {
form_error($form['application']['client_id_new'], t('Select either a local application radio button or paste a remote application ID. Not both.'));
return;
}
$token = NULL;
if (!empty($values['client_id_new'])) {
list($id, $secret, $token) = _fb_admin_parse_textfield($token);
$client_id = $id;
$key = 'client_id_new';
if ($secret) {
form_set_error($key, t('Use add application form to paste ID and secret.'));
return;
}
}
else {
$client_id = $values['client_id'];
$key = 'client_id';
}
if (empty($graph[$client_id])) {
try {
$gdata = fb_graph($client_id, $token);
} catch (exception $e) {
fb_log_exception($e, t('Failed to look up application %id.', array(
'%id' => $client_id,
)));
$gdata = NULL;
}
}
else {
$gdata = $graph[$client_id];
}
if (empty($gdata) || empty($gdata['id'])) {
form_set_error($key, t('Failed to look up application id %id.', array(
'%id' => $client_id,
)));
}
else {
form_set_value($form['fb_app_data'], array(
'client_id' => $gdata['id'],
'name' => $gdata['name'],
'namespace' => !empty($gdata['namespace']) ? $gdata['namespace'] : NULL,
), $form_state);
}
}