Index: branches/2.8.x/CHANGELOG
===================================================================
--- branches/2.8.x/CHANGELOG	(revision 2002)
+++ branches/2.8.x/CHANGELOG	(revision 2003)
@@ -11,6 +11,10 @@
 ! = Update/Change
 ===============================================================================
 
+14 Nov-2013 Build 2003 Dietmar Woellbrink (Luisehahne)
+! /modules/news/upgrade.php optimize add and modify field tables, rebuild message
+! /modules/news/modify_post.php and modify_post.php check posts folder if not exists then create
+! /upgrade-script.php  add ModuleReorgAbstract calling the Reorg Accessfiles from modules
 14 Nov-2013 Build 2002 Dietmar Woellbrink (Luisehahne)
 # include/editarea/edit_area_full.js fixed browser useragent query (Tks to Marmot)
   include/editarea/SOURCE add editarea sourcecode 
Index: branches/2.8.x/wb/upgrade-script.php
===================================================================
--- branches/2.8.x/wb/upgrade-script.php	(revision 2002)
+++ branches/2.8.x/wb/upgrade-script.php	(revision 2003)
@@ -1094,7 +1094,7 @@
 				$sModulVersion =  get_modul_version ($sModul, true);
 				echo '<div style="margin-left:2em;">';
 				echo '<h4>'.'Create/Reorg Accessfiles for module \''.$sModul.'\' version '.$sModulVersion.'</h4>';
-				$oReorg = new $sModulReorg($sModulReorg::LOG_EXTENDED);
+				$oReorg = new $sModulReorg(ModuleReorgAbstract::LOG_EXTENDED);
 				$aReturnMsg = $oReorg->execute(); // show details
                 $aReport = $oReorg->getReport();
                 unset($oReorg);
Index: branches/2.8.x/wb/admin/interface/version.php
===================================================================
--- branches/2.8.x/wb/admin/interface/version.php	(revision 2002)
+++ branches/2.8.x/wb/admin/interface/version.php	(revision 2003)
@@ -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', '2002');
+if(!defined('REVISION')) define('REVISION', '2003');
 if(!defined('SP')) define('SP', '');
Index: branches/2.8.x/wb/modules/news/add_post.php
===================================================================
--- branches/2.8.x/wb/modules/news/add_post.php	(revision 2002)
+++ branches/2.8.x/wb/modules/news/add_post.php	(revision 2003)
@@ -15,41 +15,54 @@
  *
  */
 
-require('../../config.php');
+$config_file = realpath('../../config.php');
+if(file_exists($config_file) && !defined('WB_URL'))
+{
+	require($config_file);
+}
 
-// Include WB admin wrapper script
+// show the info banner
+$print_info_banner = true;
+// Include WB admin wrapper script to fetch page_id and section_id for backlink
 require(WB_PATH.'/modules/admin.php');
 
-// Include the ordering class
-require(WB_PATH.'/framework/class.order.php');
-// Get new order
-$order = new order(TABLE_PREFIX.'mod_news_posts', 'position', 'post_id', 'section_id');
-$position = $order->get_new($section_id);
-$post_id = 0;
+// Make news post access files dir
+if(!function_exists('make_dir')) {require(WB_PATH.'/framework/functions.php');}
 
-try {
-// Get default commenting
-	$sql = 'SELECT `commenting` FROM `'.TABLE_PREFIX.'mod_news_settings` '
-	     . 'WHERE `section_id`='.(int)$section_id;
-	$query_settings = $database->query($sql);
-	$fetch_settings = $query_settings->fetchRow(MYSQL_ASSOC);
-	$commenting = $fetch_settings['commenting'];
-// Insert new row into database
-	$sql = 'INSERT INTO `'.TABLE_PREFIX.'mod_news_posts` '
-	     . 'SET `section_id`='.$section_id.', '
-	     .     '`page_id`='.$page_id.', '
-	     .     '`position`='.$position.', '
-	     .     '`commenting`=\''.$commenting.'\', '
-	     .     '`created_when`='.time().', '
-	     .     '`created_by`='.(int)$admin->get_user_id().', '
-	     .     '`posted_when`='.time().', '
-	     .     '`posted_by`='.(int)$admin->get_user_id().', '
-	     .     '`active`=1';
-	$database->query($sql);
-	$post_id = $admin->getIDKEY($database->LastInsertId);
-} catch(WbDatabaseException $e) {
-	$sSectionIdPrefix = ( defined( 'SEC_ANCHOR' ) && ( SEC_ANCHOR != '' )  ? SEC_ANCHOR : 'Sec' );
-	$admin->print_error($database->get_error(), WB_URL.'/modules/news/modify_post.php?page_id='.$page_id.'#'.$sSectionIdPrefix.$section_id );
-}
-$admin->print_success($TEXT['SUCCESS'], WB_URL.'/modules/news/modify_post.php?page_id='.$page_id.'&section_id='.$section_id.'&post_id='.$post_id );
+if(!make_dir(WB_PATH.PAGES_DIRECTORY.'/posts')) {
+	$admin->print_error($MESSAGE['GENERIC_BAD_PERMISSIONS'], ADMIN_URL.'/pages/modify.php?page_id='.$page_id );
+} else {
+    // Include the ordering class
+    require(WB_PATH.'/framework/class.order.php');
+    // Get new order
+    $order = new order(TABLE_PREFIX.'mod_news_posts', 'position', 'post_id', 'section_id');
+    $position = $order->get_new($section_id);
+    $post_id = 0;
+    
+    try {
+    // Get default commenting
+    	$sql = 'SELECT `commenting` FROM `'.TABLE_PREFIX.'mod_news_settings` '
+    	     . 'WHERE `section_id`='.(int)$section_id;
+    	$query_settings = $database->query($sql);
+    	$fetch_settings = $query_settings->fetchRow(MYSQL_ASSOC);
+    	$commenting = $fetch_settings['commenting'];
+    // Insert new row into database
+    	$sql = 'INSERT INTO `'.TABLE_PREFIX.'mod_news_posts` '
+    	     . 'SET `section_id`='.$section_id.', '
+    	     .     '`page_id`='.$page_id.', '
+    	     .     '`position`='.$position.', '
+    	     .     '`commenting`=\''.$commenting.'\', '
+    	     .     '`created_when`='.time().', '
+    	     .     '`created_by`='.(int)$admin->get_user_id().', '
+    	     .     '`posted_when`='.time().', '
+    	     .     '`posted_by`='.(int)$admin->get_user_id().', '
+    	     .     '`active`=1';
+    	$database->query($sql);
+    	$post_id = $admin->getIDKEY($database->LastInsertId);
+    } catch(WbDatabaseException $e) {
+        $sSectionIdPrefix = ( defined( 'SEC_ANCHOR' ) && ( SEC_ANCHOR != '' )  ? SEC_ANCHOR : 'Sec' );
+    	$admin->print_error($database->get_error(), WB_URL.'/modules/news/modify_post.php?page_id='.$page_id.'#'.$sSectionIdPrefix.$section_id );
+    }
+        $admin->print_success($TEXT['SUCCESS'], WB_URL.'/modules/news/modify_post.php?page_id='.$page_id.'&section_id='.$section_id.'&post_id='.$post_id );
+    }
 $admin->print_footer();
Index: branches/2.8.x/wb/modules/news/upgrade.php
===================================================================
--- branches/2.8.x/wb/modules/news/upgrade.php	(revision 2002)
+++ branches/2.8.x/wb/modules/news/upgrade.php	(revision 2003)
@@ -49,179 +49,171 @@
 //{
 	function mod_news_Upgrade($bDebug=false)
 	{
+	// set environment
 		global $OK ,$FAIL;
-		$database=WbDatabase::getInstance();
-		$mLang = Translate::getinstance();
-		$sModName = basename(dirname(__FILE__));
-		$mLang->enableAddon('modules\\'.$sModName);
-		$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 for missing tables, if true stop the upgrade
-		$aTable = array('mod_news_posts','mod_news_groups','mod_news_comments','mod_news_settings');
-		$aPackage = UpgradeHelper::existsAllTables($aTable);
-		if( sizeof($aPackage) > 0){
-			$msg[] =  'TABLE '.implode(' missing! '.$FAIL.'<br />TABLE ',$aPackage).' missing! '.$FAIL;
-			$msg[] = "WYSIWYG upgrade failed $FAIL";
-			if($globalStarted) {
+		$aMandatoryTables = array('mod_news_posts','mod_news_groups','mod_news_comments','mod_news_settings');
+		$oDb              = WbDatabase::getInstance();
+		$oLang            = Translate::getinstance();
+		$oReg             = WbAdaptor::getInstance();
+		$msg              = array();
+		$sCallingScript   = $_SERVER['SCRIPT_NAME'];
+		$sPagesPath       = $oReg->AppPath.$oReg->PagesDir;
+		$sPostsPath       = $sPagesPath.'/posts';
+		$sModName         = basename(dirname(__FILE__));
+		$oLang->enableAddon('modules\\'.$sModName);
+	// check if upgrade startet by upgrade-script to echo a message
+		$bGlobalStarted = preg_match('/upgrade\-script\.php$/', $sCallingScript);
+/* --- check for missing tables, if true stop the upgrade ----------------------------- */
+		$aMissingTables = UpgradeHelper::getMissingTables($aMandatoryTables);
+		if( sizeof($aMissingTables) > 0){
+			$msg[] = 'TABLE '.implode(' missing! '.$FAIL.'<br />TABLE ', $aMissingTables).' missing! '.$FAIL;
+			$msg[] = 'WYSIWYG upgrade failed '.$FAIL;
+			if($bGlobalStarted) {
 				echo '<strong>'.implode('<br />',$msg).'</strong><br />';
 			}
-			$mLang->disableAddon();
-			return ( ($globalStarted==true ) ? $globalStarted : $msg);
-		} else {
-			/**
-			 * check database engine
-			 */
-			 for($x=0; $x<sizeof($aTable);$x++) {
-				if(($sOldType = $database->getTableEngine($database->TablePrefix.$aTable[$x]))) {
-					if(('myisam' != strtolower($sOldType))) {
-						if(!$database->query('ALTER TABLE `'.$database->TablePrefix.$aTable[$x].'` Engine = \'MyISAM\' ')) {
-							$msg[] = $database->get_error()." $FAIL";
-						} else{
-							$msg[] = 'TABLE `'.$database->TablePrefix.$aTable[$x].'` changed to Engine = \'MyISAM\''." $OK";
-						}
-					} else {
-						 $msg[] = 'TABLE `'.$database->TablePrefix.$aTable[$x].'` has Engine = \'MyISAM\''." $OK";
+			$oLang->disableAddon();
+			return ( ($bGlobalStarted==true ) ? $bGlobalStarted : $msg);
+		}
+/* --- check for database engine ------------------------------------------------------ */
+		for($x=0; $x<sizeof($aMandatoryTables);$x++) {
+			if(($sOldType = $oDb->getTableEngine($oDb->TablePrefix.$aMandatoryTables[$x]))) {
+				if(('myisam' != strtolower($sOldType))) {
+					if(!$oDb->query('ALTER TABLE `'.$oDb->TablePrefix.$aMandatoryTables[$x].'` Engine = \'MyISAM\' ')) {
+						$msg[] = $oDb->get_error()." $FAIL";
+					}else {
+						$msg[] = 'TABLE `'.$oDb->TablePrefix.$aMandatoryTables[$x].'` changed to Engine = \'MyISAM\''." $OK";
 					}
 				} else {
-					$msg[] = $database->get_error()." $FAIL";
+					 $msg[] = 'TABLE `'.$oDb->TablePrefix.$aMandatoryTables[$x].'` has Engine = \'MyISAM\''." $OK";
 				}
+			} else {
+				$msg[] = $oDb->get_error()." $FAIL";
 			}
-
-			$sPagesPath = WB_PATH.PAGES_DIRECTORY;
-			$sPostsPath = $sPagesPath.'/posts';
-// create /posts/ - directory if not exists
-			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);
+		}
+/* --- create posts/ - directory if not exists ---------------------------------------- */
+		if(!($bRetval = is_dir($sPostsPath))) 
+		{ 
+		// /posts - dir missing
+			if(is_writable($sPagesPath))
+			{
+			// try to create the directory
+				$iOldUmask = umask(0) ;
+				if(!($bRetval = mkdir($sPostsPath, $oReg->OctalDirMode, true)))
+				{
+					$msg[] = 'Not able to create directory "'.str_replace($oReg->AppPath, '', $sPostsPath).'". '.$FAIL;
 				}
-				if($bRetval) {
-					$msg[] = 'Directory "'.PAGES_DIRECTORY.'/posts/" already exists or created.'." $OK";
-				}else {
-					$msg[] = ($mLang->MESSAGE_PAGES_CANNOT_CREATE_ACCESS_FILE)." $FAIL";
-				}
-			}else {
-					$msg[] = ($mLang->MESSAGE_PAGES_CANNOT_CREATE_ACCESS_FILE)." $FAIL";
+				umask($iOldUmask);
+			}else
+			{
+				$msg[] = 'Directory "'.str_replace($oReg->AppPath, '', $sPostsPath).'" is not writeable.'." $FAIL";
+				$bRetval = false;
 			}
-	// check if new fields must be added
-			$doImportDate = true;
-			if(!$database->field_exists($database->TablePrefix.'mod_news_posts', 'created_when')) {
-				if(!$database->field_add($database->TablePrefix.'mod_news_posts', 'created_when',
-				                        'INT NOT NULL DEFAULT \'0\' AFTER `commenting`')) {
-					$msg[] = $mLang->MESSAGE_RECORD_MODIFIED_FAILED." $FAIL";
-				} else {
-					$msg[] = 'TABLE `'.$database->TablePrefix.'mod_news_posts` Datafield `created_when` added.'." $OK";
-				}
-			} else { 
-				$msg[] = 'TABLE `'.$database->TablePrefix.'mod_news_posts` Datafield `created_when` already exists.'." $OK";
-				$doImportDate = false; 
+			if(!$bRetval) { 
+				$oLang->disableAddon();
+				return ( ($bGlobalStarted==true ) ? $bGlobalStarted : $msg);
 			}
-
-			if(!$database->field_exists($database->TablePrefix.'mod_news_posts', 'created_by')) {
-				if(!$database->field_add($database->TablePrefix.'mod_news_posts', 'created_by',
-				                        'INT NOT NULL DEFAULT \'0\' AFTER `created_when`')) {
-					$msg[] = $mLang->MESSAGE_RECORD_MODIFIED_FAILED." $FAIL";
-				} else {
-					$msg[] = 'TABLE `'.$database->TablePrefix.'mod_news_posts` Datafield `created_by` added.'." $OK";
-				}
-			} else { 
-				$msg[] = 'TABLE `'.$database->TablePrefix.'mod_news_posts` Datafield `created_by` already exists.'." $OK";
-				$doImportDate = false; 
+		}
+		$msg[] = 'Directory "'.str_replace($oReg->AppPath, '', $sPostsPath).'" exists.'." $OK";
+/* --- create new db fields if `created_when` and `created_by` is missing ------------- */
+		$doImportDate = 0;
+		$aMsgList = array(
+			0 => 'Datafield `'.$oDb->TablePrefix.'mod_news_posts`.`created_when` exists. '.$OK,
+			1 => 'Datafield `'.$oDb->TablePrefix.'mod_news_posts`.`created_by` exists. '.$OK,
+			2 => 'missing Datafield `'.$oDb->TablePrefix.'mod_news_posts`.`created_when`. '.$FAIL,
+			3 => 'missing Datafield `'.$oDb->TablePrefix.'mod_news_posts`.`created_by`. '.$FAIL,
+			4 => 'Datafield `'.$oDb->TablePrefix.'mod_news_posts`.`created_when` created. '.$OK,
+			5 => 'Datafield `'.$oDb->TablePrefix.'mod_news_posts`.`created_by` created. '.$OK,
+		);
+		if($oDb->field_exists($oDb->TablePrefix.'mod_news_posts', 'created_when')) {
+			$doImportDate |= pow(2, 0);
+		}else {
+			if($oDb->field_add($oDb->TablePrefix.'mod_news_posts', 'created_when', 'INT NOT NULL DEFAULT \'0\' AFTER `commenting`')) {
+				$doImportDate |= (pow(2, 0) | pow(2, 4));
+			}else {
+				$doImportDate |= pow(2, 2);
 			}
-// preset new fields `created_by` and `created_by` from existing values
-			if($doImportDate) {
-				$sql  = 'UPDATE `'.$database->TablePrefix.'mod_news_posts` ';
-				$sql .= 'SET `created_by`=`posted_by`, `created_when`=`posted_when`';
-				$database->query($sql);
+		}
+		if($oDb->field_exists($oDb->TablePrefix.'mod_news_posts', 'created_by')) {
+			$doImportDate |= pow(2, 1);
+		}else {
+			if($oDb->field_add($oDb->TablePrefix.'mod_news_posts', 'created_by', 'INT NOT NULL DEFAULT \'0\' AFTER `created_when`')) {
+				$doImportDate |= (pow(2, 1) | pow(2, 5));
+			}else {
+				$doImportDate |= pow(2, 3);
 			}
-	if($doImportDate) {
-	/**
-	 * rebuild news post folder
-	 */
-//	$array = rebuildFolderProtectFile($sPostsPath);
-		// now iterate through all existing accessfiles,
-		// write its creation date into database
-			if(is_writable($sPostsPath)) {
-				$oDir = new DirectoryIterator($sPostsPath);
-				$count = 0;
-				foreach ($oDir as $fileinfo)
-				{
-					$fileName = $fileinfo->getFilename();
-					if((!$fileinfo->isDot()) &&
-					   ($fileName != 'index.php') &&
-					   (substr_compare($fileName,PAGE_EXTENSION,(0-strlen(PAGE_EXTENSION)),strlen(PAGE_EXTENSION)) === 0)
-					  )
-					{
-					// save creation date from old accessfile
-						if($doImportDate) {
-							$link = '/posts/'.preg_replace('/'.preg_quote(PAGE_EXTENSION).'$/i', '', $fileinfo->getFilename());
-							$sql  = 'UPDATE `'.$database->TablePrefix.'mod_news_posts` ';
-							$sql .= 'SET `created_when`='.$fileinfo->getMTime().' ';
-							$sql .= 'WHERE `link`=\''.$link.'\'';
-							if($database->query($sql)) {
-								// delete old access file
-								unlink($fileinfo->getPathname());
-								$count++;
-							}
-						}
-					}
+		}
+		// build messages
+		foreach($aMsgList as $iKey => $sMsgText) {
+			if($doImportDate & pow(2, $iKey)) { $msg[] = $sMsgText; }
+		}
+		// break if not all fields exists now
+		if(!($doImportDate & (pow(2, 0) | pow(2, 1)))) {
+			$oLang->disableAddon();
+			return ($bGlobalStarted ? $bGlobalStarted : $msg);
+		}
+/* --- import creation date from old style accessfiles -------------------------------- */
+		// preset new fields `created_by` and `created_by` from existing values
+		// if both fields are created new
+		if($doImportDate & (pow(2, 4) | pow(2, 5)))
+		{
+		// first copy values inside the table and exchange all \ by / in field `link`
+			$sql  = 'UPDATE `'.$oDb->TablePrefix.'mod_news_posts` '
+			      . 'SET `created_by`=`posted_by`, '
+			      .     '`created_when`=`posted_when` '
+			      .     '`link`= REPLACE(`link`, \'\\\', \'/\')';
+			$oDb->query($sql);
+		// read Timestamps from old styled accessfiles
+			$iCount = 0;
+			$aMatches = glob($sPostsPath.'*'.$oReg->PageExtension);
+			if(is_array($aMatches)) {
+				foreach($aMatches as $sFile) {
+					$sLink = str_replace($sPagesPath, '', str_replace('\\', '/', $sFile));
+					$sLink = '/'.preg_replace('/'.preg_quote($oReg->PageExtension).'$/i', '', $sLink);
+					$sql = 'UPDATE `'.$oDb->TablePrefix.'mod_news_posts` '
+					     . 'SET `created_when`='.filemtime($sFile).' '
+					     . 'WHERE `link`=\''.$sLink.'\'';
+					if(($oDb->query('$sql'))) { $iCount++; }
 				}
-				unset($oDir);
 			}
-			if($count > 0) {
-				$msg[] = 'Save date of creation from '.$count.' old accessfiles and delete these files.'." $OK";
+			if($iCount) {
+				$msg[] = 'Creation date of &#62;'.$iCount.'&#60; posts has been imported from old styled accessfiles.'." $OK";
 			}
-	}
-// ************************************************
-// Check the validity of 'create-file-timestamp' and balance against 'posted-timestamp'
-			$sql = 'UPDATE `'.$database->TablePrefix.'mod_news_posts` '
+		// Check the validity of 'create-file-timestamp' and balance against 'posted-timestamp'
+			$sql = 'UPDATE `'.$oDb->TablePrefix.'mod_news_posts` '
 			     . 'SET `created_when`=`published_when` '
 			     . 'WHERE `published_when`<`created_when`';
-			$database->query($sql);
-			$sql = 'UPDATE `'.$database->TablePrefix.'mod_news_posts` '
+			$oDb->query($sql);
+			$sql = 'UPDATE `'.$oDb->TablePrefix.'mod_news_posts` '
 			     . 'SET `created_when`=`posted_when` '
 			     . 'WHERE `published_when`=0 OR `published_when`>`posted_when`';
-			$database->query($sql);
-// ************************************************
-// rebuild all access files
-			$aReport = array('FilesDeleted'=>0,'FilesCreated'=>0,);
-        	if( !$globalStarted && class_exists('m_news_Reorg') ) {
-        		$oReorg = new m_news_Reorg(ModuleReorgAbstract::LOG_EXTENDED);
-				$oReorg->execute(); // show details
-                $aReport = $oReorg->getReport();
-                unset($oReorg);
-        	}
-// ************************************************
-			// only for upgrade-script
-			if($globalStarted) {
-				if($bDebug) {
-					echo '<strong>'.implode('<br />',$msg).'</strong><br />';
-				}
-			} 
+			$oDb->query($sql);
 		}
-
-//		$msg[] = '<strong>'.$aReport['FilesDeleted'].' Files successful deleted</strong>';
+/* --- rebuild all access files ------------------------------------------------------- */
+		$aReport = array('FilesDeleted'=>0,'FilesCreated'=>0,);
+		$oReorg = new m_news_Reorg(ModuleReorgAbstract::LOG_EXTENDED);
+		$oReorg->execute(); // show details
+		$aReport = $oReorg->getReport();
+		unset($oReorg);
+/* --- for running from upgrade-script.php only --------------------------------------- */
+		if($bGlobalStarted && $bDebug) {
+			echo '<strong>'.implode('<br />',$msg).'</strong><br />';
+		}
+/* ------------------------------------------------------------------------------------ */
 		$msg[] = '<strong>Number of new formated access files: '.$aReport['FilesCreated'].'</strong>';
 		$msg[] = "<strong>News upgrade successfull finished</strong>";
-		if($globalStarted) {
+		if($bGlobalStarted) {
 			echo "<strong>News upgrade successfull finished $OK</strong><br />";
 		}
-		$mLang->disableAddon();
-		return ( ($globalStarted==true ) ? $globalStarted : $msg);
+		$oLang->disableAddon();
+		return ($bGlobalStarted ? $bGlobalStarted : $msg);
 	}
-//}
 // end mod_news_Upgrade
 
 // ------------------------------------
 // Don't show the messages twice
-$bDebugModus = ((isset($bDebugModus)) ? $bDebugModus : false);
-if( is_array($msg = mod_news_Upgrade($bDebugModus)) ) {
+	$bDebugModus = ((isset($bDebugModus)) ? $bDebugModus : false);
+	if( is_array($msg = mod_news_Upgrade($bDebugModus)) ) {
 // only show if manuell upgrade
-	echo ''.implode('<br />',$msg).'<br />';
-}
+		echo implode('<br />', $msg).'<br />';
+	}
 /* **** END UPGRADE ********************************************************* */
Index: branches/2.8.x/wb/modules/news/modify_post.php
===================================================================
--- branches/2.8.x/wb/modules/news/modify_post.php	(revision 2002)
+++ branches/2.8.x/wb/modules/news/modify_post.php	(revision 2003)
@@ -15,7 +15,11 @@
  *
  */
 
-require('../../config.php');
+$config_file = realpath('../../config.php');
+if(file_exists($config_file) && !defined('WB_URL'))
+{
+	require($config_file);
+}
 
 // $admin_header = true;
 // Tells script to update when this page was last updated
@@ -26,260 +30,269 @@
 require(WB_PATH.'/modules/admin.php');
 
 $backlink = ADMIN_URL.'/pages/modify.php?page_id='.(int)$page_id;
-$post_id = intval($admin->checkIDKEY('post_id', false, 'GET'));
-if (!$post_id) {
-	$admin->print_error($MESSAGE['GENERIC_SECURITY_ACCESS'], $backlink);
-}
-$aPostRec = array(
-'post_id' => 0,
-'section_id' => 0,
-'page_id' => 0,
-'group_id' => 0,
-'active' => 0,
-'position' => 0,
-'title' => '',
-'link' => '',
-'content_short' => '',
-'content_long' => '',
-'commenting' => '',
-'created_when' => 0,
-'created_by' => 0,
-'published_when' => 0,
-'published_until' => 0,
-'posted_when' => 0,
-'posted_by' => 0
-);
-$sMediaUrl = WB_URL.MEDIA_DIRECTORY;
-// Get header and footer
-$sql = 'SELECT * FROM `'.TABLE_PREFIX.'mod_news_posts` WHERE `post_id`='.(int)$post_id;
-if($oPostRes = $database->query($sql)){
-	$aPostRec = $oPostRes->fetchRow(MYSQL_ASSOC);
-	$aPostRec['content_short'] = str_replace('{SYSVAR:MEDIA_REL}', $sMediaUrl,$aPostRec['content_short']);
-	$aPostRec['content_long']  = str_replace('{SYSVAR:MEDIA_REL}', $sMediaUrl,$aPostRec['content_long']);
-}
-//$query_content = $database->query("SELECT * FROM ".TABLE_PREFIX."mod_news_posts WHERE post_id = '$post_id'");
 
-//print '<pre style="text-align:left;color:#000;padding:1em;"><strong>function '.__FUNCTION__.'( '.$post_id.' );</strong>  basename: '.basename(__FILE__).'  line: '.__LINE__.' -> <br />'; 
-//print_r( $fetch_content['content_short'] ); print '</pre>'; // flush ();sleep(10); die();
-if(!isset($wysiwyg_editor_loaded)) {
-    $wysiwyg_editor_loaded=true;
-	if (!defined('WYSIWYG_EDITOR') OR WYSIWYG_EDITOR=="none" OR !file_exists(WB_PATH.'/modules/'.WYSIWYG_EDITOR.'/include.php')) {
-		function show_wysiwyg_editor($name,$id,$content,$width,$height) {
-			echo '<textarea name="'.$name.'" id="'.$id.'" rows="10" cols="1" style="width: '.$width.'; height: '.$height.';">'.$content.'</textarea>';
-		}
-	} else {
-		$id_list=array("short","long");
-		require(WB_PATH.'/modules/'.WYSIWYG_EDITOR.'/include.php');
-	}
-}
+// Make news post access files dir
+if(!function_exists('make_dir')) {require(WB_PATH.'/framework/functions.php');}
 
-// include jscalendar-setup
-$jscal_use_time = true; // whether to use a clock, too
-require_once(WB_PATH."/include/jscalendar/wb-setup.php");
-?>
-<h2><?php echo $TEXT['ADD'].'/'.$TEXT['MODIFY'].' '.$TEXT['POST']; ?></h2>
-<div class="jsadmin jcalendar hide"></div> 
-<form name="modify" action="<?php echo WB_URL; ?>/modules/news/save_post.php" method="post" style="margin: 0;">
-
-<input type="hidden" name="section_id" value="<?php echo $section_id; ?>" />
-<input type="hidden" name="page_id" value="<?php echo $page_id; ?>" />
-<input type="hidden" name="post_id" value="<?php echo $post_id; ?>" />
-<input type="hidden" name="link" value="<?php echo $aPostRec['link']; ?>" />
-<?php echo $admin->getFTAN(); ?>
-
-<table class="row_a" cellpadding="2" cellspacing="0" width="100%">
-<tr>
-	<td><?php echo $TEXT['TITLE']; ?>:</td>
-	<td width="80%">
-		<input type="text" name="title" value="<?php echo (htmlspecialchars($aPostRec['title'])); ?>" style="width: 98%;" maxlength="255" />
-	</td>
-</tr>
-<tr>
-	<td><?php echo $TEXT['GROUP']; ?>:</td>
-	<td>
-		<select name="group" style="width: 100%;">
-			<option value="0"><?php echo $TEXT['NONE']; ?></option>
-			<?php
-			$query = $database->query("SELECT group_id,title FROM ".TABLE_PREFIX."mod_news_groups WHERE section_id = '$section_id' ORDER BY position ASC");
-			if($query->numRows() > 0) {
-				// Loop through groups
-				while($group = $query->fetchRow(MYSQL_ASSOC)) {
-					?>
-					<option value="<?php echo $group['group_id']; ?>"<?php if($aPostRec['group_id'] == $group['group_id']) { echo ' selected="selected"'; } ?>><?php echo $group['title']; ?></option>
-					<?php
-				}
-			}
-			?>
-		</select>
-	</td>
-</tr>
-<tr>
-	<td><?php echo $TEXT['COMMENTING']; ?>:</td>
-	<td>
-		<select name="commenting" style="width: 100%;">
-			<option value="none"><?php echo $TEXT['DISABLED']; ?></option>
-			<option value="public" <?php if($aPostRec['commenting'] == 'public') { echo ' selected="selected"'; } ?>><?php echo $TEXT['PUBLIC']; ?></option>
-			<option value="private" <?php if($aPostRec['commenting'] == 'private') { echo ' selected="selected"'; } ?>><?php echo $TEXT['PRIVATE']; ?></option>
-		</select>
-	</td>
-</tr>
-<tr>
-	<td><?php echo $TEXT['ACTIVE']; ?>:</td>
-	<td>
-		<input type="radio" name="active" id="active_true" value="1" <?php if($aPostRec['active'] == 1) { echo ' checked="checked"'; } ?> />
-		<a href="#" onclick="javascript: document.getElementById('active_true').checked = true;">
-		<?php echo $TEXT['YES']; ?>
-		</a>
-		&nbsp;
-		<input type="radio" name="active" id="active_false" value="0" <?php if($aPostRec['active'] == 0) { echo ' checked="checked"'; } ?> />
-		<a href="#" onclick="javascript: document.getElementById('active_false').checked = true;">
-		<?php echo $TEXT['NO']; ?>
-		</a>
-	</td>
-</tr>
-<tr>
-	<td><?php echo $TEXT['PUBL_START_DATE']; ?>:</td>
-	<td>
-	<input type="text" id="publishdate" name="publishdate" value="<?php if($aPostRec['published_when']==0) print date($jscal_format, strtotime((date('Y-m-d H:i')))); else print date($jscal_format, $aPostRec['published_when']);?>" style="width: 120px;" />
-	<img src="<?php echo THEME_URL ?>/images/clock_16.png" id="publishdate_trigger" style="cursor: pointer;" title="<?php echo $TEXT['CALENDAR']; ?>" alt="<?php echo $TEXT['CALENDAR']; ?>" onmouseover="this.style.background='lightgrey';" onmouseout="this.style.background=''" />
-	<img src="<?php echo THEME_URL ?>/images/clock_del_16.png" style="cursor: pointer;" title="<?php echo $TEXT['DELETE_DATE']; ?>" alt="<?php echo $TEXT['DELETE_DATE']; ?>" onmouseover="this.style.background='lightgrey';" onmouseout="this.style.background=''" onclick="document.modify.publishdate.value=''" />
-	</td>
-</tr>
-<tr>
-	<td><?php echo $TEXT['PUBL_END_DATE']; ?>:</td>
-	<td>
-	<input type="text" id="enddate" name="enddate" value="<?php if($aPostRec['published_until']==0) print ""; else print date($jscal_format, $aPostRec['published_until'])?>" style="width: 120px;" />
-	<img src="<?php echo THEME_URL ?>/images/clock_16.png" id="enddate_trigger" style="cursor: pointer;" title="<?php echo $TEXT['CALENDAR']; ?>" alt="<?php echo $TEXT['CALENDAR']; ?>" onmouseover="this.style.background='lightgrey';" onmouseout="this.style.background=''" />
-	<img src="<?php echo THEME_URL ?>/images/clock_del_16.png" style="cursor: pointer;" title="<?php echo $TEXT['DELETE_DATE']; ?>" alt="<?php echo $TEXT['DELETE_DATE']; ?>" onmouseover="this.style.background='lightgrey';" onmouseout="this.style.background=''" onclick="document.modify.enddate.value=''" />
-	</td>
-</tr>
-</table>
-
-<table class="row_a" cellpadding="2" cellspacing="0" border="0" width="100%">
-<tr>
-	<td valign="top"><?php echo $TEXT['SHORT']; ?>:</td>
-</tr>
-<tr>
-	<td>
-	<?php
-	show_wysiwyg_editor("short","short",htmlspecialchars($aPostRec['content_short']),"100%","200px");
-	?>
-	</td>
-</tr>
-<tr>
-	<td valign="top"><?php echo $TEXT['LONG']; ?>:</td>
-</tr>
-<tr>
-	<td>
-	<?php
-	show_wysiwyg_editor("long","long",htmlspecialchars($aPostRec['content_long']),"100%","650px");
-	?>
-	</td>
-</tr>
-</table>
-
-<table cellpadding="2" cellspacing="0" border="0" width="100%">
-<tr>
-	<td align="left">
-		<input name="save" type="submit" value="<?php echo $TEXT['SAVE']; ?>" style="width: 100px; margin-top: 5px;" />
-	</td>
-	<td align="right">
-		<input type="button" value="<?php echo $TEXT['CANCEL']; ?>" onclick="javascript: window.location = '<?php echo ADMIN_URL; ?>/pages/modify.php?page_id=<?php echo $page_id; ?>';" style="width: 100px; margin-top: 5px;" />
-	</td>
-</tr>
-</table>
-</form>
-
-<script type="text/javascript">
-	Calendar.setup(
-		{
-			inputField  : "publishdate",
-			ifFormat    : "<?php echo $jscal_ifformat ?>",
-			button      : "publishdate_trigger",
-			firstDay    : <?php echo $jscal_firstday ?>,
-			<?php if(isset($jscal_use_time) && $jscal_use_time==TRUE)
-            { ?>
-				showsTime   : "true",
-				timeFormat  : "24",
-			<?php
-            } ?>
-			date        : "<?php echo $jscal_today ?>",
-			range       : [1970, 2037],
-			step        : 1
-		}
-	);
-	Calendar.setup(
-		{
-			inputField  : "enddate",
-			ifFormat    : "<?php echo $jscal_ifformat ?>",
-			button      : "enddate_trigger",
-			firstDay    : <?php echo $jscal_firstday ?>,
-			<?php if(isset($jscal_use_time) && $jscal_use_time==TRUE)
-            { ?>
-				showsTime   : "true",
-				timeFormat  : "24",
-			<?php
-            } ?>
-			date        : "<?php echo $jscal_today ?>",
-			range       : [1970, 2037],
-			step        : 1
-		}
-	);
-</script>
-
-<br />
-
-<h2><?php echo $TEXT['MODIFY'].'/'.$TEXT['DELETE'].' '.$TEXT['COMMENT']; ?></h2>
-
-<?php
-
-// Loop through existing posts
-$query_comments = $database->query("SELECT * FROM `".TABLE_PREFIX."mod_news_comments` WHERE section_id = '$section_id' AND post_id = '$post_id' ORDER BY commented_when DESC");
-if($query_comments->numRows() > 0) {
-	$row = 'a';
-	$pid = $admin->getIDKEY($post_id);
-	?>
-	<table cellpadding="2" cellspacing="0" border="0" width="100%">
-	<?php
-	while($comment = $query_comments->fetchRow(MYSQL_ASSOC)) {
-		$cid = $admin->getIDKEY($comment['comment_id']);
-		?>
-		<tr class="row_<?php echo $row; ?>" >
-			<td width="20" style="padding-left: 5px;">
-				<a href="<?php echo WB_URL; ?>/modules/news/modify_comment.php?page_id=<?php echo $page_id; ?>&amp;section_id=<?php
-					echo $section_id; ?>&amp;comment_id=<?php echo $cid; ?>" title="<?php echo $TEXT['MODIFY']; ?>">
-					<img src="<?php echo THEME_URL; ?>/images/modify_16.png" border="0" alt="^" />
-				</a>
-			</td>	
-			<td>
-				<a href="<?php echo WB_URL; ?>/modules/news/modify_comment.php?page_id=<?php echo $page_id; ?>&amp;section_id=<?php
-					echo $section_id; ?>&amp;comment_id=<?php echo $cid; ?>">
-					<?php echo $comment['title']; ?>
-				</a>
-			</td>
-			<td width="20">
-				<a href="javascript: confirm_link('<?php echo $TEXT['ARE_YOU_SURE']; ?>', '<?php
-					echo WB_URL; ?>/modules/news/delete_comment.php?page_id=<?php echo $page_id; ?>&amp;section_id=<?php
-					echo $section_id; ?>&amp;post_id=<?php echo $pid; ?>&amp;comment_id=<?php echo $cid; ?>');" title="<?php
-					echo $TEXT['DELETE']; ?>">
-					<img src="<?php echo THEME_URL; ?>/images/delete_16.png" border="0" alt="X" />
-				</a>
-			</td>
-		</tr>
-		<?php
-		// Alternate row color
-		if($row == 'a') {
-			$row = 'b';
-		} else {
-			$row = 'a';
-		}
-	}
-	?>
-	</table>
-	<?php
+if(!make_dir(WB_PATH.PAGES_DIRECTORY.'/posts')) {
+	$admin->print_error($MESSAGE['GENERIC_BAD_PERMISSIONS'], ADMIN_URL.'/pages/modify.php?page_id='.$page_id );
 } else {
-	echo $TEXT['NONE_FOUND'];
+    
+    $post_id = intval($admin->checkIDKEY('post_id', false, 'GET'));
+    if (!$post_id) {
+    	$admin->print_error($MESSAGE['GENERIC_SECURITY_ACCESS'], $backlink);
+    }
+    $aPostRec = 
+        array(
+            'post_id'         => 0,
+            'section_id'      => 0,
+            'page_id'         => 0,
+            'group_id'        => 0,
+            'active'          => 0,
+            'position'        => 0,
+            'title'           => '',
+            'link'            => '',
+            'content_short'   => '',
+            'content_long'    => '',
+            'commenting'      => '',
+            'created_when'    => 0,
+            'created_by'      => 0,
+            'published_when'  => 0,
+            'published_until' => 0,
+            'posted_when'     => 0,
+            'posted_by'       => 0
+    );
+    $sMediaUrl = WB_URL.MEDIA_DIRECTORY;
+    // Get header and footer
+    $sql = 'SELECT * FROM `'.TABLE_PREFIX.'mod_news_posts` WHERE `post_id`='.(int)$post_id;
+    if($oPostRes = $database->query($sql)){
+    	$aPostRec = $oPostRes->fetchRow(MYSQL_ASSOC);
+    	$aPostRec['content_short'] = str_replace('{SYSVAR:MEDIA_REL}', $sMediaUrl,$aPostRec['content_short']);
+    	$aPostRec['content_long']  = str_replace('{SYSVAR:MEDIA_REL}', $sMediaUrl,$aPostRec['content_long']);
+    }
+    //$query_content = $database->query("SELECT * FROM ".TABLE_PREFIX."mod_news_posts WHERE post_id = '$post_id'");
+    
+    //print '<pre style="text-align:left;color:#000;padding:1em;"><strong>function '.__FUNCTION__.'( '.$post_id.' );</strong>  basename: '.basename(__FILE__).'  line: '.__LINE__.' -> <br />'; 
+    //print_r( $fetch_content['content_short'] ); print '</pre>'; // flush ();sleep(10); die();
+    if(!isset($wysiwyg_editor_loaded)) {
+        $wysiwyg_editor_loaded=true;
+    	if (!defined('WYSIWYG_EDITOR') OR WYSIWYG_EDITOR=="none" OR !file_exists(WB_PATH.'/modules/'.WYSIWYG_EDITOR.'/include.php')) {
+    		function show_wysiwyg_editor($name,$id,$content,$width,$height) {
+    			echo '<textarea name="'.$name.'" id="'.$id.'" rows="10" cols="1" style="width: '.$width.'; height: '.$height.';">'.$content.'</textarea>';
+    		}
+    	} else {
+    		$id_list=array("short","long");
+    		require(WB_PATH.'/modules/'.WYSIWYG_EDITOR.'/include.php');
+    	}
+    }
+    
+    // include jscalendar-setup
+    $jscal_use_time = true; // whether to use a clock, too
+    require_once(WB_PATH."/include/jscalendar/wb-setup.php");
+    ?>
+    <h2><?php echo $TEXT['ADD'].'/'.$TEXT['MODIFY'].' '.$TEXT['POST']; ?></h2>
+    <div class="jsadmin jcalendar hide"></div> 
+    <form name="modify" action="<?php echo WB_URL; ?>/modules/news/save_post.php" method="post" style="margin: 0;">
+    
+    <input type="hidden" name="section_id" value="<?php echo $section_id; ?>" />
+    <input type="hidden" name="page_id" value="<?php echo $page_id; ?>" />
+    <input type="hidden" name="post_id" value="<?php echo $post_id; ?>" />
+    <input type="hidden" name="link" value="<?php echo $aPostRec['link']; ?>" />
+    <?php echo $admin->getFTAN(); ?>
+    
+    <table class="row_a" cellpadding="2" cellspacing="0" width="100%">
+    <tr>
+    	<td><?php echo $TEXT['TITLE']; ?>:</td>
+    	<td width="80%">
+    		<input type="text" name="title" value="<?php echo (htmlspecialchars($aPostRec['title'])); ?>" style="width: 98%;" maxlength="255" />
+    	</td>
+    </tr>
+    <tr>
+    	<td><?php echo $TEXT['GROUP']; ?>:</td>
+    	<td>
+    		<select name="group" style="width: 100%;">
+    			<option value="0"><?php echo $TEXT['NONE']; ?></option>
+    			<?php
+    			$query = $database->query("SELECT group_id,title FROM ".TABLE_PREFIX."mod_news_groups WHERE section_id = '$section_id' ORDER BY position ASC");
+    			if($query->numRows() > 0) {
+    				// Loop through groups
+    				while($group = $query->fetchRow(MYSQL_ASSOC)) {
+    					?>
+    					<option value="<?php echo $group['group_id']; ?>"<?php if($aPostRec['group_id'] == $group['group_id']) { echo ' selected="selected"'; } ?>><?php echo $group['title']; ?></option>
+    					<?php
+    				}
+    			}
+    			?>
+    		</select>
+    	</td>
+    </tr>
+    <tr>
+    	<td><?php echo $TEXT['COMMENTING']; ?>:</td>
+    	<td>
+    		<select name="commenting" style="width: 100%;">
+    			<option value="none"><?php echo $TEXT['DISABLED']; ?></option>
+    			<option value="public" <?php if($aPostRec['commenting'] == 'public') { echo ' selected="selected"'; } ?>><?php echo $TEXT['PUBLIC']; ?></option>
+    			<option value="private" <?php if($aPostRec['commenting'] == 'private') { echo ' selected="selected"'; } ?>><?php echo $TEXT['PRIVATE']; ?></option>
+    		</select>
+    	</td>
+    </tr>
+    <tr>
+    	<td><?php echo $TEXT['ACTIVE']; ?>:</td>
+    	<td>
+    		<input type="radio" name="active" id="active_true" value="1" <?php if($aPostRec['active'] == 1) { echo ' checked="checked"'; } ?> />
+    		<a href="#" onclick="javascript: document.getElementById('active_true').checked = true;">
+    		<?php echo $TEXT['YES']; ?>
+    		</a>
+    		&nbsp;
+    		<input type="radio" name="active" id="active_false" value="0" <?php if($aPostRec['active'] == 0) { echo ' checked="checked"'; } ?> />
+    		<a href="#" onclick="javascript: document.getElementById('active_false').checked = true;">
+    		<?php echo $TEXT['NO']; ?>
+    		</a>
+    	</td>
+    </tr>
+    <tr>
+    	<td><?php echo $TEXT['PUBL_START_DATE']; ?>:</td>
+    	<td>
+    	<input type="text" id="publishdate" name="publishdate" value="<?php if($aPostRec['published_when']==0) print date($jscal_format, strtotime((date('Y-m-d H:i')))); else print date($jscal_format, $aPostRec['published_when']);?>" style="width: 120px;" />
+    	<img src="<?php echo THEME_URL ?>/images/clock_16.png" id="publishdate_trigger" style="cursor: pointer;" title="<?php echo $TEXT['CALENDAR']; ?>" alt="<?php echo $TEXT['CALENDAR']; ?>" onmouseover="this.style.background='lightgrey';" onmouseout="this.style.background=''" />
+    	<img src="<?php echo THEME_URL ?>/images/clock_del_16.png" style="cursor: pointer;" title="<?php echo $TEXT['DELETE_DATE']; ?>" alt="<?php echo $TEXT['DELETE_DATE']; ?>" onmouseover="this.style.background='lightgrey';" onmouseout="this.style.background=''" onclick="document.modify.publishdate.value=''" />
+    	</td>
+    </tr>
+    <tr>
+    	<td><?php echo $TEXT['PUBL_END_DATE']; ?>:</td>
+    	<td>
+    	<input type="text" id="enddate" name="enddate" value="<?php if($aPostRec['published_until']==0) print ""; else print date($jscal_format, $aPostRec['published_until'])?>" style="width: 120px;" />
+    	<img src="<?php echo THEME_URL ?>/images/clock_16.png" id="enddate_trigger" style="cursor: pointer;" title="<?php echo $TEXT['CALENDAR']; ?>" alt="<?php echo $TEXT['CALENDAR']; ?>" onmouseover="this.style.background='lightgrey';" onmouseout="this.style.background=''" />
+    	<img src="<?php echo THEME_URL ?>/images/clock_del_16.png" style="cursor: pointer;" title="<?php echo $TEXT['DELETE_DATE']; ?>" alt="<?php echo $TEXT['DELETE_DATE']; ?>" onmouseover="this.style.background='lightgrey';" onmouseout="this.style.background=''" onclick="document.modify.enddate.value=''" />
+    	</td>
+    </tr>
+    </table>
+    
+    <table class="row_a" cellpadding="2" cellspacing="0" border="0" width="100%">
+    <tr>
+    	<td valign="top"><?php echo $TEXT['SHORT']; ?>:</td>
+    </tr>
+    <tr>
+    	<td>
+    	<?php
+    	show_wysiwyg_editor("short","short",htmlspecialchars($aPostRec['content_short']),"100%","200px");
+    	?>
+    	</td>
+    </tr>
+    <tr>
+    	<td valign="top"><?php echo $TEXT['LONG']; ?>:</td>
+    </tr>
+    <tr>
+    	<td>
+    	<?php
+    	show_wysiwyg_editor("long","long",htmlspecialchars($aPostRec['content_long']),"100%","650px");
+    	?>
+    	</td>
+    </tr>
+    </table>
+    
+    <table cellpadding="2" cellspacing="0" border="0" width="100%">
+    <tr>
+    	<td align="left">
+    		<input name="save" type="submit" value="<?php echo $TEXT['SAVE']; ?>" style="width: 100px; margin-top: 5px;" />
+    	</td>
+    	<td align="right">
+    		<input type="button" value="<?php echo $TEXT['CANCEL']; ?>" onclick="javascript: window.location = '<?php echo ADMIN_URL; ?>/pages/modify.php?page_id=<?php echo $page_id; ?>';" style="width: 100px; margin-top: 5px;" />
+    	</td>
+    </tr>
+    </table>
+    </form>
+    
+    <script type="text/javascript">
+    	Calendar.setup(
+    		{
+    			inputField  : "publishdate",
+    			ifFormat    : "<?php echo $jscal_ifformat ?>",
+    			button      : "publishdate_trigger",
+    			firstDay    : <?php echo $jscal_firstday ?>,
+    			<?php if(isset($jscal_use_time) && $jscal_use_time==TRUE)
+                { ?>
+    				showsTime   : "true",
+    				timeFormat  : "24",
+    			<?php
+                } ?>
+    			date        : "<?php echo $jscal_today ?>",
+    			range       : [1970, 2037],
+    			step        : 1
+    		}
+    	);
+    	Calendar.setup(
+    		{
+    			inputField  : "enddate",
+    			ifFormat    : "<?php echo $jscal_ifformat ?>",
+    			button      : "enddate_trigger",
+    			firstDay    : <?php echo $jscal_firstday ?>,
+    			<?php if(isset($jscal_use_time) && $jscal_use_time==TRUE)
+                { ?>
+    				showsTime   : "true",
+    				timeFormat  : "24",
+    			<?php
+                } ?>
+    			date        : "<?php echo $jscal_today ?>",
+    			range       : [1970, 2037],
+    			step        : 1
+    		}
+    	);
+    </script>
+    
+    <br />
+    
+    <h2><?php echo $TEXT['MODIFY'].'/'.$TEXT['DELETE'].' '.$TEXT['COMMENT']; ?></h2>
+    
+    <?php
+    
+    // Loop through existing posts
+    $query_comments = $database->query("SELECT * FROM `".TABLE_PREFIX."mod_news_comments` WHERE section_id = '$section_id' AND post_id = '$post_id' ORDER BY commented_when DESC");
+    if($query_comments->numRows() > 0) {
+    	$row = 'a';
+    	$pid = $admin->getIDKEY($post_id);
+    	?>
+    	<table cellpadding="2" cellspacing="0" border="0" width="100%">
+    	<?php
+    	while($comment = $query_comments->fetchRow(MYSQL_ASSOC)) {
+    		$cid = $admin->getIDKEY($comment['comment_id']);
+    		?>
+    		<tr class="row_<?php echo $row; ?>" >
+    			<td width="20" style="padding-left: 5px;">
+    				<a href="<?php echo WB_URL; ?>/modules/news/modify_comment.php?page_id=<?php echo $page_id; ?>&amp;section_id=<?php
+    					echo $section_id; ?>&amp;comment_id=<?php echo $cid; ?>" title="<?php echo $TEXT['MODIFY']; ?>">
+    					<img src="<?php echo THEME_URL; ?>/images/modify_16.png" border="0" alt="^" />
+    				</a>
+    			</td>	
+    			<td>
+    				<a href="<?php echo WB_URL; ?>/modules/news/modify_comment.php?page_id=<?php echo $page_id; ?>&amp;section_id=<?php
+    					echo $section_id; ?>&amp;comment_id=<?php echo $cid; ?>">
+    					<?php echo $comment['title']; ?>
+    				</a>
+    			</td>
+    			<td width="20">
+    				<a href="javascript: confirm_link('<?php echo $TEXT['ARE_YOU_SURE']; ?>', '<?php
+    					echo WB_URL; ?>/modules/news/delete_comment.php?page_id=<?php echo $page_id; ?>&amp;section_id=<?php
+    					echo $section_id; ?>&amp;post_id=<?php echo $pid; ?>&amp;comment_id=<?php echo $cid; ?>');" title="<?php
+    					echo $TEXT['DELETE']; ?>">
+    					<img src="<?php echo THEME_URL; ?>/images/delete_16.png" border="0" alt="X" />
+    				</a>
+    			</td>
+    		</tr>
+    		<?php
+    		// Alternate row color
+    		if($row == 'a') {
+    			$row = 'b';
+    		} else {
+    			$row = 'a';
+    		}
+    	}
+    	?>
+    	</table>
+    	<?php
+    } else {
+    	echo $TEXT['NONE_FOUND'];
+    }
 }
-
 // Print admin footer
 $admin->print_footer();
