1 |
1425
|
Luisehahne
|
<?php
|
2 |
|
|
/**
|
3 |
|
|
*
|
4 |
1538
|
Luisehahne
|
* @category modules
|
5 |
|
|
* @package news
|
6 |
|
|
* @author WebsiteBaker Project
|
7 |
1895
|
Luisehahne
|
* @copyright 2009-2013, WebsiteBaker Org. e.V.
|
8 |
|
|
* @link http://www.websitebaker2.org/
|
9 |
1425
|
Luisehahne
|
* @license http://www.gnu.org/licenses/gpl.html
|
10 |
1538
|
Luisehahne
|
* @platform WebsiteBaker 2.8.x
|
11 |
|
|
* @requirements PHP 5.2.2 and higher
|
12 |
1425
|
Luisehahne
|
* @version $Id$
|
13 |
1895
|
Luisehahne
|
* @filesource $HeadURL$
|
14 |
1538
|
Luisehahne
|
* @lastmodified $Date$
|
15 |
1425
|
Luisehahne
|
*
|
16 |
|
|
*/
|
17 |
|
|
|
18 |
1538
|
Luisehahne
|
/* -------------------------------------------------------- */
|
19 |
1895
|
Luisehahne
|
// 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 |
1538
|
Luisehahne
|
}
|
24 |
|
|
/* -------------------------------------------------------- */
|
25 |
1457
|
Luisehahne
|
global $post_id, $post_section,$TEXT,$MESSAGE;
|
26 |
1918
|
Luisehahne
|
$sMediaUrl = WB_URL.MEDIA_DIRECTORY;
|
27 |
1425
|
Luisehahne
|
|
28 |
|
|
// load module language file
|
29 |
|
|
$lang = (dirname(__FILE__)) . '/languages/' . LANGUAGE . '.php';
|
30 |
|
|
require_once(!file_exists($lang) ? (dirname(__FILE__)) . '/languages/EN.php' : $lang );
|
31 |
|
|
|
32 |
|
|
//overwrite php.ini on Apache servers for valid SESSION ID Separator
|
33 |
1895
|
Luisehahne
|
if(function_exists('ini_set')) {
|
34 |
1425
|
Luisehahne
|
ini_set('arg_separator.output', '&');
|
35 |
|
|
}
|
36 |
|
|
|
37 |
|
|
// Check if there is a start point defined
|
38 |
1457
|
Luisehahne
|
$position = ( isset($_GET['p']) ? intval($_GET['p']) : 0);
|
39 |
1425
|
Luisehahne
|
// Get user's username, display name, email, and id - needed for insertion into post info
|
40 |
|
|
$users = array();
|
41 |
1457
|
Luisehahne
|
$sql = 'SELECT `user_id`,`username`,`display_name`,`email` FROM `'.TABLE_PREFIX.'users`';
|
42 |
|
|
if( ($resUsers = $database->query($sql)) ) {
|
43 |
|
|
while( $recUser = $resUsers->fetchRow() ) {
|
44 |
|
|
$users[$recUser['user_id']] = $recUser;
|
45 |
1425
|
Luisehahne
|
}
|
46 |
|
|
}
|
47 |
|
|
// Get groups (title, if they are active, and their image [if one has been uploaded])
|
48 |
|
|
if (isset($groups))
|
49 |
|
|
{
|
50 |
1895
|
Luisehahne
|
unset($groups);
|
51 |
1425
|
Luisehahne
|
}
|
52 |
|
|
|
53 |
|
|
$groups[0]['title'] = '';
|
54 |
|
|
$groups[0]['active'] = true;
|
55 |
|
|
$groups[0]['image'] = '';
|
56 |
|
|
|
57 |
|
|
$query_users = $database->query("SELECT group_id,title,active FROM ".TABLE_PREFIX."mod_news_groups WHERE section_id = '$section_id' ORDER BY position ASC");
|
58 |
1918
|
Luisehahne
|
if($query_users->numRows() > 0){
|
59 |
1457
|
Luisehahne
|
|
60 |
1425
|
Luisehahne
|
while( false != ($group = $query_users->fetchRow()) )
|
61 |
1895
|
Luisehahne
|
{
|
62 |
1425
|
Luisehahne
|
// Insert user info into users array
|
63 |
|
|
$group_id = $group['group_id'];
|
64 |
|
|
$groups[$group_id]['title'] = ($group['title']);
|
65 |
|
|
$groups[$group_id]['active'] = $group['active'];
|
66 |
1895
|
Luisehahne
|
if(file_exists(WB_PATH.MEDIA_DIRECTORY.'/.news/image'.$group_id.'.jpg')) {
|
67 |
1425
|
Luisehahne
|
$groups[$group_id]['image'] = WB_URL.MEDIA_DIRECTORY.'/.news/image'.$group_id.'.jpg';
|
68 |
|
|
} else {
|
69 |
|
|
$groups[$group_id]['image'] = '';
|
70 |
|
|
}
|
71 |
|
|
}
|
72 |
|
|
}
|
73 |
|
|
|
74 |
|
|
// Check if we should show the main page or a post itself
|
75 |
1457
|
Luisehahne
|
// if(!defined('POST_ID') OR !is_numeric(POST_ID))
|
76 |
1918
|
Luisehahne
|
if(!isset($post_id) || !is_numeric($post_id)){
|
77 |
1425
|
Luisehahne
|
|
78 |
|
|
// Check if we should only list posts from a certain group
|
79 |
1895
|
Luisehahne
|
if(isset($_GET['g']) AND is_numeric($_GET['g'])) {
|
80 |
1457
|
Luisehahne
|
$query_extra = 'AND `group_id`='.(int)$_GET['g'].' ';
|
81 |
1425
|
Luisehahne
|
} else {
|
82 |
|
|
$query_extra = '';
|
83 |
|
|
}
|
84 |
|
|
|
85 |
|
|
// Check if we should only list posts from a certain group
|
86 |
1895
|
Luisehahne
|
if(isset($_GET['g']) AND is_numeric($_GET['g'])) {
|
87 |
1457
|
Luisehahne
|
$query_extra = 'AND `group_id`='.(int)$_GET['g'].' ';
|
88 |
1425
|
Luisehahne
|
} else {
|
89 |
|
|
$query_extra = '';
|
90 |
|
|
}
|
91 |
|
|
|
92 |
|
|
// Get settings
|
93 |
1457
|
Luisehahne
|
$setting_header = $setting_post_loop = $setting_footer = $setting_posts_per_page = '';
|
94 |
|
|
$sql = 'SELECT `header`, `post_loop`, `footer`, `posts_per_page` ';
|
95 |
|
|
$sql .= 'FROM `'.TABLE_PREFIX.'mod_news_settings` ';
|
96 |
|
|
$sql .= 'WHERE `section_id`='.(int)$section_id;
|
97 |
|
|
if( ($resSettings = $database->query($sql)) ){
|
98 |
|
|
if( ($recSettings = $resSettings->fetchRow()) ) {
|
99 |
|
|
foreach($recSettings as $key=>$val){
|
100 |
|
|
${'setting_'.$key} = $val;
|
101 |
|
|
}
|
102 |
|
|
}
|
103 |
1425
|
Luisehahne
|
}
|
104 |
|
|
$t = time();
|
105 |
|
|
// Get total number of posts
|
106 |
1457
|
Luisehahne
|
$sql = 'SELECT COUNT(*) FROM `'.TABLE_PREFIX.'mod_news_posts` ';
|
107 |
|
|
$sql .= 'WHERE `section_id`='.(int)$section_id.' AND `active`=1 ';
|
108 |
|
|
$sql .= 'AND `title`!=\'\' '.$query_extra;
|
109 |
|
|
$sql .= 'AND (`published_when`=0 OR `published_when`<='.$t.') ';
|
110 |
|
|
$sql .= 'AND (`published_until`=0 OR `published_until`>='.$t.') ';
|
111 |
|
|
$total_num = intval($database->get_one($sql));
|
112 |
1425
|
Luisehahne
|
// Work-out if we need to add limit code to sql
|
113 |
1895
|
Luisehahne
|
if($setting_posts_per_page != 0) {
|
114 |
1425
|
Luisehahne
|
$limit_sql = " LIMIT $position, $setting_posts_per_page";
|
115 |
|
|
} else {
|
116 |
|
|
$limit_sql = "";
|
117 |
|
|
}
|
118 |
|
|
|
119 |
|
|
// Query posts (for this page)
|
120 |
|
|
$query_posts = $database->query("SELECT * FROM ".TABLE_PREFIX."mod_news_posts
|
121 |
|
|
WHERE section_id = '$section_id' AND active = '1' AND title != ''$query_extra
|
122 |
|
|
AND (published_when = '0' OR published_when <= $t) AND (published_until = 0 OR published_until >= $t)
|
123 |
|
|
ORDER BY position DESC".$limit_sql);
|
124 |
|
|
$num_posts = $query_posts->numRows();
|
125 |
|
|
|
126 |
|
|
// Create previous and next links
|
127 |
|
|
if($setting_posts_per_page != 0)
|
128 |
1895
|
Luisehahne
|
{
|
129 |
1425
|
Luisehahne
|
if($position > 0)
|
130 |
1895
|
Luisehahne
|
{
|
131 |
|
|
if(isset($_GET['g']) AND is_numeric($_GET['g'])) {
|
132 |
1425
|
Luisehahne
|
$pl_prepend = '<a href="?p='.($position-$setting_posts_per_page).'&g='.$_GET['g'].'"><< ';
|
133 |
|
|
} else {
|
134 |
|
|
$pl_prepend = '<a href="?p='.($position-$setting_posts_per_page).'"><< ';
|
135 |
|
|
}
|
136 |
|
|
$pl_append = '</a>';
|
137 |
|
|
$previous_link = $pl_prepend.$TEXT['PREVIOUS'].$pl_append;
|
138 |
|
|
$previous_page_link = $pl_prepend.$TEXT['PREVIOUS_PAGE'].$pl_append;
|
139 |
|
|
} else {
|
140 |
|
|
$previous_link = '';
|
141 |
|
|
$previous_page_link = '';
|
142 |
|
|
}
|
143 |
1895
|
Luisehahne
|
if($position + $setting_posts_per_page >= $total_num) {
|
144 |
1425
|
Luisehahne
|
$next_link = '';
|
145 |
|
|
$next_page_link = '';
|
146 |
|
|
} else {
|
147 |
1895
|
Luisehahne
|
if(isset($_GET['g']) AND is_numeric($_GET['g'])) {
|
148 |
1425
|
Luisehahne
|
$nl_prepend = '<a href="?p='.($position+$setting_posts_per_page).'&g='.$_GET['g'].'"> ';
|
149 |
|
|
} else {
|
150 |
|
|
$nl_prepend = '<a href="?p='.($position+$setting_posts_per_page).'"> ';
|
151 |
|
|
}
|
152 |
|
|
$nl_append = ' >></a>';
|
153 |
|
|
$next_link = $nl_prepend.$TEXT['NEXT'].$nl_append;
|
154 |
|
|
$next_page_link = $nl_prepend.$TEXT['NEXT_PAGE'].$nl_append;
|
155 |
|
|
}
|
156 |
1895
|
Luisehahne
|
if($position+$setting_posts_per_page > $total_num) {
|
157 |
1425
|
Luisehahne
|
$num_of = $position+$num_posts;
|
158 |
|
|
} else {
|
159 |
|
|
$num_of = $position+$setting_posts_per_page;
|
160 |
|
|
}
|
161 |
|
|
|
162 |
|
|
$out_of = ($position+1).'-'.$num_of.' '.strtolower($TEXT['OUT_OF']).' '.$total_num;
|
163 |
|
|
$of = ($position+1).'-'.$num_of.' '.strtolower($TEXT['OF']).' '.$total_num;
|
164 |
|
|
$display_previous_next_links = '';
|
165 |
|
|
} else {
|
166 |
|
|
$display_previous_next_links = 'none';
|
167 |
|
|
}
|
168 |
|
|
|
169 |
1895
|
Luisehahne
|
if ($num_posts === 0) {
|
170 |
1425
|
Luisehahne
|
$setting_header = '';
|
171 |
|
|
$setting_post_loop = '';
|
172 |
|
|
$setting_footer = '';
|
173 |
|
|
$setting_posts_per_page = '';
|
174 |
|
|
}
|
175 |
|
|
|
176 |
|
|
// Print header
|
177 |
1895
|
Luisehahne
|
if($display_previous_next_links == 'none') {
|
178 |
1425
|
Luisehahne
|
print str_replace( array('[NEXT_PAGE_LINK]','[NEXT_LINK]','[PREVIOUS_PAGE_LINK]','[PREVIOUS_LINK]','[OUT_OF]','[OF]','[DISPLAY_PREVIOUS_NEXT_LINKS]'),
|
179 |
1895
|
Luisehahne
|
array('','','','','','', $display_previous_next_links), $setting_header);
|
180 |
1425
|
Luisehahne
|
} else {
|
181 |
|
|
print str_replace( array('[NEXT_PAGE_LINK]','[NEXT_LINK]','[PREVIOUS_PAGE_LINK]','[PREVIOUS_LINK]','[OUT_OF]','[OF]','[DISPLAY_PREVIOUS_NEXT_LINKS]'),
|
182 |
1895
|
Luisehahne
|
array($next_page_link, $next_link, $previous_page_link, $previous_link, $out_of, $of, $display_previous_next_links), $setting_header);
|
183 |
1425
|
Luisehahne
|
}
|
184 |
|
|
if($num_posts > 0)
|
185 |
1895
|
Luisehahne
|
{
|
186 |
1425
|
Luisehahne
|
if($query_extra != '')
|
187 |
1895
|
Luisehahne
|
{
|
188 |
1425
|
Luisehahne
|
?>
|
189 |
|
|
<div class="selected-group-title">
|
190 |
|
|
<?php print '<a href="'.htmlspecialchars(strip_tags($_SERVER['SCRIPT_NAME'])).'">'.PAGE_TITLE.'</a> >> '.$groups[$_GET['g']]['title']; ?>
|
191 |
|
|
</div>
|
192 |
|
|
<?php
|
193 |
|
|
}
|
194 |
1918
|
Luisehahne
|
while( false != ($post = $query_posts->fetchRow(MYSQL_ASSOC)) )
|
195 |
1895
|
Luisehahne
|
{
|
196 |
1425
|
Luisehahne
|
if(isset($groups[$post['group_id']]['active']) AND $groups[$post['group_id']]['active'] != false)
|
197 |
1895
|
Luisehahne
|
{ // Make sure parent group is active
|
198 |
1425
|
Luisehahne
|
$uid = $post['posted_by']; // User who last modified the post
|
199 |
|
|
// Workout date and time of last modified post
|
200 |
1895
|
Luisehahne
|
if ($post['published_when'] === '0'){ $post['published_when'] = time();}
|
201 |
|
|
if ($post['published_when'] > $post['posted_when']) {
|
202 |
1457
|
Luisehahne
|
$post_date = date(DATE_FORMAT, $post['published_when']+TIMEZONE);
|
203 |
|
|
$post_time = date(TIME_FORMAT, $post['published_when']+TIMEZONE);
|
204 |
1425
|
Luisehahne
|
} else {
|
205 |
1457
|
Luisehahne
|
$post_date = date(DATE_FORMAT, $post['posted_when']+TIMEZONE);
|
206 |
|
|
$post_time = date(TIME_FORMAT, $post['posted_when']+TIMEZONE);
|
207 |
1425
|
Luisehahne
|
}
|
208 |
|
|
|
209 |
1895
|
Luisehahne
|
$publ_date = date(DATE_FORMAT,$post['published_when']+TIMEZONE);
|
210 |
|
|
$publ_time = date(TIME_FORMAT,$post['published_when']+TIMEZONE);
|
211 |
1425
|
Luisehahne
|
|
212 |
1895
|
Luisehahne
|
// Work-out the post link
|
213 |
1425
|
Luisehahne
|
$post_link = page_link($post['link']);
|
214 |
1895
|
Luisehahne
|
$post_link_path = str_replace(WB_URL, WB_PATH,$post_link);
|
215 |
|
|
$create_date = date(DATE_FORMAT, $post['created_when']+TIMEZONE);
|
216 |
|
|
$create_time = date(TIME_FORMAT, $post['created_when']+TIMEZONE);
|
217 |
1425
|
Luisehahne
|
|
218 |
1895
|
Luisehahne
|
if(isset($_GET['p']) AND $position > 0) {
|
219 |
1425
|
Luisehahne
|
$post_link .= '?p='.$position;
|
220 |
|
|
}
|
221 |
1895
|
Luisehahne
|
if(isset($_GET['g']) AND is_numeric($_GET['g'])) {
|
222 |
|
|
if(isset($_GET['p']) AND $position > 0) { $post_link .= '&'; } else { $post_link .= '?'; } {
|
223 |
1425
|
Luisehahne
|
$post_link .= 'g='.$_GET['g'];
|
224 |
1895
|
Luisehahne
|
}
|
225 |
1425
|
Luisehahne
|
}
|
226 |
|
|
// Get group id, title, and image
|
227 |
|
|
$group_id = $post['group_id'];
|
228 |
|
|
$group_title = $groups[$group_id]['title'];
|
229 |
|
|
$group_image = $groups[$group_id]['image'];
|
230 |
|
|
$display_image = ($group_image == '') ? "none" : "inherit";
|
231 |
|
|
$display_group = ($group_id == 0) ? 'none' : 'inherit';
|
232 |
|
|
|
233 |
|
|
if ($group_image != "") $group_image= "<img src='".$group_image."' alt='".$group_title."' />";
|
234 |
|
|
|
235 |
|
|
// Replace [wblink--PAGE_ID--] with real link
|
236 |
|
|
$short = ($post['content_short']);
|
237 |
|
|
// Replace vars with values
|
238 |
|
|
$post_long_len = strlen($post['content_long']);
|
239 |
|
|
$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]');
|
240 |
|
|
if(isset($users[$uid]['username']) AND $users[$uid]['username'] != '')
|
241 |
1895
|
Luisehahne
|
{
|
242 |
|
|
if($post_long_len < 9) {
|
243 |
1425
|
Luisehahne
|
$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');
|
244 |
|
|
} else {
|
245 |
1895
|
Luisehahne
|
$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');
|
246 |
1425
|
Luisehahne
|
}
|
247 |
|
|
} else {
|
248 |
1895
|
Luisehahne
|
if($post_long_len < 9) {
|
249 |
1425
|
Luisehahne
|
$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');
|
250 |
|
|
} else {
|
251 |
|
|
$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');
|
252 |
|
|
}
|
253 |
|
|
}
|
254 |
|
|
print str_replace($vars, $values, $setting_post_loop);
|
255 |
|
|
}
|
256 |
|
|
}
|
257 |
|
|
}
|
258 |
1895
|
Luisehahne
|
// Print footer
|
259 |
|
|
if($display_previous_next_links == 'none') {
|
260 |
|
|
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);
|
261 |
|
|
} else {
|
262 |
|
|
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);
|
263 |
|
|
}
|
264 |
1425
|
Luisehahne
|
|
265 |
|
|
}
|
266 |
1457
|
Luisehahne
|
//elseif(defined('POST_ID') AND is_numeric(POST_ID))
|
267 |
1918
|
Luisehahne
|
elseif(isset($post_id) && is_numeric($post_id)){
|
268 |
1895
|
Luisehahne
|
// print '<h2>'.POST_ID.'/'.PAGE_ID.'/'.POST_SECTION.'</h2>';
|
269 |
1457
|
Luisehahne
|
// if(defined('POST_SECTION') AND POST_SECTION == $section_id)
|
270 |
1918
|
Luisehahne
|
if(isset($post_section) && ($post_section == $section_id)){
|
271 |
1895
|
Luisehahne
|
// Get settings
|
272 |
|
|
$setting_post_header = $setting_post_footer = $setting_comments_header
|
273 |
|
|
= $setting_comments_loop = $setting_comments_footer = '';
|
274 |
|
|
$sql = 'SELECT `post_header`, `post_footer`, `comments_header`, `comments_loop`, `comments_footer` ';
|
275 |
|
|
$sql .= 'FROM `'.TABLE_PREFIX.'mod_news_settings` ';
|
276 |
|
|
$sql .= 'WHERE `section_id`='.(int)$section_id;
|
277 |
|
|
if( ($resSettings = $database->query($sql)) ){
|
278 |
|
|
if( ($recSettings = $resSettings->fetchRow()) ) {
|
279 |
|
|
foreach($recSettings as $key=>$val){
|
280 |
|
|
${'setting_'.$key} = $val;
|
281 |
|
|
}
|
282 |
1457
|
Luisehahne
|
}
|
283 |
|
|
}
|
284 |
1895
|
Luisehahne
|
// Get page info
|
285 |
|
|
$query_page = $database->query("SELECT link FROM ".TABLE_PREFIX."pages WHERE page_id = '".PAGE_ID."'");
|
286 |
|
|
if($query_page->numRows() > 0) {
|
287 |
|
|
$page = $query_page->fetchRow();
|
288 |
|
|
$page_link = page_link($page['link']);
|
289 |
|
|
if(isset($_GET['p']) AND $position > 0) {
|
290 |
|
|
$page_link .= '?p='.$_GET['p'];
|
291 |
|
|
}
|
292 |
|
|
if(isset($_GET['g']) AND is_numeric($_GET['g'])) {
|
293 |
|
|
if(isset($_GET['p']) AND $position > 0) { $page_link .= '&'; } else { $page_link .= '?'; }
|
294 |
|
|
$page_link .= 'g='.$_GET['g'];
|
295 |
|
|
}
|
296 |
|
|
} else {
|
297 |
|
|
exit($MESSAGE['PAGES_NOT_FOUND']);
|
298 |
1425
|
Luisehahne
|
}
|
299 |
|
|
|
300 |
1918
|
Luisehahne
|
// Get post info
|
301 |
1895
|
Luisehahne
|
$t = time();
|
302 |
|
|
$query_post = $database->query("SELECT * FROM ".TABLE_PREFIX."mod_news_posts
|
303 |
|
|
WHERE post_id = '".$post_id."' AND active = '1'
|
304 |
|
|
AND (published_when = '0' OR published_when <= $t) AND (published_until = 0 OR published_until >= $t)");
|
305 |
1425
|
Luisehahne
|
|
306 |
1895
|
Luisehahne
|
if($query_post->numRows() > 0)
|
307 |
|
|
{
|
308 |
|
|
$post = $query_post->fetchRow();
|
309 |
|
|
if(isset($groups[$post['group_id']]['active']) AND $groups[$post['group_id']]['active'] != false)
|
310 |
|
|
{ // Make sure parent group is active
|
311 |
|
|
$uid = $post['posted_by']; // User who last modified the post
|
312 |
|
|
// Workout date and time of last modified post
|
313 |
|
|
if ($post['published_when'] === '0'){ $post['published_when'] = time();}
|
314 |
|
|
if ($post['published_when'] > $post['posted_when']) {
|
315 |
|
|
$post_date = date(DATE_FORMAT, $post['published_when']+TIMEZONE);
|
316 |
|
|
$post_time = date(TIME_FORMAT, $post['published_when']+TIMEZONE);
|
317 |
|
|
} else {
|
318 |
|
|
$post_date = date(DATE_FORMAT, $post['posted_when']+TIMEZONE);
|
319 |
|
|
$post_time = date(TIME_FORMAT, $post['posted_when']+TIMEZONE);
|
320 |
|
|
}
|
321 |
1425
|
Luisehahne
|
|
322 |
1895
|
Luisehahne
|
$publ_date = date(DATE_FORMAT,$post['published_when']+TIMEZONE);
|
323 |
|
|
$publ_time = date(TIME_FORMAT,$post['published_when']+TIMEZONE);
|
324 |
1425
|
Luisehahne
|
|
325 |
1895
|
Luisehahne
|
// Work-out the post link
|
326 |
|
|
$post_link = page_link($post['link']);
|
327 |
1425
|
Luisehahne
|
|
328 |
1895
|
Luisehahne
|
$post_link_path = str_replace(WB_URL, WB_PATH,$post_link);
|
329 |
|
|
$create_date = date(DATE_FORMAT, $post['created_when']+TIMEZONE);
|
330 |
|
|
$create_time = date(TIME_FORMAT, $post['created_when']+TIMEZONE);
|
331 |
1918
|
Luisehahne
|
// Get group id, title, and image
|
332 |
1895
|
Luisehahne
|
$group_id = $post['group_id'];
|
333 |
|
|
$group_title = $groups[$group_id]['title'];
|
334 |
|
|
$group_image = $groups[$group_id]['image'];
|
335 |
|
|
$display_image = ($group_image == '') ? "none" : "inherit";
|
336 |
|
|
$display_group = ($group_id == 0) ? 'none' : 'inherit';
|
337 |
1425
|
Luisehahne
|
|
338 |
1895
|
Luisehahne
|
if ($group_image != "") $group_image= "<img src='".$group_image."' alt='".$group_title."' />";
|
339 |
1425
|
Luisehahne
|
|
340 |
1895
|
Luisehahne
|
$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]');
|
341 |
|
|
$post_short=$post['content_short'];
|
342 |
|
|
if(isset($users[$uid]['username']) AND $users[$uid]['username'] != '') {
|
343 |
|
|
$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']);
|
344 |
|
|
} else {
|
345 |
|
|
$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'], '', '', '', '');
|
346 |
|
|
}
|
347 |
|
|
// $post_long = ($post['content_long']);
|
348 |
|
|
$post_long = ($post['content_long'] != '') ? $post['content_long'] : $post['content_short'];
|
349 |
1425
|
Luisehahne
|
}
|
350 |
1895
|
Luisehahne
|
} else {
|
351 |
|
|
$wb->print_error($MESSAGE['FRONTEND_SORRY_NO_ACTIVE_SECTIONS'], 'view.php', false);
|
352 |
1425
|
Luisehahne
|
}
|
353 |
|
|
|
354 |
1895
|
Luisehahne
|
// Print post header
|
355 |
|
|
print str_replace($vars, $values, $setting_post_header);
|
356 |
|
|
// Print long
|
357 |
|
|
print $post_long;
|
358 |
1425
|
Luisehahne
|
|
359 |
1895
|
Luisehahne
|
// Print post footer
|
360 |
|
|
print str_replace($vars, $values, $setting_post_footer);
|
361 |
1425
|
Luisehahne
|
|
362 |
1895
|
Luisehahne
|
// Show comments section if we have to
|
363 |
|
|
if(($post['commenting'] == 'private' AND isset($wb) AND $wb->is_authenticated() == true) OR $post['commenting'] == 'public')
|
364 |
|
|
{
|
365 |
|
|
// Print comments header
|
366 |
|
|
$vars = array('[ADD_COMMENT_URL]','[TEXT_COMMENTS]');
|
367 |
|
|
// $pid = $admin->getIDKEY(POST_ID);
|
368 |
|
|
$values = array(WB_URL.'/modules/news/comment.php?post_id='.$post_id.'&section_id='.$section_id, $MOD_NEWS['TEXT_COMMENTS']);
|
369 |
|
|
print str_replace($vars, $values, $setting_comments_header);
|
370 |
1425
|
Luisehahne
|
|
371 |
1918
|
Luisehahne
|
// Query for comments
|
372 |
1895
|
Luisehahne
|
$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");
|
373 |
|
|
if($query_comments->numRows() > 0)
|
374 |
|
|
{
|
375 |
|
|
while( false != ($comment = $query_comments->fetchRow()) )
|
376 |
|
|
{
|
377 |
|
|
// Display Comments without slashes, but with new-line characters
|
378 |
|
|
$comment['comment'] = nl2br($wb->strip_slashes($comment['comment']));
|
379 |
|
|
$comment['title'] = $wb->strip_slashes($comment['title']);
|
380 |
|
|
// Print comments loop
|
381 |
|
|
$commented_date = date(DATE_FORMAT, $comment['commented_when']+TIMEZONE);
|
382 |
|
|
$commented_time = date(TIME_FORMAT, $comment['commented_when']+TIMEZONE);
|
383 |
|
|
$uid = $comment['commented_by'];
|
384 |
|
|
$vars = array('[TITLE]','[COMMENT]','[TEXT_ON]','[DATE]','[TEXT_AT]','[TIME]','[TEXT_BY]','[USER_ID]','[USERNAME]','[DISPLAY_NAME]', '[EMAIL]');
|
385 |
|
|
if(isset($users[$uid]['username']) AND $users[$uid]['username'] != '') {
|
386 |
|
|
$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']));
|
387 |
|
|
} else {
|
388 |
|
|
$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'], '');
|
389 |
|
|
}
|
390 |
|
|
print str_replace($vars, $values, $setting_comments_loop);
|
391 |
|
|
}
|
392 |
|
|
} else {
|
393 |
|
|
// Say no comments found
|
394 |
|
|
$content = '';
|
395 |
1425
|
Luisehahne
|
$vars = array('[TITLE]','[COMMENT]','[TEXT_ON]','[DATE]','[TEXT_AT]','[TIME]','[TEXT_BY]','[USER_ID]','[USERNAME]','[DISPLAY_NAME]', '[EMAIL]');
|
396 |
1895
|
Luisehahne
|
$values = array( '', $MOD_NEWS['NO_COMMENT_FOUND'], '', '', '', '', '', '', '', '');
|
397 |
1425
|
Luisehahne
|
print str_replace($vars, $values, $setting_comments_loop);
|
398 |
|
|
}
|
399 |
1895
|
Luisehahne
|
|
400 |
|
|
// Print comments footer
|
401 |
|
|
$vars = array('[ADD_COMMENT_URL]','[TEXT_ADD_COMMENT]');
|
402 |
|
|
$values = array(WB_URL.'/modules/news/comment.php?post_id='.$post_id.'&section_id='.$section_id, $MOD_NEWS['TEXT_ADD_COMMENT']);
|
403 |
|
|
print str_replace($vars, $values, $setting_comments_footer);
|
404 |
|
|
|
405 |
1425
|
Luisehahne
|
}
|
406 |
|
|
|
407 |
|
|
}
|
408 |
|
|
|
409 |
1895
|
Luisehahne
|
if(ENABLED_ASP) {
|
410 |
1457
|
Luisehahne
|
$_SESSION['comes_from_view'] = $post_id;
|
411 |
1425
|
Luisehahne
|
$_SESSION['comes_from_view_time'] = time();
|
412 |
|
|
}
|
413 |
|
|
|
414 |
|
|
}
|