Pagina 1 van 1

[EzPortal] Recente Onderwerpen

Geplaatst: 20 apr 2004, 21:37
door djrandall
Ik wil op de portal alleen in recente onderwerpen uit 3 forums hebben. Ingelogd of niet ingelogd:

Code: Selecteer alles

// Bijzondere foprums voor Recente Onderwerpen, bijv. '2,4,10' (bericht: mijn recente onderwerpen script heeft zijn eigen permissie checking, zodat je deze variabel leeg kunt laten)
$CFG['exceptional_forums'] = '21,22,23';

//
// Recente onderwerpen
//
$sql = "SELECT * FROM ". FORUMS_TABLE . " ORDER BY forum_id";
if (!$result = $db->sql_query($sql))
{
	message_die(GENERAL_ERROR, 'Could not query forums information', '', __LINE__, __FILE__, $sql);
}
$forum_data = array();
while( $row = $db->sql_fetchrow($result) )
{
	$forum_data[] = $row;
}

$is_auth_ary = array();
$is_auth_ary = auth(AUTH_ALL, AUTH_LIST_ALL, $userdata, $forum_data);

if( $CFG['exceptional_forums'] == '' )
{
	$except_forum_id = '\'start\'';
}
else
{
	$except_forum_id = $CFG['exceptional_forums'];
}

for ($i = 0; $i < count($forum_data); $i++)
{
	if ((!$is_auth_ary[$forum_data[$i]['forum_id']]['auth_read']) or (!$is_auth_ary[$forum_data[$i]['forum_id']]['auth_view']))
	{
		if ($except_forum_id == '\'start\'')
		{
			$except_forum_id = $forum_data[$i]['forum_id'];
		}
		else
		{
			$except_forum_id .= ',' . $forum_data[$i]['forum_id'];
		}
	}
}
$sql = "SELECT t.topic_id, t.topic_title, t.topic_last_post_id, t.forum_id, p.post_id, p.poster_id, p.post_time, u.user_id, u.username
		FROM " . TOPICS_TABLE . " AS t, " . POSTS_TABLE . " AS p, " . USERS_TABLE . " AS u
		WHERE t.forum_id IN (" . $except_forum_id . ")
			AND t.topic_status <> 2
			AND p.post_id = t.topic_last_post_id
			AND p.poster_id = u.user_id
		ORDER BY p.post_id DESC
		LIMIT " . $CFG['number_recent_topics'];
if (!$result = $db->sql_query($sql))
{
	message_die(GENERAL_ERROR, 'Could not query recent topics information', '', __LINE__, __FILE__, $sql);
}
$number_recent_topics = $db->sql_numrows($result);
$recent_topic_row = array();
while ($row = $db->sql_fetchrow($result))
{
	$recent_topic_row[] = $row;
}
for ($i = 0; $i < $number_recent_topics; $i++)
{
	$template->assign_block_vars('recent_topic_row', array(
		'U_TITLE' => append_sid("viewtopic.$phpEx?" . POST_POST_URL . '=' . $recent_topic_row[$i]['post_id']) . '#' .$recent_topic_row[$i]['post_id'],
		'L_TITLE' => $recent_topic_row[$i]['topic_title'],
		'U_POSTER' => append_sid("profile.$phpEx?mode=viewprofile&" . POST_USERS_URL . "=" . $recent_topic_row[$i]['user_id']),
		'S_POSTER' => $recent_topic_row[$i]['username'],
		'S_POSTTIME' => create_date($board_config['default_dateformat'], $recent_topic_row[$i]['post_time'], $board_config['board_timezone'])
		)
	);
}
//
// BEEINDIG - Recente onderwerpen
//
Heb het originele script aangepast in bovenstaande:
Verandering:

Code: Selecteer alles

WHERE t.forum_id NOT IN (" . $except_forum_id . ")
Verandert in:

Code: Selecteer alles

WHERE t.forum_id IN (" . $except_forum_id . ")
Ingelogde mensen zien nu idd alleen recente onderwerpen uit forum 21,22,23
niet ingelogde mensen zien onderwerpen uit alle forums!

Hoe verander ik dit?

Geplaatst: 20 apr 2004, 21:41
door Luuk
Probeer dit eens:

Code: Selecteer alles

// Bijzondere foprums voor Recente Onderwerpen, bijv. '2,4,10' (bericht: mijn recente onderwerpen script heeft zijn eigen permissie checking, zodat je deze variabel leeg kunt laten) 
$CFG['exceptional_forums'] = '21,22,23'; 

// 
// Recente onderwerpen 
// 
$sql = "SELECT * FROM ". FORUMS_TABLE . " ORDER BY forum_id"; 
if (!$result = $db->sql_query($sql)) 
{ 
   message_die(GENERAL_ERROR, 'Could not query forums information', '', __LINE__, __FILE__, $sql); 
} 
$forum_data = array(); 
while( $row = $db->sql_fetchrow($result) ) 
{ 
   $forum_data[] = $row; 
} 

if( $CFG['exceptional_forums'] == '' ) 
{ 
   $except_forum_id = '\'start\''; 
} 
else 
{ 
   $except_forum_id = $CFG['exceptional_forums']; 
} 

for ($i = 0; $i < count($forum_data); $i++) 
{ 
      if ($except_forum_id == '\'start\'') 
      { 
         $except_forum_id = $forum_data[$i]['forum_id']; 
      } 
      else 
      { 
         $except_forum_id .= ',' . $forum_data[$i]['forum_id']; 
} 
$sql = "SELECT t.topic_id, t.topic_title, t.topic_last_post_id, t.forum_id, p.post_id, p.poster_id, p.post_time, u.user_id, u.username 
      FROM " . TOPICS_TABLE . " AS t, " . POSTS_TABLE . " AS p, " . USERS_TABLE . " AS u 
      WHERE t.forum_id IN (" . $except_forum_id . ") 
         AND t.topic_status <> 2 
         AND p.post_id = t.topic_last_post_id 
         AND p.poster_id = u.user_id 
      ORDER BY p.post_id DESC 
      LIMIT " . $CFG['number_recent_topics']; 
if (!$result = $db->sql_query($sql)) 
{ 
   message_die(GENERAL_ERROR, 'Could not query recent topics information', '', __LINE__, __FILE__, $sql); 
} 
$number_recent_topics = $db->sql_numrows($result); 
$recent_topic_row = array(); 
while ($row = $db->sql_fetchrow($result)) 
{ 
   $recent_topic_row[] = $row; 
} 
for ($i = 0; $i < $number_recent_topics; $i++) 
{ 
   $template->assign_block_vars('recent_topic_row', array( 
      'U_TITLE' => append_sid("viewtopic.$phpEx?" . POST_POST_URL . '=' . $recent_topic_row[$i]['post_id']) . '#' .$recent_topic_row[$i]['post_id'], 
      'L_TITLE' => $recent_topic_row[$i]['topic_title'], 
      'U_POSTER' => append_sid("profile.$phpEx?mode=viewprofile&" . POST_USERS_URL . "=" . $recent_topic_row[$i]['user_id']), 
      'S_POSTER' => $recent_topic_row[$i]['username'], 
      'S_POSTTIME' => create_date($board_config['default_dateformat'], $recent_topic_row[$i]['post_time'], $board_config['board_timezone']) 
      ) 
   ); 
} 
// 
// BEEINDIG - Recente onderwerpen 
//

Geplaatst: 20 apr 2004, 21:45
door djrandall
Kun je me eerst even vertellen wat er nu verandert is?
Ik probeer het namelijk ook te begrijpen :lol:

Geplaatst: 20 apr 2004, 21:52
door djrandall
Ik denk dat er ergens een } te weinig staat.
Nu geeft hij een error op laatste regels van de pagina.

Geplaatst: 21 apr 2004, 08:54
door Luuk
Wat ik gedaan heb is overal de auth check weg te halen...