The Arcive of Official vBulletin Modifications Site.It is not a VB3 engine, just a parsed copy! |
|
#1
|
|||
|
|||
New Forum via PHP, however.... Need help
I'm able to add a row to the "forum" table via PHP, however the newly created database entry for the forum only actually shows up anywhere in the forum and in the admin control panel is if you are in Forum Management And you click "save display order".
Does anybody know if there is another table that needs an entry or is it a data manager issue? There has to be a way to do it. Any help would be appreciated. |
#2
|
|||
|
|||
If you're doing your add in a plugin or a custom page using vbulletin code, then you should use the forum datamanager (in includes/class_dm_forum.php). You can see how to use it in by looking in admincp/forum.php, the section that starts with:
Code:
// ###################### Start update ####################### if ($_POST['do'] == 'update') I don't know the answer to your question offhand, but looking at that code a little bit and when the datamanager saves a forum it calls build_forum_permissions() in includes/adminfunctions.php, and I believe that also rebuilds the forumcache, which is probably your problem. If you can't include the vbulletin code so that you can use those fucntions, then you might want to look in there and see what it's doing. |
#3
|
||||
|
||||
PHP Code:
You should run function PHP Code:
|
#4
|
||||
|
||||
Can I ask what your plans are? Adding forums/tables directly via the database isn't ideal.
|
#5
|
||||
|
||||
Yeah I don't get it, if you want to add forums, why not just use the forum manager?
|
#6
|
|||
|
|||
Quote:
The I saw the do:update thing last night as I was cruisin through the code. I'm just not sure how to supply information to the datamanager and haven't yet tried to utilize it via PHP only. It looks like it should be included in my custom page and then supplied the do=update (however I am going to guess that update is an array with all the data I want in it.) This is just a theory right now and I've got a lack of knowledge basis of how to interact with the datamanager to do a practical test. Looking at class_dm_forum.php I see how its done, but still not sure how to interact with the manager. Quote:
Ozzy, I have a custom coded page where I can add a "clan" and assign a usergroup ('leader') to that clan as well as have it automatically generate an X amount of forums and child forums for it. A lot less work and more automation means much more time spent elsewhere. |
#7
|
||||
|
||||
Gotcha, sounds logical. Thanks for the explanation.
|
#8
|
|||
|
|||
Quote:
You would do something like this: Code:
$forumdata =& datamanager_init('Forum', $vbulletin, ERRTYPE_SILENT); // set info with calls like // $forumdata->set_bitfield('options', $varname, $value); or // $forumdata->set($varname, $value); $forumid = $forumdata->save(); And that should take care of everything. For the info part, you would make multiple calls to $forumdata->set() or $forumdata->set_bitfield(), and of course what to use as $varname and $value is the question. You can find out by looking at the html for the form you fill out when creating a forum in the admincp. If a field is named like name="forum[displayorder]" that corresponds to Code:
$forumdata->set('displayorder', $value); and if it's named like forum[options][moderatenewpost] then that corresponds to Code:
$forumdata->set_bitfield('options', 'moderatenewpost', $value); The 'set' names probably correspond to database column names, so it's really the options that might be difficult to figure out. Anyway, I hope that helps. |
Благодарность от: | ||
ozzy47 |
#9
|
|||
|
|||
OK, I went ahead and added a couple of lines to print out what gets set when you create a forum from the forum manager, so here's the complete code that should create a forum with the defaults:
Code:
$forumdata =& datamanager_init('Forum', $vbulletin, ERRTYPE_SILENT); $forumdata->set(title, 'test forum'); $forumdata->set(description, 'This is a test'); $forumdata->set(link, ''); $forumdata->set(displayorder, 1); $forumdata->set(parentid, -1); $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', bypassdp, 0); $forumdata->set_bitfield('options', allowhtml, 0); $forumdata->set_bitfield('options', allowbbcode, 1); $forumdata->set_bitfield('options', allowimages, 1); $forumdata->set_bitfield('options', allowvideos, 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_bitfield('options', prefixrequired, 0); $forumdata->set_bitfield('options', displaywrt, 1); $forumdata->set_bitfield('options', canreputation, 1); $forumdata->set(styleid, 0); $forumdata->set(imageprefix, ''); $forumdata->set(password, ''); $forumid = $forumdata->save(); |
Благодарность от: | ||
bridge2heyday |
#10
|
|||
|
|||
sweet deal man. Much appreciation. The options actually wont be to much of a problem. I've figured out that the options column in the forum table are a bit when it is saved. So I made a forum with the options I wanted and I will be using that bit value.
I will try it out and post here my results, if any. haha --------------- Added [DATE]1421845661[/DATE] at [TIME]1421845661[/TIME] --------------- That's pretty nice of you KH99. One last thing I have a question about, what files do I need to include for that code. here's what I have now, and I'm assuming: admincp/forum.php as require_once('./admincp/forum.php'); Another thought... Is how do I overcome the fact that a login is required and ability to admin is requried.... Is there anything else I need to include so that it can look at session ID of the USER that is executing the script as such? this is all pretty new to me. The datamanager looks like a pretty interesting way to input data to the forum. |
|
|
X vBulletin 3.8.12 by vBS Debug Information | |
---|---|
|
|
More Information | |
Template Usage:
Phrase Groups Available:
|
Included Files:
Hooks Called:
|