vb.org Archive

vb.org Archive (https://vborg.vbsupport.ru/index.php)
-   vBulletin 3 Articles (https://vborg.vbsupport.ru/forumdisplay.php?f=187)
-   -   HowTo Create Custom Usergroup Permissions (https://vborg.vbsupport.ru/showthread.php?t=82844)

Brinnie 07-29-2005 08:08 PM

very nice,

thank you! :D

Mr Blunt 08-21-2005 04:50 AM

KirbyDE .... Great How-To!!

One thing I would like to point out to everyone which I think is extremely relevant to this thread is the install="X" field will not be recognized during a product installation script ... at least not without extra code which I haven't figured out how to write yet. Simply rebuilding the bitfields (while it will allow the new permissions to begin functioning) will result in all zero's as default for all groups.

http://www.vbulletin.com/forum/bugs3...iew&bugid=1054

This is the vBulletin response.

Quote:

Originally Posted by John
This is happening because the install field in the bitfield XML is only used when vBulletin is first installed (see lines 2280-2315 in install/mysql_schema.php). You may want to reproduce some of the code from there in your plugin to get it to take up the default values.

I played with this all day today and basically got nowhere.
Maybe someone else will have better luck than me.

Andreas 08-23-2005 12:57 PM

Untested, but

PHP Code:

 // Rebuild Bitfields
require_once(DIR '/includes/class_bitfield_builder.php');
vB_Bitfield_Builder::save($db);
$myobj =& vB_Bitfield_Builder::init();

$groupinfo = array();

for (
$x 1$x 9$x++)
{
    
$groupinfo["$x"]['mypermissions'] = 0;
}

foreach (
$myobj->data['ugp']['mypermissions'] AS $permtitle => $permvalue)
{
    if (empty(
$permvalue['group']))
    {
        continue;
    }

    if (!empty(
$permvalue['install']))
    {
        foreach (
$permvalue['install'] AS $gid)
        {
            
$groupinfo["$gid"]['mypermission'] += $permvalue['value'];
        }
    }
}

foreach (
$groupinfo AS $usergroupid => $permissions)
{
    
$db->query_write("UPDATE " TABLE_PREFIX "usergroup SET mypermissions=$permissions[mypermissions] WHERE usergroupid=$usergroupid");
}
build_forum_permissions(); 


Mr Blunt 08-23-2005 05:55 PM

You were close Kirby
You only forgot the WHERE usergroupid=$usergroupid in the query.
Works like a charm!!!
Thank you, Sir!!

PHP Code:

    $db->hide_errors();
    
$db->query_write("UPDATE " TABLE_PREFIX "usergroup SET mypermissions=$permissions[mypermissions] WHERE usergroupid=$usergroupid");
    
$db->show_errors(); 


Andreas 08-23-2005 05:58 PM

I knew there was a reason why I specified a Variable for the Key in foreach() :p

Kirk Y 08-23-2005 07:36 PM

lol... Kirby, might I ask why I'm in your signature?

Andreas 08-23-2005 07:43 PM

Yes. I've read this Post you made and found it very amusing :)

Mr Blunt 08-23-2005 08:16 PM

Can anyone verify or deny for certain if two of the same "canfoo" bitfield names can exist as long as they are each under a different groupname?

For example, something like "canview" under groupname "bluntswhodlpermissions".

I could see almost every hack using a "canview", LOL, but the groupname is very unique.

I ask because I do see a lot of vbulletin code which checks for clashes, but the code gets a little too deep for me to fully understand so far.

I ask in this thread to help reinforce this how-to. I mean if we must all diversify this variable as well, then maybe the how-to should reflect that we should put part of our myhack name in this too somehow .... or maybe we are all good with real simple short vars here if duplicate canfoo's are ok as long as the groupname is unique. I suspect the latter, but I leave it as a question.

Just trying to help avert potential problems down the road while we are all learning the vb350 ways.

Andreas 08-23-2005 08:21 PM

You can have "canfoo" in myperms1, myperms2, mypers3, doesntmatterperms and so on - doesn't cause Problems, as they are different Bitfields and those Names are just Shortcuts for the Bits :)

Mr Blunt 08-23-2005 08:36 PM

3 thumbs up for Kirby!!
Appreciate the time!!


All times are GMT. The time now is 11:58 PM.

Powered by vBulletin® Version 3.8.12 by vBS
Copyright ©2000 - 2024, vBulletin Solutions Inc.

X vBulletin 3.8.12 by vBS Debug Information
  • Page Generation 0.01406 seconds
  • Memory Usage 1,751KB
  • Queries Executed 10 (?)
More Information
Template Usage:
  • (1)ad_footer_end
  • (1)ad_footer_start
  • (1)ad_header_end
  • (1)ad_header_logo
  • (1)ad_navbar_below
  • (2)bbcode_php_printable
  • (1)bbcode_quote_printable
  • (1)footer
  • (1)gobutton
  • (1)header
  • (1)headinclude
  • (6)option
  • (1)pagenav
  • (1)pagenav_curpage
  • (4)pagenav_pagelink
  • (1)post_thanks_navbar_search
  • (1)printthread
  • (10)printthreadbit
  • (1)spacer_close
  • (1)spacer_open 

Phrase Groups Available:
  • global
  • postbit
  • showthread
Included Files:
  • ./printthread.php
  • ./global.php
  • ./includes/init.php
  • ./includes/class_core.php
  • ./includes/config.php
  • ./includes/functions.php
  • ./includes/class_hook.php
  • ./includes/modsystem_functions.php
  • ./includes/class_bbcode_alt.php
  • ./includes/class_bbcode.php
  • ./includes/functions_bigthree.php 

Hooks Called:
  • init_startup
  • init_startup_session_setup_start
  • init_startup_session_setup_complete
  • cache_permissions
  • fetch_threadinfo_query
  • fetch_threadinfo
  • fetch_foruminfo
  • style_fetch
  • cache_templates
  • global_start
  • parse_templates
  • global_setup_complete
  • printthread_start
  • pagenav_page
  • pagenav_complete
  • bbcode_fetch_tags
  • bbcode_create
  • bbcode_parse_start
  • bbcode_parse_complete_precache
  • bbcode_parse_complete
  • printthread_post
  • printthread_complete