neilsimp1
10-07-2014, 09:19 PM
Hi
I'm following instructions from https://vborg.vbsupport.ru/showthread.php?t=82786&highlight=data+manager+pm to create a datamanager and send a PM.
Everything looks good in my code, I believe, except that I'm having trouble including/requiring the files:
core/includes/functions.php
core/includes/class_core.php
per http://www.vbulletin.com/docs/html/data_managers
the file I'm working from is located in /public/my/includes/myscript.php, so what I'm trying is:
include('privateMessage.php');//script in same folder, this one loads fine
//then later on...
api_send_privateMessage($fromuserid, $fromusername, $title, $message, $recipient);
//which is located in privateMessage.php
So in privateMessage.php:
require_once(realpath(__DIR__).'/../../core/includes/functions.php');
require_once(realpath(__DIR__).'/../../core/includes/class_core.php');
function api_send_privateMessage($fromuserid, $fromusername, $title, $message, $recipients){
$pmdm =& datamanager_init('PM', $vbulletin, ERRTYPE_ARRAY);
$pmdm->set('fromuserid', $fromuserid);
$pmdm->set('fromusername', $fromusername);
$pmdm->set('title', $title);
$pmdm->set('message', $message);
$pmdm->set_recipients($recipients, $botpermissions);
$pmdm->set('dateline', TIMENOW);
$pmdm->save();
return $pmdm->errors;
}
If I comment out the require_once's, I get an error saying that datamanager_init is not found, so I know it's calling the function correctly.
I've tried various combinations of pointing to functions.php and class_core.php, but I keep end up getting "Access denied." on a blank white page, without it ever completing and going to the next actual web page.
Can somebody point out my (hopefully) obvious mistake?
This has been driving me crazy, any help would be appreciated.
I'm following instructions from https://vborg.vbsupport.ru/showthread.php?t=82786&highlight=data+manager+pm to create a datamanager and send a PM.
Everything looks good in my code, I believe, except that I'm having trouble including/requiring the files:
core/includes/functions.php
core/includes/class_core.php
per http://www.vbulletin.com/docs/html/data_managers
the file I'm working from is located in /public/my/includes/myscript.php, so what I'm trying is:
include('privateMessage.php');//script in same folder, this one loads fine
//then later on...
api_send_privateMessage($fromuserid, $fromusername, $title, $message, $recipient);
//which is located in privateMessage.php
So in privateMessage.php:
require_once(realpath(__DIR__).'/../../core/includes/functions.php');
require_once(realpath(__DIR__).'/../../core/includes/class_core.php');
function api_send_privateMessage($fromuserid, $fromusername, $title, $message, $recipients){
$pmdm =& datamanager_init('PM', $vbulletin, ERRTYPE_ARRAY);
$pmdm->set('fromuserid', $fromuserid);
$pmdm->set('fromusername', $fromusername);
$pmdm->set('title', $title);
$pmdm->set('message', $message);
$pmdm->set_recipients($recipients, $botpermissions);
$pmdm->set('dateline', TIMENOW);
$pmdm->save();
return $pmdm->errors;
}
If I comment out the require_once's, I get an error saying that datamanager_init is not found, so I know it's calling the function correctly.
I've tried various combinations of pointing to functions.php and class_core.php, but I keep end up getting "Access denied." on a blank white page, without it ever completing and going to the next actual web page.
Can somebody point out my (hopefully) obvious mistake?
This has been driving me crazy, any help would be appreciated.