Ignoring of permissions in news/announcements now works.

This commit is contained in:
Ice
2008-03-31 10:26:24 +00:00
parent 41d0f997d7
commit 8290db9459

View File

@@ -83,45 +83,40 @@ function phpbb_fetch_posts($forum_from, $permissions, $number_of_posts, $text_le
$str_where = ''; $str_where = '';
if( $permissions ) if( $permissions == TRUE )
{ {
$allow_access = array_unique(array_keys($auth->acl_getf('f_read', true))); $disallow_access = array_unique(array_keys($auth->acl_getf('!f_read', true)));
} else { } else {
$allow_access = array_unique(array_keys($auth->acl_getf('f_', true))); $disallow_access = array();
} }
if( sizeof($allow_access) ){ $global_f = FALSE;
if( sizeof($forum_from) ) if( sizeof($forum_from) )
{ {
foreach( $allow_access as $acc_id ) $disallow_access = array_diff($forum_from, $disallow_access);
{
if( in_array($acc_id, $forum_from ) ) foreach( $disallow_access as $acc_id )
{ {
$str_where .= "t.forum_id = $acc_id OR "; $str_where .= "t.forum_id = $acc_id OR ";
if( !isset($gobal_f) ) if( $global_f === FALSE )
{ {
$global_f = $acc_id; $global_f = $acc_id;
} }
} }
} }
}
else else
{ {
foreach( $allow_access as $acc_id ) foreach( $disallow_access as $acc_id )
{ {
$str_where .= "t.forum_id <> $acc_id OR ";
$str_where .= "t.forum_id = $acc_id OR "; if( $global_f === FALSE )
if( !isset($gobal_f) )
{ {
$global_f = $acc_id; $global_f = $acc_id;
} }
} }
} }
if( strlen($str_where) > 0 )
{
switch( $type ) switch( $type )
{ {
case "announcements": case "announcements":
@@ -136,7 +131,7 @@ function phpbb_fetch_posts($forum_from, $permissions, $number_of_posts, $text_le
case "news": case "news":
$topic_type = 't.topic_type = ' . POST_NORMAL; $topic_type = 't.topic_type = ' . POST_NORMAL;
$str_where = 'AND (' . substr($str_where, 0, -4) . ')'; $str_where = ( strlen($str_where) > 0 ) ? 'AND (' . substr($str_where, 0, -4) . ')' : '';
$user_link = 't.topic_last_poster_id = u.user_id'; $user_link = 't.topic_last_poster_id = u.user_id';
$post_link = 't.topic_last_post_id = p.post_id'; $post_link = 't.topic_last_post_id = p.post_id';
$topic_order = 't.topic_last_post_time DESC'; $topic_order = 't.topic_last_post_time DESC';
@@ -145,7 +140,7 @@ function phpbb_fetch_posts($forum_from, $permissions, $number_of_posts, $text_le
case "news_all": case "news_all":
$topic_type = '( t.topic_type != ' . POST_ANNOUNCE . ' ) AND ( t.topic_type != ' . POST_GLOBAL . ')'; $topic_type = '( t.topic_type != ' . POST_ANNOUNCE . ' ) AND ( t.topic_type != ' . POST_GLOBAL . ')';
$str_where = 'AND (' . substr($str_where, 0, -4) . ')'; $str_where = ( strlen($str_where) > 0 ) ? 'AND (' . substr($str_where, 0, -4) . ')' : '';
$user_link = 't.topic_last_poster_id = u.user_id'; $user_link = 't.topic_last_poster_id = u.user_id';
$post_link = 't.topic_last_post_id = p.post_id'; $post_link = 't.topic_last_post_id = p.post_id';
$topic_order = 't.topic_last_post_time DESC'; $topic_order = 't.topic_last_post_time DESC';
@@ -275,9 +270,6 @@ function phpbb_fetch_posts($forum_from, $permissions, $number_of_posts, $text_le
$i++; $i++;
} }
}
}
return $posts; return $posts;
} }