Project

General

Profile

« Previous | Next » 

Revision 2003

Added by Dietmar about 11 years ago

! /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

View differences:

branches/2.8.x/CHANGELOG
11 11
! = Update/Change
12 12
===============================================================================
13 13

  
14
14 Nov-2013 Build 2003 Dietmar Woellbrink (Luisehahne)
15
! /modules/news/upgrade.php optimize add and modify field tables, rebuild message
16
! /modules/news/modify_post.php and modify_post.php check posts folder if not exists then create
17
! /upgrade-script.php  add ModuleReorgAbstract calling the Reorg Accessfiles from modules
14 18
14 Nov-2013 Build 2002 Dietmar Woellbrink (Luisehahne)
15 19
# include/editarea/edit_area_full.js fixed browser useragent query (Tks to Marmot)
16 20
  include/editarea/SOURCE add editarea sourcecode 
branches/2.8.x/wb/upgrade-script.php
1094 1094
				$sModulVersion =  get_modul_version ($sModul, true);
1095 1095
				echo '<div style="margin-left:2em;">';
1096 1096
				echo '<h4>'.'Create/Reorg Accessfiles for module \''.$sModul.'\' version '.$sModulVersion.'</h4>';
1097
				$oReorg = new $sModulReorg($sModulReorg::LOG_EXTENDED);
1097
				$oReorg = new $sModulReorg(ModuleReorgAbstract::LOG_EXTENDED);
1098 1098
				$aReturnMsg = $oReorg->execute(); // show details
1099 1099
                $aReport = $oReorg->getReport();
1100 1100
                unset($oReorg);
branches/2.8.x/wb/admin/interface/version.php
51 51

  
52 52
// check if defined to avoid errors during installation (redirect to admin panel fails if PHP error/warnings are enabled)
53 53
if(!defined('VERSION')) define('VERSION', '2.8.3');
54
if(!defined('REVISION')) define('REVISION', '2002');
54
if(!defined('REVISION')) define('REVISION', '2003');
55 55
if(!defined('SP')) define('SP', '');
branches/2.8.x/wb/modules/news/add_post.php
15 15
 *
16 16
 */
17 17

  
18
require('../../config.php');
18
$config_file = realpath('../../config.php');
19
if(file_exists($config_file) && !defined('WB_URL'))
20
{
21
	require($config_file);
22
}
19 23

  
20
// Include WB admin wrapper script
24
// show the info banner
25
$print_info_banner = true;
26
// Include WB admin wrapper script to fetch page_id and section_id for backlink
21 27
require(WB_PATH.'/modules/admin.php');
22 28

  
23
// Include the ordering class
24
require(WB_PATH.'/framework/class.order.php');
25
// Get new order
26
$order = new order(TABLE_PREFIX.'mod_news_posts', 'position', 'post_id', 'section_id');
27
$position = $order->get_new($section_id);
28
$post_id = 0;
29
// Make news post access files dir
30
if(!function_exists('make_dir')) {require(WB_PATH.'/framework/functions.php');}
29 31

  
30
try {
31
// Get default commenting
32
	$sql = 'SELECT `commenting` FROM `'.TABLE_PREFIX.'mod_news_settings` '
33
	     . 'WHERE `section_id`='.(int)$section_id;
34
	$query_settings = $database->query($sql);
35
	$fetch_settings = $query_settings->fetchRow(MYSQL_ASSOC);
36
	$commenting = $fetch_settings['commenting'];
37
// Insert new row into database
38
	$sql = 'INSERT INTO `'.TABLE_PREFIX.'mod_news_posts` '
39
	     . 'SET `section_id`='.$section_id.', '
40
	     .     '`page_id`='.$page_id.', '
41
	     .     '`position`='.$position.', '
42
	     .     '`commenting`=\''.$commenting.'\', '
43
	     .     '`created_when`='.time().', '
44
	     .     '`created_by`='.(int)$admin->get_user_id().', '
45
	     .     '`posted_when`='.time().', '
46
	     .     '`posted_by`='.(int)$admin->get_user_id().', '
47
	     .     '`active`=1';
48
	$database->query($sql);
49
	$post_id = $admin->getIDKEY($database->LastInsertId);
50
} catch(WbDatabaseException $e) {
51
	$sSectionIdPrefix = ( defined( 'SEC_ANCHOR' ) && ( SEC_ANCHOR != '' )  ? SEC_ANCHOR : 'Sec' );
52
	$admin->print_error($database->get_error(), WB_URL.'/modules/news/modify_post.php?page_id='.$page_id.'#'.$sSectionIdPrefix.$section_id );
53
}
54
$admin->print_success($TEXT['SUCCESS'], WB_URL.'/modules/news/modify_post.php?page_id='.$page_id.'&section_id='.$section_id.'&post_id='.$post_id );
32
if(!make_dir(WB_PATH.PAGES_DIRECTORY.'/posts')) {
33
	$admin->print_error($MESSAGE['GENERIC_BAD_PERMISSIONS'], ADMIN_URL.'/pages/modify.php?page_id='.$page_id );
34
} else {
35
    // Include the ordering class
36
    require(WB_PATH.'/framework/class.order.php');
37
    // Get new order
38
    $order = new order(TABLE_PREFIX.'mod_news_posts', 'position', 'post_id', 'section_id');
39
    $position = $order->get_new($section_id);
40
    $post_id = 0;
41
    
42
    try {
43
    // Get default commenting
44
    	$sql = 'SELECT `commenting` FROM `'.TABLE_PREFIX.'mod_news_settings` '
45
    	     . 'WHERE `section_id`='.(int)$section_id;
46
    	$query_settings = $database->query($sql);
47
    	$fetch_settings = $query_settings->fetchRow(MYSQL_ASSOC);
48
    	$commenting = $fetch_settings['commenting'];
49
    // Insert new row into database
50
    	$sql = 'INSERT INTO `'.TABLE_PREFIX.'mod_news_posts` '
51
    	     . 'SET `section_id`='.$section_id.', '
52
    	     .     '`page_id`='.$page_id.', '
53
    	     .     '`position`='.$position.', '
54
    	     .     '`commenting`=\''.$commenting.'\', '
55
    	     .     '`created_when`='.time().', '
56
    	     .     '`created_by`='.(int)$admin->get_user_id().', '
57
    	     .     '`posted_when`='.time().', '
58
    	     .     '`posted_by`='.(int)$admin->get_user_id().', '
59
    	     .     '`active`=1';
60
    	$database->query($sql);
61
    	$post_id = $admin->getIDKEY($database->LastInsertId);
62
    } catch(WbDatabaseException $e) {
63
        $sSectionIdPrefix = ( defined( 'SEC_ANCHOR' ) && ( SEC_ANCHOR != '' )  ? SEC_ANCHOR : 'Sec' );
64
    	$admin->print_error($database->get_error(), WB_URL.'/modules/news/modify_post.php?page_id='.$page_id.'#'.$sSectionIdPrefix.$section_id );
65
    }
66
        $admin->print_success($TEXT['SUCCESS'], WB_URL.'/modules/news/modify_post.php?page_id='.$page_id.'&section_id='.$section_id.'&post_id='.$post_id );
67
    }
55 68
$admin->print_footer();
branches/2.8.x/wb/modules/news/upgrade.php
49 49
//{
50 50
	function mod_news_Upgrade($bDebug=false)
51 51
	{
52
	// set environment
52 53
		global $OK ,$FAIL;
53
		$database=WbDatabase::getInstance();
54
		$mLang = Translate::getinstance();
55
		$sModName = basename(dirname(__FILE__));
56
		$mLang->enableAddon('modules\\'.$sModName);
57
		$msg    = array();
58
		$callingScript = $_SERVER["SCRIPT_NAME"];
59
// check if upgrade startet by upgrade-script to echo a message
60
		$tmp = 'upgrade-script.php';
61
		$globalStarted = substr_compare($callingScript, $tmp,(0-strlen($tmp)),strlen($tmp)) === 0;
62
// check for missing tables, if true stop the upgrade
63
		$aTable = array('mod_news_posts','mod_news_groups','mod_news_comments','mod_news_settings');
64
		$aPackage = UpgradeHelper::existsAllTables($aTable);
65
		if( sizeof($aPackage) > 0){
66
			$msg[] =  'TABLE '.implode(' missing! '.$FAIL.'<br />TABLE ',$aPackage).' missing! '.$FAIL;
67
			$msg[] = "WYSIWYG upgrade failed $FAIL";
68
			if($globalStarted) {
54
		$aMandatoryTables = array('mod_news_posts','mod_news_groups','mod_news_comments','mod_news_settings');
55
		$oDb              = WbDatabase::getInstance();
56
		$oLang            = Translate::getinstance();
57
		$oReg             = WbAdaptor::getInstance();
58
		$msg              = array();
59
		$sCallingScript   = $_SERVER['SCRIPT_NAME'];
60
		$sPagesPath       = $oReg->AppPath.$oReg->PagesDir;
61
		$sPostsPath       = $sPagesPath.'/posts';
62
		$sModName         = basename(dirname(__FILE__));
63
		$oLang->enableAddon('modules\\'.$sModName);
64
	// check if upgrade startet by upgrade-script to echo a message
65
		$bGlobalStarted = preg_match('/upgrade\-script\.php$/', $sCallingScript);
66
/* --- check for missing tables, if true stop the upgrade ----------------------------- */
67
		$aMissingTables = UpgradeHelper::getMissingTables($aMandatoryTables);
68
		if( sizeof($aMissingTables) > 0){
69
			$msg[] = 'TABLE '.implode(' missing! '.$FAIL.'<br />TABLE ', $aMissingTables).' missing! '.$FAIL;
70
			$msg[] = 'WYSIWYG upgrade failed '.$FAIL;
71
			if($bGlobalStarted) {
69 72
				echo '<strong>'.implode('<br />',$msg).'</strong><br />';
70 73
			}
71
			$mLang->disableAddon();
72
			return ( ($globalStarted==true ) ? $globalStarted : $msg);
73
		} else {
74
			/**
75
			 * check database engine
76
			 */
77
			 for($x=0; $x<sizeof($aTable);$x++) {
78
				if(($sOldType = $database->getTableEngine($database->TablePrefix.$aTable[$x]))) {
79
					if(('myisam' != strtolower($sOldType))) {
80
						if(!$database->query('ALTER TABLE `'.$database->TablePrefix.$aTable[$x].'` Engine = \'MyISAM\' ')) {
81
							$msg[] = $database->get_error()." $FAIL";
82
						} else{
83
							$msg[] = 'TABLE `'.$database->TablePrefix.$aTable[$x].'` changed to Engine = \'MyISAM\''." $OK";
84
						}
85
					} else {
86
						 $msg[] = 'TABLE `'.$database->TablePrefix.$aTable[$x].'` has Engine = \'MyISAM\''." $OK";
74
			$oLang->disableAddon();
75
			return ( ($bGlobalStarted==true ) ? $bGlobalStarted : $msg);
76
		}
77
/* --- check for database engine ------------------------------------------------------ */
78
		for($x=0; $x<sizeof($aMandatoryTables);$x++) {
79
			if(($sOldType = $oDb->getTableEngine($oDb->TablePrefix.$aMandatoryTables[$x]))) {
80
				if(('myisam' != strtolower($sOldType))) {
81
					if(!$oDb->query('ALTER TABLE `'.$oDb->TablePrefix.$aMandatoryTables[$x].'` Engine = \'MyISAM\' ')) {
82
						$msg[] = $oDb->get_error()." $FAIL";
83
					}else {
84
						$msg[] = 'TABLE `'.$oDb->TablePrefix.$aMandatoryTables[$x].'` changed to Engine = \'MyISAM\''." $OK";
87 85
					}
88 86
				} else {
89
					$msg[] = $database->get_error()." $FAIL";
87
					 $msg[] = 'TABLE `'.$oDb->TablePrefix.$aMandatoryTables[$x].'` has Engine = \'MyISAM\''." $OK";
90 88
				}
89
			} else {
90
				$msg[] = $oDb->get_error()." $FAIL";
91 91
			}
92

  
93
			$sPagesPath = WB_PATH.PAGES_DIRECTORY;
94
			$sPostsPath = $sPagesPath.'/posts';
95
// create /posts/ - directory if not exists
96
			if(is_writable($sPagesPath)) {
97
				if(!($bRetval = is_dir($sPostsPath))) {
98
					$iOldUmask = umask(0) ;
99
					// sanitize directory mode to 'o+rwx/g+x/u+x' and create path
100
					$bRetval = mkdir($sPostsPath, (OCTAL_DIR_MODE |0711), true); 
101
					umask($iOldUmask);
92
		}
93
/* --- create posts/ - directory if not exists ---------------------------------------- */
94
		if(!($bRetval = is_dir($sPostsPath))) 
95
		{ 
96
		// /posts - dir missing
97
			if(is_writable($sPagesPath))
98
			{
99
			// try to create the directory
100
				$iOldUmask = umask(0) ;
101
				if(!($bRetval = mkdir($sPostsPath, $oReg->OctalDirMode, true)))
102
				{
103
					$msg[] = 'Not able to create directory "'.str_replace($oReg->AppPath, '', $sPostsPath).'". '.$FAIL;
102 104
				}
103
				if($bRetval) {
104
					$msg[] = 'Directory "'.PAGES_DIRECTORY.'/posts/" already exists or created.'." $OK";
105
				}else {
106
					$msg[] = ($mLang->MESSAGE_PAGES_CANNOT_CREATE_ACCESS_FILE)." $FAIL";
107
				}
108
			}else {
109
					$msg[] = ($mLang->MESSAGE_PAGES_CANNOT_CREATE_ACCESS_FILE)." $FAIL";
105
				umask($iOldUmask);
106
			}else
107
			{
108
				$msg[] = 'Directory "'.str_replace($oReg->AppPath, '', $sPostsPath).'" is not writeable.'." $FAIL";
109
				$bRetval = false;
110 110
			}
111
	// check if new fields must be added
112
			$doImportDate = true;
113
			if(!$database->field_exists($database->TablePrefix.'mod_news_posts', 'created_when')) {
114
				if(!$database->field_add($database->TablePrefix.'mod_news_posts', 'created_when',
115
				                        'INT NOT NULL DEFAULT \'0\' AFTER `commenting`')) {
116
					$msg[] = $mLang->MESSAGE_RECORD_MODIFIED_FAILED." $FAIL";
117
				} else {
118
					$msg[] = 'TABLE `'.$database->TablePrefix.'mod_news_posts` Datafield `created_when` added.'." $OK";
119
				}
120
			} else { 
121
				$msg[] = 'TABLE `'.$database->TablePrefix.'mod_news_posts` Datafield `created_when` already exists.'." $OK";
122
				$doImportDate = false; 
111
			if(!$bRetval) { 
112
				$oLang->disableAddon();
113
				return ( ($bGlobalStarted==true ) ? $bGlobalStarted : $msg);
123 114
			}
124

  
125
			if(!$database->field_exists($database->TablePrefix.'mod_news_posts', 'created_by')) {
126
				if(!$database->field_add($database->TablePrefix.'mod_news_posts', 'created_by',
127
				                        'INT NOT NULL DEFAULT \'0\' AFTER `created_when`')) {
128
					$msg[] = $mLang->MESSAGE_RECORD_MODIFIED_FAILED." $FAIL";
129
				} else {
130
					$msg[] = 'TABLE `'.$database->TablePrefix.'mod_news_posts` Datafield `created_by` added.'." $OK";
131
				}
132
			} else { 
133
				$msg[] = 'TABLE `'.$database->TablePrefix.'mod_news_posts` Datafield `created_by` already exists.'." $OK";
134
				$doImportDate = false; 
115
		}
116
		$msg[] = 'Directory "'.str_replace($oReg->AppPath, '', $sPostsPath).'" exists.'." $OK";
117
/* --- create new db fields if `created_when` and `created_by` is missing ------------- */
118
		$doImportDate = 0;
119
		$aMsgList = array(
120
			0 => 'Datafield `'.$oDb->TablePrefix.'mod_news_posts`.`created_when` exists. '.$OK,
121
			1 => 'Datafield `'.$oDb->TablePrefix.'mod_news_posts`.`created_by` exists. '.$OK,
122
			2 => 'missing Datafield `'.$oDb->TablePrefix.'mod_news_posts`.`created_when`. '.$FAIL,
123
			3 => 'missing Datafield `'.$oDb->TablePrefix.'mod_news_posts`.`created_by`. '.$FAIL,
124
			4 => 'Datafield `'.$oDb->TablePrefix.'mod_news_posts`.`created_when` created. '.$OK,
125
			5 => 'Datafield `'.$oDb->TablePrefix.'mod_news_posts`.`created_by` created. '.$OK,
126
		);
127
		if($oDb->field_exists($oDb->TablePrefix.'mod_news_posts', 'created_when')) {
128
			$doImportDate |= pow(2, 0);
129
		}else {
130
			if($oDb->field_add($oDb->TablePrefix.'mod_news_posts', 'created_when', 'INT NOT NULL DEFAULT \'0\' AFTER `commenting`')) {
131
				$doImportDate |= (pow(2, 0) | pow(2, 4));
132
			}else {
133
				$doImportDate |= pow(2, 2);
135 134
			}
136
// preset new fields `created_by` and `created_by` from existing values
137
			if($doImportDate) {
138
				$sql  = 'UPDATE `'.$database->TablePrefix.'mod_news_posts` ';
139
				$sql .= 'SET `created_by`=`posted_by`, `created_when`=`posted_when`';
140
				$database->query($sql);
135
		}
136
		if($oDb->field_exists($oDb->TablePrefix.'mod_news_posts', 'created_by')) {
137
			$doImportDate |= pow(2, 1);
138
		}else {
139
			if($oDb->field_add($oDb->TablePrefix.'mod_news_posts', 'created_by', 'INT NOT NULL DEFAULT \'0\' AFTER `created_when`')) {
140
				$doImportDate |= (pow(2, 1) | pow(2, 5));
141
			}else {
142
				$doImportDate |= pow(2, 3);
141 143
			}
142
	if($doImportDate) {
143
	/**
144
	 * rebuild news post folder
145
	 */
146
//	$array = rebuildFolderProtectFile($sPostsPath);
147
		// now iterate through all existing accessfiles,
148
		// write its creation date into database
149
			if(is_writable($sPostsPath)) {
150
				$oDir = new DirectoryIterator($sPostsPath);
151
				$count = 0;
152
				foreach ($oDir as $fileinfo)
153
				{
154
					$fileName = $fileinfo->getFilename();
155
					if((!$fileinfo->isDot()) &&
156
					   ($fileName != 'index.php') &&
157
					   (substr_compare($fileName,PAGE_EXTENSION,(0-strlen(PAGE_EXTENSION)),strlen(PAGE_EXTENSION)) === 0)
158
					  )
159
					{
160
					// save creation date from old accessfile
161
						if($doImportDate) {
162
							$link = '/posts/'.preg_replace('/'.preg_quote(PAGE_EXTENSION).'$/i', '', $fileinfo->getFilename());
163
							$sql  = 'UPDATE `'.$database->TablePrefix.'mod_news_posts` ';
164
							$sql .= 'SET `created_when`='.$fileinfo->getMTime().' ';
165
							$sql .= 'WHERE `link`=\''.$link.'\'';
166
							if($database->query($sql)) {
167
								// delete old access file
168
								unlink($fileinfo->getPathname());
169
								$count++;
170
							}
171
						}
172
					}
144
		}
145
		// build messages
146
		foreach($aMsgList as $iKey => $sMsgText) {
147
			if($doImportDate & pow(2, $iKey)) { $msg[] = $sMsgText; }
148
		}
149
		// break if not all fields exists now
150
		if(!($doImportDate & (pow(2, 0) | pow(2, 1)))) {
151
			$oLang->disableAddon();
152
			return ($bGlobalStarted ? $bGlobalStarted : $msg);
153
		}
154
/* --- import creation date from old style accessfiles -------------------------------- */
155
		// preset new fields `created_by` and `created_by` from existing values
156
		// if both fields are created new
157
		if($doImportDate & (pow(2, 4) | pow(2, 5)))
158
		{
159
		// first copy values inside the table and exchange all \ by / in field `link`
160
			$sql  = 'UPDATE `'.$oDb->TablePrefix.'mod_news_posts` '
161
			      . 'SET `created_by`=`posted_by`, '
162
			      .     '`created_when`=`posted_when` '
163
			      .     '`link`= REPLACE(`link`, \'\\\', \'/\')';
164
			$oDb->query($sql);
165
		// read Timestamps from old styled accessfiles
166
			$iCount = 0;
167
			$aMatches = glob($sPostsPath.'*'.$oReg->PageExtension);
168
			if(is_array($aMatches)) {
169
				foreach($aMatches as $sFile) {
170
					$sLink = str_replace($sPagesPath, '', str_replace('\\', '/', $sFile));
171
					$sLink = '/'.preg_replace('/'.preg_quote($oReg->PageExtension).'$/i', '', $sLink);
172
					$sql = 'UPDATE `'.$oDb->TablePrefix.'mod_news_posts` '
173
					     . 'SET `created_when`='.filemtime($sFile).' '
174
					     . 'WHERE `link`=\''.$sLink.'\'';
175
					if(($oDb->query('$sql'))) { $iCount++; }
173 176
				}
174
				unset($oDir);
175 177
			}
176
			if($count > 0) {
177
				$msg[] = 'Save date of creation from '.$count.' old accessfiles and delete these files.'." $OK";
178
			if($iCount) {
179
				$msg[] = 'Creation date of &#62;'.$iCount.'&#60; posts has been imported from old styled accessfiles.'." $OK";
178 180
			}
179
	}
180
// ************************************************
181
// Check the validity of 'create-file-timestamp' and balance against 'posted-timestamp'
182
			$sql = 'UPDATE `'.$database->TablePrefix.'mod_news_posts` '
181
		// Check the validity of 'create-file-timestamp' and balance against 'posted-timestamp'
182
			$sql = 'UPDATE `'.$oDb->TablePrefix.'mod_news_posts` '
183 183
			     . 'SET `created_when`=`published_when` '
184 184
			     . 'WHERE `published_when`<`created_when`';
185
			$database->query($sql);
186
			$sql = 'UPDATE `'.$database->TablePrefix.'mod_news_posts` '
185
			$oDb->query($sql);
186
			$sql = 'UPDATE `'.$oDb->TablePrefix.'mod_news_posts` '
187 187
			     . 'SET `created_when`=`posted_when` '
188 188
			     . 'WHERE `published_when`=0 OR `published_when`>`posted_when`';
189
			$database->query($sql);
190
// ************************************************
191
// rebuild all access files
192
			$aReport = array('FilesDeleted'=>0,'FilesCreated'=>0,);
193
        	if( !$globalStarted && class_exists('m_news_Reorg') ) {
194
        		$oReorg = new m_news_Reorg(ModuleReorgAbstract::LOG_EXTENDED);
195
				$oReorg->execute(); // show details
196
                $aReport = $oReorg->getReport();
197
                unset($oReorg);
198
        	}
199
// ************************************************
200
			// only for upgrade-script
201
			if($globalStarted) {
202
				if($bDebug) {
203
					echo '<strong>'.implode('<br />',$msg).'</strong><br />';
204
				}
205
			} 
189
			$oDb->query($sql);
206 190
		}
207

  
208
//		$msg[] = '<strong>'.$aReport['FilesDeleted'].' Files successful deleted</strong>';
191
/* --- rebuild all access files ------------------------------------------------------- */
192
		$aReport = array('FilesDeleted'=>0,'FilesCreated'=>0,);
193
		$oReorg = new m_news_Reorg(ModuleReorgAbstract::LOG_EXTENDED);
194
		$oReorg->execute(); // show details
195
		$aReport = $oReorg->getReport();
196
		unset($oReorg);
197
/* --- for running from upgrade-script.php only --------------------------------------- */
198
		if($bGlobalStarted && $bDebug) {
199
			echo '<strong>'.implode('<br />',$msg).'</strong><br />';
200
		}
201
/* ------------------------------------------------------------------------------------ */
209 202
		$msg[] = '<strong>Number of new formated access files: '.$aReport['FilesCreated'].'</strong>';
210 203
		$msg[] = "<strong>News upgrade successfull finished</strong>";
211
		if($globalStarted) {
204
		if($bGlobalStarted) {
212 205
			echo "<strong>News upgrade successfull finished $OK</strong><br />";
213 206
		}
214
		$mLang->disableAddon();
215
		return ( ($globalStarted==true ) ? $globalStarted : $msg);
207
		$oLang->disableAddon();
208
		return ($bGlobalStarted ? $bGlobalStarted : $msg);
216 209
	}
217
//}
218 210
// end mod_news_Upgrade
219 211

  
220 212
// ------------------------------------
221 213
// Don't show the messages twice
222
$bDebugModus = ((isset($bDebugModus)) ? $bDebugModus : false);
223
if( is_array($msg = mod_news_Upgrade($bDebugModus)) ) {
214
	$bDebugModus = ((isset($bDebugModus)) ? $bDebugModus : false);
215
	if( is_array($msg = mod_news_Upgrade($bDebugModus)) ) {
224 216
// only show if manuell upgrade
225
	echo ''.implode('<br />',$msg).'<br />';
226
}
217
		echo implode('<br />', $msg).'<br />';
218
	}
227 219
/* **** END UPGRADE ********************************************************* */
branches/2.8.x/wb/modules/news/modify_post.php
15 15
 *
16 16
 */
17 17

  
18
require('../../config.php');
18
$config_file = realpath('../../config.php');
19
if(file_exists($config_file) && !defined('WB_URL'))
20
{
21
	require($config_file);
22
}
19 23

  
20 24
// $admin_header = true;
21 25
// Tells script to update when this page was last updated
......
26 30
require(WB_PATH.'/modules/admin.php');
27 31

  
28 32
$backlink = ADMIN_URL.'/pages/modify.php?page_id='.(int)$page_id;
29
$post_id = intval($admin->checkIDKEY('post_id', false, 'GET'));
30
if (!$post_id) {
31
	$admin->print_error($MESSAGE['GENERIC_SECURITY_ACCESS'], $backlink);
32
}
33
$aPostRec = array(
34
'post_id' => 0,
35
'section_id' => 0,
36
'page_id' => 0,
37
'group_id' => 0,
38
'active' => 0,
39
'position' => 0,
40
'title' => '',
41
'link' => '',
42
'content_short' => '',
43
'content_long' => '',
44
'commenting' => '',
45
'created_when' => 0,
46
'created_by' => 0,
47
'published_when' => 0,
48
'published_until' => 0,
49
'posted_when' => 0,
50
'posted_by' => 0
51
);
52
$sMediaUrl = WB_URL.MEDIA_DIRECTORY;
53
// Get header and footer
54
$sql = 'SELECT * FROM `'.TABLE_PREFIX.'mod_news_posts` WHERE `post_id`='.(int)$post_id;
55
if($oPostRes = $database->query($sql)){
56
	$aPostRec = $oPostRes->fetchRow(MYSQL_ASSOC);
57
	$aPostRec['content_short'] = str_replace('{SYSVAR:MEDIA_REL}', $sMediaUrl,$aPostRec['content_short']);
58
	$aPostRec['content_long']  = str_replace('{SYSVAR:MEDIA_REL}', $sMediaUrl,$aPostRec['content_long']);
59
}
60
//$query_content = $database->query("SELECT * FROM ".TABLE_PREFIX."mod_news_posts WHERE post_id = '$post_id'");
61 33

  
62
//print '<pre style="text-align:left;color:#000;padding:1em;"><strong>function '.__FUNCTION__.'( '.$post_id.' );</strong>  basename: '.basename(__FILE__).'  line: '.__LINE__.' -> <br />'; 
63
//print_r( $fetch_content['content_short'] ); print '</pre>'; // flush ();sleep(10); die();
64
if(!isset($wysiwyg_editor_loaded)) {
65
    $wysiwyg_editor_loaded=true;
66
	if (!defined('WYSIWYG_EDITOR') OR WYSIWYG_EDITOR=="none" OR !file_exists(WB_PATH.'/modules/'.WYSIWYG_EDITOR.'/include.php')) {
67
		function show_wysiwyg_editor($name,$id,$content,$width,$height) {
68
			echo '<textarea name="'.$name.'" id="'.$id.'" rows="10" cols="1" style="width: '.$width.'; height: '.$height.';">'.$content.'</textarea>';
69
		}
70
	} else {
71
		$id_list=array("short","long");
72
		require(WB_PATH.'/modules/'.WYSIWYG_EDITOR.'/include.php');
73
	}
74
}
34
// Make news post access files dir
35
if(!function_exists('make_dir')) {require(WB_PATH.'/framework/functions.php');}
75 36

  
76
// include jscalendar-setup
77
$jscal_use_time = true; // whether to use a clock, too
78
require_once(WB_PATH."/include/jscalendar/wb-setup.php");
79
?>
80
<h2><?php echo $TEXT['ADD'].'/'.$TEXT['MODIFY'].' '.$TEXT['POST']; ?></h2>
81
<div class="jsadmin jcalendar hide"></div> 
82
<form name="modify" action="<?php echo WB_URL; ?>/modules/news/save_post.php" method="post" style="margin: 0;">
83

  
84
<input type="hidden" name="section_id" value="<?php echo $section_id; ?>" />
85
<input type="hidden" name="page_id" value="<?php echo $page_id; ?>" />
86
<input type="hidden" name="post_id" value="<?php echo $post_id; ?>" />
87
<input type="hidden" name="link" value="<?php echo $aPostRec['link']; ?>" />
88
<?php echo $admin->getFTAN(); ?>
89

  
90
<table class="row_a" cellpadding="2" cellspacing="0" width="100%">
91
<tr>
92
	<td><?php echo $TEXT['TITLE']; ?>:</td>
93
	<td width="80%">
94
		<input type="text" name="title" value="<?php echo (htmlspecialchars($aPostRec['title'])); ?>" style="width: 98%;" maxlength="255" />
95
	</td>
96
</tr>
97
<tr>
98
	<td><?php echo $TEXT['GROUP']; ?>:</td>
99
	<td>
100
		<select name="group" style="width: 100%;">
101
			<option value="0"><?php echo $TEXT['NONE']; ?></option>
102
			<?php
103
			$query = $database->query("SELECT group_id,title FROM ".TABLE_PREFIX."mod_news_groups WHERE section_id = '$section_id' ORDER BY position ASC");
104
			if($query->numRows() > 0) {
105
				// Loop through groups
106
				while($group = $query->fetchRow(MYSQL_ASSOC)) {
107
					?>
108
					<option value="<?php echo $group['group_id']; ?>"<?php if($aPostRec['group_id'] == $group['group_id']) { echo ' selected="selected"'; } ?>><?php echo $group['title']; ?></option>
109
					<?php
110
				}
111
			}
112
			?>
113
		</select>
114
	</td>
115
</tr>
116
<tr>
117
	<td><?php echo $TEXT['COMMENTING']; ?>:</td>
118
	<td>
119
		<select name="commenting" style="width: 100%;">
120
			<option value="none"><?php echo $TEXT['DISABLED']; ?></option>
121
			<option value="public" <?php if($aPostRec['commenting'] == 'public') { echo ' selected="selected"'; } ?>><?php echo $TEXT['PUBLIC']; ?></option>
122
			<option value="private" <?php if($aPostRec['commenting'] == 'private') { echo ' selected="selected"'; } ?>><?php echo $TEXT['PRIVATE']; ?></option>
123
		</select>
124
	</td>
125
</tr>
126
<tr>
127
	<td><?php echo $TEXT['ACTIVE']; ?>:</td>
128
	<td>
129
		<input type="radio" name="active" id="active_true" value="1" <?php if($aPostRec['active'] == 1) { echo ' checked="checked"'; } ?> />
130
		<a href="#" onclick="javascript: document.getElementById('active_true').checked = true;">
131
		<?php echo $TEXT['YES']; ?>
132
		</a>
133
		&nbsp;
134
		<input type="radio" name="active" id="active_false" value="0" <?php if($aPostRec['active'] == 0) { echo ' checked="checked"'; } ?> />
135
		<a href="#" onclick="javascript: document.getElementById('active_false').checked = true;">
136
		<?php echo $TEXT['NO']; ?>
137
		</a>
138
	</td>
139
</tr>
140
<tr>
141
	<td><?php echo $TEXT['PUBL_START_DATE']; ?>:</td>
142
	<td>
143
	<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;" />
144
	<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=''" />
145
	<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=''" />
146
	</td>
147
</tr>
148
<tr>
149
	<td><?php echo $TEXT['PUBL_END_DATE']; ?>:</td>
150
	<td>
151
	<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;" />
152
	<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=''" />
153
	<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=''" />
154
	</td>
155
</tr>
156
</table>
157

  
158
<table class="row_a" cellpadding="2" cellspacing="0" border="0" width="100%">
159
<tr>
160
	<td valign="top"><?php echo $TEXT['SHORT']; ?>:</td>
161
</tr>
162
<tr>
163
	<td>
164
	<?php
165
	show_wysiwyg_editor("short","short",htmlspecialchars($aPostRec['content_short']),"100%","200px");
166
	?>
167
	</td>
168
</tr>
169
<tr>
170
	<td valign="top"><?php echo $TEXT['LONG']; ?>:</td>
171
</tr>
172
<tr>
173
	<td>
174
	<?php
175
	show_wysiwyg_editor("long","long",htmlspecialchars($aPostRec['content_long']),"100%","650px");
176
	?>
177
	</td>
178
</tr>
179
</table>
180

  
181
<table cellpadding="2" cellspacing="0" border="0" width="100%">
182
<tr>
183
	<td align="left">
184
		<input name="save" type="submit" value="<?php echo $TEXT['SAVE']; ?>" style="width: 100px; margin-top: 5px;" />
185
	</td>
186
	<td align="right">
187
		<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;" />
188
	</td>
189
</tr>
190
</table>
191
</form>
192

  
193
<script type="text/javascript">
194
	Calendar.setup(
195
		{
196
			inputField  : "publishdate",
197
			ifFormat    : "<?php echo $jscal_ifformat ?>",
198
			button      : "publishdate_trigger",
199
			firstDay    : <?php echo $jscal_firstday ?>,
200
			<?php if(isset($jscal_use_time) && $jscal_use_time==TRUE)
201
            { ?>
202
				showsTime   : "true",
203
				timeFormat  : "24",
204
			<?php
205
            } ?>
206
			date        : "<?php echo $jscal_today ?>",
207
			range       : [1970, 2037],
208
			step        : 1
209
		}
210
	);
211
	Calendar.setup(
212
		{
213
			inputField  : "enddate",
214
			ifFormat    : "<?php echo $jscal_ifformat ?>",
215
			button      : "enddate_trigger",
216
			firstDay    : <?php echo $jscal_firstday ?>,
217
			<?php if(isset($jscal_use_time) && $jscal_use_time==TRUE)
218
            { ?>
219
				showsTime   : "true",
220
				timeFormat  : "24",
221
			<?php
222
            } ?>
223
			date        : "<?php echo $jscal_today ?>",
224
			range       : [1970, 2037],
225
			step        : 1
226
		}
227
	);
228
</script>
229

  
230
<br />
231

  
232
<h2><?php echo $TEXT['MODIFY'].'/'.$TEXT['DELETE'].' '.$TEXT['COMMENT']; ?></h2>
233

  
234
<?php
235

  
236
// Loop through existing posts
237
$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");
238
if($query_comments->numRows() > 0) {
239
	$row = 'a';
240
	$pid = $admin->getIDKEY($post_id);
241
	?>
242
	<table cellpadding="2" cellspacing="0" border="0" width="100%">
243
	<?php
244
	while($comment = $query_comments->fetchRow(MYSQL_ASSOC)) {
245
		$cid = $admin->getIDKEY($comment['comment_id']);
246
		?>
247
		<tr class="row_<?php echo $row; ?>" >
248
			<td width="20" style="padding-left: 5px;">
249
				<a href="<?php echo WB_URL; ?>/modules/news/modify_comment.php?page_id=<?php echo $page_id; ?>&amp;section_id=<?php
250
					echo $section_id; ?>&amp;comment_id=<?php echo $cid; ?>" title="<?php echo $TEXT['MODIFY']; ?>">
251
					<img src="<?php echo THEME_URL; ?>/images/modify_16.png" border="0" alt="^" />
252
				</a>
253
			</td>	
254
			<td>
255
				<a href="<?php echo WB_URL; ?>/modules/news/modify_comment.php?page_id=<?php echo $page_id; ?>&amp;section_id=<?php
256
					echo $section_id; ?>&amp;comment_id=<?php echo $cid; ?>">
257
					<?php echo $comment['title']; ?>
258
				</a>
259
			</td>
260
			<td width="20">
261
				<a href="javascript: confirm_link('<?php echo $TEXT['ARE_YOU_SURE']; ?>', '<?php
262
					echo WB_URL; ?>/modules/news/delete_comment.php?page_id=<?php echo $page_id; ?>&amp;section_id=<?php
263
					echo $section_id; ?>&amp;post_id=<?php echo $pid; ?>&amp;comment_id=<?php echo $cid; ?>');" title="<?php
264
					echo $TEXT['DELETE']; ?>">
265
					<img src="<?php echo THEME_URL; ?>/images/delete_16.png" border="0" alt="X" />
266
				</a>
267
			</td>
268
		</tr>
269
		<?php
270
		// Alternate row color
271
		if($row == 'a') {
272
			$row = 'b';
273
		} else {
274
			$row = 'a';
275
		}
276
	}
277
	?>
278
	</table>
279
	<?php
37
if(!make_dir(WB_PATH.PAGES_DIRECTORY.'/posts')) {
38
	$admin->print_error($MESSAGE['GENERIC_BAD_PERMISSIONS'], ADMIN_URL.'/pages/modify.php?page_id='.$page_id );
280 39
} else {
281
	echo $TEXT['NONE_FOUND'];
40
    
41
    $post_id = intval($admin->checkIDKEY('post_id', false, 'GET'));
42
    if (!$post_id) {
43
    	$admin->print_error($MESSAGE['GENERIC_SECURITY_ACCESS'], $backlink);
44
    }
45
    $aPostRec = 
46
        array(
47
            'post_id'         => 0,
48
            'section_id'      => 0,
49
            'page_id'         => 0,
50
            'group_id'        => 0,
51
            'active'          => 0,
52
            'position'        => 0,
53
            'title'           => '',
54
            'link'            => '',
55
            'content_short'   => '',
56
            'content_long'    => '',
57
            'commenting'      => '',
58
            'created_when'    => 0,
59
            'created_by'      => 0,
60
            'published_when'  => 0,
61
            'published_until' => 0,
62
            'posted_when'     => 0,
63
            'posted_by'       => 0
64
    );
65
    $sMediaUrl = WB_URL.MEDIA_DIRECTORY;
66
    // Get header and footer
67
    $sql = 'SELECT * FROM `'.TABLE_PREFIX.'mod_news_posts` WHERE `post_id`='.(int)$post_id;
68
    if($oPostRes = $database->query($sql)){
69
    	$aPostRec = $oPostRes->fetchRow(MYSQL_ASSOC);
70
    	$aPostRec['content_short'] = str_replace('{SYSVAR:MEDIA_REL}', $sMediaUrl,$aPostRec['content_short']);
71
    	$aPostRec['content_long']  = str_replace('{SYSVAR:MEDIA_REL}', $sMediaUrl,$aPostRec['content_long']);
72
    }
73
    //$query_content = $database->query("SELECT * FROM ".TABLE_PREFIX."mod_news_posts WHERE post_id = '$post_id'");
74
    
75
    //print '<pre style="text-align:left;color:#000;padding:1em;"><strong>function '.__FUNCTION__.'( '.$post_id.' );</strong>  basename: '.basename(__FILE__).'  line: '.__LINE__.' -> <br />'; 
76
    //print_r( $fetch_content['content_short'] ); print '</pre>'; // flush ();sleep(10); die();
77
    if(!isset($wysiwyg_editor_loaded)) {
78
        $wysiwyg_editor_loaded=true;
79
    	if (!defined('WYSIWYG_EDITOR') OR WYSIWYG_EDITOR=="none" OR !file_exists(WB_PATH.'/modules/'.WYSIWYG_EDITOR.'/include.php')) {
80
    		function show_wysiwyg_editor($name,$id,$content,$width,$height) {
81
    			echo '<textarea name="'.$name.'" id="'.$id.'" rows="10" cols="1" style="width: '.$width.'; height: '.$height.';">'.$content.'</textarea>';
82
    		}
83
    	} else {
84
    		$id_list=array("short","long");
85
    		require(WB_PATH.'/modules/'.WYSIWYG_EDITOR.'/include.php');
86
    	}
87
    }
88
    
89
    // include jscalendar-setup
90
    $jscal_use_time = true; // whether to use a clock, too
91
    require_once(WB_PATH."/include/jscalendar/wb-setup.php");
92
    ?>
93
    <h2><?php echo $TEXT['ADD'].'/'.$TEXT['MODIFY'].' '.$TEXT['POST']; ?></h2>
94
    <div class="jsadmin jcalendar hide"></div> 
95
    <form name="modify" action="<?php echo WB_URL; ?>/modules/news/save_post.php" method="post" style="margin: 0;">
96
    
97
    <input type="hidden" name="section_id" value="<?php echo $section_id; ?>" />
98
    <input type="hidden" name="page_id" value="<?php echo $page_id; ?>" />
99
    <input type="hidden" name="post_id" value="<?php echo $post_id; ?>" />
100
    <input type="hidden" name="link" value="<?php echo $aPostRec['link']; ?>" />
101
    <?php echo $admin->getFTAN(); ?>
102
    
103
    <table class="row_a" cellpadding="2" cellspacing="0" width="100%">
104
    <tr>
105
    	<td><?php echo $TEXT['TITLE']; ?>:</td>
106
    	<td width="80%">
107
    		<input type="text" name="title" value="<?php echo (htmlspecialchars($aPostRec['title'])); ?>" style="width: 98%;" maxlength="255" />
108
    	</td>
109
    </tr>
110
    <tr>
111
    	<td><?php echo $TEXT['GROUP']; ?>:</td>
112
    	<td>
113
    		<select name="group" style="width: 100%;">
114
    			<option value="0"><?php echo $TEXT['NONE']; ?></option>
115
    			<?php
116
    			$query = $database->query("SELECT group_id,title FROM ".TABLE_PREFIX."mod_news_groups WHERE section_id = '$section_id' ORDER BY position ASC");
117
    			if($query->numRows() > 0) {
118
    				// Loop through groups
119
    				while($group = $query->fetchRow(MYSQL_ASSOC)) {
120
    					?>
121
    					<option value="<?php echo $group['group_id']; ?>"<?php if($aPostRec['group_id'] == $group['group_id']) { echo ' selected="selected"'; } ?>><?php echo $group['title']; ?></option>
122
    					<?php
123
    				}
124
    			}
125
    			?>
126
    		</select>
127
    	</td>
128
    </tr>
129
    <tr>
130
    	<td><?php echo $TEXT['COMMENTING']; ?>:</td>
131
    	<td>
132
    		<select name="commenting" style="width: 100%;">
133
    			<option value="none"><?php echo $TEXT['DISABLED']; ?></option>
134
    			<option value="public" <?php if($aPostRec['commenting'] == 'public') { echo ' selected="selected"'; } ?>><?php echo $TEXT['PUBLIC']; ?></option>
135
    			<option value="private" <?php if($aPostRec['commenting'] == 'private') { echo ' selected="selected"'; } ?>><?php echo $TEXT['PRIVATE']; ?></option>
136
    		</select>
137
    	</td>
138
    </tr>
139
    <tr>
140
    	<td><?php echo $TEXT['ACTIVE']; ?>:</td>
141
    	<td>
142
    		<input type="radio" name="active" id="active_true" value="1" <?php if($aPostRec['active'] == 1) { echo ' checked="checked"'; } ?> />
143
    		<a href="#" onclick="javascript: document.getElementById('active_true').checked = true;">
144
    		<?php echo $TEXT['YES']; ?>
145
    		</a>
146
    		&nbsp;
147
    		<input type="radio" name="active" id="active_false" value="0" <?php if($aPostRec['active'] == 0) { echo ' checked="checked"'; } ?> />
148
    		<a href="#" onclick="javascript: document.getElementById('active_false').checked = true;">
149
    		<?php echo $TEXT['NO']; ?>
150
    		</a>
151
    	</td>
152
    </tr>
153
    <tr>
154
    	<td><?php echo $TEXT['PUBL_START_DATE']; ?>:</td>
155
    	<td>
156
    	<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;" />
157
    	<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=''" />
158
    	<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=''" />
159
    	</td>
160
    </tr>
161
    <tr>
162
    	<td><?php echo $TEXT['PUBL_END_DATE']; ?>:</td>
163
    	<td>
164
    	<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;" />
165
    	<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=''" />
166
    	<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=''" />
167
    	</td>
168
    </tr>
169
    </table>
170
    
171
    <table class="row_a" cellpadding="2" cellspacing="0" border="0" width="100%">
172
    <tr>
173
    	<td valign="top"><?php echo $TEXT['SHORT']; ?>:</td>
174
    </tr>
175
    <tr>
176
    	<td>
177
    	<?php
178
    	show_wysiwyg_editor("short","short",htmlspecialchars($aPostRec['content_short']),"100%","200px");
179
    	?>
180
    	</td>
181
    </tr>
182
    <tr>
183
    	<td valign="top"><?php echo $TEXT['LONG']; ?>:</td>
184
    </tr>
185
    <tr>
186
    	<td>
187
    	<?php
188
    	show_wysiwyg_editor("long","long",htmlspecialchars($aPostRec['content_long']),"100%","650px");
189
    	?>
190
    	</td>
191
    </tr>
192
    </table>
193
    
194
    <table cellpadding="2" cellspacing="0" border="0" width="100%">
195
    <tr>
196
    	<td align="left">
197
    		<input name="save" type="submit" value="<?php echo $TEXT['SAVE']; ?>" style="width: 100px; margin-top: 5px;" />
198
    	</td>
199
    	<td align="right">
200
    		<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;" />
201
    	</td>
202
    </tr>
203
    </table>
204
    </form>
205
    
206
    <script type="text/javascript">
207
    	Calendar.setup(
208
    		{
209
    			inputField  : "publishdate",
210
    			ifFormat    : "<?php echo $jscal_ifformat ?>",
211
    			button      : "publishdate_trigger",
212
    			firstDay    : <?php echo $jscal_firstday ?>,
213
    			<?php if(isset($jscal_use_time) && $jscal_use_time==TRUE)
214
                { ?>
215
    				showsTime   : "true",
216
    				timeFormat  : "24",
217
    			<?php
218
                } ?>
219
    			date        : "<?php echo $jscal_today ?>",
220
    			range       : [1970, 2037],
221
    			step        : 1
222
    		}
223
    	);
224
    	Calendar.setup(
225
    		{
226
    			inputField  : "enddate",
227
    			ifFormat    : "<?php echo $jscal_ifformat ?>",
228
    			button      : "enddate_trigger",
229
    			firstDay    : <?php echo $jscal_firstday ?>,
230
    			<?php if(isset($jscal_use_time) && $jscal_use_time==TRUE)
231
                { ?>
232
    				showsTime   : "true",
233
    				timeFormat  : "24",
234
    			<?php
235
                } ?>
236
    			date        : "<?php echo $jscal_today ?>",
237
    			range       : [1970, 2037],
238
    			step        : 1
239
    		}
240
    	);
241
    </script>
242
    
243
    <br />
244
    
245
    <h2><?php echo $TEXT['MODIFY'].'/'.$TEXT['DELETE'].' '.$TEXT['COMMENT']; ?></h2>
246
    
247
    <?php
248
    
249
    // Loop through existing posts
250
    $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");
251
    if($query_comments->numRows() > 0) {
252
    	$row = 'a';
253
    	$pid = $admin->getIDKEY($post_id);
254
    	?>
255
    	<table cellpadding="2" cellspacing="0" border="0" width="100%">
256
    	<?php
257
    	while($comment = $query_comments->fetchRow(MYSQL_ASSOC)) {
258
    		$cid = $admin->getIDKEY($comment['comment_id']);
259
    		?>
260
    		<tr class="row_<?php echo $row; ?>" >
261
    			<td width="20" style="padding-left: 5px;">
262
    				<a href="<?php echo WB_URL; ?>/modules/news/modify_comment.php?page_id=<?php echo $page_id; ?>&amp;section_id=<?php
263
    					echo $section_id; ?>&amp;comment_id=<?php echo $cid; ?>" title="<?php echo $TEXT['MODIFY']; ?>">
264
    					<img src="<?php echo THEME_URL; ?>/images/modify_16.png" border="0" alt="^" />
265
    				</a>
266
    			</td>	
267
    			<td>
268
    				<a href="<?php echo WB_URL; ?>/modules/news/modify_comment.php?page_id=<?php echo $page_id; ?>&amp;section_id=<?php
269
    					echo $section_id; ?>&amp;comment_id=<?php echo $cid; ?>">
270
    					<?php echo $comment['title']; ?>
271
    				</a>
272
    			</td>
273
    			<td width="20">
274
    				<a href="javascript: confirm_link('<?php echo $TEXT['ARE_YOU_SURE']; ?>', '<?php
275
    					echo WB_URL; ?>/modules/news/delete_comment.php?page_id=<?php echo $page_id; ?>&amp;section_id=<?php
276
    					echo $section_id; ?>&amp;post_id=<?php echo $pid; ?>&amp;comment_id=<?php echo $cid; ?>');" title="<?php
277
    					echo $TEXT['DELETE']; ?>">
278
    					<img src="<?php echo THEME_URL; ?>/images/delete_16.png" border="0" alt="X" />
279
    				</a>
280
    			</td>
281
    		</tr>
282
    		<?php
283
    		// Alternate row color
284
    		if($row == 'a') {
285
    			$row = 'b';
286
    		} else {
287
    			$row = 'a';
288
    		}
289
    	}
290
    	?>
291
    	</table>
292
    	<?php
293
    } else {
294
    	echo $TEXT['NONE_FOUND'];
295
    }
282 296
}
283

  
284 297
// Print admin footer
285 298
$admin->print_footer();

Also available in: Unified diff