vb.org Archive

vb.org Archive (https://vborg.vbsupport.ru/index.php)
-   vBulletin 3 Articles (https://vborg.vbsupport.ru/forumdisplay.php?f=187)
-   -   Send PMs (automatically) (https://vborg.vbsupport.ru/showthread.php?t=82786)

Antivirus 07-26-2006 03:00 PM

Does anyone know if there's a setting which can be used within ($pmdm->set(...)) for whether or not to parse html? In other words, if the text sent in the PM is allowed to use html?

fly 09-30-2006 01:05 PM

Was something changed on 3.6? This code no longer works:

PHP Code:

    // create the DM to do error checking and insert the new PM 
        
$pmdm =& datamanager_init('PM'$vbulletinERRTYPE_SILENT); 
        
$pmdm->set('fromuserid'$fromuser['userid']); 
        
$pmdm->set('fromusername'$fromuser['username']); 
        
$pmdm->set_info('receipt'false); 
        
$pmdm->set_info('savecopy'false); 
        
$pmdm->set('title'"Important information regarding your registration!"); 
        
$pmdm->set('message'"[center][b]AUTOGENERATED PM[/b][/center] "); 
        
$pmdm->set_recipients($userinfo['username'], $fromuser['permissions']); 
        
$pmdm->set('dateline'TIMENOW); 
        
$pmdm->save(); 

I haven't changed any of the code from 3.5 since the upgrade, so something in there no longer works. Any idea what it is?

Okay, I got it working, but there is no popup for the user about a PM. Any ideas?

Cebby 09-30-2006 08:18 PM

This seems like a good place to ask ;)

I'm creating a link in a vB powered page (template) for a user to send a PM to me on a specific subject (just like you can do with EM very easily). I want it to open the PM, address it, and fill in the title of the PM, then wait for the user to enter their message.

Can this be done in 3.6.1?

DigitalCrowd 10-06-2006 11:23 PM

I have to do this to get private messages to update correctly in most cases. In a few specific cases, I don't have too. But, don't remember off the top my head which one.

Code:

$db->query_write("UPDATE vb_user SET pmunread=pmunread+1,pmtotal=pmtotal+1 WHERE userid=$userid");
That will do the trick everytime. ;)

HPIA 11-01-2006 04:01 AM

Where does this go exactly XD?

CyberRanger 11-08-2006 03:13 PM

Quote:

Originally Posted by Andreas
If you want to send PMs no matter if the PM box of the recipient is full or not:

PHP Code:

$botpermissions['adminpermissions'] = 2


Thx for the wonderful tutorial. I've used your guide to develop an add-on to one of my products.

The only item that I can't get working is overriding the mailbox full restriction. I've used the code above but setting adminpermissions to 2 doesn't seem to work. In class_dm_pm.php, $overridequota = false seems to need to be set to "true" but I can't figure out how to do that.

If you have a few minutes, I'd really appreciate help in figuring out how to set the variables so that the user will receive the PM even if his mailbox is full and he receives PMs only from buddies and sender is not on the list and not board staff.

I'm pretty sure that can be achieved by setting $overridequota = true, just can't figure out how to do that.

In class_dm_pm.php, line 80:

PHP Code:

var $overridequota false

while starting at line 370:
PHP Code:

        // run through recipients to check if we can insert the message
        
foreach ($users AS $lowname => $user)
        {
            if (!(
$user['options'] & $this->registry->bf_misc_useroptions['receivepm']) AND !$this->overridequota)
            {
                
// recipient has private messaging disabled
                
$this->error('pmrecipturnedoff'$user['username']);
                return 
false;
            }
            else if ((
$user['options'] & $this->registry->bf_misc_useroptions['receivepmbuddies']) AND strpos($user[buddylist] "$fromuser[userid] ") === false AND !can_moderate() AND !$this->overridequota)
            {
                
// recipient receives PMs only from buddies and sender is not on the list and not board staff
                
$this->error('pmrecipturnedoff'$user['username']);
                return 
false;
            }
            else
            { 

But I don't see anyway to set $overridequota without hacking class_dm_pm.php.

Thx!

Acido 11-09-2006 03:31 PM

What's the trick to Automatically parse links in text ?

mrpaint 11-11-2006 08:20 PM

Quote:

Originally Posted by Acido
What's the trick to Automatically parse links in text ?

Just use BBCode such as [url]
[code]text

My problem is: it isn't count my auto-PM into PM's quota. I found this in the previous page but it is too.... (no word to say!)

Quote:

I have to do this to get private messages to update correctly in most cases. In a few specific cases, I don't have too. But, don't remember off the top my head which one.

Code:

$db->query_write("UPDATE vb_user SET pmunread=pmunread+1,pmtotal=pmtotal+1 WHERE userid=$userid");
That will do the trick everytime.
Any new ideas?

mferguson 11-20-2006 04:15 PM

Quote:

Originally Posted by CyberRanger (Post 1113077)

The only item that I can't get working is overriding the mailbox full restriction. I've used the code above but setting adminpermissions to 2 doesn't seem to work. In class_dm_pm.php, $overridequota = false seems to need to be set to "true" but I can't figure out how to do that.

I had the same issue. What I found by searching through all the vB code is a couple of places where overridequota was referenced. All that is required to set this to send the PM even if the recipient's mailbox is full is to:

PHP Code:

$pmdm->overridequota true

Here is how my code looks with this:
PHP Code:

$pmdm =& datamanager_init('PM'$vbulletinERRTYPE_ARRAY);         

$pmdm->set('fromuserid'$vbulletin->userinfo['userid']);
$pmdm->set('fromusername'$vbulletin->userinfo['username']);
$pmdm->set_info('receipt'false);
$pmdm->set_info('savecopy'false);
$pmdm->overridequota true;                   // Force pm send even if recipient's mailbox is full
$pmdm->set('title'$title);
$pmdm->set('message'$message);
$pmdm->set('dateline'TIMENOW);
$pmdm->set('allowsmilie'true);            

$pmtousernames implode(';'$pmto_users);
$pmdm->set_recipients($pmtousernames$botpermissions);
$pmdm->save(); 

Hope this helps everyone that was running into similar problems.

Mark

When testing my auto send pm's code I kept seeing users that had pmpopup (popup-based pm notification) not being updated when I sent my auto pm.

If a user has pmpopup notification on this column should show as "1" in the user table. If they receive a new message and haven't read it yet it should show as "2" in the user table. The two denotes that there is an unread popup.

In the case where I was sending a message to multiple recipients I noticed that only the last of the recipients that also had pmpopup notification was having the pmpopup column updated to "2" while other's weren't.

In debuggint this problem I found that in the forums/includes/class_dm_pm.php file that line 557:

PHP Code:

$popupusers = array(); 

is reinitializing the array and therefore causes any previous userids that have pmpopup enabled to be lost (since its within a foreach loop processing all the users)

To resolve this I've commented the line out for now and also filed a bug report with vBulletin to get it resolved in a future release. I found this is 3.6.1 and also in 3.6.3.

Hope this helps some others that found problems in getting this mod working as expected.

Mark

Blaine0002 12-14-2006 06:38 PM

Would i need to change anything to stick this into a cron?
If so what would i change

If i dont need to change anything is it because im using 3.6.0 that its not working?

mferguson 12-14-2006 06:43 PM

Are you wanting to bulk email members based on a cron? If so the only thing I believe you need to do would be to figure out what you needed to populate when the cron is run (ie - subject, body, etc.)

Mark

Blaine0002 12-14-2006 06:54 PM

no, only want it to send 2 pms, but its not sending any, and the cron IS being run correctly.

mferguson 12-14-2006 07:16 PM

I guess I'm confused as to why you are doing this with a cron. If you can provide some background it will give me a better idea of how it might be done.

As to the cron itself. How are you verifying that it is being run correctly? Is there some type of output being generated?

Thanks

Mark

Blaine0002 12-15-2006 12:05 AM

in my auction modification, a cron runs every 10 minutes which closes auctions and notifies buyer and seller of who won.

paul41598 12-20-2006 05:27 PM

Um I have the below code in a cron job, and when it runs Im getting this error:

PHP Code:

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


Code:

      // Fetch the PM message 
        if ($vbulletin->options['ptp_pm_on_off'] == '1')
        {
                    $ptp_pm =
          construct_phrase(
            $vbphrase['ptp_alertpm'],
            $pquery['username'],
          );
     
      // Send a PM to user(s)
      $pmdm =& datamanager_init('PM', $vbulletin, ERRTYPE_ARRAY);
      $pmdm->set('fromuserid', 6);
      $pmdm->set('fromusername', 'JonB');
      $pmdm->set('title', 'Crap');
      $pmdm->overridequota = true;
      $pmdm->set('message', 'test');
      $pmdm->set_recipients($pquery['username'], $botpermissions);
      $pmdm->set('dateline', TIMENOW);
      $pmdm->save();
        }

Whats wrong here? I think it worked before now all of a sudden doesnt... (I think) :cross-eyed:

jwocky 12-20-2006 09:06 PM

Quote:

Originally Posted by paul41598 (Post 1142336)
Um I have the below code in a cron job, and when it runs Im getting this error:

PHP Code:

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


Code:

      // Fetch the PM message 
        if ($vbulletin->options['ptp_pm_on_off'] == '1')
        {
                    $ptp_pm =
          construct_phrase(
            $vbphrase['ptp_alertpm'],
            $pquery['username'],
          );
     
      // Send a PM to user(s)
      $pmdm =& datamanager_init('PM', $vbulletin, ERRTYPE_ARRAY);
      $pmdm->set('fromuserid', 6);
      $pmdm->set('fromusername', 'JonB');
      $pmdm->set('title', 'Crap');
      $pmdm->overridequota = true;
      $pmdm->set('message', 'test');
      $pmdm->set_recipients($pquery['username'], $botpermissions);
      $pmdm->set('dateline', TIMENOW);
      $pmdm->save();
        }

Whats wrong here? I think it worked before now all of a sudden doesnt... (I think) :cross-eyed:

Wow, i'm having the identical error message which just started today as well, I wonder whats going on here... and I mean identical Is there a way to get the script to echo the error? return $pmdm->errors; ? I have that in my cron script, but when i run it in the task manager i get no text echoed, maybee another way so that we can diagnose this problem

Blaine0002 12-20-2006 09:41 PM

PHP Code:

echo $pmdm->errors

When i did a cron i actually made a seperate function and ran the function from the cron.

jwocky 12-20-2006 09:44 PM

Quote:

Originally Posted by Blaine0002 (Post 1142487)
PHP Code:

echo $pmdm->errors

When i did a cron i actually made a seperate function and ran the function from the cron.

That just prints out the word "Array" .. dont know how to parse that pmdm->errors to give us some valuable data on diagnosing the problem

paul41598 12-20-2006 10:27 PM

actually if I take out the PM datamanager code temporarily...and replace with this:

Code:

      $pmto_users[] = $pquery['username'];

      $pmtousernames = implode(';', $pmto_users);
                        echo "$pmtousernames";

I get CMUrickCMUrick;Pepsico

Its printing out CMUrick twice and I have no idea why. But its working kinda...

jwocky: You need the code in this post I think to grab names and put em in an array, then you will get a different output in your tests.

jwocky 12-20-2006 11:43 PM

Quote:

Originally Posted by paul41598 (Post 1142513)
actually if I take out the PM datamanager code temporarily...and replace with this:

Code:

      $pmto_users[] = $pquery['username'];

      $pmtousernames = implode(';', $pmto_users);
                        echo "$pmtousernames";

I get CMUrickCMUrick;Pepsico

Its printing out CMUrick twice and I have no idea why. But its working kinda...

jwocky: You need the code in this post I think to grab names and put em in an array, then you will get a different output in your tests.


Ok, i imploded the array $pmdm->errors in the same way you did above and got it to spit out the error code, turns out in my case, the user set to recieve the PM had his inbox full! argh.

paul41598 12-20-2006 11:49 PM

least urs might be working..mine keeps sending multiple PM's to the same person. argh

jwocky 12-20-2006 11:54 PM

Quote:

Originally Posted by paul41598 (Post 1142544)
least urs might be working..mine keeps sending multiple PM's to the same person. argh

If its doubling up the name like that without the semicolon it shouldnt be sending multiple pms? try doing the same thing I did (put the pmdm->errors into the implode and then echo that variable and see what the exact error is thats being stored ?

paul41598 12-21-2006 12:07 AM

Ok here is my code in my cron...stripped down to show the basic idea.

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']; }
                $pmtousernames = implode( '; ', $pmto_users);
                echo "$pmtousernames";
               
                //Took Out PM Datamanager Code HERE for time Being
}

WHen I run my CRON job manually, it echo's out this: (keeping in mind there are 2 users who have a post_groan_time greater than 0...

PHP Code:

CMURickCMURickPepsico

Done 


I got it, Im an idiot

sp00fer 12-21-2006 06:24 PM

i get an mySQL sytax error if i use this to send a PM to a user with an apostrophe in his name........any help?

Edit: Manually Escaping the apostrophe also doesnt work (generates a vbulletin error: cant find user)

nevermind, its not a problem after all :D

jwocky 02-12-2007 03:12 AM

Any ideas how to override a full PM box in vb 3.6? the $pmdm->overridequota = true; doesn't seem to be working at all :(

Antivirus 02-17-2007 10:59 PM

$pmdm->overridequota = true; works fine for me. Although I think it needs to be right after you initialize the class like this:
$pmdm =& datamanager_init('PM', $vbulletin, ERRTYPE_ARRAY);
$pmdm->overridequota = true;

You might also need to set $botpermissions in set recipients like this:
$pmdm->set_recipients($recipient, $botpermissions);

cashpath 03-07-2007 03:50 PM

Quote:

$pmdm->set_recipients($recipient, $botpermissions);
Quick question.. is there a way to send the PM to a recipient by userid instead of by username???

Thanks.

fly 03-07-2007 04:15 PM

Quote:

Originally Posted by cashpath (Post 1198097)
Quick question.. is there a way to send the PM to a recipient by userid instead of by username???

Thanks.

Can't you just get the name from the id? Why do you have one but not the other?

cashpath 03-07-2007 04:23 PM

Well.. I have stored the userid into another custom table..and it is not the userid that is currently accessing the page. I didn't store the username..

If there is no way to send to the userid using the functions then I guess I can always just store the username also... Good point.

fly 03-07-2007 04:37 PM

Quote:

Originally Posted by cashpath (Post 1198131)
Well.. I have stored the userid into another custom table..and it is not the userid that is currently accessing the page. I didn't store the username..

If there is no way to send to the userid using the functions then I guess I can always just store the username also... Good point.

You could always just do a query to get the name. There is likely a better solution that is beyond me though...

cashpath 03-07-2007 04:49 PM

Yeah I didn't want to run another query it's a relatively small table.. but I just wasn't thinking and storing the username also is the smart move... thanks for waking me up :)

Deriel 03-13-2007 04:46 PM

How do I send a PM to a user A (normal) and the same PM to user B (with BCC)? user B shall receive the same PM from A but user A should'nt know that user B got the PM too.

CyberRanger 03-13-2007 05:07 PM

Quote:

Originally Posted by Deriel (Post 1202644)
How do I send a PM to a user A (normal) and the same PM to user B (with BCC)? user B shall receive the same PM from A but user A should'nt know that user B got the PM too.

untested but should work: set_recipients($recipientlist, $botpermissions, $type = 'bcc')

xman_79 03-28-2007 05:00 PM

Thank you for your useful and explicite answer .

I made a modul in wich a member can add a text.
I want this member to receive a pm in case I erase his text.
I have accomplished a modul but I want to know if the code is correct .

Code:

//The link is : script.php?do=delete&p=$row['text_id']

if(isset($_GET['p']) AND is_numeric($_GET['p']))
{
        $me = $db->query_read("SELECT text_title,text_uid,text_user FROM " . TABLE_PREFIX . "table WHERE text_id='{$_GET['p']}'");
        $me_s = $db->fetch_array($me);
        $txtuid        = $me_s['text_uid'];
        $username        = $me_s['text_user'];
        $title                = $me_s['text_title'];
               
        $pmdm =& datamanager_init('PM', $vbulletin, ERRTYPE_ARRAY);
        $pmdm->set('fromuserid', $txtuid);
        $pmdm->set('fromusername', $username);
        $pmdm->set('title', 'Information');
        $pmdm->set('message', "I delete your text : $title .......");
        $pmdm->set_recipients($username, $botpermissions);
        $pmdm->set('dateline', TIMENOW);
        $pmdm->errors;
        $pmdm->save();
       
        $db->query_write("DELETE FROM " . TABLE_PREFIX . "table WHERE text_id='{$_GET['p']}'");
        define('CP_REDIRECT', "script.php?do=show");
        print_stop_message('text_deleted');
        exit;
}

Thank you .

budlight 03-30-2007 08:53 PM

Quote:

Originally Posted by xman_79 (Post 1214586)
Thank you for your useful and explicite answer .

I made a modul in wich a member can add a text.
I want this member to receive a pm in case I erase his text.
I have accomplished a modul but I want to know if the code is correct .

Code:

//The link is : script.php?do=delete&p=$row['text_id']

if(isset($_GET['p']) AND is_numeric($_GET['p']))
{
        $me = $db->query_read("SELECT text_title,text_uid,text_user FROM " . TABLE_PREFIX . "table WHERE text_id='{$_GET['p']}'");
        $me_s = $db->fetch_array($me);
        $txtuid        = $me_s['text_uid'];
        $username        = $me_s['text_user'];
        $title                = $me_s['text_title'];
               
        $pmdm =& datamanager_init('PM', $vbulletin, ERRTYPE_ARRAY);
        $pmdm->set('fromuserid', $txtuid);
        $pmdm->set('fromusername', $username);
        $pmdm->set('title', 'Information');
        $pmdm->set('message', "I delete your text : $title .......");
        $pmdm->set_recipients($username, $botpermissions);
        $pmdm->set('dateline', TIMENOW);
        $pmdm->errors;
        $pmdm->save();
       
        $db->query_write("DELETE FROM " . TABLE_PREFIX . "table WHERE text_id='{$_GET['p']}'");
        define('CP_REDIRECT', "script.php?do=show");
        print_stop_message('text_deleted');
        exit;
}

Thank you .

This looks like a horrible idea, as anyone could just enumerate through the textid's and delete them all.

xman_79 04-01-2007 12:27 AM

Quote:

Originally Posted by budlight (Post 1216431)
This looks like a horrible idea, as anyone could just enumerate through the textid's and delete them all.


This isn't the entire code , I wrote just the part that I was more intrested in .
I am interested in the idea not in the code itself .

Thanks .

Till 04-18-2007 01:19 PM

I am using this snippet on a non-VB page. Beforehand I am including the global.html and so on - as described in various "login from non-vb page" threads/hacks.

Code:

$pmdm =& datamanager_init('PM', $vbulletin, ERRTYPE_ARRAY);
$pmdm->set('fromuserid', 5);
$pmdm->set('fromusername', 'Foo');
$pmdm->set('title', sprintf('Einladung %s', $name));
$pmdm->set('message', $message);
$pmdm->set_recipients($to, $botpermissions);
$pmdm->set('dateline', TIMENOW);
//var_dump($pmdm->errors);

$to is set to a valid username, however i get the following error right with the "set_recipients" part.

Quote:

Fatal error: Call to undefined function: query_first_slave() in /user/public_html/community/includes/functions.html on line 1154
Anyone have an idea? I did a var_dump(get_class_methods($vbulletin->db)); right beforeit uses the query_first_slave and it shows the query_first_slave method. My PHP is 4.4.x - so do I need to update my vb? We are still on 3.6.4 (only on the development server).

Factory Ten 04-19-2007 05:56 PM

Is there a way I can use this to automatically PM someone when they get an infraction?

CyberRanger 04-19-2007 06:05 PM

Quote:

Originally Posted by Factory Ten (Post 1231381)
Is there a way I can use this to automatically PM someone when they get an infraction?

:confused: That's already an option in the infraction system.

Punky Guy 05-04-2007 01:28 PM

Is there a way I can call this from a link or button? Some hook I could use?


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

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.01638 seconds
  • Memory Usage 1,904KB
  • 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
  • (10)bbcode_code_printable
  • (12)bbcode_php_printable
  • (16)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
  • (40)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