? clone_permitted_1.patch
? clone_permitted_2.patch
? clone_permitted_3.patch
? prepopulate_clone_1.diff
? prepopulate_clone_4.patch
? prepopulate_clone_5x_2.patch
? prepopulate_clone_5x_3.patch
Index: clone.module
===================================================================
RCS file: /cvs/drupal-contrib/contributions/modules/node_clone/clone.module,v
retrieving revision 1.9.2.1
diff -u -p -r1.9.2.1 clone.module
--- clone.module 15 Feb 2007 03:33:14 -0000 1.9.2.1
+++ clone.module 4 May 2007 23:28:59 -0000
@@ -39,7 +39,7 @@ function clone_menu($may_cache) {
if (arg(0) == 'node' && is_numeric(arg(1))){
$node = node_load(arg(1));
if ($node->nid) {
- $access = (user_access('clone node') && filter_access($node->format) && node_access('create',$node->type));
+ $access = (user_access('clone node') && clone_is_permitted($node->type) && filter_access($node->format) && node_access('create',$node->type));
$items[] = array(
'path' => 'node/'. $node->nid.'/clone',
'title' => t('Clone'),
@@ -54,6 +54,10 @@ function clone_menu($may_cache) {
return $items;
}
+function clone_is_permitted($type) {
+ return !in_array($type, variable_get('clone_omitted', array()));
+}
+
/**
* menu callback to configure module settings.
*/
@@ -67,14 +71,25 @@ function clone_settings() {
'#type' => 'fieldset',
'#title' => ''.t('Should the publishing options ( e.g. published, promoted, etc) be reset to the defaults?').'',
);
-
- foreach (node_get_types() as $type_obj) {
- $form['publishing']['clone_reset_'. $type_obj->type] = array(
+ $types = node_get_types('names');
+
+ foreach ($types as $type => $name) {
+ $form['publishing']['clone_reset_'. $type] = array(
'#type' => 'checkbox',
- '#title' => t('@s: reset publishing options when cloned', array('@s' => $type_obj->name)),
- '#default_value' => variable_get('clone_reset_'. $type_obj->type, FALSE),
+ '#title' => t('@s: reset publishing options when cloned', array('@s' => $name)),
+ '#default_value' => variable_get('clone_reset_'. $type, FALSE),
);
}
+ // Need the variable default key to be something that's never a valid node type.
+ $types = array_merge( array('!' => "<". t("none") .">"), $types);
+ $form['clone_omitted'] = array(
+ '#type' => 'select',
+ '#title' => t('Omitted content types'),
+ '#default_value' => variable_get('clone_omitted', array('!')),
+ '#options' => $types,
+ '#description' => t('Select any node types which should never be cloned. Typically you should will want to select here all node types for which cloning fails (e.g. image nodes).'),
+ '#multiple' => TRUE
+ );
return system_settings_form($form);
}
@@ -108,7 +123,7 @@ function clone_node($nid)
global $user;
$node = node_load($nid);
- if (isset($node->nid)) {
+ if (isset($node->nid) && clone_is_permitted($node->type)) {
$node->nid = NULL;
$node->uid = $user->uid;