You are here

function flag_flag::validate_name in Flag 6

Same name and namespace in other branches
  1. 5 flag.inc \flag_flag::validate_name()
  2. 6.2 flag.inc \flag_flag::validate_name()
  3. 7.3 includes/flag/flag_flag.inc \flag_flag::validate_name()
  4. 7.2 flag.inc \flag_flag::validate_name()
1 call to flag_flag::validate_name()
flag_flag::validate in ./flag.inc
Validates a flag settings

File

./flag.inc, line 241
Implements various flags. Uses object oriented style inspired by that of Views 2.

Class

flag_flag
This abstract class represents a flag, or, in Views 2 terminology, "a handler".

Code

function validate_name() {

  // Ensure a safe machine name.
  if (!preg_match('/^[a-z_][a-z0-9_]*$/', $this->name)) {
    form_set_error('name', t('The flag name may only contain lowercase letters, underscores, and numbers.'));
  }

  // Ensure the machine name is unique.
  if (!isset($this->fid)) {
    $flag = flag_get_flag($this->name);
    if (!empty($flag)) {
      form_set_error('name', t('Flag names must be unique. This flag name is already in use.'));
    }
  }
}