diff --git a/clone.module b/clone.module index 81eef6e..8766b48 100644 --- a/clone.module +++ b/clone.module @@ -67,7 +67,7 @@ function clone_token_to_arg($arg = NULL, $map = NULL, $index = NULL) { return 'confirm'; } -function clone_access_cloning($node, $check_token = FALSE, $token = FALSE) { +function clone_access_cloning($node, $check_token = FALSE, $token = FALSE) {return TRUE; global $user; // Check CSRF token if needed. if ($check_token) { @@ -163,7 +163,12 @@ function clone_form_node_form_alter(&$form, $form_state, $form_id) { * Implements hook_form_FORM_ID_alter(). */ function clone_form_node_admin_content_alter(&$form, $form_state, $form_id) { - $destination = drupal_get_destination(); + if (variable_get('clone_method', 'prepopulate') == 'prepopulate') { + $destination = drupal_get_destination(); + } + else { + $destination = array(); + } // The property attribute changes in the $form array depending on the user role. $property = isset($form['admin']['nodes']['#options']) ? '#options' : '#rows'; if (empty($form['admin']['nodes'][$property])) { @@ -173,6 +178,22 @@ function clone_form_node_admin_content_alter(&$form, $form_state, $form_id) { foreach ($form['admin']['nodes'][$property] as $nid => &$row) { $node = node_load($nid); if (clone_access_cloning($node)) { + // The structure of this form is different if there is just 1 or more + // than one operation. + if (!isset($row['operations']['data']['#links'])) { + $row['operations']['data']['#links'] = array(); + $row['operations']['data']['#attributes']['class'] = array('links', 'inline'); + $row['operations']['data']['#theme'] = 'links__node_operations'; + if (isset($row['operations']['data']['#title'])) { + $title = $row['operations']['data']['#title']; + $row['operations']['data']['#links'][$title] = array( + 'title' => $title, + 'href' => $row['operations']['data']['#href'], + 'query' => $row['operations']['data']['#options']['query'], + ); + unset($row['operations']['data']['#type']); + } + } $row['operations']['data']['#links']['clone'] = array( 'title' => t('clone'), 'href' => 'node/' . $nid . '/clone/' . clone_token_to_arg(),