Only in phorum.orig: LICENSE.txt diff -ubr phorum.orig/phorum_converter.info phorum_converter/phorum_converter.info --- phorum.orig/phorum_converter.info 2008-04-30 01:12:58.000000000 +0100 +++ phorum_converter/phorum_converter.info 2009-07-31 02:28:17.420757242 +0100 @@ -1,11 +1,5 @@ -; $Id: phorum_converter.info,v 1.1 2008/04/29 20:59:24 greggles Exp $ -name = Phorum Conversion -description = Converts Phorum database data into Drupal's own forum. -package = Other -dependencies = forum comment - -; Information added by drupal.org packaging script on 2008-04-30 -version = "5.x-1.x-dev" -project = "phorum" -datestamp = "1209514378" +; $Id: image.info,v 1.5 2008/01/06 22:15:24 drewish Exp $ +name = Phorum converter +description = Converts Phorum DB data into Drupal's forum. Please do not forget to enable forum module as well and to visit this module's settings page as well. +core = 6.x diff -ubr phorum.orig/phorum_converter.install phorum_converter/phorum_converter.install --- phorum.orig/phorum_converter.install 2008-04-29 21:56:18.000000000 +0100 +++ phorum_converter/phorum_converter.install 2009-07-31 02:28:17.200710552 +0100 @@ -1,59 +1,109 @@ 'bla.', + 'fields' => array( + 'phorum' => array( + 'description' => 'The primary identifier for a phorum.', + 'type' => 'int', + 'not null' => TRUE, + 'default' => 0, + ), + 'drupal' => array( + 'description' => 'The primary identifier for a node.', + 'type' => 'int', + 'not null' => TRUE, + 'default' => 0, + ), + ), + 'primary key' => array('phorum'), + ); + $schema['phorum_tmp_forum_join'] = array( + 'description' => 'bla.', + 'fields' => array( + 'phorum' => array( + 'description' => 'The primary identifier for a phorum.', + 'type' => 'int', + 'not null' => TRUE, + 'default' => 0, + ), + 'drupal' => array( + 'description' => 'The primary identifier for a node.', + 'type' => 'int', + 'not null' => TRUE, + 'default' => 0, + ), + ), + 'primary key' => array('phorum'), + ); + $schema['phorum_tmp_message_join'] = array( + 'description' => 'bla.', + 'fields' => array( + 'phorum' => array( + 'description' => 'The primary identifier for a phorum.', + 'type' => 'int', + 'not null' => TRUE, + 'default' => 0, + ), + 'drupal' => array( + 'description' => 'The primary identifier for a node.', + 'type' => 'int', + 'not null' => TRUE, + 'default' => 0, + ), + 'nid' => array( + 'description' => 'The primary identifier for a node.', + 'type' => 'int', + 'not null' => TRUE, + 'default' => 0, + ), + ), + 'primary key' => array('phorum'), + ); + $schema['phorum_users'] = array( + 'description' => 'bla.', + 'fields' => array( + 'uid' => array( + 'description' => 'The primary identifier for a phorum.', + 'type' => 'int', + 'not null' => TRUE, + 'default' => 0, + ), + 'email_notify' => array( + 'description' => 'The primary identifier for a node.', + 'type' => 'int', + 'not null' => TRUE, + 'default' => 0, + ), + 'post_count' => array( + 'description' => 'The primary identifier for a node.', + 'type' => 'int', + 'not null' => TRUE, + 'default' => 0, + ), + ), + 'primary key' => array('uid'), + ); + return $schema; +} /** - * Creates the necessery extra and temporary tables for the conversion + * Implementation of hook_install(). */ function phorum_converter_install() { - // user_id - uid - db_query(" - CREATE TABLE {phorum_tmp_user_join} ( - phorum int unsigned not null PRIMARY KEY, - drupal int unsigned not null - ) - "); - // forum_id - tid - db_query(" - CREATE TABLE {phorum_tmp_forum_join} ( - phorum int unsigned not null PRIMARY KEY, - drupal int unsigned not null - ) - "); - // message_id - cid - nid - db_query(" - CREATE TABLE {phorum_tmp_message_join} ( - phorum int unsigned not null PRIMARY KEY, - drupal int unsigned not null, - nid int unsigned not null - ) - "); - db_query(" - CREATE TABLE {phorum_users} ( - uid int unsigned not null PRIMARY KEY, - email_notify tinyint(1) unsigned not null, - post_count int unsigned not null - ) - "); - db_query(" - ALTER TABLE {comments} - MODIFY subject varchar(255) not null - "); - db_query(" - ALTER TABLE {node} - MODIFY title varchar(255) not null - "); - db_query(" - ALTER TABLE {node_revisions} - MODIFY title varchar(255) not null - "); - db_query(" - ALTER TABLE {users} - MODIFY signature text not null - "); + drupal_install_schema('phorum_converter'); } +/** + * Implementation of hook_uninstall(). + */ function phorum_converter_uninstall() { + drupal_uninstall_schema('phorum_converter'); // delete the variables we created. variable_del('phorum_converter_prefix'); variable_del('phorum_converter_runtime'); @@ -62,9 +112,4 @@ variable_del('phorum_converter_phase'); variable_del('phorum_converter_phase_arg'); - db_query("DROP TABLE {phorum_tmp_user_join}"); - db_query("DROP TABLE {phorum_tmp_forum_join}"); - db_query("DROP TABLE {phorum_tmp_message_join}"); - db_query("DROP TABLE {phorum_users}"); } - diff -ubr phorum.orig/phorum_converter.module phorum_converter/phorum_converter.module --- phorum.orig/phorum_converter.module 2008-04-29 21:56:18.000000000 +0100 +++ phorum_converter/phorum_converter.module 2009-07-31 02:34:30.568700686 +0100 @@ -1,7 +1,7 @@ ported to Drupal 6 +// based on d5 port /** * @file * Converts Phorum database data into drupal's own forum @@ -30,26 +30,24 @@ /** * Implementation of hook_menu(). */ -function phorum_converter_menu($may_cache) { +function phorum_converter_menu() { $items = array(); - if ($may_cache) { - $items[] = array( - 'path' => 'admin/settings/phorum', + $items['admin/settings/phorum'] = array( 'title' => t('Phorum conversion'), 'description' => t('Configure the phorum conversion module.'), - 'callback' => 'drupal_get_form', - 'callback arguments' => array('phorum_converter_admin_form'), - 'access' => user_access('administer forums'), + 'page callback' => 'drupal_get_form', + 'page arguments' => array('phorum_converter_admin_form'), + 'access arguments' => array('administer site configuration'), 'type' => MENU_NORMAL_ITEM, ); - $items[] = array('path' => 'phorum', + $items['phorum'] = array( 'title' => t('Phorum conversion'), - 'callback' => 'phorum_converter_cron', - 'access' => user_access('administer forums'), + 'page callback' => 'phorum_converter_cron', + 'page arguments' => array('manual'), + 'access arguments' => array('administer site configuration'), 'type' => MENU_NORMAL_ITEM, ); - } return $items; } @@ -91,6 +89,12 @@ '#default_value' => variable_get('phorum_converter_msg_format', 1), '#options' => $filters, ); + $form['phase_wrapper_start'] = array('#value' => '
');
+  $phase = variable_get('phorum_converter_phase', 'init');
+  $form['phase'] = array('#value' => t("Currently running phase @phase\n", array("@phase"=>$phase)));
+  $phase_arg = variable_get('phorum_converter_phase_arg', 0);
+  $form['phase_arg'] = array('#value' => t("Current phase argument @phase_arg\n", array("@phase_arg"=>$phase_arg)));
+  $form['phase_wrapper_end'] = array('#value' => '
'); return system_settings_form($form); } @@ -108,8 +112,8 @@ $prefix = variable_get('phorum_converter_prefix', 'phorum'); $table = empty($prefix) ? 'forums' : $prefix .'_forums'; db_set_active('phorum'); - $rs = db_query_range("SELECT forum_id FROM $table", 0, 1); - if (db_num_rows($rs) == 0) { + $rows = db_result(db_query("SELECT COUNT(*) FROM $table LIMIT 1")); + if ($rows == 0) { watchdog('phorum converter', t('Phorum DB can not be found. Please check if the Phorum DB access information is right in the settings.php file or if the prefix field is set correctly on the admin/settings/phorum_converter page.')); db_set_active(); return; @@ -195,10 +199,12 @@ // $row->username = _phorum_converter_get_username($row->username); // user_save cannot be used straightforward since that would MD5 hash the // already hashed password - $uid = db_next_id('{users}_uid'); - db_query("INSERT INTO {users} (uid, name, pass, mail, status, signature, created, timezone) - VALUES(%d, '%s', '%s', '%s', %d, '%s', %d, '%s')", - $uid, $row->username, $row->password, $row->email, $row->active, $row->signature, $row->date_added, (3600*$row->tz_offset)); +// $uid = db_next_id('{users}_uid'); + db_query("INSERT INTO {users} (name, pass, mail, status, signature, created, timezone) + VALUES('%s', '%s', '%s', %d, '%s', %d, '%s')", + $row->username, $row->password, $row->email, $row->active, $row->signature, $row->date_added, (3600*$row->tz_offset)); + $uid = db_last_insert_id('users', 'uid'); + } db_query("INSERT INTO {phorum_tmp_user_join} (phorum, drupal) VALUES(%d, %d)", $row->user_id, $uid); db_query("INSERT INTO {phorum_users} (uid, email_notify, post_count) VALUES(%d, %d, %d)", $uid, $row->email_notify, $row->posts); @@ -239,6 +245,11 @@ db_set_active('phorum'); $rs = db_query("SELECT name, description, display_order AS weight, folder_flag, forum_id FROM $table WHERE forum_id > %d ORDER BY forum_id ASC", $start_id); while (($term = db_fetch_array($rs)) && ($end_time > time())) { + /// hack for https://mimo.gn.apc.org/gps/forum +// if (trim($term['name']) != 'gps forum') { +// continue; +// } + /// /hack db_set_active(); $term['vid'] = $forum_vid; taxonomy_save_term($term); @@ -292,6 +303,9 @@ // can not use node_save since that would overwrite the created and modify timestamps if ($row->parent_id == 0) { $tid = db_result(db_query("SELECT drupal FROM {phorum_tmp_forum_join} WHERE phorum = %d", $row->forum_id)); + if ($tid == 0) { + continue; + } if ($row->message_id != $row->thread) { // we have a moved topic's left-behind entry at hand // Phorum: when moving a topic they have rewritten the forum_id then @@ -299,23 +313,36 @@ // topic starter message $nid = db_result(db_query("SELECT nid FROM {phorum_tmp_message_join} WHERE phorum = %d", $row->thread)); db_query("INSERT INTO {term_node} (nid, tid) VALUES(%d, %d)", $nid, $tid); - } - else { + } else { // we have a topic at hand - $nid = db_next_id('{node}_nid'); - $vid = db_next_id('{node_revisions}_vid'); - db_query("INSERT INTO {forum} (nid, vid, tid) VALUES(%d, %d, %d)", $nid, $vid, $tid); - db_query("INSERT INTO {term_node} (nid, tid) VALUES(%d, %d)", $nid, $tid); - // for the changed filed we can not use the Phorum's modifydate Phorum sets that for the last message's timestamp in the said thread - db_query("INSERT INTO {node} - (nid, vid, type, title, uid, status, created, changed, comment, promote, moderate, sticky) - VALUES(%d, %d, '%s', '%s', %d, %d, %d, %d, %d, %d, %d, %d)", - $nid, $vid, 'forum', $row->subject, $uid, ($row->status == 2), $row->datestamp, - $row->datestamp, ($row->closed == 0 ? 2 : 1), 0, ($row->status == -1), ($row->sort == 1)); + $nid = 0; db_query("INSERT INTO {node_revisions} - (nid, vid, uid, title, body, teaser, log, timestamp, format) - VALUES(%d, %d, %d, '%s', '%s', '%s', '%s', %d, %d)", $nid, $vid, $uid, $row->subject, + (nid, uid, title, body, teaser, log, timestamp, format) + VALUES(%d, %d, '%s', '%s', '%s', '%s', %d, %d)", $nid, $uid, $row->subject, $row->body, $row->body, '', $row->datestamp, variable_get('phorum_converter_msg_format', 1)); + $vid = db_last_insert_id('node_revisions', 'vid'); + if (!$vid) { + watchdog('phorum converter', t('trouble no vid.')); + exit; + } + db_query("INSERT INTO {node} + (vid, type, title, uid, status, created, changed, comment, promote, moderate, sticky) + VALUES(%d, '%s', '%s', %d, %d, %d, %d, %d, %d, %d, %d)", + $vid, 'forum', $row->subject, $uid, ($row->status == 2), $row->datestamp, + $row->datestamp, ($row->closed == 0 ? 2 : 1), 0, ($row->status == -1), ($row->sort == 1)); + + $nid = db_last_insert_id('node', 'nid'); + if (!$nid) { + watchdog('phorum converter', t('trouble no nid.')); + exit; + } + db_query("UPDATE {node_revisions} SET nid=%d WHERE vid=%d", $nid, $vid); + db_query("INSERT INTO {forum} (nid, vid, tid) VALUES(%d, %d, %d)", $nid, $vid, $tid); + db_query("INSERT INTO {term_node} (nid, vid, tid) VALUES(%d, %d, %d)", $nid, $vid, $tid); + + // for the changed filed we can not use the Phorum's modifydate Phorum sets that for the last message's timestamp in the said thread + + db_query("INSERT INTO {node_comment_statistics} (nid, last_comment_timestamp, last_comment_name, last_comment_uid, comment_count) VALUES(%d, %d, '%s', %d, %d)", $nid, $row->datestamp, NULL, $uid, 0); @@ -327,14 +354,20 @@ // comment parent id $pid = $row2->drupal; $nid = $row2->nid; - $cid = db_next_id('{comments}_cid'); +// $cid = db_next_id('{comments}_cid'); $thread = _phorum_convert_determine_thread($pid, $nid); // Phorum's modifystamp is only set at the topic starter messages, therefore it will be 0 here, so the timestamp will be the createdate db_query("INSERT INTO {comments} - (cid, pid, nid, uid, subject, comment, hostname, timestamp, score, status, format, thread) - VALUES(%d, %d, %d, %d, '%s', '%s', '%s', %d, %d, %d, %d, '%s')", - $cid, $pid, $nid, $uid, $row->subject, $row->body, $row->ip, $row->datestamp, 0, + (pid, nid, uid, subject, comment, hostname, timestamp, status, format, thread) + VALUES(%d, %d, %d, '%s', '%s', '%s', %d, %d, %d, '%s')", + $pid, $nid, $uid, $row->subject, $row->body, $row->ip, $row->datestamp, (($row->status == 2) ? COMMENT_PUBLISHED : COMMENT_NOT_PUBLISHED), variable_get('phorum_converter_msg_format', 1), $thread); + $cid = db_last_insert_id('comments', 'cid'); + if (!$cid) { + watchdog('phorum converter', t('trouble no cid.')); + exit; + } + db_query("UPDATE {node_comment_statistics} SET last_comment_timestamp = %d, last_comment_uid = %d, comment_count = comment_count +1 WHERE nid = %d", $row->datestamp, $uid, $nid); @@ -442,3 +475,12 @@ } return $thread; } +/** porting to d6 **/ +function _forum_get_vid() { + $vid = variable_get('forum_nav_vocabulary', ''); + if (!$vid) { + watchdog('phorum converter', t('The converter needs the forum module to be initialised.')); + exit; + } + return $vid; +} Only in phorum_converter/: phorum_converter.module~ Only in phorum.orig: README.txt