You are here

function patterns_utils_if_invalid_go_back in Patterns 7.2

Same name and namespace in other branches
  1. 7 includes/ \patterns_utils_if_invalid_go_back()

Checks a pattern identifier (numeric or alphanumeric) and if it not valid displays an error message and redirect the user to the specified page. If the pattern is valid, returns it.

If no page is specified redirects to '/admin/patterns/'.


mixed $pattern the pattern identifier:

mixed $back the page to redirect to (default '/admin/patterns/'):

array $options an associative array of extra options. E.g.: $options('numeric' => TRUE) enforces that the pattern id must be numeric.

10 calls to patterns_utils_if_invalid_go_back()
patterns_edit_page in includes/forms/
Display the page for editing a pattern.
patterns_enable_pattern in ./patterns.module
Form constructor for the Patterns enabling form.
patterns_modules_page in theme/
Lists the modules used by a particular pattern.
patterns_publish_pattern in includes/
Callback function for route /admin/patterns/publish/
patterns_publish_pattern_submit in includes/
Executes patterns_db_publish_pattern($pid) and display a message.

... See full list


includes/, line 27
Collectiion of general purpose functions.


function patterns_utils_if_invalid_go_back($pattern = NULL, $back = '/admin/patterns/', $options = array()) {
  $id = $pattern;

  // store a reference to the original parameter
  if (isset($options['numeric'])) {
    if (!is_numeric($pattern)) {
      drupal_set_message(t('You must specify a valid id for the pattern.'));
      return FALSE;
  $pattern = patterns_get_pattern($pattern);
  if (!$pattern) {
    drupal_set_message(t('No pattern was found with the given id: %id', array(
      '%id' => $id,
    )), 'error');
  return $pattern;