phpBB2Refugees.com Logo
Not affiliated with or endorsed by the phpBB Group

Register •  Login 

Continue the legacy...

Welcome to all phpBB2 Refugees!Wave Smilie

This site is intended to continue support for the legacy 2.x line of the phpBB2 bulletin board package. If you are a fan of phpBB2, please, by all means register, post, and help us out by offering your suggestions. We are primarily a community and support network. Our secondary goal is to provide a phpBB2 MOD Author and Styles area.

[RELEASED] Track PMs for phpBB2

Goto page Previous  1, 2
 
Search this topic... | Search MOD Development... | Search Box
Register or Login to Post    Index » MOD Development  Previous TopicPrint TopicNext Topic
Author Message
vlad77
Board Member



Joined: 31 May 2015

Posts: 72


flag
PostPosted: Sun Jan 27, 2019 5:19 pm 
Post subject: Re: Track PMs for phpBB2

Vendethiel wrote:
In which case is the to_userid NULL?
In all cases. The sql query does not have a extract of the "privmsgs_to_userid" column. To remake the request is time consuming, it is necessary to test for a long time, so that users could not read other people's private messages, it is necessary for security.
I dont have time for this.
Back to top
vlad77
Board Member



Joined: 31 May 2015

Posts: 72


flag
PostPosted: Sun Jan 27, 2019 5:47 pm 
Post subject: Re: Track PMs for phpBB2

Vendethiel wrote:
I have changed the code, to use privmsgs_date + text as a differentiator:
You test the code. I can spend a lot of time.
Back to top
vlad77
Board Member



Joined: 31 May 2015

Posts: 72


flag
PostPosted: Sun Jan 27, 2019 7:10 pm 
Post subject: Re: Track PMs for phpBB2

Vendethiel, instead of code
Code:
         if ($row['privmsgs_to_userid'] == $row['privmsgs_from_userid'] && ($row['privmsgs_type'] == PRIVMSGS_SENT_MAIL || $row['privmsgs_type'] == PRIVMSGS_SAVED_OUT_MAIL))
         { // V: if we're sending PMs to ourselves, skip it all
            continue;
         }
test this code
Code:
         if ($row['user_id_1'] == $row['user_id_2'] && ($row['privmsgs_type'] == PRIVMSGS_SENT_MAIL || $row['privmsgs_type'] == PRIVMSGS_SAVED_OUT_MAIL))
         { // V: if we're sending PMs to ourselves, skip it all
            continue;
         }
Back to top
Vendethiel
Board Member



Joined: 26 Oct 2014

Posts: 151



PostPosted: Mon Jan 28, 2019 1:08 pm 
Post subject: Re: Track PMs for phpBB2

Here is the attach mod add-on:

Code:

#
#-----[ OPEN ]------------------------------------------------
#
attach_mod/displaying.php
#
#-----[ FIND ]------------------------------------------------
#
function init_display_pm_attachments($switch_attachment)
{
   global $attach_config, $template, $userdata, $lang, $attachments, $privmsg;
   if ($userdata['user_level'] == ADMIN)
   {
      $auth_download = 1;
   }
   else
   {
      $auth_download = intval($attach_config['allow_pm_attach']);
   }
   if (intval($switch_attachment) == 0 || intval($attach_config['disable_mod']) || !$auth_download)
   {
      return;
   }
   $privmsgs_id = $privmsg['privmsgs_id'];
   
   @reset($attachments);
   $attachments['_' . $privmsgs_id] = get_attachments_from_pm($privmsgs_id);
   if (count($attachments['_' . $privmsgs_id]) == 0)
   {
      return;
   }
   $template->assign_block_vars('postrow', array());
      
   init_display_template('body', '{ATTACHMENTS}');
   init_complete_extensions_data();
   
   $template->assign_vars(array(
      'L_POSTED_ATTACHMENTS' => $lang['Posted_attachments'],
      'L_KILOBYTE' => $lang['KB'])
   );
   display_pm_attachments($privmsgs_id, $switch_attachment);
}
#
#-----[ REPLACE WITH ]------------------------------------------------
#
function init_display_pm_attachments($switch_attachment, $privmsg_ids)
{
   global $attach_config, $template, $userdata, $lang, $attachments;

   if ($userdata['user_level'] == ADMIN)
   {
      $auth_download = 1;
   }
   else
   {
      $auth_download = intval($attach_config['allow_pm_attach']);
   }

   if (intval($switch_attachment) == 0 || intval($attach_config['disable_mod']) || !$auth_download)
   {
      return;
   }

   @reset($attachments);
   $fetched_attachments = get_attachments_from_pm($privmsg_ids);
   if (count($fetched_attachments) == 0)
   {
      return;
   }
   // V: first, reset, just in case we fetched the same privmsg attach twice
   // (this always happens with the Track PMs Mod)
   foreach ($fetched_attachments as $row)
   {
      $attachments['_' . $row['privmsgs_id']] = array();
   }

   foreach ($fetched_attachments as $row)
   {
      $attachments['_' . $row['privmsgs_id']][] = $row;
   }

   init_complete_extensions_data();
   
   $template->assign_vars(array(
      'L_POSTED_ATTACHMENTS' => $lang['Posted_attachments'],
      'L_KILOBYTE' => $lang['KB'])
   );

   // V: we use an array for Track PMs, it's handled manually
   if (!is_array($privmsg_ids))
   {
      $template->assign_block_vars('postrow', array());

      init_display_template('body', '{ATTACHMENTS}');

      display_pm_attachments($privmsg_ids, $switch_attachment);
   }
}
#
#-----[ OPEN ]------------------------------------------------
# whichever file does PM for you, I use PCP so it's in profilcp/
privmsg.php
#
#-----[ FIND ]------------------------------------------------
#
      while ( $row = $db->sql_fetchrow($result) )
#
#-----[ BEFORE, ADD ]------------------------------------------------
#
      $privmsg_ids = array();
      $switch_attachment = false;
#
#-----[ FIND ]------------------------------------------------
#
         $list_row[] = $row;
      }
#
#-----[ BEFORE, ADD ]------------------------------------------------
#
         $privmsg_ids[] = $row['privmsgs_id'];
         if ($row['privmsgs_attachment'])
         {
            $switch_attachment = true;
         }
#
#-----[ AFTER, ADD ]------------------------------------------------
#
      if ($switch_attachment)
      {
         init_display_pm_attachments($switch_attachment, $privmsg_ids);
         init_display_template('pm_tracker', '{ATTACHMENTS}');
      }
#
#-----[ FIND ]------------------------------------------------
# this can be slightly different, depending on where the ) is
               'PM_DATE' => create_date($board_config['default_dateformat'], $list_row[$i]['privmsgs_date'], $board_config['board_timezone']),
               'PM_SUBJECT' => $reply_subject,
               'MESSAGE' => $reply_message,
               )
            );
#
#-----[ AFTER, ADD ]------------------------------------------------
#
            display_pm_attachments($list_row[$i]['privmsgs_id'], $list_row[$i]['privmsgs_attachment']);
#
#-----[ FIND ]------------------------------------------------
#
   return $pm_track_id;
#
#-----[ AFTER, ADD ]------------------------------------------------
#
   $template->_tpldata['postrow.'] = array();
#
#-----[ OPEN ]------------------------------------------------
#
templates/subSilver/posting_pm_tracker.tpl
#
#-----[ FIND ]------------------------------------------------
#
                                <td colspan="2"><span class="postbody">{postrow.MESSAGE}</span></td>
                        </tr>
#
#-----[ AFTER, ADD ]------------------------------------------------
#
                       <tr>
                               <td colspan="2">{ATTACHMENTS}</td>
                       </tr>

_________________
Developer on EzArena, the ADR premod.
Developer on Icy Phoenix, the phpBB hybrid cms.
Developer on IntegraMOD, the full-featured premod.
Help me archive premods on github! (fixed for recent PHPs).
Back to top
vlad77
Board Member



Joined: 31 May 2015

Posts: 72


flag
PostPosted: Tue Jan 29, 2019 9:12 am 
Post subject: Re: Track PMs for phpBB2

I looked at your code, until I tested it.

Line "if ($row['privmsgs_attachment'])" will not work, because there is no column retrieval in sql query privmsgs_attachment, so $row['privmsgs_attachment'] will always be NULL.


Have you tested the code?
Code:
         if ($row['user_id_1'] == $row['user_id_2'] && ($row['privmsgs_type'] == PRIVMSGS_SENT_MAIL || $row['privmsgs_type'] == PRIVMSGS_SAVED_OUT_MAIL))
         { // V: if we're sending PMs to ourselves, skip it all
            continue;
         }
Back to top
Vendethiel
Board Member



Joined: 26 Oct 2014

Posts: 151



PostPosted: Tue Jan 29, 2019 12:04 pm 
Post subject: Re: Track PMs for phpBB2

I forgot the SQL bit, you’re right. You need to add it to the SQL query.

I have started testing user_id_1 and 2, but not with savebox yet.

_________________
Developer on EzArena, the ADR premod.
Developer on Icy Phoenix, the phpBB hybrid cms.
Developer on IntegraMOD, the full-featured premod.
Help me archive premods on github! (fixed for recent PHPs).
Back to top
vlad77
Board Member



Joined: 31 May 2015

Posts: 72


flag
PostPosted: Tue Jan 29, 2019 1:10 pm 
Post subject: Re: Track PMs for phpBB2

Probably at the end of the query
Code:
$sql = "SELECT pm.privmsgs_id, pm.privmsgs_type, ....
add
Code:
, pm.privmsgs_attachment


See if there are the necessary columns, temporarily adding to the code
Code:
print_r($list_row);
Back to top
Vendethiel
Board Member



Joined: 26 Oct 2014

Posts: 151



PostPosted: Tue Jan 29, 2019 2:43 pm 
Post subject: Re: Track PMs for phpBB2

I did that in my version. I know attachments work for sure. But I forgot to add the SQL to my ADDON.
_________________
Developer on EzArena, the ADR premod.
Developer on Icy Phoenix, the phpBB hybrid cms.
Developer on IntegraMOD, the full-featured premod.
Help me archive premods on github! (fixed for recent PHPs).
Back to top
vlad77
Board Member



Joined: 31 May 2015

Posts: 72


flag
PostPosted: Sat Feb 02, 2019 9:09 am 
Post subject: Re: Track PMs for phpBB2

You have written
Code:
#
#-----[ FIND ]------------------------------------------------
#
   return $pm_track_id;
#
#-----[ AFTER, ADD ]------------------------------------------------
#
   $template->_tpldata['postrow.'] = array();
Maybe it meant?
Code:
#
#-----[ FIND ]------------------------------------------------
#
   return $pm_track_id;
#
#-----[ BEFORE, ADD ]------------------------------------------------
#
   $template->_tpldata['postrow.'] = array();
Code after return will not work.

We'll have to thoroughly recheck everything and maybe redo it. icon_sad.gif
Back to top
vlad77
Board Member



Joined: 31 May 2015

Posts: 72


flag
PostPosted: Sat Feb 02, 2019 10:11 am 
Post subject: Re: Track PMs for phpBB2

I'm testing your code.
Attachments in private messages are not visible. You changed the function init_display_pm_attachments, it would be correct not to change it, but add another function init_display_track_pms_attachments with your code.
Back to top
vlad77
Board Member



Joined: 31 May 2015

Posts: 72


flag
PostPosted: Sat Feb 02, 2019 12:42 pm 
Post subject: Re: Track PMs for phpBB2

Added addon attachments to the first post of this topic: "Attachment for Track PMs".
Back to top
Vendethiel
Board Member



Joined: 26 Oct 2014

Posts: 151



PostPosted: Sat Feb 02, 2019 10:52 pm 
Post subject: Re: Track PMs for phpBB2

Perfect. Diff looks good. It was indeed meant to be "BEFORE, ADD" yes
_________________
Developer on EzArena, the ADR premod.
Developer on Icy Phoenix, the phpBB hybrid cms.
Developer on IntegraMOD, the full-featured premod.
Help me archive premods on github! (fixed for recent PHPs).
Back to top
vlad77
Board Member



Joined: 31 May 2015

Posts: 72


flag
PostPosted: Sun Feb 03, 2019 3:09 pm 
Post subject: Re: Track PMs for phpBB2

Added to the first message the mod version 2.0.6
Mark the message being viewed now does not require install "eXtreme Styles mod 2".

Add to the mod code did no
Code:
         if ($row['user_id_1'] == $row['user_id_2'] && ($row['privmsgs_type'] == PRIVMSGS_SENT_MAIL || $row['privmsgs_type'] == PRIVMSGS_SAVED_OUT_MAIL))
         { // V: if we're sending PMs to ourselves, skip it all
            continue;
         }
Because it requires complex configuration, for example the message marked as “currently open” is deleted, and the unmarked is shown. The complexity of the task does not justify the insignificance of the result.
Back to top
vlad77
Board Member



Joined: 31 May 2015

Posts: 72


flag
PostPosted: Wed Feb 06, 2019 8:43 am 
Post subject: Re: Track PMs for phpBB2

Example track_pms_2.0.6


123.png
 Description:
Example track_pms_2.0.6
 Filesize:  5.1 KB
 Viewed:  3142 Time(s)

123.png


Back to top
Display posts from previous:   
Register or Login to Post    Index » MOD Development  Previous TopicPrint TopicNext Topic
Page 2 of 2 All times are GMT
Goto page Previous  1, 2
 
Jump to:  

Index • About • FAQ • Rules • Privacy • Search •  Register •  Login 
Not affiliated with or endorsed by the phpBB Group
Powered by phpBB2 © phpBB Group
Generated in 0.0352 seconds using 18 queries. (SQL 0.0038 Parse 0.0026 Other 0.0287)
phpBB Customizations by the phpBBDoctor.com
Template Design by DeLFlo and MomentsOfLight.com Moments of Light Logo