vb.org Archive

vb.org Archive (https://vborg.vbsupport.ru/index.php)
-   vBulletin 3 Articles (https://vborg.vbsupport.ru/forumdisplay.php?f=187)
-   -   Create Private Group Forums (automatically) (https://vborg.vbsupport.ru/showthread.php?t=172911)

xxclixxx 03-12-2008 10:00 PM

Create Private Group Forums (automatically)
 
I'm in the process of integrating vBulletin into my existing site. Part of that, is I have Teams that have their own private forums. I found the Add new Users article very helpful, so I figured why not share what I figured out too.

Basically what this does is creates a new usergroup, creates a new child forum, and restricts access to the child forum to registered users, and gives access to the new usergroup.

You will need to edit the parentid in the code to the ID of your forum these will be children of. You don't need to do any special permissions to that main forum either, as the permissions are set to the sub children.

You'll notice three sets of forumpermissions. Only edit the one that's below the comment saying to edit that one, if necessary. The others are purposely set to 0 to give the private forums privacy =P

PHP Code:

$teamarray = array (
 
'title' => "Team Title",
 
'description' => "Team Description",
 
'usertitle' => "Team User Title",
 
'opentag' => '',
 
'closetag' => '',
 
'passwordexpires' => '',
 
'passwordhistory' => '',
 
'ispublicgroup' => '0',
 
'canoverride' => '1',
 
'forumpermissions' => 0,
 
'genericpermissions' => 0,
 
'attachlimit' => '1000000',
 
'pmquota' => '0',
 
'pmpermissions' => 0,
 
'pmsendmax' => '5',
 
'calendarpermissions' => 0,
 
'wolpermissions' => 1,
 
'adminpermissions' => 0,
 
'genericoptions' => 41,
 
'profilepicmaxwidth' => '100',
 
'profilepicmaxheight' => '100',
 
'profilepicmaxsize' => '25000',
 
'avatarmaxwidth' => '50',
 
'avatarmaxheight' => '50',
 
'avatarmaxsize' => '20000',
 
'signaturepermissions' => 0,
 
'sigpicmaxwidth' => '',
 
'sigpicmaxheight' => '',
 
'sigpicmaxsize' => '',
 
'sigmaxrawchars' => '',
 
'sigmaxchars' => '',
 
'sigmaxlines' => '',
 
'sigmaxsizebbcode' => '7',
 
'sigmaximages' => '',
);

$db->query_write(fetch_query_sql($teamarray'usergroup'));
$usergroupid $db->insert_id();

$forumdata =& datamanager_init('Forum'$vbulletinERRTYPE_CP);
$forumdata->set('title''Team Name Private Forum');
$forumdata->set('description''The private forum for Team ');
$forumdata->set('link''');
$forumdata->set('displayorder'1);
$forumdata->set('parentid'18);
$forumdata->set('daysprune', -1);
$forumdata->set('defaultsortfield''lastpost');
$forumdata->set('defaultsortorder''desc');
$forumdata->set('showprivate'0);
$forumdata->set('newpostemail''');
$forumdata->set('newthreademail''');
$forumdata->set_bitfield('options''moderatenewpost'0);
$forumdata->set_bitfield('options''moderatenewthread'0);
$forumdata->set_bitfield('options''moderateattach'0);
$forumdata->set_bitfield('options''styleoverride'0);
$forumdata->set_bitfield('options''canhavepassword'1);
$forumdata->set_bitfield('options''cancontainthreads'1);
$forumdata->set_bitfield('options''active'1);
$forumdata->set_bitfield('options''allowposting'1);
$forumdata->set_bitfield('options''indexposts'1);
$forumdata->set_bitfield('options''allowhtml'0);
$forumdata->set_bitfield('options''allowbbcode'1);
$forumdata->set_bitfield('options''allowimages'1);
$forumdata->set_bitfield('options''allowsmilies'1);
$forumdata->set_bitfield('options''allowicons'1);
$forumdata->set_bitfield('options''allowratings'1);
$forumdata->set_bitfield('options''countposts'1);
$forumdata->set_bitfield('options''showonforumjump'1);
$forumdata->set(styleid, -1);
$forumdata->set(password'');

$forumid $forumdata->save();

// Edit the below forumpermissions
$querydata = array(
    
'usergroupid' => $usergroupid,
    
'forumpermissions' => 1048575,
    
'forumid' => $forumid
);
        
$query fetch_query_sql($querydata'forumpermission');
$db->query_write($query);

$querydata = array(
    
'usergroupid' => 2,
    
'forumpermissions' => 0,
    
'forumid' => $forumid
);
        
$query fetch_query_sql($querydata'forumpermission');
$db->query_write($query);        
        
build_forum_permissions(); 

There you go, it should be enough to get you started quicker than it took me. Oh and before you ask, the only included files I am using are these, however I'm also doing other functions as well so I don't really know which ones are required but you can just remove each file one by one until it flips out and wants the file back =P

PHP Code:

define('THIS_SCRIPT'__FILE__);
define('FORUMPATH''/home/startx/public_html/forums');
$cwd getcwd();
chdir(FORUMPATH);
require_once(
'./includes/init.php'); // includes class_core.php
require_once('./includes/class_dm.php'); // for class_dm_user.php
require_once('./includes/class_dm_user.php'); // for user functions
require_once('./includes/functions.php'); // vbsetcookie etc.
require_once('./includes/functions_login.php'); // process login/logout 


ringleader 07-12-2008 02:49 PM

Absolutely smashing stuff - worked first time :D

Thank you for sharing this!


All times are GMT. The time now is 03:42 PM.

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

X vBulletin 3.8.12 by vBS Debug Information
  • Page Generation 0.01164 seconds
  • Memory Usage 1,765KB
  • 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)footer
  • (1)gobutton
  • (1)header
  • (1)headinclude
  • (6)option
  • (1)post_thanks_navbar_search
  • (1)printthread
  • (2)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
  • bbcode_fetch_tags
  • bbcode_create
  • bbcode_parse_start
  • bbcode_parse_complete_precache
  • bbcode_parse_complete
  • printthread_post
  • printthread_complete