Topic: Mass Private Messaging?

Is there a way to Mass PM members using the Private Messaging Mod?

Can this function be added with something else?

Re: Mass Private Messaging?

That would be great.....

PunnyBunny..

Re: Mass Private Messaging?

AP_Mass_PM.php

<?php
/***********************************************************************

  Copyright (C) 2007  guardian34 (punbb@fmguy.com)

  This file is part of PunBB.

  PunBB is free software; you can redistribute it and/or modify it
  under the terms of the GNU General Public License as published
  by the Free Software Foundation; either version 2 of the License,
  or (at your option) any later version.

  PunBB is distributed in the hope that it will be useful, but
  WITHOUT ANY WARRANTY; without even the implied warranty of
  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  GNU General Public License for more details.

  You should have received a copy of the GNU General Public License
  along with this program; if not, write to the Free Software
  Foundation, Inc., 59 Temple Place, Suite 330, Boston,
  MA  02111-1307  USA

************************************************************************/


// Make sure no one attempts to run this script "directly"
if (!defined('PUN'))
    exit;

// Tell admin_loader.php that this is indeed a plugin and that it is loaded
define('PUN_PLUGIN_LOADED', 1);

// Load the language files
require_once PUN_ROOT.'lang/'.$pun_user['language'].'/pms.php';
require_once PUN_ROOT.'lang/'.$pun_user['language'].'/post.php';


if (isset($_POST['send']))
{
    $group = intval($_POST['group']);
    $subject = pun_trim($_POST['subject']);
    $message = pun_linebreaks(pun_trim($_POST['message']));
    $hide_smilies = (isset($_POST['hide_smilies'])) ? 1 : 0;

    // Check group
    if ($group < 0 || $group == 3)
        message('You didn\'t specify a valid group!');

    // Check subject
    if ($subject == '')
        message($lang_post['No subject']);
    else if (pun_strlen($subject) > 70)
        message($lang_post['Too long subject']);

    // Check message
    if ($message == '')
        message($lang_post['No message']);
    else if (strlen($message) > 65535)
        message($lang_post['Too long message']);

    // Validate BBCode syntax
    if ($pun_config['p_message_bbcode'] == '1' && strpos($message, '[') !== false && strpos($message, ']') !== false)
    {
        require PUN_ROOT.'include/parser.php';
        $message = preparse_bbcode($message, $errors);
    }
    if (isset($errors))
        message($errors[0]);


    // Get group members
    $where_sql = ($group != 0) ? 'group_id='.$group : 'id!=1';
    $result = $db->query('SELECT id, username FROM '.$db->prefix.'users WHERE '.$where_sql) or error('Unable to fetch group members', __FILE__, __LINE__, $db->error());
    if ($db->num_rows($result) == 0)
        message('No members found for group '.$group.'.');

    // Save a copy of the message for the sender
    if(isset($_POST['save_message']))
    {
        $db->query('INSERT INTO '.$db->prefix.'messages (owner, subject, message, sender, sender_id, sender_ip, smileys, showed, status, posted) VALUES(
            \''.$pun_user['id'].'\',
            \''.$db->escape($subject).'\',
            \''.$db->escape($message).'\',
            \''.$db->escape($user).'\',
            \''.$pun_user['id'].'\',
            \''.get_remote_address().'\',
            \''.$hide_smilies.'\',
            \'1\',
            \'1\',
            \''.time().'\'
        )') or error('Unable to save message', __FILE__, __LINE__, $db->error());
    }

    // Send messages
    while ($cur_user = $db->fetch_assoc($result))
    {
        $db->query('INSERT INTO '.$db->prefix.'messages (owner, subject, message, sender, sender_id, sender_ip, smileys, showed, status, posted) VALUES(
            \''.$cur_user['id'].'\',
            \''.$db->escape($subject).'\',
            \''.$db->escape($message).'\',
            \''.$db->escape($pun_user['username']).'\',
            \''.$pun_user['id'].'\',
            \''.get_remote_address().'\',
            \''.$hide_smilies.'\',
            \'0\',
            \'0\',
            \''.time().'\'
        )') or error('Unable to send message', __FILE__, __LINE__, $db->error());
    }

    redirect($_SERVER['REQUEST_URI'], 'Private messages sent');
}


// Display the admin navigation menu
generate_admin_menu($plugin);

?>
    <div class="block">
        <h2><span>Mass Private Message - v1.0</span></h2>
        <div class="box">
            <div class="inbox">
                <form method="post" action="<?php echo $_SERVER['REQUEST_URI'] ?>">
                    <p>This plugin "sends" private messages to a group of users. (<em>Note:</em> Private message mod is required.)</p>
                </form>
            </div>
        </div>
    </div>

    <div class="blockform">
        <h2 class="block2"><span>Mass Private Message</span></h2>
        <div class="box">
            <form method="post" action="<?php echo $_SERVER['REQUEST_URI'] ?>">
                <div class="inform">
                    <fieldset>
                        <legend>Message</legend>
                        <div class="infldset">
                            <label><strong><?php echo $lang_pms['Send to'] ?></strong><br />
                                <select name="group">
                                    <option value="0" selected="selected">** All Users</option>
<?php
                                    // Get admin and moderator groups
                                    $result = $db->query('SELECT g_id, g_title FROM '.$db->prefix.'groups WHERE g_id<'.PUN_GUEST.' ORDER BY g_id') or error('Unable to fetch user group list', __FILE__, __LINE__, $db->error());                                    

                                    while ($cur_group = $db->fetch_assoc($result))
                                        echo "\t\t\t\t\t\t\t\t\t".'<option value="'.$cur_group['g_id'].'">'.pun_htmlspecialchars($cur_group['g_title']).'</option>'."\n";

                                    // Get other groups
                                    $result = $db->query('SELECT g_id, g_title FROM '.$db->prefix.'groups WHERE g_id>'.PUN_GUEST.' ORDER BY g_title') or error('Unable to fetch user group list', __FILE__, __LINE__, $db->error());

                                    while ($cur_group = $db->fetch_assoc($result))
                                        echo "\t\t\t\t\t\t\t\t\t".'<option value="'.$cur_group['g_id'].'">'.pun_htmlspecialchars($cur_group['g_title']).'</option>'."\n";

?>                                </select><br />
                            </label>
                            
                            <label><strong><?php echo $lang_common['Subject'] ?></strong><br />
                            <input class="longinput" type="text" name="subject" value="" size="80" maxlength="70" style="width: 100%;" /><br /></label>
                            
                            <?php //require PUN_ROOT.'mod_easy_bbcode.php' ?>
                            
                            <label><strong><?php echo $lang_common['Message'] ?></strong><br />
                            <textarea name="message" rows="18" cols="95" style="width: 100%;"></textarea></label>
                            
                            <ul class="bblinks">
                                <li><a href="help.php#bbcode" onclick="window.open(this.href); return false;"><?php echo $lang_common['BBCode'] ?></a>: <?php echo ($pun_config['p_message_bbcode'] == '1') ? $lang_common['on'] : $lang_common['off']; ?></li>
                                <li><a href="help.php#img" onclick="window.open(this.href); return false;"><?php echo $lang_common['img tag'] ?></a>: <?php echo ($pun_config['p_message_img_tag'] == '1') ? $lang_common['on'] : $lang_common['off']; ?></li>
                                <li><a href="help.php#smilies" onclick="window.open(this.href); return false;"><?php echo $lang_common['Smilies'] ?></a>: <?php echo ($pun_config['o_smilies'] == '1') ? $lang_common['on'] : $lang_common['off']; ?></li>
                            </ul>
                        </div>
                    </fieldset>
                </div>
<?php
    $checkboxes = array();

    if ($pun_config['o_smilies'] == '1')
        $checkboxes[] = '<label><input type="checkbox" name="hide_smilies" value="1" />'.$lang_post['Hide smilies'];

    $checkboxes[] = '<label><input type="checkbox" name="save_message" value="1" />'.$lang_pms['Save message']; 

    if (!empty($checkboxes))
    {
?>                <div class="inform">
                     <fieldset>
                        <legend>Options</legend>
                        <div class="infldset">
                            <div class="infldset">
                                <div class="rbox">
                                    <?php echo implode('<br /></label>'."\n\t\t\t\t", $checkboxes).'<br /></label>'."\n" ?>
                                </div>
                            </div>
                        </div>
                    </fieldset>
                 </div>
<?php
    }
?>                <p class="submitend"><input type="submit" name="send" value="<?php echo $lang_pms['Send'] ?>" /></p>
            </form>
        </div>
    </div>

Re: Mass Private Messaging?

wow thnx works great!

PunnyBunny..

Re: Mass Private Messaging?

I have over 900 members...most of them have private message email notification enabled.

My webhost only allows around 500 emails an hour and only 100 a minute.

What will happen with regards to emails, does this mod pace itself at all?

My worry is that not everyone will get their email notification as my webhost has restrictions to avoid flooding/spamming.

Punbb w/coppermine and wordpress integrated

see my hack to integrate punbb with wordpress comment system.
Illustration Community

Re: Mass Private Messaging?

nickfzx wrote:

most of them have private message email notification enabled.

I've never seen that?

Re: Mass Private Messaging?

oh there is a mod that enables users to get emailed when they receive a private message.

The option is on as default and users have to disable it in their profile if they don't want to be notified by email.

here is the link to the mod:  (translated from french as it is a french mod originally)

http://www.punres.org/viewtopic.php?pid=4643#p4643

How does this mass pm handle sending out the messages?  does it just send out the pm all at once to everyone or is there some kind of flood protection?

Punbb w/coppermine and wordpress integrated

see my hack to integrate punbb with wordpress comment system.
Illustration Community

Re: Mass Private Messaging?

It will not trigger your notification mod, since your mod relies on code in send_message.php

Re: Mass Private Messaging?

Oh, ok, is there a way to change this so it does trigger the notification mod?

Punbb w/coppermine and wordpress integrated

see my hack to integrate punbb with wordpress comment system.
Illustration Community

Re: Mass Private Messaging?

Sending private messages just uses database queries?

// Send messages
while ($cur_user = $db->fetch_assoc($result))

Re: Mass Private Messaging?

nickfzx wrote:

Oh, ok, is there a way to change this so it does trigger the notification mod?

If you code the mod into the plugin. However, you'll then have the issue of sending out too many emails at once.

Re: Mass Private Messaging?

ah I understand now...that is a bummer I would really like to be able to do this.

Maybe I'll send out all the private messages and then email everyone (in batches) to inform them they have a private message...I can get all the email addresses easily from the database.

This is sort of the same thing just not automated.

I only want to do this as a one off in a couple of months so it doesn't matter that it's not automated.

Punbb w/coppermine and wordpress integrated

see my hack to integrate punbb with wordpress comment system.
Illustration Community

13

Re: Mass Private Messaging?

I would love to have this plugin with

- use easy BBCode  (I saw it is there, but if I uncomment it , it displays, but it don't insert the bbCodes into the textarea)
- Preview button
- email notification

Has anybody done this?

14

Re: Mass Private Messaging?

anybody a solution for those "extensions" ?
At least how to get thas "Easy BBCodes" to work.

Thanks

15

Re: Mass Private Messaging?

Hi all, is it possible to CC in other members, say I want to PM Moderators and Senior Members. At the moment, I can only do one at a time. Also, is there a way to allow other groups to use this feature, such as Moderators ?.

Cheers

Richard

16

Re: Mass Private Messaging?

Search the threads for this mod. The modification is in one of them for multi-recipient messages, I believe.