function patterns_utils_if_invalid_go_back in Patterns 7
Same name and namespace in other branches
- 7.2 includes/utils.inc \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/'.
Parameters
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.
8 calls to patterns_utils_if_invalid_go_back()
- patterns_edit_page in includes/
forms/ editor.inc - 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/
modules.inc - Lists the modules used by a particular pattern.
- patterns_publish_pattern in includes/
servers.inc - Callback function for route /admin/patterns/publish/
- patterns_remove_pattern in ./
patterns.module - Form constructor for the Patterns removing form.
File
- includes/
utils.inc, line 27 - Collectiion of general purpose functions.
Code
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');
drupal_goto($back);
}
return $pattern;
}