vb.org Archive

vb.org Archive (https://vborg.vbsupport.ru/index.php)
-   Modification Requests/Questions (Unpaid) (https://vborg.vbsupport.ru/forumdisplay.php?f=112)
-   -   auto-creating a forum? (https://vborg.vbsupport.ru/showthread.php?t=61419)

Wired1 02-11-2004 02:49 AM

auto-creating a forum?
 
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)

PHP Code:

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

PHP Code:

$DB_site->query(fetch_query_sql($forum'forum')); 

that's the important part ;)

Wired1 02-12-2004 02:06 AM

This is interesting...
Code:

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:
Code:

        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:
PHP Code:

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.


All times are GMT. The time now is 08:08 PM.

Powered by vBulletin® Version 3.8.12 by vBS
Copyright ©2000 - 2025, vBulletin Solutions Inc.

X vBulletin 3.8.12 by vBS Debug Information
  • Page Generation 0.01043 seconds
  • Memory Usage 1,753KB
  • Queries Executed 10 (?)
More Information
Template Usage:
  • (1)ad_footer_end
  • (1)ad_footer_start
  • (1)ad_header_end
  • (1)ad_header_logo
  • (1)ad_navbar_below
  • (2)bbcode_code_printable
  • (3)bbcode_php_printable
  • (1)footer
  • (1)gobutton
  • (1)header
  • (1)headinclude
  • (6)option
  • (1)pagenav
  • (1)pagenav_curpage
  • (1)pagenav_pagelink
  • (1)post_thanks_navbar_search
  • (1)printthread
  • (10)printthreadbit
  • (1)spacer_close
  • (1)spacer_open 

Phrase Groups Available:
  • global
  • postbit
  • showthread
Included Files:
  • ./printthread.php
  • ./global.php
  • ./includes/init.php
  • ./includes/class_core.php
  • ./includes/config.php
  • ./includes/functions.php
  • ./includes/class_hook.php
  • ./includes/modsystem_functions.php
  • ./includes/class_bbcode_alt.php
  • ./includes/class_bbcode.php
  • ./includes/functions_bigthree.php 

Hooks Called:
  • init_startup
  • init_startup_session_setup_start
  • init_startup_session_setup_complete
  • cache_permissions
  • fetch_threadinfo_query
  • fetch_threadinfo
  • fetch_foruminfo
  • style_fetch
  • cache_templates
  • global_start
  • parse_templates
  • global_setup_complete
  • printthread_start
  • pagenav_page
  • pagenav_complete
  • bbcode_fetch_tags
  • bbcode_create
  • bbcode_parse_start
  • bbcode_parse_complete_precache
  • bbcode_parse_complete
  • printthread_post
  • printthread_complete