Index: comment_mover.info =================================================================== RCS file: comment_mover.info diff -N comment_mover.info --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ comment_mover.info 25 Nov 2006 01:01:37 -0000 @@ -0,0 +1,4 @@ +; $Id$ +name = Comment mover +description = Move comments to other threads or convert them to nodes. +dependencies = comment \ No newline at end of file Index: comment_mover.module =================================================================== RCS file: /cvs/drupal-contrib/contributions/modules/comment_mover/comment_mover.module,v retrieving revision 1.19 diff -u -p -r1.19 comment_mover.module --- comment_mover.module 30 Nov 2006 11:22:50 -0000 1.19 +++ comment_mover.module 1 Dec 2006 07:31:32 -0000 @@ -10,13 +10,17 @@ define ('COMMENT_MOVER_COMMENT_TO_COMMEN * Implementation of hook_help */ function comment_mover_help($section) { - $output = ''; switch ($section) { - case 'admin/modules#description': - $output = t('Move comments to other threads or create nodes from them.'); - break; + case 'admin/help#comment_mover': + $output = '
'. t('Comment mover enables you to move comments and nodes around by pruning and grafting. Pruning and grafting are similar to cut and paste but operate on branches, not on single comments. If you prune and graft a comment thread, the entire thread will be moved, not just the pruned comment.') .'
'; + $output .= ''. t('Basic use is simple; it starts by pruning a node or comment via the link prune. The pruned node/comment now appears in the Graft block. The graft block shows the title and author of the pruned content and always allows you to cancel the action. You can now navigate through your site and choose one of two options: grafting or conversion.') .'
'; + $output .= ''. t('Grafting is a simple matter: simply click the graft link on the content (comment or node) you want the pruned object to reside under. All childcomments will be moved together with the pruned node or comment') .'
'; + + $output .= ''. t('If you just pruned a comment and enabled story and page under "Enable promotion to the following node types" on the comment mover settings page, the graft block also shows you story and page in the selection of node types to which the +comment can be converted. When you then, for example, select story and click convert, a story submission form will appear with prefilled fields. Edit if necessary, then click submit. A new story node will be created. All children of the original comment will be moved to the new node.', array('@url' => url('admin/settings/comment_mover'))) .'
'; + $output .= ''. t('When you move a comment to another node or convert it to a node, the original comment will contain a link pointing to the comments new location. When you move a node to become a comment on another node, the original node will contain a redirect to the new location.') .'
'; + return $output; } - return $output; } /** @@ -31,18 +35,25 @@ function comment_mover_menu($may_cache) 'access' => $access, 'callback' => 'comment_mover_cancel', 'type' => MENU_CALLBACK); + $items[] = array('path' => 'admin/settings/comment_mover', + 'title' => t('Comment mover'), + 'description' => t('Configure comment mover to operate on specific content types.'), + 'callback' => 'drupal_get_form', + 'callback arguments' => 'comment_mover_settings', + 'access' => user_access('administer site configuration'), + ); } else { - $items[] = array('path' => 'comment/promote', 'title' => t('promote comment'), + $items[] = array('path' => 'comment/promote', 'title' => t('Promote comment'), 'callback' => 'comment_mover_promote', 'access' => $access, 'type' => MENU_CALLBACK); - $items[] = array('path' => 'comment/graft', 'title' => t('prune comment'), + $items[] = array('path' => 'comment/graft', 'title' => t('Prune comment'), 'callback' => 'comment_mover_graft', 'access' => $access, 'callback arguments' => array(arg(2), arg(3)), 'type' => MENU_CALLBACK); - $items[] = array('path' => 'comment/prune', 'title' => t('prune comment'), + $items[] = array('path' => 'comment/prune', 'title' => t('Prune comment'), 'callback' => 'comment_mover_prune', 'access' => $access, 'callback arguments' => array(arg(2), arg(3)), 'type' => MENU_CALLBACK); @@ -66,11 +77,17 @@ function comment_mover_link($type, $obje !($prune->nid == $object->nid && $prune->cid == 0) && // comment is not a child of the pruned node !in_array($object->cid, comment_mover_get_children($prune->cid))) { // comment is not a child of the pruned comment - $links[] = l(t('graft'), "comment/graft/$object->nid/$object->cid"); + $links['comment_mover_comment_graft'] = array( + 'title' => t('graft'), + 'href' => "comment/graft/{$object->nid}/{$object->cid}", + ); } } else if (comment_mover_allows_pruning('comment', $object)) { - $links[] = l(t('prune'), "comment/prune/$object->nid/$object->cid"); + $links['comment_mover_comment_prune'] = array( + 'title' => t('prune'), + 'href' => "comment/prune/{$object->nid}/{$object->cid}", + ); } } else if ($type == 'node' && !$teaser && user_access('administer comments')) { @@ -80,11 +97,18 @@ function comment_mover_link($type, $obje if (comment_mover_allows_grafting('node', $object) && // grafting on node_type is set !($prune->nid == $object->nid && $prune->cid == 0) && // node is not the pruned node !($prune->nid == $object->nid && $prune->pid == 0)) { // node is not the direct parent of pruned comment - $links[] = l(t('graft'), "comment/graft/$object->nid"); + $links['comment_mover_node_graft'] = array( + 'title' => t('Graft'), + 'href' => "comment/graft/{$object->nid}", + ); } } else if (node_access('update', $object) && user_access('administer comments') && comment_mover_allows_pruning('node', $object)) { - $links[] = l(t('prune'), "comment/prune/$object->nid", NULL, drupal_get_destination()); + $links['comment_mover_node_prune'] = array( + 'title' => t('Prune'), + 'href' => "comment/prune/{$object->nid}", + 'query' => drupal_get_destination(), + ); } } return $links; @@ -98,7 +122,9 @@ function comment_mover_link($type, $obje function comment_mover_promote_form() { $form = array(); $options = array(); - foreach (node_get_types() as $type => $name) { + foreach (node_get_types() as $node_type) { + $type = $node_type->type; + $name = $node_type->name; if (node_access('create', $type) && variable_get("commentmover_promotion_$type", FALSE)) { $options[$type] = $name; } @@ -111,11 +137,11 @@ function comment_mover_promote_form() { '#options' => $options, ); $form['submit'] = array('#type' => 'submit', '#value' => t('Convert')); - return drupal_get_form('comment_mover_promote', $form); } + return $form; } -function comment_mover_promote_submit($form_id, $form_values) { +function comment_mover_promote_form_submit($form_id, $form_values) { return "comment/promote/{$form_values['type']}" ; } @@ -147,8 +173,9 @@ function comment_mover_promote($type) { drupal_set_message(t('Author has been set to %username.', array('%username' => theme('username', $user)))); } - $output = node_form($node); - drupal_set_title(t('Submit %name', array('%name' => node_get_name($node)))); + //$output = node_form($node); + $output = drupal_get_form($type .'_node_form', $node); + drupal_set_title(t('Submit %name', array('%name' => node_get_types('name', $node)))); return $output; } } @@ -313,7 +340,7 @@ function comment_mover_move($object, $pi case COMMENT_MOVER_COMMENT_TO_NODE: $new_nid = $object['new_nid']; $comment = $object; - $comment['comment'] = t('This comment has been moved here.', array('%url' => url('node/'. $new_nid, NULL, NULL, TRUE))); + $comment['comment'] = t('This comment has been moved here.', array('@url' => url('node/'. $new_nid, NULL, NULL, TRUE))); break; case COMMENT_MOVER_NODE_TO_COMMENT: $comment = $object; @@ -357,7 +384,7 @@ function comment_mover_move($object, $pi $object = (object) $object; node_save($object); } - if (module_exist('oglist')) { + if (module_exists('oglist')) { switch ($object['comment_mover']) { case COMMENT_MOVER_NODE_TO_COMMENT: db_query('UPDATE {og2list_msgid} SET nid = %d, cid = %d WHERE nid = %d AND cid = 0', $new_comment['nid'], $new_comment['cid'], $object['nid']); @@ -525,6 +552,18 @@ function comment_mover_prune($nid, $cid } } +function comment_mover_graft($nid, $cid = 0) { + return drupal_get_form('confirm_comment_mover_graft', $nid, $cid); +} + + +function confirm_comment_mover_graft($nid, $cid) { + $form['nid'] = array('#type' => 'value', '#value' => $nid); + $form['cid'] = array('#type' => 'value', '#value' => $cid); + return confirm_form($form, t('Are you sure you want to move this post here?'), 'node/'. $nid); +} + + /* * The grafting part, wrapper for comment_mover_move * @@ -534,13 +573,11 @@ function comment_mover_prune($nid, $cid * The cid that shoud become the parent of the pruned comment (in $_SESSION) * If 0, the $nid should be the direct parent */ -function comment_mover_graft($nid, $cid = 0) { +function confirm_comment_mover_graft_submit($form_id, $form_values) { + $nid = $form_values['nid']; + $cid = $form_values['cid']; $prune = comment_mover_pruning(); - if ($_POST['op'] != t('Confirm')) { - return confirm_form('confirm_comment_mover_graft', array(), t('Are you sure you want to move this post here?'), 'node/'. $nid); - } - // Load node to check whether the target node allows grafting. if (is_numeric($nid)) { $target_node = node_load($nid); @@ -684,14 +721,14 @@ function theme_comment_mover_block($op, $content = ''; if ($op == 'comment') { $content = '