function admin_edit_group_form_validate

7.x admin.groups.inc admin_edit_group_form_validate(&$form, &$form_state)
6.x admin.groups.inc admin_edit_group_form_validate(&$form, &$form_state)
5.x admin.groups.inc admin_edit_group_form_validate(&$form, &$form_state)

Validate handler for edit group form.

File

modules/admin/admin.groups.inc, line 10

Code

function admin_edit_group_form_validate(&$form, &$form_state) {
  $values = $form_state ["values"];
  $group_name = trim($values ["group_name"]);
  $group_id = $values ["group_id"];
  $de_catalog_year = $values ["de_catalog_year"];


  // We want to make sure the group_name is in a machine-name format,
  // and we need to make sure it is unique for this catalog year!
  $group_name = fp_get_machine_readable(strtolower($group_name));

  $form_state ['values']['group_name'] = $group_name;


  // Check that group_name is unique (but exclude the current group_id from the check)
  $mycount = db_query("SELECT count(*) as mycount FROM draft_groups 
                       WHERE group_name = ?
                       AND group_id != ?
                       AND delete_flag = '0'
                       AND catalog_year = ?", $group_name, $group_id, $de_catalog_year)->fetchColumn();

  if ($mycount > 0) {
    form_error("group_name", t("The 'Internal group machine name' %gn is already in use in FlightPath by another group
                                in the catalog year %cy.  
                                Please change to a different name, and submit again. <b>Your work has NOT been saved.</b>
                                ", array("%gn" => $group_name, "%cy" => $de_catalog_year)));
    return;
  }


}