Project

General

Profile

« Previous | Next » 

Revision 1157

Added by Dietmar about 15 years ago

Ticket #770, #785, #792, #807, #809, fixes and recoded the news module

View differences:

install.php
25 25

  
26 26
if(defined('WB_URL')) {
27 27
	
28
	$database->query("DROP TABLE IF EXISTS `".TABLE_PREFIX."mod_news_posts`");
29
	$mod_news = 'CREATE TABLE `'.TABLE_PREFIX.'mod_news_posts` ( '
28
	// $database->query("DROP TABLE IF EXISTS `".TABLE_PREFIX."mod_news_posts`");
29
	$mod_news = 'CREATE TABLE IF NOT EXISTS `'.TABLE_PREFIX.'mod_news_posts` ( '
30 30
					 . '`post_id` INT NOT NULL AUTO_INCREMENT,'
31 31
					 . '`section_id` INT NOT NULL DEFAULT \'0\','
32 32
					 . '`page_id` INT NOT NULL DEFAULT \'0\','
......
46 46
					 . ' )';
47 47
	$database->query($mod_news);
48 48
	
49
	$database->query("DROP TABLE IF EXISTS `".TABLE_PREFIX."mod_news_groups`");
50
	$mod_news = 'CREATE TABLE `'.TABLE_PREFIX.'mod_news_groups` ( '
49
	// $database->query("DROP TABLE IF EXISTS `".TABLE_PREFIX."mod_news_groups`");
50
	$mod_news = 'CREATE TABLE IF NOT EXISTS `'.TABLE_PREFIX.'mod_news_groups` ( '
51 51
					 . '`group_id` INT NOT NULL AUTO_INCREMENT,'
52 52
					 . '`section_id` INT NOT NULL DEFAULT \'0\','
53 53
					 . '`page_id` INT NOT NULL DEFAULT \'0\','
......
58 58
                . ' )';
59 59
	$database->query($mod_news);
60 60
	
61
	$database->query("DROP TABLE IF EXISTS `".TABLE_PREFIX."mod_news_comments`");
62
	$mod_news = 'CREATE TABLE `'.TABLE_PREFIX.'mod_news_comments` ( '
61
	// $database->query("DROP TABLE IF EXISTS `".TABLE_PREFIX."mod_news_comments`");
62
	$mod_news = 'CREATE TABLE IF NOT EXISTS `'.TABLE_PREFIX.'mod_news_comments` ( '
63 63
					 . '`comment_id` INT NOT NULL AUTO_INCREMENT,'
64 64
					 . '`section_id` INT NOT NULL DEFAULT \'0\','
65 65
					 . '`page_id` INT NOT NULL DEFAULT \'0\','
......
72 72
                . ' )';
73 73
	$database->query($mod_news);
74 74
	
75
	$database->query("DROP TABLE IF EXISTS `".TABLE_PREFIX."mod_news_settings`");
76
	$mod_news = 'CREATE TABLE `'.TABLE_PREFIX.'mod_news_settings` ( '
75
	// $database->query("DROP TABLE IF EXISTS `".TABLE_PREFIX."mod_news_settings`");
76
	$mod_news = 'CREATE TABLE IF NOT EXISTS `'.TABLE_PREFIX.'mod_news_settings` ( '
77 77
					 . '`section_id` INT NOT NULL DEFAULT \'0\','
78 78
					 . '`page_id` INT NOT NULL DEFAULT \'0\','
79 79
					 . '`header` TEXT NOT NULL ,'
......
93 93
                . ' )';
94 94
	$database->query($mod_news);
95 95
		
96
	// Insert info into the search table
97
	// Module query info
98
	$field_info = array();
99
	$field_info['page_id'] = 'page_id';
100
	$field_info['title'] = 'page_title';
101
	$field_info['link'] = 'link';
102
	$field_info['description'] = 'description';
103
	$field_info['modified_when'] = 'modified_when';
104
	$field_info['modified_by'] = 'modified_by';
105
	$field_info = serialize($field_info);
106
	$database->query("INSERT INTO ".TABLE_PREFIX."search (name,value,extra) VALUES ('module', 'news', '$field_info')");
107
	// Query start
108
	$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 ";
109
	$database->query("INSERT INTO ".TABLE_PREFIX."search (name,value,extra) VALUES ('query_start', '$query_start_code', 'news')");
110
	// Query body
111
	$query_body_code = "
112
	[TP]pages.page_id = [TP]mod_news_posts.page_id AND [TP]mod_news_posts.title LIKE \'%[STRING]%\'
113
	OR [TP]pages.page_id = [TP]mod_news_posts.page_id AND [TP]mod_news_posts.content_short LIKE \'%[STRING]%\'
114
	OR [TP]pages.page_id = [TP]mod_news_posts.page_id AND [TP]mod_news_posts.content_long LIKE \'%[STRING]%\'
115
	OR [TP]pages.page_id = [TP]mod_news_comments.page_id AND [TP]mod_news_comments.title LIKE \'%[STRING]%\'
116
	OR [TP]pages.page_id = [TP]mod_news_comments.page_id AND [TP]mod_news_comments.comment LIKE \'%[STRING]%\'
117
	OR [TP]pages.page_id = [TP]mod_news_settings.page_id AND [TP]mod_news_settings.header LIKE \'%[STRING]%\'
118
	OR [TP]pages.page_id = [TP]mod_news_settings.page_id AND [TP]mod_news_settings.footer LIKE \'%[STRING]%\'
119
	OR [TP]pages.page_id = [TP]mod_news_settings.page_id AND [TP]mod_news_settings.post_header LIKE \'%[STRING]%\'
120
	OR [TP]pages.page_id = [TP]mod_news_settings.page_id AND [TP]mod_news_settings.post_footer LIKE \'%[STRING]%\'
121
	OR [TP]pages.page_id = [TP]mod_news_settings.page_id AND [TP]mod_news_settings.comments_header LIKE \'%[STRING]%\'
122
	OR [TP]pages.page_id = [TP]mod_news_settings.page_id AND [TP]mod_news_settings.comments_footer LIKE \'%[STRING]%\'";
123
	$database->query("INSERT INTO ".TABLE_PREFIX."search (name,value,extra) VALUES ('query_body', '$query_body_code', 'news')");
124
	// Query end
125
	$query_end_code = "";	
126
	$database->query("INSERT INTO ".TABLE_PREFIX."search (name,value,extra) VALUES ('query_end', '$query_end_code', 'news')");
127
	
128
	// Insert blank row (there needs to be at least on row for the search to work)
129
	$database->query("INSERT INTO ".TABLE_PREFIX."mod_news_posts (section_id,page_id) VALUES ('0', '0')");
130
	$database->query("INSERT INTO ".TABLE_PREFIX."mod_news_groups (section_id,page_id) VALUES ('0', '0')");
131
	$database->query("INSERT INTO ".TABLE_PREFIX."mod_news_comments (section_id,page_id) VALUES ('0', '0')");
132
	$database->query("INSERT INTO ".TABLE_PREFIX."mod_news_settings (section_id,page_id) VALUES ('0', '0')");
133
	
96
    $mod_search = "SELECT * FROM ".TABLE_PREFIX."search  WHERE value = 'mod_wysiwyg_query'";
97
    $database->query($mod_search);
98
    $insert_search = $database->is_error();
99

  
100
    if( $insert_search )
101
    {
102
    	// Insert info into the search table
103
    	// Module query info
104
    	$field_info = array();
105
    	$field_info['page_id'] = 'page_id';
106
    	$field_info['title'] = 'page_title';
107
    	$field_info['link'] = 'link';
108
    	$field_info['description'] = 'description';
109
    	$field_info['modified_when'] = 'modified_when';
110
    	$field_info['modified_by'] = 'modified_by';
111
    	$field_info = serialize($field_info);
112
    	$database->query("INSERT INTO ".TABLE_PREFIX."search (name,value,extra) VALUES ('module', 'news', '$field_info')");
113
    	// Query start
114
    	$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 ";
115
    	$database->query("INSERT INTO ".TABLE_PREFIX."search (name,value,extra) VALUES ('query_start', '$query_start_code', 'news')");
116
    	// Query body
117
    	$query_body_code = "
118
    	[TP]pages.page_id = [TP]mod_news_posts.page_id AND [TP]mod_news_posts.title LIKE \'%[STRING]%\'
119
    	OR [TP]pages.page_id = [TP]mod_news_posts.page_id AND [TP]mod_news_posts.content_short LIKE \'%[STRING]%\'
120
    	OR [TP]pages.page_id = [TP]mod_news_posts.page_id AND [TP]mod_news_posts.content_long LIKE \'%[STRING]%\'
121
    	OR [TP]pages.page_id = [TP]mod_news_comments.page_id AND [TP]mod_news_comments.title LIKE \'%[STRING]%\'
122
    	OR [TP]pages.page_id = [TP]mod_news_comments.page_id AND [TP]mod_news_comments.comment LIKE \'%[STRING]%\'
123
    	OR [TP]pages.page_id = [TP]mod_news_settings.page_id AND [TP]mod_news_settings.header LIKE \'%[STRING]%\'
124
    	OR [TP]pages.page_id = [TP]mod_news_settings.page_id AND [TP]mod_news_settings.footer LIKE \'%[STRING]%\'
125
    	OR [TP]pages.page_id = [TP]mod_news_settings.page_id AND [TP]mod_news_settings.post_header LIKE \'%[STRING]%\'
126
    	OR [TP]pages.page_id = [TP]mod_news_settings.page_id AND [TP]mod_news_settings.post_footer LIKE \'%[STRING]%\'
127
    	OR [TP]pages.page_id = [TP]mod_news_settings.page_id AND [TP]mod_news_settings.comments_header LIKE \'%[STRING]%\'
128
    	OR [TP]pages.page_id = [TP]mod_news_settings.page_id AND [TP]mod_news_settings.comments_footer LIKE \'%[STRING]%\'";
129
    	$database->query("INSERT INTO ".TABLE_PREFIX."search (name,value,extra) VALUES ('query_body', '$query_body_code', 'news')");
130
    	// Query end
131
    	$query_end_code = "";
132
    	$database->query("INSERT INTO ".TABLE_PREFIX."search (name,value,extra) VALUES ('query_end', '$query_end_code', 'news')");
133

  
134
    	// Insert blank row (there needs to be at least on row for the search to work)
135
    	$database->query("INSERT INTO ".TABLE_PREFIX."mod_news_posts (section_id,page_id) VALUES ('0', '0')");
136
    	$database->query("INSERT INTO ".TABLE_PREFIX."mod_news_groups (section_id,page_id) VALUES ('0', '0')");
137
    	$database->query("INSERT INTO ".TABLE_PREFIX."mod_news_comments (section_id,page_id) VALUES ('0', '0')");
138
    	$database->query("INSERT INTO ".TABLE_PREFIX."mod_news_settings (section_id,page_id) VALUES ('0', '0')");
139
    }
140

  
134 141
	// Make news post access files dir
135 142
	require_once(WB_PATH.'/framework/functions.php');
136 143
	if(make_dir(WB_PATH.PAGES_DIRECTORY.'/posts')) {

Also available in: Unified diff