Commit 18e9874b authored by Croitor Alexandru's avatar Croitor Alexandru
Browse files

Forgot some files.

parent 71407992
// $Id$
Welcome to Node Convert.
This module allows to convert one or many nodes between different node types.
It can transfer most cck fields, and node-specific options for book and forum types.
Support of more basic types will be in future releases.
Also the module provides an API for converting nodes and cck fields, hooks for processing
additional options of custom node types, integrates with hook_node_operations and Drupal's
Action API.
I. Single node conversion:
1) Set 'administer conversion' and 'convert to x', 'convert from y' permissions.
2) Go to /node/x/convert and follow the provided steps to convert the node.
II. Multiple node conversion (using hook_node_operations)
1) Set appropriate permissions.
2) Go to admin/build/node_convert_templates
3) Create a new template following the the provided steps.
4) Go to admin/content/node
5) Select the correct nodes.
6) Choose "Convert template: x" (based on the template name created above) from the update options.
7) Click Update.
III. Multiple node conversion (using Actions API + Views Bulk Operations)
Note: This requires the contributed modules Views and Views Bulk Operations
1) Set appropriate permissions.
2) Go to admin/build/node_convert_templates
3) Create a new template following the the provided steps (also check Create Action).
3) Create a new view with the options you require.
4) Select Views Bulk Operations as the style.
5) Configure all options as necessary
6) Select as an operation one of the convert templates.
Note: Most probably there will be duplicates of the same template, this is because
VBO uses both Actions API and hook_node_operations to show possible operations
7) Save the view. View it.
8) Select the necessary nodes and click the Convert x button.
Useful API calls:
node_convert_node_convert($nid, $dest_node_type, $source_fields, $dest_fields, $no_fields_flag, $hook_options = NULL);
node_convert_field_convert($nid, $source_field, $dest_field);
hook_node_convert_change($data, $op);
\ No newline at end of file
// $Id$
- Make node_convert independent of CCK
- Implement support for types: poll, blog, og, etc.
- Write more complex SimpleTest tests (that use different cck fields and base types like blog, poll)
- Include watchdog support
- Clean up code, try to increase performance
- Change messages to be more user-friendly
- ? Come up with a better UI
- ? Possibly create more hooks or triggers
\ No newline at end of file
// $Id$
* @file
* Node convert Simpletest Unit
* Tests for basic Node Convert functionality.
class NodeConvertTestCase extends DrupalWebTestCase {
* Implementation of getInfo().
function getInfo() {
return array(
'name' => t('Node conversion'),
'description' => t('Tests diverse aspects of Node Convert.'),
'group' => t('Node Convert'),
function setUp() {
// The first thing a setUp() method should always do is call its parent setUp() method.
// If you need to enable any modules (including the one being tested),
// add them as function parameters.
parent::setUp('content', 'node_convert');
// Next, perform any required steps for the test methods within this test grouping.
* Implementation of tearDown().
function tearDown() {
// Perform any clean-up tasks.
// The last thing a tearDown() method should always do is call its parent tearDown() method.
function testSimpleNodeConvert() {
$type1_name = $this->randomName(4);
$type2_name = $this->randomName(4);
$type1 = $this->drupalCreateContentType(array('type' => $type1_name, 'name' => $type1_name));
$type2 = $this->drupalCreateContentType(array('type' => $type2_name, 'name' => $type2_name));
$edit['type'] = $type1_name;
$node = $this->drupalCreateNode($edit);
node_convert_node_convert($node->nid, $type2_name, array(), array(), TRUE);
$result = db_query("SELECT type FROM {node} WHERE nid = :nid", array(':nid' => $node->nid))->fetchField();
$this->assertEqual($result, $type2_name, t("Simple node conversion passed."));
function testInvalidNidConvert() {
$result = node_convert_node_convert(-1, $this->randomName(4), array(), array(), TRUE);
$this->assertFalse($result, t("Node conversion didn't pass due to illegal nid."));
function testSimpleNodeConvertUI() {
$type1_name = $this->randomName(4);
$type2_name = $this->randomName(4);
$type1 = $this->drupalCreateContentType(array('type' => $type1_name, 'name' => $type1_name));
$type2 = $this->drupalCreateContentType(array('type' => $type2_name, 'name' => $type2_name));
$admin_user = $this->drupalCreateUser(array('administer site configuration', 'access administration pages', 'administer nodes', 'administer content types', 'administer conversion', 'convert from ' . $type1_name, 'convert to ' . $type2_name));
$edit['type'] = $type1_name;
$node = $this->drupalCreateNode($edit);
$edit = array();
$edit['destination_type'] = $type2_name;
$this->drupalPost('node/' . $node->nid . '/convert', $edit, t("Next"));
$this->drupalPost(NULL, array(), t("Convert"));
$this->assertText(t("Node @nid has been converted successfully.", array('@nid' => $node->nid)), t("Simple node conversion ui test passed."));
$result = db_query("SELECT type FROM {node} WHERE nid = :nid", array(':nid' => $node->nid))->fetchField();
$this->assertEqual($result, $type2_name, t("The converted node type is equal to the destination node type."));
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment