XOOPS  2.6.0
viewpmsg.php
Go to the documentation of this file.
1 <?php
2 /*
3  You may not change or alter any portion of this comment or credits
4  of supporting developers from this source code or any supporting source code
5  which is considered copyrighted (c) material of the original comment or credit authors.
6 
7  This program is distributed in the hope that it will be useful,
8  but WITHOUT ANY WARRANTY; without even the implied warranty of
9  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
10 */
11 
22 include __DIR__ . DIRECTORY_SEPARATOR . 'mainfile.php';
23 
25 $xoops->preload()->triggerEvent('core.viewpmsg.start');
26 
27 if (!$xoops->isUser()) {
28  $errormessage = XoopsLocale::E_YOU_ARE_NOT_REGISTERED . "<br />"
30  $xoops->redirect("user.php", 2, $errormessage);
31 } else {
32  $pm_handler = $xoops->getHandlerPrivmessage();
33  if (isset($_POST['delete_messages']) && (isset($_POST['msg_id']) || isset($_POST['msg_ids']))) {
34  if (!$xoops->security()->check()) {
35  echo implode('<br />', $xoops->security()->getErrors());
36  exit();
37  } else {
38  if (empty($_REQUEST['ok'])) {
39  $xoops->header('module:system/system_viewpmsg.tpl');
40  // Define Stylesheet
41  $xoops->theme()->addStylesheet('modules/system/css/admin.css');
42  echo $xoops->confirm(array(
43  'ok' => 1, 'delete_messages' => 1,
44  'msg_ids' => json_encode(array_map("intval", $_POST['msg_id']))
46  $xoops->footer();
47  }
48  }
49 
50  $clean_msg_id = json_decode($_POST['msg_ids'], true, 2);
51  if (!empty($clean_msg_id)) {
52  $clean_msg_id = array_map("intval", $clean_msg_id);
53  }
54  $size = count($clean_msg_id);
55  $msg =& $clean_msg_id;
56  for ($i = 0; $i < $size; ++$i) {
57  $pm = $pm_handler->get(intval($msg[$i]));
58  if ($pm->getVar('to_userid') == $xoops->user->getVar('uid')) {
59  $pm_handler->delete($pm);
60  }
61  unset($pm);
62  }
63  $xoops->redirect("viewpmsg.php", 1, XoopsLocale::S_YOUR_MESSAGES_DELETED);
64  }
65  $xoops->header('module:system/system_viewpmsg.tpl');
66  $criteria = new Criteria('to_userid', $xoops->user->getVar('uid'));
67  $criteria->setSort('msg_time');
68  $criteria->setOrder('DESC');
69  $pm_arr = $pm_handler->getObjects($criteria);
71  $xoops->tpl()->assign('display', true);
72  $xoops->tpl()->assign('anonymous', $xoops->getConfig('anonymous'));
73  $xoops->tpl()->assign('uid', $xoops->user->getVar("uid"));
74  $xoops->tpl()->assign('total_messages', $total_messages);
75  $msg_no = 0;
76  foreach (array_keys($pm_arr) as $i) {
77  $messages['msg_id'] = $pm_arr[$i]->getVar("msg_id");
78  $messages['read_msg'] = $pm_arr[$i]->getVar("read_msg");
79  $messages['msg_image'] = $pm_arr[$i]->getVar("msg_image");
80  $messages['posteruid'] = $pm_arr[$i]->getVar('from_userid');
81  $messages['postername'] = XoopsUser::getUnameFromId($pm_arr[$i]->getVar('from_userid'));
82  $messages['subject'] = $pm_arr[$i]->getVar("subject");
83  $messages['msg_time'] = XoopsLocale::formatTimestamp($pm_arr[$i]->getVar('msg_time'));
84  $messages['msg_no'] = $msg_no;
85  $xoops->tpl()->append('messages', $messages);
86  ++$msg_no;
87  }
88  $xoops->tpl()->assign('token', $xoops->security()->getTokenHTML());
89  $xoops->footer();
90 }
$pm_arr
Definition: viewpmsg.php:69
static formatTimestamp($time, $format= 'l', $timeoffset=null)
Definition: Abstract.php:289
$i
Definition: dialog.php:68
static getInstance()
Definition: Xoops.php:160
const S_YOUR_MESSAGES_DELETED
Definition: en_US.php:1036
$_SERVER['REQUEST_URI']
exit
Definition: browse.php:104
defined('DS') or define('DS' DIRECTORY_SEPARATOR
Definition: common.php:41
$criteria
Definition: viewpmsg.php:66
$total_messages
Definition: viewpmsg.php:70
$msg_no
Definition: viewpmsg.php:75
static getUnameFromId($userid, $usereal=0)
Definition: user.php:124
const E_REGISTER_FIRST_TO_SEND_PRIVATE_MESSAGES
Definition: en_US.php:360
const Q_ARE_YOU_SURE_YOU_WANT_TO_DELETE_THIS_MESSAGES
Definition: en_US.php:930
$xoops
Definition: viewpmsg.php:24
const E_YOU_ARE_NOT_REGISTERED
Definition: en_US.php:381
if(!is_object($module)||!$module->getVar('isactive')) $msg
Definition: groupperm.php:38
$pm_handler
Definition: readpmsg.php:37