function oa_clone_prepare in Open Atrium Clone 7.2
Prepares a node to be cloned via the 'clone' module.
After you've made any changes, save it using oa_clone_save().
Parameters
object|int $original_node: The node object or nid that we are cloning.
int $space_nid: (Optional) The nid of the Space to add this node to.
int $section_nid: (Optional) The nid of the Section to add this node to.
boolean $bypass_access_check: (Optional) If set to TRUE, the access check will be bypassed.
Return value
object|NULL The new node object that was created or NULL if the user doesn't have access to clone it.
See also
oa_clone()
1 call to oa_clone_prepare()
- oa_clone in ./
oa_clone.module - Clones a node using the 'clone' module.
File
- ./
oa_clone.module, line 360
Code
function oa_clone_prepare($original_node, $space_nid = NULL, $section_nid = NULL, $bypass_access_check = FALSE) {
if (!is_object($original_node)) {
$original_node = node_load($original_node);
$original_node->oa_clone_skip = TRUE;
}
// We mark the node to bypass access check, which will be recognized by
// clone_access_cloning() and passed down to other content contained within
// this this $node (ie. Section, sub-Spaces, etc).
//
// NOTE: This won't bypass ALL access checks. It'll only bypass them for
// group content (normal 'clone' module access checks will remain) and some
// additional hook_clone_access_alter() function can choose to heed it or not
// depending on what they want to do.
$original_node->oa_clone_bypass_access_check = $bypass_access_check;
if (clone_access_cloning($original_node)) {
module_load_include('inc', 'clone', 'clone.pages');
$node = _clone_node_prepare($original_node, FALSE);
if ($space_nid) {
if ($node->type == 'oa_space') {
if (module_exists('oa_subspaces')) {
$node->{OA_PARENT_SPACE}[LANGUAGE_NONE][0]['target_id'] = $space_nid;
}
}
else {
$node->{OA_SPACE_FIELD}[LANGUAGE_NONE][0]['target_id'] = $space_nid;
}
}
if ($section_nid) {
$node->{OA_SECTION_FIELD}[LANGUAGE_NONE][0]['target_id'] = $section_nid;
}
$context = array(
'method' => 'save-edit',
'original_node' => $original_node,
);
drupal_alter('clone_node', $node, $context);
return $node;
}
}