/** * Mark a message as read * * @param XoopsPrivmessage $pm {@link XoopsPrivmessage} object * @return bool **/ public function setRead(XoopsPrivmessage &$pm) { $qb = $this->db2->createXoopsQueryBuilder()->update($this->table, 'pm')->set('pm.read_msg', ':readmsg')->where('pm.msg_id = :msgid')->setParameter(':readmsg', 1, \PDO::PARAM_INT)->setParameter(':msgid', $pm->getVar('msg_id'), \PDO::PARAM_INT); $result = $qb->execute(); if (!$result) { return false; } return true; }
/** * Send a message to user's email * @param XoopsPrivmessage $pm {@link XoopsPrivmessage} object * @param XoopsUser $user * @return bool **/ public function sendEmail(XoopsPrivmessage $pm, XoopsUser $user) { global $xoopsConfig; if (!is_object($user)) { $user =& $GLOBALS['xoopsUser']; } $msg = sprintf(_PM_EMAIL_DESC, $user->getVar('uname')); $msg .= "\n\n"; $msg .= formatTimestamp($pm->getVar('msg_time')); $msg .= "\n"; $from = new XoopsUser($pm->getVar('from_userid')); $to = new XoopsUser($pm->getVar('to_userid')); $msg .= sprintf(_PM_EMAIL_FROM, $from->getVar('uname') . ' (' . XOOPS_URL . '/userinfo.php?uid=' . $pm->getVar('from_userid') . ')'); $msg .= "\n"; $msg .= sprintf(_PM_EMAIL_TO, $to->getVar('uname') . ' (' . XOOPS_URL . '/userinfo.php?uid=' . $pm->getVar('to_userid') . ')'); $msg .= "\n"; $msg .= _PM_EMAIL_MESSAGE . ":\n"; $msg .= "\n" . $pm->getVar('subject') . "\n"; $msg .= "\n" . strip_tags(str_replace(array('<p>', '</p>', '<br>', '<br>'), "\n", $pm->getVar('msg_text'))) . "\n\n"; $msg .= "--------------\n"; $msg .= $xoopsConfig['sitename'] . ': ' . XOOPS_URL . "\n"; $xoopsMailer =& xoops_getMailer(); $xoopsMailer->useMail(); $xoopsMailer->setToEmails($user->getVar('email')); $xoopsMailer->setFromEmail($xoopsConfig['adminmail']); $xoopsMailer->setFromName($xoopsConfig['sitename']); $xoopsMailer->setSubject(sprintf(_PM_EMAIL_SUBJECT, $pm->getVar('subject'))); $xoopsMailer->setBody($msg); return $xoopsMailer->send(); }