


function display_custom_bbcodes()
{
global $db, $template, $auth;
//Set the bbcode group arrays
$disallowed_bbcode_group = array();
$allowed_bbcode_group = array();
//Find which groups you have permission for and what you don't
$sql = 'SELECT group_name
FROM ' . BBCODE_EXTENSION_GROUPS . '
ORDER BY group_name';
$result = $db->sql_query($sql);
while ($row = $db->sql_fetchrow($result))
{
if (!$auth->acl_get('u_bbcode_group_' . $row['group_name'] . ''))
{
$disallowed_bbcode_group[] = "'" . $row['group_name'] . "'";
}
elseif ($auth->acl_get('u_bbcode_group_' . $row['group_name'] . ''))
{
$allowed_bbcode_group[] = "'" . $row['group_name'] . "'";
}
}
$db->sql_freeresult($result);
//if there is disallowed groups continue
if (sizeof($disallowed_bbcode_group))
{
//Implode to set for each file
$disallowed_separated = implode(" OR group_name = ", $disallowed_bbcode_group);
$allowed_separated = implode(" OR group_name = ", $allowed_bbcode_group);
//Compile the disallowed bbcodes
$disallowed_bbcode = array();
$sql = 'SELECT *
FROM ' . BBCODE_EXTENSIONS . "
WHERE group_name = " . $disallowed_separated . "
ORDER BY extension";
$result = $db->sql_query($sql);
$rows = $db->sql_fetchrowset($result);
foreach ($rows as $row)
{
$disallowed_bbcode[] = "'" . $row['extension'] . "'";
}
$db->sql_freeresult($result);
//Compile the allowed bbcodes
$allowed_bbcode = array();
$sql = 'SELECT *
FROM ' . BBCODE_EXTENSIONS . "
WHERE group_name = " . $allowed_separated . "
ORDER BY extension";
$result = $db->sql_query($sql);
$rows = $db->sql_fetchrowset($result);
foreach ($rows as $row)
{
$allowed_bbcode[] = "'" . $row['extension'] . "'";
}
$db->sql_freeresult($result);
//Check to see the diffenances between the two arrays and pull out overall allowed bbcodes
$bbcode_result = array_diff($disallowed_bbcode, $allowed_bbcode);
//If there is ones they can't see get rid of them
if (sizeof($bbcode_result))
{
$overall_allowed_bbcodes = implode(" AND bbcode_tag <> ", $bbcode_result);
$sql = 'SELECT bbcode_id, bbcode_tag, bbcode_helpline
FROM ' . BBCODES_TABLE . "
WHERE bbcode_tag <> " . $overall_allowed_bbcodes . "
AND display_on_posting = 1
ORDER BY bbcode_tag";
}
//Else they have permission to see them all so display them
else
{
$sql = 'SELECT bbcode_id, bbcode_tag, bbcode_helpline
FROM ' . BBCODES_TABLE . "
WHERE display_on_posting = 1
ORDER BY bbcode_tag";
}
$result = $db->sql_query($sql);
}
//else they have permission to see it all
else
{
$sql = 'SELECT bbcode_id, bbcode_tag, bbcode_helpline
FROM ' . BBCODES_TABLE . "
WHERE display_on_posting = 1
ORDER BY bbcode_tag";
$result = $db->sql_query($sql);
}
// Start counting from 22 for the bbcode ids (every bbcode takes two ids - opening/closing)
$num_predefined_bbcodes = 22;
$i = 0;
while ($row = $db->sql_fetchrow($result))
{
$template->assign_block_vars('custom_tags', array(
'BBCODE_NAME' => "'[{$row['bbcode_tag']}]', '[/" . str_replace('=', '', $row['bbcode_tag']) . "]'",
'BBCODE_ID' => $num_predefined_bbcodes + ($i * 2),
'BBCODE_TAG' => $row['bbcode_tag'],
'BBCODE_HELPLINE' => $row['bbcode_helpline'],
'A_BBCODE_HELPLINE' => str_replace(array('&', '"', "'", '<', '>'), array('&', '"', "\'", '<', '>'), $row['bbcode_helpline']),
));
$i++;
}
$db->sql_freeresult($result);
} 



your not doin a bad job.
function display_custom_bbcodes()
{
global $db, $template, $auth;
//Set the bbcode group arrays
$disallowed_bbcode_group = array();
$allowed_bbcode_group = array();
//Find which groups you have permission for and what you don't
$sql = 'SELECT group_name
FROM ' . BBCODE_EXTENSION_GROUPS . '
ORDER BY group_name';
$result = $db->sql_query($sql);
while ($row = $db->sql_fetchrow($result))
{
if (!$auth->acl_get('u_bbcode_group_' . $row['group_name'] . ''))
{
$disallowed_bbcode_group[] = "'" . $row['group_name'] . "'";
}
elseif ($auth->acl_get('u_bbcode_group_' . $row['group_name'] . ''))
{
$allowed_bbcode_group[] = "'" . $row['group_name'] . "'";
}
}
$db->sql_freeresult($result);
//if there is disallowed groups continue and allowed groups continue
if (sizeof($disallowed_bbcode_group) && sizeof($allowed_bbcode_group))
{
//Implode to set for each file
$disallowed_separated = implode(" OR group_name = ", $disallowed_bbcode_group);
$allowed_separated = implode(" OR group_name = ", $allowed_bbcode_group);
//Compile the disallowed bbcodes
$disallowed_bbcode = array();
$sql = 'SELECT *
FROM ' . BBCODE_EXTENSIONS . "
WHERE group_name = " . $disallowed_separated . "
ORDER BY extension";
$result = $db->sql_query($sql);
$rows = $db->sql_fetchrowset($result);
foreach ($rows as $row)
{
$disallowed_bbcode[] = "'" . $row['extension'] . "'";
}
$db->sql_freeresult($result);
//Compile the allowed bbcodes
$allowed_bbcode = array();
$sql = 'SELECT *
FROM ' . BBCODE_EXTENSIONS . "
WHERE group_name = " . $allowed_separated . "
ORDER BY extension";
$result = $db->sql_query($sql);
$rows = $db->sql_fetchrowset($result);
foreach ($rows as $row)
{
$allowed_bbcode[] = "'" . $row['extension'] . "'";
}
$db->sql_freeresult($result);
//Check to see the diffenances between the two arrays and pull out overall allowed bbcodes
$bbcode_result = array_diff($disallowed_bbcode, $allowed_bbcode);
//If there is ones they can't see get rid of them
if (sizeof($bbcode_result))
{
$overall_allowed_bbcodes = implode(" AND bbcode_tag <> ", $bbcode_result);
$sql = 'SELECT bbcode_id, bbcode_tag, bbcode_helpline
FROM ' . BBCODES_TABLE . "
WHERE bbcode_tag <> " . $overall_allowed_bbcodes . "
AND display_on_posting = 1
ORDER BY bbcode_tag";
}
//Else they have permission to see them all so display them
else
{
$sql = 'SELECT bbcode_id, bbcode_tag, bbcode_helpline
FROM ' . BBCODES_TABLE . "
WHERE display_on_posting = 1
ORDER BY bbcode_tag";
}
$result = $db->sql_query($sql);
}
//if there is disallowed groups but no allowed that means they can't view any so do nothing
elseif (sizeof($disallowed_bbcode_group) && !sizeof($allowed_bbcode_group))
{
//Do nothing here
}
//if there is no disallowed groups then they have permission to see them all
elseif (!sizeof($disallowed_bbcode_group) && sizeof($allowed_bbcode_group))
{
$sql = 'SELECT bbcode_id, bbcode_tag, bbcode_helpline
FROM ' . BBCODES_TABLE . "
WHERE display_on_posting = 1
ORDER BY bbcode_tag";
$result = $db->sql_query($sql);
}
// Start counting from 22 for the bbcode ids (every bbcode takes two ids - opening/closing)
$num_predefined_bbcodes = 22;
$i = 0;
while ($row = $db->sql_fetchrow($result))
{
$template->assign_block_vars('custom_tags', array(
'BBCODE_NAME' => "'[{$row['bbcode_tag']}]', '[/" . str_replace('=', '', $row['bbcode_tag']) . "]'",
'BBCODE_ID' => $num_predefined_bbcodes + ($i * 2),
'BBCODE_TAG' => $row['bbcode_tag'],
'BBCODE_HELPLINE' => $row['bbcode_helpline'],
'A_BBCODE_HELPLINE' => str_replace(array('&', '"', "'", '<', '>'), array('&', '"', "\'", '<', '>'), $row['bbcode_helpline']),
));
$i++;
}
$db->sql_freeresult($result);
} 








Return to phpBB3 Customizations
Users browsing this forum: No registered users and 25 guests