$message = ''; // Validation: // must have a subject or body non-empty (or both) if (!empty($_REQUEST['subject']) && !empty($_REQUEST['body'])) { // Parse the to, cc and bcc fields into an array $arrTo = explode(',', preg_replace('/ /', '', $_REQUEST['to'])); $arrCc = explode(',', preg_replace('/ /', '', $_REQUEST['cc'])); $arrBcc = explode(',', preg_replace('/ /', '', $_REQUEST['bcc'])); $toUsers = array_unique(array_merge($arrTo, $arrCc, $arrBcc)); // Validation: either to, cc or bcc must have a valid user if (count($toUsers)) { // Insert the message in the inboxes of each user foreach ($toUsers as $toUser) { if (!empty($toUser)) { $_REQUEST['to_login'] = $toUser; if ($messages->postMessage($_REQUEST)) { $feedback['success'][] = tra("Message will be sent to: ") . ' ' . $toUser; } else { $feedback['error'][] = $messages->mErrors['compose']; } } } $gBitSmarty->assign('sent', 1); } else { $feedback['error'][] = tra('ERROR: No valid users to send the message.'); } } else { $feedback['error'][] = tra('ERROR: Either the subject or body must contain text.'); } } $gBitSystem->display('bitpackage:messages/compose.tpl', 'Compose Message', array('display_mode' => 'display'));
function postMessage() { $newMessage = new Messages(); echo $newMessage->postMessage(); }
<?php /** * message package modules * * @author * @version $Header$ * @package messages * @subpackage functions */ // Copyright (c) 2002-2003, Luis Argerich, Garland Foster, Eduardo Polidor, et. al. // All Rights Reserved. See below for details and a complete list of authors. // Licensed under the GNU LESSER GENERAL PUBLIC LICENSE. See http://www.gnu.org/copyleft/lesser.html for details. /** * required setup */ require_once '../kernel/setup_inc.php'; require_once MESSAGES_PKG_PATH . 'Messages.php'; $gBitSystem->verifyFeature('messages_site_contact'); $messages = new Messages(); if (!empty($_REQUEST['send'])) { if (empty($_REQUEST['subject']) && empty($_REQUEST['body'])) { $gBitSystem->fatalError(tra("Either a subject or a message body is required.")); } $postHash = $_REQUEST; $postHash['to_login'] = $postHash['msg_to'] = $gBitSystem->getConfig('messages_contact_user'); $messages->postMessage($postHash); $feedback['success'] = tra('Your message was sent to') . ': ' . $gBitSystem->getConfig('messages_contact_user'); $gBitSmarty->assign('feedback', $feedback); } $gBitSystem->display('bitpackage:messages/contact.tpl', NULL, array('display_mode' => 'display'));
function modWarn($message) { global $gBitSystem, $gBitUser; if (empty($message)) { $gBitSystem->fatalError("No Warning Message Given. <br />A post cannot be warned without a message"); } $data['is_warned'] = 1; $data['warned_message'] = $message; $this->setMetaData($data); if ($gBitSystem->isPackageActive('messages')) { require_once MESSAGES_PKG_PATH . 'Messages.php'; $u = new BitUser($this->mInfo['user_id']); $u->load(); $userInfo = $u->mInfo; $pm = new Messages(); $message = "Your post \"" . $this->mInfo['title'] . "\" [http://" . $_SERVER['HTTP_HOST'] . $this->getContactUrl() . "] has been warned with the following message:\n{$message}\n"; $msgHash = array('to_login' => $userInfo['login'], 'to' => $userInfo['real_name'], 'subject' => tra('Warned Post') . ': ' . $this->mInfo['title'], 'priority' => 4); $pm->postMessage($msgHash); } }