Announcement Permissions Power
This commit is contained in:
@@ -17,29 +17,10 @@ if (!defined('IN_PORTAL'))
|
|||||||
exit;
|
exit;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Get cleaned up list... return only those forums not having the f_read permission
|
|
||||||
$forum_ary = $auth->acl_getf('!f_read', true);
|
|
||||||
$forum_ary = array_unique(array_keys($forum_ary));
|
|
||||||
|
|
||||||
// Determine first forum the user is able to read into - for global announcement link
|
|
||||||
$sql = 'SELECT forum_id
|
|
||||||
FROM ' . FORUMS_TABLE . '
|
|
||||||
WHERE forum_type = ' . FORUM_POST;
|
|
||||||
|
|
||||||
if (sizeof($forum_ary))
|
|
||||||
{
|
|
||||||
$sql .= ' AND ' . $db->sql_in_set('forum_id', $forum_ary, true);
|
|
||||||
}
|
|
||||||
$result = $db->sql_query_limit($sql, 1);
|
|
||||||
$g_forum_id = (int) $db->sql_fetchfield('forum_id');
|
|
||||||
$db->sql_freeresult($result);
|
|
||||||
|
|
||||||
$can_read = ( $g_forum_id == 0 ) ? false : true;
|
|
||||||
|
|
||||||
$news = request_var('announcement', -1);
|
$news = request_var('announcement', -1);
|
||||||
if($news < 0)
|
if($news < 0)
|
||||||
{
|
{
|
||||||
$fetch_news = phpbb_fetch_posts('', $portal_config['portal_number_of_announcements'], $portal_config['portal_announcements_length'], $portal_config['portal_announcements_day'], 'announcements');
|
$fetch_news = phpbb_fetch_posts($portal_config['portal_global_announcements_forum'], $portal_config['portal_number_of_announcements'], $portal_config['portal_announcements_length'], $portal_config['portal_announcements_day'], 'announcements');
|
||||||
|
|
||||||
if (count($fetch_news) == 0)
|
if (count($fetch_news) == 0)
|
||||||
{
|
{
|
||||||
@@ -47,6 +28,8 @@ if($news < 0)
|
|||||||
'S_NO_TOPICS' => true,
|
'S_NO_TOPICS' => true,
|
||||||
'S_NOT_LAST' => false
|
'S_NOT_LAST' => false
|
||||||
));
|
));
|
||||||
|
|
||||||
|
$template->assign_var('S_CAN_READ', $can_read);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
@@ -71,7 +54,7 @@ if($news < 0)
|
|||||||
$topic_tracking_info = get_complete_topic_tracking($forum_id, $topic_id, $global_announce_list = false);
|
$topic_tracking_info = get_complete_topic_tracking($forum_id, $topic_id, $global_announce_list = false);
|
||||||
$unread_topic = (isset($topic_tracking_info[$topic_id]) && $fetch_news[$i]['topic_last_post_time'] > $topic_tracking_info[$topic_id]) ? true : false;
|
$unread_topic = (isset($topic_tracking_info[$topic_id]) && $fetch_news[$i]['topic_last_post_time'] > $topic_tracking_info[$topic_id]) ? true : false;
|
||||||
|
|
||||||
$real_forum_id = ( $forum_id == 0 ) ? $g_forum_id : $forum_id;
|
$real_forum_id = ( $forum_id == 0 ) ? $fetch_news[$i]['global_id']: $forum_id;
|
||||||
|
|
||||||
$template->assign_block_vars('announcements_row', array(
|
$template->assign_block_vars('announcements_row', array(
|
||||||
'ATTACH_ICON_IMG' => ($fetch_news[$i]['attachment']) ? $user->img('icon_topic_attach', $user->lang['TOTAL_ATTACHMENTS']) : '',
|
'ATTACH_ICON_IMG' => ($fetch_news[$i]['attachment']) ? $user->img('icon_topic_attach', $user->lang['TOTAL_ATTACHMENTS']) : '',
|
||||||
@@ -101,8 +84,7 @@ if($news < 0)
|
|||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
#$fetch_news = phpbb_fetch_posts($portal_config['portal_news_forum'], $portal_config['portal_number_of_news'], 0, 0, ($portal_config['portal_show_all_news']) ? 'news_all' : 'news');
|
$fetch_news = phpbb_fetch_posts($portal_config['portal_news_forum'], $portal_config['portal_number_of_news'], $portal_config['portal_news_length'], 0, ($portal_config['portal_show_all_news']) ? 'news_all' : 'news');
|
||||||
$fetch_news = phpbb_fetch_posts('', $portal_config['portal_number_of_announcements'], 0, 0, 'announcements');
|
|
||||||
|
|
||||||
$i = $news;
|
$i = $news;
|
||||||
$forum_id = $fetch_news[$i]['forum_id'];
|
$forum_id = $fetch_news[$i]['forum_id'];
|
||||||
@@ -140,7 +122,6 @@ $template->assign_vars(array(
|
|||||||
'NEWEST_POST_IMG' => $user->img('icon_topic_newest', 'VIEW_NEWEST_POST'),
|
'NEWEST_POST_IMG' => $user->img('icon_topic_newest', 'VIEW_NEWEST_POST'),
|
||||||
'READ_POST_IMG' => $user->img('icon_topic_latest', 'VIEW_NEWEST_POST'),
|
'READ_POST_IMG' => $user->img('icon_topic_latest', 'VIEW_NEWEST_POST'),
|
||||||
'S_DISPLAY_ANNOUNCEMENTS' => true,
|
'S_DISPLAY_ANNOUNCEMENTS' => true,
|
||||||
'S_CAN_READ' => $can_read,
|
|
||||||
));
|
));
|
||||||
|
|
||||||
?>
|
?>
|
||||||
@@ -31,22 +31,198 @@ while( $row = $db->sql_fetchrow($result) )
|
|||||||
include($phpbb_root_path . 'includes/message_parser.'.$phpEx);
|
include($phpbb_root_path . 'includes/message_parser.'.$phpEx);
|
||||||
|
|
||||||
// fetch post for news & announce
|
// fetch post for news & announce
|
||||||
function phpbb_fetch_posts($forum_sql, $number_of_posts, $text_length, $time, $type)
|
function phpbb_fetch_posts($forum_from, $number_of_posts, $text_length, $time, $type)
|
||||||
{
|
{
|
||||||
global $db, $phpbb_root_path, $auth, $bbcode_bitfield, $user, $forum_id;
|
global $db, $phpbb_root_path, $auth, $user, $bbcode_bitfield;
|
||||||
|
|
||||||
|
$posts = array();
|
||||||
|
|
||||||
$from_forum = ($forum_sql) ? 't.forum_id IN (' . $forum_sql . ') AND' : '';
|
$post_time = ($time == 0) ? '' : 't.topic_last_post_time > ' . (time() - $time * 86400) . ' AND';
|
||||||
$post_time = ($time == 0) ? '' : 't.topic_last_post_time > ' . (time() - $time * 86400) . ' AND';
|
|
||||||
|
|
||||||
|
$forum_from = ( strpos($forum_from, ',') !== FALSE ) ? explode(',', $forum_from) : (($forum_from != '') ? array($forum_from) : array());
|
||||||
|
|
||||||
if ($type == 'announcements')
|
$str_where = '';
|
||||||
{
|
|
||||||
// only global announcements for announcements block
|
|
||||||
$topic_type = '(( t.topic_type = ' . POST_ANNOUNCE . ') OR ( t.topic_type = ' . POST_GLOBAL . ')) AND';
|
|
||||||
|
|
||||||
|
$allow_access = $auth->acl_getf('f_read', true);
|
||||||
|
|
||||||
|
if( sizeof($allow_access) ){
|
||||||
|
|
||||||
|
if( sizeof($forum_from) )
|
||||||
|
{
|
||||||
|
foreach( $allow_access as $acc_id => $acc_data )
|
||||||
|
{
|
||||||
|
if( in_array($acc_id, $forum_from ) )
|
||||||
|
{
|
||||||
|
$str_where .= "t.forum_id = $acc_id OR ";
|
||||||
|
if( !isset($gobal_f) )
|
||||||
|
{
|
||||||
|
$global_f = $acc_id;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
foreach( $allow_access as $acc_id => $acc_bool )
|
||||||
|
{
|
||||||
|
|
||||||
|
$str_where .= "t.forum_id = $acc_id OR ";
|
||||||
|
if( !isset($gobal_f) )
|
||||||
|
{
|
||||||
|
$global_f = $acc_id;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if ($type == 'announcements')
|
||||||
|
{
|
||||||
|
// only global announcements for announcements block
|
||||||
|
$topic_type = '(( t.topic_type = ' . POST_ANNOUNCE . ') OR ( t.topic_type = ' . POST_GLOBAL . ')) AND';
|
||||||
|
|
||||||
|
if( strlen($str_where) > 0 )
|
||||||
|
{
|
||||||
|
$str_where = ( strlen($str_where) > 0 ) ? 'AND (t.forum_id = 0 OR ' . substr($str_where, 0, -4) . ')' : '';
|
||||||
|
|
||||||
|
$sql = 'SELECT
|
||||||
|
t.forum_id,
|
||||||
|
t.topic_id,
|
||||||
|
t.topic_last_post_id,
|
||||||
|
t.topic_last_post_time,
|
||||||
|
t.topic_time,
|
||||||
|
t.topic_title,
|
||||||
|
t.topic_attachment,
|
||||||
|
t.topic_views,
|
||||||
|
t.poll_title,
|
||||||
|
t.topic_replies,
|
||||||
|
t.topic_poster,
|
||||||
|
u.username,
|
||||||
|
u.user_id,
|
||||||
|
u.user_type,
|
||||||
|
u.user_colour,
|
||||||
|
p.post_id,
|
||||||
|
p.post_time,
|
||||||
|
p.post_text,
|
||||||
|
p.post_attachment,
|
||||||
|
p.enable_smilies,
|
||||||
|
p.enable_bbcode,
|
||||||
|
p.enable_magic_url,
|
||||||
|
p.bbcode_bitfield,
|
||||||
|
p.bbcode_uid,
|
||||||
|
f.forum_name
|
||||||
|
FROM
|
||||||
|
' . TOPICS_TABLE . ' AS t
|
||||||
|
LEFT JOIN
|
||||||
|
' . USERS_TABLE . ' as u
|
||||||
|
ON
|
||||||
|
t.topic_poster = u.user_id
|
||||||
|
LEFT JOIN
|
||||||
|
' . FORUMS_TABLE . ' as f
|
||||||
|
ON
|
||||||
|
t.forum_id=f.forum_id
|
||||||
|
LEFT JOIN
|
||||||
|
' . POSTS_TABLE . ' as p
|
||||||
|
ON
|
||||||
|
t.topic_first_post_id = p.post_id
|
||||||
|
WHERE
|
||||||
|
' . $topic_type . '
|
||||||
|
' . $post_time . '
|
||||||
|
t.topic_status <> 2 AND
|
||||||
|
t.topic_approved = 1
|
||||||
|
' . $str_where .'
|
||||||
|
ORDER BY
|
||||||
|
t.topic_time DESC';
|
||||||
|
|
||||||
|
|
||||||
|
// query the database
|
||||||
|
if(!($result = $db->sql_query_limit($sql, $number_of_posts)))
|
||||||
|
{
|
||||||
|
die('Could not query topic information for board3 Portal announcements section');
|
||||||
|
}
|
||||||
|
|
||||||
|
//
|
||||||
|
// fetch all postings
|
||||||
|
//
|
||||||
|
|
||||||
|
// Instantiate BBCode if need be
|
||||||
|
if ($bbcode_bitfield !== '')
|
||||||
|
{
|
||||||
|
$phpEx = substr(strrchr(__FILE__, '.'), 1);
|
||||||
|
include_once($phpbb_root_path . 'includes/bbcode.' . $phpEx);
|
||||||
|
$bbcode = new bbcode(base64_encode($bbcode_bitfield));
|
||||||
|
}
|
||||||
|
$i = 0;
|
||||||
|
while ( ($row = $db->sql_fetchrow($result)) && ( ($i < $number_of_posts) || ($number_of_posts == '0') ) )
|
||||||
|
{
|
||||||
|
if ($row['user_id'] != ANONYMOUS && $row['user_colour'])
|
||||||
|
{
|
||||||
|
$row['username'] = '<b style="color:#' . $row['user_colour'] . '">' . $row['username'] . '</b>';
|
||||||
|
}
|
||||||
|
$posts[$i]['bbcode_uid'] = $row['bbcode_uid'];
|
||||||
|
$len_check = $row['post_text'];
|
||||||
|
$maxlen = $text_length;
|
||||||
|
if (($text_length != 0) && (strlen($len_check) > $text_length))
|
||||||
|
{
|
||||||
|
$posts[$i]['post_text'] = censor_text(get_sub_taged_string(str_replace("\n", '<br/> ', $row['post_text']), $row['bbcode_uid'], $maxlen));
|
||||||
|
$posts[$i]['striped'] = true;
|
||||||
|
} else $posts[$i]['post_text'] = censor_text($row['post_text']);
|
||||||
|
|
||||||
|
$posts[$i]['topic_id'] = $row['topic_id'];
|
||||||
|
$posts[$i]['topic_last_post_id'] = $row['topic_last_post_id'];
|
||||||
|
$posts[$i]['forum_id'] = $row['forum_id'];
|
||||||
|
$posts[$i]['topic_replies'] = $row['topic_replies'];
|
||||||
|
$posts[$i]['topic_time'] = $user->format_date($row['topic_time']);
|
||||||
|
$posts[$i]['topic_last_post_time'] = $row['topic_last_post_time'];
|
||||||
|
$posts[$i]['topic_title'] = $row['topic_title'];
|
||||||
|
$posts[$i]['username'] = $row['username'];
|
||||||
|
$posts[$i]['user_id'] = $row['user_id'];
|
||||||
|
$posts[$i]['user_type'] = $row['user_type'];
|
||||||
|
$posts[$i]['user_user_colour'] = $row['user_colour'];
|
||||||
|
$posts[$i]['poll'] = ($row['poll_title']) ? true : false;
|
||||||
|
$posts[$i]['attachment'] = ($row['topic_attachment']) ? true : false;
|
||||||
|
$posts[$i]['topic_views'] = ($row['topic_views']);
|
||||||
|
$posts[$i]['forum_name'] = ($row['forum_name']);
|
||||||
|
$posts[$i]['global_id'] = ($global_f);
|
||||||
|
|
||||||
|
$message = $posts[$i]['post_text'];
|
||||||
|
$message = str_replace("\n", '<br />', $message);
|
||||||
|
|
||||||
|
|
||||||
|
if ($auth->acl_get('f_html', $row['forum_id']))
|
||||||
|
{
|
||||||
|
$message = preg_replace('#<!\-\-(.*?)\-\->#is', '', $message); // Remove Comments from post content
|
||||||
|
}
|
||||||
|
// Second parse bbcode here
|
||||||
|
if ($row['bbcode_bitfield'])
|
||||||
|
{
|
||||||
|
$bbcode->bbcode_second_pass($message, $row['bbcode_uid'], $row['bbcode_bitfield']);
|
||||||
|
}
|
||||||
|
$message = smiley_text($message); // Always process smilies after parsing bbcodes
|
||||||
|
$posts[$i]['post_text']= ap_validate($message);
|
||||||
|
$i++;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
// return the result
|
||||||
|
return $posts;
|
||||||
|
}
|
||||||
|
|
||||||
|
// news - get last post
|
||||||
|
|
||||||
|
else if ($type == 'news_all')
|
||||||
|
{
|
||||||
|
// not show global announcements
|
||||||
|
$topic_type = '( t.topic_type != ' . POST_ANNOUNCE . ' ) AND ( t.topic_type != ' . POST_GLOBAL . ') AND';
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
// only normal topic
|
||||||
|
$topic_type = 't.topic_type = ' . POST_NORMAL . ' AND';
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
$str_where = 'AND (' . substr($str_where, 0, -4) . ')';
|
||||||
|
|
||||||
$sql = 'SELECT
|
$sql = 'SELECT
|
||||||
t.forum_id,
|
t.forum_id,
|
||||||
t.topic_id,
|
t.topic_id,
|
||||||
t.topic_last_post_id,
|
t.topic_last_post_id,
|
||||||
t.topic_last_post_time,
|
t.topic_last_post_time,
|
||||||
@@ -56,6 +232,7 @@ function phpbb_fetch_posts($forum_sql, $number_of_posts, $text_length, $time, $t
|
|||||||
t.topic_views,
|
t.topic_views,
|
||||||
t.poll_title,
|
t.poll_title,
|
||||||
t.topic_replies,
|
t.topic_replies,
|
||||||
|
t.forum_id,
|
||||||
t.topic_poster,
|
t.topic_poster,
|
||||||
u.username,
|
u.username,
|
||||||
u.user_id,
|
u.user_id,
|
||||||
@@ -71,237 +248,106 @@ function phpbb_fetch_posts($forum_sql, $number_of_posts, $text_length, $time, $t
|
|||||||
p.bbcode_bitfield,
|
p.bbcode_bitfield,
|
||||||
p.bbcode_uid,
|
p.bbcode_uid,
|
||||||
f.forum_name
|
f.forum_name
|
||||||
FROM
|
FROM
|
||||||
' . TOPICS_TABLE . ' AS t
|
' . TOPICS_TABLE . ' AS t
|
||||||
LEFT JOIN
|
LEFT JOIN
|
||||||
' . USERS_TABLE . ' as u
|
' . USERS_TABLE . ' as u
|
||||||
ON
|
ON
|
||||||
t.topic_poster = u.user_id
|
t.topic_poster = u.user_id
|
||||||
LEFT JOIN
|
LEFT JOIN
|
||||||
' . FORUMS_TABLE . ' as f
|
' . FORUMS_TABLE . ' as f
|
||||||
ON
|
ON
|
||||||
t.forum_id=f.forum_id
|
t.forum_id=f.forum_id
|
||||||
LEFT JOIN
|
LEFT JOIN
|
||||||
' . POSTS_TABLE . ' as p
|
' . POSTS_TABLE . ' as p
|
||||||
ON
|
ON
|
||||||
t.topic_first_post_id = p.post_id
|
t.topic_first_post_id = p.post_id
|
||||||
WHERE
|
WHERE
|
||||||
' . $topic_type . '
|
' . $topic_type . '
|
||||||
' . $from_forum . '
|
' . $post_time . '
|
||||||
' . $post_time . '
|
t.topic_status <> 2 AND
|
||||||
t.topic_status <> 2 AND
|
t.topic_approved = 1
|
||||||
t.topic_approved = 1
|
' . $str_where . '
|
||||||
ORDER BY
|
ORDER BY
|
||||||
t.topic_time DESC';
|
t.topic_last_post_time DESC';
|
||||||
|
|
||||||
|
|
||||||
// query the database
|
|
||||||
if(!($result = $db->sql_query_limit($sql, $number_of_posts)))
|
|
||||||
{
|
|
||||||
die('Could not query topic information for board3 Portal announcements section');
|
|
||||||
}
|
|
||||||
|
|
||||||
//
|
|
||||||
// fetch all postings
|
|
||||||
//
|
|
||||||
|
|
||||||
// Instantiate BBCode if need be
|
// query the database
|
||||||
if ($bbcode_bitfield !== '')
|
if(!($result = $db->sql_query_limit($sql, $number_of_posts)))
|
||||||
{
|
|
||||||
$phpEx = substr(strrchr(__FILE__, '.'), 1);
|
|
||||||
include_once($phpbb_root_path . 'includes/bbcode.' . $phpEx);
|
|
||||||
$bbcode = new bbcode(base64_encode($bbcode_bitfield));
|
|
||||||
}
|
|
||||||
$posts = array();
|
|
||||||
$i = 0;
|
|
||||||
while ( ($row = $db->sql_fetchrow($result)) && ( ($i < $number_of_posts) || ($number_of_posts == '0') ) )
|
|
||||||
{
|
|
||||||
if ( ($auth->acl_get('f_read', $row['forum_id'])) || ($row['forum_id'] == '0') )
|
|
||||||
{
|
{
|
||||||
if ($row['user_id'] != ANONYMOUS && $row['user_colour'])
|
die('Could not query topic information for board Portal news section');
|
||||||
{
|
|
||||||
$row['username'] = '<b style="color:#' . $row['user_colour'] . '">' . $row['username'] . '</b>';
|
|
||||||
}
|
|
||||||
$posts[$i]['bbcode_uid'] = $row['bbcode_uid'];
|
|
||||||
$len_check = $row['post_text'];
|
|
||||||
$maxlen = $text_length;
|
|
||||||
if (($text_length != 0) && (strlen($len_check) > $text_length))
|
|
||||||
{
|
|
||||||
$posts[$i]['post_text'] = censor_text(get_sub_taged_string(str_replace("\n", '<br/> ', $row['post_text']), $row['bbcode_uid'], $maxlen));
|
|
||||||
$posts[$i]['striped'] = true;
|
|
||||||
} else $posts[$i]['post_text'] = censor_text($row['post_text']);
|
|
||||||
|
|
||||||
$posts[$i]['topic_id'] = $row['topic_id'];
|
|
||||||
$posts[$i]['topic_last_post_id'] = $row['topic_last_post_id'];
|
|
||||||
$posts[$i]['forum_id'] = $row['forum_id'];
|
|
||||||
$posts[$i]['topic_replies'] = $row['topic_replies'];
|
|
||||||
$posts[$i]['topic_time'] = $user->format_date($row['topic_time']);
|
|
||||||
$posts[$i]['topic_last_post_time'] = $row['topic_last_post_time'];
|
|
||||||
$posts[$i]['topic_title'] = $row['topic_title'];
|
|
||||||
$posts[$i]['username'] = $row['username'];
|
|
||||||
$posts[$i]['user_id'] = $row['user_id'];
|
|
||||||
$posts[$i]['user_type'] = $row['user_type'];
|
|
||||||
$posts[$i]['user_user_colour'] = $row['user_colour'];
|
|
||||||
$posts[$i]['poll'] = ($row['poll_title']) ? true : false;
|
|
||||||
$posts[$i]['attachment'] = ($row['topic_attachment']) ? true : false;
|
|
||||||
$posts[$i]['topic_views'] = ($row['topic_views']);
|
|
||||||
$posts[$i]['forum_name'] = ($row['forum_name']);
|
|
||||||
|
|
||||||
$message = $posts[$i]['post_text'];
|
|
||||||
$message = str_replace("\n", '<br />', $message);
|
|
||||||
|
|
||||||
|
|
||||||
if ($auth->acl_get('f_html', $forum_id))
|
|
||||||
{
|
|
||||||
$message = preg_replace('#<!\-\-(.*?)\-\->#is', '', $message); // Remove Comments from post content
|
|
||||||
}
|
|
||||||
// Second parse bbcode here
|
|
||||||
if ($row['bbcode_bitfield'])
|
|
||||||
{
|
|
||||||
$bbcode->bbcode_second_pass($message, $row['bbcode_uid'], $row['bbcode_bitfield']);
|
|
||||||
}
|
|
||||||
$message = smiley_text($message); // Always process smilies after parsing bbcodes
|
|
||||||
$posts[$i]['post_text']= ap_validate($message);
|
|
||||||
$i++;
|
|
||||||
}
|
}
|
||||||
}
|
|
||||||
// return the result
|
//
|
||||||
return $posts;
|
// fetch all postings
|
||||||
}
|
//
|
||||||
|
|
||||||
// news - get last post
|
// Instantiate BBCode if need be
|
||||||
|
if ($bbcode_bitfield !== '')
|
||||||
else if ($type == 'news_all')
|
{
|
||||||
{
|
$phpEx = substr(strrchr(__FILE__, '.'), 1);
|
||||||
// not show global announcements
|
include_once($phpbb_root_path . 'includes/bbcode.' . $phpEx);
|
||||||
$topic_type = '( t.topic_type != ' . POST_ANNOUNCE . ' ) AND ( t.topic_type != ' . POST_GLOBAL . ') AND';
|
$bbcode = new bbcode(base64_encode($bbcode_bitfield));
|
||||||
|
}
|
||||||
|
$i = 0;
|
||||||
|
while ( ($row = $db->sql_fetchrow($result)) && ( ($i < $number_of_posts) || ($number_of_posts == '0') ) )
|
||||||
|
{
|
||||||
|
if ( ($auth->acl_get('f_read', $row['forum_id'])) || ($row['forum_id'] == '0') )
|
||||||
|
{
|
||||||
|
if ($row['user_id'] != ANONYMOUS && $row['user_colour'])
|
||||||
|
{
|
||||||
|
$row['username'] = '<b style="color:#' . $row['user_colour'] . '">' . $row['username'] . '</b>';
|
||||||
|
}
|
||||||
|
$posts[$i]['bbcode_uid'] = $row['bbcode_uid'];
|
||||||
|
$len_check = $row['post_text'];
|
||||||
|
$maxlen = $text_length;
|
||||||
|
if (($text_length != 0) && (strlen($len_check) > $text_length))
|
||||||
|
{
|
||||||
|
$posts[$i]['post_text'] = censor_text(get_sub_taged_string(str_replace("\n", '<br/> ', $row['post_text']), $row['bbcode_uid'], $maxlen));
|
||||||
|
$posts[$i]['striped'] = true;
|
||||||
|
} else $posts[$i]['post_text'] = censor_text($row['post_text']);
|
||||||
|
|
||||||
|
|
||||||
|
$posts[$i]['topic_id'] = $row['topic_id'];
|
||||||
|
$posts[$i]['topic_last_post_id'] = $row['topic_last_post_id'];
|
||||||
|
$posts[$i]['forum_id'] = $row['forum_id'];
|
||||||
|
$posts[$i]['topic_replies'] = $row['topic_replies'];
|
||||||
|
$posts[$i]['topic_time'] = $user->format_date($row['topic_last_post_time']);
|
||||||
|
$posts[$i]['topic_last_post_time'] = $row['topic_last_post_time'];
|
||||||
|
$posts[$i]['topic_title'] = $row['topic_title'];
|
||||||
|
$posts[$i]['username'] = $row['username'];
|
||||||
|
$posts[$i]['user_id'] = $row['user_id'];
|
||||||
|
$posts[$i]['user_type'] = $row['user_type'];
|
||||||
|
$posts[$i]['user_user_colour'] = $row['user_colour'];
|
||||||
|
$posts[$i]['poll'] = ($row['poll_title']) ? true : false;
|
||||||
|
$posts[$i]['attachment'] = ($row['topic_attachment']) ? true : false;
|
||||||
|
$posts[$i]['topic_views'] = ($row['topic_views']);
|
||||||
|
$posts[$i]['forum_name'] = ($row['forum_name']);
|
||||||
|
|
||||||
|
$message = $posts[$i]['post_text'];
|
||||||
|
$message = str_replace("\n", '<br/> ', $message);
|
||||||
|
|
||||||
|
|
||||||
|
if ($auth->acl_get('f_html', $row['forum_id']))
|
||||||
|
{
|
||||||
|
$message = preg_replace('#<!\-\-(.*?)\-\->#is', '', $message); // Remove Comments from post content
|
||||||
|
}
|
||||||
|
// Second parse bbcode here
|
||||||
|
if ($row['bbcode_bitfield'])
|
||||||
|
{
|
||||||
|
$bbcode->bbcode_second_pass($message, $row['bbcode_uid'], $row['bbcode_bitfield']);
|
||||||
|
}
|
||||||
|
$message = smiley_text($message); // Always process smilies after parsing bbcodes
|
||||||
|
$posts[$i]['post_text']= ap_validate($message);
|
||||||
|
$i++;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
// return the result
|
||||||
|
return $posts;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
// only normal topic
|
return array();
|
||||||
$topic_type = 't.topic_type = ' . POST_NORMAL . ' AND';
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
$sql = 'SELECT
|
|
||||||
t.forum_id,
|
|
||||||
t.topic_id,
|
|
||||||
t.topic_last_post_id,
|
|
||||||
t.topic_last_post_time,
|
|
||||||
t.topic_time,
|
|
||||||
t.topic_title,
|
|
||||||
t.topic_attachment,
|
|
||||||
t.topic_views,
|
|
||||||
t.poll_title,
|
|
||||||
t.topic_replies,
|
|
||||||
t.forum_id,
|
|
||||||
t.topic_poster,
|
|
||||||
u.username,
|
|
||||||
u.user_id,
|
|
||||||
u.user_type,
|
|
||||||
u.user_colour,
|
|
||||||
p.post_id,
|
|
||||||
p.post_time,
|
|
||||||
p.post_text,
|
|
||||||
p.post_attachment,
|
|
||||||
p.enable_smilies,
|
|
||||||
p.enable_bbcode,
|
|
||||||
p.enable_magic_url,
|
|
||||||
p.bbcode_bitfield,
|
|
||||||
p.bbcode_uid,
|
|
||||||
f.forum_name
|
|
||||||
FROM
|
|
||||||
' . TOPICS_TABLE . ' AS t,
|
|
||||||
' . USERS_TABLE . ' AS u,
|
|
||||||
' . POSTS_TABLE . ' AS p,
|
|
||||||
' . FORUMS_TABLE . ' AS f
|
|
||||||
WHERE
|
|
||||||
' . $topic_type . '
|
|
||||||
' . $from_forum . '
|
|
||||||
' . $post_time . '
|
|
||||||
t.topic_last_poster_id = u.user_id AND
|
|
||||||
t.topic_last_post_id = p.post_id AND
|
|
||||||
t.topic_status <> 2 AND
|
|
||||||
t.topic_approved = 1 AND
|
|
||||||
f.forum_id = t.forum_id
|
|
||||||
|
|
||||||
ORDER BY
|
|
||||||
t.topic_last_post_time DESC';
|
|
||||||
|
|
||||||
|
|
||||||
// query the database
|
|
||||||
if(!($result = $db->sql_query_limit($sql, $number_of_posts)))
|
|
||||||
{
|
|
||||||
die('Could not query topic information for board Portal news section');
|
|
||||||
}
|
|
||||||
|
|
||||||
//
|
|
||||||
// fetch all postings
|
|
||||||
//
|
|
||||||
|
|
||||||
// Instantiate BBCode if need be
|
|
||||||
if ($bbcode_bitfield !== '')
|
|
||||||
{
|
|
||||||
$phpEx = substr(strrchr(__FILE__, '.'), 1);
|
|
||||||
include_once($phpbb_root_path . 'includes/bbcode.' . $phpEx);
|
|
||||||
$bbcode = new bbcode(base64_encode($bbcode_bitfield));
|
|
||||||
}
|
|
||||||
$posts = array();
|
|
||||||
$i = 0;
|
|
||||||
while ( ($row = $db->sql_fetchrow($result)) && ( ($i < $number_of_posts) || ($number_of_posts == '0') ) )
|
|
||||||
{
|
|
||||||
if ( ($auth->acl_get('f_read', $row['forum_id'])) || ($row['forum_id'] == '0') )
|
|
||||||
{
|
|
||||||
if ($row['user_id'] != ANONYMOUS && $row['user_colour'])
|
|
||||||
{
|
|
||||||
$row['username'] = '<b style="color:#' . $row['user_colour'] . '">' . $row['username'] . '</b>';
|
|
||||||
}
|
|
||||||
$posts[$i]['bbcode_uid'] = $row['bbcode_uid'];
|
|
||||||
$len_check = $row['post_text'];
|
|
||||||
$maxlen = $text_length;
|
|
||||||
if (($text_length != 0) && (strlen($len_check) > $text_length))
|
|
||||||
{
|
|
||||||
$posts[$i]['post_text'] = censor_text(get_sub_taged_string(str_replace("\n", '<br/> ', $row['post_text']), $row['bbcode_uid'], $maxlen));
|
|
||||||
$posts[$i]['striped'] = true;
|
|
||||||
} else $posts[$i]['post_text'] = censor_text($row['post_text']);
|
|
||||||
|
|
||||||
|
|
||||||
$posts[$i]['topic_id'] = $row['topic_id'];
|
|
||||||
$posts[$i]['topic_last_post_id'] = $row['topic_last_post_id'];
|
|
||||||
$posts[$i]['forum_id'] = $row['forum_id'];
|
|
||||||
$posts[$i]['topic_replies'] = $row['topic_replies'];
|
|
||||||
$posts[$i]['topic_time'] = $user->format_date($row['topic_last_post_time']);
|
|
||||||
$posts[$i]['topic_last_post_time'] = $row['topic_last_post_time'];
|
|
||||||
$posts[$i]['topic_title'] = $row['topic_title'];
|
|
||||||
$posts[$i]['username'] = $row['username'];
|
|
||||||
$posts[$i]['user_id'] = $row['user_id'];
|
|
||||||
$posts[$i]['user_type'] = $row['user_type'];
|
|
||||||
$posts[$i]['user_user_colour'] = $row['user_colour'];
|
|
||||||
$posts[$i]['poll'] = ($row['poll_title']) ? true : false;
|
|
||||||
$posts[$i]['attachment'] = ($row['topic_attachment']) ? true : false;
|
|
||||||
$posts[$i]['topic_views'] = ($row['topic_views']);
|
|
||||||
$posts[$i]['forum_name'] = ($row['forum_name']);
|
|
||||||
|
|
||||||
$message = $posts[$i]['post_text'];
|
|
||||||
$message = str_replace("\n", '<br/> ', $message);
|
|
||||||
|
|
||||||
|
|
||||||
if ($auth->acl_get('f_html', $forum_id))
|
|
||||||
{
|
|
||||||
$message = preg_replace('#<!\-\-(.*?)\-\->#is', '', $message); // Remove Comments from post content
|
|
||||||
}
|
|
||||||
// Second parse bbcode here
|
|
||||||
if ($row['bbcode_bitfield'])
|
|
||||||
{
|
|
||||||
$bbcode->bbcode_second_pass($message, $row['bbcode_uid'], $row['bbcode_bitfield']);
|
|
||||||
}
|
|
||||||
$message = smiley_text($message); // Always process smilies after parsing bbcodes
|
|
||||||
$posts[$i]['post_text']= ap_validate($message);
|
|
||||||
$i++;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
// return the result
|
|
||||||
return $posts;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
Reference in New Issue
Block a user