XOOPS 2.5.6  Final
 All Classes Namespaces Files Functions Variables Pages
pmlite.php
Go to the documentation of this file.
1 <?php
21 if (!defined('XOOPS_MAINFILE_INCLUDED')) {
22  include_once dirname(dirname(dirname(__FILE__))) . DIRECTORY_SEPARATOR . 'mainfile.php';
23 } else {
24  chdir(XOOPS_ROOT_PATH . '/modules/pm/');
25  xoops_loadLanguage('main', 'pm');
26 }
27 
28 $reply = !empty($_GET['reply']) ? 1 : 0;
29 $send = !empty($_GET['send']) ? 1 : 0;
30 $send2 = !empty($_GET['send2']) ? 1 : 0;
31 $sendmod = !empty($_POST['sendmod']) ? 1 : 0; // send from other modules with post data
32 $to_userid = isset($_GET['to_userid']) ? intval($_GET['to_userid']) : 0;
33 $msg_id = isset($_GET['msg_id']) ? intval($_GET['msg_id']) : 0;
34 
35 if (empty($_GET['refresh']) && isset($_POST['op']) && $_POST['op'] != "submit") {
36  $jump = "pmlite.php?refresh=" . time();
37  if ($send == 1) {
38  $jump .= "&amp;send={$send}";
39  } else if ($send2 == 1) {
40  $jump .= "&amp;send2={$send2}&amp;to_userid={$to_userid}";
41  } else if ($reply == 1) {
42  $jump .= "&amp;reply={$reply}&amp;msg_id={$msg_id}";
43  } else {
44  }
45  header('location: ' . $jump);
46  exit();
47 }
48 
49 if (!is_object($GLOBALS['xoopsUser'])) {
50  redirect_header(XOOPS_URL, 3, _NOPERM);
51  exit();
52 }
53 xoops_header();
54 
56 if (isset($_POST['op']) && $_POST['op'] == "submit") {
57  $member_handler =& xoops_gethandler('member');
58  $count = $member_handler->getUserCount(new Criteria('uid', intval($_POST['to_userid'])));
59  if ($count != 1) {
60  echo "<br /><br /><div><h4>"._PM_USERNOEXIST."<br />";
61  echo _PM_PLZTRYAGAIN."</h4><br />";
62  echo "[ <a href='javascript:history.go(-1)'>"._PM_GOBACK."</a> ]</div>";
63  } else if ($GLOBALS['xoopsSecurity']->check()) {
64  $pm_handler =& xoops_getModuleHandler('message', 'pm');
65  $pm =& $pm_handler->create();
66  $pm->setVar("msg_time", time());
67 //------------------ mamba
68 if (isset($_POST['icon'])) {
69  $pm->setVar("msg_image", $_POST['icon']);
70  }
71  //else $pm->setVar("msg_image", 'icon1.gif');
72 //----------------- mamba
73  $pm->setVar("subject", $_POST['subject']);
74  $pm->setVar("msg_text", $_POST['message']);
75  $pm->setVar("to_userid", $_POST['to_userid']);
76  $pm->setVar("from_userid", $GLOBALS['xoopsUser']->getVar("uid"));
77  if (isset($_REQUEST['savecopy']) && $_REQUEST['savecopy'] == 1) {
78  //PMs are by default not saved in outbox
79  $pm->setVar('from_delete', 0);
80  }
81  if (!$pm_handler->insert($pm)) {
82  echo $pm->getHtmlErrors();
83  echo "<br /><a href='javascript:history.go(-1)'>"._PM_GOBACK."</a>";
84  } else {
85  // @todo: Send notification email if user has selected this in the profile
86 
87  echo "<br /><br /><div style='text-align:center;'><h4>" . _PM_MESSAGEPOSTED . "</h4><br /><a href=\"javascript:window.opener.location='".XOOPS_URL."/viewpmsg.php';window.close();\">"._PM_CLICKHERE."</a><br /><br /><a href=\"javascript:window.close();\">"._PM_ORCLOSEWINDOW."</a></div>";
88  }
89  } else {
90  echo implode('<br />', $GLOBALS['xoopsSecurity']->getErrors());
91  echo "<br /><a href=\"javascript:window.close();\">"._PM_ORCLOSEWINDOW."</a>";
92  }
93 
94 } else if ($reply == 1 || $send == 1 || $send2 == 1 || $sendmod == 1) {
95  if ($reply == 1) {
96  $pm_handler =& xoops_getModuleHandler('message', 'pm');
97  $pm =& $pm_handler->get($msg_id);
98  if ($pm->getVar("to_userid") == $GLOBALS['xoopsUser']->getVar('uid')) {
99  $pm_uname = XoopsUser::getUnameFromId($pm->getVar("from_userid"));
100  $message = "[quote]\n";
101  $message .= sprintf(_PM_USERWROTE , $pm_uname);
102  $message .= "\n" . $pm->getVar("msg_text", "E") . "\n[/quote]";
103  } else {
104  unset($pm);
105  $reply = $send2 = 0;
106  }
107  }
108 
109  include_once $GLOBALS['xoops']->path('class/template.php');
110  $GLOBALS['xoopsTpl'] = new XoopsTpl();
111  include_once $GLOBALS['xoops']->path('class/xoopsformloader.php');
112  $pmform = new XoopsForm('', 'pmform', 'pmlite.php', 'post', true);
113 
114  if ($reply == 1) {
115  $subject = $pm->getVar('subject', 'E');
116  if (!preg_match("/^" . _RE . "/i", $subject)) {
117  $subject = _RE . ' ' . $subject;
118  }
119  $GLOBALS['xoopsTpl']->assign('to_username', $pm_uname);
120  $pmform->addElement(new XoopsFormHidden('to_userid', $pm->getVar("from_userid")));
121  } else if ($sendmod == 1) {
122  $GLOBALS['xoopsTpl']->assign('to_username', XoopsUser::getUnameFromId($_POST["to_userid"]));
123  $pmform->addElement(new XoopsFormHidden('to_userid', intval($_POST["to_userid"])));
124  $subject = $myts->htmlSpecialChars($myts->stripSlashesGPC($_POST['subject']));
125  $message = $myts->htmlSpecialChars($myts->stripSlashesGPC($_POST['message']));
126  } else {
127  if ($send2 == 1) {
128  $GLOBALS['xoopsTpl']->assign('to_username', XoopsUser::getUnameFromId($to_userid, false));
129  $pmform->addElement(new XoopsFormHidden('to_userid', $to_userid));
130  } else {
131  $to_username = new XoopsFormSelectUser('', 'to_userid');
132  $GLOBALS['xoopsTpl']->assign('to_username', $to_username->render());
133  }
134  $subject = "";
135  $message = "";
136  }
137  $pmform->addElement(new XoopsFormText('', 'subject', 30, 100, $subject), true);
138 
139 //----------------------------- mamba
140  $msg_image='';
141  $icons_radio = new XoopsFormRadio(_MESSAGEICON, 'msg_image', $msg_image);
142  $subject_icons = XoopsLists::getSubjectsList();
143  // foreach ($subject_icons as $iconfile) {
144  // $icons_radio->addOption($iconfile, '<img src="' . XOOPS_URL . '/images/subject/' . $iconfile . '" alt="" />');
145  // }
146  // $pmform->addElement($icons_radio, true);
147 
148  $xoopsTpl->assign('radio_icons', $subject_icons);
149 //------------------------------- mamba
150 
151 
152  $pmform->addElement(new XoopsFormDhtmlTextArea('', 'message', $message, 8, 37), true);
153  $pmform->addElement(new XoopsFormRadioYN('', 'savecopy', 0));
154 
155  $pmform->addElement(new XoopsFormHidden('op', 'submit'));
156  $pmform->addElement(new XoopsFormButton('', 'submit', _SUBMIT, 'submit'));
157  $pmform->addElement(new XoopsFormButton('', 'reset', _PM_CLEAR, 'reset'));
158 
159  $cancel_send = new XoopsFormButton('', 'cancel', _PM_CANCELSEND, 'button');
160  $cancel_send->setExtra("onclick='javascript:window.close();'");
161  $pmform->addElement($cancel_send);
162  $pmform->assign($GLOBALS['xoopsTpl']);
163  $GLOBALS['xoopsTpl']->display("db:pm_pmlite.html");
164 }
165 xoops_footer();
166 ?>