View Full Version : auto-creating a forum?
Wired1
02-11-2004, 02:49 AM
Does anyone know of a way of auto-creating a forum, other than a normal mySQL command? Looking for the vB function, if it exists.
Andreas
02-11-2004, 03:05 AM
AFAIK there is none.
A draft code could be (not tested)
require_once('./includes/functions_misc.php');
require_once('./includes/adminfunctions_forums.php');
$forum = array(
'parentid' => $parentid,
'title' => 'Some foobar title',
'description' => 'Some foobar description'
);
$parentlist = fetch_forum_parentlist($forum['parentid']);
$DB_site->query(fetch_query_sql($forum, 'forum'));
$forumid = $DB_site->insert_id();
$DB_site->query("
UPDATE " . TABLE_PREFIX . "forum
SET parentlist='" . addslashes("$forumid,$parentlist") . "',
childlist = '$forumid,-1'
WHERE forumid = $forumid
");
build_forum_permissions();
Xenon
02-11-2004, 01:32 PM
$DB_site->query(fetch_query_sql($forum, 'forum'));
that's the important part ;)
Wired1
02-12-2004, 02:06 AM
This is interesting...
function fetch_forum_parentlist($forumid)
{
global $DB_site;
if ($forumid == -1)
{
return '-1';
}
$foruminfo = $DB_site->query_first("SELECT parentid FROM " . TABLE_PREFIX . "forum WHERE forumid = $forumid");
$forumarray = $forumid;
if ($foruminfo['parentid'] != 0)
{
$forumarray .= ',' . fetch_forum_parent_list($foruminfo['parentid']);
}
if (substr($forumarray, -2) != -1)
{
$forumarray .= '-1';
}
return $forumarray;
}
Look at this snippet of that function:
if ($foruminfo['parentid'] != 0)
{
$forumarray .= ',' . fetch_forum_parent_list($foruminfo['parentid']);
}
fetch_forum_parentlist is the name of the function, but it refers to fetch_forum_parent_list ... that function doesn't exist, yet the admin section sub-forum thing works just fine from the admin CP. I'm using RC3, can anyone confirm if this was a bug intro'd in RC3, or was it fixed in RC4?
Andreas
02-12-2004, 02:48 AM
It does exist - in functions.php. Doh! ;)
Wired1
02-12-2004, 03:11 AM
Well, I got it to work, except that Display Order = 0 and every setting except for Apply This Password to Child Forums is set to 0. This setup is not the default. If I'm reading it correct, build_forum_permissions(); is supposed to use the defaults? I'd like for it to use the defaults of the site, or the forum it is a sub-forum of. Here's the code so far:
require_once('./global.php');
require_once('./includes/functions_misc.php');
require_once('./includes/adminfunctions_forums.php');
require_once('./includes/adminfunctions.php');
$foruminfo = array(
'parentid' => 10,
'title' => 'Some foobar title',
'description' => 'Some foobar description'
);
$parentlist = fetch_forum_parentlist($foruminfo['parentid']);
$DB_site->query(fetch_query_sql($foruminfo, 'forum'));
$forumid = $DB_site->insert_id();
$DB_site->query("
UPDATE " . TABLE_PREFIX . "forum
SET parentlist='" . addslashes("$forumid,$parentlist") . "',
childlist = '$forumid,-1'
WHERE forumid = $forumid
");
build_forum_permissions();
Wired1
02-14-2004, 04:27 AM
Is build_forum_permissions(); is supposed to use the forum defaults?
Wired1
02-15-2004, 11:25 PM
:( No one knows? I'm about to update to RC4 to see if they've put in any comments for this function, crossing my fingers for the moment, unless someone else knows.
Update: Nope, RC4 didn't help :(
Wired1
02-22-2004, 08:18 AM
Blatant BUMP...... If I can get this auto forum script to work, I can finally put the pieces of my site together.... PLEASEEEEEEEEEEEEEEEE :)
Yes, I'm desperate enough to whine :)
aspen0
07-30-2006, 04:46 PM
Anyone ever figure this out? I keep getting this error:
Database error in vBulletin 3.0.6:
Invalid SQL: SELECT parentid FROM forum WHERE forumid =
mysql error: You have an error in your SQL syntax. Check the manual that corresponds to your MySQL server version for the right syntax to use near '' at line 1
mysql error number: 1064
I'm using the same exact code.
Wired1
08-08-2006, 11:59 AM
Yeah, but I think there's a couple of tutorials floating around about it now. Goodness knows I can't remember how I did it :)
vBulletin® v3.8.12 by vBS, Copyright ©2000-2025, vBulletin Solutions Inc.