[drupal-devel] [feature] Add functionality to make a copy of a node

puregin drupal-devel at drupal.org
Sat Apr 30 01:57:40 UTC 2005


Issue status update for http://drupal.org/node/21632

 Project:      Drupal
 Version:      cvs
 Component:    node system
 Category:     feature requests
 Priority:     normal
 Assigned to:  puregin
 Reported by:  puregin
 Updated by:   puregin
 Status:       patch
 Attachment:   http://drupal.org/files/issues/node_copy_patch (4.06 KB)

The purpose of this patch is to enable a copy operation on nodes.
The semantics of this are: given a node, a copy is saved.  Only
the title is changed (and of course the node will have new nid).
Hence, for example, copies of book pages are siblings of the
original.  


  Q. Are there any situations where having a copy of a node
will mess up a compound/structure?  


  Q. Should anything else be modfied (created/changed dates, ...)?


  Could you please review carefully - I'm pretty new to this
code!  Please pay special attention to:


    - permission checks - I'm not clear on the semantics of these
    - generation of watchdog entries / messages


  The patch makes the following changes:


1. Adds a function node_copy(&$node), based on node_submit.  This
accepts a node or node array, and checks if the current user has view
permissions and create permissions.  If so, it creates a title


    "(Copy of node ".$node->nid.") ". $node->title


It then clears the node's nid, and submits to node_save(), which
creates a new node. Appropriate messages are generated to indicate
success or reasons for failure.


2. Adds an item to the $items[] array in node_menu after line 710 to
allow adding copying a node '$nid' by by "node/$nid/copy".  This tries
to follow the way "node/$nid/delete" is handled.


3. Adds an operation


    'copy'   =>    array(t('Copy the selected posts'), ''),


(at line 748) to the operations array in function node_admin_nodes()
to allow mass copying of nodes (a la mass deletion of nodes).
Implements this operation.


4. Adds a case in function node_page() to take care of the copy
operation.




puregin




More information about the drupal-devel mailing list