1
|
<?php
|
2
|
|
3
|
// $Id: install.php 66 2005-09-11 10:19:10Z stefan $
|
4
|
|
5
|
/*
|
6
|
|
7
|
Website Baker Project <http://www.websitebaker.org/>
|
8
|
Copyright (C) 2004-2005, Ryan Djurovich
|
9
|
|
10
|
Website Baker is free software; you can redistribute it and/or modify
|
11
|
it under the terms of the GNU General Public License as published by
|
12
|
the Free Software Foundation; either version 2 of the License, or
|
13
|
(at your option) any later version.
|
14
|
|
15
|
Website Baker is distributed in the hope that it will be useful,
|
16
|
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
17
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
18
|
GNU General Public License for more details.
|
19
|
|
20
|
You should have received a copy of the GNU General Public License
|
21
|
along with Website Baker; if not, write to the Free Software
|
22
|
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
23
|
|
24
|
*/
|
25
|
|
26
|
if(defined('WB_URL')) {
|
27
|
|
28
|
$database->query("DROP TABLE IF EXISTS `".TABLE_PREFIX."mod_news_posts`");
|
29
|
$mod_news = 'CREATE TABLE `'.TABLE_PREFIX.'mod_news_posts` ( '
|
30
|
. '`post_id` INT NOT NULL AUTO_INCREMENT,'
|
31
|
. '`section_id` INT NOT NULL,'
|
32
|
. '`page_id` INT NOT NULL,'
|
33
|
. '`group_id` INT NOT NULL,'
|
34
|
. '`active` INT NOT NULL,'
|
35
|
. '`position` INT NOT NULL,'
|
36
|
. '`title` VARCHAR(255) NOT NULL,'
|
37
|
. '`link` TEXT NOT NULL,'
|
38
|
. '`content_short` TEXT NOT NULL,'
|
39
|
. '`content_long` TEXT NOT NULL,'
|
40
|
. '`commenting` VARCHAR(7) NOT NULL,'
|
41
|
. '`posted_when` INT NOT NULL ,'
|
42
|
. '`posted_by` INT NOT NULL ,'
|
43
|
. 'PRIMARY KEY (post_id)'
|
44
|
. ' )';
|
45
|
$database->query($mod_news);
|
46
|
|
47
|
$database->query("DROP TABLE IF EXISTS `".TABLE_PREFIX."mod_news_groups`");
|
48
|
$mod_news = 'CREATE TABLE `'.TABLE_PREFIX.'mod_news_groups` ( '
|
49
|
. '`group_id` INT NOT NULL AUTO_INCREMENT,'
|
50
|
. '`section_id` INT NOT NULL,'
|
51
|
. '`page_id` INT NOT NULL,'
|
52
|
. '`active` INT NOT NULL,'
|
53
|
. '`position` INT NOT NULL,'
|
54
|
. '`title` VARCHAR(255) NOT NULL,'
|
55
|
. 'PRIMARY KEY (group_id)'
|
56
|
. ' )';
|
57
|
$database->query($mod_news);
|
58
|
|
59
|
$database->query("DROP TABLE IF EXISTS `".TABLE_PREFIX."mod_news_comments`");
|
60
|
$mod_news = 'CREATE TABLE `'.TABLE_PREFIX.'mod_news_comments` ( '
|
61
|
. '`comment_id` INT NOT NULL AUTO_INCREMENT,'
|
62
|
. '`section_id` INT NOT NULL,'
|
63
|
. '`page_id` INT NOT NULL,'
|
64
|
. '`post_id` INT NOT NULL,'
|
65
|
. '`title` VARCHAR(255) NOT NULL,'
|
66
|
. '`comment` TEXT NOT NULL,'
|
67
|
. '`commented_when` INT NOT NULL ,'
|
68
|
. '`commented_by` INT NOT NULL ,'
|
69
|
. 'PRIMARY KEY (comment_id)'
|
70
|
. ' )';
|
71
|
$database->query($mod_news);
|
72
|
|
73
|
$database->query("DROP TABLE IF EXISTS `".TABLE_PREFIX."mod_news_settings`");
|
74
|
$mod_news = 'CREATE TABLE `'.TABLE_PREFIX.'mod_news_settings` ( '
|
75
|
. '`section_id` INT NOT NULL,'
|
76
|
. '`page_id` INT NOT NULL,'
|
77
|
. '`header` TEXT NOT NULL,'
|
78
|
. '`post_loop` TEXT NOT NULL,'
|
79
|
. '`footer` TEXT NOT NULL,'
|
80
|
. '`posts_per_page` INT NOT NULL,'
|
81
|
. '`post_header` TEXT NOT NULL,'
|
82
|
. '`post_footer` TEXT NOT NULL,'
|
83
|
. '`comments_header` TEXT NOT NULL,'
|
84
|
. '`comments_loop` TEXT NOT NULL,'
|
85
|
. '`comments_footer` TEXT NOT NULL,'
|
86
|
. '`comments_page` TEXT NOT NULL,'
|
87
|
. '`commenting` VARCHAR(7) NOT NULL,'
|
88
|
. '`resize` INT NOT NULL,'
|
89
|
. 'PRIMARY KEY (section_id)'
|
90
|
. ' )';
|
91
|
$database->query($mod_news);
|
92
|
|
93
|
// Insert info into the search table
|
94
|
// Module query info
|
95
|
$field_info = array();
|
96
|
$field_info['page_id'] = 'page_id';
|
97
|
$field_info['title'] = 'page_title';
|
98
|
$field_info['link'] = 'link';
|
99
|
$field_info['description'] = 'description';
|
100
|
$field_info['modified_when'] = 'modified_when';
|
101
|
$field_info['modified_by'] = 'modified_by';
|
102
|
$field_info = serialize($field_info);
|
103
|
$database->query("INSERT INTO ".TABLE_PREFIX."search (name,value,extra) VALUES ('module', 'news', '$field_info')");
|
104
|
// Query start
|
105
|
$query_start_code = "SELECT [TP]pages.page_id, [TP]pages.page_title, [TP]pages.link, [TP]pages.description, [TP]pages.modified_when, [TP]pages.modified_by FROM [TP]mod_news_posts, [TP]mod_news_groups, [TP]mod_news_comments, [TP]mod_news_settings, [TP]pages WHERE ";
|
106
|
$database->query("INSERT INTO ".TABLE_PREFIX."search (name,value,extra) VALUES ('query_start', '$query_start_code', 'news')");
|
107
|
// Query body
|
108
|
$query_body_code = "
|
109
|
[TP]pages.page_id = [TP]mod_news_posts.page_id AND [TP]mod_news_posts.title LIKE \'%[STRING]%\'
|
110
|
OR [TP]pages.page_id = [TP]mod_news_posts.page_id AND [TP]mod_news_posts.content_short LIKE \'%[STRING]%\'
|
111
|
OR [TP]pages.page_id = [TP]mod_news_posts.page_id AND [TP]mod_news_posts.content_long LIKE \'%[STRING]%\'
|
112
|
OR [TP]pages.page_id = [TP]mod_news_comments.page_id AND [TP]mod_news_comments.title LIKE \'%[STRING]%\'
|
113
|
OR [TP]pages.page_id = [TP]mod_news_comments.page_id AND [TP]mod_news_comments.comment LIKE \'%[STRING]%\'
|
114
|
OR [TP]pages.page_id = [TP]mod_news_settings.page_id AND [TP]mod_news_settings.header LIKE \'%[STRING]%\'
|
115
|
OR [TP]pages.page_id = [TP]mod_news_settings.page_id AND [TP]mod_news_settings.footer LIKE \'%[STRING]%\'
|
116
|
OR [TP]pages.page_id = [TP]mod_news_settings.page_id AND [TP]mod_news_settings.post_header LIKE \'%[STRING]%\'
|
117
|
OR [TP]pages.page_id = [TP]mod_news_settings.page_id AND [TP]mod_news_settings.post_footer LIKE \'%[STRING]%\'
|
118
|
OR [TP]pages.page_id = [TP]mod_news_settings.page_id AND [TP]mod_news_settings.comments_header LIKE \'%[STRING]%\'
|
119
|
OR [TP]pages.page_id = [TP]mod_news_settings.page_id AND [TP]mod_news_settings.comments_footer LIKE \'%[STRING]%\'
|
120
|
OR [TP]pages.page_id = [TP]mod_news_settings.page_id AND [TP]mod_news_settings.comments_footer LIKE \'%[STRING]%\'";
|
121
|
$database->query("INSERT INTO ".TABLE_PREFIX."search (name,value,extra) VALUES ('query_body', '$query_body_code', 'news')");
|
122
|
// Query end
|
123
|
$query_end_code = "";
|
124
|
$database->query("INSERT INTO ".TABLE_PREFIX."search (name,value,extra) VALUES ('query_end', '$query_end_code', 'news')");
|
125
|
|
126
|
// Insert blank row (there needs to be at least on row for the search to work)
|
127
|
$database->query("INSERT INTO ".TABLE_PREFIX."mod_news_posts (section_id,page_id) VALUES ('0', '0')");
|
128
|
$database->query("INSERT INTO ".TABLE_PREFIX."mod_news_groups (section_id,page_id) VALUES ('0', '0')");
|
129
|
$database->query("INSERT INTO ".TABLE_PREFIX."mod_news_comments (section_id,page_id) VALUES ('0', '0')");
|
130
|
$database->query("INSERT INTO ".TABLE_PREFIX."mod_news_settings (section_id,page_id) VALUES ('0', '0')");
|
131
|
|
132
|
// Make news post access files dir
|
133
|
make_dir(WB_PATH.PAGES_DIRECTORY.'/posts/');
|
134
|
|
135
|
}
|
136
|
|
137
|
?>
|