vBulletin Mods

The Official vBulletin Modifications Site
https://www.vbulletin.org/forum/showthread.php?t=316800

New Forum via PHP, however.... Need help
by Medi0cr3
20 Jan 2015 19:14

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.

kh99 20 Jan 2015 19:47

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:

Block Disabled:      (Update License Status)  
Suspended or Unlicensed Members Cannot View Code.


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.

bridge2heyday 20 Jan 2015 20:41


Block Disabled:      (Update License Status)  
Suspended or Unlicensed Members Cannot View Code.

is pulled from datastore ..
You should run function
Block Disabled:      (Update License Status)  
Suspended or Unlicensed Members Cannot View Code.

after your query to update datastore

Zachery 20 Jan 2015 21:56

Can I ask what your plans are? Adding forums/tables directly via the database isn't ideal.

ozzy47 21 Jan 2015 02:15

Yeah I don't get it, if you want to add forums, why not just use the forum manager?

Medi0cr3 21 Jan 2015 10:04

Quote:

Originally Posted by kh99 (Post 2533583)
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:

Block Disabled:      (Update License Status)  
Suspended or Unlicensed Members Cannot View Code.


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.

Thanks kh99,
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:

Originally Posted by bridge2heyday (Post 2533591)
Block Disabled:      (Update License Status)  
Suspended or Unlicensed Members Cannot View Code.

is pulled from datastore ..
You should run function
Block Disabled:      (Update License Status)  
Suspended or Unlicensed Members Cannot View Code.

after your query to update datastore

So after I do an INSERT INTO in the "forum" table, i should include adminfunctions.php and call build_forum_permissions() ??? Not quite sure where you are going with that.

Quote:

Originally Posted by ozzy47 (Post 2533661)
Yeah I don't get it, if you want to add forums, why not just use the forum manager?

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.

ozzy47 21 Jan 2015 10:21

Gotcha, sounds logical. :) Thanks for the explanation.

kh99 21 Jan 2015 11:10

Quote:

Originally Posted by Medi0cr3 (Post 2533706)
Thanks kh99,
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..


You would do something like this:

Block Disabled:      (Update License Status)  
Suspended or Unlicensed Members Cannot View Code.


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

Block Disabled:      (Update License Status)  
Suspended or Unlicensed Members Cannot View Code.


and if it's named like forum[options][moderatenewpost] then that corresponds to

Block Disabled:      (Update License Status)  
Suspended or Unlicensed Members Cannot View Code.


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.

kh99 21 Jan 2015 11:24

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:

Block Disabled:      (Update License Status)  
Suspended or Unlicensed Members Cannot View Code.


Medi0cr3 21 Jan 2015 11:39

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 21 Jan 2015 at 12:07 ---------------

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.

kh99 21 Jan 2015 12:14

Where did you put your code for creating a forum? If you are already including vbulletin's global.php, or if you are writing a plugin, then you probably don't have to explicitly include anything. If this is a custom script that doesn't include vbulletin's global.php then that's more of a problem. In that case it may turn out to be too difficult to use any vbulletin code since it mostly depends on having included global.php, which has a lot of overhead associate with it.

ETA: OK, I see you said above that you're creating a custom page. So if you're not already including vbulletin global.php then you'd have to think about adding it if you want to use the above code.

Medi0cr3 21 Jan 2015 13:40

I have made it practice to include global.php. There's a lot of usage I've done with that one included.

Fatal error: Call to undefined function can_administer() in /home/xxxxxxxxx/xxxxxxxx/forum/admincp/forum.php on line 31



Block Disabled:      (Update License Status)  
Suspended or Unlicensed Members Cannot View Code.

This is a fully functional custom template and I'm logged in. This is close to the developed page. However, I would like to use it on a separate page for the Jquery function to send header requests to, due to my liking of Jquery.

kh99 21 Jan 2015 13:47

You should not be including admincp/forum.php. If you're trying the code I posted above, try it without including anything (ETA: I mean anything more than you are already). The one thing you might need before that code, if your code is inside a function, is

Block Disabled:      (Update License Status)  
Suspended or Unlicensed Members Cannot View Code.


Medi0cr3 21 Jan 2015 14:17

It works great. I need to figure out how to edit it next haha.
I had to add the global variable and all is good.
Here's an example for others to follow if interested

Block Disabled:      (Update License Status)  
Suspended or Unlicensed Members Cannot View Code.


Zachery 21 Jan 2015 16:10

I figured you were trying to automate the creation of forums. Be aware that the system will start to break down around 2000 total forums + usergroups, in any combination. By break down, I mean have too much overhead for data to be processed reguarlly.


All times are GMT. The time now is 20:04.

Powered by vBulletin® Version 3.8.14
Copyright © 2021, MH Sub I, LLC dba vBulletin. All Rights Reserved. vBulletin® is a registered trademark of MH Sub I, LLC
Copyright ©2001 - , vbulletin.org. All rights reserved.