PDA

View Full Version : Construct_Phrase issues


paul41598
12-21-2006, 11:05 AM
I have something like this below. I wanna use a phrase for the body of the PM being sent, so I can change it around in the phrase. However when this job runs in the cron job I get this error:

Fatal error: Unable to proceed with save while $errors array is not empty in class vb_datamanager_pm in /includes/class_dm.php on line 758




$place = construct_phrase($vbphrase['ptp_alertpm'], $pquery['username']);

// Send a PM to user(s)
$pmdm =& datamanager_init('PM', $vbulletin, ERRTYPE_ARRAY);
$pmdm->set('fromuserid', $vbulletin->options['ptp_fromuserid']);
$pmdm->set('fromusername', $vbulletin->options['ptp_fromusername']);
$pmdm->set('title', 'Crap');
$pmdm->set('message', $place);
$pmtousernames = implode(';', $pmto_users);
$pmdm->set_recipients($pmtousernames, $botpermissions);
$pmdm->set('dateline', TIMENOW);
$pmdm->save();


Any ideas? If I replace $place in the actual PM datamanager code above with 'text' the cron runs fine, so I know that is the issue

peterska2
12-21-2006, 11:16 AM
if it's a phrase it would be need to be the phrase variable and not just $placeunless you have got it set that $place = $vbphrase[place]or whatever your equivalent is (and the right thing for in php because I think thats wrong but I'm not sure what the correct one would be)

paul41598
12-21-2006, 11:27 AM
Peter, its still not working. Here is all my code to give you a better idea of what Im doing. Basically running a query and selecting all users who meet the WHERE condition and PM'ing them



$userpointsqry = $vbulletin->db->query_read("
SELECT vbbux, userid, username
FROM " . TABLE_PREFIX . "user
WHERE post_groan_times > 0
");

$pmto_users = array();
while($pquery = $vbulletin->db->fetch_array($userpointsqry))
{
$pmto_users[] = $pquery['username']; // initiliaze array for PM sending

} // End While Statement


$ptp_alertpm = construct_phrase($vbphrase['ptp_alertpm'], $pquery['username']);

// Send a PM to user(s)
$pmdm =& datamanager_init('PM', $vbulletin, ERRTYPE_ARRAY);
$pmdm->set('fromuserid', $vbulletin->options['ptp_fromuserid']);
$pmdm->set('fromusername', $vbulletin->options['ptp_fromusername']);
$pmdm->set('title', 'Crap');
$pmdm->set('message', $ptp_alertpm);
$pmtousernames = implode(';', $pmto_users);
$pmdm->set_recipients($pmtousernames, $botpermissions);
$pmdm->set('dateline', TIMENOW);
$pmdm->save();

peterska2
12-21-2006, 11:36 AM
not sure. The logic in your code looks fine to me.

Just had a really odd idea though, so I'm not sure if/how it would work, but it might be worth considering....

If you are going to be wanting to edit the phrase frequently anyway, and you are already adding some settings, why not use a vboption setting for the body text? How well it would work with something like usernames I'm not sure, but thats something that will be easier to figure out (maybe a replacement variable or something if you cant just use $username or similar).

Completely random idea, and no idea why I thought about it, but might be worth considering.

paul41598
12-21-2006, 11:45 AM
I did that actually prior, I had:

$pmdm->set('message', $ptp_alertpm);

set to:

$pmdm->set('message', $vbulletin->options['ptp_text');

and it worked great! But like you said..when I went to enter in the body of the PM text in the admincp, I couldnt use {1} or like $bbuserinfo[username]. NO variables work so it kinda sucks

peterska2
12-21-2006, 11:48 AM
did you try $pquery[username] in it?

I'm thinking outside the box a bit here so I might ask some really obvious questions before we get there.

paul41598
12-21-2006, 11:53 AM
Yeah tried that, also tried $pquery['username'], $username, etc

Here is a screenshot of what I'm dealing with ;)

Dam this sucks...lol

peterska2
12-21-2006, 11:57 AM
I'm about out of ideas then :(

unless..... maybe the [you] mod would work, but I'm not sure if it works in PM's or just posts, or if it even works on 3.6.x

paul41598
12-21-2006, 12:02 PM
I'm just surprised the dam construct_phrase function isnt working. It makes no sense. The code looks 100% accurate unless I'm missing something. Maybe others can shed some light.

Peter, I thankyou for your quick and friendly response. Happy Holidays to you buddy


--------------------------------------------------------------
b.t.w, think I'm getting closer here:

If I do

$ptp_alertpm = construct_phrase($vbphrase['ptp_alertpm']);

if (empty($vbphrase['ptp_alertpm'])) {
echo "phrase is empty";
}

it actually prints out Phrase is empty, which leads me to believe the contstruct phrase isnt working or something because the phrase has info in it, I checked.