Project

General

Profile

« Previous | Next » 

Revision 1895

Added by Dietmar over 11 years ago

! update jsadmin module and set Version to 1.4.1
! update news module and set Version to 3.8.7

View differences:

branches/2.8.x/CHANGELOG
13 13

  
14 14

  
15 15

  
16
20 Mar-2013 Build 1895 Dietmar Woellbrink (Luisehahne)
17
! update jsadmin module and set Version to 1.4.1
18
! update news module and set Version to 3.8.7
16 19
19 Mar-2013 Build 1894 Dietmar Woellbrink (Luisehahne)
17 20
# bugfix form intall form284db.sql
18 21
# bugfix wb_search_data.sql layout for table settings 
branches/2.8.x/wb/upgrade-script.php
953 953
	 * $aModuleList list of proofed modules
954 954
	 */
955 955
	$aModuleList = array(
956
	              'captcha_control','code','form','menu_link',
957
	              'output_filter','wysiwyg');
956
	              'captcha_control','code','form','jsadmin',
957
	              'menu_link','news','output_filter','wysiwyg');
958 958
	if(sizeof($aModuleList)) 
959 959
	{
960 960
		echo '<h3>Step '.(++$stepID).': Upgrade proofed modules</h3>';
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', '1894');
54
if(!defined('REVISION')) define('REVISION', '1895');
55 55
if(!defined('SP')) define('SP', '');
branches/2.8.x/wb/modules/jsadmin/info.php
4 4
 * @category        modules
5 5
 * @package         jsadmin
6 6
 * @author          WebsiteBaker Project
7
 * @copyright       2009-2011, Website Baker Org. e.V.
7
 * @copyright       2009-2012, WebsiteBaker Org. e.V.
8 8
 * @link            http://www.websitebaker2.org/
9 9
 * @license         http://www.gnu.org/licenses/gpl.html
10 10
 * @platform        WebsiteBaker 2.8.x
......
18 18
$module_directory = 'jsadmin';
19 19
$module_name = 'Javascript Admin';
20 20
$module_function = 'tool';
21
$module_version = '1.4.0';
22
$module_platform = '2.7 | 2.8.x';
21
$module_version = '1.4.1';
22
$module_platform = '2.8.4';
23 23
$module_author = 'Stepan Riha, Swen Uth';
24 24
$module_license	= 'BSD License';
25 25
$module_description = 'This module adds Javascript functionality to the Website Baker Admin to improve some of the UI interactions. Uses the YahooUI library.';
branches/2.8.x/wb/modules/jsadmin/install.php
4 4
 * @category        modules
5 5
 * @package         JsAdmin
6 6
 * @author          WebsiteBaker Project, modified by Swen Uth for Website Baker 2.7
7
 * @copyright       (C) 2006, Stepan Riha, 2009-2011, Website Baker Org. e.V.
8
 * @link			http://www.websitebaker2.org/
7
 * @copyright       2009-2013, WebsiteBaker Org. e.V.
8
 * @link            http://www.websitebaker2.org/
9 9
 * @license         http://www.gnu.org/licenses/gpl.html
10 10
 * @platform        WebsiteBaker 2.8.x
11 11
 * @requirements    PHP 5.2.2 and higher
12 12
 * @version         $Id$
13
 * @filesource		$HeadURL$
13
 * @filesource      $HeadURL$
14 14
 * @lastmodified    $Date$
15 15
 *
16 16
*/
17 17

  
18
// prevent this file from being accessed directly
19 18
/* -------------------------------------------------------- */
20
if(defined('WB_PATH') == false)
21
{
22
	// Stop this file being access directly
23
	die('<head><title>Access denied</title></head><body><h2 style="color:red;margin:3em auto;text-align:center;">Cannot access this file directly</h2></body></html>');
24
}
25
/* -------------------------------------------------------- */
26

  
27
// add new rows to table "settings"
28

  
29
$msg = array ();
30
$table = TABLE_PREFIX ."mod_jsadmin";
31
$jsadminDefault = array (
32
	array ( 'id' => '1','name' => 'mod_jsadmin_persist_order','value' => '1' ),
33
	array ( 'id' => '2','name' => 'mod_jsadmin_ajax_order_pages','value' => '1' ),
34
	array ( 'id' => '3','name' => 'mod_jsadmin_ajax_order_sections','value' => '1' ),
35
);
36

  
37
$database->query("DROP TABLE IF EXISTS `$table`");
38
$sql = 'CREATE TABLE IF NOT EXISTS `'.TABLE_PREFIX.'mod_jsadmin` ('
39
	. ' `id` INT(11) NOT NULL DEFAULT \'0\','
40
	. ' `name` VARCHAR(255) NOT NULL DEFAULT \'0\','
41
	. ' `value` INT(11) NOT NULL DEFAULT \'0\','
42
	. ' PRIMARY KEY ( `id` )'
43
	. ' ) ENGINE=MyISAM DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci';
44

  
45
if($database->query($sql) ) {
46

  
47
	for($x=0;$x<sizeof($jsadminDefault); $x++) {
48
		$sql  = 'INSERT INTO '.$table.' SET ';
49
		$sql .= '`id`=\''.$jsadminDefault[$x]['id'].'\', ';
50
		$sql .= '`name`=\''.$jsadminDefault[$x]['name'].'\', ';
51
		$sql .= '`value`=\''.$jsadminDefault[$x]['value'].'\' ';
52
		if(!$database->query($sql) ) { $msg[] = $database->get_error();}
19
// Must include code to stop this file being accessed directly
20
if(!defined('WB_PATH')) {
21
	require_once(dirname(dirname(dirname(__FILE__))).'/framework/globalExceptionHandler.php');
22
	throw new IllegalFileException();
23
} else {
24
	$sError = array();
25
	// Create table
26
	if(!$database->SqlImport(dirname(__FILE__).'/sql/mod_jsadmin.sql','',false)){
27
		$sError[] = $database->get_error();
53 28
	}
54
} else {
55
	$msg[] = $database->get_error();
29
// Create table
30
	if(!$database->SqlImport(dirname(__FILE__).'/sql/data_jsadmin.sql','',false)){
31
		$sError[] = $database->get_error();
32
	}
56 33
}
57

  
branches/2.8.x/wb/modules/jsadmin/sql/mod_jsadmin.sql
1
-- phpMyAdmin SQL Dump
2
-- Erstellungszeit: 15. Mrz 2013 um 18:21
3
-- Server-Version: 5.5.27
4
--
5
SET SQL_MODE="NO_AUTO_VALUE_ON_ZERO";
6
SET time_zone = "+00:00";
7
-- --------------------------------------------------------
8
-- Database structure for WebsiteBaker core
9
--
10
-- Replacements: {TABLE_PREFIX}, {TABLE_ENGINE}, {TABLE_COLLATION}
11
--
12
-- --------------------------------------------------------
13
--
14
-- Tabellenstruktur für Tabelle `mod_jsadmin`
15
--
16
CREATE TABLE IF NOT EXISTS `{TABLE_PREFIX}mod_jsadmin` (
17
  `id` int(11) NOT NULL DEFAULT '0',
18
  `name` varchar(255) NOT NULL DEFAULT '',
19
  `value` int(11) NOT NULL DEFAULT '0',
20
  PRIMARY KEY (`id`)
21
){TABLE_ENGINE};
22
-- EndOfFile
branches/2.8.x/wb/modules/jsadmin/sql/data_jsadmin.sql
1
-- phpMyAdmin SQL Dump
2
-- Erstellungszeit: 18. Mrz 2013 um 04:35
3
-- Server Version: 5.5.27
4
SET SQL_MODE="NO_AUTO_VALUE_ON_ZERO";
5
SET time_zone = "+00:00";
6
-- --------------------------------------------------------
7
-- Database structure for WebsiteBaker core
8
--
9
-- Replacements: {TABLE_PREFIX}, {TABLE_ENGINE}, {TABLE_COLLATION}
10
--
11
-- --------------------------------------------------------
12
--
13
-- Daten für Tabelle `mod_jsadmin`
14
--
15

  
16
INSERT INTO `{TABLE_PREFIX}mod_jsadmin` VALUES(1, 'mod_jsadmin_persist_order', 1);
17
INSERT INTO `{TABLE_PREFIX}mod_jsadmin` VALUES(2, 'mod_jsadmin_ajax_order_pages', 1);
18
INSERT INTO `{TABLE_PREFIX}mod_jsadmin` VALUES(3, 'mod_jsadmin_ajax_order_sections', 1);
19
-- EndOfFile
branches/2.8.x/wb/modules/jsadmin/upgrade.php
4 4
 * @category        modules
5 5
 * @package         jsadmin
6 6
 * @author          WebsiteBaker Project
7
 * @copyright       2009-2011, Website Baker Org. e.V.
7
 * @copyright       2009-2013, WebsiteBaker Org. e.V.
8 8
 * @link            http://www.websitebaker2.org/
9 9
 * @license         http://www.gnu.org/licenses/gpl.html
10 10
 * @platform        WebsiteBaker 2.8.x
......
16 16
 */
17 17
// Must include code to stop this file being access directly
18 18
/* -------------------------------------------------------- */
19
if(defined('WB_PATH') == false)
20
{
21
	// Stop this file being access directly
22
		die('<head><title>Access denied</title></head><body><h2 style="color:red;margin:3em auto;text-align:center;">Cannot access this file directly</h2></body></html>');
19
// Must include code to stop this file being accessed directly
20
if(!defined('WB_URL')) {
21
	require_once(dirname(dirname(dirname(__FILE__))).'/framework/globalExceptionHandler.php');
22
	throw new IllegalFileException();
23 23
}
24 24
/* -------------------------------------------------------- */
25 25

  
26
$msg = '';
27
$sTable = TABLE_PREFIX.'mod_jsadmin';
28
if(($sOldType = $database->getTableEngine($sTable))) {
29
	if(('myisam' != strtolower($sOldType))) {
30
		if(!$database->query('ALTER TABLE `'.$sTable.'` Engine = \'MyISAM\' ')) {
31
			$msg = $database->get_error();
26
	function mod_jsadmin_upgrade($bDebug=false) {
27
		global $OK ,$FAIL;
28
		$database=WbDatabase::getInstance();
29
		$msg = array();
30
		$callingScript = $_SERVER["SCRIPT_NAME"];
31
		// check if upgrade startet by upgrade-script to echo a message
32
		$tmp = 'upgrade-script.php';
33
		$globalStarted = substr_compare($callingScript, $tmp,(0-strlen($tmp)),strlen($tmp)) === 0;
34
// check for missing tables, if true stop the upgrade
35
		$aTable = array('mod_jsadmin');
36
		$aPackage = UpgradeHelper::existsAllTables($aTable);
37
		if( sizeof($aPackage) > 0){
38
			$msg[] =  'TABLE '.implode(' missing! '.$FAIL.'<br />TABLE ',$aPackage).' missing! '.$FAIL;
39
			$msg[] = 'Jsadmin upgrade failed'." $FAIL";
40
			if($globalStarted) {
41
				echo '<strong>'.implode('<br />',$msg).'</strong><br />';
42
			}
43
			return ( ($globalStarted==true ) ? $globalStarted : $msg);
44
		} else {
45
			for($x=0; $x<sizeof($aTable);$x++) {
46
				if(($sOldType = $database->getTableEngine($database->TablePrefix.$aTable[$x]))) {
47
					if(('myisam' != strtolower($sOldType))) {
48
						if(!$database->query('ALTER TABLE `'.$database->TablePrefix.$aTable[$x].'` Engine = \'MyISAM\' ')) {
49
							$msg[] = $database->get_error();
50
						} else{
51
							$msg[] = 'TABLE `'.$database->TablePrefix.$aTable[$x].'` changed to Engine = \'MyISAM\''." $OK";
52
						}
53
					} else {
54
						$msg[] = 'TABLE `'.$database->TablePrefix.$aTable[$x].'` has Engine = \'MyISAM\''." $OK";
55
					}
56
				} else {
57
					$msg[] = $database->get_error();
58
				}
59
			}
60
// only for upgrade-script
61
			if($globalStarted) {
62
				if($bDebug) {
63
					echo '<strong>'.implode('<br />',$msg).'</strong><br />';
64
				}
65
			}
32 66
		}
67
		$msg[] = 'Jsadmin upgrade successfull finished '." $OK";
68
		if($globalStarted) {
69
			echo "<strong>Jsadmin upgrade successfull finished $OK</strong><br />";
70
		}
71
		return ( ($globalStarted==true ) ? $globalStarted : $msg);
33 72
	}
34
} else {
35
	$msg = $database->get_error();
73
// ------------------------------------
74

  
75
$bDebugModus = ((isset($bDebugModus)) ? $bDebugModus : false);
76
// Don't show the messages twice
77
if( is_array($msg = mod_jsadmin_upgrade($bDebugModus)) ) {
78
	echo '<strong>'.implode('<br />',$msg).'</strong><br />';
36 79
}
37 80
// ------------------------------------
branches/2.8.x/wb/modules/news/info.php
26 26
$module_directory   = 'news';
27 27
$module_name        = 'News';
28 28
$module_function    = 'page';
29
$module_version     = '3.5.6';
30
$module_platform    = '2.8.2';
29
$module_version     = '3.5.7';
30
$module_platform    = '2.8.4';
31 31
$module_author      = 'Ryan Djurovich, Rob Smith, Werner v.d.Decken';
32 32
$module_license     = 'GNU General Public License';
33 33
$module_description = 'This page type is designed for making a news page.';
34 34

  
branches/2.8.x/wb/modules/news/view.php
4 4
 * @category        modules
5 5
 * @package         news
6 6
 * @author          WebsiteBaker Project
7
 * @copyright       2009-2011, Website Baker Org. e.V.
8
 * @link			http://www.websitebaker2.org/
7
 * @copyright       2009-2013, WebsiteBaker Org. e.V.
8
 * @link            http://www.websitebaker2.org/
9 9
 * @license         http://www.gnu.org/licenses/gpl.html
10 10
 * @platform        WebsiteBaker 2.8.x
11 11
 * @requirements    PHP 5.2.2 and higher
12 12
 * @version         $Id$
13
 * @filesource		$HeadURL$
13
 * @filesource      $HeadURL$
14 14
 * @lastmodified    $Date$
15 15
 *
16 16
 */
17 17

  
18
// Must include code to stop this file being access directly
19 18
/* -------------------------------------------------------- */
20
if(defined('WB_PATH') == false)
21
{
22
	// Stop this file being access directly
23
		die('<head><title>Access denied</title></head><body><h2 style="color:red;margin:3em auto;text-align:center;">Cannot access this file directly</h2></body></html>');
19
// Must include code to stop this file being accessed directly
20
if(!defined('WB_URL')) {
21
	require_once(dirname(dirname(dirname(__FILE__))).'/framework/globalExceptionHandler.php');
22
	throw new IllegalFileException();
24 23
}
25 24
/* -------------------------------------------------------- */
26 25
global $post_id, $post_section,$TEXT,$MESSAGE;
......
30 29
require_once(!file_exists($lang) ? (dirname(__FILE__)) . '/languages/EN.php' : $lang );
31 30

  
32 31
//overwrite php.ini on Apache servers for valid SESSION ID Separator
33
if(function_exists('ini_set'))
34
{
32
if(function_exists('ini_set')) {
35 33
	ini_set('arg_separator.output', '&amp;');
36 34
}
37 35

  
......
48 46
// Get groups (title, if they are active, and their image [if one has been uploaded])
49 47
if (isset($groups))
50 48
{
51
   unset($groups);
49
	unset($groups);
52 50
}
53 51

  
54 52
$groups[0]['title'] = '';
......
60 58
{
61 59

  
62 60
	while( false != ($group = $query_users->fetchRow()) )
63
    {
61
	{
64 62
		// Insert user info into users array
65 63
		$group_id = $group['group_id'];
66 64
		$groups[$group_id]['title'] = ($group['title']);
67 65
		$groups[$group_id]['active'] = $group['active'];
68
		if(file_exists(WB_PATH.MEDIA_DIRECTORY.'/.news/image'.$group_id.'.jpg'))
69
        {
66
		if(file_exists(WB_PATH.MEDIA_DIRECTORY.'/.news/image'.$group_id.'.jpg')) {
70 67
			$groups[$group_id]['image'] = WB_URL.MEDIA_DIRECTORY.'/.news/image'.$group_id.'.jpg';
71 68
		} else {
72 69
			$groups[$group_id]['image'] = '';
......
80 77
{
81 78

  
82 79
	// Check if we should only list posts from a certain group
83
	if(isset($_GET['g']) AND is_numeric($_GET['g']))
84
    {
80
	if(isset($_GET['g']) AND is_numeric($_GET['g'])) {
85 81
		$query_extra = 'AND `group_id`='.(int)$_GET['g'].' ';
86 82
	} else {
87 83
		$query_extra = '';
88 84
	}
89 85

  
90 86
	// Check if we should only list posts from a certain group
91
	if(isset($_GET['g']) AND is_numeric($_GET['g']))
92
    {
87
	if(isset($_GET['g']) AND is_numeric($_GET['g'])) {
93 88
		$query_extra = 'AND `group_id`='.(int)$_GET['g'].' ';
94 89
	} else {
95 90
		$query_extra = '';
......
116 111
	$sql .=        'AND (`published_until`=0 OR `published_until`>='.$t.') ';
117 112
	$total_num = intval($database->get_one($sql));
118 113
	// Work-out if we need to add limit code to sql
119
	if($setting_posts_per_page != 0)
120
    {
114
	if($setting_posts_per_page != 0) {
121 115
		$limit_sql = " LIMIT $position, $setting_posts_per_page";
122 116
	} else {
123 117
		$limit_sql = "";
......
132 126

  
133 127
	// Create previous and next links
134 128
	if($setting_posts_per_page != 0)
135
    {
129
	{
136 130
		if($position > 0)
137
        {
138
			if(isset($_GET['g']) AND is_numeric($_GET['g']))
139
            {
131
		{
132
			if(isset($_GET['g']) AND is_numeric($_GET['g'])) {
140 133
				$pl_prepend = '<a href="?p='.($position-$setting_posts_per_page).'&amp;g='.$_GET['g'].'">&lt;&lt; ';
141 134
			} else {
142 135
				$pl_prepend = '<a href="?p='.($position-$setting_posts_per_page).'">&lt;&lt; ';
......
148 141
			$previous_link = '';
149 142
			$previous_page_link = '';
150 143
		}
151
		if($position + $setting_posts_per_page >= $total_num)
152
        {
144
		if($position + $setting_posts_per_page >= $total_num) {
153 145
			$next_link = '';
154 146
			$next_page_link = '';
155 147
		} else {
156
			if(isset($_GET['g']) AND is_numeric($_GET['g']))
157
            {
148
			if(isset($_GET['g']) AND is_numeric($_GET['g'])) {
158 149
				$nl_prepend = '<a href="?p='.($position+$setting_posts_per_page).'&amp;g='.$_GET['g'].'"> ';
159 150
			} else {
160 151
				$nl_prepend = '<a href="?p='.($position+$setting_posts_per_page).'"> ';
......
163 154
			$next_link = $nl_prepend.$TEXT['NEXT'].$nl_append;
164 155
			$next_page_link = $nl_prepend.$TEXT['NEXT_PAGE'].$nl_append;
165 156
		}
166
		if($position+$setting_posts_per_page > $total_num)
167
        {
157
		if($position+$setting_posts_per_page > $total_num) {
168 158
			$num_of = $position+$num_posts;
169 159
		} else {
170 160
			$num_of = $position+$setting_posts_per_page;
......
177 167
		$display_previous_next_links = 'none';
178 168
	}
179 169

  
180
	if ($num_posts === 0)
181
    {
170
	if ($num_posts === 0) {
182 171
		$setting_header = '';
183 172
		$setting_post_loop = '';
184 173
		$setting_footer = '';
......
186 175
	}
187 176

  
188 177
	// Print header
189
	if($display_previous_next_links == 'none')
190
    {
178
	if($display_previous_next_links == 'none') {
191 179
		print  str_replace( array('[NEXT_PAGE_LINK]','[NEXT_LINK]','[PREVIOUS_PAGE_LINK]','[PREVIOUS_LINK]','[OUT_OF]','[OF]','[DISPLAY_PREVIOUS_NEXT_LINKS]'),
192
                            array('','','','','','', $display_previous_next_links), $setting_header);
180
		                    array('','','','','','', $display_previous_next_links), $setting_header);
193 181
	} else {
194 182
		print str_replace(  array('[NEXT_PAGE_LINK]','[NEXT_LINK]','[PREVIOUS_PAGE_LINK]','[PREVIOUS_LINK]','[OUT_OF]','[OF]','[DISPLAY_PREVIOUS_NEXT_LINKS]'),
195
                            array($next_page_link, $next_link, $previous_page_link, $previous_link, $out_of, $of, $display_previous_next_links), $setting_header);
183
		                    array($next_page_link, $next_link, $previous_page_link, $previous_link, $out_of, $of, $display_previous_next_links), $setting_header);
196 184
	}
197 185
	if($num_posts > 0)
198
    {
186
	{
199 187
		if($query_extra != '')
200
        {
188
		{
201 189
			?>
202 190
			<div class="selected-group-title">
203 191
				<?php print '<a href="'.htmlspecialchars(strip_tags($_SERVER['SCRIPT_NAME'])).'">'.PAGE_TITLE.'</a> &gt;&gt; '.$groups[$_GET['g']]['title']; ?>
......
205 193
			<?php
206 194
		}
207 195
		while( false != ($post = $query_posts->fetchRow()) )
208
        {
196
		{
209 197
			if(isset($groups[$post['group_id']]['active']) AND $groups[$post['group_id']]['active'] != false)
210
            { // Make sure parent group is active
198
			{ // Make sure parent group is active
211 199
				$uid = $post['posted_by']; // User who last modified the post
212 200
				// Workout date and time of last modified post
213
				if ($post['published_when'] === '0') $post['published_when'] = time();
214
				if ($post['published_when'] > $post['posted_when'])
215
                {
201
				if ($post['published_when'] === '0'){ $post['published_when'] = time();}
202
				if ($post['published_when'] > $post['posted_when']) {
216 203
					$post_date = date(DATE_FORMAT, $post['published_when']+TIMEZONE);
217 204
					$post_time = date(TIME_FORMAT, $post['published_when']+TIMEZONE);
218 205
				} else {
......
220 207
					$post_time = date(TIME_FORMAT, $post['posted_when']+TIMEZONE);
221 208
				}
222 209

  
223
				$publ_date = date(DATE_FORMAT,$post['published_when']);
224
				$publ_time = date(TIME_FORMAT,$post['published_when']);
210
				$publ_date = date(DATE_FORMAT,$post['published_when']+TIMEZONE);
211
				$publ_time = date(TIME_FORMAT,$post['published_when']+TIMEZONE);
225 212

  
226
				// Work-out the post link
213
// Work-out the post link
227 214
				$post_link = page_link($post['link']);
215
				$post_link_path = str_replace(WB_URL, WB_PATH,$post_link);
216
				$create_date = date(DATE_FORMAT, $post['created_when']+TIMEZONE);
217
				$create_time = date(TIME_FORMAT, $post['created_when']+TIMEZONE);
228 218

  
229
                $post_link_path = str_replace(WB_URL, WB_PATH,$post_link);
230
    			$create_date = date(DATE_FORMAT, $post['created_when']);
231
    			$create_time = date(TIME_FORMAT, $post['created_when']);
232

  
233
				if(isset($_GET['p']) AND $position > 0)
234
                {
219
				if(isset($_GET['p']) AND $position > 0) {
235 220
					$post_link .= '?p='.$position;
236 221
				}
237
				if(isset($_GET['g']) AND is_numeric($_GET['g']))
238
                {
239
					if(isset($_GET['p']) AND $position > 0) { $post_link .= '&amp;'; } else { $post_link .= '?'; }
240
                    {
222
				if(isset($_GET['g']) AND is_numeric($_GET['g'])) {
223
					if(isset($_GET['p']) AND $position > 0) { $post_link .= '&amp;'; } else { $post_link .= '?'; } {
241 224
					$post_link .= 'g='.$_GET['g'];
242
                    }
225
					}
243 226
				}
244 227

  
245 228
				// Get group id, title, and image
......
257 240
				$post_long_len = strlen($post['content_long']);
258 241
				$vars = array('[PAGE_TITLE]', '[GROUP_ID]', '[GROUP_TITLE]', '[GROUP_IMAGE]', '[DISPLAY_GROUP]', '[DISPLAY_IMAGE]', '[TITLE]', '[SHORT]', '[LINK]', '[MODI_DATE]', '[MODI_TIME]', '[CREATED_DATE]', '[CREATED_TIME]', '[PUBLISHED_DATE]', '[PUBLISHED_TIME]', '[USER_ID]', '[USERNAME]', '[DISPLAY_NAME]', '[EMAIL]', '[TEXT_READ_MORE]','[SHOW_READ_MORE]');
259 242
				if(isset($users[$uid]['username']) AND $users[$uid]['username'] != '')
260
                {
261
					if($post_long_len < 9)
262
                    {
243
				{
244
					if($post_long_len < 9) {
263 245
						$values = array(PAGE_TITLE, $group_id, $group_title, $group_image, $display_group, $display_image, $post['title'], $short, '#" onclick="javascript:void(0);return false;" style="cursor:no-drop;', $post_date, $post_time, $create_date, $create_time, $publ_date, $publ_time, $uid, $users[$uid]['username'], $users[$uid]['display_name'], $users[$uid]['email'], '', 'hidden');
264 246
					} else {
265
					   	$values = array(PAGE_TITLE, $group_id, $group_title, $group_image, $display_group, $display_image, $post['title'], $short, $post_link, $post_date, $post_time, $create_date, $create_time, $publ_date, $publ_time, $uid, $users[$uid]['username'], $users[$uid]['display_name'], $users[$uid]['email'], $MOD_NEWS['TEXT_READ_MORE'], 'visible');
247
						$values = array(PAGE_TITLE, $group_id, $group_title, $group_image, $display_group, $display_image, $post['title'], $short, $post_link, $post_date, $post_time, $create_date, $create_time, $publ_date, $publ_time, $uid, $users[$uid]['username'], $users[$uid]['display_name'], $users[$uid]['email'], $MOD_NEWS['TEXT_READ_MORE'], 'visible');
266 248
					}
267 249
				} else {
268
					if($post_long_len < 9)
269
                    {
250
					if($post_long_len < 9) {
270 251
						$values = array(PAGE_TITLE, $group_id, $group_title, $group_image, $display_group, $display_image, $post['title'], $short, '#" onclick="javascript:void(0);return false;" style="cursor:no-drop;', $post_date, $post_time, $create_date, $create_time, $publ_date, $publ_time, '', '', '', '', '','hidden');
271 252
					} else {
272 253
						$values = array(PAGE_TITLE, $group_id, $group_title, $group_image, $display_group, $display_image, $post['title'], $short, $post_link, $post_date, $post_time, $create_date, $create_time, $publ_date, $publ_time, '', '', '', '', $MOD_NEWS['TEXT_READ_MORE'],'visible');
......
276 257
			}
277 258
		}
278 259
	}
279
    // Print footer
280
    if($display_previous_next_links == 'none')
281
    {
282
    	print  str_replace(array('[NEXT_PAGE_LINK]','[NEXT_LINK]','[PREVIOUS_PAGE_LINK]','[PREVIOUS_LINK]','[OUT_OF]','[OF]','[DISPLAY_PREVIOUS_NEXT_LINKS]'), array('','','','','','', $display_previous_next_links), $setting_footer);
283
    }
284
    else
285
    {
286
    	print str_replace(array('[NEXT_PAGE_LINK]','[NEXT_LINK]','[PREVIOUS_PAGE_LINK]','[PREVIOUS_LINK]','[OUT_OF]','[OF]','[DISPLAY_PREVIOUS_NEXT_LINKS]'), array($next_page_link, $next_link, $previous_page_link, $previous_link, $out_of, $of, $display_previous_next_links), $setting_footer);
287
    }
260
// Print footer
261
	if($display_previous_next_links == 'none') {
262
		print  str_replace(array('[NEXT_PAGE_LINK]','[NEXT_LINK]','[PREVIOUS_PAGE_LINK]','[PREVIOUS_LINK]','[OUT_OF]','[OF]','[DISPLAY_PREVIOUS_NEXT_LINKS]'), array('','','','','','', $display_previous_next_links), $setting_footer);
263
	} else {
264
		print str_replace(array('[NEXT_PAGE_LINK]','[NEXT_LINK]','[PREVIOUS_PAGE_LINK]','[PREVIOUS_LINK]','[OUT_OF]','[OF]','[DISPLAY_PREVIOUS_NEXT_LINKS]'), array($next_page_link, $next_link, $previous_page_link, $previous_link, $out_of, $of, $display_previous_next_links), $setting_footer);
265
	}
288 266

  
289 267
}
290 268
//elseif(defined('POST_ID') AND is_numeric(POST_ID))
291 269
elseif(isset($post_id) && is_numeric($post_id))
292 270
{
293

  
294
  // print '<h2>'.POST_ID.'/'.PAGE_ID.'/'.POST_SECTION.'</h2>';
271
// print '<h2>'.POST_ID.'/'.PAGE_ID.'/'.POST_SECTION.'</h2>';
295 272
//  if(defined('POST_SECTION') AND POST_SECTION == $section_id)
296
  if(isset($post_section) && ($post_section == $section_id))
297
  {
298
	// Get settings
299
	$setting_post_header = $setting_post_footer = $setting_comments_header
300
	                     = $setting_comments_loop = $setting_comments_footer = '';
301
	$sql  = 'SELECT `post_header`, `post_footer`, `comments_header`, `comments_loop`, `comments_footer` ';
302
	$sql .= 'FROM `'.TABLE_PREFIX.'mod_news_settings` ';
303
	$sql .= 'WHERE `section_id`='.(int)$section_id;
304
	if( ($resSettings = $database->query($sql)) ){
305
		if( ($recSettings = $resSettings->fetchRow()) ) {
306
			foreach($recSettings as $key=>$val){
307
				${'setting_'.$key} = $val;
273
	if(isset($post_section) && ($post_section == $section_id))
274
	{
275
		// Get settings
276
		$setting_post_header = $setting_post_footer = $setting_comments_header
277
		                     = $setting_comments_loop = $setting_comments_footer = '';
278
		$sql  = 'SELECT `post_header`, `post_footer`, `comments_header`, `comments_loop`, `comments_footer` ';
279
		$sql .= 'FROM `'.TABLE_PREFIX.'mod_news_settings` ';
280
		$sql .= 'WHERE `section_id`='.(int)$section_id;
281
		if( ($resSettings = $database->query($sql)) ){
282
			if( ($recSettings = $resSettings->fetchRow()) ) {
283
				foreach($recSettings as $key=>$val){
284
					${'setting_'.$key} = $val;
285
				}
308 286
			}
309 287
		}
310
	}
311
	// Get page info
312
	$query_page = $database->query("SELECT link FROM ".TABLE_PREFIX."pages WHERE page_id = '".PAGE_ID."'");
313
	if($query_page->numRows() > 0)
314
    {
315
		$page = $query_page->fetchRow();
316
		$page_link = page_link($page['link']);
317
		if(isset($_GET['p']) AND $position > 0)
318
        {
319
			$page_link .= '?p='.$_GET['p'];
288
// Get page info
289
		$query_page = $database->query("SELECT link FROM ".TABLE_PREFIX."pages WHERE page_id = '".PAGE_ID."'");
290
		if($query_page->numRows() > 0) {
291
			$page = $query_page->fetchRow();
292
			$page_link = page_link($page['link']);
293
			if(isset($_GET['p']) AND $position > 0) {
294
				$page_link .= '?p='.$_GET['p'];
295
			}
296
			if(isset($_GET['g']) AND is_numeric($_GET['g'])) {
297
				if(isset($_GET['p']) AND $position > 0) { $page_link .= '&amp;'; } else { $page_link .= '?'; }
298
				$page_link .= 'g='.$_GET['g'];
299
			}
300
		} else {
301
			exit($MESSAGE['PAGES_NOT_FOUND']);
320 302
		}
321
		if(isset($_GET['g']) AND is_numeric($_GET['g']))
322
        {
323
			if(isset($_GET['p']) AND $position > 0) { $page_link .= '&amp;'; } else { $page_link .= '?'; }
324
			$page_link .= 'g='.$_GET['g'];
325
		}
326
	} else {
327
		exit($MESSAGE['PAGES']['NOT_FOUND']);
328
	}
329 303

  
330
	// Get post info
331
	$t = time();
332
	$query_post = $database->query("SELECT * FROM ".TABLE_PREFIX."mod_news_posts
333
		WHERE post_id = '".$post_id."' AND active = '1'
334
		AND (published_when = '0' OR published_when <= $t) AND (published_until = 0 OR published_until >= $t)");
304
		// Get post info
305
		$t = time();
306
		$query_post = $database->query("SELECT * FROM ".TABLE_PREFIX."mod_news_posts
307
			WHERE post_id = '".$post_id."' AND active = '1'
308
			AND (published_when = '0' OR published_when <= $t) AND (published_until = 0 OR published_until >= $t)");
335 309

  
336
	if($query_post->numRows() > 0)
337
    {
338
		$post = $query_post->fetchRow();
339
		if(isset($groups[$post['group_id']]['active']) AND $groups[$post['group_id']]['active'] != false)
340
        { // Make sure parent group is active
341
			$uid = $post['posted_by']; // User who last modified the post
342
			// Workout date and time of last modified post
343
			if ($post['published_when'] === '0') $post['published_when'] = time();
344
			if ($post['published_when'] > $post['posted_when'])
345
            {
346
				$post_date = date(DATE_FORMAT, $post['published_when']+TIMEZONE);
347
				$post_time = date(TIME_FORMAT, $post['published_when']+TIMEZONE);
348
			}
349
            else
350
            {
351
				$post_date = date(DATE_FORMAT, $post['posted_when']+TIMEZONE);
352
				$post_time = date(TIME_FORMAT, $post['posted_when']+TIMEZONE);
353
			}
310
		if($query_post->numRows() > 0)
311
		{
312
			$post = $query_post->fetchRow();
313
			if(isset($groups[$post['group_id']]['active']) AND $groups[$post['group_id']]['active'] != false)
314
			{ // Make sure parent group is active
315
				$uid = $post['posted_by']; // User who last modified the post
316
				// Workout date and time of last modified post
317
				if ($post['published_when'] === '0'){ $post['published_when'] = time();}
318
				if ($post['published_when'] > $post['posted_when']) {
319
					$post_date = date(DATE_FORMAT, $post['published_when']+TIMEZONE);
320
					$post_time = date(TIME_FORMAT, $post['published_when']+TIMEZONE);
321
				} else {
322
					$post_date = date(DATE_FORMAT, $post['posted_when']+TIMEZONE);
323
					$post_time = date(TIME_FORMAT, $post['posted_when']+TIMEZONE);
324
				}
354 325

  
355
			$publ_date = date(DATE_FORMAT,$post['published_when']);
356
			$publ_time = date(TIME_FORMAT,$post['published_when']);
326
				$publ_date = date(DATE_FORMAT,$post['published_when']+TIMEZONE);
327
				$publ_time = date(TIME_FORMAT,$post['published_when']+TIMEZONE);
357 328

  
358
			// Work-out the post link
359
			$post_link = page_link($post['link']);
329
				// Work-out the post link
330
				$post_link = page_link($post['link']);
360 331

  
361
			$post_link_path = str_replace(WB_URL, WB_PATH,$post_link);
362
			$create_date = date(DATE_FORMAT, $post['created_when']);
363
			$create_time = date(TIME_FORMAT, $post['created_when']);
364
			// Get group id, title, and image
365
			$group_id = $post['group_id'];
366
			$group_title = $groups[$group_id]['title'];
367
			$group_image = $groups[$group_id]['image'];
368
			$display_image = ($group_image == '') ? "none" : "inherit";
369
			$display_group = ($group_id == 0) ? 'none' : 'inherit';
332
				$post_link_path = str_replace(WB_URL, WB_PATH,$post_link);
333
				$create_date = date(DATE_FORMAT, $post['created_when']+TIMEZONE);
334
				$create_time = date(TIME_FORMAT, $post['created_when']+TIMEZONE);
335
				// Get group id, title, and image
336
				$group_id = $post['group_id'];
337
				$group_title = $groups[$group_id]['title'];
338
				$group_image = $groups[$group_id]['image'];
339
				$display_image = ($group_image == '') ? "none" : "inherit";
340
				$display_group = ($group_id == 0) ? 'none' : 'inherit';
370 341

  
371
			if ($group_image != "") $group_image= "<img src='".$group_image."' alt='".$group_title."' />";
342
				if ($group_image != "") $group_image= "<img src='".$group_image."' alt='".$group_title."' />";
372 343

  
373
			$vars = array('[PAGE_TITLE]', '[GROUP_ID]', '[GROUP_TITLE]', '[GROUP_IMAGE]', '[DISPLAY_GROUP]', '[DISPLAY_IMAGE]', '[TITLE]', '[SHORT]', '[BACK]', '[TEXT_BACK]', '[TEXT_LAST_CHANGED]', '[MODI_DATE]', '[TEXT_AT]', '[MODI_TIME]', '[CREATED_DATE]', '[CREATED_TIME]', '[PUBLISHED_DATE]', '[PUBLISHED_TIME]', '[TEXT_POSTED_BY]', '[TEXT_ON]', '[USER_ID]', '[USERNAME]', '[DISPLAY_NAME]', '[EMAIL]');
374
			$post_short=$post['content_short'];
375
			if(isset($users[$uid]['username']) AND $users[$uid]['username'] != '')
376
            {
377
				$values = array(PAGE_TITLE, $group_id, $group_title, $group_image, $display_group, $display_image, $post['title'], $post_short, $page_link, $MOD_NEWS['TEXT_BACK'], $MOD_NEWS['TEXT_LAST_CHANGED'],$post_date, $MOD_NEWS['TEXT_AT'], $post_time, $create_date, $create_time, $publ_date, $publ_time, $MOD_NEWS['TEXT_POSTED_BY'], $MOD_NEWS['TEXT_ON'], $uid, $users[$uid]['username'], $users[$uid]['display_name'], $users[$uid]['email']);
378
			} else {
379
				$values = array(PAGE_TITLE, $group_id, $group_title, $group_image, $display_group, $display_image, $post['title'], $post_short, $page_link, $MOD_NEWS['TEXT_BACK'], $MOD_NEWS['TEXT_LAST_CHANGED'], $post_date, $MOD_NEWS['TEXT_AT'], $post_time, $create_date, $create_time, $publ_date, $publ_time, $MOD_NEWS['TEXT_POSTED_BY'], $MOD_NEWS['TEXT_ON'], '', '', '', '');
344
				$vars = array('[PAGE_TITLE]', '[GROUP_ID]', '[GROUP_TITLE]', '[GROUP_IMAGE]', '[DISPLAY_GROUP]', '[DISPLAY_IMAGE]', '[TITLE]', '[SHORT]', '[BACK]', '[TEXT_BACK]', '[TEXT_LAST_CHANGED]', '[MODI_DATE]', '[TEXT_AT]', '[MODI_TIME]', '[CREATED_DATE]', '[CREATED_TIME]', '[PUBLISHED_DATE]', '[PUBLISHED_TIME]', '[TEXT_POSTED_BY]', '[TEXT_ON]', '[USER_ID]', '[USERNAME]', '[DISPLAY_NAME]', '[EMAIL]');
345
				$post_short=$post['content_short'];
346
				if(isset($users[$uid]['username']) AND $users[$uid]['username'] != '') {
347
					$values = array(PAGE_TITLE, $group_id, $group_title, $group_image, $display_group, $display_image, $post['title'], $post_short, $page_link, $MOD_NEWS['TEXT_BACK'], $MOD_NEWS['TEXT_LAST_CHANGED'],$post_date, $MOD_NEWS['TEXT_AT'], $post_time, $create_date, $create_time, $publ_date, $publ_time, $MOD_NEWS['TEXT_POSTED_BY'], $MOD_NEWS['TEXT_ON'], $uid, $users[$uid]['username'], $users[$uid]['display_name'], $users[$uid]['email']);
348
				} else {
349
					$values = array(PAGE_TITLE, $group_id, $group_title, $group_image, $display_group, $display_image, $post['title'], $post_short, $page_link, $MOD_NEWS['TEXT_BACK'], $MOD_NEWS['TEXT_LAST_CHANGED'], $post_date, $MOD_NEWS['TEXT_AT'], $post_time, $create_date, $create_time, $publ_date, $publ_time, $MOD_NEWS['TEXT_POSTED_BY'], $MOD_NEWS['TEXT_ON'], '', '', '', '');
350
				}
351
				// $post_long = ($post['content_long']);
352
				$post_long = ($post['content_long'] != '') ? $post['content_long'] : $post['content_short'];
380 353
			}
381
			// $post_long = ($post['content_long']);
382
			$post_long = ($post['content_long'] != '') ? $post['content_long'] : $post['content_short'];
354
		} else {
355
				$wb->print_error($MESSAGE['FRONTEND_SORRY_NO_ACTIVE_SECTIONS'], 'view.php', false);
383 356
		}
384
	} else {
385
	    	$wb->print_error($MESSAGE['FRONTEND']['SORRY_NO_ACTIVE_SECTIONS'], 'view.php', false);
386
	}
387 357

  
388
	// Print post header
389
	print str_replace($vars, $values, $setting_post_header);
390
	// Print long
391
	print $post_long;
358
		// Print post header
359
		print str_replace($vars, $values, $setting_post_header);
360
		// Print long
361
		print $post_long;
392 362

  
393
	// Print post footer
394
	print str_replace($vars, $values, $setting_post_footer);
363
		// Print post footer
364
		print str_replace($vars, $values, $setting_post_footer);
395 365

  
396
	// Show comments section if we have to
397
	if(($post['commenting'] == 'private' AND isset($wb) AND $wb->is_authenticated() == true) OR $post['commenting'] == 'public')
398
    {
399
		// Print comments header
400
		$vars = array('[ADD_COMMENT_URL]','[TEXT_COMMENTS]');
401
		// $pid = $admin->getIDKEY(POST_ID);
402
		$values = array(WB_URL.'/modules/news/comment.php?post_id='.$post_id.'&amp;section_id='.$section_id, $MOD_NEWS['TEXT_COMMENTS']);
403
		print str_replace($vars, $values, $setting_comments_header);
366
		// Show comments section if we have to
367
		if(($post['commenting'] == 'private' AND isset($wb) AND $wb->is_authenticated() == true) OR $post['commenting'] == 'public')
368
		{
369
			// Print comments header
370
			$vars = array('[ADD_COMMENT_URL]','[TEXT_COMMENTS]');
371
			// $pid = $admin->getIDKEY(POST_ID);
372
			$values = array(WB_URL.'/modules/news/comment.php?post_id='.$post_id.'&amp;section_id='.$section_id, $MOD_NEWS['TEXT_COMMENTS']);
373
			print str_replace($vars, $values, $setting_comments_header);
404 374

  
405
		// Query for comments
406
		$query_comments = $database->query("SELECT title,comment,commented_when,commented_by FROM ".TABLE_PREFIX."mod_news_comments WHERE post_id = '".$post_id."' ORDER BY commented_when ASC");
407
		if($query_comments->numRows() > 0)
408
        {
409
			while( false != ($comment = $query_comments->fetchRow()) )
410
            {
411
				// Display Comments without slashes, but with new-line characters
412
				$comment['comment'] = nl2br($wb->strip_slashes($comment['comment']));
413
				$comment['title'] = $wb->strip_slashes($comment['title']);
414
				// Print comments loop
415
				$commented_date = date(DATE_FORMAT, $comment['commented_when']+TIMEZONE);
416
				$commented_time = date(TIME_FORMAT, $comment['commented_when']+TIMEZONE);
417
				$uid = $comment['commented_by'];
375
			// Query for comments
376
			$query_comments = $database->query("SELECT title,comment,commented_when,commented_by FROM ".TABLE_PREFIX."mod_news_comments WHERE post_id = '".$post_id."' ORDER BY commented_when ASC");
377
			if($query_comments->numRows() > 0)
378
			{
379
				while( false != ($comment = $query_comments->fetchRow()) )
380
				{
381
					// Display Comments without slashes, but with new-line characters
382
					$comment['comment'] = nl2br($wb->strip_slashes($comment['comment']));
383
					$comment['title'] = $wb->strip_slashes($comment['title']);
384
					// Print comments loop
385
					$commented_date = date(DATE_FORMAT, $comment['commented_when']+TIMEZONE);
386
					$commented_time = date(TIME_FORMAT, $comment['commented_when']+TIMEZONE);
387
					$uid = $comment['commented_by'];
388
					$vars = array('[TITLE]','[COMMENT]','[TEXT_ON]','[DATE]','[TEXT_AT]','[TIME]','[TEXT_BY]','[USER_ID]','[USERNAME]','[DISPLAY_NAME]', '[EMAIL]');
389
					if(isset($users[$uid]['username']) AND $users[$uid]['username'] != '') {
390
						$values = array(($comment['title']), ($comment['comment']), $MOD_NEWS['TEXT_ON'], $commented_date, $MOD_NEWS['TEXT_AT'], $commented_time, $MOD_NEWS['TEXT_BY'], $uid, ($users[$uid]['username']), ($users[$uid]['display_name']), ($users[$uid]['email']));
391
					} else {
392
						$values = array(($comment['title']), ($comment['comment']), $MOD_NEWS['TEXT_ON'], $commented_date, $MOD_NEWS['TEXT_AT'], $commented_time, $MOD_NEWS['TEXT_BY'], '0', strtolower($TEXT['UNKNOWN']), $TEXT['UNKNOWN'], '');
393
					}
394
					print str_replace($vars, $values, $setting_comments_loop);
395
				}
396
			} else {
397
				// Say no comments found
398
				$content = '';
418 399
				$vars = array('[TITLE]','[COMMENT]','[TEXT_ON]','[DATE]','[TEXT_AT]','[TIME]','[TEXT_BY]','[USER_ID]','[USERNAME]','[DISPLAY_NAME]', '[EMAIL]');
419
				if(isset($users[$uid]['username']) AND $users[$uid]['username'] != '')
420
                {
421
					$values = array(($comment['title']), ($comment['comment']), $MOD_NEWS['TEXT_ON'], $commented_date, $MOD_NEWS['TEXT_AT'], $commented_time, $MOD_NEWS['TEXT_BY'], $uid, ($users[$uid]['username']), ($users[$uid]['display_name']), ($users[$uid]['email']));
422
				} else {
423
					$values = array(($comment['title']), ($comment['comment']), $MOD_NEWS['TEXT_ON'], $commented_date, $MOD_NEWS['TEXT_AT'], $commented_time, $MOD_NEWS['TEXT_BY'], '0', strtolower($TEXT['UNKNOWN']), $TEXT['UNKNOWN'], '');
424
				}
400
				$values = array( '', $MOD_NEWS['NO_COMMENT_FOUND'], '', '', '', '', '', '', '', '');
425 401
				print str_replace($vars, $values, $setting_comments_loop);
426 402
			}
427
		} else {
428
			// Say no comments found
429
			$content = '';
430
			$vars = array('[TITLE]','[COMMENT]','[TEXT_ON]','[DATE]','[TEXT_AT]','[TIME]','[TEXT_BY]','[USER_ID]','[USERNAME]','[DISPLAY_NAME]', '[EMAIL]');
431
			$values = array( '', $MOD_NEWS['NO_COMMENT_FOUND'], '', '', '', '', '', '', '', '');
432
			print str_replace($vars, $values, $setting_comments_loop);
403

  
404
			// Print comments footer
405
			$vars = array('[ADD_COMMENT_URL]','[TEXT_ADD_COMMENT]');
406
			$values = array(WB_URL.'/modules/news/comment.php?post_id='.$post_id.'&amp;section_id='.$section_id, $MOD_NEWS['TEXT_ADD_COMMENT']);
407
			print str_replace($vars, $values, $setting_comments_footer);
408

  
433 409
		}
434 410

  
435
		// Print comments footer
436
		$vars = array('[ADD_COMMENT_URL]','[TEXT_ADD_COMMENT]');
437
		$values = array(WB_URL.'/modules/news/comment.php?post_id='.$post_id.'&amp;section_id='.$section_id, $MOD_NEWS['TEXT_ADD_COMMENT']);
438
		print str_replace($vars, $values, $setting_comments_footer);
439

  
440 411
	}
441 412

  
442
    }
443

  
444
	if(ENABLED_ASP)
445
    {
413
	if(ENABLED_ASP) {
446 414
		$_SESSION['comes_from_view'] = $post_id;
447 415
		$_SESSION['comes_from_view_time'] = time();
448 416
	}
branches/2.8.x/wb/modules/news/upgrade.php
37 37

  
38 38
/* -------------------------------------------------------- */
39 39
// Must include code to stop this file being accessed directly
40
require_once( dirname(dirname(dirname(__FILE__))).'/framework/globalExceptionHandler.php');
41
if(!defined('WB_PATH')) { throw new IllegalFileException(); }
40
if(!defined('WB_URL')) {
41
	require_once(dirname(dirname(dirname(__FILE__))).'/framework/globalExceptionHandler.php');
42
	throw new IllegalFileException();
43
}
44

  
45

  
42 46
/* -------------------------------------------------------- */
43 47
/* **** START UPGRADE ******************************************************* */
44
if(!function_exists('mod_news_Upgrade'))
45
{
46
	function mod_news_Upgrade()
48
//if(!function_exists('mod_news_Upgrade'))
49
//{
50
	function mod_news_Upgrade($bDebug=false)
47 51
	{
48
		global $database, $admin, $MESSAGE,$bDebugModus;
49
		$msg = array();
52
		global $OK ,$FAIL;
53
		$database=WbDatabase::getInstance();
54
		$mLang = Translate::getinstance();
55
		$sModName = basename(dirname(__FILE__));
56
		$mLang->enableAddon('modules\\'.$sModName);
57
		$msg    = array();
50 58
		$callingScript = $_SERVER["SCRIPT_NAME"];
51 59
// check if upgrade startet by upgrade-script to echo a message
52 60
		$tmp = 'upgrade-script.php';
53 61
		$globalStarted = substr_compare($callingScript, $tmp,(0-strlen($tmp)),strlen($tmp)) === 0;
54
		/**
55
		 * check database engine
56
		 */
62
// check for missing tables, if true stop the upgrade
57 63
		$aTable = array('mod_news_posts','mod_news_groups','mod_news_comments','mod_news_settings');
58
		 for($x=0; $x<sizeof($aTable);$x++) {
59
			if(($sOldType = $database->getTableEngine(TABLE_PREFIX.$aTable[$x]))) {
60
				if(('myisam' != strtolower($sOldType))) {
61
					if(!$database->query('ALTER TABLE `'.TABLE_PREFIX.$aTable[$x].'` Engine = \'MyISAM\' ')) {
62
						$msg[] = $database->get_error();
63
					} else{
64
		                $msg[] = 'TABLE `'.TABLE_PREFIX.$aTable[$x].'` changed to Engine = \'MyISAM\'';
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) {
69
				echo '<strong>'.implode('<br />',$msg).'</strong><br />';
70
			}
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";
65 87
					}
66 88
				} else {
67
							 $msg[] = 'TABLE `'.TABLE_PREFIX.$aTable[$x].'` has Engine = \'MyISAM\'';
89
					$msg[] = $database->get_error()." $FAIL";
68 90
				}
69
			} else {
70
				$msg[] = $database->get_error();
71 91
			}
72
		}
73 92

  
74
		$sPagesPath = WB_PATH.PAGES_DIRECTORY;
75
		$sPostsPath = $sPagesPath.'/posts';
93
			$sPagesPath = WB_PATH.PAGES_DIRECTORY;
94
			$sPostsPath = $sPagesPath.'/posts';
76 95
	// create /posts/ - directory if not exists
77
		if(is_writable($sPagesPath)) {
78
			if(!($bRetval = is_dir($sPostsPath))) {
79
				$iOldUmask = umask(0) ;
80
				// sanitize directory mode to 'o+rwx/g+x/u+x' and create path
81
				$bRetval = mkdir($sPostsPath, (OCTAL_DIR_MODE |0711), true); 
82
				umask($iOldUmask);
83
			}
84
			if($bRetval) {
85
				$msg[] = 'Directory "'.PAGES_DIRECTORY.'/posts/" already exists or created.';
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);
102
				}
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
				}
86 108
			}else {
87
				$msg[] = ($MESSAGE['PAGES_CANNOT_CREATE_ACCESS_FILE']);
109
					$msg[] = ($mLang->MESSAGE_PAGES_CANNOT_CREATE_ACCESS_FILE)." $FAIL";
88 110
			}
89
		}else {
90
				$msg[] = ($MESSAGE['PAGES_CANNOT_CREATE_ACCESS_FILE']);
91
		}
92 111
	// check if new fields must be added
93
		$doImportDate = true;
94
		if(!$database->field_exists(TABLE_PREFIX.'mod_news_posts', 'created_when')) {
95
			if(!$database->field_add(TABLE_PREFIX.'mod_news_posts', 'created_when',
96
			                        'INT NOT NULL DEFAULT \'0\' AFTER `commenting`')) {
97
					$msg[] = $MESSAGE['RECORD_MODIFIED_FAILED'];
98
			} else {
99
				$msg[] = 'TABLE `'.TABLE_PREFIX.'mod_news_posts` Datafield `created_when` 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; 
100 123
			}
101
		} else { 
102
			$msg[] = 'TABLE `'.TABLE_PREFIX.'mod_news_posts` Datafield `created_when` already exists.';
103
			$doImportDate = false; 
104
		}
105 124

  
106
		if(!$database->field_exists(TABLE_PREFIX.'mod_news_posts', 'created_by')) {
107
			if(!$database->field_add(TABLE_PREFIX.'mod_news_posts', 'created_by',
108
			                        'INT NOT NULL DEFAULT \'0\' AFTER `created_when`')) {
109
				$msg[] = $MESSAGE['RECORD_MODIFIED_FAILED'];
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; 
110 135
			}
111
		} else { 
112
			$msg[] = 'TABLE `'.TABLE_PREFIX.'mod_news_posts` Datafield `created_by` already exists.';
113
			$doImportDate = false; 
114
		}
115 136
 	// preset new fields `created_by` and `created_by` from existing values
116
		if($doImportDate) {
117
			$sql  = 'UPDATE `'.TABLE_PREFIX.'mod_news_posts` ';
118
			$sql .= 'SET `created_by`=`posted_by`, `created_when`=`posted_when`';
119
			$database->query($sql);
120
		}
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);
141
			}
121 142

  
122 143
	/**
123 144
	 * rebuild news post folder
124 145
	 */
125 146
//	$array = rebuildFolderProtectFile($sPostsPath);
126
	// now iterate through all existing accessfiles,
127
	// write its creation date into database
128
		$oDir = new DirectoryIterator($sPostsPath);
129
		$count = 0;
130
		foreach ($oDir as $fileinfo)
131
		{
132
			$fileName = $fileinfo->getFilename();
133
			if((!$fileinfo->isDot()) &&
134
			   ($fileName != 'index.php') &&
135
			   (substr_compare($fileName,PAGE_EXTENSION,(0-strlen(PAGE_EXTENSION)),strlen(PAGE_EXTENSION)) === 0)
136
			  )
137
			{
138
			// save creation date from old accessfile
139
				if($doImportDate) {
140
					$link = '/posts/'.preg_replace('/'.preg_quote(PAGE_EXTENSION).'$/i', '', $fileinfo->getFilename());
141
					$sql  = 'UPDATE `'.TABLE_PREFIX.'mod_news_posts` ';
142
					$sql .= 'SET `created_when`='.$fileinfo->getMTime().' ';
143
					$sql .= 'WHERE `link`=\''.$link.'\'';
144
					if($database->query($sql)) {
145
						// delete old access file
146
						unlink($fileinfo->getPathname());
147
						$count++;
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
						}
148 172
					}
149 173
				}
174
				unset($oDir);
150 175
			}
151
		}
152
		unset($oDir);
153

  
154
		if($count > 0) {
155
			$msg[] = 'Save date of creation from '.$count.' old accessfiles and delete these files.';
156
		}
176
			if($count > 0) {
177
				$msg[] = 'Save date of creation from '.$count.' old accessfiles and delete these files.'." $OK";
178
			}
157 179
// ************************************************
158
	// Check the validity of 'create-file-timestamp' and balance against 'posted-timestamp'
159
		$sql  = 'UPDATE `'.TABLE_PREFIX.'mod_news_posts` ';
160
		$sql .= 'SET `created_when`=`published_when` ';
161
		$sql .= 'WHERE `published_when`<`created_when`';
162
		$database->query($sql);
163
		$sql  = 'UPDATE `'.TABLE_PREFIX.'mod_news_posts` ';
164
		$sql .= 'SET `created_when`=`posted_when` ';
165
		$sql .= 'WHERE `published_when`=0 OR `published_when`>`posted_when`';
166
		$database->query($sql);
180
		// Check the validity of 'create-file-timestamp' and balance against 'posted-timestamp'
181
			$sql  = 'UPDATE `'.$database->TablePrefix.'mod_news_posts` ';
182
			$sql .= 'SET `created_when`=`published_when` ';
183
			$sql .= 'WHERE `published_when`<`created_when`';
184
			$database->query($sql);
185
			$sql  = 'UPDATE `'.$database->TablePrefix.'mod_news_posts` ';
186
			$sql .= 'SET `created_when`=`posted_when` ';
187
			$sql .= 'WHERE `published_when`=0 OR `published_when`>`posted_when`';
188
			$database->query($sql);
167 189
// ************************************************
168 190

  
169
        // only for upgrade-script
170
        if($globalStarted) {
171
            if($bDebugModus) {
172
                foreach($msg as $title) {
173
                    echo '<strong>'.$title.'</strong><br />';
174
                }
175
            }
176
        } 
177
        return ( ($globalStarted==true ) ? $globalStarted : $msg);
191
			// only for upgrade-script
192
			if($globalStarted) {
193
				if($bDebug) {
194
					echo '<strong>'.implode('<br />',$msg).'</strong><br />';
195
				}
196
			} 
197
		}
198
		$msg[] = "News upgrade successfull finished $OK";
199
		if($globalStarted) {
200
			echo "<strong>News upgrade successfull finished $OK</strong><br />";
201
		}
202
		$mLang->disableAddon();
203
		return ( ($globalStarted==true ) ? $globalStarted : $msg);
178 204
	}
179
}
205
//}
180 206
// end mod_news_Upgrade
181 207

  
182 208
// ------------------------------------
183 209
// only show if manuell upgrade
184
if( is_array($msg = mod_news_Upgrade()) ) {
210
$bDebugModus = ((isset($bDebugModus)) ? $bDebugModus : false);
211
// Don't show the messages twice
212
if( is_array($msg = mod_news_Upgrade($bDebugModus)) ) {
185 213
	$sModulReorg = 'm_news_Reorg';
186 214
	if(class_exists($sModulReorg)) {
187 215
		$oReorg = new $sModulReorg();
188 216
		$msg = array_merge($msg, $oReorg->execute() ); // show details
189
//		$msg = array_merge($msg,(new $sModulReorg())->execute()); // show details
190 217
	}
191
    foreach($msg as $title) {
192
        echo '<strong>'.$title.'</strong><br />';
193
    }
194
	echo '<strong>News upgrade finished </strong><br /><br>';
218
	echo '<strong>'.implode('<br />',$msg).'</strong><br />';
195 219
}
196 220
/* **** END UPGRADE ********************************************************* */
197 221

  
branches/2.8.x/wb/modules/news/install.php
19 19
require_once( dirname(dirname(dirname(__FILE__))).'/framework/globalExceptionHandler.php');
20 20
if(!defined('WB_PATH')) { throw new IllegalFileException(); }
21 21
/* -------------------------------------------------------- */
22
	$sDefaultSql = dirname(__FILE__).'/install.sql';
22
	$sDefaultSql = dirname(__FILE__).'/sql/mod_news.sql';
23 23
	if (is_readable($sDefaultSql)) {
24 24
// create needet database tables and set default records
25
		if ($database->SqlImport($sDefaultSql, TABLE_PREFIX)) {
25
		if ($database->SqlImport($sDefaultSql, '',false)) {
26 26
// Make news post access files dir
27 27
			require_once(WB_PATH.'/framework/functions.php');
28 28
			if(make_dir(WB_PATH.PAGES_DIRECTORY.'/posts')) {
branches/2.8.x/wb/modules/news/sql/mod_news.sql
1
-- phpMyAdmin SQL Dump
2
-- Erstellungszeit: 20. Januar 2012 um 12:37
3
-- Server Version: 5.1.41
4
SET SQL_MODE="NO_AUTO_VALUE_ON_ZERO";
5
-- --------------------------------------------------------
6
-- Database structure for module 'news'
7
--
8
-- Replacements: {TABLE_PREFIX}, {TABLE_ENGINE}, {TABLE_COLLATION}
9
--
10
-- --------------------------------------------------------
11
--
12
-- Tabellenstruktur für Tabelle `mod_news_comments`
13
--
14
DROP TABLE IF EXISTS `{TABLE_PREFIX}mod_news_comments`;
15
CREATE TABLE IF NOT EXISTS `{TABLE_PREFIX}mod_news_comments` (
16
  `comment_id` int(11) NOT NULL AUTO_INCREMENT,
17
  `section_id` int(11) NOT NULL DEFAULT '0',
18
  `page_id` int(11) NOT NULL DEFAULT '0',
19
  `post_id` int(11) NOT NULL DEFAULT '0',
20
  `title` varchar(255){TABLE_COLLATION} NOT NULL,
21
  `comment` text{TABLE_COLLATION} NOT NULL,
22
  `commented_when` int(11) NOT NULL DEFAULT '0',
23
  `commented_by` int(11) NOT NULL DEFAULT '0',
24
  PRIMARY KEY (`comment_id`)
25
){TABLE_ENGINE};
26
-- --------------------------------------------------------
27
--
28
-- Tabellenstruktur für Tabelle `mod_news_groups`
29
--
30
DROP TABLE IF EXISTS `{TABLE_PREFIX}mod_news_groups`;
31
CREATE TABLE IF NOT EXISTS `{TABLE_PREFIX}mod_news_groups` (
32
  `group_id` int(11) NOT NULL AUTO_INCREMENT,
33
  `section_id` int(11) NOT NULL DEFAULT '0',
34
  `page_id` int(11) NOT NULL DEFAULT '0',
35
  `active` int(11) NOT NULL DEFAULT '0',
36
  `position` int(11) NOT NULL DEFAULT '0',
37
  `title` varchar(255){TABLE_COLLATION} NOT NULL,
38
  PRIMARY KEY (`group_id`)
39
){TABLE_ENGINE};
40
-- --------------------------------------------------------
41
--
42
-- Tabellenstruktur für Tabelle `mod_news_posts`
43
--
44
DROP TABLE IF EXISTS `{TABLE_PREFIX}mod_news_posts`;
45
CREATE TABLE IF NOT EXISTS `{TABLE_PREFIX}mod_news_posts` (
46
  `post_id` int(11) NOT NULL AUTO_INCREMENT,
47
  `section_id` int(11) NOT NULL DEFAULT '0',
48
  `page_id` int(11) NOT NULL DEFAULT '0',
49
  `group_id` int(11) NOT NULL DEFAULT '0',
50
  `active` int(11) NOT NULL DEFAULT '0',
51
  `position` int(11) NOT NULL DEFAULT '0',
52
  `title` varchar(255){TABLE_COLLATION} NOT NULL,
53
  `link` text{TABLE_COLLATION} NOT NULL,
54
  `content_short` text{TABLE_COLLATION} NOT NULL,
55
  `content_long` text{TABLE_COLLATION} NOT NULL,
56
  `commenting` varchar(7){TABLE_COLLATION} NOT NULL,
57
  `created_when` int(11) NOT NULL,
58
  `created_by` int(11) NOT NULL,
59
  `published_when` int(11) NOT NULL DEFAULT '0',
60
  `published_until` int(11) NOT NULL DEFAULT '0',
61
  `posted_when` int(11) NOT NULL DEFAULT '0',
62
  `posted_by` int(11) NOT NULL DEFAULT '0',
63
  PRIMARY KEY (`post_id`)
64
){TABLE_ENGINE};
65
-- --------------------------------------------------------
66
--
67
-- Tabellenstruktur für Tabelle `mod_news_settings`
68
--
69
DROP TABLE IF EXISTS `{TABLE_PREFIX}mod_news_settings`;
70
CREATE TABLE IF NOT EXISTS `{TABLE_PREFIX}mod_news_settings` (
71
  `section_id` int(11) NOT NULL DEFAULT '0',
72
  `page_id` int(11) NOT NULL DEFAULT '0',
73
  `header` text{TABLE_COLLATION} NOT NULL,
74
  `post_loop` text{TABLE_COLLATION} NOT NULL,
75
  `footer` text{TABLE_COLLATION} NOT NULL,
76
  `posts_per_page` int(11) NOT NULL DEFAULT '0',
77
  `post_header` text{TABLE_COLLATION} NOT NULL,
78
  `post_footer` text{TABLE_COLLATION} NOT NULL,
79
  `comments_header` text{TABLE_COLLATION} NOT NULL,
80
  `comments_loop` text{TABLE_COLLATION} NOT NULL,
81
  `comments_footer` text{TABLE_COLLATION} NOT NULL,
82
  `comments_page` text{TABLE_COLLATION} NOT NULL,
83
  `commenting` varchar(7){TABLE_COLLATION} NOT NULL,
84
  `resize` int(11) NOT NULL DEFAULT '0',
85
  `use_captcha` int(11) NOT NULL DEFAULT '0',
86
  PRIMARY KEY (`section_id`)
87
){TABLE_ENGINE};
88
-- EndOfFile

Also available in: Unified diff