Index: branches/2.8.x/wb/upgrade-script.php
===================================================================
--- branches/2.8.x/wb/upgrade-script.php	(revision 1865)
+++ branches/2.8.x/wb/upgrade-script.php	(revision 1866)
@@ -1,20 +1,39 @@
 <?php
 /**
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
  *
- * @category        backend
- * @package         installation
- * @author          WebsiteBaker Project
- * @copyright       2009-2012, WebsiteBaker Org. e.V.
- * @link            http://www.websitebaker2.org/
- * @license         http://www.gnu.org/licenses/gpl.html
- * @platform        WebsiteBaker 2.8.x
- * @requirements    PHP 5.2.2 and higher
- * @version         $Id$
- * @filesource		$HeadURL$
- * @lastmodified    $Date$
+ * This program 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 3 of the License, or
+ * (at your option) any later version.
  *
+ * This program 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 this program.  If not, see <http://www.gnu.org/licenses/>.
  */
 
+/**
+ * 
+ * 
+ * @category     Module
+ * @package      Module_bakery
+ * @subpackage   Name of the subpackage if needed
+ * @author       Dietmar Wöllbrink <dietmar.woellbrink@websitebaker.org>
+ * @author       Werner v.d.Decken <wkl@isteam.de>
+ * @copyright    Werner v.d.Decken <wkl@isteam.de>
+ * @license      http://www.gnu.org/licenses/gpl.html   GPL License
+ * @version      0.0.1
+ * @revision     $Revision$
+ * @link         $HeadURL$
+ * @lastmodified $Date$
+ * @since        File available since 17.01.2013
+ * @deprecated   
+ * @description  xyz
+ */
 // Include config file
 $config_file = realpath('config.php');
 if(file_exists($config_file) && !defined('WB_URL'))
@@ -44,10 +63,10 @@
 // database tables including in WB package
 $aPackage = array (
     'settings','groups','addons','pages','sections','search','users',
-    'mod_captcha_control','mod_code','mod_droplets','mod_form_fields',
-    'mod_form_settings','mod_form_submissions','mod_jsadmin','mod_menu_link',
-    'mod_news_comments','mod_news_groups','mod_news_posts','mod_news_settings',
-    'mod_output_filter','mod_wrapper','mod_wysiwyg'
+    'mod_captcha_control','mod_code','mod_droplets',
+    'mod_jsadmin','mod_menu_link','mod_output_filter','mod_wrapper','mod_wysiwyg',
+//    'mod_form_fields','mod_form_settings','mod_form_submissions',
+//    'mod_news_comments','mod_news_groups','mod_news_posts','mod_news_settings',
 );
 
 $OK            = ' <span class="ok">OK</span> ';
@@ -65,16 +84,15 @@
 */
 			'[ADMIN]/themes/',
 		 );
+//
+	$filesRemove['0'] = array(
 
-if(version_compare(WB_REVISION, VERSION, '<='))
-{
-    $filesRemove['0'] = array(
-
 			'[ADMIN]/preferences/details.php',
 			'[ADMIN]/preferences/email.php',
 			'[ADMIN]/preferences/password.php',
 			'[ADMIN]/pages/settings2.php',
 			'[ADMIN]/users/users.php',
+			'[ADMIN]/skel/themes/htt/groups.htt',
 
 			'[FRAMEWORK]/class.msg_queue.php',
 			'[FRAMEWORK]/class.logfile.php',
@@ -81,7 +99,11 @@
 			'[MODULES]/droplets/js/mdcr.js',
 
 		 );
+	$aFilesToRemove = array_merge($filesRemove['0']);
 
+// deleting files below only from less 2.8.4 stable
+if(version_compare(WB_REVISION, REVISION, '<='))
+{
 	$filesRemove['1'] = array(
 
 			'[TEMPLATE]/argos_theme/templates/access.htt',
@@ -92,10 +114,8 @@
 			'[TEMPLATE]/argos_theme/templates/groups_form.htt',
 			'[TEMPLATE]/argos_theme/templates/languages.htt',
 			'[TEMPLATE]/argos_theme/templates/languages_details.htt',
-	/*
 			'[TEMPLATE]/argos_theme/templates/login.htt',
 			'[TEMPLATE]/argos_theme/templates/login_forgot.htt',
-	*/
 			'[TEMPLATE]/argos_theme/templates/media.htt',
 			'[TEMPLATE]/argos_theme/templates/media_browse.htt',
 			'[TEMPLATE]/argos_theme/templates/media_rename.htt',
@@ -123,12 +143,8 @@
 			'[TEMPLATE]/wb_theme/templates/groups_form.htt',
 			'[TEMPLATE]/wb_theme/templates/languages.htt',
 			'[TEMPLATE]/wb_theme/templates/languages_details.htt',
-
-	/*
 			'[TEMPLATE]/wb_theme/templates/login.htt',
 			'[TEMPLATE]/wb_theme/templates/login_forgot.htt',
-	*/
-
 			'[TEMPLATE]/wb_theme/templates/media.htt',
 			'[TEMPLATE]/wb_theme/templates/media_browse.htt',
 			'[TEMPLATE]/wb_theme/templates/media_rename.htt',
@@ -146,13 +162,12 @@
 			'[TEMPLATE]/wb_theme/templates/templates.htt',
 			'[TEMPLATE]/wb_theme/templates/templates_details.htt',
 			'[TEMPLATE]/wb_theme/templates/users.htt',
-			'[TEMPLATE]/wb_theme/templates/users_form.htt',
+			'[TEMPLATE]/wb_theme/templates/users_form.htt'
 		 );
 
-    $aFilesToRemove = array_merge($filesRemove['0'],$filesRemove['1']);
+	$aFilesToRemove = array_merge($aFilesToRemove,$filesRemove['1']);
 
 }
-
 /* display a status message on the screen **************************************
  * @param string $message: the message to show
  * @param string $class:   kind of message as a css-class
@@ -177,8 +192,8 @@
  * @return
  */
 function add_modify_field_in_database($sTable,$sField,$sDescription){
-    global $database,$OK,$FAIL,$bDebugModus;
-    $aDebugMessage = array();
+	global $database,$OK,$FAIL,$bDebugModus;
+	$aDebugMessage = array();
 	if(!$database->field_exists($sTable,$sField)) {
 		$aDebugMessage[] = "<span>Adding field $sField to $sTable table</span>";
 		$aDebugMessage[] = ($database->field_add($sTable, $sField, $sDescription) ? " $OK<br />" : " $FAIL!<br />");
@@ -186,10 +201,10 @@
 		$aDebugMessage[] = "<span>Modify field $sField to $sTable table</span>";
 		$aDebugMessage[] = ($database->field_modify($sTable, $sField, $sDescription) ? " $OK<br />" : " $FAIL!<br />");
 	}
-    if($bDebugModus) {
-        echo implode(PHP_EOL,$aDebugMessage);
-    }
-    return;
+	if($bDebugModus) {
+		echo implode(PHP_EOL,$aDebugMessage);
+	}
+return;
 }
 
 /**
@@ -201,13 +216,13 @@
  */
 function check_wb_tables()
 {
-    global $database,$aPackage;
+	global $database,$aPackage;
 
 // if prefix inludes '_' or '%'
-    $search_for = addcslashes ( TABLE_PREFIX, '%_' );
-    $get_result = $database->query( 'SHOW TABLES LIKE "'.$search_for.'%"');
+	$search_for = addcslashes ( TABLE_PREFIX, '%_' );
+	$get_result = $database->query( 'SHOW TABLES LIKE "'.$search_for.'%"');
 
-    // $get_result = $database->query( "SHOW TABLES FROM ".DB_NAME);
+	// $get_result = $database->query( "SHOW TABLES FROM ".DB_NAME);
     $all_tables = array();
     $aTable = array();
     if($get_result->numRows() > 0)
@@ -250,7 +265,7 @@
 #container {
 	min-width:48em;
     width: 70%;
-	background: #A8BCCB url(templates/wb_theme/images/background.png) repeat-x;
+	background: #A8BCCB url(<?php echo WB_URL; ?>/templates/wb_theme/images/background.png) repeat-x;
 	border:1px solid #000;
 	color:#000;
 	margin:2em auto;
@@ -290,10 +305,10 @@
 
 textarea {
 	width:100%;
-    border: 2px groove #0F1D44;
-    padding: 2px;
-    color: #000;
-    font-weight: normal;
+	border: 2px groove #0F1D44;
+	padding: 2px;
+	color: #000;
+	font-weight: normal;
 }
 .ok, .error { font-weight:bold; }
 .ok { color:green; }
@@ -323,7 +338,7 @@
 <body>
 <div id="container">
 <div class="page">
-<img src="templates/wb_theme/images/logo.png" alt="WebsiteBaker Project" />
+<img src="<?php echo WB_URL; ?>/templates/wb_theme/images/logo.png" alt="WebsiteBaker Project" />
 <div class="content">
 <h1>WebsiteBaker Upgrade</h1>
 <?php
@@ -331,8 +346,8 @@
 		status_msg('<strong>Warning:</strong><br />It is not possible to upgrade from WebsiteBaker Versions before 2.7.<br />For upgrading to version '.VERSION.' you must upgrade first to v.2.7 at least!!!', 'warning', 'div');
 		echo '<br /><br />';
 		echo "</div>
-        </div>
-        </div>
+		</div>
+		</div>
 		</body>
 		</html>
 		";
@@ -353,7 +368,7 @@
 <h5 class="warning">It is highly recommended to <strong>create a manual backup</strong> of the entire <strong class="error"><?php echo  PAGES_DIRECTORY ?>/</strong> folder and the <strong>MySQL database</strong> before proceeding.</h5>
 <p><strong class="error">Note: </strong>The upgrade script alters some settings of your existing database!!! You need to confirm the disclaimer before proceeding.</p>
 
-<form name="send" action="<?php echo $_SERVER['SCRIPT_NAME'];?>" method="post">
+<form action="<?php echo $_SERVER['SCRIPT_NAME'];?>" method="post">
 <textarea cols="92" rows="5">DISCLAIMER: The WebsiteBaker upgrade script 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. One needs to confirm that a manual backup of the <?php echo  PAGES_DIRECTORY ?>/ folder (including all files and subfolders contained in it) and backup of the entire WebsiteBaker MySQL database was created before you can proceed.</textarea>
 <br /><br /><input name="backup_confirmed" type="checkbox" value="confirmed" />&nbsp;<strong>I confirm that a manual backup of the <?php echo  PAGES_DIRECTORY ?>/ folder and the MySQL database was created.</strong>
 <br /><br /><input name="debug_confirmed" type="checkbox" value="debug" />&nbsp;<strong>Here you can get more details during running upgrade.</strong>
@@ -363,13 +378,11 @@
 
 <?php
 	status_msg('<strong> Notice:</strong><br />You need to confirm that you have created a manual backup of the '.PAGES_DIRECTORY.'/ directory and the MySQL database before you can proceed.', 'warning', 'div');
-	echo '<br /><br />';
-    echo "</div>
-    </div>
-    </div>
-    </body>
-    </html>
-    ";
+	echo "<br /><br /></div>
+	</div>
+	</div>
+	</body>
+	</html>";
 	exit();
 }
 
@@ -397,7 +410,8 @@
         status_msg('<strong>:</strong><br />can\'t run Upgrade, missing tables', 'warning', 'div');
         echo '<h4>Missing required tables. You can install them in backend->addons->modules.<br />';
         echo 'Or if you uploaded per FTP install possible by backend->addons->modules->advanced.<br />';
-        echo 'After installing missing tables again run upgrade-script.php</h4>';
+        echo 'First rename or delete the upgrade-script.php, so the script can\'t start automatically by backend<br />';
+        echo 'After installing missing tables upload and run again upgrade-script.php</h4>';
         $result = array_diff ( $aPackage, $aTable );
 
         echo '<h4 class="warning"><br />';
@@ -414,17 +428,15 @@
         	echo '</form>';
         }
         if(defined('ADMIN_URL')) {
-        	echo '<form action="'.ADMIN_URL.'/">';
-        	echo '&nbsp;<input type="submit" value="kick me to the Backend" />';
+        	echo '<form action="'.ADMIN_URL.'/index.php" method="post">';
+        	echo '&nbsp;<input name="backend_send" type="submit" value="kick me to the Backend" />';
         	echo '</form>';
         }
-
         echo "<br /><br /></div>
         </div>
         </div>
         </body>
-        </html>
-        ";
+        </html>";
 
         exit();
     }
@@ -444,7 +456,7 @@
     echo implode(PHP_EOL,$aDebugMessage);
 }
 $aDebugMessage = array();
-echo'<h3>Step '.(++$stepID).': Updating core tables</h3>';
+echo'<h3>Step '.(++$stepID).': Updating tables included in package</h3>';
     /**********************************************************
      *  - Adding field sec_anchor to settings table
      */
@@ -580,9 +592,9 @@
 
     if($bDebugModus) {
         echo implode(PHP_EOL,$aDebugMessage);
-        $aDebugMessage = array();
     }
 
+    $aDebugMessage = array();
     echo "<h4>Adding/updating field on table pages</h4>";
 	/**********************************************************
 	 *  - Add field "page_trail" to table "pages"
@@ -684,10 +696,10 @@
 
     if($bDebugModus) {
         echo implode(PHP_EOL,$aDebugMessage);
-        $aDebugMessage = array();
     }
 
-    /**********************************************************
+	$aDebugMessage = array();
+	/**********************************************************
      * modify wrong strucre on table sections
      * wrong structure let crash wb
      */
@@ -705,9 +717,9 @@
 
     if($bDebugModus) {
         echo implode(PHP_EOL,$aDebugMessage);
-        $aDebugMessage = array();
     }
 
+	$aDebugMessage = array();
 	/**********************************************************
      *   `confirm_code` VARCHAR(32) NOT NULL DEFAULT '',
      *   `confirm_timeout` INT(11) NOT NULL DEFAULT '0',
@@ -725,16 +737,16 @@
 
     if($bDebugModus) {
         echo implode(PHP_EOL,$aDebugMessage);
-        $aDebugMessage = array();
     }
 
+    $aDebugMessage = array();
 	/**********************************************************
      * Modify Administrator on groups table
      */
 	echo "<h4>Update group Administrator on table groups</h4>";
 	$aDebugMessage[] = "<span>Modify Administrator on groups table</span>";
-    $sModulePermissions = '';
-    $sTemplatePermissions = '';
+	$sModulePermissions = '';
+	$sTemplatePermissions = '';
 	$sSystemPermissions  = 'access,addons,admintools,admintools_view,groups,groups_add,groups_delete,groups_modify,groups_view,';
 	$sSystemPermissions .= 'languages,languages_install,languages_uninstall,languages_view,media,media_create,media_delete,media_rename,media_upload,media_view,';
 	$sSystemPermissions .= 'modules,modules_advanced,modules_install,modules_uninstall,modules_view,pages,pages_add,pages_add_l0,pages_delete,pages_intro,pages_modify,pages_settings,pages_view,';
@@ -753,7 +765,6 @@
 
     if($bDebugModus) {
         echo implode(PHP_EOL,$aDebugMessage);
-        $aDebugMessage = array();
     }
     echo '</div>';
 
@@ -790,7 +801,7 @@
     }
 }
 
-if(version_compare(WB_REVISION, VERSION, '<'))
+if(version_compare(WB_REVISION, REVISION, '<='))
 {
     $aDebugMessage = array();
     echo '<h3>Step '.(++$stepID).': Updating group_id in table users</h3>';
@@ -844,7 +855,7 @@
 }
 
 $aDebugMessage = array();
-echo '<h3>Step '.(++$stepID).': Updating acess and protected files in folders</h3>';
+echo '<h3>Step '.(++$stepID).': Updating access and protected files in folders</h3>';
 
 echo '<div style="margin-left:2em;">';
     /**********************************************************
@@ -852,14 +863,15 @@
     */
     $dir = (WB_PATH.MEDIA_DIRECTORY);
     echo '<h4>Upgrade media directory '.MEDIA_DIRECTORY.'/ index.php protect files</h4>';
-    $array = rebuildFolderProtectFile($dir);
-    if( sizeof( $array ) ){
-    	echo '<span><strong>Upgrade '.sizeof( $array ).' directory '.MEDIA_DIRECTORY.'/ protect files</strong></span>'." $OK<br />";
+    $aDebugMessage = rebuildFolderProtectFile($dir);
+    if( sizeof( $aDebugMessage ) ){
+    	echo '<span><strong>Upgrade '.sizeof( $aDebugMessage ).' directory '.MEDIA_DIRECTORY.'/ protect files</strong></span>'." $OK<br />";
     } else {
     	echo '<span><strong>Upgrade directory '.MEDIA_DIRECTORY.'/ protect files</strong></span>'." $FAIL!<br />";
-    	echo implode ('<br />',$array);
+    	echo implode ('<br />',$aDebugMessage);
     }
 
+    $aDebugMessage = array();
     /**********************************************************
      * upgrade pages directory index access files
      */
@@ -871,8 +883,9 @@
     $sPagePath = (defined('PAGES_DIRECTORY') && (PAGES_DIRECTORY != '') ? PAGES_DIRECTORY : '');
     $msg = rebuild_all_accessfiles();
 
-	echo implode ('<br />',$msg);
+	echo '<strong>'.implode ('<br />',$msg).'</strong>';
     echo '</div>';
+
     /* *****************************************************************************
      * - check for deprecated / never needed files
      */
@@ -921,12 +934,11 @@
 			echo '<form action="'.$_SERVER['SCRIPT_NAME'].'">';
 			echo '&nbsp;<input name="send" type="submit" value="Restart upgrade script" />';
 			echo '</form>';
-            echo "<br /><br /></div>
-            </div>
-            </div>
-            </body>
-            </html>
-            ";
+			echo "<br /><br /></div>
+			</div>
+			</div>
+			</body>
+			</html>";
 			exit;
 		}
     }
@@ -973,12 +985,11 @@
 			echo '<form action="'.$_SERVER['SCRIPT_NAME'].'">';
 			echo '&nbsp;<input name="send" type="submit" value="Restart upgrade script" />';
 			echo '</form>';
-            echo "<br /><br /></div>
-            </div>
-            </div>
-            </body>
-            </html>
-            ";
+			echo "<br /><br /></div>
+			</div>
+			</div>
+			</body>
+			</html>";
 			exit;
 		}
 	}
@@ -988,20 +999,49 @@
      * $aModuleList list of proofed modules
      */
     $aModuleList = array('news','wysiwyg','form');
-    echo '<h3>Step '.(++$stepID).': Upgrade proofed modules</h3>';
-	foreach($aModuleList as $sModul) {
-		if(file_exists(WB_PATH.'/modules/'.$sModul.'/upgrade.php')) {
-			$currModulVersion = get_modul_version ($sModul, false);
-			$newModulVersion =  get_modul_version ($sModul, true);
-			if((version_compare($currModulVersion, $newModulVersion) <= 0)) {
-                echo '<div style="margin-left:2em;">';
-				echo '<h4>'.'Upgrade module \''.$sModul.'\' version '.$newModulVersion.'</h4>';
-				require_once(WB_PATH.'/modules/'.$sModul.'/upgrade.php');
-                echo '</div>';
+	if(sizeof($aModuleList)) 
+	{
+	    echo '<h3>Step '.(++$stepID).': Upgrade proofed modules</h3>';
+		foreach($aModuleList as $sModul) {
+			if(file_exists(WB_PATH.'/modules/'.$sModul.'/upgrade.php')) {
+				$currModulVersion = get_modul_version ($sModul, false);
+				$newModulVersion =  get_modul_version ($sModul, true);
+				if((version_compare($currModulVersion, $newModulVersion) <= 0)) {
+	                echo '<div style="margin-left:2em;">';
+					echo '<h4>'.'Upgrade module \''.$sModul.'\' version '.$newModulVersion.'</h4>';
+					require(WB_PATH.'/modules/'.$sModul.'/upgrade.php');
+	                echo '</div>';
+				}
 			}
 		}
 	}
 
+    /**********************************************************
+     * Reformat/rebuild all existing moules access files
+     * $aModuleList list of modules
+     */
+    $aModuleList = array('bakery','topics','news');
+	if(sizeof($aModuleList)) 
+	{
+		echo '<h3>Step '.(++$stepID).': Create/Reorg Accessfiles from modules</h3>';
+		foreach($aModuleList as $sModul) {
+			$aReturnMsg = array();
+			$sModulReorg = 'm_'.$sModul.'_Reorg';
+			if(class_exists($sModulReorg)) {
+				$sModulVersion =  get_modul_version ($sModul, true);
+				echo '<div style="margin-left:2em;">';
+				echo '<h4>'.'Create/Reorg Accesfiles for module \''.$sModul.'\' version '.$sModulVersion.'</h4>';
+				$oReorg = new $sModulReorg();
+				$aReturnMsg = $oReorg->execute(); // show details
+				if($bDebugModus && is_array($aReturnMsg)) {
+					foreach($aReturnMsg as $title) {
+					echo '<strong>'.$title.'</strong><br />';
+					}
+				}
+				echo '</div>';
+			}
+		}
+	}
 /**********************************************************
  *  - Reload all addons
  */
@@ -1023,7 +1063,7 @@
 		}
 		closedir($handle);
 	}
-	echo '<span><strong>'.$iLoaded.' Modules reloaded,</span> found '.$iFound.' directories in folder /modules/</strong><br />';
+	echo '<strong><span>'.$iLoaded.' Modules reloaded,</span> found '.$iFound.' directories in folder /modules/</strong><br />';
 
     $iFound = 0;
     $iLoaded = 0;
@@ -1041,7 +1081,7 @@
 		}
 		closedir($handle);
 	}
-	echo '<span><strong>'.$iLoaded.' Templates reloaded,</span> found '.$iFound.' directories in folder /templates/</strong><br />';
+	echo '<strong><span>'.$iLoaded.' Templates reloaded,</span> found '.$iFound.' directories in folder /templates/</strong><br />';
 
     $iFound = 0;
     $iLoaded = 0;
@@ -1057,7 +1097,7 @@
 		}
 		closedir($handle);
 	}
-	echo '<span><strong>'.$iLoaded.' Languages reloaded,</span> found '.$iFound.' files in folder /languages/</strong><br />';
+	echo '<strong><span>'.$iLoaded.' Languages reloaded,</span> found '.$iFound.' files in folder /languages/</strong><br />';
     echo '</div>';
 
 /**********************************************************
Index: branches/2.8.x/wb/admin/skel/themes/htt/groups.htt
===================================================================
--- branches/2.8.x/wb/admin/skel/themes/htt/groups.htt	(revision 1865)
+++ branches/2.8.x/wb/admin/skel/themes/htt/groups.htt	(nonexistent)
@@ -1,30 +0,0 @@
-<!-- BEGIN main_block -->
-
-<form class="access" action="groups.php" method="post">
- {FTAN}
-  <table summary="" cellpadding="5" cellspacing="0" border="0" align="center" width="100%" style="margin-bottom:10px;">
-	<tr style="background:#f0f0f0;">
-		<td align="left"><h2>{HEADING_MODIFY_DELETE_GROUP}</h2></td>
-		<td align="right">
-		<!-- BEGIN manage_users_block -->
-		<a href="{ADMIN_URL}/users/index.php">{TEXT_MANAGE_USERS}</a>
-		<!-- END manage_users_block -->
-		</td>
-     </tr>
-</table>
-
-  <select name="group_id" style="width: 500px;">
-    <!-- BEGIN list_block -->
-    <option value="{VALUE}">
-    {NAME}
-    </option>
-    <!-- END list_block -->
-  </select>
-  <input type="submit" name="modify" style="width: 100px;" value="{TEXT_MODIFY}" class="{DISPLAY_MODIFY}" />
-  <input type="submit" name="delete" style="width: 100px;" value="{TEXT_DELETE}" onclick="return confirm('{CONFIRM_DELETE}');" class="{DISPLAY_DELETE}" />
-</form>
-<br />
-<h2 class="{DISPLAY_ADD}">
-  {HEADING_ADD_GROUP}
-</h2>
-<!-- END main_block -->

Property changes on: branches/2.8.x/wb/admin/skel/themes/htt/groups.htt
___________________________________________________________________
Deleted: svn:eol-style
## -1 +0,0 ##
-native
\ No newline at end of property
Deleted: svn:keywords
## -1 +0,0 ##
-Date Author Id Revision HeadURL
\ No newline at end of property
Index: branches/2.8.x/wb/admin/interface/version.php
===================================================================
--- branches/2.8.x/wb/admin/interface/version.php	(revision 1865)
+++ branches/2.8.x/wb/admin/interface/version.php	(revision 1866)
@@ -51,5 +51,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.3');
-if(!defined('REVISION')) define('REVISION', '1865');
+if(!defined('REVISION')) define('REVISION', '1866');
 if(!defined('SP')) define('SP', '');
Index: branches/2.8.x/wb/framework/WbDatabase.php
===================================================================
--- branches/2.8.x/wb/framework/WbDatabase.php	(revision 1865)
+++ branches/2.8.x/wb/framework/WbDatabase.php	(revision 1866)
@@ -1,45 +1,44 @@
 <?php
 /**
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
  *
- * @category        framework
- * @package         database
- * @author          WebsiteBaker Project
- * @copyright       2004-2009, Ryan Djurovich
- * @copyright       2009-2011, Website Baker Org. e.V.
- * @link            http://www.websitebaker2.org/
- * @license         http://www.gnu.org/licenses/gpl.html
- * @platform        WebsiteBaker 2.8.x
- * @requirements    PHP 5.2.2 and higher
- * @version         $Id$
- * @filesource      $HeadURL$
- * @lastmodified    $Date$
+ * This program 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 3 of the License, or
+ * (at your option) any later version.
  *
+ * This program 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 this program.  If not, see <http://www.gnu.org/licenses/>.
  */
-/*
-Database class
-This class will be used to interface between the database
-and the Website Baker code
-*/
+/**
+ * WbDatabase.php
+ *
+ * @category     Core
+ * @package      Core_database
+ * @author       Werner v.d.Decken <wkl@isteam.de>
+ * @author       Dietmar W. <dietmar.woellbrink@websitebaker.org>
+ * @copyright    Werner v.d.Decken <wkl@isteam.de>
+ * @license      http://www.gnu.org/licenses/gpl.html   GPL License
+ * @version      0.0.9
+ * @revision     $Revision$
+ * @lastmodified $Date$
+ * @deprecated   from WB version number 2.9
+ * @description  Mysql database wrapper for use with websitebaker up to version 2.8.4
+ */
+
 /* -------------------------------------------------------- */
-// Must include code to stop this file being accessed directly
-if(!defined('WB_PATH')) {
-	require_once(dirname(__FILE__).'/globalExceptionHandler.php');
-	throw new IllegalFileException();
-}
-/* -------------------------------------------------------- */
 define('DATABASE_CLASS_LOADED', true);
 
-
 class WbDatabase {
 
 	private static $_oInstances = array();
 
 	private $_db_handle = null; // readonly from outside
-	private $_scheme    = 'mysql';
-	private $_hostname  = 'localhost';
-	private $_username  = '';
-	private $_password  = '';
-	private $_hostport  = '3306';
 	private $_db_name   = '';
 	private $connected  = false;
 	private $error      = '';
@@ -84,27 +83,29 @@
 	public function doConnect($url = '') {
 		if($url != '') {
 			$aIni = parse_url($url);
-			$this->_scheme   = isset($aIni['scheme']) ? $aIni['scheme'] : 'mysql';
-			$this->_hostname = isset($aIni['host']) ? $aIni['host'] : '';
-			$this->_username = isset($aIni['user']) ? $aIni['user'] : '';
-			$this->_password = isset($aIni['pass']) ? $aIni['pass'] : '';
-			$this->_hostport = isset($aIni['port']) ? $aIni['port'] : '3306';
-			$this->_hostport = $this->_hostport == '3306' ? '' : ':'.$this->_hostport;
-			$this->_db_name  = ltrim(isset($aIni['path']) ? $aIni['path'] : '', '/\\');
+			
+			$scheme   = isset($aIni['scheme']) ? $aIni['scheme'] : 'mysql';
+			$hostname = isset($aIni['host']) ? $aIni['host'] : '';
+			$username = isset($aIni['user']) ? $aIni['user'] : '';
+			$password = isset($aIni['pass']) ? $aIni['pass'] : '';
+			$hostport = isset($aIni['port']) ? $aIni['port'] : '3306';
+			$hostport = $hostport == '3306' ? '' : ':'.$hostport;
+			$db_name  = ltrim(isset($aIni['path']) ? $aIni['path'] : '', '/\\');
+			$this->_db_name = $db_name;
 		}else {
 			throw new RuntimeException('Missing parameter: unable to connect database');
 		}
-		$this->_db_handle = mysql_connect($this->_hostname.$this->_hostport,
-		                                  $this->_username,
-		                                  $this->_password);
+		$this->_db_handle = mysql_connect($hostname.$hostport,
+		                                  $username,
+		                                  $password);
 		if(!$this->_db_handle) {
-			throw new RuntimeException('unable to connect \''.$this->_scheme.'://'.
-			                           $this->_hostname.$this->_hostport.'\'');
+			throw new RuntimeException('unable to connect \''.$scheme.'://'.
+			                           $hostname.$hostport.'\'');
 		} else {
-			if(!mysql_select_db($this->_db_name)) {
-				throw new RuntimeException('unable to select database \''.$this->_db_name.
-				                           '\' on \''.$this->_scheme.'://'.
-				                           $this->_hostname.$this->_hostport.'\'');
+			if(!mysql_select_db($db_name)) {
+				throw new RuntimeException('unable to select database \''.$db_name.
+				                           '\' on \''.$scheme.'://'.
+				                           $hostname.$hostport.'\'');
 			} else {
 				$this->connected = true;
 			}
@@ -170,9 +171,19 @@
 		return $this->error;
 	}
 
+	// Return escape_string
 /**
+ * escape a string for use in DB
+ * @param string 
+ * @return string
+ */	
+	public function escapeString($string) {
+		return mysql_real_escape_string($string, $this->_db_handle);
+	}
+
+/**
  * default Getter for some properties
- * @param string $sPropertyName
+ * @param string name of the Property
  * @return mixed NULL on error or missing property
  */
 	public function __get($sPropertyName)
@@ -183,6 +194,9 @@
 			case 'getDbHandle':
 				$retval = $this->_db_handle;
 				break;
+			case 'LastInsertId':
+				$retval = mysql_insert_id($this->_db_handle);
+				break;
 			case 'db_name':
 			case 'DbName':
 			case 'getDbName':
@@ -199,9 +213,9 @@
 	} // __get()
 
 /*
- * @param string $table_name: full name of the table (incl. TABLE_PREFIX)
- * @param string $field_name: name of the field to seek for
- * @return bool: true if field exists
+ * @param string full name of the table (incl. TABLE_PREFIX)
+ * @param string name of the field to seek for
+ * @return bool true if field exists
  */
 	public function field_exists($table_name, $field_name)
 	{
@@ -211,9 +225,9 @@
 	}
 
 /*
- * @param string $table_name: full name of the table (incl. TABLE_PREFIX)
- * @param string $index_name: name of the index to seek for
- * @return bool: true if field exists
+ * @param string full name of the table (incl. TABLE_PREFIX)
+ * @param string name of the index to seek for
+ * @return bool true if field exists
  */
 	public function index_exists($table_name, $index_name, $number_fields = 0)
 	{
@@ -241,10 +255,10 @@
 	}
 
 /*
- * @param string $table_name: full name of the table (incl. TABLE_PREFIX)
- * @param string $field_name: name of the field to add
- * @param string $description: describes the new field like ( INT NOT NULL DEFAULT '0')
- * @return bool: true if successful, otherwise false and error will be set
+ * @param string full name of the table (incl. TABLE_PREFIX)
+ * @param string name of the field to add
+ * @param string describes the new field like ( INT NOT NULL DEFAULT '0')
+ * @return bool true if successful, otherwise false and error will be set
  */
 	public function field_add($table_name, $field_name, $description)
 	{
Index: branches/2.8.x/wb/framework/TranslationTable.php
===================================================================
--- branches/2.8.x/wb/framework/TranslationTable.php	(revision 1865)
+++ branches/2.8.x/wb/framework/TranslationTable.php	(revision 1866)
@@ -83,7 +83,7 @@
 		}else {
 			$bLanguageFound = false;
 			$oAdaptor= new $sAdaptor($this->sAddon);
-			if(!$oAdaptor instanceof TranslatorAdaptorInterface) {
+			if(!$oAdaptor instanceof TranslateAdaptorInterface) {
 				$sMsg = 'Class ['.$sAdaptor.'] does not implement the '
 				      . 'interface [TranslateAdaptorInterface]';
 				throw new TranslationException($sMsg);
Index: branches/2.8.x/wb/framework/functions.php
===================================================================
--- branches/2.8.x/wb/framework/functions.php	(revision 1865)
+++ branches/2.8.x/wb/framework/functions.php	(revision 1866)
@@ -13,7 +13,7 @@
  * @filesource      $HeadURL$
  * @lastmodified    $Date$
  *
-*/
+ */
 /* -------------------------------------------------------- */
 // Must include code to stop this file being accessed directly
 if(!defined('WB_PATH')) {
@@ -415,15 +415,15 @@
 // Function to create directories
 function make_dir($dir_name, $dir_mode = OCTAL_DIR_MODE, $recursive=true)
 {
-	$retVal = is_dir($dir_name);
-	if(!is_dir($dir_name))
+	$bRetval = is_dir($dir_name);
+	if(!$bRetval)
     {
 		// To create the folder with 0777 permissions, we need to set umask to zero.
 		$oldumask = umask(0) ;
-		$retVal = mkdir($dir_name, $dir_mode, $recursive);
+		$bRetval = mkdir($dir_name, $dir_mode|0711, $recursive);
 		umask( $oldumask ) ;
 	}
-	return $retVal;
+	return $bRetval;
 }
 
 /**
@@ -433,7 +433,7 @@
  * @param int rights in dec-value. 0= use wb-defaults
  * @return bool
  */
-function change_mode($sName, $iMode = 0)
+function change_mode($sName, $iMode = 0 )
 {
 	$bRetval = true;
     $iErrorReporting = error_reporting(0);
@@ -653,6 +653,7 @@
 	}
 }
 
+
 // Create a new directory and/or protected file in the given directory
 function createFolderProtectFile($sAbsDir='',$make_dir=true)
 {
@@ -663,16 +664,15 @@
 
 	if ( $make_dir==true ) {
 		// Check to see if the folder already exists
-		if(file_exists($sAbsDir)) {
-			// $admin->print_error($MESSAGE['MEDIA_DIR_EXISTS']);
+		if(is_readable($sAbsDir)) {
 			$retVal[] = basename($sAbsDir).'::'.$MESSAGE['MEDIA_DIR_EXISTS'];
 		}
 		if (!is_dir($sAbsDir) && !make_dir($sAbsDir) ) {
-			// $admin->print_error($MESSAGE['MEDIA_DIR_NOT_MADE']);
 			$retVal[] = basename($sAbsDir).'::'.$MESSAGE['MEDIA_DIR_NOT_MADE'];
 		} else {
 			change_mode($sAbsDir);
 		}
+		return $retVal;
 	}
 
 	if( is_writable($sAbsDir) )
@@ -698,8 +698,7 @@
 		// write content into file
 		  if(is_writable($filename) || !file_exists($filename)) {
 		      if(file_put_contents($filename, $content)) {
-		//    print 'create => '.str_replace( $wb_path,'',$filename).'<br />';
-		          change_mode($filename, 'file');
+		          $retVal[] = change_mode($filename);
 		      } else {
 		    $retVal[] = $MESSAGE['GENERIC_BAD_PERMISSIONS'].' :: '.$filename;
 		   }
@@ -714,6 +713,7 @@
 {
 	global $MESSAGE;
 	$retVal = array();
+	$tmpVal = array();
 	$dir = rtrim(str_replace('\/\\', '/', $dir), '/');
 	try {
 		$files = array();
@@ -724,8 +724,9 @@
 		$files = array_unique($files);
 		foreach( $files as $file) {
 			$protect_file = rtrim(str_replace('\/\\', '/', $file), '/');
-			$retVal[] = createFolderProtectFile($protect_file,false);
+			$tmpVal['file'][] = createFolderProtectFile($protect_file,false);
 		}
+		$retVal = $tmpVal['file'];
 	} catch ( Exception $e ) {
 		$retVal[] = $MESSAGE['MEDIA_DIR_ACCESS_DENIED'];
 	}
@@ -733,56 +734,94 @@
 }
 
 // Create a new file in the pages directory
-function create_access_file($filename,$page_id,$level)
+/**
+ * createAccessFile()
+ * 
+ * @param string The full path and filename to the new accessfile
+ * @param int    Id of the page for which the file should created
+ * @param mixed  an array with one or more additional statements to include in accessfile.
+ * @return bool|string true or error message
+ * @deprecated this function will be replaced by a core method in next version
+ * @description: Create a new access file in the pages directory and subdirectory also if needed.<br />
+ * Example: $aOptionalCommands = array(
+ *                     '$section_id = '.$section_id,
+ *                     '$mod_var_int = '.$mod_var_int,
+ *                     'define(\'MOD_CONSTANT\'', '.$mod_var_int.')'
+ *          );
+ * forbidden commands: include|require[_once]
+ * @deprecated   2013/02/19
+ */
+  
+function create_access_file($sFileName, $iPageId, $iLevel = 0, array $aOptionalCommands = array() )
 {
-	global $admin, $MESSAGE;
-	$retVal = array();
-	// First make sure parent folder exists
-	$parent_folders = explode('/',str_replace(WB_PATH.PAGES_DIRECTORY, '', dirname($filename)));
-	$parents = '';
-	foreach($parent_folders AS $parent_folder)
-	{
-		if($parent_folder != '/' AND $parent_folder != '')
+	global $MESSAGE;
+	$sError = '';
+// sanitize pathnames for the standard 'trailing slash' scheme
+	$sAppPath  = rtrim(str_replace('\\', '/', WB_PATH), '/').'/';
+	$sFileName = str_replace('\\', '/', $sFileName);
+// try to create the whoole path to the accessfile
+	$sAccessPath = dirname($sFileName).'/';
+	if(!($bRetval = is_dir($sAccessPath))) {
+		$iOldUmask = umask(0) ;
+		// sanitize directory mode to 'o+rwx/g+x/u+x' and create path
+		$bRetval = mkdir($sAccessPath, (OCTAL_DIR_MODE |0711), true); 
+		umask($iOldUmask);
+	}
+	if($bRetval) {
+	// check if accessfile is writeable
+		if(is_writable($sAccessPath) ||
+		   (file_exists($sFileName) && is_writable($sFileName)) )
 		{
-			$parents .= '/'.$parent_folder;
-			$acces_file = WB_PATH.PAGES_DIRECTORY.$parents;
-			// can only be dirs
-			if(!is_readable($acces_file)) {
-				if(!make_dir($acces_file)) {
-					$retVal[] = $MESSAGE['PAGES_CANNOT_CREATE_ACCESS_FILE_FOLDER'];
-                    $retVal[] = $MESSAGE['MEDIA_DIR_ACCESS_DENIED'];
+		// build content for accessfile
+			$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".'$page_id = '.$iPageId.';'."\n";
+		// analyse OptionalCommands and add it to the accessfile
+			foreach($aOptionalCommands as $sCommand) {
+			// loop through all available entries
+			// remove all leading whitespaces and chars less then \x41(A) except \x24 ($)
+			// also all trailing whitespaces and \x3B(;) too.
+				$sNewCmd  = rtrim(ltrim($sCommand, "\x00..\x23\x25..\x40"), ';');
+				if(preg_match('/^include|^require/i', $sNewCmd)) {
+				// insert forbidden include|require[_once] command and comment it out
+					$sContent .= "\t".'// *not allowed command >> * '.$sNewCmd.';'."\n";
+				}elseif(preg_match('/^define/i', $sNewCmd)) {
+				// insert active define command and comment it as set deprecated
+					$sContent .= "\t".$sNewCmd.'; // *deprecated command*'."\n";
+				}else {
+				// insert allowed active command
+					$sContent .= "\t".$sNewCmd.';'."\n";
 				}
 			}
+		// calculate the needed backsteps and create the relative link to index.php
+			$iBackSteps = substr_count(str_replace($sAppPath, '', $sFileName), '/');
+			$sIndexFile = str_repeat('../', $iBackSteps).'index.php';
+		// insert needed require command for index.php
+			$sContent .= "\t".'require(\''.$sIndexFile.'\');'."\n"
+			           . '// *************************************************'."\n"
+			           . '// end of file'."\n";
+		// write new file out. If the file already exists overwrite its content.
+			if(file_put_contents($sFileName, $sContent) !== false ) {
+			// if OS is not windows then chmod the new file 
+				if (strtoupper(substr(PHP_OS, 0, 3)) !== 'WIN') {
+				// sanitize filemode to 'o-x/g-x/u-x/o+rw' and chmod the new file
+					$bRetval = chmod($sName, ((OCTAL_FILE_MODE & ~0111)|0600));
+				}
+			}else {
+		        $sError = $MESSAGE['PAGES_CANNOT_CREATE_ACCESS_FILE'];
+			}
+		}else {
+			$sError = $MESSAGE['UPLOAD_ERR_CANT_WRITE'];
 		}
+	}else {
+		$sError = $MESSAGE['UPLOAD_ERR_CANT_WRITE'];
 	}
-
-	// The depth of the page directory in the directory hierarchy
-	// '/pages' is at depth 2
-	$bPagesDirectorySet = (sizeof(explode('/',PAGES_DIRECTORY))==1);
-	// Work-out how many ../'s we need to get to the index page
-	$pages_dir_depth = sizeof($parent_folders)-intval($bPagesDirectorySet);
-	$index_location = str_repeat ( '../' , $pages_dir_depth );
-	$content =
-		'<?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".'$page_id    = '.$page_id.';'."\n".
-		"\t".'require(\''.$index_location.'index.php\');'."\n".
-		'// *************************************************'."\n";
-
-	if( ($handle = fopen($filename, 'w')) ) {
-		fwrite($handle, $content);
-		fclose($handle);
-		// Chmod the file
-		change_mode($filename);
-	} else {
-//		$admin->print_error($MESSAGE['PAGES_CANNOT_CREATE_ACCESS_FILE']);
-        $retVal[] = $MESSAGE['PAGES_CANNOT_CREATE_ACCESS_FILE'];
-	}
-	return $retVal;
+	// return boolean true if ok, on error return a message
+	return ($sError == '' ? true : $sError);
  }
 
 // Function for working out a file mime type (if the in-built PHP one is not enabled)
@@ -1348,16 +1387,19 @@
     	 * try to remove access files and build new folder protect files
     	 */
     	$sTempDir = (defined('PAGES_DIRECTORY') && (PAGES_DIRECTORY != '') ? PAGES_DIRECTORY : '');
-    	if(($sTempDir!='') && is_writeable(WB_PATH.$sTempDir)==true) {
-    	 	if(rm_full_dir (WB_PATH.$sTempDir, true )==false) {
-    			$retVal[] = '<span><strong>Could not delete existing access files</strong></span>';
-    	 	}
-    	}
-		$retVal[] = createFolderProtectFile(rtrim( WB_PATH.PAGES_DIRECTORY,'/') );
+//    	if(($sTempDir!='') && is_writeable(WB_PATH.$sTempDir)==true) {
+//    	 	if(rm_full_dir (WB_PATH.$sTempDir, true )==false) {
+//    			$retVal[] = 'Could not delete existing access files';
+//    	 	}
+//    	}
+		$retVal = createFolderProtectFile(rtrim( WB_PATH.PAGES_DIRECTORY,'/') );
     	/**
     	 * Reformat/rebuild all existing access files
     	 */
-        $sql = 'SELECT `page_id`,`root_parent`,`link`, `level` FROM `'.TABLE_PREFIX.'pages` ORDER BY `link`';
+//        $sql = 'SELECT `page_id`,`root_parent`,`link`, `level` FROM `'.TABLE_PREFIX.'pages` ORDER BY `link`';
+		$sql  = 'SELECT `page_id`,`root_parent`,`link`, `level` ';
+		$sql .= 'FROM `'.TABLE_PREFIX.'pages` ';
+		$sql .= 'WHERE `link` != \'\' ORDER BY `link` ';
         if (($oPage = $database->query($sql)))
         {
             $x = 0;
@@ -1378,10 +1420,10 @@
 
                 if(!$database->query($sql)) {}
                 $filename = WB_PATH.PAGES_DIRECTORY.$page['link'].PAGE_EXTENSION;
-                $retVal = create_access_file($filename, $page['page_id'], $page['level']);
+                create_access_file($filename, $page['page_id'], $page['level']);
                 $x++;
             }
-            $retVal[] = '<span><strong>Number of new formated access files: '.$x.'</strong></span>';
+            $retVal[] = 'Number of new formated access files: '.$x.'';
         }
     return $retVal;
 	}
@@ -1395,7 +1437,7 @@
     			$currModulVersion = get_modul_version ($sModul, false);
     			$newModulVersion =  get_modul_version ($sModul, true);
     			if((version_compare($currModulVersion, $newModulVersion) <= 0)) {
-    				require_once(WB_PATH.'/modules/'.$sModul.'/upgrade.php');
+    				require(WB_PATH.'/modules/'.$sModul.'/upgrade.php');
     			}
     		}
     	}
Index: branches/2.8.x/wb/framework/ModLanguage.php
===================================================================
--- branches/2.8.x/wb/framework/ModLanguage.php	(revision 1865)
+++ branches/2.8.x/wb/framework/ModLanguage.php	(revision 1866)
@@ -9,6 +9,7 @@
  * @filesource   $HeadURL$
  * @since        Datei vorhanden seit Release 2.8.4
  * @lastmodified $Date$
+ * @deprecated   2013/02/19
  */
 class ModLanguage {
 
@@ -203,4 +204,4 @@
 /**
  *  Exception class for Translation
  */
-class TranslationException extends AppException {}
+//class TranslationException extends AppException {}
Index: branches/2.8.x/wb/modules/news/Reorg.php
===================================================================
--- branches/2.8.x/wb/modules/news/Reorg.php	(nonexistent)
+++ branches/2.8.x/wb/modules/news/Reorg.php	(revision 1866)
@@ -0,0 +1,88 @@
+<?php
+/**
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
+ *
+ * This program 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 3 of the License, or
+ * (at your option) any later version.
+ *
+ * This program 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 this program.  If not, see <http://www.gnu.org/licenses/>.
+ */
+
+/**
+ * Reorg.php
+ *
+ * @category     Module
+ * @package      Module_news
+ * @author       Werner v.d.Decken <wkl@isteam.de>
+ * @copyright    Werner v.d.Decken <wkl@isteam.de>
+ * @license      http://www.gnu.org/licenses/gpl.html   GPL License
+ * @version      0.0.1
+ * @revision     $Revision: $
+ * @link         $HeadURL: $
+ * @lastmodified $Date: $
+ * @since        File available since 17.01.2013
+ * @description  Reorganisation jobs for the 'news' module
+ */
+
+class m_news_Reorg {
+
+	private $_aSys = array();
+/**
+ * Execute reorganisation
+ * @return string all occured messages 
+ */
+	public function execute() 
+	{
+		$sOutput = null;
+		if(class_exists('WbAdaptor')) {
+			$this->_aSys['TablePrefix'] = WbAdaptor::getInstance()->TablePrefix;
+			$this->_aSys['AppPath'] = WbAdaptor::getInstance()->AppPath;
+			$this->_aSys['PagesDir'] = WbAdaptor::getInstance()->PagesDir;
+			$this->_aSys['PageExtension'] = WbAdaptor::getInstance()->PageExtension;
+			$sOutput = $this->createAccessFiles();
+		}
+		// add here the requests for additional reorg methods
+		return $sOutput;
+	}
+/**
+ * Creates all Accessfiles from DB
+ * @return string all occured messages 
+ */
+	protected function createAccessFiles()
+	{
+		$count = 0;
+		$aReturnMsg = array();
+		$sql  = 'SELECT `page_id`,`post_id`,`section_id`,`link` ';
+		$sql .= 'FROM `'.$this->_aSys['TablePrefix'].'mod_news_posts`';
+		$sql .= 'WHERE `link` != \'\'';
+		if(($oPosts = WbDatabase::getInstance()->query($sql))) {
+			while($aPost = $oPosts->fetchRow(MYSQL_ASSOC))
+			{
+				$sAccessFile = $this->_aSys['AppPath'].$this->_aSys['PagesDir']
+				               . trim(str_replace('\\', '/', $aPost['link']), '/')
+				               . $this->_aSys['PageExtension'];
+				$aOptionalCommand = array(
+					'$section_id   = '.$aPost['section_id'].';',
+					'$post_section = '.$aPost['section_id'].';',
+					'$post_id      = '.$aPost['post_id'].';'
+				);
+				if(create_access_file($sAccessFile, $aPost['page_id'], 0, $aOptionalCommand)){
+					$count++;	
+				} else {
+					$aReturnMsg[] = 'Can\'t create '.$sAccessFile;	
+				}
+			}
+			$aReturnMsg[] = 'Number of new created access files: '.$count;
+		}
+		return $aReturnMsg;
+	}
+	// add here some additional reorg methods **************************************** *//
+} // end of class Reorg
Index: branches/2.8.x/wb/modules/news/upgrade.php
===================================================================
--- branches/2.8.x/wb/modules/news/upgrade.php	(revision 1865)
+++ branches/2.8.x/wb/modules/news/upgrade.php	(revision 1866)
@@ -1,20 +1,40 @@
 <?php
 /**
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
  *
- * @category        modules
- * @package         news
- * @subpackage      upgrade
- * @copyright       2009-2012, WebsiteBaker Org. e.V.
- * @link			http://www.websitebaker2.org/
- * @license         http://www.gnu.org/licenses/gpl.html
- * @platform        WebsiteBaker 2.8.x
- * @requirements    PHP 5.2.2 and higher
- * @version         $Id$
- * @filesource		$HeadURL$
- * @lastmodified    $Date$
+ * This program 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 3 of the License, or
+ * (at your option) any later version.
  *
+ * This program 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 this program.  If not, see <http://www.gnu.org/licenses/>.
  */
 
+/**
+ * upgrade.php
+ * 
+ * @category     Module
+ * @package      Module_news
+ * @subpackage   upgrade
+ * @author       Dietmar WÃ¶llbrink <dietmar.woellbrink@websitebaker.org>
+ * @author       Werner v.d.Decken <wkl@isteam.de>
+ * @copyright    Werner v.d.Decken <wkl@isteam.de>
+ * @license      http://www.gnu.org/licenses/gpl.html   GPL License
+ * @version      0.0.1
+ * @revision     $Revision$
+ * @link         $HeadURL$
+ * @lastmodified $Date$
+ * @since        File available since 17.01.2013
+ * @description  xyz
+ * 
+ */
+
 /* -------------------------------------------------------- */
 // Must include code to stop this file being accessed directly
 require_once( dirname(dirname(dirname(__FILE__))).'/framework/globalExceptionHandler.php');
@@ -26,51 +46,48 @@
 	function mod_news_Upgrade()
 	{
 		global $database, $admin, $MESSAGE,$bDebugModus;
-    	$msg = array();
+		$msg = array();
 		$callingScript = $_SERVER["SCRIPT_NAME"];
 // check if upgrade startet by upgrade-script to echo a message
 		$tmp = 'upgrade-script.php';
 		$globalStarted = substr_compare($callingScript, $tmp,(0-strlen($tmp)),strlen($tmp)) === 0;
-        /**
-         * check database engine
-         */
-    	$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[] = 'TABLE `'.TABLE_PREFIX.$aTable[$x].'` changed to Engine = \'MyISAM\'';
-        			}
-        		} else {
-                 $msg[] = 'TABLE `'.TABLE_PREFIX.$aTable[$x].'` has Engine = \'MyISAM\'';
-        		}
-        	} else {
-        		$msg[] = $database->get_error();
-        	}
-        }
+		/**
+		 * check database engine
+		 */
+		$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[] = 'TABLE `'.TABLE_PREFIX.$aTable[$x].'` changed to Engine = \'MyISAM\'';
+					}
+				} else {
+							 $msg[] = 'TABLE `'.TABLE_PREFIX.$aTable[$x].'` has Engine = \'MyISAM\'';
+				}
+			} else {
+				$msg[] = $database->get_error();
+			}
+		}
 
-
 		$sPagesPath = WB_PATH.PAGES_DIRECTORY;
 		$sPostsPath = $sPagesPath.'/posts';
 	// create /posts/ - directory if not exists
-		if(!file_exists($sPostsPath)) {
-			if(is_writable($sPagesPath)) {
-				make_dir(WB_PATH.PAGES_DIRECTORY.'/posts/');
-			} else {
-				if(!$globalStarted){
-					$msg[] = ($MESSAGE['PAGES_CANNOT_CREATE_ACCESS_FILE']);
-//					$admin->print_error($MESSAGE['PAGES_CANNOT_CREATE_ACCESS_FILE']);
-					return $msg;
-				} else {
-					echo  ''.$MESSAGE['PAGES_CANNOT_CREATE_ACCESS_FILE'].'';
-					return $msg;
-				}
+		if(is_writable($sPagesPath)) {
+			if(!($bRetval = is_dir($sPostsPath))) {
+				$iOldUmask = umask(0) ;
+				// sanitize directory mode to 'o+rwx/g+x/u+x' and create path
+				$bRetval = mkdir($sPostsPath, (OCTAL_DIR_MODE |0711), true); 
+				umask($iOldUmask);
 			}
-            $msg[] = '<strong>Directory "'.PAGES_DIRECTORY.'/posts/" created</strong>';
-		} else {
-            $msg[] = '<strong>Directory "'.PAGES_DIRECTORY.'/posts/" already exists.</strong>';
+			if($bRetval) {
+				$msg[] = 'Directory "'.PAGES_DIRECTORY.'/posts/" already exists or created.';
+			}else {
+				$msg[] = ($MESSAGE['PAGES_CANNOT_CREATE_ACCESS_FILE']);
+			}
+		}else {
+				$msg[] = ($MESSAGE['PAGES_CANNOT_CREATE_ACCESS_FILE']);
 		}
 	// check if new fields must be added
 		$doImportDate = true;
@@ -77,38 +94,25 @@
 		if(!$database->field_exists(TABLE_PREFIX.'mod_news_posts', 'created_when')) {
 			if(!$database->field_add(TABLE_PREFIX.'mod_news_posts', 'created_when',
 			                        'INT NOT NULL DEFAULT \'0\' AFTER `commenting`')) {
-				if($globalStarted){
-					echo ''.$MESSAGE['RECORD_MODIFIED_FAILED'].'';
-					return $msg;
-				} else {
-//					$admin->print_error($MESSAGE['RECORD_MODIFIED_FAILED']);
 					$msg[] = $MESSAGE['RECORD_MODIFIED_FAILED'];
-					return $msg;
-				}
+			} else {
+				$msg[] = 'TABLE `'.TABLE_PREFIX.'mod_news_posts` Datafield `created_when` added.';
 			}
+		} else { 
+			$msg[] = 'TABLE `'.TABLE_PREFIX.'mod_news_posts` Datafield `created_when` already exists.';
+			$doImportDate = false; 
+		}
 
-            if($globalStarted) {
-                echo 'Datafield `'.TABLE_PREFIX.'mod_news_posts`.`created_when` added.<br />';
-            }
-		} else { $doImportDate = false; }
-
 		if(!$database->field_exists(TABLE_PREFIX.'mod_news_posts', 'created_by')) {
 			if(!$database->field_add(TABLE_PREFIX.'mod_news_posts', 'created_by',
 			                        'INT NOT NULL DEFAULT \'0\' AFTER `created_when`')) {
-				if($globalStarted){
-					echo ''.$MESSAGE['RECORD_MODIFIED_FAILED'].'';
-					return $msg;
-				}else {
-//					$admin->print_error($MESSAGE['RECORD_MODIFIED_FAILED']);
-					$msg[] = $MESSAGE['RECORD_MODIFIED_FAILED'];
-					return $msg;
-				}
+				$msg[] = $MESSAGE['RECORD_MODIFIED_FAILED'];
 			}
-            if($globalStarted) {
-                echo 'datafield `'.TABLE_PREFIX.'mod_news_posts`.`created_by` added.<br />';
-            }
+		} else { 
+			$msg[] = 'TABLE `'.TABLE_PREFIX.'mod_news_posts` Datafield `created_by` already exists.';
+			$doImportDate = false; 
 		}
-	// preset new fields `created_by` and `created_when` from existing values
+ 	// preset new fields `created_by` and `created_by` from existing values
 		if($doImportDate) {
 			$sql  = 'UPDATE `'.TABLE_PREFIX.'mod_news_posts` ';
 			$sql .= 'SET `created_by`=`posted_by`, `created_when`=`posted_when`';
@@ -115,10 +119,10 @@
 			$database->query($sql);
 		}
 
-    /**
-     * rebuild news post folder
-     */
-	$array = rebuildFolderProtectFile($sPostsPath);
+	/**
+	 * rebuild news post folder
+	 */
+//	$array = rebuildFolderProtectFile($sPostsPath);
 	// now iterate through all existing accessfiles,
 	// write its creation date into database
 		$oDir = new DirectoryIterator($sPostsPath);
@@ -137,17 +141,18 @@
 					$sql  = 'UPDATE `'.TABLE_PREFIX.'mod_news_posts` ';
 					$sql .= 'SET `created_when`='.$fileinfo->getMTime().' ';
 					$sql .= 'WHERE `link`=\''.$link.'\'';
-					$database->query($sql);
+					if($database->query($sql)) {
+						// delete old access file
+						unlink($fileinfo->getPathname());
+						$count++;
+					}
 				}
-			// delete old access file
-				unlink($fileinfo->getPathname());
-				$count++;
 			}
 		}
 		unset($oDir);
 
 		if($count > 0) {
-			$msg[] = 'save date of creation from '.$count.' old accessfiles and delete these files.';
+			$msg[] = 'Save date of creation from '.$count.' old accessfiles and delete these files.';
 		}
 // ************************************************
 	// Check the validity of 'create-file-timestamp' and balance against 'posted-timestamp'
@@ -161,41 +166,6 @@
 		$database->query($sql);
 // ************************************************
 
-	// rebuild all access-files
-		$count = 0;
-		$backSteps = preg_replace('@^'.preg_quote(WB_PATH).'@', '', $sPostsPath);
-		$backSteps = str_repeat( '../', substr_count($backSteps, '/'));
-		$sql  = 'SELECT `page_id`,`post_id`,`section_id`,`link` ';
-		$sql .= 'FROM `'.TABLE_PREFIX.'mod_news_posts`';
-		$sql .= 'WHERE `link` != \'\'';
-		if( ($resPosts = $database->query($sql)) )
-		{
-			while( $recPost = $resPosts->fetchRow() )
-			{
-				$file = $sPagesPath.$recPost['link'].PAGE_EXTENSION;
-				$content =
-					'<?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".'$page_id    = '.$recPost['page_id'].';'."\n".
-					"\t".'$section_id = '.$recPost['section_id'].';'."\n".
-					"\t".'$post_id    = '.$recPost['post_id'].';'."\n".
-					"\t".'$post_section = '.$recPost['section_id'].';'."\n".
-					"\t".'require(\''.$backSteps.'index.php\');'."\n".
-					'// *************************************************'."\n";
-				if( file_put_contents($file, $content) !== false ) {
-				// Chmod the file
-					change_mode($file);
-				}else {
-					$msg[] = ($MESSAGE['PAGES_CANNOT_CREATE_ACCESS_FILE']);
-				}
-				$count++;
-			}
-            $msg[] = '<strong>Number of new created access files: '.$count.'</strong>';
-		}
         // only for upgrade-script
         if($globalStarted) {
             if($bDebugModus) {
@@ -203,15 +173,24 @@
                     echo '<strong>'.$title.'</strong><br />';
                 }
             }
-        }
-        return $msg;
+        } 
+        return ( ($globalStarted==true ) ? $globalStarted : $msg);
 	}
 }
 // end mod_news_Upgrade
 
 // ------------------------------------
-
-$msg = mod_news_Upgrade();
-
-
-/* **** END UPGRADE ********************************************************* */
\ No newline at end of file
+// only show if manuell upgrade
+if( is_array($msg = mod_news_Upgrade()) ) {
+	$sModulReorg = 'm_news_Reorg';
+	if(class_exists($sModulReorg)) {
+		$oReorg = new $sModulReorg();
+		$msg = array_merge($msg, $oReorg->execute() ); // show details
+//		$msg = array_merge($msg,(new $sModulReorg())->execute()); // show details
+	}
+    foreach($msg as $title) {
+        echo '<strong>'.$title.'</strong><br />';
+    }
+	echo '<strong>News upgrade finished </strong><br /><br>';
+}
+/* **** END UPGRADE ********************************************************* */
