vb.org Archive

vb.org Archive (https://vborg.vbsupport.ru/index.php)
-   vBulletin 2.x Full Releases (https://vborg.vbsupport.ru/forumdisplay.php?f=4)
-   -   Preview Private Message Before Sending (https://vborg.vbsupport.ru/showthread.php?t=32695)

bira 11-25-2001 10:00 PM

OK, I wrote this hack seeing as my users were nagging about it and I could not find one here (if there is one, I apologise - please give me the URL).

This works exactly like post preview:

http://www.atlasf1.com/personal/bira/privmsgpreview.gif

How to install:

Open private.php

1) First we need to move "newmessage" after "dosend". Highlight the entire section between:

Code:

    // ############################### start new message ###############################
Until (but not including):

Code:

    // ############################### start send message ###############################

Cut this entire section (a total of 83 lines in 2.2.1) and paste it right above:

Code:

    // ############################### start do stuff (move, etc) ###############################
2) Now we need to insert the following code:

a) Find:

Code:

    $savecopy=iif($savecopy=="yes",1,0);
Right under it insert:

Code:


    // preview hack
    $pmreceipt=iif($pmreceipt=="yes",1,0);
    // preview hack
   

b) Find:

Code:

    if ($pmquota>0 and $touserinfo[usergroupid] != 6 and $bbuserinfo[usergroupid] != 6) {
Right above it insert:

Code:


    // preview hack
    if ($preview) {
        $previewpost=1;
        $previewmessage=bbcodeparse($message,0,$allowsmilie);

        if ($signature) {
            $post['signature'] = bbcodeparse($bbuserinfo['signature'],0,$allowsmilie);
            eval("\$post[signature] = \"".gettemplate("postbit_signature")."\";");
            $previewmessage.=$post['signature'];
        }

        eval("\$postpreview=\"".gettemplate("priv_sendpreview")."\";");

        $parseurlchecked=iif($parseurl,"checked","");
        $pmreceiptchecked=iif($pmreceipt,"checked","");
        $savecopychecked=iif($savecopy,"checked","");
        $signaturechecked=iif($signature,"checked","");
        $previewchecked=0;
       
        $title = htmlspecialchars($title);
       
        $privatemessageid = $prevmessageid;
        $forward;               
        $subject = $title;
        $privmessage = $message;
        $action="newmessage";
    } else {
    // preview hack
   

c) Find:

Code:

    } #end dosend
Right above it insert:

Code:


    } // preview hack
   

d) Find:

Code:

    //show new message form
Right under it insert:

Code:


    // preview hack
    if (!$pagetext) {
        // parse message for html if previewing
        $message = htmlspecialchars($message); // Without this, a </textarea> in the message breaks the form on preview
    }
    // preview hack
   

e) Find:

Code:

    if ($bbuserinfo[userid]!=0 and !$previewpost and $bbuserinfo[signature]!="") {
        $signaturechecked="CHECKED";
    }

Right under it insert:

Code:


    // preview hack
    if (!isset($parseurl)) {
        $parseurlchecked="CHECKED";
    }

    if (!isset($savecopy)) {
        $savecopychecked="CHECKED";
    }
   
    if (!isset($pmreceipt)) { 
        $pmreceiptchecked="CHECKED";
    }
    // preview hack
   

f) Find:

Code:

    // /enhanced
    eval("dooutput(\"".gettemplate("priv_sendprivmsg")."\");");

Right above it insert:

Code:


    // preview hack
    if (!isset($privmessage)) {
        $privmessage = $message[message];
    }
    // preview hack
   


g) Find:

Code:

    // enhanced
  $receipt=iif($pmreceipt=="yes",1,0);
  // /enhanced

And replace it with (the code to remove is marked in red):

Code:

    // enhanced
  $receipt=iif($pmreceipt,1,0);
  // /enhanced


Save private.php and upload to server.


In the Administration control panel -> Templates

1) ADD template priv_sendpreview and insert to it:

Code:


    <br>

    <table cellpadding="0" cellspacing="0" border="0" bgcolor="#555576"  width="100%" align="center"><tr><td>
    <table cellpadding="4" cellspacing="1" border="0"  width="100%">
    <tr>
        <td bgcolor="#8080A6"><smallfont color="#EEEEFF"><b>Message Preview:</b></smallfont></td>
    </tr>
    <tr>
        <td bgcolor="#F1F1F1"><normalfont>$previewmessage</normalfont></td>
    </tr>
    </table>
    </td></tr></table>
   

(you may edit this to your liking).

2) Open template priv_sendprivmsg

a) place $postpreview where you want the message preview to appear (normally would be under $cpnav).

b) Find:

Code:

    <textarea name="message" rows="20" cols="$textareacols" wrap="virtual" tabindex="3">$message[message]</textarea>
And replace it with (change marked in red):

Code:

    <textarea name="message" rows="20" cols="$textareacols" wrap="virtual" tabindex="3"> $privmessage</textarea>
c) Find:

Code:

    <input type="checkbox" name="parseurl" value="yes" checked>
And replace it with (change marked in red):

Code:

    <input type="checkbox" name="parseurl" value="yes" $parseurlchecked>
d) Find:

Code:

    <input type="checkbox" name="savecopy" value="yes" checked>
And replace it with (change marked in red):

Code:

    <input type="checkbox" name="savecopy" value="yes" $savecopychecked>
e) Find:

Code:

    <input type="submit" class="bginput" name="submit" value="Send Message" accesskey="s" tabindex="4">
And replace it with (change marked in red):

Code:

    <input type="submit" class="bginput" name="submit" value="Send Message" accesskey="s" tabindex="4">
    <input type="submit" class="bginput" name="preview" value="Preview Message" accesskey="p" tabindex="4">


3) Open template priv_requestreceipt

Find:

Code:

    <input type="checkbox" name="pmreceipt" value="yes" checked>
And replace it with (change marked in red):

Code:

    <input type="checkbox" name="pmreceipt" value="yes" $pmreceiptchecked>
That's it!

Comments and additions welcome.

Cheers,

Bira

bira 11-26-2001 02:39 AM

Sorry, forgot to attack the instructions in a txt file as well (the same instructions as posted above).

JJR512 11-26-2001 02:55 AM

bira, in the attached text file, you left a [/code] in. :o

It's in this part:
PHP Code:

Right under it insert:

    
// preview hack
    
if (!isset($parseurl)) {
        
$parseurlchecked="CHECKED";
    }

    if (!isset(
$savecopy)) {
        
$savecopychecked="CHECKED";
    }
    
    if (!isset(
$pmreceipt)) {   
        
$pmreceiptchecked="CHECKED";
    }
    
// preview hack
    
[/code


bira 11-26-2001 02:59 AM

:o

fixed, thanks

bira 11-26-2001 03:12 AM

Not that I think anyone managed to install this hack so fast, but just in case - I made the following change to the above hack installation instructions:


In the private.php:

Quote:

f) Find:

Code:

    // /enhanced
    eval("dooutput(\"".gettemplate("priv_sendprivmsg")."\");");

Right above it insert:

Code:


    // preview hack
    if (!isset($privmessage)) {
        $privmessage = $message[message];
    }
    // preview hack
   


And, in editing template priv_sendprivmsg please remove $message[message] from the textarea code.

JJR512 11-26-2001 03:21 AM

[QUOTE]Originally posted by bira
Not that I think anyone managed to install this hack so fast, but just in case...

bira 11-26-2001 03:24 AM

Thanks :)

bira 11-27-2001 03:45 PM

If you haven't installed the hack, ignore this message -- the installation instructions in the first thread and the downloadable attachment txt file have been modified.


I've had a bug on my BB after installing this hack, so if anyone who installed this hack experiences the same problem, here's the fix:

Problem: even if you select the option to "request read receipt", the PM doesn't appear in the message tracking page.

Fix: in private.php find:

Code:

  // enhanced
  $receipt=iif($pmreceipt=="yes",1,0);
  // /enhanced

And replace with:

Code:

  // enhanced
  $receipt=iif($pmreceipt,1,0);
  // /enhanced

(the part removed is coloured in red in the original code).

JJR512 11-27-2001 03:55 PM

After reading your message, I tested, and found I had the same problem. Your fix works fine. But I have to wonder, since it looks like this isn't part of your hack code, but rather part of the original code...does this fix have any other side effects?

bira 11-27-2001 04:51 PM

JJR512 it shouldn't.

There is no difference as far as the private.php script goes between $pmreceipt=="yes" and just $pmreceipt not NULL.

For some reason, the preview hack alters the "yes". But it's still either NULL (empty) or not (has value).

So, the original code does:

Code:

if ($pmreceipt=="yes") {
  return 1;
} else {
  return 0;
}

My fix does:

Code:

if ($pmrecepit) { //does $pmreceipt have a value?
  return 1;
} else {
  return 0;
}

Hope I;m clear :)

Cheers,

Bira


All times are GMT. The time now is 06:11 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.01839 seconds
  • Memory Usage 1,775KB
  • 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
  • (34)bbcode_code_printable
  • (1)bbcode_php_printable
  • (1)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