Customizing SMF > SMF Coding Discussion

Create own PM Inbox

(1/3) > >>

PS4DEV:
Hello , I tried to create my own PM Inbox function, but somehow I think I need help.

This current code, badly shows all of the PM´s sent by every user, but i want to show only the PMs that belongs to this User.
How to show only the Personal Messages which belongs to the right user. ?

Has someone ideas or a solution ?
Thank you very much.


--- Code: ---function pm_subjectlist()
{
global $smcFunc, $scripturl, $sourcedir, $modSettings, $settings, $context, $user_info, $boarddir, $txt, $options, $event, $childbutton, $button, $user_settings, $themeurl;

$personalmessage_result = $smcFunc['db_query']('', '
   SELECT   pm.id_pm, pm.id_pm_head, pm.subject, pm.body, pm.deleted_by_sender, pm.from_name, pm.id_member_from, pm.msgtime,
pmr.id_member , pmr.labels, pmr.is_read, pmr.is_new, pmr.deleted, u.avatar, u.member_name
   FROM {db_prefix}personal_messages AS pm
   LEFT JOIN {db_prefix}members AS u ON (pm.id_member_from = u.id_member)
   LEFT JOIN {db_prefix}pm_recipients AS pmr ON (pm.id_member_from = pmr.id_member)
   WHERE pmr.deleted = 0
   GROUP BY pm.id_pm_head
   ORDER BY pm.id_pm DESC
   LIMIT 1000
');
$personalmessages = array();

while ($row_posts = $smcFunc['db_fetch_assoc']($personalmessage_result))
{
global $memberContext;
loadMemberData($row_posts['id_member']);
loadMemberContext($row_posts['id_member']);

   $personalmessages[] = array(
  'pm_msg_id' => $row_posts['id_pm'],
  'user_id' => $row_posts['id_member'],
  'username' => '<a href="' . $scripturl . '?action=profile;u=' . $row_posts['id_member'] . '" style="font-weight:">' . $row_posts['member_name'] . '</a>',
  'subject' => '<b>'. $row_posts['subject'] .'</b>' ,
  'body' => '' .$row_posts['body'] .'',  
  'avatar' => $row_posts['avatar'] == '' ? $memberContext[$row_posts['id_member']]['avatar']['href'] : (stristr($row_posts['avatar'], 'http://') ? $row_posts['avatar'] : $modSettings['avatar_url'] . '/' . $row_posts['avatar']), 
  'time' => timeformat($row_posts['msgtime'], '%d %B %Y at %H:%M'),
  'new' => !empty($row_posts['is_read'])
   );

}
$smcFunc['db_free_result']($personalmessage_result);

echo '<div class="pmcontainer" id="pmcontainer_u' . $user_info['id'] . '" style="display:block;">';
foreach($personalmessages as $pm) {

echo '
<a class="pmessage" href="' . $scripturl . '?action=pm#' . $pm['pm_msg_id'] . '">
<img src="' . $pm['avatar'] . '" width="50px" height="50px" title="" alt="" />
<span>' . $pm['subject'] . '</span><br />
<span>' . $pm['body'] . '</span><br />
<span>' . $pm['time'] . '</span>
</a>';

}
echo '</div>';

}

--- End code ---

K@:
SMF doesn't agree with anybody viewing other member's PRIVATE messages.

So, you won't be getting any help, for this.

It's immoral.

PS4DEV:

--- Quote from: K@ on August 30, 2012, 07:25:00 AM ---SMF doesn't agree with anybody viewing other member's PRIVATE messages.

So, you won't be getting any help, for this.

It's immoral.

--- End quote ---
No you didn´t  understand it correctly.
I´m sorry for my English.
The point is , that i don´t want to show all PMs of all Members , like you said that its immortal !
But my current code does this and  that´s why i´m asking for a better code or help , so that i can fix this problem.

Suki:
Why exactly do you want to do this?  wont be better to use the existing code and just adapt it to your needs?

Yoshi:
Might be worth it to add WHERE u.id_member = {int:userid} in the query, see if that solves it.

Though I agree with Suki, it's better to adapt the code.

Navigation

[0] Message Index

[#] Next page

Go to full version