Private Messaging System Private Messaging System
 

News:

cpg1.5.48 Security release - upgrade mandatory!
The Coppermine development team is releasing a security update for Coppermine in order to counter a recently discovered vulnerability. It is important that all users who run version cpg1.5.46 or older update to this latest version as soon as possible.
[more]

Main Menu

Private Messaging System

Started by Stramm, October 31, 2007, 01:59:25 AM

Previous topic - Next topic

0 Members and 2 Guests are viewing this topic.

Stramm

This plugin allows you to send private messages to other registered users.
Actually this plugin works for an unbridged coppermine. It'll add a send pm functionality and one to view PMs. Also there is bridge support built in. For now the smf10 works too. It's not that easy to add other bridges cause the bridge files aren't written in the same style. Therefore the way to go would be to hardcode some routines.

In bridged mode the plugin uses the forums PM functions and just adds 'send PM' links in thumbnail view, above the intermediate image and if you copy/ paste the contents of theme_changes.txt to your theme.php another 'send PM' link next to commenter names.

In the admin menu a 'PMS' button will appeare. You can make some settings here
- enable/ disable pm
- a bunch of other stuff like smilies etc... some are not yet implemented
important is
Display pm status info when logged in - this will add some statistics (Private Messages:  2 unread, total 9)
Display login form - will show a login box if a user isn't logged in, the above stats at that place when logged in

An english lang file is added. You can add new lang files... the sheme is similar to the other cpg lang files.

Installation:
- unzip and upload to your plugins folder, use the plugin manager to install it
- have a look into the folder images_to_move
   -> copy all images within this folder to your themes images folder (eg themes/classic/images)
   -> copy/ paste the contents from css_changes.txt to your themes css file (eg themes/classic/style.css)
   -> copy/ paste the contents of theme_changes.txt to your theme.php (eg themes/classic/theme.php)
       [no biggie if you don't do that, however the 'send PM' link won't then display next to the username within comments]
   -> if you want to display a 'send PM' link in the user profile, you'll have to manually edit profile.php. Version 1.1 of the plugin introduces a plugin hook in profile.php to reduce the editing amount.

in profile.php find (at the end of the code)
        make_form($display_profile_form_param, $form_data);

and replace with
        //added for plugin support - PMS
$profile_data = CPGPluginAPI::filter('profile_add_data', array ( 0 => $display_profile_form_param, 1 => $form_data ));
        make_form($profile_data[0], $profile_data[1]);


that's it with editing

The login form by default is placed after the sub  menu. If you want it to appeare somewhere else, then add
{LOGIN_FORM}
to your template.html.

New version (1.1 uploaded on 11/02/2007)
- added plugin hook in profile.php and changed code in codebase.php to make use of that hook to add data to the profile (send PM link)

bigarte


Su8Z3r0

Hi there Great plug in thx. just 1 thing i found is that the Pm link in the comments dont work. click on pm next to user name and it just comes up with The webpage cannot be found HTTP404. But all the other pm links work.
ive installed it all as it says, checked it. Is it the same for anyone else? or is it just me.

thx

Stramm

Yes, seems I have added an older version of the theme changes to the zip.
Find below what I intended to put there

if ($CONFIG['pms_enabled']) {
$pm_link = "<cite><a href=\"{PM_LINK}{AUTHOR_ID}\"><img src='{THEME_DIR}images/pm.gif' width=\"16\" height=\"11\" border=\"0\" alt=\"Send PM\" /></a></cite>";
}
$template_image_comments = <<<EOT
<table align="center" width="{WIDTH}" cellspacing="1" cellpadding="0" class="maintable">

        <tr>
                <td>
                        <table width="100%" cellpadding="0" cellspacing="0">
                           <tr>
                                <td class="tableh2_compact" nowrap="nowrap">
                                        <b>{MSG_AUTHOR}</b><a name="comment{MSG_ID}"></a>&nbsp;
$pm_link
<!-- BEGIN ipinfo -->
                                                                                 ({IP})
<!-- END ipinfo -->
</td>


                                <td class="tableh2_compact" align="right" width="100%">
<!-- BEGIN report_comment_button -->
     <a href="report_file.php?pid={PID}&amp;msg_id={MSG_ID}&amp;what=comment" title="{REPORT_COMMENT_TITLE}"><img src="images/report.gif" width="16" height="16" border="0" align="middle" alt="{REPORT_COMMENT_TITLE}" /></a>
<!-- END report_comment_button -->


<!-- BEGIN buttons -->
                                        <a href="javascript:;" onclick="blocking('cbody{MSG_ID}','', 'block'); blocking('cedit{MSG_ID}','', 'block'); return false;" title="{EDIT_TITLE}"><img src="images/edit.gif" border="0" align="middle" /></a>
                                        <a href="delete.php?msg_id={MSG_ID}&what=comment"  onclick="return confirm('{CONFIRM_DELETE}');"><img src="images/delete.gif" border="0" align="middle" /></a>
<!-- END buttons -->
                                </td>
                                <td class="tableh2_compact" align="right" nowrap="nowrap">
                                        <span class="comment_date">[{MSG_DATE}]</span>
                                </td></tr>
                        </table>
                </td>
        </tr>
        <tr>
                <td class="tableb_compact">
                        <div id="cbody{MSG_ID}" style="display:block">
                                {MSG_BODY}
                        </div>
                        <div id="cedit{MSG_ID}" style="display:none">
<!-- BEGIN edit_box_smilies -->
                                <table width="100%" cellpadding="0" cellspacing="0">

                                                <form name="f{MSG_ID}" method="POST" action="db_input.php">
                                                <input type="hidden" name="event" value="comment_update" />
                                                <input type="hidden" name="msg_id" value="{MSG_ID}" />
                                                <tr>
                                                <td>
                                                   <input type="text" name="msg_author" value="{MSG_AUTHOR}" class="textinput" size="25" />
                                                </td><td>
                                                </tr>
                                                <tr>
                                                <td width="80%">
                                                        <textarea cols="40" rows="2" class="textinput" name="msg_body" onselect="storeCaret_f{MSG_ID}(this);" onclick="storeCaret_f{MSG_ID}(this);" onkeyup="storeCaret_f{MSG_ID}(this);" style="width: 100%;">{MSG_BODY_RAW}</textarea>
                                                </td>
                                                <td class="tableb_compact">
                                                </td>
                                                <td>
                                                        <input type="submit" class="comment_button" name="submit" value="{OK}" />
                                                </td>
                                                </form>
                                        </tr>
                                        <tr>
                                                <td colspan="3"><img src="images/spacer.gif" width="1" height="2" /><br /></td>
                                        </tr>
                                </table>
                                {SMILIES}
<!-- END edit_box_smilies -->
<!-- BEGIN edit_box_no_smilies -->
                                <table width="100%" cellpadding="0" cellspacing="0">
                                        <tr>
                                                <form name="f{MSG_ID}" method="POST" action="db_input.php">
                                                <input type="hidden" name="event" value="comment_update" />
                                                <input type="hidden" name="msg_id" value="{MSG_ID}" />
                                                <td>
                                                <input type="text" name="msg_author" value="{MSG_AUTHOR}" class="textinput" size="25" />
                                                </td>
                                        </tr>
                                        <tr>
                                                <td width="100%">
                                                        <textarea cols="40" rows="2" class="textinput" name="msg_body" style="width: 100%;">{MSG_BODY_RAW}</textarea>
                                                </td>
                                                <td class="tableb_compact">
                                                </td>
                                                <td>
                                                        <input type="submit" class="comment_button" name="submit" value="{OK}" />
                                                </td>
                                                </form>
                                        </tr>
                                        <tr>
                                                <td colspan="3"><img src="images/spacer.gif" width="1" height="2" /><br /></td>
                                        </tr>
                                </table>
<!-- END edit_box_no_smilies -->
                        </div>
                </td>
        </tr>
</table>
EOT;



function theme_html_comments($pid)
{
    global $CONFIG, $USER, $CURRENT_ALBUM_DATA, $comment_date_fmt, $HTML_SUBST;
    global $template_image_comments, $template_add_your_comment, $lang_display_comments, $THEME_DIR;

    $html = '';

    // report to moderator buttons
    if (!(($CONFIG['report_post']==1) && (USER_CAN_SEND_ECARDS))) {
        template_extract_block($template_image_comments, 'report_comment_button');
    }

    if (!$CONFIG['enable_smilies']) {
        $tmpl_comment_edit_box = template_extract_block($template_image_comments, 'edit_box_no_smilies', '{EDIT}');
        template_extract_block($template_image_comments, 'edit_box_smilies');
        template_extract_block($template_add_your_comment, 'input_box_smilies');
    } else {
        $tmpl_comment_edit_box = template_extract_block($template_image_comments, 'edit_box_smilies', '{EDIT}');
        template_extract_block($template_image_comments, 'edit_box_no_smilies');
        template_extract_block($template_add_your_comment, 'input_box_no_smilies');
    }

    $tmpl_comments_buttons = template_extract_block($template_image_comments, 'buttons', '{BUTTONS}');
    $tmpl_comments_ipinfo = template_extract_block($template_image_comments, 'ipinfo', '{IPINFO}');

    if ($CONFIG['comments_sort_descending'] == 1) {
        $comment_sort_order = 'DESC';
    } else {
        $comment_sort_order = 'ASC';
    }
    $result = cpg_db_query("SELECT msg_id, msg_author, msg_body, UNIX_TIMESTAMP(msg_date) AS msg_date, author_id, author_md5_id, msg_raw_ip, msg_hdr_ip, pid FROM {$CONFIG['TABLE_COMMENTS']} WHERE pid='$pid' ORDER BY msg_id $comment_sort_order");

    while ($row = mysql_fetch_array($result)) {
        $user_can_edit = (GALLERY_ADMIN_MODE) || (USER_ID && USER_ID == $row['author_id'] && USER_CAN_POST_COMMENTS) || (!USER_ID && USER_CAN_POST_COMMENTS && ($USER['ID'] == $row['author_md5_id']));
        $comment_buttons = $user_can_edit ? $tmpl_comments_buttons : '';
        $comment_edit_box = $user_can_edit ? $tmpl_comment_edit_box : '';
        $comment_ipinfo = ($row['msg_raw_ip'] && GALLERY_ADMIN_MODE)?$tmpl_comments_ipinfo : '';

        if ($CONFIG['enable_smilies']) {
            $comment_body = process_smilies(make_clickable($row['msg_body']));
            $smilies = generate_smilies("f{$row['msg_id']}", 'msg_body');
        } else {
            $comment_body = make_clickable($row['msg_body']);
            $smilies = '';
        }

        $ip = $row['msg_hdr_ip'];
        if ($row['msg_hdr_ip'] != $row['msg_raw_ip']) {
            $ip .= ' [' . $row['msg_raw_ip'] . ']';
        }

        $params = array('{EDIT}' => &$comment_edit_box,
            '{BUTTONS}' => &$comment_buttons,
            '{IPINFO}' => &$comment_ipinfo
            );

        $template = template_eval($template_image_comments, $params);

        $params = array('{MSG_AUTHOR}' => stripslashes($row['msg_author']),
            '{MSG_ID}' => $row['msg_id'],
            '{PID}' => $row['pid'],
            '{EDIT_TITLE}' => &$lang_display_comments['edit_title'],
            '{CONFIRM_DELETE}' => &$lang_display_comments['confirm_delete'],
            '{MSG_DATE}' => localised_date($row['msg_date'], $comment_date_fmt),
            '{MSG_BODY}' => bb_decode($comment_body),
            '{MSG_BODY_RAW}' => $row['msg_body'],
            '{OK}' => &$lang_display_comments['OK'],
            '{SMILIES}' => $smilies,
            '{IP}' => $ip,
            '{REPORT_COMMENT_TITLE}' => &$lang_display_comments['report_comment_title'],
            '{WIDTH}' => $CONFIG['picture_table_width'],
            '{THEME_DIR}' => $THEME_DIR,
            '{AUTHOR_ID}' => $row['author_id'],
            '{PM_LINK}' => PM_LINK
            );

        $html .= template_eval($template, $params);
    }

    if (USER_CAN_POST_COMMENTS && $CURRENT_ALBUM_DATA['comments'] == 'YES') {
        if (USER_ID) {
            $user_name_input = '<tr><td><input type="hidden" name="msg_author" value="' . stripslashes(USER_NAME) . '" /></td>';
            template_extract_block($template_add_your_comment, 'user_name_input', $user_name_input);
            $user_name = '';
        } else {
            if (isset($USER['name'])) {
              $user_name = strtr($USER['name'], $HTML_SUBST);
            } else {
              $user_name = $lang_display_comments['your_name'];
            }
        }

        $params = array('{ADD_YOUR_COMMENT}' => $lang_display_comments['add_your_comment'],
            // Modified Name and comment field
            '{NAME}' => $lang_display_comments['name'],
            '{COMMENT}' => $lang_display_comments['comment'],
            '{PIC_ID}' => $pid,
            '{USER_NAME}' => $user_name,
            '{MAX_COM_LENGTH}' => $CONFIG['max_com_size'],
            '{OK}' => $lang_display_comments['OK'],
            '{SMILIES}' => '',
            '{WIDTH}' => $CONFIG['picture_table_width'],
            );

        if ($CONFIG['enable_smilies']){
                        $params['{SMILIES}'] = generate_smilies();
                } else {
                        template_extract_block($template_add_your_comment, 'smilies');
                }

        $html .= template_eval($template_add_your_comment, $params);
    }

    return $html;
}

will

Hi Stramm

I've moved the {LOGIN_FORM} around to where I want it and I have it on the right side of my gallery where everything is aligned left. I've tried aligning it left in my template.html but it still stays on the right. Is there anywhere in the plugin that I can change to make it align left?

Thanks ;)

Stramm

codebase.php, function pms_loginform ... have a look at the html there

Su8Z3r0

Works a treat now Stramm. many thx

will

Gone into the codebase.php changed what I think is the right piece of code so I've changed it to 'left' like so:

if (USER_ID) {

                           $loginFormHtml = "<div align=\"left\" class=\"smallfont\">".$lang_pms_sys['welcome']." <strong>".(USER_NAME)."</strong><br/></div>";


But is still aligned right! ???

Am I missing something, by the way its the section of the plugin when logged in and showing how many pms I have is the bit what I need aligning.

Thanks

Stramm


will


Stramm


will

Did you log into the forum here as my gallery is bridged:

http://cdcoverhideout.com/newforum

You will see a gallery link in the forum once logged in ;)

will

sorry my bad:

u/n = test

p/w = emmahurry ;)

Stramm

had a look at your code... here I see that
$loginFormHtml = "<div align=\"right\" class=\"smallfont\">".$lang_pms_sys['welcome']." <strong>".(USER_NAME)."</strong><br />";
hasn't been changed to
$loginFormHtml = "<div align=\"left\" class=\"smallfont\">".$lang_pms_sys['welcome']." <strong>".(USER_NAME)."</strong><br />";


or you have another plugin/ mod tunning that overrides the pm function (modpack is one and there's my login form plugin)

That's the output (from your sites source)
<h2>My Account</h2>
<left></left><div class="smallfont" align="right">Welcome back <strong>test</strong><br><a

you see... still align right (btw. what's the use of <left></left>)

will

haven't added that, I'll take another look ;)

will

I must of added that anyway took it out I've attached the file to show that I have changed to left but still the same ???

Stramm

your change in that file doesn't reflect on your site. Are you sure you've uploaded and overwritten the original codebase.php in the photo_shop plugin dir?

I've seen that you use IPB... that's not yet supported unless you write bridge support for it
Actually this plugin works for an unbridged coppermine. It'll add a send pm functionality and one to view PMs. Also there is bridge support built in. For now the smf10 works too.

will

ok, didn't read that part of the thread, I'll wait for IPB support has I'm not good with PHP coding ;D

PHIPHI

Bonjour,

Voici ma modeste contribution à ce magnifique plugin qu'est "Messages privés".
Vous trouverez en pièce jointe, la version française de cpg_pms.

Tous les fichiers du plugin ont été traduit en français.

Bonne installation

DPH91

Stramm