XOOPS 2.5.6  Final
 All Classes Namespaces Files Functions Variables Pages
readpmsg.php
Go to the documentation of this file.
1 <?php
19 include dirname(__FILE__) . DIRECTORY_SEPARATOR . 'mainfile.php';
21 $xoopsPreload->triggerEvent('core.readpmsg.start');
22 
23 xoops_loadLanguage('pmsg');
24 
25 if (!is_object($xoopsUser)) {
26  redirect_header("user.php", 0);
27  exit();
28 } else {
29  $pm_handler =& xoops_gethandler('privmessage');
30  if (!empty($_POST['delete'])) {
31  if (!$GLOBALS['xoopsSecurity']->check()) {
32  echo implode('<br />', $GLOBALS['xoopsSecurity']->getErrors());
33  exit();
34  } else if (empty($_REQUEST['ok'])) {
35  include $GLOBALS['xoops']->path('header.php');
36  xoops_confirm(array('ok' => 1, 'delete' => 1, 'msg_id'=> intval($_POST['msg_id'])), $_SERVER['REQUEST_URI'], _PM_SURE_TO_DELETE);
37  include $GLOBALS['xoops']->path('footer.php');
38  exit();
39  }
40  $pm =& $pm_handler->get(intval($_POST['msg_id']));
41  if (!is_object($pm) || $pm->getVar('to_userid') != $xoopsUser->getVar('uid') || !$pm_handler->delete($pm)) {
42  exit();
43  } else {
44  redirect_header("viewpmsg.php", 1, _PM_DELETED);
45  exit();
46  }
47  }
48  $start = !empty($_GET['start']) ? intval($_GET['start']) : 0;
49  $total_messages = !empty($_GET['total_messages']) ? intval($_GET['total_messages']) : 0;
50  include $GLOBALS['xoops']->path('header.php');
51  $criteria = new Criteria('to_userid', $xoopsUser->getVar('uid'));
52  $criteria->setLimit(1);
53  $criteria->setStart($start);
54  $criteria->setSort('msg_time');
55  $pm_arr = $pm_handler->getObjects($criteria);
56  echo "<div><h4>" . _PM_PRIVATEMESSAGE . "</h4></div><br /><a href='userinfo.php?uid=" . $xoopsUser->getVar("uid") . "' title=''>" . _PM_PROFILE . "</a>&nbsp;<span class='bold'>&raquo;&raquo;</span>&nbsp;<a href='viewpmsg.php' title=''>" . _PM_INBOX . "</a>&nbsp;<span class='bold'>&raquo;&raquo;</span>&nbsp;\n";
57  if (empty($pm_arr)) {
58  echo '<br /><br />' . _PM_YOUDONTHAVE;
59  } else {
60  if (!$pm_handler->setRead($pm_arr[0])) {
61  //echo "failed";
62  }
63  echo $pm_arr[0]->getVar("subject") . "<br /><form action='readpmsg.php' method='post' name='delete" . $pm_arr[0]->getVar("msg_id") . "'><table cellpadding='4' cellspacing='1' class='outer width100 bnone'><tr><th colspan='2'>" . _PM_FROM . "</th></tr><tr class='even'>\n";
64  $poster = new XoopsUser($pm_arr[0]->getVar("from_userid"));
65  if (!$poster->isActive()) {
66  $poster = false;
67  }
68  echo "<td valign='top'>";
69  if ($poster != false) { // we need to do this for deleted users
70  echo "<a href='userinfo.php?uid=" . $poster->getVar("uid") . "' title=''>" . $poster->getVar("uname") . "</a><br />\n";
71  if ($poster->getVar("user_avatar") != "") {
72  echo "<img src='uploads/" . $poster->getVar("user_avatar") . "' alt='' /><br />\n";
73  }
74  if ($poster->getVar("user_from") != "") {
75  echo _PM_FROMC . "" . $poster->getVar("user_from") . "<br /><br />\n";
76  }
77  if ($poster->isOnline()) {
78  echo "<span class='red bold'>" . _PM_ONLINE . "</span><br /><br />\n";
79  }
80  } else {
81  echo $xoopsConfig['anonymous']; // we need to do this for deleted users
82  }
83 //------------- mamba
84  $iconName=$pm_arr[0]->getVar("msg_image", "E");
85  if ($iconName != '') {
86  echo "</td><td><img src='images/subject/" .$iconName . "' alt='' />&nbsp;" . _PM_SENTC . "" . formatTimestamp($pm_arr[0]->getVar("msg_time"));
87  }
88  else {
89  echo "</td><td>" . _PM_SENTC . "" . formatTimestamp($pm_arr[0]->getVar("msg_time"));
90  }
91 //------------- mamba
92 
93  echo "<hr /><br /><strong>" . $pm_arr[0]->getVar("subject") . "</strong><br /><br />\n";
94  echo $pm_arr[0]->getVar("msg_text") . "<br /><br /></td></tr><tr class='foot'><td class='width20 txtleft' colspan='2'>";
95  // we dont want to reply to a deleted user!
96  if ($poster != false) {
97  echo "<a href='#' onclick='javascript:openWithSelfMain(\"" . XOOPS_URL . "/pmlite.php?reply=1&amp;msg_id=" . $pm_arr[0]->getVar("msg_id") . "\",\"pmlite\",565,500);'><img src='" . XOOPS_URL . "/images/icons/reply.gif' alt='" . _PM_REPLY . "' /></a>\n";
98  }
99  echo "<input type='hidden' name='delete' value='1' />";
100  echo $GLOBALS['xoopsSecurity']->getTokenHTML();
101  echo "<input type='hidden' name='msg_id' value='" . $pm_arr[0]->getVar("msg_id") . "' />";
102  echo "<a href='#" . $pm_arr[0]->getVar("msg_id") . "' onclick='javascript:document.delete" . $pm_arr[0]->getVar("msg_id") . ".submit();'><img src='" . XOOPS_URL . "/images/icons/delete.gif' alt='" . _PM_DELETE . "' /></a>";
103  echo "</td></tr><tr><td class='txtright' colspan='2'>";
105  $next = $start + 1;
106  if ($previous >= 0) {
107  echo "<a href='readpmsg.php?start=" . $previous . "&amp;total_messages=" . $total_messages . "' title=''>" . _PM_PREVIOUS . "</a> | ";
108  } else {
109  echo _PM_PREVIOUS . " | ";
110  }
111  if ($next < $total_messages) {
112  echo "<a href='readpmsg.php?start=" . $next . "&amp;total_messages=" . $total_messages . "' title=''>" . _PM_NEXT . "</a>";
113  } else {
114  echo _PM_NEXT;
115  }
116  echo "</td></tr></table></form>\n";
117  }
118  include $GLOBALS['xoops']->path('footer.php');
119 }
120 ?>