/[drupal]/contributions/modules/imc_alba/dadamigrate/dadamigrate.install
ViewVC logotype

Contents of /contributions/modules/imc_alba/dadamigrate/dadamigrate.install

Parent Directory Parent Directory | Revision Log Revision Log | View Revision Graph Revision Graph


Revision 1.7 - (show annotations) (download) (as text)
Sat May 17 15:16:28 2008 UTC (18 months, 1 week ago) by tomm
Branch: MAIN
CVS Tags: DRUPAL-6--1-4, DRUPAL-6--1-5, DRUPAL-6--1-0, DRUPAL-6--1-1, DRUPAL-6--1-2, DRUPAL-6--1-3, HEAD
Branch point for: DRUPAL-6--1
Changes since 1.6: +6 -1 lines
File MIME type: text/x-php
*** empty log message ***
1 <?php
2
3 function dadamigrate_update_1() {
4 // Put authors into nodextradata, instead of the silly old way.
5 // This shouldn't take too long, so be lazy instead of using a batch thing
6 set_time_limit(0);
7 $re = "/^(<!--break-->)?<p><em class=\"attribution\">BY ([^<]*)<\/em><\/p>/";
8 $q = db_query('SELECT nid,vid,body,teaser FROM {node_revisions}');
9 while ($x = db_fetch_array($q)) {
10 $regs = null;
11 preg_match($re, $x['body'], $regs);
12 if ($regs) {
13 //print '<p>NID '.$x['nid'].': '.$regs[1];
14 $x['body'] = preg_replace($re, '', $x['body']);
15 db_query('INSERT INTO {nodextradata} (nid, author) VALUES (%d,"%s")', $x['nid'], $regs[2]);
16 db_query('UPDATE {node_revisions} SET body="%s" WHERE nid=%d AND vid=%d', $x['body'], $x['nid'], $x['vid']);
17 }
18 preg_match($re, $x['teaser'], $regs);
19 if ($regs) {
20 $x['teaser'] = preg_replace($re, '', $x['teaser']);
21 db_query('UPDATE {node_revisions} SET teaser="%s" WHERE nid=%d AND vid=%d', $x['teaser'], $x['nid'], $x['vid']);
22 }
23 }
24 return array();
25 }
26
27
28 function dadamigrate_schema() {
29 $schema['dada_articles'] = array(
30 'fields' => array(
31 'objectid' => array(
32 'type' => 'int',
33 'unsigned' => TRUE,
34 'not null' => TRUE,
35 'default' => '0'),
36 'nid' => array(
37 'type' => 'int',
38 'unsigned' => TRUE,
39 'not null' => TRUE,
40 'default' => '0'),
41 ),
42 'primary key' => array('objectid'),
43 );
44 $schema['dada_features'] = array(
45 'fields' => array(
46 'objectid' => array(
47 'type' => 'int',
48 'unsigned' => TRUE,
49 'not null' => TRUE,
50 'default' => '0'),
51 'nid' => array(
52 'type' => 'int',
53 'unsigned' => TRUE,
54 'not null' => TRUE,
55 'default' => '0'),
56 ),
57 'primary key' => array('objectid'),
58 );
59 $schema['dada_media'] = array(
60 'fields' => array(
61 'objectid' => array(
62 'type' => 'int',
63 'unsigned' => TRUE,
64 'not null' => TRUE,
65 'default' => '0'),
66 'nid' => array(
67 'type' => 'int',
68 'unsigned' => TRUE,
69 'not null' => TRUE,
70 'default' => '0'),
71 ),
72 'primary key' => array('objectid'),
73 );
74 $schema['dada_otherpress'] = array(
75 'fields' => array(
76 'objectid' => array(
77 'type' => 'int',
78 'unsigned' => TRUE,
79 'not null' => TRUE,
80 'default' => '0'),
81 'nid' => array(
82 'type' => 'int',
83 'unsigned' => TRUE,
84 'not null' => TRUE,
85 'default' => '0'),
86 ),
87 'primary key' => array('objectid'),
88 );
89 $schema['dada_comments'] = array(
90 'fields' => array(
91 'objectid' => array(
92 'type' => 'int',
93 'unsigned' => TRUE,
94 'not null' => TRUE,
95 'default' => '0'),
96 'nid' => array(
97 'type' => 'int',
98 'unsigned' => TRUE,
99 'not null' => TRUE,
100 'default' => '0'),
101 ),
102 'primary key' => array('objectid'),
103 );
104 return $schema;
105 }
106
107 function dadamigrate_install() {
108 drupal_install_schema('dadamigrate');
109 }
110
111 function dadamigrate_uninstall() {
112 drupal_uninstall_schema('dadamigrate');
113 }

  ViewVC Help
Powered by ViewVC 1.1.2