Index: branches/2.8.x/CHANGELOG
===================================================================
--- branches/2.8.x/CHANGELOG	(revision 1976)
+++ branches/2.8.x/CHANGELOG	(revision 1977)
@@ -11,10 +11,16 @@
 ! = Update/Change
 ===============================================================================
 
+06 Oct-2013 Build 1977 Dietmar Woellbrink (Luisehahne)
+! /framework/functions.php: started implementation of packet AccessFile in function rebuild_all_accessfiles()
++ /framework/functions.php::rm_full_dir() added additional argument to set list of protected files
+! integrate the new processes into the upgrade-script.php
++ extended checks and informations in /modules/MultiLingual/upgrade.php 
+  increasing version for module MultiLingual to 1.6.9
 05 Oct-2013 Build 1976 Manuela v.d.Decken(DarkViper)
 # Packet AccessFile fixed indifferent handling of './..' directory entries
 04 Oct-2013 Build 1975 Dietmar Woellbrink (Luisehahne)
-!   /install/sql/wb_search_data.sql recoding initial data for table `search` without primary index value
+!  /install/sql/wb_search_data.sql recoding initial data for table `search` without primary index value
 04 Oct-2013 Build 1974 Manuela v.d.Decken(DarkViper)
 ! /framework/WbDatabase  fixed little problem with multiple database connections
 03 Oct-2013 Build 1973 Manuela v.d.Decken(DarkViper)

Property changes on: branches/2.8.x/CHANGELOG
___________________________________________________________________
Added: svn:eol-style
## -0,0 +1 ##
+native
\ No newline at end of property
Modified: svn:keywords
## -1,4 +1 ##
-Id
-Revision
-HeadURL
-Date
\ No newline at end of property
+Date Author Id Revision HeadURL
\ No newline at end of property
Index: branches/2.8.x/wb/upgrade-script.php
===================================================================
--- branches/2.8.x/wb/upgrade-script.php	(revision 1976)
+++ branches/2.8.x/wb/upgrade-script.php	(revision 1977)
@@ -116,7 +116,7 @@
 $FAIL          = ' <span class="error">FAILED</span> ';
 $DEFAULT_THEME = 'wb_theme';
 
-$stepID = 0;
+$stepID = 1;
 $dirRemove = array(
 /*
 			'[TEMPLATE]/allcss/',
@@ -679,17 +679,6 @@
 	add_modify_field_in_database($table_name,$field_name,$description);
 
 	/**********************************************************
-	 *  - Add field "page_code" to table "pages"
-	 *
-	 *  will be done in upgrade.php of the module MultiLingual
-	 *  until the module is integrated completely
-	 */
-//	$table_name = TABLE_PREFIX.'pages';
-//	$field_name = 'page_code';
-//	$description = "INT NOT NULL DEFAULT '0' AFTER `language`";
-//	add_modify_field_in_database($table_name,$field_name,$description);
-
-	/**********************************************************
 	 *  - Add field "menu_icon_0" to table "pages"
 	 */
 	$table_name = TABLE_PREFIX.'pages';
@@ -897,9 +886,8 @@
 	/**********************************************************
 	* upgrade media directory index protect files
 	*/
-	$dir = (WB_PATH.MEDIA_DIRECTORY);
 	echo '<h4>Upgrade media directory '.MEDIA_DIRECTORY.'/ index.php protect files</h4>';
-	$aDebugMessage = rebuildFolderProtectFile($dir);
+	$aDebugMessage = rebuildFolderProtectFile();
 	if( sizeof( $aDebugMessage ) ){
 		echo '<span><strong>Upgrade '.sizeof( $aDebugMessage ).' directory '.MEDIA_DIRECTORY.'/ protect files</strong></span>'." $OK<br />";
 	} else {
@@ -916,9 +904,13 @@
     /**********************************************************
      *  - Reformat/rebuild all existing access files
      */
-    $sPagePath = (defined('PAGES_DIRECTORY') && (PAGES_DIRECTORY != '') ? PAGES_DIRECTORY : '');
-    $msg = rebuild_all_accessfiles();
-	$dir = (WB_PATH.PAGES_DIRECTORY);
+//    $sPagePath = (defined('PAGES_DIRECTORY') && (PAGES_DIRECTORY != '') ? PAGES_DIRECTORY : '');
+//	$sPageDir = str_replace('\\','/',WB_PATH.$sPagePath);
+//	$aProtectedFiles = array(
+//           $sPageDir.'/intro.php',
+//           $sPageDir.'/intro/intro.php',
+//    );
+    $msg = rebuild_all_accessfiles($bDebugModus);
 //	$aDebugMessage = rebuildFolderProtectFile($dir);
 	echo '<strong>'.implode ('<br />',$msg).'</strong>';
     echo '</div>';
Index: branches/2.8.x/wb/admin/interface/version.php
===================================================================
--- branches/2.8.x/wb/admin/interface/version.php	(revision 1976)
+++ branches/2.8.x/wb/admin/interface/version.php	(revision 1977)
@@ -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', '1976');
+if(!defined('REVISION')) define('REVISION', '1977');
 if(!defined('SP')) define('SP', '');
Index: branches/2.8.x/wb/framework/functions.php
===================================================================
--- branches/2.8.x/wb/framework/functions.php	(revision 1976)
+++ branches/2.8.x/wb/framework/functions.php	(revision 1977)
@@ -24,26 +24,61 @@
 // Define that this file has been loaded
 define('FUNCTIONS_FILE_LOADED', true);
 
+
 /**
+ * Delete an Accessfiles Tree
+ * @param  string  $sDirToDelete  
+ * @return boolean true/false
+ * @description    Delete all accessfiles and its depending directory tree 
+ *                 inside the given directory.
+ */
+
+function DeleteAccessFilesTree($sDirToDelete)
+{
+        $sBaseDir = realpath($sDirToDelete);
+        if( $sBaseDir !== false) {    
+		$sBaseDir = rtrim(str_replace('\\', '/', $sBaseDir), '/') . '/';
+		// scan start directory for access files
+		foreach (glob($sBaseDir . '*.php', GLOB_MARK) as $sItem) {
+            $sItem = str_replace('\\', '/', $sItem);
+			try{
+				$oAccFile = new AccessFile($sItem);
+				$oAccFile->delete();
+			}catch(AccessFileIsNoAccessfileException $e) {
+				continue;
+			}
+		}
+		return true;
+	}	
+	return false;
+}
+
+/**
  * @description: recursively delete a non empty directory
  * @param string $directory :
  * @param bool $empty : true if you want the folder just emptied, but not deleted
  *                      false, or just simply leave it out, the given directory will be deleted, as well
+ * @param array $aProtectedFiles optional list of protected files, full path needed
  * @return boolean: true/false
  * @from http://www.php.net/manual/de/function.rmdir.php#98499
  */
-function rm_full_dir($directory, $empty = false)
+function rm_full_dir($directory, $empty = false, $aProtectedFiles = null)
 {
+	$directory = rtrim(str_replace('\\','/',$directory),'/');
+	if($aProtectedFiles == null) {
+		$aProtectedFiles = array();
+	}
     $iErrorReporting = error_reporting(0);
-	if(substr($directory,-1) == "/") {
-        $directory = substr($directory,0,-1);
-    }
-   // If suplied dirname is a file then unlink it
+
     if (is_file( $directory )&& is_writable( $directory )) {
-        $retval = unlink($directory);
-        clearstatcache();
-        error_reporting($iErrorReporting);
-        return $retval;
+		if(!in_array(($directory), $aProtectedFiles)) {
+			$retval = unlink($directory);
+			clearstatcache();
+			error_reporting($iErrorReporting);
+			return $retval;
+		}else {
+			return true;
+		}
     }
     if(!is_writable($directory) || !is_dir($directory)) {
         error_reporting($iErrorReporting);
@@ -59,10 +94,12 @@
 			{
                 $path = $directory . "/" . $contents;
                 if(is_dir($path)) {
-                    rm_full_dir($path);
+                    rm_full_dir($path, false, $aProtectedFiles);
                 } else {
-                    unlink($path);
-					clearstatcache();
+					if(!in_array($path, $aProtectedFiles)) {
+				        unlink($path);
+						clearstatcache();
+					}
                 }
             }
         }
@@ -670,8 +707,9 @@
 {
 	global $admin, $MESSAGE;
 	$retVal = array();
-	$wb_path = rtrim(str_replace('\/\\', '/', WB_PATH), '/');
-	if( ($sAbsDir=='') || ($sAbsDir == $wb_path) ) { return $retVal;}
+	$wb_path   = rtrim(str_replace('\/\\', '/', WB_PATH), '/');
+	$sAppPath  = rtrim(str_replace('\/\\', '/', WB_PATH), '/').'/';
+	if( ($sAbsDir=='') || ($sAbsDir == $sAppPath) ) { return $retVal;}
 
 	if ( $make_dir==true ) {
 		// Check to see if the folder already exists
@@ -678,7 +716,7 @@
 		if(is_readable($sAbsDir)) {
 			$retVal[] = basename($sAbsDir).'::'.$MESSAGE['MEDIA_DIR_EXISTS'];
 		}
-		if (!is_dir($sAbsDir) && !make_dir($sAbsDir) ) {
+		if (!make_dir($sAbsDir) && !is_dir($sAbsDir) ) {
 			$retVal[] = basename($sAbsDir).'::'.$MESSAGE['MEDIA_DIR_NOT_MADE'];
 		} else {
 			change_mode($sAbsDir);
@@ -693,8 +731,8 @@
 	{
         // if(file_exists($sAbsDir.'/index.php')) { unlink($sAbsDir.'/index.php'); }
 	    // Create default "index.php" file
-		$rel_pages_dir = str_replace($wb_path, '', dirname($sAbsDir) );
-		$step_back = str_repeat( '../', substr_count($rel_pages_dir, '/')+1 );
+		$iBackSteps = substr_count(str_replace($sAppPath, '', $sAbsDir), '/');
+		$sIndexFile = str_repeat('../', $iBackSteps).'index.php';
 		$sResponse  = $_SERVER['SERVER_PROTOCOL'].' 301 Moved Permanently';
 		$content =
 			'<?php'."\n".
@@ -1407,19 +1445,26 @@
 }
 
 if(!function_exists('rebuild_all_accessfiles')){
-	function rebuild_all_accessfiles() {
+	function rebuild_all_accessfiles($bShowDetails=false ) {
         global $database;
-    	$retVal = array();
+    	$aRetval = array();
     	/**
     	 * 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[] = 'Could not delete existing access files';
-    	 	}
+ //   	$sTempDir = (defined('PAGES_DIRECTORY') && (PAGES_DIRECTORY != '') ? PAGES_DIRECTORY : '').'/';
+        $sTreeToDelete = WbAdaptor::getInstance()->AppPath.WbAdaptor::getInstance()->PagesDir;
+    	if(($sTreeToDelete!='') && is_writeable($sTreeToDelete)==true) {
+//    	 	if(rm_full_dir (WB_PATH.$sTempDir, true, $aProtectedFiles )==false) {
+//    			$aRetval[] = 'Could not delete existing access files';
+//    	 	}
+            DeleteAccessFilesTree($sTreeToDelete);
+            if($bShowDetails) {
+                $aRetval = array_merge($aRetval, AccessFileHelper::getDelTreeLog());
+            }
     	}
-		$retVal = createFolderProtectFile(rtrim( WB_PATH.PAGES_DIRECTORY,'/') );
+
+		$aRetval = array_merge($aRetval,createFolderProtectFile(rtrim( WB_PATH.PAGES_DIRECTORY,'/') ));
+
     	/**
     	 * Reformat/rebuild all existing access files
     	 */
@@ -1450,9 +1495,9 @@
                 create_access_file($filename, $page['page_id'], $page['level']);
                 $x++;
             }
-            $retVal[] = 'Number of new formated access files: '.$x.'';
+            $aRetval[] = 'Number of new formated access files: '.$x.'';
         }
-    return $retVal;
+    return $aRetval;
 	}
 }
 
Index: branches/2.8.x/wb/modules/MultiLingual/info.php
===================================================================
--- branches/2.8.x/wb/modules/MultiLingual/info.php	(revision 1976)
+++ branches/2.8.x/wb/modules/MultiLingual/info.php	(revision 1977)
@@ -25,7 +25,7 @@
  * @author       Dietmar Wöllbrink <dietmar.woellbrink@websiteBaker.org>
  * @copyright    Werner v.d.Decken <wkl@isteam.de>
  * @license      http://www.gnu.org/licenses/gpl.html   GPL License
- * @version      1.6.8
+ * @version      1.6.9
  * @revision     $Revision$
  * @link         $HeadURL$
  * @lastmodified $Date$
@@ -34,9 +34,9 @@
  */
 
 $module_directory = 'MultiLingual';
-$module_name = 'MultiLingual Switcher 1.6.8';
+$module_name = 'MultiLingual Switcher 1.6.9';
 $module_function = 'snippet';
-$module_version = '1.6.8';
+$module_version = '1.6.9';
 $module_status	= 'alpha';
 $module_platform = '2.8.4';
 $module_author = 'Luisehahne';
Index: branches/2.8.x/wb/modules/MultiLingual/upgrade.php
===================================================================
--- branches/2.8.x/wb/modules/MultiLingual/upgrade.php	(revision 1976)
+++ branches/2.8.x/wb/modules/MultiLingual/upgrade.php	(revision 1977)
@@ -25,7 +25,7 @@
  * @author       Dietmar Wöllbrink <dietmar.woellbrink@websiteBaker.org>
  * @copyright    Werner v.d.Decken <wkl@isteam.de>
  * @license      http://www.gnu.org/licenses/gpl.html   GPL License
- * @version      1.6.8
+ * @version      1.6.9
  * @revision     $Revision$
  * @link         $HeadURL$
  * @lastmodified $Date$
@@ -41,35 +41,75 @@
 }
 /* -------------------------------------------------------- */
 
-// Work-out if we should check for existing page_code
-$sql = 'DESCRIBE `'.$database->TablePrefix.'pages` `page_code`';
-$field_sql = $database->query($sql);
-$field_set = $field_sql->numRows();
-$format = $field_sql->fetchRow(MYSQL_ASSOC) ;
-// upgrade only if old format
-if($format['Type'] == 'varchar(255)' )
-{
-    $sql = 'SELECT `page_code`,`page_id` FROM `'.$database->TablePrefix.'pages` ORDER BY `page_id`';
-    if($query_code = $database->query($sql))
-    {
-      // extract page_id from old format
-      $pattern = '/(?<=_)([0-9]{1,11})/s';
-      while( $page  = $query_code->fetchRow(MYSQL_ASSOC))
-      {
-          preg_match($pattern, $page['page_code'], $array);
-          $page_code = $array[0];
-          $page_id =  $page['page_id'];
-          $sql  = 'UPDATE `'.$database->TablePrefix.'pages` SET ';
-          $sql .= ((empty($array[0])) ? '`page_code` = 0 ' : '`page_code` = '.$page_code.' ');
-          $sql .= 'WHERE `page_id` = '.$page_id;
-          $database->query($sql);
-      }
-      $field_set = $database->field_modify('page_code', 'pages', 'INT(11) NOT NULL AFTER `modified_by`');
-//      $sql = 'ALTER TABLE `'.$database->TablePrefix.'pages` MODIFY COLUMN `page_code` INT(11) NOT NULL';
-//      $database->query($sql);
-  }   
+	function mod_MultiLingual_upgrade($bDebug=false) {
+		global $OK ,$FAIL;
+		$database=WbDatabase::getInstance();
+		$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;
+// change table structure
+		$sTable = $database->TablePrefix.'pages';
+    	$sFieldName = 'page_code';
+    	$sDescription = "INT NOT NULL DEFAULT '0' AFTER `language`";
+		if(!$database->field_add($sTable,$sFieldName,$sDescription)) {
+			$msg[] = ''.$database->get_error();
+		} else {
+			$msg[] = 'Field ( `page_code` ) description has been add successfully'." $OK";
+		}
+// Work-out if we should check old format for existing page_code
+        $sql = 'DESCRIBE `'.$database->TablePrefix.'pages` `page_code`';
+        $field_sql = $database->query($sql);
+//        $field_set = $field_sql->numRows();
+        $format = $field_sql->fetchRow(MYSQL_ASSOC) ;
+        // upgrade only if old format
+        if($format['Type'] == 'varchar(255)' )
+        {
+            $sql = 'SELECT `page_code`,`page_id` FROM `'.$database->TablePrefix.'pages` ORDER BY `page_id`';
+            if($query_code = $database->query($sql))
+            {
+                // extract page_id from old format
+                $pattern = '/(?<=_)([0-9]{1,11})/s';
+                while( $page  = $query_code->fetchRow(MYSQL_ASSOC))
+                {
+                    preg_match($pattern, $page['page_code'], $array);
+                    $page_code = $array[0];
+                    $page_id =  $page['page_id'];
+                    $sql  = 'UPDATE `'.$database->TablePrefix.'pages` SET ';
+                    $sql .= ((empty($array[0])) ? '`page_code` = 0 ' : '`page_code` = '.$page_code.' ');
+                    $sql .= 'WHERE `page_id` = '.$page_id;
+                    $database->query($sql);
+                }
+                $field_set = $database->field_modify($sTable,$sFieldName,$sDescription);
+                $msg[] = 'Field ( `page_code` ) description has been changed successfully'." $OK";
+// only for upgrade-script
+    			if($globalStarted) {
+    				if($bDebug) {
+    					echo '<strong>'.implode('<br />',$msg).'</strong><br />';
+    				}
+    			}
+            }  else {
+                $msg[] = ''.$database->get_error();
+            }  
+        }
+        //
+		$msg[] = 'MultiLingual upgrade successfull finished ';
+		if($globalStarted) {
+			echo "<strong>MultiLingual upgrade successfull finished $OK</strong><br />";
+		}
+		return ( ($globalStarted==true ) ? $globalStarted : $msg);
+
+	}
+// ------------------------------------
+//$directory = dirname(__FILE__).'/'.'info.php';
+//// update entry in table addons to new version
+//load_module($directory, $install = false);
+
+$bDebugModus = ((isset($bDebugModus)) ? $bDebugModus : false);
+// Don't show the messages twice
+if( is_array($msg = mod_MultiLingual_upgrade($bDebugModus))) {
+	echo '<strong>'.implode('<br />',$msg).'</strong><br />';
 }
-//
-$directory = dirname(__FILE__).'/'.'info.php';
-// update entry in table addons to new version
-load_module($directory, $install = false);
+
+// ------------------------------------
