You are here

function socialfeed_settings_form_validate in Social Feed 6

Implements form_validate().

File

./socialfeed.module, line 204
Module for fetching data from Facebook, Twitter, Youtube, and Foursquare. This module provides block content retrieved from a

Code

function socialfeed_settings_form_validate(&$form, &$form_state) {

  // We make sure the title is a number or a letter.
  if (!ctype_alnum($form_state['values']['socialfeed_title'])) {
    form_set_error('socialfeed_title', t('You can only enter letters or numbers in the title.'));
  }

  // We make sure the display count is a number greater than zero.
  if (!is_numeric($form_state['values']['socialfeed_displaycount'])) {
    form_set_error('socialfeed_displaycount', t('You must enter a number for the count.'));
  }
  elseif ($form_state['values']['socialfeed_displaycount'] < 1) {
    form_set_error('socialfeed_displaycount', t('The count must be greater than zero.'));
  }

  // Make sure the Facebook title is a number or a letter if it is declared.
  if ($form_state['values']['socialfeed_facebook_title'] != '') {
    if (!ctype_alnum($form_state['values']['socialfeed_facebook_title'])) {
      form_set_error('socialfeed_facebook_title', t('You can only enter letters or numbers in the custom Facebook title.'));
    }
  }

  // Make sure the Facebook profile ID is a number if it is declared.
  if ($form_state['values']['socialfeed_facebook_profile_id'] != '') {
    if (!is_numeric($form_state['values']['socialfeed_facebook_profile_id'])) {
      form_set_error('socialfeed_facebook_profile_id', t('You must enter a number for the profile ID.'));
    }
  }

  // We make sure the Facebook App ID is a number but only if it is declared.
  if ($form_state['values']['socialfeed_facebook_app_id'] != '') {
    if (!is_numeric($form_state['values']['socialfeed_facebook_app_id'])) {
      form_set_error('socialfeed_facebook_app_id', t('You must enter a number for the app id.'));
    }
  }

  // Make sure the App Secret is a number or a letter if it is declared.
  if ($form_state['values']['socialfeed_facebook_app_secret'] != '') {
    if (!ctype_alnum($form_state['values']['socialfeed_facebook_app_secret'])) {
      form_set_error('socialfeed_facebook_app_secret', t('You must enter an alphanumeric string for the app secret.'));
    }
  }

  // Make sure the custom Twitter title is a number or a letter if its declared.
  if ($form_state['values']['socialfeed_twitter_title'] != '') {
    if (!ctype_alnum($form_state['values']['socialfeed_twitter_title'])) {
      form_set_error('socialfeed_twitter_title', t('You can only enter letters or numbers in the custom Twitter title.'));
    }
  }

  // Make sure the Twitter Profile ID is a number or a letter if its declared.
  if ($form_state['values']['socialfeed_twitter_profile_id'] != '') {
    if (!ctype_alnum($form_state['values']['socialfeed_twitter_profile_id'])) {
      form_set_error('socialfeed_twitter_profile_id', t('You can only enter letters or numbers in the Twitter Profile ID.'));
    }
  }

  // Make sure the Youtube title is a number or a letter if its declared.
  if ($form_state['values']['socialfeed_youtube_title'] != '') {
    if (!ctype_alnum($form_state['values']['socialfeed_youtube_title'])) {
      form_set_error('socialfeed_youtube_title', t('You can only enter letters or numbers in the custom Youtube title.'));
    }
  }

  // Make sure the Youtube Name is a number or a letter if its declared.
  if ($form_state['values']['socialfeed_youtube_profile_name'] != '') {
    if (!ctype_alnum($form_state['values']['socialfeed_youtube_profile_name'])) {
      form_set_error('socialfeed_youtube_profile_name', t('You can only enter letters or numbers in the custom Youtube Profile Name.'));
    }
  }

  // Make sure the Foursquare title is a number or a letter if its declared.
  if ($form_state['values']['socialfeed_foursquare_title'] != '') {
    if (!ctype_alnum($form_state['values']['socialfeed_foursquare_title'])) {
      form_set_error('socialfeed_foursquare_title', t('You can only enter letters or numbers in the custom Foursquare title.'));
    }
  }

  // Make sure the Foursquare Access Token is a number if its declared.
  if ($form_state['values']['socialfeed_foursquare_access_token'] != '') {
    if (!ctype_alnum($form_state['values']['socialfeed_foursquare_access_token'])) {
      form_set_error('socialfeed_foursquare_access_token', t('You must enter an alphanumeric string for the access token.'));
    }
  }
}