1 |
4
|
ryan
|
<?php
|
2 |
|
|
|
3 |
103
|
ryan
|
// $Id$
|
4 |
4
|
ryan
|
|
5 |
|
|
/*
|
6 |
|
|
|
7 |
|
|
Website Baker Project <http://www.websitebaker.org/>
|
8 |
519
|
Ruebenwurz
|
Copyright (C) 2004-2008, Ryan Djurovich
|
9 |
4
|
ryan
|
|
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 |
|
|
/*
|
27 |
|
|
The Website Baker Project would like to thank Rudolph Lartey <www.carbonect.com>
|
28 |
|
|
for his contributions to this module - adding extra field types
|
29 |
|
|
*/
|
30 |
|
|
|
31 |
|
|
if(defined('WB_URL')) {
|
32 |
|
|
|
33 |
317
|
stefan
|
// Create tables
|
34 |
|
|
$database->query("DROP TABLE IF EXISTS `".TABLE_PREFIX."mod_form_fields`");
|
35 |
|
|
$mod_form = 'CREATE TABLE `'.TABLE_PREFIX.'mod_form_fields` ( `field_id` INT NOT NULL AUTO_INCREMENT,'
|
36 |
371
|
Ruebenwurz
|
. ' `section_id` INT NOT NULL DEFAULT \'0\' ,'
|
37 |
|
|
. ' `page_id` INT NOT NULL DEFAULT \'0\' ,'
|
38 |
|
|
. ' `position` INT NOT NULL DEFAULT \'0\' ,'
|
39 |
|
|
. ' `title` VARCHAR(255) NOT NULL DEFAULT \'\' ,'
|
40 |
|
|
. ' `type` VARCHAR(255) NOT NULL DEFAULT \'\' ,'
|
41 |
|
|
. ' `required` INT NOT NULL DEFAULT \'0\' ,'
|
42 |
|
|
. ' `value` TEXT NOT NULL ,'
|
43 |
|
|
. ' `extra` TEXT NOT NULL ,'
|
44 |
|
|
. ' PRIMARY KEY ( `field_id` ) '
|
45 |
|
|
. ' )';
|
46 |
317
|
stefan
|
$database->query($mod_form);
|
47 |
|
|
$database->query("DROP TABLE IF EXISTS `".TABLE_PREFIX."mod_form_settings`");
|
48 |
|
|
$mod_form = 'CREATE TABLE `'.TABLE_PREFIX.'mod_form_settings` ('
|
49 |
371
|
Ruebenwurz
|
. ' `section_id` INT NOT NULL DEFAULT \'0\' ,'
|
50 |
|
|
. ' `page_id` INT NOT NULL DEFAULT \'0\' ,'
|
51 |
|
|
. ' `header` TEXT NOT NULL ,'
|
52 |
|
|
. ' `field_loop` TEXT NOT NULL ,'
|
53 |
|
|
. ' `footer` TEXT NOT NULL ,'
|
54 |
|
|
. ' `email_to` TEXT NOT NULL ,'
|
55 |
|
|
. ' `email_from` VARCHAR(255) NOT NULL DEFAULT \'\' ,'
|
56 |
|
|
. ' `email_subject` VARCHAR(255) NOT NULL DEFAULT \'\' ,'
|
57 |
|
|
. ' `success_message` TEXT NOT NULL ,'
|
58 |
|
|
. ' `stored_submissions` INT NOT NULL DEFAULT \'0\' ,'
|
59 |
|
|
. ' `max_submissions` INT NOT NULL DEFAULT \'0\' ,'
|
60 |
|
|
. ' `use_captcha` INT NOT NULL DEFAULT \'0\' ,'
|
61 |
|
|
. ' PRIMARY KEY ( `section_id` ) '
|
62 |
|
|
. ' )';
|
63 |
317
|
stefan
|
$database->query($mod_form);
|
64 |
|
|
$database->query("DROP TABLE IF EXISTS `".TABLE_PREFIX."mod_form_submissions`");
|
65 |
|
|
$mod_form = 'CREATE TABLE `'.TABLE_PREFIX.'mod_form_submissions` ( `submission_id` INT NOT NULL AUTO_INCREMENT,'
|
66 |
371
|
Ruebenwurz
|
. ' `section_id` INT NOT NULL DEFAULT \'0\' ,'
|
67 |
|
|
. ' `page_id` INT NOT NULL DEFAULT \'0\' ,'
|
68 |
|
|
. ' `submitted_when` INT NOT NULL DEFAULT \'0\' ,'
|
69 |
|
|
. ' `submitted_by` INT NOT NULL DEFAULT \'0\','
|
70 |
|
|
. ' `body` TEXT NOT NULL,'
|
71 |
|
|
. ' PRIMARY KEY ( `submission_id` ) '
|
72 |
|
|
. ' )';
|
73 |
4
|
ryan
|
$database->query($mod_form);
|
74 |
317
|
stefan
|
|
75 |
|
|
// Insert info into the search table
|
76 |
|
|
// Module query info
|
77 |
|
|
$field_info = array();
|
78 |
|
|
$field_info['page_id'] = 'page_id';
|
79 |
|
|
$field_info['title'] = 'page_title';
|
80 |
4
|
ryan
|
$field_info['link'] = 'link';
|
81 |
|
|
$field_info['description'] = 'description';
|
82 |
|
|
$field_info['modified_when'] = 'modified_when';
|
83 |
317
|
stefan
|
$field_info['modified_by'] = 'modified_by';
|
84 |
|
|
$field_info = serialize($field_info);
|
85 |
|
|
$database->query("INSERT INTO ".TABLE_PREFIX."search (name,value,extra) VALUES ('module', 'form', '$field_info')");
|
86 |
|
|
// Query start
|
87 |
|
|
$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_form_fields, [TP]mod_form_settings, [TP]pages WHERE ";
|
88 |
|
|
$database->query("INSERT INTO ".TABLE_PREFIX."search (name,value,extra) VALUES ('query_start', '$query_start_code', 'form')");
|
89 |
|
|
// Query body
|
90 |
415
|
Ruebenwurz
|
$query_body_code = " [TP]pages.page_id = [TP]mod_form_settings.page_id AND [TP]mod_form_settings.header LIKE \'%[STRING]%\'
|
91 |
|
|
OR [TP]pages.page_id = [TP]mod_form_settings.page_id AND [TP]mod_form_settings.footer LIKE \'%[STRING]%\'
|
92 |
|
|
OR [TP]pages.page_id = [TP]mod_form_fields.page_id AND [TP]mod_form_fields.title LIKE \'%[STRING]%\' ";
|
93 |
317
|
stefan
|
$database->query("INSERT INTO ".TABLE_PREFIX."search (name,value,extra) VALUES ('query_body', '$query_body_code', 'form')");
|
94 |
|
|
// Query end
|
95 |
415
|
Ruebenwurz
|
$query_end_code = "";
|
96 |
317
|
stefan
|
$database->query("INSERT INTO ".TABLE_PREFIX."search (name,value,extra) VALUES ('query_end', '$query_end_code', 'form')");
|
97 |
|
|
|
98 |
|
|
// Insert blank row (there needs to be at least on row for the search to work)
|
99 |
|
|
$database->query("INSERT INTO ".TABLE_PREFIX."mod_form_fields (page_id,section_id) VALUES ('0','0')");
|
100 |
|
|
$database->query("INSERT INTO ".TABLE_PREFIX."mod_form_settings (page_id,section_id) VALUES ('0','0')");
|
101 |
4
|
ryan
|
|
102 |
|
|
}
|
103 |
317
|
stefan
|
|
104 |
399
|
Ruebenwurz
|
?>
|