Log in

View Full Version : Automatically creating forums


DB03
02-05-2006, 02:57 PM
Is there anyway I can run a script to automatically create a forum (instead of doing it through the admin cp)? I tried adding an entry to the forum database but it seems like I might have to add another entry somewhere as it does not show up in the admin cp. Thanks.

Marco van Herwaarden
02-05-2006, 08:04 PM
What is it you are trying to achieve?

DeMiNe0
03-07-2006, 11:35 PM
I have the same question. I have a set of about 10 forums that takes me an extra half hour to create every time i need to add new ones. If i can just run a query or script to make them all in one shot, it would speed things up alot.

zell_11
03-08-2006, 02:55 PM
What like having carbon copy forums that runs x amount of time. So the forums would have same premissions, same moderator, same parent catagory but diffrent name?

Tell me if this is what you are looking for

DeMiNe0
03-10-2006, 01:06 AM
yes. exactly. All i would need to do is run a script and imput the names i want the forums to have,

DeMiNe0
03-11-2006, 09:00 PM
This is becoming harder then i thought to do lol.

Borgs8472
03-11-2006, 09:13 PM
On topic, some command line type functions might be helpful as an alternative to the admincp at times.

nitro
03-11-2006, 10:29 PM
why dont you just drop your query into the query box in cp or phpmyadmin ?

You could probably run a php script at command line with args as well so you would just do something like this in ssh #php newforum.php blabla and the php script as long as it had the right query would just do what you wanted.

merk
03-12-2006, 07:42 AM
You can just add the entries via SQL, but you will have to rebuild the forum information, easiest way is to edit a forum then save it.

Harder way would be to look for the correct datastore function to rebuild forum information.

OR - use the forum datamanager.

thomberg
05-12-2006, 11:12 AM
Datamanager i wrote to create a forum:

<?php
define('THIS_SCRIPT','datamanager');
define('SKIP_SESSIONCREATE',true);
chdir('..'); // change directory to your forum home with global.php in it
require_once('./global.php');

if (count($_SERVER['argv']) < 3) die ("Usage: ".__FILE__." <forumname> <parentid> [<description>]\n");

$forumdata =& datamanager_init('Forum', $vbulletin, ERRTYPE_ARRAY);

// arguments
$forumdata->set('title', $_SERVER['argv'][1]);
$forumdata->set('parentid', $_SERVER['argv'][2]);
if ($_SERVER['argv'][3]) $forumdata->set('description', $_SERVER['argv'][3]);

// your default settings
$forumdata->set('displayorder', 1);
$forumdata->set_bitfield('options', 'active', 1);
$forumdata->set_bitfield('options', 'allowposting', 1);
$forumdata->set_bitfield('options', 'cancontainthreads', 1);
$forumdata->set_bitfield('options', 'moderatenewpost', 0);
$forumdata->set_bitfield('options', 'moderatenewthread', 0);
$forumdata->set_bitfield('options', 'moderateattach', 0);
$forumdata->set_bitfield('options', 'allowbbcode', 1);
$forumdata->set_bitfield('options', 'allowimages', 1);
$forumdata->set_bitfield('options', 'allowhtml', 0);
$forumdata->set_bitfield('options', 'allowsmilies', 1);
$forumdata->set_bitfield('options', 'allowicons', 1);
$forumdata->set_bitfield('options', 'allowratings', 0);
$forumdata->set_bitfield('options', 'countposts', 1);
$forumdata->set_bitfield('options', 'canhavepassword', 0);
$forumdata->set_bitfield('options', 'indexposts', 1);
$forumdata->set_bitfield('options', 'styleoverride', 0);
$forumdata->set_bitfield('options', 'showonforumjump', 1);
$forumdata->set_bitfield('options', 'warnall', 0);


// check for errors
if (!empty($forumdata->errors))
{
$errorlist = '';
foreach ($forumdata->errors AS $index => $error)
{
$errorlist .= $error."\n";
}
echo $errorlist;

// ... additional code; $errorlist is outputted to the user
}
else
{
// save the data

$vbulletin->userinfo['forumid'] = $forumid = $forumdata->save();
echo $forumid;
}

?>

Marco van Herwaarden
05-14-2006, 03:03 PM
I hope you do realize that anyone can create a new forum with that script???

Depending on your settings, even guests could do it.

thomberg
05-14-2006, 07:45 PM
This script gets called by commandline/cronjob

It is not under the document root. So nobody is able to start this script without shell access and execution permissions.