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() {
3731function 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 */
8781function 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
111105function 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 */
133127function 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 */
140134function 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) {
152146function 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 */
162156function 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 */
189183function 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