Go Back   vb.org Archive > vBulletin 3 Discussion > vB3 Programming Discussions
  #1  
Old 12-21-2006, 11:05 AM
paul41598's Avatar
paul41598 paul41598 is offline
 
Join Date: Jun 2004
Location: MI
Posts: 732
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default Construct_Phrase issues

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



Code:
		$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
Reply With Quote
  #2  
Old 12-21-2006, 11:16 AM
peterska2 peterska2 is offline
 
Join Date: Oct 2003
Location: Manchester, UK
Posts: 6,504
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

if it's a phrase it would be need to be the phrase variable and not just
Code:
$place
unless you have got it set that
Code:
$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)
Reply With Quote
  #3  
Old 12-21-2006, 11:27 AM
paul41598's Avatar
paul41598 paul41598 is offline
 
Join Date: Jun 2004
Location: MI
Posts: 732
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

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


Code:
	$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();
Reply With Quote
  #4  
Old 12-21-2006, 11:36 AM
peterska2 peterska2 is offline
 
Join Date: Oct 2003
Location: Manchester, UK
Posts: 6,504
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

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.
Reply With Quote
  #5  
Old 12-21-2006, 11:45 AM
paul41598's Avatar
paul41598 paul41598 is offline
 
Join Date: Jun 2004
Location: MI
Posts: 732
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

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
Reply With Quote
  #6  
Old 12-21-2006, 11:48 AM
peterska2 peterska2 is offline
 
Join Date: Oct 2003
Location: Manchester, UK
Posts: 6,504
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

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.
Reply With Quote
  #7  
Old 12-21-2006, 11:53 AM
paul41598's Avatar
paul41598 paul41598 is offline
 
Join Date: Jun 2004
Location: MI
Posts: 732
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Yeah tried that, also tried $pquery['username'], $username, etc

Here is a screenshot of what I'm dealing with

Dam this sucks...lol
Attached Images
File Type: gif issue_1.gif (25.2 KB, 0 views)
Reply With Quote
  #8  
Old 12-21-2006, 11:57 AM
peterska2 peterska2 is offline
 
Join Date: Oct 2003
Location: Manchester, UK
Posts: 6,504
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

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
Reply With Quote
  #9  
Old 12-21-2006, 12:02 PM
paul41598's Avatar
paul41598 paul41598 is offline
 
Join Date: Jun 2004
Location: MI
Posts: 732
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

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

Code:
			$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.
Reply With Quote
Reply

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT. The time now is 04:31 PM.


Powered by vBulletin® Version 3.8.12 by vBS
Copyright ©2000 - 2024, vBulletin Solutions Inc.
X vBulletin 3.8.12 by vBS Debug Information
  • Page Generation 0.08340 seconds
  • Memory Usage 2,253KB
  • Queries Executed 12 (?)
More Information
Template Usage:
  • (1)SHOWTHREAD
  • (1)ad_footer_end
  • (1)ad_footer_start
  • (1)ad_header_end
  • (1)ad_header_logo
  • (1)ad_navbar_below
  • (1)ad_showthread_beforeqr
  • (1)ad_showthread_firstpost
  • (1)ad_showthread_firstpost_sig
  • (1)ad_showthread_firstpost_start
  • (5)bbcode_code
  • (1)footer
  • (1)forumjump
  • (1)forumrules
  • (1)gobutton
  • (1)header
  • (1)headinclude
  • (1)navbar
  • (3)navbar_link
  • (120)option
  • (9)post_thanks_box
  • (9)post_thanks_button
  • (1)post_thanks_javascript
  • (1)post_thanks_navbar_search
  • (9)post_thanks_postbit_info
  • (9)postbit
  • (1)postbit_attachment
  • (9)postbit_onlinestatus
  • (9)postbit_wrapper
  • (1)spacer_close
  • (1)spacer_open
  • (1)tagbit_wrapper 

Phrase Groups Available:
  • global
  • inlinemod
  • postbit
  • posting
  • reputationlevel
  • showthread
Included Files:
  • ./showthread.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/functions_bigthree.php
  • ./includes/class_postbit.php
  • ./includes/class_bbcode.php
  • ./includes/functions_reputation.php
  • ./includes/functions_post_thanks.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
  • showthread_start
  • showthread_getinfo
  • forumjump
  • showthread_post_start
  • showthread_query_postids
  • showthread_query
  • bbcode_fetch_tags
  • bbcode_create
  • showthread_postbit_create
  • postbit_factory
  • postbit_display_start
  • post_thanks_function_post_thanks_off_start
  • post_thanks_function_post_thanks_off_end
  • post_thanks_function_fetch_thanks_start
  • post_thanks_function_fetch_thanks_end
  • post_thanks_function_thanked_already_start
  • post_thanks_function_thanked_already_end
  • fetch_musername
  • postbit_imicons
  • bbcode_parse_start
  • bbcode_parse_complete_precache
  • bbcode_parse_complete
  • postbit_display_complete
  • post_thanks_function_can_thank_this_post_start
  • postbit_attachment
  • tag_fetchbit_complete
  • forumrules
  • navbits
  • navbits_complete
  • showthread_complete