/[drupal]/contributions/modules/aggregation/aggregation.install
ViewVC logotype

Contents of /contributions/modules/aggregation/aggregation.install

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


Revision 1.4 - (show annotations) (download) (as text)
Sat Feb 24 00:28:57 2007 UTC (2 years, 9 months ago) by mistknight
Branch: MAIN
CVS Tags: DRUPAL-5--1-0, HEAD
Branch point for: DRUPAL-5, DRUPAL-6--1
Changes since 1.3: +33 -1 lines
File MIME type: text/x-php
Updated to drupal 5.x
1 <?php
2
3 // $Id: aggregation.install,v 1.3 2007/02/23 07:08:09 mistknight Exp $
4
5 function aggregation_install()
6 {
7 switch ($GLOBALS['db_type'])
8 {
9 case 'mysqli':
10 case 'mysql':
11
12 $query = <<<begin_create_query
13 CREATE TABLE IF NOT EXISTS {aggregation_feed} (
14 `nid` int(10) unsigned NOT NULL,
15 `original_author` varchar(100) NOT NULL default '',
16 `url` varchar(125) NOT NULL,
17 `username` varchar(50) NOT NULL default '',
18 `password` varchar(50) NOT NULL default '',
19 `refresh_interval` int(10) unsigned NOT NULL,
20 `title_as_guid_interval` int(10) unsigned NOT NULL,
21 `enabled` enum('yes', 'no') NOT NULL default 'yes',
22 `publish_new_items` enum('yes', 'no') NOT NULL default 'yes',
23 `delete_old_items` enum('yes', 'no') NOT NULL default 'no',
24 `item_categories` varchar(150) NOT NULL default '',
25 `etag` varchar(255) NOT NULL default '',
26 `last_modified` int(11) NOT NULL default 0,
27 `last_refreshed` int(11) NOT NULL default 0,
28 PRIMARY KEY (`nid`)
29 ) TYPE=MyISAM /*!40100 DEFAULT CHARACTER SET utf8 */;
30 begin_create_query;
31
32 db_query($query);
33
34 $query = <<<begin_create_query
35 CREATE TABLE IF NOT EXISTS {aggregation_item} (
36 `nid` int(10) unsigned NOT NULL,
37 `url` varchar(125) NOT NULL default '',
38 `original_author` varchar(100) NOT NULL default '',
39 `story_guid` int NOT NULL default 0,
40 `fid` int(10) unsigned NOT NULL default 0,
41 `image_id` int(10) unsigned NOT NULL default 0,
42 `image_guid` int NOT NULL default 0,
43 PRIMARY KEY (`nid`),
44 INDEX (`story_guid`),
45 INDEX (`image_id`),
46 INDEX (`fid`),
47 INDEX (`image_guid`)
48 ) TYPE=MyISAM /*!40100 DEFAULT CHARACTER SET utf8 */;
49 begin_create_query;
50
51 db_query($query);
52
53 if (db_fetch_object(db_query("SELECT COUNT(vid) AS vid_count FROM {vocabulary} ".
54 "WHERE name = '%s'", 'Aggregation Feed Types'))->vid_count == 0)
55 {
56 $vocab = array();
57
58 $vocab['name'] = 'Aggregation Feed Types';
59 $vocab['description'] = 'All Aggregation Feed Types are to be declared as terms under this vocabulary';
60 $vocab['help'] = 'Add terms that represent the feed types. For example, if you create a term called '.
61 'RSS10 you"ll need to create a file RSS10.inc in the feed_handlers that implements a function called '.
62 '_aggregation_RSS10_parse. This function will handle all feeds under this term! '.
63 'Checkout the file default.inc and RSS20 for an example.'.
64 $vocab['multiple'] = 0;
65 $vocab['required'] = 1;
66 $vocab['module'] = 'aggregation';
67 $vocab['nodes']['aggregation_feed'] = 1;
68 $vocab['tags'] = 0;
69 $vocab['weight'] = 0;
70
71 taxonomy_save_vocabulary($vocab);
72
73 variable_set('aggregation_current_vid', $vocab['vid']);
74
75 $term = array();
76
77 $term['name'] = 'RSS20';
78 $term['description'] = 'This is an RSS 2.0 feed handler';
79 $term['vid'] = $vocab['vid'];
80 $term['weight'] = 0;
81
82 taxonomy_save_term($term);
83 }
84 break;
85 }
86
87 }
88
89 function aggregation_update_1()
90 {
91 $ret = array();
92
93 switch ($GLOBALS['db_type'])
94 {
95 case 'mysql':
96 case 'mysqli':
97 $ret[] = update_sql("ALTER TABLE {aggregation_feed} ADD aggregate_to_moderation_queue enum('yes', 'no') NOT NULL default 'no' AFTER publish_new_items");
98 $ret[] = update_sql("ALTER TABLE {aggregation_feed} ADD sticky_items enum('yes', 'no') NOT NULL default 'no' AFTER aggregate_to_moderation_queue");
99 $ret[] = update_sql("ALTER TABLE {aggregation_feed} ADD enable_comments_on_articles enum('yes','no') NOT NULL default 'no' AFTER sticky_items");
100 $ret[] = update_sql("ALTER TABLE {aggregation_feed} ADD enable_comments_on_images enum('yes','no') NOT NULL default 'no' AFTER enable_comments_on_articles");
101 $ret[] = update_sql("ALTER TABLE {aggregation_feed} ADD promote_to_frontpage int(10) NOT NULL default 0 AFTER enable_comments_on_images");
102 break;
103 }
104
105 return $ret;
106 }
107
108 function aggregation_uninstall()
109 {
110 // Delete all aggregation items
111 $result = db_query("SELECT ai.nid FROM {aggregation_item} ai, {node} n WHERE ai.nid = n.nid");
112 while ($row = db_fetch_object($result))
113 node_delete($row->nid);
114
115 // Delete all aggregation feeds
116 $result = db_query("SELECT af.nid FROM {aggregation_feed} af, {node} n WHERE af.nid = n.nid");
117 while ($row = db_fetch_object($result))
118 node_delete($row->nid);
119
120 // We'll get -1 if this is not set for some reason
121 $vocabulary_to_delete = variable_get('aggregation_current_vid', -1);
122
123 if ($vocabulary_to_delete >= 0)
124 taxonomy_del_vocabulary($vocabulary_to_delete);
125
126 db_query("DROP TABLE {aggregation_item}");
127 db_query("DROP TABLE {aggregation_feed}");
128 variable_del('aggregation_current_vid');
129 variable_del('aggregation_item_time_to_live');
130 variable_del('aggregation_enable_logging');
131 variable_del('aggregation_image_to_display');
132 variable_del('aggregation_enable_cron');
133 variable_del('aggregation_feeds_to_refresh_per_cron');
134 variable_del('aggregation_feed_refresh_cooldown');
135
136 node_type_delete('aggregation_feed');
137 node_type_delete('aggregation_item');
138 }

  ViewVC Help
Powered by ViewVC 1.1.2