XOOPS 2.5.6  Final
 All Classes Namespaces Files Functions Variables Pages
viewpmsg.php
Go to the documentation of this file.
1 <?php
19 include dirname(__FILE__) . DIRECTORY_SEPARATOR . 'mainfile.php';
21 $xoopsPreload->triggerEvent('core.viewpmsg.start');
22 
23 xoops_loadLanguage('pmsg');
24 
25 if (!is_object($xoopsUser)) {
26  $errormessage = _PM_SORRY . "<br />" . _PM_PLZREG . "";
27  redirect_header("user.php", 2, $errormessage);
28 } else {
29  $pm_handler =& xoops_gethandler('privmessage');
30  if (isset($_POST['delete_messages']) && isset($_POST['msg_id'])) {
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_messages' => 1, 'msg_id'=> serialize(array_map("intval", $_POST['msg_id']))), $_SERVER['REQUEST_URI'], _PM_SURE_TO_DELETE);
37  include $GLOBALS['xoops']->path('footer.php');
38  exit();
39  }
40  $_POST['msg_id'] = unserialize($_REQUEST['msg_id']);
41  $size = count($_POST['msg_id']);
42  $msg =& $_POST['msg_id'];
43  for($i = 0; $i < $size; $i++) {
44  $pm =& $pm_handler->get(intval($msg[$i]));
45  if ($pm->getVar('to_userid') == $xoopsUser->getVar('uid')) {
46  $pm_handler->delete($pm);
47  }
48  unset($pm);
49  }
50  redirect_header("viewpmsg.php", 1, _PM_DELETED);
51  exit();
52  }
53  include $GLOBALS['xoops']->path('header.php');
54  $criteria = new Criteria('to_userid', $xoopsUser->getVar('uid'));
55  $criteria->setOrder('DESC');
56  $pm_arr = $pm_handler->getObjects($criteria);
57  echo "<h4 class='txtcenter'>" . _PM_PRIVATEMESSAGE . "</h4><br /><a href='userinfo.php?uid=" . $xoopsUser->getVar("uid") . "'>" . _PM_PROFILE . "</a>&nbsp;<span style='font-weight:bold;'>&raquo;&raquo;</span>&nbsp;" . _PM_INBOX . "<br /><br />";
58  echo "<form name='prvmsg' method='post' action='viewpmsg.php'>";
59  echo "<table cellspacing='1' cellpadding='4' class='outer width100 bnone'>\n";
60  echo "<tr align='center' valign='middle'><th><input name='allbox' id='allbox' onclick='xoopsCheckAll(\"prvmsg\", \"allbox\");' type='checkbox' value='Check All' /></th><th><img class'bnone' src='images/download.gif' alt=''/></th><th>&nbsp;</th><th>" . _PM_FROM . "</th><th>" . _PM_SUBJECT . "</th><th class='txtcenter'>" . _PM_DATE . "</th></tr>\n";
62  if ($total_messages == 0) {
63  echo "<tr><td class='even txcenter' colspan='6'>" . _PM_YOUDONTHAVE . "</td></tr> ";
64  $display = 0;
65  } else {
66  $display = 1;
67  }
68  for($i = 0; $i < $total_messages; $i++) {
69  $class = ($i % 2 == 0) ? 'even' : 'odd';
70  echo "<tr class='$class txtleft'><td class='aligntop width2 txtcenter'><input type='checkbox' id='msg_id[]' name='msg_id[]' value='" . $pm_arr[$i]->getVar("msg_id") . "' /></td>\n";
71  if ($pm_arr[$i]->getVar('read_msg') == 1) {
72  echo "<td class='aligntop width5 txtcenter'><img src='images/email_read.png' alt='" . _PM_READ . "' title='" . _PM_READ . "' /></td>\n";
73  } else {
74  echo "<td class='aligntop width5 txtcenter'><img src='images/email_notread.png' alt='" . _PM_NOTREAD . "' title='" . _PM_NOTREAD . "' /></td>\n";
75  }
76  $iconName=$pm_arr[$i]->getVar("msg_image", "E");
77  if ($iconName != '') {
78  echo "<td class='aligntop width5 txtcenter'><img src='images/subject/" . $iconName . "' alt='' /></td>\n";
79  }
80  else {
81  echo "<td class='aligntop width5 txtcenter'></td>\n";
82  }
83  $postername = XoopsUser::getUnameFromId($pm_arr[$i]->getVar("from_userid"));
84  echo "<td class='alignmiddle width10'>";
85  // no need to show deleted users
86  if ($postername) {
87  echo "<a href='userinfo.php?uid=" . $pm_arr[$i]->getVar("from_userid") . "' title=''>" . $postername . "</a>";
88  } else {
89  echo $xoopsConfig['anonymous'];
90  }
91  echo "</td>\n";
92  echo "<td class='alignmiddle'><a href='readpmsg.php?start=" . ($total_messages - $i - 1), "&amp;total_messages=$total_messages'>" . $pm_arr[$i]->getVar("subject") . "</a></td>";
93  echo "<td class='alignmiddle txtcenter width20'>" . formatTimestamp($pm_arr[$i]->getVar("msg_time")) . "</td></tr>";
94  }
95  if ($display == 1) {
96  echo "<tr class='foot txtleft'><td colspan='6' align='left'><input type='button' class='formButton' onclick='javascript:openWithSelfMain(\"" . XOOPS_URL . "/pmlite.php?send=1\",\"pmlite\",565,500);' value='" . _PM_SEND . "' />&nbsp;<input type='submit' class='formButton' name='delete_messages' value='" . _PM_DELETE . "' />" . $GLOBALS['xoopsSecurity']->getTokenHTML() . "</td></tr></table></form>";
97  } else {
98  echo "<tr class='bg2 txtleft'><td class='txtleft' colspan='6'><input type='button' class='formButton' onclick='javascript:openWithSelfMain(\"" . XOOPS_URL . "/pmlite.php?send=1\",\"pmlite\",565,500);' value='" . _PM_SEND . "' /></td></tr></table></form>";
99  }
100  include $GLOBALS['xoops']->path('footer.php');
101 }
102 ?>