Index: branches/2.8.x/CHANGELOG
===================================================================
--- branches/2.8.x/CHANGELOG	(revision 1586)
+++ branches/2.8.x/CHANGELOG	(revision 1587)
@@ -11,6 +11,9 @@
 ! = Update/Change
 
 =========================== add small Features 2.8.2 ==========================
+25 Jan-2012 Build 1587 Werner v.d.Decken(DarkViper)
++ module news: added sql-dump to create database tables
+# module news: some little fixes in install/upgrade
 24 Jan-2012 Build 1586 Werner v.d.Decken(DarkViper)
 + added new method SqlImport() to class database
 19 Jan-2012 Build 1585 Dietmar Woellbrink (Luisehahne)
Index: branches/2.8.x/wb/admin/interface/version.php
===================================================================
--- branches/2.8.x/wb/admin/interface/version.php	(revision 1586)
+++ branches/2.8.x/wb/admin/interface/version.php	(revision 1587)
@@ -52,5 +52,5 @@
 
 // check if defined to avoid errors during installation (redirect to admin panel fails if PHP error/warnings are enabled)
 if(!defined('VERSION')) define('VERSION', '2.8.2');
-if(!defined('REVISION')) define('REVISION', '1586');
+if(!defined('REVISION')) define('REVISION', '1587');
 if(!defined('SP')) define('SP', 'SP2');
Index: branches/2.8.x/wb/modules/news/install.sql
===================================================================
--- branches/2.8.x/wb/modules/news/install.sql	(nonexistent)
+++ branches/2.8.x/wb/modules/news/install.sql	(revision 1587)
@@ -0,0 +1,88 @@
+-- phpMyAdmin SQL Dump
+-- Erstellungszeit: 20. Januar 2012 um 12:37
+-- Server Version: 5.1.41
+SET SQL_MODE="NO_AUTO_VALUE_ON_ZERO";
+-- --------------------------------------------------------
+-- Database structure for module 'news'
+--
+-- Replacements: {TABLE_PREFIX}, {TABLE_ENGINE}, {TABLE_COLLATION}
+--
+-- --------------------------------------------------------
+--
+-- Tabellenstruktur für Tabelle `mod_news_comments`
+--
+DROP TABLE IF EXISTS `{TABLE_PREFIX}mod_news_comments`;
+CREATE TABLE IF NOT EXISTS `{TABLE_PREFIX}mod_news_comments` (
+  `comment_id` int(11) NOT NULL AUTO_INCREMENT,
+  `section_id` int(11) NOT NULL DEFAULT '0',
+  `page_id` int(11) NOT NULL DEFAULT '0',
+  `post_id` int(11) NOT NULL DEFAULT '0',
+  `title` varchar(255){TABLE_COLLATION} NOT NULL,
+  `comment` text{TABLE_COLLATION} NOT NULL,
+  `commented_when` int(11) NOT NULL DEFAULT '0',
+  `commented_by` int(11) NOT NULL DEFAULT '0',
+  PRIMARY KEY (`comment_id`)
+){TABLE_ENGINE};
+-- --------------------------------------------------------
+--
+-- Tabellenstruktur für Tabelle `mod_news_groups`
+--
+DROP TABLE IF EXISTS `{TABLE_PREFIX}mod_news_groups`;
+CREATE TABLE IF NOT EXISTS `{TABLE_PREFIX}mod_news_groups` (
+  `group_id` int(11) NOT NULL AUTO_INCREMENT,
+  `section_id` int(11) NOT NULL DEFAULT '0',
+  `page_id` int(11) NOT NULL DEFAULT '0',
+  `active` int(11) NOT NULL DEFAULT '0',
+  `position` int(11) NOT NULL DEFAULT '0',
+  `title` varchar(255){TABLE_COLLATION} NOT NULL,
+  PRIMARY KEY (`group_id`)
+){TABLE_ENGINE};
+-- --------------------------------------------------------
+--
+-- Tabellenstruktur für Tabelle `mod_news_posts`
+--
+DROP TABLE IF EXISTS `{TABLE_PREFIX}mod_news_posts`;
+CREATE TABLE IF NOT EXISTS `{TABLE_PREFIX}mod_news_posts` (
+  `post_id` int(11) NOT NULL AUTO_INCREMENT,
+  `section_id` int(11) NOT NULL DEFAULT '0',
+  `page_id` int(11) NOT NULL DEFAULT '0',
+  `group_id` int(11) NOT NULL DEFAULT '0',
+  `active` int(11) NOT NULL DEFAULT '0',
+  `position` int(11) NOT NULL DEFAULT '0',
+  `title` varchar(255){TABLE_COLLATION} NOT NULL,
+  `link` text{TABLE_COLLATION} NOT NULL,
+  `content_short` text{TABLE_COLLATION} NOT NULL,
+  `content_long` text{TABLE_COLLATION} NOT NULL,
+  `commenting` varchar(7){TABLE_COLLATION} NOT NULL,
+  `created_when` int(11) NOT NULL,
+  `created_by` int(11) NOT NULL,
+  `published_when` int(11) NOT NULL DEFAULT '0',
+  `published_until` int(11) NOT NULL DEFAULT '0',
+  `posted_when` int(11) NOT NULL DEFAULT '0',
+  `posted_by` int(11) NOT NULL DEFAULT '0',
+  PRIMARY KEY (`post_id`)
+){TABLE_ENGINE};
+-- --------------------------------------------------------
+--
+-- Tabellenstruktur für Tabelle `mod_news_settings`
+--
+DROP TABLE IF EXISTS `{TABLE_PREFIX}mod_news_settings`;
+CREATE TABLE IF NOT EXISTS `{TABLE_PREFIX}mod_news_settings` (
+  `section_id` int(11) NOT NULL DEFAULT '0',
+  `page_id` int(11) NOT NULL DEFAULT '0',
+  `header` text{TABLE_COLLATION} NOT NULL,
+  `post_loop` text{TABLE_COLLATION} NOT NULL,
+  `footer` text{TABLE_COLLATION} NOT NULL,
+  `posts_per_page` int(11) NOT NULL DEFAULT '0',
+  `post_header` text{TABLE_COLLATION} NOT NULL,
+  `post_footer` text{TABLE_COLLATION} NOT NULL,
+  `comments_header` text{TABLE_COLLATION} NOT NULL,
+  `comments_loop` text{TABLE_COLLATION} NOT NULL,
+  `comments_footer` text{TABLE_COLLATION} NOT NULL,
+  `comments_page` text{TABLE_COLLATION} NOT NULL,
+  `commenting` varchar(7){TABLE_COLLATION} NOT NULL,
+  `resize` int(11) NOT NULL DEFAULT '0',
+  `use_captcha` int(11) NOT NULL DEFAULT '0',
+  PRIMARY KEY (`section_id`)
+){TABLE_ENGINE};
+-- EndOfFile
\ No newline at end of file
Index: branches/2.8.x/wb/modules/news/upgrade.php
===================================================================
--- branches/2.8.x/wb/modules/news/upgrade.php	(revision 1586)
+++ branches/2.8.x/wb/modules/news/upgrade.php	(revision 1587)
@@ -15,14 +15,11 @@
  *
  */
 
-// Must include code to stop this file being access directly
 /* -------------------------------------------------------- */
-if(defined('WB_PATH') == false)
-{
-	// Stop this file being access directly
-		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>');
-}
-
+// Must include code to stop this file being accessed directly
+require_once( dirname(dirname(dirname(__FILE__))).'/framework/globalExceptionHandler.php');
+if(!defined('WB_PATH')) { throw new IllegalFileException(); }
+/* -------------------------------------------------------- */
 /* **** START UPGRADE ******************************************************* */
 if(!function_exists('mod_news_Upgrade'))
 {
@@ -124,7 +121,6 @@
 
 	// rebuild all access-files
 		$count = 0;
-		// $backSteps = preg_replace('/^'.preg_quote(WB_PATH).'/', '', $sPostsPath);
 		$backSteps = preg_replace('@^'.preg_quote(WB_PATH).'@', '', $sPostsPath);
 		$backSteps = str_repeat( '../', substr_count($backSteps, '/'));
 		$sql  = 'SELECT `page_id`,`post_id`,`section_id`,`link` ';
@@ -146,8 +142,6 @@
 					"\t".'$section_id = '.$recPost['section_id'].';'."\n".
 					"\t".'$post_id    = '.$recPost['post_id'].';'."\n".
 					"\t".'$post_section = '.$recPost['section_id'].';'."\n".
-//					"\t".'define(\'POST_SECTION\', '.$recPost['section_id'].');'."\n".
-//					"\t".'define(\'POST_ID\',      '.$recPost['post_id'].');'."\n".
 					"\t".'require(\''.$backSteps.'index.php\');'."\n".
 					'// *************************************************'."\n";
 				if( file_put_contents($file, $content) !== false ) {
@@ -165,23 +159,22 @@
 			}
 		}
 		if($globalStarted) { $msg[] = 'created '.$count.' new accessfiles.'; }
-		// if(!$globalStarted) { $admin->print_footer(); }
 	}
 }
 
-$msg = array();
-$aTable = array('mod_news_posts','mod_news_groups','mod_news_comments','mod_news_settings');
-for($x=0; $x<sizeof($aTable);$x++) {
-	if(($sOldType = $database->getTableEngine(TABLE_PREFIX.$aTable[$x]))) {
-		if(('myisam' != strtolower($sOldType))) {
-			if(!$database->query('ALTER TABLE `'.TABLE_PREFIX.$aTable[$x].'` Engine = \'MyISAM\' ')) {
-				$msg[] = $database->get_error();
+	$msg = array();
+	$aTable = array('mod_news_posts','mod_news_groups','mod_news_comments','mod_news_settings');
+	for($x=0; $x<sizeof($aTable);$x++) {
+		if(($sOldType = $database->getTableEngine(TABLE_PREFIX.$aTable[$x]))) {
+			if(('myisam' != strtolower($sOldType))) {
+				if(!$database->query('ALTER TABLE `'.TABLE_PREFIX.$aTable[$x].'` Engine = \'MyISAM\' ')) {
+					$msg[] = $database->get_error();
+				}
 			}
+		} else {
+			$msg[] = $database->get_error();
 		}
-	} else {
-		$msg[] = $database->get_error();
 	}
-}
 // ------------------------------------
 	mod_news_Upgrade();
-/* **** END UPGRADE ********************************************************* */
+/* **** END UPGRADE ********************************************************* */
\ No newline at end of file
Index: branches/2.8.x/wb/modules/news/install.php
===================================================================
--- branches/2.8.x/wb/modules/news/install.php	(revision 1586)
+++ branches/2.8.x/wb/modules/news/install.php	(revision 1587)
@@ -14,158 +14,34 @@
  * @lastmodified    $Date$
  *
  */
-
-if(defined('WB_URL'))
-{
-	
-	// $database->query("DROP TABLE IF EXISTS `".TABLE_PREFIX."mod_news_posts`");
-	$mod_news = 'CREATE TABLE IF NOT EXISTS `'.TABLE_PREFIX.'mod_news_posts` ( '
-					 . '`post_id` INT NOT NULL AUTO_INCREMENT,'
-					 . '`section_id` INT NOT NULL DEFAULT \'0\','
-					 . '`page_id` INT NOT NULL DEFAULT \'0\','
-					 . '`group_id` INT NOT NULL DEFAULT \'0\','
-					 . '`active` INT NOT NULL DEFAULT \'0\','
-					 . '`position` INT NOT NULL DEFAULT \'0\','
-					 . '`title` VARCHAR(255) NOT NULL DEFAULT \'\','
-					 . '`link` TEXT NOT NULL ,'
-					 . '`content_short` TEXT NOT NULL ,'
-					 . '`content_long` TEXT NOT NULL ,'
-					 . '`commenting` VARCHAR(7) NOT NULL DEFAULT \'\','
-					 . '`created_when` INT NOT NULL DEFAULT \'0\','
-					 . '`created_by` INT NOT NULL DEFAULT \'0\','
-					 . '`published_when` INT NOT NULL DEFAULT \'0\','
-					 . '`published_until` INT NOT NULL DEFAULT \'0\','
-					 . '`posted_when` INT NOT NULL DEFAULT \'0\','
-					 . '`posted_by` INT NOT NULL DEFAULT \'0\','
-					 . 'PRIMARY KEY (post_id)'
-					 . ' ) ENGINE=MyISAM DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci';
-	$database->query($mod_news);
-	
-	// $database->query("DROP TABLE IF EXISTS `".TABLE_PREFIX."mod_news_groups`");
-	$mod_news = 'CREATE TABLE IF NOT EXISTS `'.TABLE_PREFIX.'mod_news_groups` ( '
-					 . '`group_id` INT NOT NULL AUTO_INCREMENT,'
-					 . '`section_id` INT NOT NULL DEFAULT \'0\','
-					 . '`page_id` INT NOT NULL DEFAULT \'0\','
-					 . '`active` INT NOT NULL DEFAULT \'0\','
-					 . '`position` INT NOT NULL DEFAULT \'0\','
-					 . '`title` VARCHAR(255) NOT NULL DEFAULT \'\','
-					 . 'PRIMARY KEY (group_id)'
-                . ' ) ENGINE=MyISAM DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci';
-	$database->query($mod_news);
-	
-	// $database->query("DROP TABLE IF EXISTS `".TABLE_PREFIX."mod_news_comments`");
-	$mod_news = 'CREATE TABLE IF NOT EXISTS `'.TABLE_PREFIX.'mod_news_comments` ( '
-					 . '`comment_id` INT NOT NULL AUTO_INCREMENT,'
-					 . '`section_id` INT NOT NULL DEFAULT \'0\','
-					 . '`page_id` INT NOT NULL DEFAULT \'0\','
-					 . '`post_id` INT NOT NULL DEFAULT \'0\','
-					 . '`title` VARCHAR(255) NOT NULL DEFAULT \'\','
-					 . '`comment` TEXT NOT NULL ,'
-					 . '`commented_when` INT NOT NULL DEFAULT \'0\','
-					 . '`commented_by` INT NOT NULL DEFAULT \'0\','
-					 . 'PRIMARY KEY (comment_id)'
-                . ' ) ENGINE=MyISAM DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci';
-
-	$database->query($mod_news);
-	
-	// $database->query("DROP TABLE IF EXISTS `".TABLE_PREFIX."mod_news_settings`");
-	$mod_news = 'CREATE TABLE IF NOT EXISTS `'.TABLE_PREFIX.'mod_news_settings` ( '
-					 . '`section_id` INT NOT NULL DEFAULT \'0\','
-					 . '`page_id` INT NOT NULL DEFAULT \'0\','
-					 . '`header` TEXT NOT NULL ,'
-					 . '`post_loop` TEXT NOT NULL ,'
-					 . '`footer` TEXT NOT NULL ,'
-					 . '`posts_per_page` INT NOT NULL DEFAULT \'0\','
-					 . '`post_header` TEXT NOT NULL,'
-					 . '`post_footer` TEXT NOT NULL,'
-					 . '`comments_header` TEXT NOT NULL,'
-					 . '`comments_loop` TEXT NOT NULL,'
-					 . '`comments_footer` TEXT NOT NULL,'
-					 . '`comments_page` TEXT NOT NULL,'
-					 . '`commenting` VARCHAR(7) NOT NULL DEFAULT \'\','
-					 . '`resize` INT NOT NULL DEFAULT \'0\','
-					 . ' `use_captcha` INT NOT NULL DEFAULT \'0\','
-					 . 'PRIMARY KEY (section_id)'
-                . ' ) ENGINE=MyISAM DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci';
-
-	$database->query($mod_news);
-		
-    $mod_search = "SELECT * FROM ".TABLE_PREFIX."search WHERE value = 'news'";
-    $insert_search = $database->query($mod_search);
-    if( $insert_search->numRows() == 0 )
-    {
-    	// Insert info into the search table
-    	// Module query info
-    	$field_info = array();
-    	$field_info['page_id'] = 'page_id';
-    	$field_info['title'] = 'page_title';
-    	$field_info['link'] = 'link';
-    	$field_info['description'] = 'description';
-    	$field_info['modified_when'] = 'modified_when';
-    	$field_info['modified_by'] = 'modified_by';
-    	$field_info = serialize($field_info);
-    	$database->query("INSERT INTO ".TABLE_PREFIX."search (name,value,extra) VALUES ('module', 'news', '$field_info')");
-    	// Query start
-    	$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 ";
-    	$database->query("INSERT INTO ".TABLE_PREFIX."search (name,value,extra) VALUES ('query_start', '$query_start_code', 'news')");
-    	// Query body
-    	$query_body_code = "
-    	[TP]pages.page_id = [TP]mod_news_posts.page_id AND [TP]mod_news_posts.title LIKE \'%[STRING]%\'
-    	OR [TP]pages.page_id = [TP]mod_news_posts.page_id AND [TP]mod_news_posts.content_short LIKE \'%[STRING]%\'
-    	OR [TP]pages.page_id = [TP]mod_news_posts.page_id AND [TP]mod_news_posts.content_long LIKE \'%[STRING]%\'
-    	OR [TP]pages.page_id = [TP]mod_news_comments.page_id AND [TP]mod_news_comments.title LIKE \'%[STRING]%\'
-    	OR [TP]pages.page_id = [TP]mod_news_comments.page_id AND [TP]mod_news_comments.comment LIKE \'%[STRING]%\'
-    	OR [TP]pages.page_id = [TP]mod_news_settings.page_id AND [TP]mod_news_settings.header LIKE \'%[STRING]%\'
-    	OR [TP]pages.page_id = [TP]mod_news_settings.page_id AND [TP]mod_news_settings.footer LIKE \'%[STRING]%\'
-    	OR [TP]pages.page_id = [TP]mod_news_settings.page_id AND [TP]mod_news_settings.post_header LIKE \'%[STRING]%\'
-    	OR [TP]pages.page_id = [TP]mod_news_settings.page_id AND [TP]mod_news_settings.post_footer LIKE \'%[STRING]%\'
-    	OR [TP]pages.page_id = [TP]mod_news_settings.page_id AND [TP]mod_news_settings.comments_header LIKE \'%[STRING]%\'
-    	OR [TP]pages.page_id = [TP]mod_news_settings.page_id AND [TP]mod_news_settings.comments_footer LIKE \'%[STRING]%\'";
-    	$database->query("INSERT INTO ".TABLE_PREFIX."search (name,value,extra) VALUES ('query_body', '$query_body_code', 'news')");
-    	// Query end
-    	$query_end_code = "";
-    	$database->query("INSERT INTO ".TABLE_PREFIX."search (name,value,extra) VALUES ('query_end', '$query_end_code', 'news')");
-
-    	// Insert blank row (there needs to be at least on row for the search to work)
-    	$database->query("INSERT INTO ".TABLE_PREFIX."mod_news_posts (section_id,page_id) VALUES ('0', '0')");
-    	$database->query("INSERT INTO ".TABLE_PREFIX."mod_news_groups (section_id,page_id) VALUES ('0', '0')");
-    	$database->query("INSERT INTO ".TABLE_PREFIX."mod_news_comments (section_id,page_id) VALUES ('0', '0')");
-    	$database->query("INSERT INTO ".TABLE_PREFIX."mod_news_settings (section_id,page_id) VALUES ('0', '0')");
-    }
-
-	// Make news post access files dir
-	require_once(WB_PATH.'/framework/functions.php');
-	if(make_dir(WB_PATH.PAGES_DIRECTORY.'/posts')) {
-		// Add a index.php file to prevent directory spoofing
-		$content = ''.
-"<?php
-
-/*
-
- Website Baker Project <http://www.websitebaker.org/>
- Copyright (C) 2004-2009, Ryan Djurovich
-
- Website Baker is free software; you can redistribute it and/or modify
- it under the terms of the GNU General Public License as published by
- the Free Software Foundation; either version 2 of the License, or
- (at your option) any later version.
-
- Website Baker is distributed in the hope that it will be useful,
- but WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
- GNU General Public License for more details.
-
- You should have received a copy of the GNU General Public License
- along with Website Baker; if not, write to the Free Software
- Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
-
-*/
-
-header('Location: ../');
-?>";
-		$handle = fopen(WB_PATH.PAGES_DIRECTORY.'/posts/index.php', 'w');
-		fwrite($handle, $content);
-		fclose($handle);
-		change_mode(WB_PATH.PAGES_DIRECTORY.'/posts/index.php', 'file');
+/* -------------------------------------------------------- */
+// Must include code to stop this file being accessed directly
+require_once( dirname(dirname(dirname(__FILE__))).'/framework/globalExceptionHandler.php');
+if(!defined('WB_PATH')) { throw new IllegalFileException(); }
+/* -------------------------------------------------------- */
+	$sDefaultSql = dirname(__FILE__).'/install.sql';
+	if (is_readable($sDefaultSql)) {
+// create needet database tables and set default records
+		if ($database->SqlImport($sDefaultSql, TABLE_PREFIX)) {
+// Make news post access files dir
+			require_once(WB_PATH.'/framework/functions.php');
+			if(make_dir(WB_PATH.PAGES_DIRECTORY.'/posts')) {
+				// Add a index.php file to prevent directory spoofing
+				$sResponse  = $_SERVER['SERVER_PROTOCOL'].' 301 Moved Permanently';
+				$sContent =
+					'<?php'."\n".
+					'// *** This file is generated by WebsiteBaker Ver.'.VERSION."\n".
+					'// *** Creation date: '.date('c')."\n".
+					'// *** Do not modify this file manually'."\n".
+					'// *** WB will rebuild this file from time to time!!'."\n".
+					'// *************************************************'."\n".
+					"\t".'header(\''.$sResponse.'\');'."\n".
+					"\t".'header(\'Location: ../index.php\');'."\n".
+					'// *************************************************'."\n";
+				$sFilename = WB_PATH.PAGES_DIRECTORY.'/posts/index.php';
+				file_put_contents($sFilename, $sContent);
+				change_mode($sFilename, 'file');
+			}
+		}
 	}
-};
+/* **** END INSTALL ********************************************************* */
\ No newline at end of file
