function node_patterns_prepare in Patterns 7
Same name and namespace in other branches
- 7.2 patterns_components/components/node.inc \node_patterns_prepare()
File
- patterns_components/
components/ node.inc, line 111
Code
function node_patterns_prepare($action, $tag, &$data) {
if ($tag == 'content_type') {
if ($action === PATTERNS_CREATE or $action === PATTERNS_MODIFY) {
if ($data['node_options']) {
$data['node_options'] = array_values($data['node_options']);
}
else {
$data['node_options'] = array(
'status',
'promote',
);
// TODO: proper defaults?
}
}
// TODO: check if the name and type fields are unique when creating
// and existing when we are modifying or deleting
}
elseif ($tag == 'node') {
global $user;
// Use 'nid' instead of 'id'.
if (empty($data['nid']) && !empty($data['id'])) {
$data['nid'] = $data['id'];
}
unset($data['id']);
// TODO: are these needed?
if (empty($data['name']) && !empty($data['author'])) {
$data['name'] = $data['author'];
}
unset($data['author']);
if (empty($data['uid'])) {
$data['uid'] = $user->uid;
}
if (empty($data['name'])) {
$data['name'] = $user->name;
}
if ($action == PATTERNS_CREATE) {
unset($data['nid']);
unset($data['vid']);
$data['node'] = (object) $data;
$data['update'] = FALSE;
}
elseif ($action == PATTERNS_MODIFY) {
$data['update'] = TRUE;
}
elseif ($action == PATTERNS_DELETE) {
$data['update'] = FALSE;
}
}
return patterns_results();
}