View Full Version : update forum data from external application
asandhanam
09-05-2008, 04:00 PM
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 1222107276 at 1222107276 ---------------
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 1222107622 at 1222107622 ---------------
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.
vBulletin® v3.8.12 by vBS, Copyright ©2000-2025, vBulletin Solutions Inc.