You are here

function tft_add_term_form_validate in Taxonomy File Tree 7.2

Same name and namespace in other branches
  1. 7 tft.admin.inc \tft_add_term_form_validate()

Validation callback: for tft_add_term_form().

Check for forbidden characters in the 'folder' name.

File

includes/tft.pages.inc, line 146
Defines all page callbacks for TFT.

Code

function tft_add_term_form_validate($form, &$form_state) {

  // If the user can only add terms to an OG term
  // @todo OG logic !!
  if (!user_access(TFT_PERM__ADD_TERMS)) {
    if (!tft_term_access($form_state['values']['parent'])) {
      form_set_error('name');
      drupal_set_message(t("You must select a parent folder that is part of a group you're a member of."), 'error');
      if ($_GET['destination']) {
        drupal_goto(urldecode($_GET['destination']));
      }
      else {
        drupal_goto();
      }
      exit;
    }
  }

  // Check for forbidden characters
  if (strpos($form_state['values']['name'], ',') !== FALSE || strpos($form_state['values']['name'], '+') !== FALSE) {
    form_set_error('name', t("The following characters are not allowed: ',' (comma) and +"));
  }
}