source: temp/test-xoops.ec-cube.net/html/readpmsg.php @ 405

Revision 405, 5.8 KB checked in by root, 20 years ago (diff)
Line 
1<?php
2// $Id: readpmsg.php,v 1.2 2005/03/18 12:51:55 onokazu Exp $
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";
29include_once "mainfile.php";
30
31if ( !$xoopsUser ) {
32    redirect_header("user.php",0);
33    exit();
34} else {
35    $pm_handler =& xoops_gethandler('privmessage');
36    if ( !empty($_POST['delete']) ) {
37        $pm =& $pm_handler->get(intval($_POST['msg_id']));
38        if (!is_object($pm) || $pm->getVar('to_userid') != $xoopsUser->getVar('uid') || !$pm_handler->delete($pm)) {
39            exit();
40        } else {
41            redirect_header("viewpmsg.php",1,_PM_DELETED);
42            exit();
43        }
44    }
45    $start = !empty($_GET['start']) ? intval($_GET['start']) : 0;
46    $total_messages = !empty($_GET['total_messages']) ? intval($_GET['total_messages']) : 0;
47    include XOOPS_ROOT_PATH.'/header.php';
48    $criteria = new Criteria('to_userid', $xoopsUser->getVar('uid'));
49    $criteria->setLimit(1);
50    $criteria->setStart($start);
51    $criteria->setSort('msg_time');
52    $pm_arr =& $pm_handler->getObjects($criteria);
53    echo "<div><h4>". _PM_PRIVATEMESSAGE."</h4></div><br /><a href='userinfo.php?uid=". $xoopsUser->getVar("uid") ."'>". _PM_PROFILE ."</a>&nbsp;<span style='font-weight:bold;'>&raquo;&raquo;</span>&nbsp;<a href='viewpmsg.php'>". _PM_INBOX ."</a>&nbsp;<span style='font-weight:bold;'>&raquo;&raquo;</span>&nbsp;\n";
54    if (empty($pm_arr)) {
55        echo '<br /><br />'._PM_YOUDONTHAVE;
56    } else {
57        if (!$pm_handler->setRead($pm_arr[0])) {
58            //echo "failed";
59        }
60        echo $pm_arr[0]->getVar("subject")."<br /><form action='readpmsg.php' method='post' name='delete".$pm_arr[0]->getVar("msg_id")."'><table border='0' cellpadding='4' cellspacing='1' class='outer' width='100%'><tr><th colspan='2'>". _PM_FROM ."</th></tr><tr class='even'>\n";
61        $poster = new XoopsUser($pm_arr[0]->getVar("from_userid"));
62        if ( !$poster->isActive() ) {
63            $poster = false;
64        }
65        echo "<td valign='top'>";
66        if ( $poster != false ) { // we need to do this for deleted users
67                echo "<a href='userinfo.php?uid=".$poster->getVar("uid")."'>".$poster->getVar("uname")."</a><br />\n";
68            if ( $poster->getVar("user_avatar") != "" ) {
69                echo "<img src='uploads/".$poster->getVar("user_avatar")."' alt='' /><br />\n";
70            }
71            if ( $poster->getVar("user_from") != "" ) {
72                echo _PM_FROMC."".$poster->getVar("user_from")."<br /><br />\n";
73            }
74            if ( $poster->isOnline() ) {
75            echo "<span style='color:#ee0000;font-weight:bold;'>"._PM_ONLINE."</span><br /><br />\n";
76            }
77        } else {
78            echo $xoopsConfig['anonymous']; // we need to do this for deleted users
79        }
80        echo "</td><td><img src='images/subject/".$pm_arr[0]->getVar("msg_image", "E")."' alt='' />&nbsp;"._PM_SENTC."".formatTimestamp($pm_arr[0]->getVar("msg_time"));
81        echo "<hr /><b>".$pm_arr[0]->getVar("subject")."</b><br /><br />\n";
82        echo $pm_arr[0]->getVar("msg_text") . "<br /><br /></td></tr><tr class='foot'><td width='20%' colspan='2' align='left'>";
83        // we dont want to reply to a deleted user!
84        if ( $poster != false ) {
85            echo "<a href='#' onclick='javascript:openWithSelfMain(\"".XOOPS_URL."/pmlite.php?reply=1&amp;msg_id=".$pm_arr[0]->getVar("msg_id")."\",\"pmlite\",450,380);'><img src='".XOOPS_URL."/images/icons/reply.gif' alt='"._PM_REPLY."' /></a>\n";
86        }
87        echo "<input type='hidden' name='delete' value='1' />";
88        echo "<input type='hidden' name='msg_id' value='".$pm_arr[0]->getVar("msg_id")."' />";
89        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>";
90        echo "</td></tr><tr><td colspan='2' align='right'>";
91        $previous = $start - 1;
92            $next = $start + 1;
93            if ( $previous >= 0 ) {
94            echo "<a href='readpmsg.php?start=".$previous."&amp;total_messages=".$total_messages."'>"._PM_PREVIOUS."</a> | ";
95        } else {
96            echo _PM_PREVIOUS." | ";
97        }
98        if ( $next < $total_messages ) {
99            echo "<a href='readpmsg.php?start=".$next."&amp;total_messages=".$total_messages."'>"._PM_NEXT."</a>";
100        } else {
101            echo _PM_NEXT;
102        }
103        echo "</td></tr></table></form>\n";
104    }
105    include "footer.php";
106}
107?>
Note: See TracBrowser for help on using the repository browser.