IMC-Drupal/Upgrade/FlexinodeToCCK

From Aktivix
Jump to navigation Jump to search


for IMC York upgrade

Converting Flexinode to CCK

Using Flexinode to CCK Coverter module

We just have flexinode-1 with fields:

mysql> select * from flexinode_field;
+----------+----------+---------------+---------------+--------+----------+-------------+------------+------+------------+-------------------+-------------------------------------------------+
| field_id | ctype_id | label         | default_value | weight | required | show_teaser | show_table | rows | field_type | options           | description                                     |
+----------+----------+---------------+---------------+--------+----------+-------------+------------+------+------------+-------------------+-------------------------------------------------+
|        1 |        1 | Details       |               |      0 |        1 |           0 |          0 |    5 | textarea   | a:1:{i:1;s:0:"";} | Details of event                                |
|        2 |        1 | Event website |               |      0 |        0 |           0 |          0 |    0 | url        | a:1:{i:1;s:0:"";} |                                                 |
|        3 |        1 | Location      |               |      0 |        0 |           1 |          0 |    0 | address    | a:1:{i:1;s:0:"";} |                                                 |
|        4 |        1 | Report        |               |      0 |        0 |           0 |          0 |    0 | url        | a:1:{i:1;s:0:"";} | add this after the event, when you report on it |
+----------+----------+---------------+---------------+--------+----------+-------------+------------+------+------------+-------------------+-------------------------------------------------+

Seems flexiconvert may not handle address field, there is no CCK type for this either. Converting this into a text area with newlines seems like the best option. The Report url can be lost as it was hardly, if ever, used. CCK gives much better link to other node option anyway.

  • Switch off flexinode before you can create CCK type with matching field names
  • First test, without the address field worked, and didn't copy the address - as predicted. Errors for each node
user warning: Unknown column 'field_details_format' in 'field list' query: UPDATE node_content_event SET field_details_format = '4' WHERE nid = 20 in /var/www/html/indymedia/york/drupal-4.7.0-multi-upgrade/includes/database.mysql.inc on line 120.

and for one node

user warning: Unknown column 'field_report_url' in 'field list' query: UPDATE node_content_event SET field_report_url = 'The attached timetable has complete details of the day\'s discussions. Speakers include Kate Hudson, Chair of CND.\r\n<IMG SRC=\"http://york.indymedia.org.uk/files/yimc/YATW.jpg\" align=\"right\" alt=\"York Against The War\">\r\nLively topics include lectures and discussion on:-<UL><LI>Project for the New American Century.\r\n<LI>War, Racism and Islamophobia\r\n<LI>Folk, Peace and Protest, a musical talk\r\n<LI>The Archaeology of War and Peace\r\n<LI>The new Nuclear Hypocrisy\r\n<LI>Iran -A history of Western Intervention\r\n<LI>Iraq - The legacy of invasion and occupation\r\n<LI>Women in Iraq today.\r\n</UL>\r\n\r\nCost is £5 for the day (£3 concessions), you can book by sending a cheque made payable to \"York Against the War\" to Friend\'s Meeting House, Friargate, York, or you can pay on the day (it looks like some tickets will be available then).' WHERE nid = 72 in /var/www/html/indymedia/york/drupal-4.7.0-multi-upgrade/includes/database.mysql.inc on line 120.
  • To insert address fields into a text field. Added this to the module.
diff -urNp flexiconvert.orig/flexiconvert.module flexiconvert/flexiconvert.module
--- flexiconvert.orig/flexiconvert.module       2007-04-02 22:53:39.000000000 +0100
+++ flexiconvert/flexiconvert.module    2007-04-15 16:40:57.000000000 +0100
@@ -74,6 +74,9 @@ function flexiconvert_form_submit($form_
         $nodes[ $row['nid'] ][$cckfield]['text'] = $row['textual_data'];
         $nodes[ $row['nid'] ][$cckfield]['format'] = $row['numeric_data'];
       }
+      else if ($row['field_type'] == 'address') {
+        $nodes[ $row['nid'] ][$cckfield]['address'] = $row['serialized_data'];
+      }
       else if ($row['field_type'] == 'image') {
         $nodes[ $row['nid'] ][$cckfield]['image'] = $row['serialized_data'];
       }
@@ -117,6 +120,11 @@ function flexiconvert_form_submit($form_
       else if ($value['url']) {
         db_query( "UPDATE {%s} SET %s = '%s' WHERE nid = %d", $cck_table,  $cckfield . '_url', $value['url'],  $nid);
       }
+      else if ($value['address']) {
+        $address = unserialize($value['address']);
+        $address = implode(" \n",$address);
+        db_query( "UPDATE {%s} SET %s = '%s' WHERE nid = %d", $cck_table,  $cckfield . '_value', $address, $nid );
+      }
       else if ($value['text']) {
         db_query( "UPDATE {%s} SET %s = '%s' WHERE nid = %d", $cck_table,  $cckfield . '_value', $value['text'], $nid );
         if( $value['format'] != 0 ) {