[BETA] Custom BBCode Permissions - (who can use them)

MODs and Styles for phpBB3.

To post your MOD or style, go to the STG MOD Manager
Forum rules
Go to http://startrekguide.com/mods to submit your MOD or style

Re: [BETA] BBcode Permissions

Postby poppertom69 » 11 May 2008, 15:02

Ok mod has been updated you can now put bbcodes into different groups and the functioning of the mod has been greatly improved let me know what you all think to this!
Image
Image
poppertom69    
Supporter
Supporter
 
Posts: 326
Joined: 13 Apr 2007, 08:08
Location: bucks, UK
Favorite Team: STG
Gender: Male
phpBB Knowledge: 8


Re: [BETA] BBcode Permissions

Postby killer-kurt » 13 May 2008, 11:34

Again upon posting...

Spoiler:
General Error
SQL ERROR [ mysql4 ]

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 'ORDER BY extension' at line 4 [1064]

SQL

SELECT * FROM phpbb_extensions_bbcode WHERE group_name = ORDER BY extension

BACKTRACE

FILE: includes/db/mysql.php
LINE: 158
CALL: dbal_mysql->sql_error()

FILE: includes/functions_display.php
LINE: 861
CALL: dbal_mysql->sql_query()

FILE: posting.php
LINE: 1583
CALL: display_custom_bbcodes()
Ultimate Online Advertising! for all your advertising needs!
I am the Confused about deck 15 Crew! Wann join?
User avatar
killer-kurt    
Ensign
Ensign
 
Posts: 99
Joined: 03 Jan 2008, 13:52
Gender: Male

Re: [BETA] BBcode Permissions

Postby poppertom69 » 13 May 2008, 13:33

ok here is the fix sorry about that thats why it is still in beta for testing

Code: Select all
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('&amp;''&quot;'"'"'&lt;''&gt;'), array('&''"'"\'"'<''>'), $row['bbcode_helpline']),
        ));

        
$i++;
    }
    
$db->sql_freeresult($result);    
Last edited by poppertom69 on 13 May 2008, 13:45, edited 1 time in total.
Image
Image
poppertom69    
Supporter
Supporter
 
Posts: 326
Joined: 13 Apr 2007, 08:08
Location: bucks, UK
Favorite Team: STG
Gender: Male
phpBB Knowledge: 8

Re: [BETA] BBcode Permissions

Postby poppertom69 » 13 May 2008, 13:38

fix placed above
Image
Image
poppertom69    
Supporter
Supporter
 
Posts: 326
Joined: 13 Apr 2007, 08:08
Location: bucks, UK
Favorite Team: STG
Gender: Male
phpBB Knowledge: 8

Re: [BETA] BBcode Permissions

Postby killer-kurt » 14 May 2008, 06:31

Getting same error even with the fix when i try to post.

Spoiler:
SQL ERROR [ mysql4 ]

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 'ORDER BY extension' at line 4 [1064]

SQL

SELECT * FROM phpbb_extensions_bbcode WHERE group_name = ORDER BY extension

BACKTRACE

FILE: includes/db/mysql.php
LINE: 158
CALL: dbal_mysql->sql_error()

FILE: includes/functions_display.php
LINE: 864
CALL: dbal_mysql->sql_query()

FILE: posting.php
LINE: 1583
CALL: display_custom_bbcodes()


It will come in time :good: your not doin a bad job.
Ultimate Online Advertising! for all your advertising needs!
I am the Confused about deck 15 Crew! Wann join?
User avatar
killer-kurt    
Ensign
Ensign
 
Posts: 99
Joined: 03 Jan 2008, 13:52
Gender: Male

Re: [BETA] BBcode Permissions

Postby poppertom69 » 14 May 2008, 07:41

ok here is the fix I have found out what was creating the error which was all the permissions being set to one side which i didn't think about but please try this
Code: Select all
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('&amp;', '&quot;', "'", '&lt;', '&gt;'), array('&', '"', "\'", '<', '>'), $row['bbcode_helpline']),
        ));

        $i++;
    }
    $db->sql_freeresult($result);    
} 
Image
Image
poppertom69    
Supporter
Supporter
 
Posts: 326
Joined: 13 Apr 2007, 08:08
Location: bucks, UK
Favorite Team: STG
Gender: Male
phpBB Knowledge: 8

Re: [BETA] BBcode Permissions

Postby killer-kurt » 15 May 2008, 05:27

Now i managed to get to post but when i hit submit i got

Spoiler:
General Error
SQL ERROR [ mysql4 ]

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 'ORDER BY extension' at line 4 [1064]

SQL

SELECT * FROM phpbb_extensions_bbcode WHERE group_name = ORDER BY extension

BACKTRACE

FILE: includes/db/mysql.php
LINE: 158
CALL: dbal_mysql->sql_error()

FILE: posting.php
LINE: 801
CALL: dbal_mysql->sql_query()


We will get there soon :good:
Ultimate Online Advertising! for all your advertising needs!
I am the Confused about deck 15 Crew! Wann join?
User avatar
killer-kurt    
Ensign
Ensign
 
Posts: 99
Joined: 03 Jan 2008, 13:52
Gender: Male

Re: [BETA] BBcode Permissions

Postby poppertom69 » 15 May 2008, 05:34

good I am dumb I applied the fix to the display but not to the posting which will need the same. god i'm silly. Just need to finish this uni work and I'll release beta 3 which the fix to the problems!
Image
Image
poppertom69    
Supporter
Supporter
 
Posts: 326
Joined: 13 Apr 2007, 08:08
Location: bucks, UK
Favorite Team: STG
Gender: Male
phpBB Knowledge: 8

Re: [BETA] Custom BBCode Permissions - (who can use them)

Postby poppertom69 » 15 May 2008, 06:26

Beta 3 released with all the required fixes - first post updated
Image
Image
poppertom69    
Supporter
Supporter
 
Posts: 326
Joined: 13 Apr 2007, 08:08
Location: bucks, UK
Favorite Team: STG
Gender: Male
phpBB Knowledge: 8

Re: [BETA] Custom BBCode Permissions - (who can use them)

Postby killer-kurt » 15 May 2008, 08:22

Ok they are sort of working now. Only issue i got now is this when i go to the permissions in the ACP

Spoiler:
[phpBB Debug] PHP Notice: in file /adm/index.php on line 150: Cannot modify header information - headers already sent by (output started at /language/en/mods/permissions_bbcode.php:45)
[phpBB Debug] PHP Notice: in file /adm/index.php on line 152: Cannot modify header information - headers already sent by (output started at /language/en/mods/permissions_bbcode.php:45)
[phpBB Debug] PHP Notice: in file /adm/index.php on line 153: Cannot modify header information - headers already sent by (output started at /language/en/mods/permissions_bbcode.php:45)
[phpBB Debug] PHP Notice: in file /adm/index.php on line 154: Cannot modify header information - headers already sent by (output started at /language/en/mods/permissions_bbcode.php:45)


And also i did try to use a BBCode with admin allow only and it wouldent let me even though i am an admin...
Also the BBCodes dont display on the post page.

Other than that it sort of works.
Ultimate Online Advertising! for all your advertising needs!
I am the Confused about deck 15 Crew! Wann join?
User avatar
killer-kurt    
Ensign
Ensign
 
Posts: 99
Joined: 03 Jan 2008, 13:52
Gender: Male

PreviousNext

Return to phpBB3 Customizations

Who is online

Users browsing this forum: No registered users and 25 guests