Source for file compose.php
Documentation is available at compose.php
* message package modules
* @version $Header: /cvsroot/bitweaver/_bit_messages/compose.php,v 1.11 2006/12/25 10:45:43 squareing Exp $
// Copyright (c) 2002-2003, Luis Argerich, Garland Foster, Eduardo Polidor, et. al.
// All Rights Reserved. See copyright.txt for details and a complete list of authors.
// Licensed under the GNU LESSER GENERAL PUBLIC LICENSE. See license.txt for details.
require_once( '../bit_setup_inc.php' );
require_once( MESSAGES_PKG_PATH. 'Messages.php' );
if( !$gBitUser->isRegistered() ) {
$gBitSmarty->assign('msg', tra("You are not logged in"));
$gBitSystem->display( 'error.tpl' );
$gBitSystem->isPackageActive( 'messages', TRUE );
$gBitSystem->verifyPermission( 'p_messages_send' );
// Configure quicktags list
if( $gBitSystem->isPackageActive( 'quicktags' ) ) {
include_once( QUICKTAGS_PKG_PATH. 'quicktags_inc.php' );
if (!isset ($_REQUEST['to']))
if (!isset ($_REQUEST['cc']))
if (!isset ($_REQUEST['bcc']))
if (!isset ($_REQUEST['subject']))
$_REQUEST['subject'] = '';
if (!isset ($_REQUEST['body']))
if (!isset ($_REQUEST['priority']))
$_REQUEST['priority'] = 3;
if( !empty( $_REQUEST['action']['reply'] ) || !empty( $_REQUEST['action']['replyall'] ) ) {
$replyToUser = $gBitUser->getUserInfo( array( 'user_id' => $_REQUEST['replyto'] ) );
$_REQUEST['to'] = $replyToUser['login'];
if( !empty( $_REQUEST['action']['replyall'] ) ) {
$_REQUEST['cc'] = preg_replace( "/". $replyToUser['login']. ",/", "", $_REQUEST['replyallto'] );
$_REQUEST['cc'] = preg_replace( "/". $gBitUser->mUsername. ",/", "", $_REQUEST['cc'] );
// Strip Re:Re:Re: from subject
if(isset ($_REQUEST['action']['reply']) || isset ($_REQUEST['action']['replyall'])) {
$_REQUEST['subject'] = tra("Re: "). preg_replace("/^(". tra("Re: "). ")+/i", "", $_REQUEST['subject']);
$gBitSmarty->assign('to', $_REQUEST['to']);
$gBitSmarty->assign('cc', $_REQUEST['cc']);
$gBitSmarty->assign('bcc', $_REQUEST['bcc']);
$gBitSmarty->assign('subject', $_REQUEST['subject']);
$gBitSmarty->assign('body', $_REQUEST['body']);
$gBitSmarty->assign('priority', $_REQUEST['priority']);
$gBitSmarty->assign('sent', 0);
$gBitSmarty->assign_by_ref( 'feedback', $feedback );
if (isset ($_REQUEST['replyto']) || isset ($_REQUEST['replyallto'])) {
'msg_id' => $_REQUEST['msg_id'],
$messages->flagMessage( $flagHash );
if (isset ($_REQUEST['send'])) {
// 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
// Validation: either to, cc or bcc must have a valid user
// 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;
$feedback['error'][] = $messages->mErrors['compose'];
$gBitSmarty->assign('sent', 1);
$feedback['error'][] = tra('ERROR: No valid users to send the message.');
$feedback['error'][] = tra( 'ERROR: Either the subject or body must contain text.' );
$gBitSystem->display( 'bitpackage:messages/compose.tpl', 'Compose Message' );
|