You are here

function flag_lists_template_validate in Flag Lists 6

Same name and namespace in other branches
  1. 7.3 flag_lists.module \flag_lists_template_validate()
  2. 7 flag_lists.module \flag_lists_template_validate()
1 string reference to 'flag_lists_template_validate'
flag_lists_form_alter in ./flag_lists.module
Implementation of hook_form_alter().

File

./flag_lists.module, line 284
The Flag Lists module.

Code

function flag_lists_template_validate($form, &$form_state) {
  $types = array_filter($form_state['values']['types']);
  $errors = array();
  foreach ($types as $type) {
    if ($result = db_query("SELECT * FROM {flag_lists_types} WHERE type = '%s' AND name <> '%s'", $type, $form_state['values']['name'])) {
      while ($errors = db_fetch_array($result)) {
        $content_types[] = $errors['type'];
        $templates[] = $errors['name'];
      }
    }
  }
  if (count($content_types)) {
    $content_types = implode(', ', $content_types);
    $templates = implode(', ', array_unique($templates));
    form_set_error('types', t('The flaggable content type(s) "@type" is(are) already assigned to the template(s) "@template." A content type may be assigned to only one template. To reassign a content type you must first remove its other assignment.', array(
      '@type' => $content_types,
      '@template' => $templates,
    )));
  }
}