Project

General

Profile

« Previous | Next » 

Revision 1587

Added by darkviper almost 13 years ago

news: added sql-dump to create database tables, some little fixes in install/upgrade

View differences:

branches/2.8.x/CHANGELOG
11 11
! = Update/Change
12 12

  
13 13
=========================== add small Features 2.8.2 ==========================
14
25 Jan-2012 Build 1587 Werner v.d.Decken(DarkViper)
15
+ module news: added sql-dump to create database tables
16
# module news: some little fixes in install/upgrade
14 17
24 Jan-2012 Build 1586 Werner v.d.Decken(DarkViper)
15 18
+ added new method SqlImport() to class database
16 19
19 Jan-2012 Build 1585 Dietmar Woellbrink (Luisehahne)
branches/2.8.x/wb/admin/interface/version.php
52 52

  
53 53
// check if defined to avoid errors during installation (redirect to admin panel fails if PHP error/warnings are enabled)
54 54
if(!defined('VERSION')) define('VERSION', '2.8.2');
55
if(!defined('REVISION')) define('REVISION', '1586');
55
if(!defined('REVISION')) define('REVISION', '1587');
56 56
if(!defined('SP')) define('SP', 'SP2');
branches/2.8.x/wb/modules/news/install.sql
1
-- phpMyAdmin SQL Dump
2
-- Erstellungszeit: 20. Januar 2012 um 12:37
3
-- Server Version: 5.1.41
4
SET SQL_MODE="NO_AUTO_VALUE_ON_ZERO";
5
-- --------------------------------------------------------
6
-- Database structure for module 'news'
7
--
8
-- Replacements: {TABLE_PREFIX}, {TABLE_ENGINE}, {TABLE_COLLATION}
9
--
10
-- --------------------------------------------------------
11
--
12
-- Tabellenstruktur für Tabelle `mod_news_comments`
13
--
14
DROP TABLE IF EXISTS `{TABLE_PREFIX}mod_news_comments`;
15
CREATE TABLE IF NOT EXISTS `{TABLE_PREFIX}mod_news_comments` (
16
  `comment_id` int(11) NOT NULL AUTO_INCREMENT,
17
  `section_id` int(11) NOT NULL DEFAULT '0',
18
  `page_id` int(11) NOT NULL DEFAULT '0',
19
  `post_id` int(11) NOT NULL DEFAULT '0',
20
  `title` varchar(255){TABLE_COLLATION} NOT NULL,
21
  `comment` text{TABLE_COLLATION} NOT NULL,
22
  `commented_when` int(11) NOT NULL DEFAULT '0',
23
  `commented_by` int(11) NOT NULL DEFAULT '0',
24
  PRIMARY KEY (`comment_id`)
25
){TABLE_ENGINE};
26
-- --------------------------------------------------------
27
--
28
-- Tabellenstruktur für Tabelle `mod_news_groups`
29
--
30
DROP TABLE IF EXISTS `{TABLE_PREFIX}mod_news_groups`;
31
CREATE TABLE IF NOT EXISTS `{TABLE_PREFIX}mod_news_groups` (
32
  `group_id` int(11) NOT NULL AUTO_INCREMENT,
33
  `section_id` int(11) NOT NULL DEFAULT '0',
34
  `page_id` int(11) NOT NULL DEFAULT '0',
35
  `active` int(11) NOT NULL DEFAULT '0',
36
  `position` int(11) NOT NULL DEFAULT '0',
37
  `title` varchar(255){TABLE_COLLATION} NOT NULL,
38
  PRIMARY KEY (`group_id`)
39
){TABLE_ENGINE};
40
-- --------------------------------------------------------
41
--
42
-- Tabellenstruktur für Tabelle `mod_news_posts`
43
--
44
DROP TABLE IF EXISTS `{TABLE_PREFIX}mod_news_posts`;
45
CREATE TABLE IF NOT EXISTS `{TABLE_PREFIX}mod_news_posts` (
46
  `post_id` int(11) NOT NULL AUTO_INCREMENT,
47
  `section_id` int(11) NOT NULL DEFAULT '0',
48
  `page_id` int(11) NOT NULL DEFAULT '0',
49
  `group_id` int(11) NOT NULL DEFAULT '0',
50
  `active` int(11) NOT NULL DEFAULT '0',
51
  `position` int(11) NOT NULL DEFAULT '0',
52
  `title` varchar(255){TABLE_COLLATION} NOT NULL,
53
  `link` text{TABLE_COLLATION} NOT NULL,
54
  `content_short` text{TABLE_COLLATION} NOT NULL,
55
  `content_long` text{TABLE_COLLATION} NOT NULL,
56
  `commenting` varchar(7){TABLE_COLLATION} NOT NULL,
57
  `created_when` int(11) NOT NULL,
58
  `created_by` int(11) NOT NULL,
59
  `published_when` int(11) NOT NULL DEFAULT '0',
60
  `published_until` int(11) NOT NULL DEFAULT '0',
61
  `posted_when` int(11) NOT NULL DEFAULT '0',
62
  `posted_by` int(11) NOT NULL DEFAULT '0',
63
  PRIMARY KEY (`post_id`)
64
){TABLE_ENGINE};
65
-- --------------------------------------------------------
66
--
67
-- Tabellenstruktur für Tabelle `mod_news_settings`
68
--
69
DROP TABLE IF EXISTS `{TABLE_PREFIX}mod_news_settings`;
70
CREATE TABLE IF NOT EXISTS `{TABLE_PREFIX}mod_news_settings` (
71
  `section_id` int(11) NOT NULL DEFAULT '0',
72
  `page_id` int(11) NOT NULL DEFAULT '0',
73
  `header` text{TABLE_COLLATION} NOT NULL,
74
  `post_loop` text{TABLE_COLLATION} NOT NULL,
75
  `footer` text{TABLE_COLLATION} NOT NULL,
76
  `posts_per_page` int(11) NOT NULL DEFAULT '0',
77
  `post_header` text{TABLE_COLLATION} NOT NULL,
78
  `post_footer` text{TABLE_COLLATION} NOT NULL,
79
  `comments_header` text{TABLE_COLLATION} NOT NULL,
80
  `comments_loop` text{TABLE_COLLATION} NOT NULL,
81
  `comments_footer` text{TABLE_COLLATION} NOT NULL,
82
  `comments_page` text{TABLE_COLLATION} NOT NULL,
83
  `commenting` varchar(7){TABLE_COLLATION} NOT NULL,
84
  `resize` int(11) NOT NULL DEFAULT '0',
85
  `use_captcha` int(11) NOT NULL DEFAULT '0',
86
  PRIMARY KEY (`section_id`)
87
){TABLE_ENGINE};
88
-- EndOfFile
branches/2.8.x/wb/modules/news/upgrade.php
15 15
 *
16 16
 */
17 17

  
18
// Must include code to stop this file being access directly
19 18
/* -------------------------------------------------------- */
20
if(defined('WB_PATH') == false)
21
{
22
	// Stop this file being access directly
23
		die('<head><title>Access denied</title></head><body><h2 style="color:red;margin:3em auto;text-align:center;">Cannot access this file directly</h2></body></html>');
24
}
25

  
19
// Must include code to stop this file being accessed directly
20
require_once( dirname(dirname(dirname(__FILE__))).'/framework/globalExceptionHandler.php');
21
if(!defined('WB_PATH')) { throw new IllegalFileException(); }
22
/* -------------------------------------------------------- */
26 23
/* **** START UPGRADE ******************************************************* */
27 24
if(!function_exists('mod_news_Upgrade'))
28 25
{
......
124 121

  
125 122
	// rebuild all access-files
126 123
		$count = 0;
127
		// $backSteps = preg_replace('/^'.preg_quote(WB_PATH).'/', '', $sPostsPath);
128 124
		$backSteps = preg_replace('@^'.preg_quote(WB_PATH).'@', '', $sPostsPath);
129 125
		$backSteps = str_repeat( '../', substr_count($backSteps, '/'));
130 126
		$sql  = 'SELECT `page_id`,`post_id`,`section_id`,`link` ';
......
146 142
					"\t".'$section_id = '.$recPost['section_id'].';'."\n".
147 143
					"\t".'$post_id    = '.$recPost['post_id'].';'."\n".
148 144
					"\t".'$post_section = '.$recPost['section_id'].';'."\n".
149
//					"\t".'define(\'POST_SECTION\', '.$recPost['section_id'].');'."\n".
150
//					"\t".'define(\'POST_ID\',      '.$recPost['post_id'].');'."\n".
151 145
					"\t".'require(\''.$backSteps.'index.php\');'."\n".
152 146
					'// *************************************************'."\n";
153 147
				if( file_put_contents($file, $content) !== false ) {
......
165 159
			}
166 160
		}
167 161
		if($globalStarted) { $msg[] = 'created '.$count.' new accessfiles.'; }
168
		// if(!$globalStarted) { $admin->print_footer(); }
169 162
	}
170 163
}
171 164

  
172
$msg = array();
173
$aTable = array('mod_news_posts','mod_news_groups','mod_news_comments','mod_news_settings');
174
for($x=0; $x<sizeof($aTable);$x++) {
175
	if(($sOldType = $database->getTableEngine(TABLE_PREFIX.$aTable[$x]))) {
176
		if(('myisam' != strtolower($sOldType))) {
177
			if(!$database->query('ALTER TABLE `'.TABLE_PREFIX.$aTable[$x].'` Engine = \'MyISAM\' ')) {
178
				$msg[] = $database->get_error();
165
	$msg = array();
166
	$aTable = array('mod_news_posts','mod_news_groups','mod_news_comments','mod_news_settings');
167
	for($x=0; $x<sizeof($aTable);$x++) {
168
		if(($sOldType = $database->getTableEngine(TABLE_PREFIX.$aTable[$x]))) {
169
			if(('myisam' != strtolower($sOldType))) {
170
				if(!$database->query('ALTER TABLE `'.TABLE_PREFIX.$aTable[$x].'` Engine = \'MyISAM\' ')) {
171
					$msg[] = $database->get_error();
172
				}
179 173
			}
174
		} else {
175
			$msg[] = $database->get_error();
180 176
		}
181
	} else {
182
		$msg[] = $database->get_error();
183 177
	}
184
}
185 178
// ------------------------------------
186 179
	mod_news_Upgrade();
187
/* **** END UPGRADE ********************************************************* */
180
/* **** END UPGRADE ********************************************************* */
branches/2.8.x/wb/modules/news/install.php
14 14
 * @lastmodified    $Date$
15 15
 *
16 16
 */
17

  
18
if(defined('WB_URL'))
19
{
20
	
21
	// $database->query("DROP TABLE IF EXISTS `".TABLE_PREFIX."mod_news_posts`");
22
	$mod_news = 'CREATE TABLE IF NOT EXISTS `'.TABLE_PREFIX.'mod_news_posts` ( '
23
					 . '`post_id` INT NOT NULL AUTO_INCREMENT,'
24
					 . '`section_id` INT NOT NULL DEFAULT \'0\','
25
					 . '`page_id` INT NOT NULL DEFAULT \'0\','
26
					 . '`group_id` INT NOT NULL DEFAULT \'0\','
27
					 . '`active` INT NOT NULL DEFAULT \'0\','
28
					 . '`position` INT NOT NULL DEFAULT \'0\','
29
					 . '`title` VARCHAR(255) NOT NULL DEFAULT \'\','
30
					 . '`link` TEXT NOT NULL ,'
31
					 . '`content_short` TEXT NOT NULL ,'
32
					 . '`content_long` TEXT NOT NULL ,'
33
					 . '`commenting` VARCHAR(7) NOT NULL DEFAULT \'\','
34
					 . '`created_when` INT NOT NULL DEFAULT \'0\','
35
					 . '`created_by` INT NOT NULL DEFAULT \'0\','
36
					 . '`published_when` INT NOT NULL DEFAULT \'0\','
37
					 . '`published_until` INT NOT NULL DEFAULT \'0\','
38
					 . '`posted_when` INT NOT NULL DEFAULT \'0\','
39
					 . '`posted_by` INT NOT NULL DEFAULT \'0\','
40
					 . 'PRIMARY KEY (post_id)'
41
					 . ' ) ENGINE=MyISAM DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci';
42
	$database->query($mod_news);
43
	
44
	// $database->query("DROP TABLE IF EXISTS `".TABLE_PREFIX."mod_news_groups`");
45
	$mod_news = 'CREATE TABLE IF NOT EXISTS `'.TABLE_PREFIX.'mod_news_groups` ( '
46
					 . '`group_id` INT NOT NULL AUTO_INCREMENT,'
47
					 . '`section_id` INT NOT NULL DEFAULT \'0\','
48
					 . '`page_id` INT NOT NULL DEFAULT \'0\','
49
					 . '`active` INT NOT NULL DEFAULT \'0\','
50
					 . '`position` INT NOT NULL DEFAULT \'0\','
51
					 . '`title` VARCHAR(255) NOT NULL DEFAULT \'\','
52
					 . 'PRIMARY KEY (group_id)'
53
                . ' ) ENGINE=MyISAM DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci';
54
	$database->query($mod_news);
55
	
56
	// $database->query("DROP TABLE IF EXISTS `".TABLE_PREFIX."mod_news_comments`");
57
	$mod_news = 'CREATE TABLE IF NOT EXISTS `'.TABLE_PREFIX.'mod_news_comments` ( '
58
					 . '`comment_id` INT NOT NULL AUTO_INCREMENT,'
59
					 . '`section_id` INT NOT NULL DEFAULT \'0\','
60
					 . '`page_id` INT NOT NULL DEFAULT \'0\','
61
					 . '`post_id` INT NOT NULL DEFAULT \'0\','
62
					 . '`title` VARCHAR(255) NOT NULL DEFAULT \'\','
63
					 . '`comment` TEXT NOT NULL ,'
64
					 . '`commented_when` INT NOT NULL DEFAULT \'0\','
65
					 . '`commented_by` INT NOT NULL DEFAULT \'0\','
66
					 . 'PRIMARY KEY (comment_id)'
67
                . ' ) ENGINE=MyISAM DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci';
68

  
69
	$database->query($mod_news);
70
	
71
	// $database->query("DROP TABLE IF EXISTS `".TABLE_PREFIX."mod_news_settings`");
72
	$mod_news = 'CREATE TABLE IF NOT EXISTS `'.TABLE_PREFIX.'mod_news_settings` ( '
73
					 . '`section_id` INT NOT NULL DEFAULT \'0\','
74
					 . '`page_id` INT NOT NULL DEFAULT \'0\','
75
					 . '`header` TEXT NOT NULL ,'
76
					 . '`post_loop` TEXT NOT NULL ,'
77
					 . '`footer` TEXT NOT NULL ,'
78
					 . '`posts_per_page` INT NOT NULL DEFAULT \'0\','
79
					 . '`post_header` TEXT NOT NULL,'
80
					 . '`post_footer` TEXT NOT NULL,'
81
					 . '`comments_header` TEXT NOT NULL,'
82
					 . '`comments_loop` TEXT NOT NULL,'
83
					 . '`comments_footer` TEXT NOT NULL,'
84
					 . '`comments_page` TEXT NOT NULL,'
85
					 . '`commenting` VARCHAR(7) NOT NULL DEFAULT \'\','
86
					 . '`resize` INT NOT NULL DEFAULT \'0\','
87
					 . ' `use_captcha` INT NOT NULL DEFAULT \'0\','
88
					 . 'PRIMARY KEY (section_id)'
89
                . ' ) ENGINE=MyISAM DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci';
90

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

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

  
136
	// Make news post access files dir
137
	require_once(WB_PATH.'/framework/functions.php');
138
	if(make_dir(WB_PATH.PAGES_DIRECTORY.'/posts')) {
139
		// Add a index.php file to prevent directory spoofing
140
		$content = ''.
141
"<?php
142

  
143
/*
144

  
145
 Website Baker Project <http://www.websitebaker.org/>
146
 Copyright (C) 2004-2009, Ryan Djurovich
147

  
148
 Website Baker is free software; you can redistribute it and/or modify
149
 it under the terms of the GNU General Public License as published by
150
 the Free Software Foundation; either version 2 of the License, or
151
 (at your option) any later version.
152

  
153
 Website Baker is distributed in the hope that it will be useful,
154
 but WITHOUT ANY WARRANTY; without even the implied warranty of
155
 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
156
 GNU General Public License for more details.
157

  
158
 You should have received a copy of the GNU General Public License
159
 along with Website Baker; if not, write to the Free Software
160
 Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
161

  
162
*/
163

  
164
header('Location: ../');
165
?>";
166
		$handle = fopen(WB_PATH.PAGES_DIRECTORY.'/posts/index.php', 'w');
167
		fwrite($handle, $content);
168
		fclose($handle);
169
		change_mode(WB_PATH.PAGES_DIRECTORY.'/posts/index.php', 'file');
17
/* -------------------------------------------------------- */
18
// Must include code to stop this file being accessed directly
19
require_once( dirname(dirname(dirname(__FILE__))).'/framework/globalExceptionHandler.php');
20
if(!defined('WB_PATH')) { throw new IllegalFileException(); }
21
/* -------------------------------------------------------- */
22
	$sDefaultSql = dirname(__FILE__).'/install.sql';
23
	if (is_readable($sDefaultSql)) {
24
// create needet database tables and set default records
25
		if ($database->SqlImport($sDefaultSql, TABLE_PREFIX)) {
26
// Make news post access files dir
27
			require_once(WB_PATH.'/framework/functions.php');
28
			if(make_dir(WB_PATH.PAGES_DIRECTORY.'/posts')) {
29
				// Add a index.php file to prevent directory spoofing
30
				$sResponse  = $_SERVER['SERVER_PROTOCOL'].' 301 Moved Permanently';
31
				$sContent =
32
					'<?php'."\n".
33
					'// *** This file is generated by WebsiteBaker Ver.'.VERSION."\n".
34
					'// *** Creation date: '.date('c')."\n".
35
					'// *** Do not modify this file manually'."\n".
36
					'// *** WB will rebuild this file from time to time!!'."\n".
37
					'// *************************************************'."\n".
38
					"\t".'header(\''.$sResponse.'\');'."\n".
39
					"\t".'header(\'Location: ../index.php\');'."\n".
40
					'// *************************************************'."\n";
41
				$sFilename = WB_PATH.PAGES_DIRECTORY.'/posts/index.php';
42
				file_put_contents($sFilename, $sContent);
43
				change_mode($sFilename, 'file');
44
			}
45
		}
170 46
	}
171
};
47
/* **** END INSTALL ********************************************************* */

Also available in: Unified diff