clone.api.php 1.3 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647
  1. <?php
  2. /**
  3. * @file
  4. * API documentation for the Node clone module.
  5. */
  6. /**
  7. * Alter the node before saving a clone.
  8. *
  9. * @param $node
  10. * Reference to the fully loaded node object being saved (the clone) that
  11. * can be altered as needed.
  12. * @param array $context
  13. * An array of context describing the clone operation. The keys are:
  14. * - 'method' : Can be either 'prepopulate' or 'save-edit'.
  15. * - 'original_node' : The original fully loaded node object being cloned.
  16. *
  17. * @see clone_node_save()
  18. * @see drupal_alter()
  19. */
  20. function hook_clone_node_alter(&$node, $context) {
  21. if ($context['original_node']->type = 'special') {
  22. $node->special = special_something();
  23. }
  24. }
  25. /**
  26. * Alter the access to the ability to clone a given node.
  27. *
  28. * @param bool $access
  29. * Reference to the boolean determining if cloning should be allowed on a
  30. * given node.
  31. * @param $node
  32. * The fully loaded node object being considered for cloning.
  33. *
  34. * @see clone_access_cloning()
  35. * @see drupal_alter()
  36. */
  37. function hook_clone_access_alter(&$access, $node) {
  38. global $user;
  39. // Only allow cloning of nodes posted to groups you belong to.
  40. // This function doesn't really exist, but you get the idea...
  41. if (!og_user_is_member_of_group_the_node_is_in($user, $node)) {
  42. $access = FALSE;
  43. }
  44. }