Project

General

Profile

« Previous | Next » 

Revision 562

Added by Matthias almost 17 years ago

Updated news modul with features from the advanced news modul

View differences:

upgrade-script.php
198 198
}
199 199

  
200 200

  
201
$database = new database(DB_URL);
202

  
201 203
//******************************************************************************
202
//The following lines upgrades the form modul from 2.6.x to the andvanced version from 2.7.x
204
//Start of upgrade script for the form modul
203 205
//******************************************************************************
204 206

  
205
$database = new database(DB_URL);
206

  
207 207
echo "<BR><B>Adding new field to database table mod_form_settings</B><BR>";
208 208

  
209 209
if($database->query("ALTER TABLE `".TABLE_PREFIX."mod_form_settings` ADD `success_email_subject` VARCHAR(255) NOT NULL AFTER `success_message`")) {
......
296 296
//End of upgrade script for the form modul
297 297
//******************************************************************************
298 298

  
299
//******************************************************************************
300
//Start of upgrade script for the news modul
301
//******************************************************************************
302

  
303
echo "<BR><B>Adding new field to database table mod_news_posts</B><BR>";
304
if($database->query("ALTER TABLE `".TABLE_PREFIX."mod_news_posts` ADD `published_when` INT NOT NULL AFTER `commenting`")) {
305
	echo 'Database Field published_when added successfully<br />';
306
}
307
echo mysql_error().'<br />';
308

  
309
// UPDATING DATA INTO FIELDS
310
echo "<BR>";
311

  
312
// These are the default setting
313
$header = '<table cellpadding=\"0\" cellspacing=\"0\" border=\"0\" width=\"98%\">';
314
$post_loop = '<tr class=\"post_top\">
315
<td class=\"post_title\"><a href=\"[LINK]\">[TITLE]</a></td>
316
<td class=\"post_date\">[MODI_TIME], [MODI_DATE]</td>
317
</tr>
318
<tr>
319
<td class=\"post_short\" colspan=\"2\">
320
[SHORT] 
321
<a href=\"[LINK]\">[TEXT_READ_MORE]</a>
322
</td>
323
</tr>';
324
$post_header = addslashes('<table cellpadding="0" cellspacing="0" border="0" width="100%">
325
<tr>
326
<td height="30"><h1>[TITLE]</h1></td>
327
<td rowspan="3" style="display: [DISPLAY_IMAGE]"><img src="[GROUP_IMAGE]" alt="[GROUP_TITLE]" /></td>
328
</tr>
329
<tr>
330
<td valign="top"><b>Posted by [DISPLAY_NAME] ([USERNAME]) on [PUBL_DATE]</b></td>
331
</tr>
332
<tr style="display: [DISPLAY_GROUP]">
333
<td valign="top"><a href="[BACK]">[PAGE_TITLE]</a> >> <a href="[BACK]?g=[GROUP_ID]">[GROUP_TITLE]</a></td>
334
</tr>
335
</table>
336
<p style="text-align: justify;">');
337
$post_footer = '</p><p>Last changed: [MODI_DATE] at [MODI_TIME]</p>
338
<a href=\"[BACK]\">Back</a>';
339
$comments_header = addslashes('<br /><br />
340
<h2>Comments</h2>
341
<table cellpadding="2" cellspacing="0" border="0" width="98%">');
342

  
343
// Insert default settings into database
344
$query_dates = $database->query("SELECT * FROM ".TABLE_PREFIX."mod_news_settings where section_id != 0 and page_id != 0");
345
while($result = $query_dates->fetchRow()) {
346
	
347
	echo "<B>Add default settings data to database for news section_id= ".$result['section_id']."</b><BR>";
348
	$section_id = $result['section_id'];
349

  
350
	if($database->query("UPDATE `".TABLE_PREFIX."mod_news_settings` SET `header` = '$header' WHERE `section_id` = $section_id")) {
351
		echo 'Database data header added successfully<br>';
352
	}
353
	echo mysql_error().'<br />';
354
	
355
	if($database->query("UPDATE `".TABLE_PREFIX."mod_news_settings` SET `post_loop` = '$post_loop' WHERE `section_id` = $section_id")) {
356
		echo 'Database data post_loop added successfully<br>';
357
	}
358
	echo mysql_error().'<br />';
359
	
360
	if($database->query("UPDATE `".TABLE_PREFIX."mod_news_settings` SET `post_header` = '$post_header' WHERE `section_id` = $section_id")) {
361
		echo 'Database data post_header added successfully<br>';
362
	}
363
	echo mysql_error().'<br />';
364
	
365
	if($database->query("UPDATE `".TABLE_PREFIX."mod_news_settings` SET `post_footer` = '$post_footer' WHERE `section_id` = $section_id")) {
366
		echo 'Database data post_footer added successfully<br>';
367
	}
368
	echo mysql_error().'<br />';
369
	
370
	if($database->query("UPDATE `".TABLE_PREFIX."mod_news_settings` SET `comments_header` = '$comments_header' WHERE `section_id` = $section_id")) {
371
		echo 'Database data comments_header added successfully<br>';
372
	}
373
	echo mysql_error().'<br />';
374

  
375
}
376

  
377
// MIGRATING FIELD DATES to POSTED_WHEN
378
echo "<B>Copying field posted_when value to published_when</B><BR>";
379
$query_dates = $database->query("SELECT * FROM ".TABLE_PREFIX."mod_news_posts where section_id != 0 and page_id != 0");
380

  
381
while($result = $query_dates->fetchRow()) {
382
	$pid = $result['post_id'];
383
	$NEW_DATE = $result['posted_when'];
384
	if($database->query("UPDATE `".TABLE_PREFIX."mod_news_posts` SET `published_when` = '$NEW_DATE' WHERE `post_id` = $pid")) {
385
		echo 'Copying posted_when value to published_when successfully<br>';
386
	}
387
	echo mysql_error().'<br />';
388
}
389

  
390
//******************************************************************************
391
//End of upgrade script for the news modul
392
//******************************************************************************
393

  
299 394
echo "<br /><br />Done<br />";
300 395

  
301 396
?>
302 397

  
303 398
</body>
304
</html>
399
</html>

Also available in: Unified diff