You are here

function fb_app_edit_form_validate in Drupal for Facebook 6.2

Same name and namespace in other branches
  1. 6.3 fb_app.admin.inc \fb_app_edit_form_validate()
  2. 7.3 fb_app.admin.inc \fb_app_edit_form_validate()

Form validation.

File

./fb_app.admin.inc, line 169

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 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_properties($fb_app);
    if (!$fb_app->application_name) {
      form_set_error('fb_app][apikey', t('Unable to get application properties.  Confirm both apikey and secret.'));
    }
  }
}