Index: branches/2.8.x/CHANGELOG
===================================================================
--- branches/2.8.x/CHANGELOG	(revision 1949)
+++ branches/2.8.x/CHANGELOG	(revision 1950)
@@ -11,6 +11,8 @@
 ! = Update/Change
 ===============================================================================
 
+09 Aug-2013 Build 1950 M.v.d.Decken(DarkViper)
+! class AccessFile implemented in modules/news
 09 Aug-2013 Build 1949 M.v.d.Decken(DarkViper)
 ! some corrections in class AccessFile
 04 Aug-2013 Build 1948 M.v.d.Decken(DarkViper)
Index: branches/2.8.x/wb/admin/interface/version.php
===================================================================
--- branches/2.8.x/wb/admin/interface/version.php	(revision 1949)
+++ branches/2.8.x/wb/admin/interface/version.php	(revision 1950)
@@ -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', '1949');
+if(!defined('REVISION')) define('REVISION', '1950');
 if(!defined('SP')) define('SP', '');
Index: branches/2.8.x/wb/modules/news/delete_post.php
===================================================================
--- branches/2.8.x/wb/modules/news/delete_post.php	(revision 1949)
+++ branches/2.8.x/wb/modules/news/delete_post.php	(revision 1950)
@@ -39,8 +39,13 @@
 }
 
 // Unlink post access file
-if(is_writable(WB_PATH.PAGES_DIRECTORY.$get_details['link'].PAGE_EXTENSION)) {
-	unlink(WB_PATH.PAGES_DIRECTORY.$get_details['link'].PAGE_EXTENSION);
+try {
+    $sFilename = WB_PATH.PAGES_DIRECTORY.$get_details['link'].PAGE_EXTENSION;
+    $oAF = new AccessFile($sFilename, $page_id);
+    $oAF->delete();
+    unset($oAF);
+}catch(AccessFileException $e) {
+    $admin->print_error($e,ADMIN_URL.'/pages/modify.php?page_id='.$page_id );
 }
 
 // Delete post
@@ -50,7 +55,7 @@
 // Clean up ordering
 require(WB_PATH.'/framework/class.order.php');
 $order = new order(TABLE_PREFIX.'mod_news_posts', 'position', 'post_id', 'section_id');
-$order->clean($section_id); 
+$order->clean($section_id);
 
 // Check if there is a db error, otherwise say successful
 if($database->is_error()) {
@@ -60,4 +65,4 @@
 }
 
 // Print admin footer
-$admin->print_footer();
+$admin->print_footer();
\ No newline at end of file
Index: branches/2.8.x/wb/modules/news/save_post.php
===================================================================
--- branches/2.8.x/wb/modules/news/save_post.php	(revision 1949)
+++ branches/2.8.x/wb/modules/news/save_post.php	(revision 1950)
@@ -14,34 +14,7 @@
  * @lastmodified    $Date$
  *
  */
-
-	function createNewsAccessFile($newLink, $oldLink, $page_id, $section_id, $post_id)
-	{
-		global $admin, $MESSAGE;
-		$sError = '';
-		$sPagesPath = WB_PATH.PAGES_DIRECTORY;
-		$sPostsPath = $sPagesPath.'/posts';
-		$sBackUrl = ADMIN_URL.'/pages/modify.php?page_id='.$page_id;
-	// delete old accessfile if link has changed
-		if(($newLink != $oldLink) && (is_writable($sPostsPath.$oldLink.PAGE_EXTENSION))) {
-			if(!unlink($sPostsPath.$oldLink.PAGE_EXTENSION)) {
-				$admin->print_error($MESSAGE['PAGES_CANNOT_DELETE_ACCESS_FILE'].' - '.$oldLink,$sBackUrl);
-			}
-		}
-	// all ok, now create new accessfile
-		$newFile = $sPagesPath.$newLink.PAGE_EXTENSION;
-		// $backSteps = preg_replace('/^'.preg_quote(WB_PATH).'/', '', $sPostsPath);
-				$aOptionalCommands = array(
-				         '$section_id   = '.$section_id,
-				         '$post_id      = '.$post_id ,
-				         '$post_section = '.$section_id
-				);
-		if(	($sError = create_access_file($newFile, $page_id, 0, $aOptionalCommands))!==true ) 
-		{
-			$admin->print_error($sError,$sBackUrl );
-		}
-	} // end of function createNewsAccessFile
-/* ************************************************************************** */
+                    error_reporting(E_ALL);
 	require('../../config.php');
 	require_once(WB_PATH."/include/jscalendar/jscalendar-functions.php");
 // Get post_id
@@ -65,8 +38,6 @@
 	}
 	$admin->print_header();
 
-//	$sMediaUrl = WB_URL.MEDIA_DIRECTORY;
-//	$searchfor = '@(<[^>]*=\s*")('.preg_quote($sMediaUrl).')([^">]*".*>)@siU';
 // Validate all fields
 	$title      = $admin->StripCodeFromText($admin->get_post('title'));
 	$commenting = $admin->StripCodeFromText($admin->get_post('commenting'));
@@ -81,24 +52,20 @@
 	} else {
 		$short      = $admin->get_post('short');
 		$long       = $admin->get_post('long');
-//		if(ini_get('magic_quotes_gpc')==true)
-//		{
-//			$short = $admin->strip_slashes($short);
-//			$long = $admin->strip_slashes($long);
-//		}
-//		$short = preg_replace($searchfor, '$1{SYSVAR:MEDIA_REL}$3', $short );
-//		$long = preg_replace($searchfor, '$1{SYSVAR:MEDIA_REL}$3', $long );
 		$short = $admin->ReplaceAbsoluteMediaUrl($short);
 		$long = $admin->ReplaceAbsoluteMediaUrl($long);
 	}
 
-// Get page link URL
-	$sql = 'SELECT `link` FROM `'.TABLE_PREFIX.'pages` WHERE `page_id`='.(int)$page_id;
-	$oldLink = $database->get_one($sql);
 // Include WB functions file
 	require(WB_PATH.'/framework/functions.php');
 // Work-out what the link should be
-	$newLink = '/posts/'.page_filename($title).PAGE_SPACER.$post_id;
+	$sNewFile = page_filename($title).PAGE_SPACER.$post_id;
+    $newLink = '/posts/'.$sNewFile;
+    $sPagesPath = WB_PATH.PAGES_DIRECTORY;
+    $sBackUrl = ADMIN_URL.'/pages/modify.php?page_id='.$page_id;
+    $sNewFilename = $sPagesPath.$newLink.PAGE_EXTENSION;
+    $sOldFilename = $sPagesPath.$old_link.PAGE_EXTENSION;
+
 // get publisedwhen and publisheduntil
 	$publishedwhen = jscalendar_to_timestamp($admin->get_post_escaped('publishdate'));
 	if($publishedwhen == '' || $publishedwhen < 1) { $publishedwhen=0; }
@@ -118,9 +85,37 @@
 	$sql .=     '`posted_when`='.time().', ';
 	$sql .=     '`posted_by`='.(int)$admin->get_user_id().' ';
 	$sql .= 'WHERE `post_id`='.(int)$post_id;
-	if( $database->query($sql) ) { 
+	if( $database->query($sql) ) {
 		// create new accessfile
-		createNewsAccessFile($newLink, $oldLink, $page_id, $section_id, $post_id);
+        $sDoWhat = (($newLink == $old_link) && (file_exists($sNewFilename))) ? "nothing" : "action";
+        if($sDoWhat == "action") {
+            $sDoWhat = (($sDoWhat == "action") && file_exists($sOldFilename)) ? "update" : "create";
+        }
+
+        switch($sDoWhat)
+        {
+            case "update":
+                try {
+                    $oAF = new AccessFile($sOldFilename, $page_id);
+                    $oAF->rename($sNewFile);
+                    unset($oAF);
+                }catch(AccessFileException $e) {
+                    $admin->print_error($e,$sBackUrl);
+                }
+            break;
+            case "create":
+                try {
+                    $oAF = new AccessFile($sNewFilename, $page_id);
+                    $oAF->addVar('section_id', $section_id, AccessFile::VAR_INT);
+                    $oAF->addVar('post_id', $post_id, AccessFile::VAR_INT);
+                    $oAF->addVar('post_section', $section_id, AccessFile::VAR_INT);
+                    $oAF->write();
+                    unset($oAF);
+                }catch(AccessFileException $e) {
+                    $admin->print_error($e,$sBackUrl);
+                }
+            break;
+        }
 	}
 // Check if there is a db error, otherwise say successful
 	if($database->is_error()) {
@@ -131,4 +126,4 @@
 		$admin->print_success($TEXT['SUCCESS'], ADMIN_URL.'/pages/modify.php?page_id='.$page_id);
 	}
 // Print admin footer
-	$admin->print_footer();
+	$admin->print_footer();
\ No newline at end of file
