home *** CD-ROM | disk | FTP | other *** search
/ Cricao de Sites - 650 Layouts Prontos / WebMasters.iso / CMS / xoops-2.0.18.1.exe / xoops-2.0.18.1 / htdocs / viewpmsg.php < prev    next >
Encoding:
PHP Script  |  2008-01-10  |  6.1 KB  |  98 lines

  1. <?php
  2. // $Id: viewpmsg.php 1240 2008-01-10 04:06:08Z julionc $
  3. //  ------------------------------------------------------------------------ //
  4. //                XOOPS - PHP Content Management System                      //
  5. //                    Copyright (c) 2000 XOOPS.org                           //
  6. //                       <http://www.xoops.org/>                             //
  7. //  ------------------------------------------------------------------------ //
  8. //  This program is free software; you can redistribute it and/or modify     //
  9. //  it under the terms of the GNU General Public License as published by     //
  10. //  the Free Software Foundation; either version 2 of the License, or        //
  11. //  (at your option) any later version.                                      //
  12. //                                                                           //
  13. //  You may not change or alter any portion of this comment or credits       //
  14. //  of supporting developers from this source code or any supporting         //
  15. //  source code which is considered copyrighted (c) material of the          //
  16. //  original comment or credit authors.                                      //
  17. //                                                                           //
  18. //  This program is distributed in the hope that it will be useful,          //
  19. //  but WITHOUT ANY WARRANTY; without even the implied warranty of           //
  20. //  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the            //
  21. //  GNU General Public License for more details.                             //
  22. //                                                                           //
  23. //  You should have received a copy of the GNU General Public License        //
  24. //  along with this program; if not, write to the Free Software              //
  25. //  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307 USA //
  26. //  ------------------------------------------------------------------------ //
  27.  
  28. $xoopsOption['pagetype'] = "pmsg";
  29. include_once "mainfile.php";
  30.  
  31. if (!is_object($xoopsUser)) {
  32.     $errormessage = _PM_SORRY."<br />"._PM_PLZREG."";
  33.     redirect_header("user.php",2,$errormessage);
  34. } else {
  35.     $pm_handler =& xoops_gethandler('privmessage');
  36.     if (isset($_POST['delete_messages']) && isset($_POST['msg_id'])) {
  37.         if (!$GLOBALS['xoopsSecurity']->check()) {
  38.             echo implode('<br />', $GLOBALS['xoopsSecurity']->getErrors());
  39.             exit();
  40.         }
  41.         $size = count($_POST['msg_id']);
  42.         $msg =& $_POST['msg_id'];
  43.             for ( $i = 0; $i < $size; $i++ ) {
  44.             $pm =& $pm_handler->get($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 XOOPS_ROOT_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 style='text-align:center;'>". _PM_PRIVATEMESSAGE ."</h4><br /><a href='userinfo.php?uid=". $xoopsUser->getVar("uid")."'>". _PM_PROFILE ."</a> <span style='font-weight:bold;'>»»</span> ". _PM_INBOX ."<br /><br />";
  58.     echo "<form name='prvmsg' method='post' action='viewpmsg.php'>";
  59.     echo "<table border='0' cellspacing='1' cellpadding='4' width='100%' class='outer'>\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 src='images/download.gif' alt='' border='0' /></th><th> </th><th>". _PM_FROM ."</th><th>". _PM_SUBJECT ."</th><th align='center'>". _PM_DATE ."</th></tr>\n";
  61.     $total_messages = count($pm_arr);
  62.     if ( $total_messages == 0 ) {
  63.         echo "<tr><td class='even' colspan='6' align='center'>"._PM_YOUDONTHAVE."</td></tr> ";
  64.         $display= 0;
  65.     } else {
  66.  
  67.         $display = 1;
  68.     }
  69.     for ($i = 0; $i < $total_messages; $i++) {
  70.         $class = ($i % 2 == 0) ? 'even' : 'odd';
  71.         echo "<tr align='left' class='$class'><td valign='top' width='2%' align='center'><input type='checkbox' id='msg_id[]' name='msg_id[]' value='".$pm_arr[$i]->getVar("msg_id")."' /></td>\n";
  72.         if ($pm_arr[$i]->getVar('read_msg') == 1) {
  73.             echo "<td valign='top' width='5%' align='center'> </td>\n";
  74.         } else {
  75.             echo "<td valign='top' width='5%' align='center'><img src='images/read.gif' alt='"._PM_NOTREAD."' /></td>\n";
  76.         }
  77.         echo "<td valign='top' width='5%' align='center'><img src='images/subject/".$pm_arr[$i]->getVar("msg_image", "E")."' alt='' /></td>\n";
  78.         $postername = XoopsUser::getUnameFromId($pm_arr[$i]->getVar("from_userid"));
  79.         echo "<td valign='middle' width='10%'>";
  80.         // no need to show deleted users
  81.         if ($postername) {
  82.             echo "<a href='userinfo.php?uid=".$pm_arr[$i]->getVar("from_userid")."'>".$postername."</a>";
  83.         } else {
  84.             echo $xoopsConfig['anonymous'];
  85.         }
  86.         echo "</td>\n";
  87.         echo "<td valign='middle'><a href='readpmsg.php?start=".($total_messages-$i-1),"&total_messages=$total_messages'>".$pm_arr[$i]->getVar("subject")."</a></td>";
  88.         echo "<td valign='middle' align='center' width='20%'>".formatTimestamp($pm_arr[$i]->getVar("msg_time"))."</td></tr>";
  89.     }
  90.  
  91.     if ( $display == 1 ) {
  92.         echo "<tr class='foot' align='left'><td colspan='6' align='left'><input type='button' class='formButton' onclick='javascript:openWithSelfMain(\"".XOOPS_URL."/pmlite.php?send=1\",\"pmlite\",450,380);' value='"._PM_SEND."' /> <input type='submit' class='formButton' name='delete_messages' value='"._PM_DELETE."' />".$GLOBALS['xoopsSecurity']->getTokenHTML()."</td></tr></table></form>";
  93.     } else {
  94.         echo "<tr class='bg2' align='left'><td colspan='6' align='left'><input type='button' class='formButton' onclick='javascript:openWithSelfMain(\"".XOOPS_URL."/pmlite.php?send=1\",\"pmlite\",450,380);' value='"._PM_SEND."' /></td></tr></table></form>";
  95.     }
  96.     include "footer.php";
  97. }
  98. ?>