Skip to content

Commit 7b0018c

Browse files
author
Andy Martha
committed
initial working release
1 parent 429cbc1 commit 7b0018c

File tree

10 files changed

+504
-71
lines changed

10 files changed

+504
-71
lines changed

LICENSE.txt

Lines changed: 339 additions & 0 deletions
Large diffs are not rendered by default.

README.txt renamed to README.md

Lines changed: 78 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,63 @@
1+
Node Clone
2+
---------------------
13

2-
README file for the clone module for Drupal 7.x.
4+
The Clone module allows users to make a copy of an existing node and then edit
5+
that copy easily. This module has also been used by some to facilitate node templating.
6+
7+
CONTENTS OF THIS FILE
8+
---------------------
9+
10+
- Introduction
11+
- Tested
12+
- Known Issues
13+
- Special Thanks
14+
- Requirements
15+
- Installation
16+
- Coming From Drupal?
17+
- Usage
18+
- License
19+
- Credits
20+
- Maintainers
21+
22+
TESTED
23+
-----
24+
25+
Working in Backdrop 1.3 for cloning nodes, but not all the options/use-cases have been tested yet.
26+
27+
KNOWN ISSUES
28+
---------------------
29+
30+
The Rules and Views portions of this module have not been ported yet.
31+
32+
SPECIAL THANKS
33+
--------------
34+
35+
Peter Wolanin <https://www.drupal.org/u/pwolanin> for the initial setup.
36+
37+
REQUIREMENTS
38+
------------
39+
40+
none
41+
42+
INSTALLATION
43+
------------
44+
45+
Install this module using the official Backdrop CMS instructions at https://backdropcms.org/guide/modules
46+
47+
Setup your options at: /admin/config/content/clone
48+
49+
COMING FROM DRUPAL?
50+
-------------------
51+
52+
Nothing very much different.
53+
54+
PERMISSIONS
55+
------------
56+
57+
none
58+
59+
USAGE
60+
-----
361

462
The clone module allows users to make a copy of an existing node and then edit
563
that copy. The authorship is set to the current user, the menu and url aliases
@@ -45,10 +103,24 @@ field-level permissions hooks. You should test your configuration
45103
carefully or not allow access to the clone functionality for non-admins if
46104
you rely on field-level permissions for important site features.
47105

48-
To install this module, copy the folder with all the files to the
49-
/sites/all/modules OR /sites/default/modules directory of your Drupal
50-
installation and enable it at /admin/build/modules. Two new permissions are
51-
available, but there are no changes to the database structure.
52-
53106
Note: this module originally derived from code posted by Steve Ringwood
54107
(nevets@drupal) at http://drupal.org/node/73381#comment-137714
108+
109+
LICENSE
110+
-------
111+
112+
This project is GPL v2 software. See the LICENSE.txt file in this directory for complete text.
113+
114+
CREDITS
115+
-----------
116+
117+
Peter Wolanin <https://www.drupal.org/u/pwolanin>
118+
119+
MAINTAINERS
120+
-----------
121+
122+
- seeking
123+
124+
Ported to Backdrop by:
125+
126+
- biolithic <https://github.com/biolithic>

clone.api.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@
1717
* - 'original_node' : The original fully loaded node object being cloned.
1818
*
1919
* @see clone_node_save()
20-
* @see drupal_alter()
20+
* @see backdrop_alter()
2121
*/
2222
function hook_clone_node_alter(&$node, $context) {
2323
if ($context['original_node']->type == 'special') {
@@ -35,7 +35,7 @@ function hook_clone_node_alter(&$node, $context) {
3535
* The fully loaded node object being considered for cloning.
3636
*
3737
* @see clone_access_cloning()
38-
* @see drupal_alter()
38+
* @see backdrop_alter()
3939
*/
4040
function hook_clone_access_alter(&$access, $node) {
4141
global $user;

clone.info

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
name = "Node clone"
22
description = "Allows users to clone (copy then edit) an existing node."
3-
core = 7.x
4-
3+
backdrop = 1.x
4+
version = 1.x-1.x
5+
type = module
56
files[] = views/views_handler_field_node_link_clone.inc
67
configure = admin/config/content/clone

clone.install

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -8,14 +8,14 @@
88
* Implementation of hook_uninstall.
99
*/
1010
function clone_uninstall() {
11-
variable_del('clone_method');
12-
variable_del('clone_omitted');
13-
variable_del('clone_nodes_without_confirm');
14-
variable_del('clone_use_node_type_name');
15-
variable_del('clone_menu_links');
16-
$types = node_type_get_names();
17-
foreach ($types as $type => $name) {
18-
variable_del('clone_reset_' . $type);
19-
}
11+
// variable_del('clone_method');
12+
// variable_del('clone_omitted');
13+
// variable_del('clone_nodes_without_confirm');
14+
// variable_del('clone_use_node_type_name');
15+
// variable_del('clone_menu_links');
16+
// $types = node_type_get_names();
17+
// foreach ($types as $type => $name) {
18+
// variable_del('clone_reset_' . $type);
19+
// }
2020
}
2121

clone.module

Lines changed: 24 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -5,20 +5,14 @@
55
*/
66

77
/**
8-
* Implementation of hook_help().
8+
* Implements hook_config_info().
99
*/
10-
function clone_help($path, $arg) {
11-
switch ($path) {
12-
case 'admin/help#clone':
13-
$output = '<p>' . t('The clone module allows users to make a copy of an existing node and then edit that copy. The authorship is set to the current user, the menu and url aliases are reset, and the words "Clone of" are inserted into the title to remind you that you are not editing the original node.') . '</p>';
14-
$output .= '<p>' . t('Users with the "clone node" permission can utilize this functionality. A new tab will appear on node pages with the word "Clone".') . '</p>';
15-
return $output;
16-
case 'node/%/clone':
17-
$method = variable_get('clone_method', 'prepopulate');
18-
if ($method == 'prepopulate') {
19-
return t('This clone will not be saved to the database until you submit.');
20-
}
21-
}
10+
function clone_config_info() {
11+
$prefixes['clone.settings'] = array(
12+
'label' => t('clone settings'),
13+
'group' => t('Configuration'),
14+
);
15+
return $prefixes;
2216
}
2317

2418
/**
@@ -37,7 +31,7 @@ function clone_permission() {
3731
function clone_menu() {
3832
$items['admin/config/content/clone'] = array(
3933
'access arguments' => array('administer site configuration'),
40-
'page callback' => 'drupal_get_form',
34+
'page callback' => 'backdrop_get_form',
4135
'page arguments' => array('clone_settings'),
4236
'title' => 'Node clone module',
4337
'file' => 'clone.pages.inc',
@@ -85,8 +79,8 @@ function clone_token_to_arg($arg, $map) {
8579
* Either 'confirm' or a CSRF token.
8680
*/
8781
function clone_get_token($nid) {
88-
if (variable_get('clone_nodes_without_confirm', FALSE)) {
89-
return drupal_get_token('clone_access_cloning-' . $nid);
82+
if (config_get('clone.settings', 'clone_nodes_without_confirm')) {
83+
return backdrop_get_token('clone_access_cloning-' . $nid);
9084
}
9185
return 'confirm';
9286
}
@@ -104,12 +98,12 @@ function clone_access_cloning($node, $check_token = FALSE, $token = FALSE) {
10498
// Make sure the user can view the original node content, and create a new one..
10599
$access = $access && node_access('view', $node) && node_access('create', $node->type);
106100
// Let other modules alter this.
107-
drupal_alter("clone_access", $access, $node);
101+
backdrop_alter("clone_access", $access, $node);
108102
return $access;
109103
}
110104

111105
function clone_is_permitted($type) {
112-
$omitted = variable_get('clone_omitted', array());
106+
$omitted = config_get('clone.settings', 'clone_omitted');
113107
return empty($omitted[$type]);
114108
}
115109

@@ -121,8 +115,8 @@ function clone_action_link_title($node) {
121115
if (current_path() != 'node/' . $node->nid) {
122116
return t('Clone');
123117
}
124-
if (variable_get('clone_use_node_type_name', 0)) {
125-
return t('Clone this !type', array('!type' => drupal_strtolower(node_type_get_name($node))));
118+
if (config_get('clone.settings', 'clone_use_node_type_name')) {
119+
return t('Clone this !type', array('!type' => backdrop_strtolower(node_type_get_name($node))));
126120
}
127121
return t('Clone content');
128122
}
@@ -131,17 +125,17 @@ function clone_action_link_title($node) {
131125
* Implementation of hook_node_type_delete().
132126
*/
133127
function clone_node_type_delete($info) {
134-
variable_del('clone_reset_' . $info->type);
128+
// variable_del('clone_reset_' . $info->type);
135129
}
136130

137131
/**
138132
* Implementation of hook_node_type_update().
139133
*/
140134
function clone_node_type_update($info) {
141135
if (!empty($info->old_type) && $info->old_type != $info->type) {
142-
if (variable_get('clone_reset_' . $info->old_type, FALSE)) {
143-
variable_del('clone_reset_' . $info->old_type);
144-
variable_set('clone_reset_' . $info->type, TRUE);
136+
if (config_get('clone.settings', 'clone_reset_' . $info->old_type)) {
137+
// variable_del('clone_reset_' . $info->old_type);
138+
config_set('clone.settings', 'clone_reset_' . $info->type, TRUE);
145139
}
146140
}
147141
}
@@ -152,15 +146,15 @@ function clone_node_type_update($info) {
152146
function clone_views_api() {
153147
return array(
154148
'api' => 3,
155-
'path' => drupal_get_path('module', 'clone') . '/views',
149+
'path' => backdrop_get_path('module', 'clone') . '/views',
156150
);
157151
}
158152

159153
/**
160154
* Implementation of hook_admin_paths().
161155
*/
162156
function clone_admin_paths() {
163-
if (variable_get('node_admin_theme')) {
157+
if (config_get('system.core', 'node_admin_theme')) {
164158
$paths = array(
165159
'node/*/clone/*' => TRUE,
166160
);
@@ -187,8 +181,8 @@ function clone_form_node_form_alter(&$form, $form_state, $form_id) {
187181
* Implements hook_form_FORM_ID_alter().
188182
*/
189183
function clone_form_node_admin_content_alter(&$form, $form_state, $form_id) {
190-
if (variable_get('clone_method', 'prepopulate') == 'prepopulate') {
191-
$destination = drupal_get_destination();
184+
if (config_get('clone.settings', 'clone_method') == 'prepopulate') {
185+
$destination = backdrop_get_destination();
192186
}
193187
else {
194188
$destination = array();
@@ -276,14 +270,14 @@ function clone_action_clone($original_node, $context) {
276270
}
277271
// Let other modules do special fixing up.
278272
$context = array('method' => 'action', 'original_node' => $original_node, 'clone_context' => $val);
279-
drupal_alter('clone_node', $node, $context);
273+
backdrop_alter('clone_node', $node, $context);
280274
node_save($node);
281275
if (module_exists('rules')) {
282276
rules_invoke_event('clone_node', $node, $original_node);
283277
}
284278
}
285279
else {
286-
drupal_set_message(t('Clone failed for %title : not permitted for nodes of type %type', array('%title' => $original_node->title, '%type' => $original_node->type)), 'warning');
280+
backdrop_set_message(t('Clone failed for %title : not permitted for nodes of type %type', array('%title' => $original_node->title, '%type' => $original_node->type)), 'warning');
287281
}
288282
}
289283

0 commit comments

Comments
 (0)