vb.org Archive

vb.org Archive (https://vborg.vbsupport.ru/index.php)
-   vB4 Programming Discussions (https://vborg.vbsupport.ru/forumdisplay.php?f=252)
-   -   newbie with lots of newbie questions! (https://vborg.vbsupport.ru/showthread.php?t=234252)

White_Snake 01-28-2010 01:43 AM

Quote:

Originally Posted by BBR-APBT (Post 1968479)
This line
Code:

        $pmdm->set_recipients('$vbulletin->userinfo['username']', $permissions);
would be
Code:

        $pmdm->set_recipients($vbulletin->userinfo['username'], $permissions);

that did the trick, any suggestion on parsing the code inside the pm message area?

BBR-APBT 01-28-2010 02:36 AM

Quote:

Originally Posted by White_Snake (Post 1968546)
that did the trick, any suggestion on parsing the code inside the pm message area?

What do you mean parsing the code in the message area?

You mean like the user name?

White_Snake 01-28-2010 03:57 AM

Quote:

Originally Posted by BBR-APBT (Post 1968586)
What do you mean parsing the code in the message area?

You mean like the user name?

my apologies, i should have been more clear with my question
this is what i mean:

PHP Code:

$pmdm->set('message'"congratulations $vbulletin->userinfo['username'] you have made your 50th post, we're all so prod of you keep on posting"); 

that line gives me the following output:

HTML Code:

congratulations Array['username'] you have made your 50th post, we're all so prod of you keep on posting

BBR-APBT 01-28-2010 04:27 AM

Quote:

Originally Posted by White_Snake (Post 1968629)
my apologies, i should have been more clear with my question
this is what i mean:

PHP Code:

$pmdm->set('message'"congratulations $vbulletin->userinfo['username'] you have made your 50th post, we're all so prod of you keep on posting"); 

that line gives me the following output:

HTML Code:

congratulations Array['username'] you have made your 50th post, we're all so prod of you keep on posting

Code:

$50postusername = $vbulletin->userinfo['username']
$pmdm->set('message', "congratulations $50postusername you have made your 50th post, we're all so prod of you keep on posting");


it may even be
Code:

$50postusername = $vbulletin->userinfo['username']
$pmdm->set('message', "congratulations " .  $50postusername  . " you have made your 50th post, we're all so prod of you keep on posting");


White_Snake 01-28-2010 04:22 PM

Quote:

Originally Posted by BBR-APBT (Post 1968646)
Code:

$50postusername = $vbulletin->userinfo['username']
$pmdm->set('message', "congratulations $50postusername you have made your 50th post, we're all so prod of you keep on posting");


it may even be
Code:

$50postusername = $vbulletin->userinfo['username']
$pmdm->set('message', "congratulations " .  $50postusername  . " you have made your 50th post, we're all so prod of you keep on posting");


thank you!

but apparently using the line " $50postusername = $vbulletin->userinfo['username']; " makes the script to stop working, and i have tried with both possibilities you have posted in here, the one with the joined strings and the one with the direct variable this is my full code:

PHP Code:

if ($foruminfo['countposts'] AND $vbulletin->userinfo['posts'] + == 50) {
$
50postusername $vbulletin->userinfo['username']; 
$pmdm =& datamanager_init('PM'$vbulletinERRTYPE_ARRAY); 
        
$pmdm->set('fromuserid'1); 
        
$pmdm->set('fromusername'Administrator); 
        
$pmdm->set('title''Congratulations');
        
$pmdm->set('message'"congratulations $50postusername you have made your 50th post, we're all so prod of you keep on posting");
        
$pmdm->set_recipients($vbulletin->userinfo['username'], $permissions); 
        
$pmdm->set('dateline'TIMENOW); 
    
        
$pmdm->pre_save(); 
    
        
// process errors if there are any 
        
$errors array_merge($errors$pmdm->errors); 
    
        if (!empty(
$errors)) 
        { 
                
$errorlist ''
                foreach (
$pmdm->errors AS $index => $error
                { 
                    
$errorlist .= "<li>$error</li>"
                } 
        } 
        else 
        { 
            
// everything's good! 
            
$pmdm->save(); 
        } 


im using the $pmdm->error() function too and its not giving me any error, its almost as if the script was dying because of the extra variable im setting in before reaching the end

White_Snake 01-29-2010 07:26 PM

i tried my code in a separate .php file where i called global.php, then i pasted this code (without the IF statement) and it worked pefectly, the PM was sent correctly without any issue, by some odd reason, just by using any extra variable in the plugin, the code doesnt works at all such as $50postusername, id appreciate if someone can help me with this!

Lynne 01-29-2010 07:42 PM

Try setting the $message first... ie:

Code:

$message = "congratulations......";
        $pmdm->set('message', $message);


White_Snake 01-29-2010 07:53 PM

Quote:

Originally Posted by Lynne (Post 1969996)
Try setting the $message first... ie:

Code:

$message = "congratulations......";
        $pmdm->set('message', $message);


same outcome, the script doesnt runs :( but thanks for the idea :)

Lynne 01-29-2010 10:25 PM

Let's see exactly what you did. It could be you wrote it incorrectly. And did you ever specific the hook location? You should tell us that information also.

White_Snake 01-29-2010 10:42 PM

okay, here goes the full plugin, with some extra stuff i added :)

hook location: newpost_complete

PHP Code:

if ($vbulletin->userinfo['referrerid'] > AND $foruminfo['countposts'] AND $vbulletin->userinfo['posts'] + == 50){
$ref_raw $db->query_read("SELECT username FROM user WHERE userid = ".$vbulletin->userinfo['referrerid']);
$ref_nam $db->fetch_array($ref_raw);

$pmdm =& datamanager_init('PM'$vbulletinERRTYPE_ARRAY);
        
$pmdm->set('fromuserid'1);
        
$pmdm->set('fromusername'Administrator);
        
$pmdm->set('title''Congratulations');
        
$pmdm->set('message'"congratulations! you have referred the user ".$vbulletin->userinfo['username']." and he has made 50 posts");
        
$pmdm->set_recipients($ref_nam['username'], $permissions);
        
$pmdm->set('dateline'TIMENOW);

        
$pmdm->pre_save();

        
// process errors if there are any
        
$errors = @array_merge($errors$pmdm->errors);

        if (!empty(
$errors))
        {
                
$errorlist '';
                foreach (
$pmdm->errors AS $index => $error)
                {
                    
$errorlist .= "<li>$error</li>";
                }
        }
        else
        {
            
// everything's good!
            
$pmdm->save();
        }


the weird part about this code is that i have tried it on a separate php file under the same directory as the forums that calls includes the file global.php and the whole thing works fine in that separated file, as well i tried to see if this hook had any conflict with others, so i disabled everything and still the problem persist

thanks!


All times are GMT. The time now is 07: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.01246 seconds
  • Memory Usage 1,786KB
  • 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
  • (8)bbcode_code_printable
  • (2)bbcode_html_printable
  • (4)bbcode_php_printable
  • (6)bbcode_quote_printable
  • (1)footer
  • (1)gobutton
  • (1)header
  • (1)headinclude
  • (6)option
  • (1)pagenav
  • (1)pagenav_curpage
  • (2)pagenav_pagelink
  • (1)post_thanks_navbar_search
  • (1)printthread
  • (10)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
  • pagenav_page
  • pagenav_complete
  • bbcode_fetch_tags
  • bbcode_create
  • bbcode_parse_start
  • bbcode_parse_complete_precache
  • bbcode_parse_complete
  • printthread_post
  • printthread_complete