function block_patterns_validate in Patterns 7
Same name and namespace in other branches
- 7.2 patterns_components/components/block.inc \block_patterns_validate()
File
- patterns_components/
components/ block.inc, line 170
Code
function block_patterns_validate($action, $tag, &$data) {
$status = PATTERNS_SUCCESS;
$msg = '';
if ($tag == 'block') {
if (!($data['module'] && isset($data['delta'])) && !$data['info']) {
$status = PATTERNS_ERR;
$msg = t('Missing required <module>, <delta> tags. Possibly malformed <id> tag could be the problem too. If creating a new block, tag <info> is required.');
}
elseif ($action === PATTERNS_DELETE && $data['module'] != 'block') {
$status = PATTERNS_ERR;
$msg = t('Unable to delete non-block module blocks.');
}
elseif ($action === PATTERNS_MODIFY || $action === PATTERNS_DELETE) {
// Block must exist.
// TODO: support $data['info']
$block_count = db_query('SELECT COUNT(1) FROM {block} WHERE module = :module AND delta = :delta', array(
'module' => $data['module'],
'delta' => $data['delta'],
))
->fetchField();
if ($block_count == 0) {
$status = PATTERNS_ERR;
$msg = t('Block does not exist.');
}
}
}
return patterns_results($status, $msg);
}