function fb_app_edit_form_validate in Drupal for Facebook 6.3
Same name and namespace in other branches
- 6.2 fb_app.admin.inc \fb_app_edit_form_validate()
- 7.3 fb_app.admin.inc \fb_app_edit_form_validate()
Form validation.
File
- ./
fb_app.admin.inc, line 181
Code
function fb_app_edit_form_validate($form, &$form_state) {
$fb_app = (object) $form_state['values'];
$fb_app->data = serialize($fb_app->fb_app_data);
if ($form_state['values']['op'] != t('Delete')) {
// Labels must be alphanumeric.
if (preg_match('/[^a-z0-9_]/', $fb_app->label)) {
form_error($form['label'], t('Label must be lower-case alphanumeric or underscores only.'));
}
// Labels must be unique.
$apps = fb_get_all_apps();
foreach ($apps as $app) {
if ($app->label == $fb_app->label && (!isset($form['#fb_app']) || $form['#fb_app']->label != $fb_app->label)) {
form_set_error('fb_app][label', t('The label %label is in use by another application.', array(
'%label' => $fb_app->label,
)));
}
}
// Getting properties confirms apikey and secret.
fb_admin_get_app_info($fb_app);
if (!$fb_app->name) {
// Don't use form_set_error(), as that will prevent the user from saving any data.
drupal_set_message(t("Unable to get application properties. Possibly, you've given the wrong id or secret. Possibly, this server is unable to reach facebook's servers. Your application will not work properly!"), 'error');
$fb_app->name = 'UNKOWN';
}
}
}