SimplePortal

Customization => Blocks and Modifications => Block Requests => Topic started by: EvilGeneral on October 07, 2011, 01:05:07 PM

Title: Help with update
Post by: EvilGeneral on October 07, 2011, 01:05:07 PM
Can anyone help me updating this block to work with  SMF 2.0?

Code: [Select]
global $cat_tree, $boards, $boardList, $scripturl, $sourcedir, $user_info, $db_prefix;

$block_parameters = array(
'num_children' => 'int',
);

if ($return_parameters)
return $block_parameters;

$child_depth = !empty($parameters['num_children']) ? (int) $parameters['num_children'] - 1 : -1;

require_once($sourcedir . '/Subs-Boards.php');
getBoardTree();

// Remobe any boards this user can't actually see.
$temp_boards = $boards;
$request = db_query("
SELECT b.ID_BOARD
FROM {$db_prefix}boards AS b
WHERE !($user_info[query_see_board])", __FILE__, __LINE__);
while ($row = mysql_fetch_assoc($request))
unset($temp_boards[$row['ID_BOARD']]);
mysql_free_result($request);

echo '
<div style="padding-left:2px;">';

foreach ($cat_tree as $catid => $tree)
{
echo '
<span class="sp_navigation_block_cat" style="font-weight:bold;"><a href="', $scripturl, '?action=forum#', $tree['node']['id'], '">', $tree['node']['name'], '</a></span><br />';

foreach ($boardList[$catid] as $boardid)
{


$prefix = '';
for ($i=0; $i<=$boards[$boardid]['level']; $i++)
$prefix .= '-';

echo '
', $prefix, '<span class="sp_navigation_block_board"><a href="', $scripturl, '?board=', $boards[$boardid]['id'], '">', $boards[$boardid]['name'], '</a></span><br />';
}
}

echo '
</div>';
Title: Re: Help with update
Post by: ccbtimewiz on October 07, 2011, 04:11:57 PM
Code: [Select]
global $cat_tree, $boards, $boardList, $scripturl, $sourcedir, $user_info, $smcFunc;

$block_parameters = array(
'num_children' => 'int',
);

if ($return_parameters)
return $block_parameters;

$child_depth = !empty($parameters['num_children']) ? (int) $parameters['num_children'] - 1 : -1;

require_once($sourcedir . '/Subs-Boards.php');
getBoardTree();

// Remove any boards this user can't actually see.
$temp_boards = $boards;
$request = $smcFunc['db_query']('', '
SELECT b.id_board
FROM {db_prefix}boards AS b
WHERE ' . !($user_info['query_see_board']),
array()
);

while ($row = $smcFunc['db_fetch_assoc']($request))
unset($temp_boards[$row['id_board']]);
$smcFunc['db_free_result']($request);

echo '
<div style="padding-left: 2px;">';

foreach ($cat_tree as $catid => $tree)
{
echo '
<span class="sp_navigation_block_cat" style="font-weight:bold;"><a href="', $scripturl, '?action=forum#', $tree['node']['id'], '">', $tree['node']['name'], '</a></span><br />';

foreach ($boardList[$catid] as $boardid)
{
$prefix = '';
for ($i = 0; $i <= $boards[$boardid]['level']; $i++)
$prefix .= '-';

echo '
', $prefix, '<span class="sp_navigation_block_board"><a href="', $scripturl, '?board=', $boards[$boardid]['id'], '">', $boards[$boardid]['name'], '</a></span><br />';
}
}

echo '
</div>';
Title: Re: Help with update
Post by: EvilGeneral on October 10, 2011, 02:05:09 PM
Many thanks, Veridis.

But i've got this:

Code: [Select]
You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near '' at line 3
Arquivo: /public_html/forum/Sources/PortalBlocks.php(3351) : eval()'d code
Linha: 22

  ;)
Title: Re: Help with update
Post by: ccbtimewiz on October 10, 2011, 03:38:27 PM
Ah, sorry about that. Forgot it was changed in 2.0.

Try this instead:
Code: [Select]
global $cat_tree, $boards, $boardList, $scripturl, $sourcedir, $user_info, $smcFunc;

$block_parameters = array(
'num_children' => 'int',
);

if ($return_parameters)
return $block_parameters;

$child_depth = !empty($parameters['num_children']) ? (int) $parameters['num_children'] - 1 : -1;

require_once($sourcedir . '/Subs-Boards.php');
getBoardTree();

// Remove any boards this user can't actually see.
$temp_boards = $boards;
$request = $smcFunc['db_query']('', '
SELECT b.id_board
FROM {db_prefix}boards AS b
WHERE {query_see_board}',
array(
)
);

while ($row = $smcFunc['db_fetch_assoc']($request))
unset($temp_boards[$row['id_board']]);
$smcFunc['db_free_result']($request);

echo '
<div style="padding-left: 2px;">';

foreach ($cat_tree as $catid => $tree)
{
echo '
<span class="sp_navigation_block_cat" style="font-weight:bold;"><a href="', $scripturl, '?action=forum#', $tree['node']['id'], '">', $tree['node']['name'], '</a></span><br />';

foreach ($boardList[$catid] as $boardid)
{
$prefix = '';
for ($i = 0; $i <= $boards[$boardid]['level']; $i++)
$prefix .= '-';

echo '
', $prefix, '<span class="sp_navigation_block_board"><a href="', $scripturl, '?board=', $boards[$boardid]['id'], '">', $boards[$boardid]['name'], '</a></span><br />';
}
}

echo '
</div>';

Title: Re: Help with update
Post by: EvilGeneral on October 13, 2011, 02:40:36 PM
That {query_see_board} really works?
Title: Re: Help with update
Post by: ccbtimewiz on October 13, 2011, 08:04:23 PM
Should work
Title: Re: Help with update
Post by: EvilGeneral on October 14, 2011, 09:47:10 AM
Should work

There is a problem with access permissions.
Guest users are viewing all forum sections.
SimplePortal 2.3.8 © 2008-2024, SimplePortal