<div dir="ltr">There's a switch statement based ajax function in outline_designer (<a href="http://drupal.org/project/outline_designer">http://drupal.org/project/outline_designer</a>) called duplicate. The best way to clone a node is to load it with drupal node_load then clear out the nid. Then call node_save and it'll look at the node, see that there isn't a nid and assign it one. The rest of the fields will be saved via the nodeapi hooks. The function you wrote before looks very similar to the one I used.<br>
<br>btopro<br><br><div class="gmail_quote">On Mon, Jul 21, 2008 at 7:44 AM, Lluís <<a href="mailto:enboig@gmail.com">enboig@gmail.com</a>> wrote:<br><blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;">
I have developed a simple group system (similar to OG in some ways,<br>
very diferent in others) so I need a user beeing able to import nodes<br>
from other groups to his own.<br>
To do so I have created a form which loads all the nodes from other<br>
groups as checkboxes. The checked items will be cloned to his group.<br>
<br>
I haven't tried node_clone, but I think it is UI oriented; I just need<br>
to clone a node knowing its ID (all group permissions, etc... are<br>
rewritten using nodeapi of my custom node).<br>
<div><div></div><div class="Wj3C7c"><br>
<br>
On Mon, Jul 21, 2008 at 11:59 AM, Nathaniel Catchpole<br>
<<a href="mailto:catch56@googlemail.com">catch56@googlemail.com</a>> wrote:<br>
> You could take a look at the node_clone module if you haven't already:<br>
> <a href="http://drupal.org/project/node_clone" target="_blank">http://drupal.org/project/node_clone</a><br>
><br>
> On Mon, Jul 21, 2008 at 10:55 AM, Lluís <<a href="mailto:enboig@gmail.com">enboig@gmail.com</a>> wrote:<br>
>> I have developed a custom module with custom node types and I need to<br>
>> make users able to clone nodes; would this be a good way to do so?<br>
>><br>
>> $clone=node_load($value);<br>
>> $clone->is_new = true;<br>
>> $clone->uid = $user->uid;<br>
>> unset($clone->nid);<br>
>> unset($clone->vid);<br>
>> node_save($clone);<br>
>><br>
>><br>
>> --<br>
><br>
<br>
<br>
<br>
</div></div><div><div></div><div class="Wj3C7c">--<br>
*La vida és com una moneda, la pots gastar en el que vulguis però<br>
només una vegada.<br>
*La felicitat ha de ser compatible, compartible i cooperativa.<br>
*Envellim quan els records superen les il·lusions.<br>
*Als llocs desconeguts només s'hi arriba per camins desconeguts.<br>
*Abans d'imprimir aquest missatge, pensa en el medi ambient.<br>
</div></div></blockquote></div><br></div>