Exemple #1
0
 /**
  * Send a message to user's email
  *
  * @param XoopsObject|PmMessage $pm
  * @param null|XoopsUser $user
  * @return bool
  */
 public function sendEmail(PmMessage $pm, XoopsUser $user = null)
 {
     $xoops = Xoops::getInstance();
     if (!is_object($user)) {
         $user = $xoops->user;
     }
     $msg = sprintf(_PM_EMAIL_DESC, $user->getVar("uname"));
     $msg .= "\n\n";
     $msg .= XoopsLocale::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") . " (" . \XoopsBaseConfig::get('url') . "/userinfo.php?uid=" . $pm->getVar("from_userid") . ")");
     $msg .= "\n";
     $msg .= sprintf(_PM_EMAIL_TO, $to->getVar("uname") . " (" . \XoopsBaseConfig::get('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 .= $xoops->getConfig('sitename') . ": " . \XoopsBaseConfig::get('url') . "\n";
     $xoopsMailer = $xoops->getMailer();
     $xoopsMailer->useMail();
     $xoopsMailer->setToEmails($user->getVar("email"));
     $xoopsMailer->setFromEmail($xoops->getConfig('adminmail'));
     $xoopsMailer->setFromName($xoops->getConfig('sitename'));
     $xoopsMailer->setSubject(sprintf(_PM_EMAIL_SUBJECT, $pm->getVar("subject")));
     $xoopsMailer->setBody($msg);
     return $xoopsMailer->send();
 }
Exemple #2
0
 /**
  * Mark a message as to_save = 1
  * @param  PmMessage $pm {@link PmMessage} object
  * @param  int    $val
  * @return bool
  */
 public function setTosave(PmMessage $pm, $val = 1)
 {
     return $this->updateAll('to_save', (int) $val, new Criteria('msg_id', $pm->getVar('msg_id')));
 }