vb.org Archive

vb.org Archive (https://vborg.vbsupport.ru/index.php)
-   vBulletin 3.8 Add-ons (https://vborg.vbsupport.ru/forumdisplay.php?f=235)
-   -   Administrative and Maintenance Tools - Yet Another Mass Private Message System 1.0.1 (https://vborg.vbsupport.ru/showthread.php?t=141622)

jdebler 06-06-2008 04:21 PM

Quote:

Originally Posted by GPTB (Post 1542413)
I have this installed on vB 3.7.1 but even when I ask it not to, the script appears to be sending this to all members (including those that have declined to receive Admin e-mails) - this is a serious problem.

I agree, it is a rather serious problem. It got me in trouble with a lot of my members who specified that they didn't want to be contacted by admins that way but did anyway. I explained this problem in post #109 nearly a year ago. I offered to pay someone to fix it in post #111, gave results of my testing in post #116, reminded folks that it doesn't work in post #206. I eventually had to start looking for an alternate way to mass PM my members, or at least only the ones who want them.

I appreciate any effort by programmers here because they can do what I cannot, but if it isn't going to be supported by the author then it shouldn't say that it will be in the product information. That way, there won't be any misunderstandings.

GPTB 06-10-2008 03:46 PM

Quote:

Originally Posted by jdebler (Post 1542428)
I agree, it is a rather serious problem. It got me in trouble with a lot of my members who specified that they didn't want to be contacted by admins that way but did anyway. I explained this problem in post #109 nearly a year ago. I offered to pay someone to fix it in post #111, gave results of my testing in post #116, reminded folks that it doesn't work in post #206. I eventually had to start looking for an alternate way to mass PM my members, or at least only the ones who want them.

I appreciate any effort by programmers here because they can do what I cannot, but if it isn't going to be supported by the author then it shouldn't say that it will be in the product information. That way, there won't be any misunderstandings.

I agree.

If someone is able and willing to update this and fix this huge bug I know I would really appreciate it.

toonysnn 06-15-2008 05:25 PM

I've applied a fix and sent it to GPTB in PM. If he would like to place it here, it's fine with me.

The fix has been tested and proved working on vBulletin 3.7.1 Patch Level 1.

Boofo 06-15-2008 11:57 PM

I would also be interested in that fix.

GPTB 06-16-2008 04:06 PM

I'm happy to place it here for the benefit of the community... I did pay for this fix so if anyone feels an urge to contribute to the cost of it feel free to send me a PM.

I've tested it and it seems to work :)

Simply replace hn_masspm.php with:

Code:

<?php

/*======================================================================*\
|| #################################################################### ||
|| # Yet Another Mass Private Message System v1.0.1 by mtha          # ||
|| # ---------------------------------------------------------------- # ||
|| # For use with vBulletin Version 3.6.x                            # ||
|| # http://www.vbulletin.com | http://www.vbulletin.com/license.html # ||
|| # Discussion and support available at                              # ||
|| # https://vborg.vbsupport.ru/showthread.php?t=141622          # ||
|| #################################################################### ||
\*======================================================================*/

// ######################## SET PHP ENVIRONMENT ###########################
error_reporting(E_ALL & ~E_NOTICE);

// ##################### DEFINE IMPORTANT CONSTANTS #######################
define('CVS_REVISION', '$RCSfile: hn_masspm.php,v 1.0.1 by mtha - $Revision: 070310 $');

// #################### PRE-CACHE TEMPLATES AND DATA ######################
$phrasegroups = array('user', 'cpuser', 'messaging', 'cprofilefield','pm');
$specialtemplates = array();

// ########################## REQUIRE BACK-END ############################
require_once('./global.php');
require_once(DIR . '/includes/adminfunctions_profilefield.php');
require_once(DIR . '/includes/adminfunctions_user.php');

// ############################# LOG ACTION ###############################
log_admin_action();

// ########################################################################
// ######################### START MAIN SCRIPT ############################
// ########################################################################

print_cp_header($vbphrase['hn_masspm_pm_manager']);

 // ##################### Start ##########################
if (empty($_REQUEST['do']))
{
    $_REQUEST['do'] = 'start';
}

// ###################### Send Mass PM ########################
if ($_REQUEST['do'] == 'dosendpm')
{
    $vbulletin->input->clean_array_gpc('p', array(
        'user'              => TYPE_ARRAY,
        'profile'          => TYPE_ARRAY,
        'serializeduser'    => TYPE_STR,
        'serializedprofile' => TYPE_STR,
        'septext'          => TYPE_NOTRIM,
        'perpage'          => TYPE_UINT,
        'startat'          => TYPE_UINT,
        'test'              => TYPE_BOOL,
        'receipt'                        => TYPE_BOOL,
        'savecopy'                    => TYPE_BOOL,
        'allowsmilie'                => TYPE_BOOL,
        'from'              => TYPE_STR,
        'fromuserid'                => TYPE_UINT,
        'subject'          => TYPE_STR,
        'message'          => TYPE_STR,
        'overridereceivepm'    => TYPE_BOOL,
    ));

//    require_once(DIR . '/includes/functions_misc.php');

    $message = $vbulletin->GPC['message'];
    $subject = $vbulletin->GPC['subject'];

    if (trim($subject) == '' || trim($message) == '')
    {
        print_stop_message('nosubject');
    }

    if ($vbulletin->GPC['fromuserid'])
    {
        $fromuser = $db->query_first("
                    SELECT userid,username
                    FROM " . TABLE_PREFIX . "user AS user
                    WHERE user.userid = " . $vbulletin->GPC['fromuserid']
                    );
    }

    if (!$fromuser)
    {
        $fromuser['userid'] = $vbulletin->userinfo['userid'];
        $fromuser['username'] = $vbulletin->userinfo['username'];
    }

    if (!empty($vbulletin->GPC['serializeduser']))
    {
        $vbulletin->GPC['user'] = @unserialize($vbulletin->GPC['serializeduser']);
        $vbulletin->GPC['profile'] = @unserialize($vbulletin->GPC['serializedprofile']);
    }

    $condition = fetch_user_search_sql($vbulletin->GPC['user'], $vbulletin->GPC['profile']);
    if (!$condition)
    {
        $condition = ' 1=1 ';
    }

    $finalcondition = "
        $condition "
        . iif($vbulletin->GPC['overridereceivepm'], "", " AND (options & " . $vbulletin->bf_misc_useroptions['receivepm'] . ")") . "
        AND user.email <> ''
        " . iif(!$vbulletin->GPC['user']['adminemail'], " AND (options & " . $vbulletin->bf_misc_useroptions['adminemail'] . ")");

    if (empty($vbulletin->GPC['perpage']))
    {
        $vbulletin->GPC['perpage'] = 500;
    }

    @set_time_limit(0);

    $counter = $db->query_first("
            SELECT COUNT(*) AS total
            FROM " . TABLE_PREFIX . "user AS user
            LEFT JOIN " . TABLE_PREFIX . "userfield AS userfield ON (userfield.userid = user.userid)
            LEFT JOIN " . TABLE_PREFIX . "usertextfield AS usertextfield ON (usertextfield.userid = user.userid)
            WHERE $finalcondition
            ");

    if ($counter['total'] == 0)
    {
        print_stop_message('no_users_matched_your_query');
    }
    else
    {
        $users = $db->query_read("
                SELECT user.userid, user.usergroupid, user.username, user.email, user.joindate,
                    useractivation.activationid
                FROM " . TABLE_PREFIX . "user AS user
                LEFT JOIN " . TABLE_PREFIX . "userfield AS userfield ON (userfield.userid = user.userid)
                LEFT JOIN " . TABLE_PREFIX . "usertextfield AS usertextfield ON (usertextfield.userid = user.userid)
                LEFT JOIN " . TABLE_PREFIX . "useractivation AS useractivation ON (useractivation.userid = user.userid AND useractivation.type = 0)
                WHERE $finalcondition
                ORDER BY userid
                LIMIT " . $vbulletin->GPC['startat'] . ", " . $vbulletin->GPC['perpage'] . "
                ");
        if ($db->num_rows($users))
        {
            $page = $vbulletin->GPC['startat'] / $vbulletin->GPC['perpage'] + 1;
            $totalpages = ceil($counter['total'] / $vbulletin->GPC['perpage']);
            echo '<p><b>' . $vbphrase['hn_masspm_PMing'] . ' <br />' . construct_phrase($vbphrase['showing_users_x_to_y_of_z'], vb_number_format($vbulletin->GPC['startat'] + 1), iif ($vbulletin->GPC['startat'] + $vbulletin->GPC['perpage'] > $counter['total'], vb_number_format($counter['total']), vb_number_format($vbulletin->GPC['startat'] + $vbulletin->GPC['perpage'])), vb_number_format($counter['total'])) . '</b></p>';
            vbflush();
   
            $recipients = array();
            while ($user = $db->fetch_array($users))
            {
                    $recipients[] = unhtmlspecialchars($user['username']);
//                    $recipients[] = html_entity_decode($user['username']);
            }
   
            if (empty($recipients))
            {
                $pmusers = '';
            }
            else
            {
                $pmusers = implode(' ; ', $recipients);
            }

            echo "\n $pmusers \n";
   
            // create the DM to do error checking and insert the new PM
            $botpermissions['adminpermissions'] = 2;

            $pmdm =& datamanager_init('PM', $vbulletin, ERRTYPE_SILENT);
            $pmdm->overridequota = true;
            $pmdm->set('fromuserid', $fromuser['userid']);
            $pmdm->set('fromusername', $fromuser['username']);
            $pmdm->set_info('receipt', $vbulletin->GPC['receipt']);            //false   
            $pmdm->set_info('savecopy', $vbulletin->GPC['savecopy']);    //false
            $pmdm->set('allowsmilie', $vbulletin->GPC['allowsmilie']);    //true
            $pmdm->set('title', $subject);
            $pmdm->set('message', $message);
            $pmdm->set_recipients($pmusers, $botpermissions);
            $pmdm->set('dateline', TIMENOW);
   
            $pmdm->pre_save();
            if (empty($pmdm->errors))
            {
                if (!$vbulletin->GPC['test'])
                {
                    $pmdm->save();
                    echo "<hr><b>$vbphrase[hn_masspm_noerror_sent]</b><hr>";
                }
                else
                {
                    echo "<hr><b>$vbphrase[hn_masspm_noerror_test]</b><hr>";
                }
            }
            else
            {
                echo "<hr><b><font color=red>$vbphrase[hn_masspm_error_nopmsent]:</font></b><pre>";
                print_r($pmdm->errors);
                echo "</pre><hr> ";
            }
            unset($pmdm);
            vbflush();
   
            $_REQUEST['do'] = 'donext';
        }
        else
        {
            define('CP_REDIRECT', 'hn_masspm.php?' . $vbulletin->session->vars['sessionurl']);
            print_stop_message('hn_masspm_sent_successfully');
        }
    }
}


// *************************** Link to next page of PMs to send **********************
if ($_REQUEST['do'] == 'donext')
{
    $vbulletin->GPC['startat'] += $vbulletin->GPC['perpage'];

    print_form_header('hn_masspm', 'dosendpm');
    construct_hidden_code('test', $vbulletin->GPC['test']);
//    construct_hidden_code( 'receipt', $vbulletin->GPC['receipt']);
//    construct_hidden_code( 'savecopy', $vbulletin->GPC['savecopy']);
    construct_hidden_code('allowsmilie', $vbulletin->GPC['allowsmilie']);

    construct_hidden_code('serializeduser', serialize($vbulletin->GPC['user']));
    construct_hidden_code('serializedprofile', serialize($vbulletin->GPC['profile']));
    construct_hidden_code('fromuserid', $vbulletin->GPC['fromuserid']);
    construct_hidden_code('subject', $vbulletin->GPC['subject']);
    construct_hidden_code('message', $vbulletin->GPC['message']);
    construct_hidden_code('startat', $vbulletin->GPC['startat']);
    construct_hidden_code('perpage', $vbulletin->GPC['perpage']);
    construct_hidden_code('overridereceivepm', $vbulletin->GPC['overridereceivepm']);
    print_submit_row($vbphrase['next_page'], 0);
//    print_cp_redirect('',2);
}

// ###################### Send PM ########################
if ($_REQUEST['do'] == 'start')
{   
?>
<script type="text/javascript">
function check_all_usergroups(formobj, toggle_status)
{
    for (var i = 0; i < formobj.elements.length; i++)
    {
        var elm = formobj.elements[i];
        if (elm.type == "checkbox" && elm.name == 'user[usergroupid][]')
        {
            elm.checked = toggle_status;
        }
    }
}
</script>
<?php
    print_form_header('hn_masspm', 'dosendpm');
    print_table_header($vbphrase['hn_masspm_pm_manager']);
    print_yes_no_row($vbphrase['hn_masspm_test_pm_only'], 'test', 0);

//    print_yes_no_row($vbphrase['request_receipt_for_message'], 'receipt', 0);                // Doesnt work for BCC
//    print_yes_no_row($vbphrase['save_copy_in_sent_items_folder'], 'savecopy', 0);        // NOT RECOMMENDED
    print_yes_no_row($vbphrase['allow_smilies'], 'allowsmilie', 1);

    print_yes_no_row($vbphrase['hn_masspm_overridereceivepm'],'overridereceivepm', 0);
    print_input_row($vbphrase['hn_masspm_pm_to_send_at_once'], 'perpage', 500);
    print_input_row($vbphrase['from'] . " " . $vbphrase['userid'], 'fromuserid', $vbulletin->userinfo['userid']);
    print_input_row($vbphrase['subject'], 'subject');
    print_textarea_row($vbphrase['hn_masspm_message'], 'message', '', 10, 50);

    print_table_break();
    print_table_header($vbphrase['search_criteria']);
    print_user_search_rows(true);

    print_table_break();
    print_submit_row($vbphrase['send']);
}
print_cp_footer();
?>


Boofo 06-16-2008 08:18 PM

Cam you give us an idea of what portion of the code was changed?

GPTB 06-16-2008 08:27 PM

You'd have to ask toonysnn - I don't know. Would be interested to know though.

toonysnn 06-18-2008 09:58 PM

This section was changed:
PHP Code:

    $finalcondition "
        
$condition "
         
iif($vbulletin->GPC['overridereceivepm'], """ AND (options & " $vbulletin->bf_misc_useroptions['receivepm'] . ")") . "
        AND user.email <> ''
        " 
iif(!$vbulletin->GPC['user']['adminemail'], " AND (options & " $vbulletin->bf_misc_useroptions['adminemail'] . ")"); 


KURTZ 06-21-2008 09:23 AM

Billy, why you don't release this for the 3.7.x version?

logicuk 06-21-2008 09:34 AM

Quote:

Originally Posted by KURTZ (Post 1555286)
Billy, why you don't release this for the 3.7.x version?


i 2nd that :D


All times are GMT. The time now is 08:09 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.01413 seconds
  • Memory Usage 1,808KB
  • 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
  • (1)bbcode_code_printable
  • (1)bbcode_php_printable
  • (3)bbcode_quote_printable
  • (1)footer
  • (1)gobutton
  • (1)header
  • (1)headinclude
  • (6)option
  • (1)pagenav
  • (1)pagenav_curpage
  • (4)pagenav_pagelink
  • (2)pagenav_pagelinkrel
  • (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