vb.org Archive

vb.org Archive (https://vborg.vbsupport.ru/index.php)
-   vB3 Programming Discussions (https://vborg.vbsupport.ru/forumdisplay.php?f=15)
-   -   update forum data from external application (https://vborg.vbsupport.ru/showthread.php?t=190110)

asandhanam 09-05-2008 04:00 PM

update forum data from external application
 
Hi, I'm trying to update the forum table from an external application. Though data gets updated, obviously i don't see changes live because of the forum cache. I've posted a question already in general discussions & was advised to use the datamanager. My application is in coldfusion. I'm just wondering how to handle this. Any suggestions?
If i were to update using datamanager how do i do it? The only thing i'll be able to pass via url is the forumid.
I'm so stuck here and vbulletin is new ground to me. Any help is greatly appreciated.
thanks.

Opserty 09-05-2008 04:10 PM

<a href="http://www.vbulletin.com/docs/html/data_managers" target="_blank">Data Managers</a>

asandhanam 09-21-2008 01:12 AM

I gathered snippets of code from previous posts and came up with this to update the forum table & reset cache. Trying to make this an include from my external app. I'm passing the forumid & the field to be updated.

<?
error_reporting(E_ALL & ~E_NOTICE);
include ('./global.php');
include (DIR . '/includes/adminfunctions_template.php');
include (DIR . '/includes/adminfunctions_forums.php');

$forum_num = $vbulletin->input->clean_gpc('g', 'f', TYPE_NOTRIM);
$sponsored = $vbulletin->input->clean_gpc('g', 's', TYPE_NOTRIM);

$forumdm =& datamanager_init('Forum', $vbulletin, ERRTYPE_STANDARD, 'forum');

$foruminfo = fetch_foruminfo($forum_num);

$forumdm->set_existing($foruminfo);
$forumdm->set('sponsored', $sponsored);

if ($forumdm->save())
echo "saved";
else
echo "error";

?>

Ofcourse i didn't expect it to work right away and so does it. Could someone point out whats wrong and guide me in the right direction.

Thanks.

Marco van Herwaarden 09-22-2008 10:24 AM

Not sure why you are using TYPE_NOTRIM. At least the forumid should be TYPE_INT or TYPE_UINT.

The reason your script is not working will be that 'sponsored' is not in the validfields array.

asandhanam 09-22-2008 03:42 PM

Thanks for your response. I got the TYPE_NOTRIM from one of the previous posts. Where do i find this 'validfields' array?

Lynne 09-22-2008 03:54 PM

class_dm_forum.php

asandhanam 09-22-2008 04:38 PM

I have this script within the includes folder & i tested till here
(../includes/test.php?f=3)

<?
error_reporting(E_ALL & ~E_NOTICE);
include ('./global.php');
include (DIR . '/includes/adminfunctions_template.php');
include (DIR . '/includes/adminfunctions_forums.php');

$forum_num = $vbulletin->input->clean_gpc('g', 'f', TYPE_UNIT);
echo $forum_num;
?>
The page comes up blank indicating error. I don't want to put the script within the admincp as that is a password protected region. As i need to be able to include this from my cfm app, i need this to be outside of admincp. what am i doing wrong? I new to vbulletin so pls help.

Lynne 09-22-2008 04:45 PM

You can't put it in the /includes folder and then have your include lines call those other scripts in that manner. global.php is not in the includes folder. Why are you putting it in the /includes folder to test instead of the regular forum?

asandhanam 09-22-2008 04:54 PM

Right. That was bad decision. I didn't have permissions to upload files to the root. I had to wait for my sys admin to grant permissions..i thought i'll try uploading it to includes folder & test in the mean while..
If i were to put it in root & test, what other class files will i have to include to get this to work. All i want to be able to do is update a new field that i added to the forum table, with the datamanager? Thanks a lot for your time.
BTW i've only tried to include the global.php thats in the root in my prev script. (include './global.php')? I just copied that part from the forum.php in admincp.

--------------- Added [DATE]1222107276[/DATE] at [TIME]1222107276[/TIME] ---------------

Thanks for your help so far. I moved it to the root & it included the core class files..It works till initiating the datamanager object. But saving part doesn't work yet. What other files need to be included to get it working?

<?

// ########################## REQUIRE BACK-END ############################
error_reporting(E_ALL & ~E_NOTICE);
@set_time_limit(0);
include ('./global.php');
include (DIR . '/includes/adminfunctions_template.php');
include (DIR . '/includes/adminfunctions_forums.php');
include (DIR . '/includes/class_core.php');
include (DIR . '/includes/class_dm.php');
include (DIR . '/includes/class_dm_forum.php');
include (DIR . '/includes/functions.php');


$forum_num = $vbulletin->input->clean_gpc('g', 'f', TYPE_UNIT);
$sponsored = $vbulletin->input->clean_gpc('g', 's', TYPE_BOOL);


$forumdm =& datamanager_init('Forum', $vbulletin, ERRTYPE_CP);

echo "initiated";

$foruminfo = fetch_foruminfo($forum_num);

$forumdm->set_existing($foruminfo);
//$forumdm->set('sponsored', $sponsored);
$forumdm->set('title_clean', 'new title');
//unset($forumdm);


if ($forumdm->save())
echo "saved";
else
echo "error";

?>

--------------- Added [DATE]1222107622[/DATE] at [TIME]1222107622[/TIME] ---------------

Update: Got it to work. For anyone who wants to know:

This file is placed in the root.

<?
// ########################## REQUIRE BACK-END ############################
error_reporting(E_ALL & ~E_NOTICE);
@set_time_limit(0);
include ('./global.php');
include (DIR . '/includes/adminfunctions_template.php');
include (DIR . '/includes/adminfunctions_forums.php');
include (DIR . '/includes/class_core.php');
include (DIR . '/includes/class_dm.php');
include (DIR . '/includes/class_dm_forum.php');
include (DIR . '/includes/functions.php');


$forum_num = $vbulletin->input->clean_gpc('g', 'f', TYPE_UNIT);


$forumdm =& datamanager_init('Forum', $vbulletin, ERRTYPE_CP);


$foruminfo = fetch_foruminfo($forum_num);


$forumdm->set_existing($foruminfo);
$forumdm->set('title_clean', 'new title');
$forumdm->save();
unset($forumdm);

?>

Thanks for your help vbulletin community.


All times are GMT. The time now is 08:17 AM.

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.01398 seconds
  • Memory Usage 1,734KB
  • 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
  • (1)footer
  • (1)gobutton
  • (1)header
  • (1)headinclude
  • (6)option
  • (1)post_thanks_navbar_search
  • (1)printthread
  • (9)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
  • bbcode_fetch_tags
  • bbcode_create
  • bbcode_parse_start
  • bbcode_parse_complete_precache
  • bbcode_parse_complete
  • printthread_post
  • printthread_complete