Register Members List Search Today's Posts Mark Forums Read

Reply
 
Thread Tools
  #1  
Old 20 Jan 2015, 19:14
Medi0cr3 Medi0cr3 is offline
 
Join Date: Aug 2014
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.
Reply With Quote
  #2  
Old 20 Jan 2015, 19:47
kh99 kh99 is offline
 
Join Date: Aug 2009
Real name: Kevin
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.
Reply With Quote
  #3  
Old 20 Jan 2015, 20:41
bridge2heyday's Avatar
bridge2heyday bridge2heyday is offline
 
Join Date: Aug 2014

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
__________________
Premium Vbulletin Modifications
Reply With Quote
  #4  
Old 20 Jan 2015, 21:56
Zachery's Avatar
Zachery Zachery is offline
 
Join Date: Jul 2002
Real name: Zachery Woods
Can I ask what your plans are? Adding forums/tables directly via the database isn't ideal.
__________________
Looking for ImpEx?
Reply With Quote
  #5  
Old 21 Jan 2015, 02:15
ozzy47's Avatar
ozzy47 ozzy47 is offline
 
Join Date: Jul 2009
Real name: Chris
Yeah I don't get it, if you want to add forums, why not just use the forum manager?
__________________
You can get access to my 180 mods for vB 3.6 - 4.x at The Admin Zone as well as the professional support you are used to. New vBulletin Spider Definitions, vBulletin Spiders List Hits 1000 Spiders! ​ OzzModz down. Site has had a data breach, checking how the intrusion happened. Change your PW if you use the same one on my site and others.
Reply With Quote
  #6  
Old 21 Jan 2015, 10:04
Medi0cr3 Medi0cr3 is offline
 
Join Date: Aug 2014
Originally Posted by kh99 View Post
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.


Originally Posted by bridge2heyday View Post
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.

Originally Posted by ozzy47 View Post
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.
Reply With Quote
  #7  
Old 21 Jan 2015, 10:21
ozzy47's Avatar
ozzy47 ozzy47 is offline
 
Join Date: Jul 2009
Real name: Chris
Gotcha, sounds logical. Thanks for the explanation.
__________________
You can get access to my 180 mods for vB 3.6 - 4.x at The Admin Zone as well as the professional support you are used to. New vBulletin Spider Definitions, vBulletin Spiders List Hits 1000 Spiders! ​ OzzModz down. Site has had a data breach, checking how the intrusion happened. Change your PW if you use the same one on my site and others.
Reply With Quote
  #8  
Old 21 Jan 2015, 11:10
kh99 kh99 is offline
 
Join Date: Aug 2009
Real name: Kevin
Originally Posted by Medi0cr3 View Post
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.
Reply With Quote
  #9  
Old 21 Jan 2015, 11:24
kh99 kh99 is offline
 
Join Date: Aug 2009
Real name: Kevin
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.

Reply With Quote
  #10  
Old 21 Jan 2015, 11:39
Medi0cr3 Medi0cr3 is offline
 
Join Date: Aug 2014
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.

Last edited by Medi0cr3; 21 Jan 2015 at 12:18.
Reply With Quote
  #11  
Old 21 Jan 2015, 12:14
kh99 kh99 is offline
 
Join Date: Aug 2009
Real name: Kevin
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.

Last edited by kh99; 21 Jan 2015 at 12:22.
Reply With Quote
  #12  
Old 21 Jan 2015, 13:40
Medi0cr3 Medi0cr3 is offline
 
Join Date: Aug 2014
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.

Last edited by Medi0cr3; 21 Jan 2015 at 14:18.
Reply With Quote
  #13  
Old 21 Jan 2015, 13:47
kh99 kh99 is offline
 
Join Date: Aug 2009
Real name: Kevin
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.


Last edited by kh99; 21 Jan 2015 at 14:10.
Reply With Quote
  #14  
Old 21 Jan 2015, 14:17
Medi0cr3 Medi0cr3 is offline
 
Join Date: Aug 2014
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.

Reply With Quote
  #15  
Old 21 Jan 2015, 16:10
Zachery's Avatar
Zachery Zachery is offline
 
Join Date: Jul 2002
Real name: Zachery Woods
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.
__________________
Looking for ImpEx?
Reply With Quote
Reply

Similar Threads
Thread Thread Starter Forum Replies Last Post
Forum Display Enhancements Localize (translate) forum name, forum titles & forum descriptions Analogpoint vBulletin 3.6 Add-ons 37 10 Sep 2012 20:01



Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off


New To Site? Need Help?

All times are GMT. The time now is 03:16.

Layout Options | Width: Wide Color: