"function"); $sql_updates = array( 'CivicSpace 0.1 to 0.2' => 'civic_update_1', 'CivicSpace 0.2 to 0.3' => 'civic_update_2', // no db updates for 0.3 to 0.4 'CivicSpace 0.4 to 0.5' => 'civic_update_4', 'CivicSpace 0.5 to 0.6' => 'civic_update_5', 'CivicSpace 0.6 to 0.7' => 'civic_update_6', 'CivicSpace 0.7 to 0.7.1' => 'civic_update_7', 'CivicSpace 0.7.1 to 0.8.0' => 'civic_update_8', // no db updates for 0.8.0 to 0.8.0.1 'CivicSpace 0.8.0.1 to 0.8.0.2' => 'civic_update_9', 'CivicSpace 0.8.0.2 to 0.8.0.3' => 'civic_update_10' ); function civic_update_1() { $ret = array(); $ret[] = update_sql("ALTER TABLE {contact} DROP first_name"); $ret[] = update_sql("ALTER TABLE {contact} DROP first_name_csid"); $ret[] = update_sql("ALTER TABLE {contact} DROP last_name"); $ret[] = update_sql("ALTER TABLE {contact} DROP last_name_csid"); $ret[] = update_sql("ALTER TABLE {contact} DROP city"); $ret[] = update_sql("ALTER TABLE {contact} DROP city_csid"); $ret[] = update_sql("ALTER TABLE {contact} DROP state"); $ret[] = update_sql("ALTER TABLE {contact} DROP state_csid"); $ret[] = update_sql("ALTER TABLE {contact} DROP zip"); $ret[] = update_sql("ALTER TABLE {contact} DROP zip_csid"); $ret[] = update_sql("ALTER TABLE {form_fields} ADD multiple tinyint(1) NOT NULL default '0'"); $ret[] = update_sql("CREATE TABLE {mailhandler} ( mid int(10) unsigned NOT NULL auto_increment, mail varchar(255) NOT NULL default '', domain varchar(255) NOT NULL default '', port int(5) unsigned NOT NULL default '0', name varchar(255) NOT NULL default '', pass varchar(255) NOT NULL default '', security tinyint(3) unsigned NOT NULL default '0', mime varchar(128) default NULL, replies tinyint(3) unsigned NOT NULL default '1', fromheader varchar(128) default NULL, commands text, sigseparator varchar(128) default NULL, enabled tinyint(4) default NULL, folder varchar(255) NOT NULL default '', imap tinyint(3) unsigned NOT NULL default '0', mailto varchar(255) NOT NULL default '', PRIMARY KEY (mid), KEY mail (mail) )"); $ret[] = update_sql("CREATE TABLE {menu} ( mid int(10) unsigned NOT NULL auto_increment, name varchar(255) NOT NULL default '', description text, weight tinyint(4) NOT NULL default '0', roles varchar(255) default '', vocabularies varchar(255) default '', PRIMARY KEY (mid), KEY name (name) )"); $ret[] = update_sql("CREATE TABLE {menu_hierarchy} ( iid int(10) unsigned NOT NULL default '0', parent int(10) unsigned NOT NULL default '0', KEY iid (iid), KEY parent (parent) )"); $ret[] = update_sql("CREATE TABLE {menu_item} ( iid int(10) unsigned NOT NULL auto_increment, mid int(10) unsigned NOT NULL default '0', name varchar(255) NOT NULL default '', description text, url varchar(255) NOT NULL default '', weight tinyint(4) NOT NULL default '0', enable int(1) unsigned NOT NULL default '0', roles varchar(255) default '', terms varchar(255) default '', PRIMARY KEY (iid), KEY mid (mid) )"); $ret[] = update_sql("CREATE TABLE {notify} ( uid int(10) unsigned NOT NULL default '0', status tinyint(2) NOT NULL default '0', node tinyint(2) NOT NULL default '0', comment tinyint(2) NOT NULL default '0', attempts tinyint(4) NOT NULL default '0', teasers tinyint(4) NOT NULL default '0', PRIMARY KEY (uid) )"); $ret[] = update_sql("ALTER TABLE {users} DROP contact_first_name"); $ret[] = update_sql("ALTER TABLE {users} DROP contact_last_name"); $ret[] = update_sql("ALTER TABLE {users} DROP contact_city"); $ret[] = update_sql("ALTER TABLE {users} DROP contact_state"); $ret[] = update_sql("ALTER TABLE {users} DROP contact_zip"); return $ret; } function civic_update_2() { $ret = array(); $ret[] = update_sql("ALTER TABLE {event} ADD {galleries} VARCHAR(100);"); $ret[] = update_sql("CREATE TABLE {image} ( nid int(10) unsigned NOT NULL default '0', image_path varchar(255) NOT NULL default '', thumb_path varchar(255) NOT NULL default '', preview_path varchar(255) NOT NULL default '', format varchar(255) NOT NULL default '', width int(10) unsigned NOT NULL default '0', height int(10) unsigned NOT NULL default '0', filesize int(10) unsigned NOT NULL default '0', iptc text, exif text, personal tinyint(4) NOT NULL default '0', weight tinyint(4) NOT NULL default '0', KEY nid (nid) )"); return $ret; } function civic_update_4() { $ret = array(); // listhandler update $ret[] = update_sql('ALTER TABLE {listhandler} CHANGE msgid msgid varchar(255) NOT NULL'); // new buddylist module $ret[] = update_sql('CREATE TABLE {buddylist} ( uid int(10) UNSIGNED NOT NULL, buddy int(10) UNSIGNED NOT NULL, timestamp int(11) NOT NULL, PRIMARY KEY (uid, buddy) )'); $ret[] = update_sql('ALTER TABLE {buddylist} ADD received tinyint(1) NOT NULL'); // event update $ret[] = update_sql('CREATE TABLE {event_field_data} ( name varchar(128) NOT NULL default \'0\', nid int(10) NOT NULL default \'0\', data text NOT NULL, PRIMARY KEY (name, nid) )'); $ret[] = update_sql('ALTER TABLE {event} CHANGE galleries galleries varchar(255) NOT NULL default \'0\''); $ret[] = update_sql('ALTER TABLE {event} DROP data'); $fields = db_query('SELECT name FROM {form_fields} WHERE fid = %d', variable_get('event_forms_fid', 0)); while ($field = db_fetch_object($fields)) { $result = db_query('SELECT nid, '. $field->name .' AS data FROM {event}'); while ($row = db_fetch_object($result)) { db_query('INSERT INTO {event_field_data} (name, nid, data) VALUES (\'%s\', %d, \'%s\') ', $field->name, $row->nid, $row->data); } $ret[] = update_sql('ALTER TABLE {event} DROP '. $field->name); } $ret[] = update_sql('ALTER TABLE {event} ADD INDEX (start)'); // aggregator updates $ret[] = update_sql('ALTER TABLE {bundle} RENAME TO {aggregator_category}'); $ret[] = update_sql('ALTER TABLE {aggregator_category} DROP attributes'); $ret[] = update_sql('ALTER TABLE {aggregator_category} CHANGE bid cid int(10) NOT NULL auto_increment'); $ret[] = update_sql('ALTER TABLE {aggregator_category} ADD description longtext NOT NULL'); $ret[] = update_sql('UPDATE {sequences} SET name = \'{aggregator_category}_cid\' WHERE name = \'{bundle}_bid\''); $ret[] = update_sql('ALTER TABLE {feed} RENAME TO {aggregator_feed}'); $ret[] = update_sql('ALTER TABLE {aggregator_feed} DROP attributes'); $ret[] = update_sql('ALTER TABLE {aggregator_feed} ADD block tinyint(2) NOT NULL'); $ret[] = update_sql('ALTER TABLE {aggregator_category} ADD block tinyint(2) NOT NULL'); $ret[] = update_sql('UPDATE {sequences} SET name = \'{aggregator_feed}_fid\' WHERE name = \'{feed}_fid\''); $ret[] = update_sql('ALTER TABLE {item} RENAME TO {aggregator_item}'); $ret[] = update_sql('ALTER TABLE {aggregator_item} DROP attributes'); /* replaced by a more working update $max = db_result(db_query_range('SELECT iid FROM {aggregator_item} ORDER BY iid DESC', 1, 1)); if ($max) { $ret[] = update_sql('INSERT INTO {sequences} (name, id) VALUES (\'{aggregator_item}_iid\', $max)'); } */ $ret[] = update_sql('CREATE TABLE {aggregator_category_feed} ( fid int(10) NOT NULL, cid int(10) NOT NULL, PRIMARY KEY (fid, cid) )'); $ret[] = update_sql('CREATE TABLE {aggregator_category_item} ( iid int(10) NOT NULL, cid int(10) NOT NULL, PRIMARY KEY (iid, cid) )'); // survey module $ret[] = update_sql('CREATE TABLE {survey} ( nid int(11) unsigned not null, fid int(11) not null, email text, result_page text, primary key(nid) )'); $ret[] = update_sql('CREATE TABLE {survey_responses} ( rid int(11) unsigned not null, nid int(11) unsigned not null, uid int(11) unsigned not null, created int(11) not null, primary key (rid) )'); $ret[] = update_sql('CREATE TABLE {survey_fields} ( rid int(11) unsigned not null, ffid int(11) not null, value text, primary key (rid, ffid) )'); // rsvp module $ret[] = update_sql('CREATE TABLE {rsvp} ( rid int(10) unsigned NOT NULL auto_increment, nid int(10) unsigned NOT NULL default \'0\', uid int(10) unsigned NOT NULL default \'0\', name varchar(128) default \'\', invite_text text, blind int(3) unsigned NOT NULL default \'0\', list_email int(3) unsigned NOT NULL default \'0\', allow_invite int(3) unsigned NOT NULL default \'0\', timestamp int(10) unsigned NOT NULL default \'0\', PRIMARY KEY (rid,uid,nid) )'); $ret[] = update_sql('CREATE TABLE {rsvp_event} ( type enum(\'reminder\',\'update\') default NULL, rid int(10) unsigned NOT NULL default \'0\', content text, trigger_date int(10) unsigned NOT NULL default \'0\', PRIMARY KEY (rid) )'); $ret[] = update_sql('CREATE TABLE {rsvp_to_user} ( response enum(\'yes\',\'no\',\'maybe\',\'none\') NOT NULL default \'none\', rid int(10) unsigned NOT NULL default \'0\', uid int(10) NOT NULL default \'0\', email varchar(128) NOT NULL default \'\', hash varchar(255) NOT NULL default \'\', invited int(10) unsigned NOT NULL default \'0\', received int(10) unsigned NOT NULL default \'0\', timestamp int(10) unsigned NOT NULL default \'0\', PRIMARY KEY (rid,email,uid) )'); $ret[] = update_sql('CREATE TABLE {rsvp_user_prefs} ( require_login int(4) unsigned NOT NULL default \'0\', uid int(10) unsigned NOT NULL default \'0\', notification int(4) unsigned NOT NULL default \'0\', blind int(4) unsigned NOT NULL default \'0\', PRIMARY KEY (uid) )'); // event aggreagation $ret[] = update_sql('CREATE TABLE {event_item} ( iid int(10) unsigned NOT NULL, nid int(10) unsigned NOT NULL, latitude decimal(10,6) NOT NULL, longitude decimal(10,6) NOT NULL, PRIMARY KEY (iid), UNIQUE KEY (nid), INDEX (latitude), INDEX (longitude) )'); return $ret; } function civic_update_5() { $ret = array(); $max = db_result(db_query_range('SELECT iid FROM {aggregator_item} ORDER BY iid DESC', 0, 1)); if ($max) { $ret[] = update_sql('REPLACE INTO {sequences} (name, id) VALUES (\'{aggregator_item}_iid\', '. $max .')'); } return $ret; } function civic_update_6() { $ret = array(); // contact updates $ret[] = update_sql('ALTER TABLE {contact} DROP mail_csid'); $ret[] = update_sql('ALTER TABLE {contact_source_list} RENAME TO {contact_sources}'); $ret[] = update_sql('CREATE TABLE {contact_data} ( nid int(10) unsigned NOT NULL, csid int(10) unsigned NOT NULL, ffid int(10) unsigned NOT NULL, active tinyint(1) unsigned NOT NULL, data text NOT NULL, PRIMARY KEY (nid, csid, ffid), INDEX (active), INDEX (data(16)) )'); $ret[] = update_sql('DROP TABLE {contact_source}'); $fields = db_query('SELECT name, ffid FROM {form_fields} WHERE fid = %d', variable_get('contact_forms_fid', 0)); while ($field = db_fetch_object($fields)) { $result = db_query('SELECT nid, '. $field->name .' AS data, '. $field->name .'_csid AS csid FROM {contact}'); while ($row = db_fetch_object($result)) { db_query('INSERT INTO {contact_data} (nid, csid, ffid, data, active) VALUES (%d, %d, %d, \'%s\', 1) ', $row->nid, $row->csid, $field->ffid, $row->data); } $ret[] = update_sql('ALTER TABLE {contact} DROP '. $field->name); $ret[] = update_sql('ALTER TABLE {contact} DROP '. $field->name .'_csid'); $ret[] = update_sql('ALTER TABLE {users} DROP contact_'. $field->name); } // new volunteer module $ret[] = update_sql('CREATE TABLE {volunteer} ( eid int(10) unsigned NOT NULL, wanted int(3) default \'2\', uid int(11), message_approve text, message_deny text, message_wait text, message_reminder text, message_follow_up text, PRIMARY KEY (eid) )'); $ret[] = update_sql('CREATE TABLE {volunteer_contact_event} ( cid int(10) unsigned NOT NULL, rating int(2), comments text, eid int(10) unsigned NOT NULL, stage int(2) unsigned )'); return $ret; } function civic_update_7() { $ret = array(); if (db_num_rows('SELECT id FROM {sequences} WHERE name = \'{contact_sources}_csid\'') == 0) { $ret[] = update_sql('UPDATE {sequences} SET name = \'{contact_sources}_csid\' WHERE name = \'{contact_source_list}_csid\''); } // adding private message module $ret[] = update_sql('CREATE TABLE {privatemsg} ( id int(10) unsigned NOT NULL auto_increment, author int(10) unsigned NOT NULL default \'0\', recipient int(10) unsigned NOT NULL default \'0\', subject varchar(64) NOT NULL default \'\', message text, timestamp int(11) unsigned NOT NULL default \'0\', new tinyint(3) unsigned NOT NULL default \'0\', hostname varchar(255) NOT NULL default \'\', folder int(10) unsigned NOT NULL default \'0\', author_del tinyint(3) unsigned NOT NULL default \'0\', recipient_del tinyint(3) unsigned NOT NULL default \'0\', PRIMARY KEY (id), KEY recipient (recipient), KEY folder (folder) )'); $ret[] = update_sql('CREATE TABLE {privatemsg_archive} ( id int(10) unsigned NOT NULL auto_increment, author int(10) unsigned NOT NULL default \'0\', recipient int(10) unsigned NOT NULL default \'0\', subject varchar(64) NOT NULL default \'\', message text NOT NULL, timestamp int(11) unsigned NOT NULL default \'0\', hostname varchar(255) NOT NULL default \'\', folder int(10) unsigned NOT NULL default \'0\', PRIMARY KEY (id), KEY recipient (recipient) )'); $ret[] = update_sql('CREATE TABLE {privatemsg_folder} ( fid int(10) unsigned NOT NULL auto_increment, uid int(10) unsigned NOT NULL default \'0\', name varchar(255) NOT NULL default \'\', PRIMARY KEY (fid) )'); $ret[] = update_sql('INSERT INTO {privatemsg_folder} VALUES (1,0,\'Sent\') '); // simple story creation from RSS items $ret[] = update_sql('CREATE TABLE {story_item} ( iid int(10) unsigned NOT NULL default \'0\', nid int(10) unsigned NOT NULL default \'0\', PRIMARY KEY (iid), UNIQUE KEY nid (nid) )'); return $ret; } function civic_update_8() { $ret = array(); // Remove the navigation module $ret[] = update_sql('DROP TABLE {menu}'); $ret[] = update_sql('DROP TABLE {menu_item}'); $ret[] = update_sql('DROP TABLE {menu_hierarchy}'); // The Drupal 4.4.x -> 4.5.x updates $ret = array_merge($ret, update_80()); $ret = array_merge($ret, update_81()); $ret = array_merge($ret, update_82()); $ret = array_merge($ret, update_83()); $ret = array_merge($ret, update_84()); // update 85 is not applicable because it is for the aggregator module $ret = array_merge($ret, update_86()); $ret = array_merge($ret, update_87()); $ret = array_merge($ret, update_88()); $ret = array_merge($ret, update_89()); $ret = array_merge($ret, update_90()); $ret = array_merge($ret, update_91()); $ret = array_merge($ret, update_92()); $ret = array_merge($ret, update_93()); $ret = array_merge($ret, update_94()); $ret = array_merge($ret, update_95()); $ret = array_merge($ret, update_96()); $ret = array_merge($ret, update_97()); $ret = array_merge($ret, update_98()); $ret = array_merge($ret, update_99()); $ret = array_merge($ret, update_100()); $ret = array_merge($ret, update_101()); $ret = array_merge($ret, update_102()); $ret = array_merge($ret, update_103()); $ret = array_merge($ret, update_104()); $ret = array_merge($ret, update_105()); $ret = array_merge($ret, update_106()); $ret = array_merge($ret, update_107()); $ret = array_merge($ret, update_108()); $ret = array_merge($ret, update_109()); // Add phplist module $ret[] = update_sql("CREATE TABLE {phplist_config} ( item varchar(35) NOT NULL default '', value longtext, editable tinyint(4) default '1', type varchar(25) default NULL, PRIMARY KEY (item) )"); $ret[] = update_sql("CREATE TABLE {phplist_contact_searches} ( csid int(10) unsigned NOT NULL default '0', lid int(10) unsigned NOT NULL default '0', PRIMARY KEY (csid,lid) )"); $ret[] = update_sql("CREATE TABLE {phplist_list} ( public tinyint(1) NOT NULL default '0', id int(11) NOT NULL auto_increment, name varchar(255) NOT NULL default '', description text, entered datetime default NULL, listorder int(11) default NULL, prefix varchar(10) default NULL, rssfeed varchar(255) default NULL, modified timestamp(14) NOT NULL, active tinyint(4) default NULL, owner int(11) default NULL, PRIMARY KEY (id) )"); $ret[] = update_sql("CREATE TABLE {phplist_listmessage} ( id int(11) NOT NULL auto_increment, messageid int(11) NOT NULL default '0', listid int(11) NOT NULL default '0', entered datetime default NULL, modified timestamp(14) NOT NULL, PRIMARY KEY (id), UNIQUE KEY messageid (messageid,listid) )"); $ret[] = update_sql("CREATE TABLE {phplist_listuser} ( userid int(11) NOT NULL default '0', listid int(11) NOT NULL default '0', entered datetime default NULL, modified timestamp(14) NOT NULL, PRIMARY KEY (userid,listid) )"); $ret[] = update_sql("CREATE TABLE {phplist_message} ( id int(11) NOT NULL auto_increment, subject varchar(255) NOT NULL default '', fromfield varchar(255) NOT NULL default '', tofield varchar(255) NOT NULL default '', replyto varchar(255) NOT NULL default '', message text, textmessage text, footer text, entered datetime default NULL, modified timestamp(14) NOT NULL, embargo datetime default NULL, repeat int(11) default '0', repeatuntil datetime default NULL, status enum('submitted','inprocess','sent','cancelled','prepared','draft') default NULL, userselection text, sent datetime default NULL, htmlformatted tinyint(4) default '0', sendformat varchar(20) default NULL, template int(11) default NULL, processed mediumint(8) unsigned default '0', astext int(11) default '0', ashtml int(11) default '0', astextandhtml int(11) default '0', aspdf int(11) default '0', astextandpdf int(11) default '0', viewed int(11) default '0', bouncecount int(11) default '0', sendstart datetime default NULL, rsstemplate varchar(100) default NULL, owner int(11) default NULL, PRIMARY KEY (id) )"); $ret[] = update_sql("CREATE TABLE {phplist_rssitem} ( id int(11) NOT NULL auto_increment, title varchar(100) NOT NULL default '', link varchar(100) NOT NULL default '', source varchar(255) default NULL, list int(11) default NULL, added datetime default NULL, processed mediumint(8) unsigned default '0', astext int(11) default '0', ashtml int(11) default '0', PRIMARY KEY (id), KEY title (title,link) )"); $ret[] = update_sql("CREATE TABLE {phplist_sendprocess} ( id int(11) NOT NULL auto_increment, started datetime default NULL, modified timestamp(14) NOT NULL, alive int(11) default '1', ipaddress varchar(50) default NULL, page varchar(100) default NULL, PRIMARY KEY (id) )"); $ret[] = update_sql("CREATE TABLE {phplist_user_attribute} ( id int(11) NOT NULL auto_increment, name varchar(255) NOT NULL default '', type varchar(30) default NULL, listorder int(11) default NULL, default_value varchar(255) default NULL, required tinyint(4) default NULL, tablename varchar(255) default NULL, PRIMARY KEY (id) )"); $ret[] = update_sql("CREATE TABLE {phplist_user_rss} ( userid int(11) NOT NULL default '0', last datetime default NULL, PRIMARY KEY (userid) )"); $ret[] = update_sql("CREATE TABLE {phplist_user_user} ( id int(11) NOT NULL auto_increment, drupalid int(10) unsigned NOT NULL default '0', email varchar(255) NOT NULL default '', confirmed tinyint(4) default '0', bouncecount int(11) default '0', entered datetime default NULL, modified timestamp(14) NOT NULL, uniqid varchar(255) default NULL, htmlemail tinyint(4) default '0', subscribepage int(11) default NULL, rssfrequency varchar(100) default NULL, password varchar(255) default NULL, passwordchanged date default NULL, disabled tinyint(4) default '0', extradata text, foreignkey varchar(100) default NULL, PRIMARY KEY (id), UNIQUE KEY email (email), KEY idx_phplist_user_user_uniqid (uniqid) )"); $ret[] = update_sql("CREATE TABLE {phplist_usermessage} ( messageid int(11) NOT NULL default '0', userid int(11) NOT NULL default '0', entered timestamp(14) NOT NULL, viewed datetime default NULL, PRIMARY KEY (userid,messageid) )"); // Add trackback module $ret[] = update_sql('CREATE TABLE {trackback_received} ( nid int(10) unsigned NOT NULL, cid int(10) unsigned NOT NULL, url varchar(255) NOT NULL default \'\', PRIMARY KEY (nid, cid) )'); $ret[] = update_sql('CREATE TABLE {trackback_sent} ( nid int(10) unsigned NOT NULL, url varchar(255) NOT NULL default \'\', successful tinyint(1) NOT NULL, PRIMARY KEY (nid, url) )'); // image module update if ($GLOBALS["db_type"] == "pgsql") { $ret[] = update_sql("ALTER TABLE {image} ADD image_list(carchar(255))"); } else { $ret[] = update_sql("ALTER TABLE {image} ADD image_list LONGTEXT"); } // mailhandler update $ret[] = update_sql("ALTER TABLE {mailhandler} ADD delete_after_read tinyint unsigned not null default '1'"); // flexinode update $ret[] = update_sql("ALTER TABLE {flexinode_field} ADD show_teaser int(1) NOT NULL default '0'"); $ret[] = update_sql("ALTER TABLE {flexinode_field} ADD show_table int(1) NOT NULL default '0'"); // set the theme to democratica $ret[] = update_sql("DELETE FROM {system} WHERE name = 'democratica'"); $ret[] = update_sql("REPLACE INTO {system} VALUES ('themes/engines/phptemplate/phptemplate.engine','phptemplate','theme_engine','',1,0,0)"); $ret[] = update_sql("REPLACE INTO {system} VALUES ('themes/democratica/page.tpl.php','democratica','theme','themes/engines/phptemplate/phptemplate.engine',1,0,0)"); variable_set('theme_default', 'democratica'); variable_set('phptemplate_extra_templates', unserialize("a:1:{s:18:\"themes/democratica\";a:1:{s:31:\"themes/democratica/page.tpl.php\";O:8:\"stdClass\":2:{s:8:\"filename\";s:31:\"themes/democratica/page.tpl.php\";s:4:\"name\";s:8:\"page.tpl\";}}}")); variable_set('phptemplate_extra_logic', unserialize("a:1:{s:31:\"themes/democratica/template.php\";s:31:\"themes/democratica/template.php\";}")); variable_set('theme_democratica_settings', unserialize("a:9:{s:12:\"default_logo\";s:1:\"0\";s:9:\"logo_path\";s:0:\"\";s:11:\"toggle_name\";s:1:\"1\";s:13:\"toggle_slogan\";s:1:\"0\";s:14:\"toggle_mission\";s:1:\"1\";s:20:\"toggle_primary_links\";s:1:\"1\";s:22:\"toggle_secondary_links\";s:1:\"1\";s:24:\"toggle_node_user_picture\";s:1:\"0\";s:27:\"toggle_comment_user_picture\";s:1:\"0\";}")); return $ret; } function civic_update_9() { $ret = array(); // trackback updates $ret[] = update_sql('ALTER TABLE {trackback_received} ADD trid int(10) unsigned NOT NULL'); $ret[] = update_sql('ALTER TABLE {trackback_received} ADD created int(11) NOT NULL'); $ret[] = update_sql('ALTER TABLE {trackback_received} ADD site varchar(255) NOT NULL'); $ret[] = update_sql('ALTER TABLE {trackback_received} ADD name varchar(60) default NULL'); $ret[] = update_sql('ALTER TABLE {trackback_received} ADD subject varchar(64) NOT NULL'); $ret[] = update_sql('ALTER TABLE {trackback_received} ADD excerpt varchar(255) NOT NULL'); $ret[] = update_sql("CREATE TABLE {trackback_node} ( nid int(10) unsigned NOT NULL, awaiting_cron tinyint(1) NOT NULL, can_receive tinyint(1) NOT NULL, PRIMARY KEY (nid) )"); $result = db_query('SELECT tr.nid, tr.cid, c.timestamp, c.homepage, c.name, c.subject, c.comment FROM {trackback_received} tr LEFT JOIN {comments} c ON tr.cid = c.cid'); while ($trackback = db_fetch_object($result)) { $trid = db_next_id('{trackback_received}_trid'); db_query("UPDATE {trackback_received} SET trid = %d, created = %d, site = '%s', name = '%s', subject = '%s', excerpt = '%s' WHERE nid = %d AND cid = %d", $trid, $trackback->timestamp, $trackback->homepage, $trackback->name, $trackback->subject, $trackback->comment, $trackback->nid, $trackback->cid); _comment_delete_thread($trackback); _comment_update_node_statistics($trackback->nid); } $ret[] = update_sql('ALTER TABLE {trackback_received} DROP PRIMARY KEY'); $ret[] = update_sql('ALTER TABLE {trackback_received} DROP cid'); $ret[] = update_sql('ALTER TABLE {trackback_received} ADD PRIMARY KEY (trid)'); return $ret; } function civic_update_10() { $ret = array(); // Drupal 4.5.x update for comment counts. $ret = array_merge($ret, update_110()); // New wmfilter module. $ret[] = update_sql('CREATE TABLE {interwiki} ( iw_prefix char(32) NOT NULL, iw_url char(127) NOT NULL, iw_local BOOL NOT NULL, UNIQUE KEY iw_prefix (iw_prefix) )'); $ret[] = update_sql("INSERT INTO {interwiki} VALUES ('kos','http://www.dkosopedia.com/index.php/$1',1)"); $ret[] = update_sql("INSERT INTO {interwiki} VALUES ('w','http://en.wikipedia.org/wiki/$1',1)"); $ret[] = update_sql("INSERT INTO {interwiki} VALUES ('dis','http://www.disinfopedia.org/wiki.phtml?title=$1',1)"); // phplist database upgrade path 2.8.11 -> 2.9.3 $ret[] = update_sql('ALTER TABLE {phplist_user_user} ADD blacklisted tinyint default 0'); $ret[] = update_sql('CREATE TABLE {phplist_user_blacklist} ( email varchar(255) not null unique, added datetime )'); $ret[] = update_sql('CREATE TABLE {phplist_user_blacklist_data} ( email varchar(255) not null unique, name varchar(100), data text )'); $ret[] = update_sql('ALTER TABLE {phplist_message} CHANGE repeat repeatinterval INTEGER'); $ret[] = update_sql('CREATE TABLE {phplist_messagedata} ( name varchar(100) not null, id integer not null, data text, PRIMARY KEY (name, id) )'); $ret[] = update_sql('ALTER TABLE {phplist_usermessage} MODIFY entered datetime'); $ret[] = update_sql('ALTER TABLE {phplist_usermessage} ADD status varchar(255)'); $ret[] = update_sql('CREATE TABLE {phplist_sessiontable} ( sessionid CHAR(32) NOT NULL, lastactive INTEGER NOT NULL, data LONGTEXT, PRIMARY KEY (sessionid) )'); return $ret; } function update_80() { if ($GLOBALS['db_type'] == 'mysql') { // Add a 'created' field to the users table: $ret[] = update_sql('ALTER TABLE {users} ADD created INT(11) NOT NULL'); $ret[] = update_sql('ALTER TABLE {users} CHANGE timestamp changed INT(11) NOT NULL'); // Add some indices to speed up the update process: $ret[] = update_sql('ALTER TABLE {comments} ADD index (timestamp)'); $ret[] = update_sql('ALTER TABLE {node} ADD index (created)'); // Assign everyone a created timestamp to begin with: $ret[] = update_sql("UPDATE {users} SET created = changed WHERE created = ''"); } else { // Add a 'created' field to the users table: $ret[] = update_sql('ALTER TABLE {users} ADD created INTEGER'); $ret[] = update_sql("ALTER TABLE {users} ALTER COLUMN created SET DEFAULT '0'"); $ret[] = update_sql("UPDATE {users} SET created = 0"); $ret[] = update_sql("ALTER TABLE {users} ALTER COLUMN created SET NOT NULL"); $ret[] = update_sql('ALTER TABLE {users} RENAME timestamp TO changed'); $ret[] = update_sql("UPDATE {users} SET created = changed WHERE created = 0"); } // Print a status message:" print '
Note: this might take a while ...
'; // Try updating the user records using the comment table: $result = db_query('SELECT DISTINCT(u.uid) FROM {comments} c LEFT JOIN {users} u ON c.uid = u.uid WHERE c.timestamp < u.created'); while ($account = db_fetch_object($result)) { // Retrieve the proper timestamp: $timestamp = db_result(db_query('SELECT MIN(timestamp) FROM {comments} WHERE uid = %d', $account->uid)); // Update this user record as well as older records with an older timestamp: db_query('UPDATE {users} SET created = %d WHERE created > %d AND uid <= %d', $timestamp, $timestamp, $account->uid); } // Try updating the user records using the node table: $result = db_query('SELECT DISTINCT(u.uid) FROM {node} n LEFT JOIN {users} u ON n.uid = u.uid WHERE n.created < u.created'); while ($account = db_fetch_object($result)) { // Retrieve the proper timestamp: $timestamp = db_result(db_query('SELECT MIN(created) FROM {node} WHERE uid = %d', $account->uid)); // Update this user record as well as older records with an older timestamp: db_query('UPDATE {users} SET created = %d WHERE created > %d AND uid <= %d', $timestamp, $timestamp, $account->uid); } if ($GLOBALS['db_type'] == 'mysql') { // Add profile module related tables: $ret[] = update_sql("CREATE TABLE {profile_fields} ( fid int(10) NOT NULL auto_increment, title varchar(255) default NULL, name varchar(128) default NULL, explanation TEXT default NULL, category varchar(255) default NULL, type varchar(128) default NULL, weight tinyint(1) DEFAULT '0' NOT NULL, overview tinyint(1) DEFAULT '0' NOT NULL, options text, KEY category (category), UNIQUE KEY name (name), PRIMARY KEY (fid) );"); $ret[] = update_sql("CREATE TABLE {profile_values} ( fid int(11) unsigned default '0', uid int(11) unsigned default '0', value text, KEY uid (uid), KEY fid (fid) );"); $ret[] = update_sql("ALTER TABLE {users} ADD picture varchar(255) NOT NULL DEFAULT ''"); } else { $ret[] = update_sql("CREATE TABLE profile_fields ( fid serial, title varchar(255) default NULL, name varchar(128) default NULL, explanation TEXT default NULL, category varchar(255) default NULL, type varchar(128) default NULL, weight smallint DEFAULT '0' NOT NULL, overview smallint DEFAULT '0' NOT NULL, options text, UNIQUE (name), PRIMARY KEY (fid) )"); $ret[] = update_sql("CREATE INDEX profile_fields_category ON profile_fields (category)"); $ret[] = update_sql("CREATE TABLE profile_values ( fid integer default '0', uid integer default '0', value text )"); $ret[] = update_sql("CREATE INDEX profile_values_uid ON profile_values (uid)"); $ret[] = update_sql("CREATE INDEX profile_values_fid ON profile_values (fid)"); $ret[] = update_sql("ALTER TABLE {users} ADD picture varchar(255)"); $ret[] = update_sql("ALTER TABLE {users} ALTER COLUMN picture SET DEFAULT ''"); $ret[] = update_sql("UPDATE {users} SET picture = ''"); $ret[] = update_sql("ALTER TABLE {users} ALTER COLUMN picture SET NOT NULL"); } // Migrate the old profile data to the new scheme: $fields = array( array("Name", "realname", "textfield", NULL, 0), array("Address", "address", "textfield", NULL, 0), array("City", "city", "textfield", NULL, 0), array("State, province or region", "state", "textfield", NULL, 0), array("Zip or postal code", "zip", "textfield", NULL, 0), array("Country", "country", "textfield", NULL, 1), array("Gender", "gender", "selection", "male\nfemale", 1), array("Job title", "job", "textfield", NULL, 0), array("ICQ messenger ID", "icq", "textfield", NULL, 0), array("MSN messenger ID", "msn", "textfield", NULL, 0), array("Yahoo messenger ID", "yahoo", "textfield", NULL, 0), array("AIM messenger ID", "aim", "textfield", NULL, 0), array("URL of homepage", "homepage", "url", NULL, 1), array("Biography", "biography", "textarea", NULL, 0), array("Interests", "interests", "textarea", NULL, 0), array("Public key", "publickey", "textarea", NULL, 0), array("Birthday", "birthday", "date", NULL, 0) ); // Remove existing data (debug mode): db_query('DELETE FROM {profile_fields}'); db_query('DELETE FROM {profile_values}'); foreach ($fields as $field) { db_query("INSERT INTO {profile_fields} (title, name, type, category, options, overview) VALUES ('%s', '%s', '%s', 'Personal information', '%s', %d)", $field[0], $field[1], $field[2], $field[3], $field[4]); } $result = db_query("SELECT uid FROM {users} WHERE uid > 0"); while ($account = db_fetch_object($result)) { // Load the user record: $account = user_load(array('uid' => $account->uid)); $edit = array(); // Modify the user record: foreach ($fields as $field) { $old = "profile_". $field[1]; $new = $field[1]; if ($account->$old) { $edit[$new] = $account->$old; } // Force deletion of old field $edit[$old] = NULL; } // Birthday format change: if ($edit['birthday']) { $edit['birthday'] = array('day' => $edit['birthday'], 'month' => $account->profile_birthmonth, 'year' => $account->profile_birthyear); // Force deletion of old field $edit['profile_birthmonth'] = NULL; $edit['profile_birthyear'] = NULL; } // Gender specific changes: if ($edit['gender'] == 'f') $edit['gender'] = 'female'; if ($edit['gender'] == 'm') $edit['gender'] = 'male'; // Avatar specific changes: if ($account->profile_avatar) { $edit['picture'] = $account->profile_avatar; // Force deletion of old field $edit['profile_avatar'] = NULL; } // Save the update record: user_save($account, $edit, 'Personal information'); } // This variable is needed to distinguish between 4.5-RC sites which ran a faulty // update_80() and 4.5-final sites. See update_108. variable_set('update_80_fix', true); return $ret; } function update_81() { if ($GLOBALS['db_type'] == 'mysql') { $ret[] = update_sql('ALTER TABLE {profile_fields} ADD page varchar(255) default NULL'); } else { $ret[] = update_sql('ALTER TABLE {profile_fields} ADD page varchar(255)'); $ret[] = update_sql('ALTER TABLE {profile_fields} ALTER COLUMN page SET default NULL'); } $ret[] = update_sql("UPDATE {profile_fields} SET type = 'url' WHERE name = 'homepage'"); return $ret; } function update_82() { if ($GLOBALS['db_type'] == 'mysql') { $ret[] = update_sql("ALTER TABLE {profile_fields} ADD required tinyint(1) DEFAULT '0' NOT NULL"); } else { $ret[] = update_sql("ALTER TABLE {profile_fields} ADD required smallint"); $ret[] = update_sql("ALTER TABLE {profile_fields} ALTER COLUMN required SET DEFAULT '0'"); $ret[] = update_sql("UPDATE {profile_fields} SET required = '0'"); $ret[] = update_sql("ALTER TABLE {profile_fields} ALTER COLUMN required SET NOT NULL"); } return $ret; } function update_83() { $ret = array(); if ($GLOBALS["db_type"] == "mysql") { $ret[] = update_sql("CREATE TABLE {menu} ( mid int(10) unsigned NOT NULL default '0', pid int(10) unsigned NOT NULL default '0', path varchar(255) NOT NULL default '', title varchar(255) NOT NULL default '', weight tinyint(4) NOT NULL default '0', visibility int(1) unsigned NOT NULL default '0', status int(1) unsigned NOT NULL default '0', PRIMARY KEY (mid) );"); } else { $ret[] = update_sql("CREATE TABLE {menu} ( mid serial, pid integer NOT NULL default '0', path varchar(255) NOT NULL default '', title varchar(255) NOT NULL default '', weight smallint NOT NULL default '0', visibility smallint NOT NULL default '0', status smallint NOT NULL default '0', PRIMARY KEY (mid) );"); } db_next_id('{menu}_mid'); return $ret; } function update_84() { $ret = array(); if ($GLOBALS["db_type"] == "mysql") { $ret[] = update_sql("ALTER TABLE {vocabulary} ADD help VARCHAR(255) NOT NULL DEFAULT '' AFTER description;"); } else { $ret[] = update_sql("ALTER TABLE {vocabulary} ADD help VARCHAR(255)"); $ret[] = update_sql("ALTER TABLE {vocabulary} ALTER help SET DEFAULT ''"); $ret[] = update_sql("UPDATE {vocabulary} SET help = ''"); $ret[] = update_sql("ALTER TABLE {vocabulary} ALTER help SET NOT NULL"); } return $ret; } function update_85() { $ret = array(); if ($GLOBALS['db_type'] == 'mysql') { $ret[] = update_sql("ALTER TABLE {bundle} RENAME TO {aggregator_category}"); $ret[] = update_sql("ALTER TABLE {aggregator_category} DROP attributes"); $ret[] = update_sql("ALTER TABLE {aggregator_category} CHANGE bid cid int(10) NOT NULL auto_increment"); $ret[] = update_sql("ALTER TABLE {aggregator_category} ADD description longtext NOT NULL"); $ret[] = update_sql("UPDATE {sequences} SET name = '{aggregator_category}_cid' WHERE name = '{bundle}_bid'"); $ret[] = update_sql("ALTER TABLE {feed} RENAME TO {aggregator_feed}"); $ret[] = update_sql("ALTER TABLE {aggregator_feed} DROP attributes"); $ret[] = update_sql("ALTER TABLE {aggregator_feed} ADD block tinyint(2) NOT NULL"); $ret[] = update_sql("ALTER TABLE {aggregator_category} ADD block tinyint(2) NOT NULL"); $ret[] = update_sql("UPDATE {sequences} SET name = '{aggregator_feed}_fid' WHERE name = '{feed}_fid'"); $ret[] = update_sql("ALTER TABLE {item} RENAME TO {aggregator_item}"); $ret[] = update_sql("ALTER TABLE {aggregator_item} DROP attributes"); $max = db_result(db_query_range("SELECT iid FROM {aggregator_item} ORDER BY iid DESC", 0, 1)); if ($max) { $ret[] = update_sql("INSERT INTO {sequences} (name, id) VALUES ('{aggregator_item}_iid', $max)"); } $ret[] = update_sql("CREATE TABLE {aggregator_category_feed} ( fid int(10) NOT NULL, cid int(10) NOT NULL, PRIMARY KEY (fid, cid) )"); $ret[] = update_sql("CREATE TABLE {aggregator_category_item} ( iid int(10) NOT NULL, cid int(10) NOT NULL, PRIMARY KEY (iid, cid) )"); $ret[] = update_sql("ALTER TABLE {aggregator_category} MODIFY description longtext NULL"); $ret[] = update_sql("ALTER TABLE {aggregator_item} MODIFY description longtext NULL"); $ret[] = update_sql("ALTER TABLE {aggregator_feed} MODIFY description longtext NULL"); $ret[] = update_sql("ALTER TABLE {aggregator_feed} MODIFY image longtext NULL"); } else { $ret[] = update_sql("ALTER TABLE {bundle} RENAME TO {aggregator_category}"); $ret[] = update_sql("ALTER TABLE {aggregator_category} DROP attributes"); $ret[] = update_sql("ALTER TABLE {aggregator_category} RENAME bid TO cid"); $lastvalue = db_result(db_query('SELECT last_value from {bundle}_bid_seq')); $ret[] = update_sql("CREATE SEQUENCE {aggregator_category}_cid_seq START $lastvalue MINVALUE 0"); $ret[] = update_sql("ALTER TABLE {aggregator_category} ALTER cid SET DEFAULT nextval('public.{aggregator_category}_cid_seq'::text)"); $ret[] = update_sql("ALTER TABLE {aggregator_category} ADD description text"); $ret[] = update_sql("UPDATE {aggregator_category} SET description = ''"); $ret[] = update_sql("ALTER TABLE {aggregator_category} ALTER COLUMN description SET NOT NULL"); $ret[] = update_sql("ALTER TABLE {feed} RENAME TO {aggregator_feed}"); $lastvalue = db_result(db_query('SELECT last_value from {feed}_fid_seq')); $ret[] = update_sql("CREATE SEQUENCE {aggregator_feed}_fid_seq START $lastvalue MINVALUE 0"); $ret[] = update_sql("ALTER TABLE {aggregator_feed} ALTER fid SET DEFAULT nextval('public.{aggregator_feed}_fid_seq'::text)"); $ret[] = update_sql("ALTER TABLE {aggregator_feed} DROP attributes"); $ret[] = update_sql("ALTER TABLE {aggregator_feed} ADD block smallint"); $ret[] = update_sql("UPDATE {aggregator_feed} SET block = 0"); $ret[] = update_sql("ALTER TABLE {aggregator_feed} ALTER COLUMN block SET NOT NULL"); $ret[] = update_sql("ALTER TABLE {aggregator_category} ADD block smallint"); $ret[] = update_sql("UPDATE {aggregator_category} SET block = 0"); $ret[] = update_sql("ALTER TABLE {aggregator_category} ALTER COLUMN block SET NOT NULL"); $ret[] = update_sql("ALTER TABLE {item} RENAME TO {aggregator_item}"); $lastvalue = db_result(db_query('SELECT last_value from {item}_iid_seq')); $ret[] = update_sql("CREATE SEQUENCE {aggregator_item}_iid_seq START $lastvalue MINVALUE 0"); $ret[] = update_sql("ALTER TABLE {aggregator_item} ALTER iid SET DEFAULT nextval('public.{aggregator_item}_iid_seq'::text)"); $ret[] = update_sql("ALTER TABLE {aggregator_item} DROP attributes"); $ret[] = update_sql("CREATE TABLE {aggregator_category_feed} ( fid integer NOT NULL default '0', cid integer NOT NULL default '0', PRIMARY KEY (fid,cid) );"); $ret[] = update_sql("CREATE TABLE {aggregator_category_item} ( iid integer NOT NULL default '0', cid integer NOT NULL default '0', PRIMARY KEY (iid,cid) )"); } return $ret; } function update_86() { $ret = array(); $ret[] = update_sql("INSERT INTO {users_roles} (uid, rid) SELECT uid, rid FROM {users}"); // TODO: should we verify the insert above worked before dropping rid? if ($GLOBALS['db_type'] == 'mysql') { //only the most recent versions of postgres support dropping columns $ret[] = update_sql("ALTER TABLE {users} DROP rid"); } return $ret; } function update_87() { // Works for both postgres and mysql $ret = array(); $ret[] = update_sql("ALTER TABLE {comments} ADD name varchar(60) DEFAULT NULL"); $ret[] = update_sql("ALTER TABLE {comments} ADD mail varchar(64) DEFAULT NULL"); $ret[] = update_sql("ALTER TABLE {comments} ADD homepage varchar(255) DEFAULT NULL"); return $ret; } function update_88() { $ret = array(); if ($GLOBALS['db_type'] == 'mysql') { $ret[] = update_sql("ALTER TABLE {menu} DROP status"); $ret[] = update_sql("ALTER TABLE {menu} DROP visibility"); $ret[] = update_sql("ALTER TABLE {menu} ADD type INT(2) UNSIGNED DEFAULT '0' NOT NULL"); } else { $ret[] = update_sql("ALTER TABLE {menu} ADD type smallint"); $ret[] = update_sql("ALTER TABLE {menu} ALTER COLUMN type SET DEFAULT '0'"); $ret[] = update_sql("UPDATE {menu} SET type = '0'"); $ret[] = update_sql("ALTER TABLE {menu} ALTER COLUMN type SET NOT NULL"); } $ret[] = update_sql("DELETE FROM {menu}"); return $ret; } function update_89() { $ret = array(); if ($GLOBALS['db_type'] == 'mysql') { $ret[] = update_sql("ALTER TABLE {node} CHANGE static sticky INT(2) DEFAULT '0' NOT NULL"); } else { $ret[] = update_sql("ALTER TABLE {node} RENAME static TO sticky;"); } // Change the node settings, so that it uses node_sticky_$type instead of node_static_$type $result = db_query("SELECT * FROM {variable} WHERE name LIKE 'node_static_%'"); while ($variable = db_fetch_object($result)) { //get the node type name, place it into $name_arr. The name can be found with $name_arr[2] $name_arr = explode("_", $variable->name, 3); $ret[] = update_sql("INSERT INTO {variable} (name,value) VALUES ('node_sticky_". $name_arr[2] ."','". $variable->value. "')"); } $ret[] = db_query("DELETE FROM {variable} WHERE name LIKE 'node_static_%'"); return $ret; } function update_90() { if ($GLOBALS['db_type'] == 'mysql') { $ret[] = update_sql("ALTER TABLE {profile_fields} CHANGE overview visibility INT(1) UNSIGNED DEFAULT '0' NOT NULL"); } else { $ret[] = update_sql("ALTER TABLE {profile_fields} RENAME overview TO visibility"); } $ret[] = update_sql("UPDATE {profile_fields} SET visibility = 2 WHERE visibility = 1"); $ret[] = update_sql("UPDATE {profile_fields} SET visibility = 1 WHERE visibility = 0"); return $ret; } function update_91() { $ret = array(); if ($GLOBALS["db_type"] == "pgsql") { // node_created was created implicitly somewhere else $ret[] = update_sql("CREATE INDEX node_changed ON {node} (changed)"); } else { $ret[] = update_sql("ALTER TABLE {node} ADD INDEX node_created (created)"); $ret[] = update_sql("ALTER TABLE {node} ADD INDEX node_changed (changed)"); } return $ret; } function update_92() { $ret = array(); $ret[] = update_sql("DELETE FROM {cache}"); return $ret; } function update_93() { $ret = array(); if ($GLOBALS['db_type'] == 'pgsql') { $ret[] = update_sql('DROP INDEX url_alias_src_idx'); } else { $ret[] = update_sql('ALTER TABLE {url_alias} DROP INDEX src'); } $ret[] = update_sql("INSERT INTO {url_alias} (src, dst) VALUES ('node/feed', 'rss.xml')"); return $ret; } function update_94() { /** * Postgres only update */ $ret = array(); if ($GLOBALS['db_type'] == 'pgsql') { $ret[] = update_sql('DROP FUNCTION "greatest"(integer, integer)'); $ret[] = update_sql(" CREATE FUNCTION greatest(integer, integer) RETURNS integer AS ' BEGIN IF $2 IS NULL THEN RETURN $1; END IF; IF $1 > $2 THEN RETURN $1; END IF; RETURN $2; END; ' LANGUAGE 'plpgsql'; "); } return $ret; } function update_95() { $ret = array(); if ($GLOBALS['db_type'] == 'mysql') { $ret[] = update_sql("CREATE TABLE {node_access} ( nid int(10) unsigned NOT NULL default '0', gid int(10) unsigned NOT NULL default '0', realm varchar(255) NOT NULL default '', grant_view tinyint(1) unsigned NOT NULL default '0', grant_update tinyint(1) unsigned NOT NULL default '0', grant_delete tinyint(1) unsigned NOT NULL default '0', PRIMARY KEY (nid,gid,realm) )"); } else { $ret[] = update_sql("CREATE TABLE {node_access} ( nid SERIAL, gid integer NOT NULL default '0', realm text NOT NULL default '', grant_view smallint NOT NULL default '0', grant_update smallint NOT NULL default '0', grant_delete smallint NOT NULL default '0', PRIMARY KEY (nid,gid,realm) )"); $ret[] = update_sql("CREATE FUNCTION \"concat\"(text, text) RETURNS text AS ' BEGIN RETURN $1 || $2; END; ' LANGUAGE 'plpgsql';"); } $ret[] = update_sql("INSERT INTO {node_access} VALUES (0, 0, 'all', 1, 0, 0);"); return $ret; } function update_96() { $ret = array(); $ret[] = update_sql('ALTER TABLE {accesslog} DROP nid'); $ret[] = update_sql('ALTER TABLE {accesslog} ADD title VARCHAR(255) DEFAULT NULL'); $ret[] = update_sql('ALTER TABLE {accesslog} ADD path VARCHAR(255) DEFAULT NULL'); if ($GLOBALS['db_type'] == 'mysql') { $ret[] = update_sql("ALTER TABLE {menu} ADD description varchar(255) DEFAULT '' NOT NULL"); } else { $ret[] = update_sql("ALTER TABLE {menu} ADD description smallint"); $ret[] = update_sql("ALTER TABLE {menu} ALTER COLUMN description SET DEFAULT '0'"); $ret[] = update_sql("UPDATE {menu} SET description = '0'"); $ret[] = update_sql("ALTER TABLE {menu} ALTER COLUMN description SET NOT NULL"); } return $ret; } function update_97() { /** * Works for both PostgreSQL and MySQL */ $convert = array('node/view/' => 'node/', 'book/view/' => 'book/', 'user/view/' => 'user/'); foreach ($convert as $from => $to) { $result = db_query("SELECT pid, src FROM {url_alias} WHERE src LIKE '%s%%'", $from); while ($alias = db_fetch_object($result)) { db_query("UPDATE {url_alias} SET src = '%s' WHERE pid = '%s'", str_replace($from, $to, $alias->src), $alias->pid); } } return array(); } function update_98() { /** * Works for both PostgreSQL and MySQL */ $result = db_query("SELECT pid, src FROM {url_alias} WHERE src LIKE 'taxonomy/%%'"); while ($alias = db_fetch_object($result)) { list(, $page, $op, $terms) = explode('/', $alias->src); if ($page == 'feed' || $page == 'page') { switch ($op) { case 'or': $new = 'taxonomy/term/'. str_replace(',', '+', $terms); break; case 'and': $new = 'taxonomy/term/'. $terms; break; } if ($new) { if ($page == 'feed') { $new .= '/0/feed'; } db_query("UPDATE {url_alias} SET src = '%s' WHERE pid = '%s'", $new, $alias->pid); } } } return array(); } function update_99() { // Filter patch - Multiple input formats $ret = array(); /* ** Load the list of PHP book and page nodes. */ $php_nodes = array(); $res = db_query("SELECT nid FROM {book} WHERE format = 1"); while ($book = db_fetch_object($res)) { $php_nodes[] = $book->nid; } $res = db_query("SELECT nid FROM {page} WHERE format = 1"); while ($page = db_fetch_object($res)) { $php_nodes[] = $page->nid; } /* ** Apply database changes */ if ($GLOBALS['db_type'] == 'mysql') { // Filters table $ret[] = update_sql("ALTER TABLE {filters} ADD format int(4) NOT NULL default '0'"); $ret[] = update_sql("ALTER TABLE {filters} ADD delta tinyint(2) NOT NULL default '0'"); // Filter_formats table $ret[] = update_sql("CREATE TABLE {filter_formats} ( format int(4) NOT NULL auto_increment, name varchar(255) NOT NULL default '', roles varchar(255) NOT NULL default '', cache tinyint(2) NOT NULL default '1', PRIMARY KEY (format) )"); // Store formats in nodes, comments and boxes $ret[] = update_sql("ALTER TABLE {boxes} CHANGE type format int(4) NOT NULL default '0'"); $ret[] = update_sql("ALTER TABLE {comments} ADD format int(4) NOT NULL default '0'"); $ret[] = update_sql("ALTER TABLE {node} ADD format int(4) NOT NULL default '0'"); // Get rid of the old book/page type info $ret[] = update_sql("ALTER TABLE {book} DROP format"); $ret[] = update_sql("ALTER TABLE {page} DROP format"); } else if ($GLOBALS['db_type'] == 'pgsql') { $result = db_query("SELECT * FROM {filters}"); if ($result) { while ($obj = db_fetch_object($result)) { $filters[] = $obj; } } $ret[] = update_sql("DROP TABLE {filters}"); $ret[] = update_sql("CREATE TABLE {filters} ( format integer NOT NULL DEFAULT '0', module varchar(64) NOT NULL DEFAULT '', delta smallint NOT NULL DEFAULT 1, weight smallint DEFAULT '0' NOT NULL )"); $ret[] = update_sql("CREATE INDEX filters_module_idx ON filters(module)"); if (is_array($filters)) { foreach ($filters as $filter) { db_query("INSERT INTO {filters} VALUES (%d, '%s', %d, %d)", $filter->format ? $filter->format : 0, $filter->module, $filter->delta ? $filter->delta : 1, $filter->weight); } } $ret[] = update_sql("CREATE TABLE {filter_formats} ( format SERIAL, name varchar(255) NOT NULL default '', roles varchar(255) NOT NULL default '', cache smallint NOT NULL default '0', PRIMARY KEY (format) )"); $ret[] = update_sql("ALTER TABLE {boxes} RENAME type TO format"); $ret[] = update_sql("ALTER TABLE {comments} ADD format smallint"); $ret[] = update_sql("ALTER TABLE {comments} ALTER COLUMN format SET DEFAULT '0'"); $ret[] = update_sql("UPDATE {comments} SET format = '0'"); $ret[] = update_sql("ALTER TABLE {comments} ALTER COLUMN format SET NOT NULL"); $ret[] = update_sql("ALTER TABLE {node} ADD format smallint"); $ret[] = update_sql("ALTER TABLE {node} ALTER COLUMN format SET DEFAULT '0'"); $ret[] = update_sql("UPDATE {node} SET format = '0'"); $ret[] = update_sql("ALTER TABLE {node} ALTER COLUMN format SET NOT NULL"); /* Postgres usually can't drop columns $ret[] = update_sql("ALTER TABLE {book} DROP format"); $ret[] = update_sql("ALTER TABLE {page} DROP format"); */ } // Initialize all nodes and comments to the legacy format (see below) $ret[] = update_sql("UPDATE {node} SET format = 1"); $ret[] = update_sql("UPDATE {comments} SET format = 1"); // Set format to PHP for the old PHP book/page nodes. if (count($php_nodes)) { $ret[] = update_sql("UPDATE {node} SET format = 2 WHERE nid IN (". implode(',', $php_nodes) .")"); } // Boxes now use the filtering system as well. // Type 0 (HTML) maps to Format 3 (Full HTML). // Type 1 (PHP) maps to Format 2 (PHP). $ret[] = update_sql("UPDATE {boxes} SET format = 3 - format"); /* ** Update PHP content to use tags. */ if ($GLOBALS['db_type'] == 'mysql') { $ret[] = update_sql("UPDATE {node} SET teaser = CONCAT('rid; } $ret[] = update_sql("INSERT INTO {filter_formats} VALUES (". db_next_id("{filter_formats}_format") .",'PHP code','". implode(',', $php_roles) .",',0)"); // This is a 'Full HTML' format which allows all HTML without restrictions. $ret[] = update_sql("INSERT INTO {filter_formats} VALUES (". db_next_id("{filter_formats}_format") .",'Full HTML','',1)"); // Set the default format to the legacy format variable_set('filter_default_format', 1); // Put the old filters into the legacy format $ret[] = update_sql("UPDATE {filters} SET format = 1"); // Add filter.module's standard filters (these used to be hardcoded). if (!variable_get('rewrite_old_urls', 0)) { $ret[] = update_sql("DELETE FROM {filters} WHERE module = 'filter'"); } else { $ret[] = update_sql("UPDATE {filters} SET delta = 2 WHERE module ='filter'"); } if ($old_html_filter != 0) { $ret[] = update_sql("INSERT INTO {filters} (format, module, delta, weight) VALUES (1,'filter',0,0)"); // HTML tag/style filter } $ret[] = update_sql("INSERT INTO {filters} (format, module, delta, weight) VALUES (1,'filter',2,1)"); // Linebreak filter $ret[] = update_sql("INSERT INTO {filters} (format, module, delta, weight) VALUES (2,'filter',1,0)"); // PHP evaluator $ret[] = update_sql("INSERT INTO {filters} (format, module, delta, weight) VALUES (3,'filter',2,0)"); // Linebreak filter // Migrate the settings for all core/contrib filtering modules into the legacy // format. $migrate = array('filter_html', // filter.module 'allowed_html', 'filter_style', 'anyfilter_regexps', // anyfilter.module 'htmlcorrector_smartclose', // htmlcorrector.module 'htmlcorrector_xhtmlify', 'htmlcorrector_valueentities', 'project_filter', // project.module 'latex_filter_link' // latex.module ); foreach ($migrate as $variable) { $value = variable_get($variable, NULL); if ($value != NULL) { variable_set($variable .'_1', $value); variable_del($variable); } } return $ret; } function update_100() { $ret = array(); if ($GLOBALS["db_type"] == "mysql") { $ret[] = update_sql("CREATE TABLE {locales_source} ( lid int(11) NOT NULL auto_increment, location varchar(128) NOT NULL default '', source blob NOT NULL, PRIMARY KEY (lid) )"); $ret[] = update_sql("CREATE TABLE {locales_target} ( lid int(11) NOT NULL default '0', translation blob NOT NULL, locale varchar(12) NOT NULL default '', plid int(11) NOT NULL default '0', plural int(1) NOT NULL default '0', KEY lid (lid), KEY lang (locale), KEY plid (plid), KEY plural (plural) )"); $ret[] = update_sql("ALTER TABLE {users} CHANGE language language varchar(12) NOT NULL default ''"); } else { $ret[] = update_sql("CREATE TABLE {locales_target} ( lid int4 NOT NULL default '0', translation text DEFAULT '' NOT NULL, locale varchar(12) NOT NULL default '', plid int4 NOT NULL default '0', plural int4 NOT NULL default '0' )"); $ret[] = update_sql("CREATE INDEX {locales_target}_lid ON {locales_target}(lid)"); $ret[] = update_sql("CREATE INDEX {locales_target}_locale ON {locales_target}(locale)"); $ret[] = update_sql("CREATE INDEX {locales_target}_plid ON {locales_target}(plid)"); $ret[] = update_sql("CREATE INDEX {locales_target}_plural ON {locales_target}(plural)"); $ret[] = update_sql("CREATE SEQUENCE {locales_source}_lid INCREMENT 1 START 0 MINVALUE 0"); $ret[] = update_sql("CREATE TABLE {locales_source} ( lid serial, location varchar(128) NOT NULL default '', source text NOT NULL, PRIMARY KEY (lid) )"); $ret[] = update_sql("ALTER TABLE {users} rename language to lang_archive"); $ret[] = update_sql("ALTER TABLE {users} add language varchar(12)"); $ret[] = update_sql("ALTER TABLE {users} ALTER language SET DEFAULT ''"); $ret[] = update_sql("UPDATE {users} SET language = ''"); $ret[] = update_sql("ALTER TABLE {users} ALTER language SET NOT NULL"); $ret[] = update_sql("update {users} set language = lang_archive"); } $ret[] = update_sql("INSERT INTO {locales_meta} (locale, name, enabled, isdefault) VALUES ('en', 'English', '1', '1')"); return $ret; } function update_101() { /** * Works for both PostgreSQL and MySQL */ include_once 'includes/locale.inc'; // get the language columns $result = db_query('SELECT * FROM {locales} LIMIT 1'); $fields = array(); if (db_num_rows($result)) { $columns = array_keys(db_fetch_array($result)); foreach ($columns as $field) { $fields[$field] = 1; } // but not the fixed fields unset($fields['lid'], $fields['location'], $fields['string']); // insert locales $list = _locale_get_iso639_list(); foreach ($fields as $key => $value) { if (db_result(db_query("SELECT COUNT(lid) FROM {locales} WHERE $key != ''"))) { if (isset($list[$key])) { $name = $list[$key][0]; if ($key == 'en') { $key = 'en-local'; } db_query("INSERT INTO {locales_meta} (locale, name) VALUES ('%s', '%s')", $key, $name); } else { db_query("INSERT INTO {locales_meta} (locale, name) VALUES ('%s', '%s')", $key, $key); } } } // get all strings $result = db_query('SELECT * FROM {locales}'); while ($entry = db_fetch_object($result)) { // insert string if at least one translation exists $test = 'return $entry->'. implode(' == "" && $entry->', array_keys($fields)) .' == "";'; if (!eval($test)) { db_query("INSERT INTO {locales_source} (location, source) VALUES ('%s', '%s')", $entry->location, $entry->string); $lid = db_fetch_object(db_query("SELECT lid FROM {locales_source} WHERE location = '%s' AND source = '%s'", $entry->location, $entry->string)); foreach ($fields as $key => $value) { // insert translation if non-empty if ($key == 'en') { $keynew = 'en-local'; } else { $keynew = $key; } db_query("INSERT INTO {locales_target} (lid, translation, locale) VALUES (%d, '%s', '%s')", $lid->lid, $entry->$key, $keynew); } } } } $ret = array(); $ret[] = update_sql("DROP TABLE {locales}"); return $ret; } function update_102() { /** * Works for both PostgreSQL and MySQL */ return array(update_sql("INSERT INTO {system} (filename, name, type, description, status, throttle, bootstrap) VALUES ('modules/legacy.module', 'legacy', 'module', '', 1, 0, 0)")); } function update_103() { $ret = array(); if ($GLOBALS['db_type'] == 'mysql') { $ret[] = update_sql("CREATE TABLE {files} ( fid int(10) unsigned NOT NULL default '0', nid int(10) unsigned NOT NULL default '0', filename varchar(255) NOT NULL default '', filepath varchar(255) NOT NULL default '', filemime varchar(255) NOT NULL default '', filesize int(10) unsigned NOT NULL default '0', list tinyint(1) unsigned NOT NULL default '0', PRIMARY KEY (fid) )"); } else { $ret[] = update_sql("CREATE TABLE {files} ( fid serial, nid integer NOT NULL default '0', filename varchar(255) NOT NULL default '', filepath varchar(255) NOT NULL default '', filemime varchar(255) NOT NULL default '', filesize integer NOT NULL default '0', list smallint NOT NULL default '0', PRIMARY KEY (fid) )"); } return $ret; } function update_104() { /** * Works for both PostgreSQL and MySQL */ $ret = array(); if (variable_get('theme_default', 'xtemplate') == 'chameleon') { $ret[] = update_sql("DELETE FROM {system} WHERE name = 'chameleon'"); $ret[] = update_sql("INSERT INTO {system} VALUES ('themes/chameleon/chameleon.theme','chameleon','theme','',1,0,0)"); $ret[] = update_sql("INSERT INTO {system} VALUES ('themes/chameleon/marvin/style.css','marvin','theme','themes/chameleon/chameleon.theme',1,0,0)"); if (variable_get("chameleon_stylesheet", "themes/chameleon/pure/chameleon.css") == "themes/chameleon/marvin/chameleon.css") { variable_set('theme_default', 'chameleon/marvin'); } else { variable_set('theme_default', 'chameleon'); } } elseif (variable_get('theme_default', 'xtemplate') == 'xtemplate') { $ret[] = update_sql("DELETE FROM {system} WHERE name = 'xtemplate'"); $ret[] = update_sql("INSERT INTO {system} VALUES ('themes/bluemarine/xtemplate.xtmpl','bluemarine','theme','themes/engines/xtemplate/xtemplate.engine',1,0,0)"); $ret[] = update_sql("INSERT INTO {system} VALUES ('themes/pushbutton/xtemplate.xtmpl','pushbutton','theme','themes/engines/xtemplate/xtemplate.engine',1,0,0)"); $ret[] = update_sql("INSERT INTO {system} VALUES ('themes/engines/xtemplate/xtemplate.engine','xtemplate','theme_engine','',1,0,0)"); if (variable_get('xtemplate_template', 'default') == 'pushbutton') { variable_set('theme_default', 'pushbutton'); } else { variable_set('theme_default', 'bluemarine'); } // Convert old xtemplate settings to new theme system $settings = array(); $convert = array('xtemplate_primary_links' => 'primary_links', 'xtemplate_secondary_links' => 'secondary_links', 'xtemplate_search_box' => 'toggle_search', 'xtemplate_avatar_node' => 'toggle_node_user_picture', 'xtemplate_avatar_comment' => 'toggle_comment_user_picture'); foreach ($convert as $from => $to) { if (($value = variable_get($from, NULL)) != NULL) { $settings[$to] = $value; variable_del($from); } } // Logo requires special treatment. Used to be an HTML tag, now it's a path to an image. if (($logo = variable_get('xtemplate_logo', NULL)) != NULL) { $match = array(); // If logo was of the form