The need is to clone nodes later, after the node is cloned, between groups. With all the hooks with nodereferences, etc., want to re-use spaces og code.

don't have anything right now to do it that's generic enough contrib, but got some changes that needed to do it.

CommentFileSizeAuthor
spaces_og_clone_solo.patch5.97 KBhefox

Comments

hefox’s picture

Explanation of changes.

+++ b/includes/nodereference.inc
@@ -28,7 +28,7 @@ function nodereference_spaces_og_clone_node_cleanup($node, $group, $sandbox, $se
+            $referenced_node = node_load($val['nid']);

Bug, eep.

+++ b/spaces_og_clone.inc
@@ -14,7 +14,6 @@ function spaces_og_clone_clone($new_group, $old_group, $settings, $batch = FALSE
-    'name' => $user->name,
     'uid' => $user->uid,

Having to supply username and uid for settings is not good developer wise, asking for problems.

+++ b/spaces_og_clone.inc
@@ -22,7 +21,7 @@ function spaces_og_clone_clone($new_group, $old_group, $settings, $batch = FALSE
+    $new_group->name = _spaces_og_fetch_user_name($new_group->uid);

So don't need to specify name

+++ b/spaces_og_clone.inc
@@ -135,6 +134,21 @@ function spaces_og_clone_nid_map_insert($clone_node, $original_group, $sogcid) {
+function spaces_og_clone_get_cloned_node_nids($new_group_nid) {

So can create the nid_map for noderefernce/text replacements when don't already have the nid_map (e.g. post clone cloning)

+++ b/spaces_og_clone.inc
@@ -210,14 +224,26 @@ function _spaces_og_clone_node_clean_group($old_group) {
+function spaces_og_clone_node_clone_nodes($nids, $group, $settings = array()) {

Name spacing to indicate it can be called later

+++ b/spaces_og_clone.inc
@@ -281,6 +307,7 @@ function _spaces_og_clone_node_clone_nodes_batch($nids, $group, $settings, &$con
+    $current_space = spaces_get_space();

If called from a different space, this prevents that space from being lost.

+++ b/spaces_og_clone.inc
@@ -296,9 +323,11 @@ function _spaces_og_clone_first_pass($nids, &$sandbox) {
+    if (isset($sandbox['settings']['uid'])) {

Default to original author if uid not set

btopro’s picture

Status: Needs review » Fixed

Makes sense to me, Rolling this into an alpha build.

Status: Fixed » Closed (fixed)

Automatically closed -- issue fixed for 2 weeks with no activity.