messages
[ class tree: messages ] [ index: messages ] [ all elements ]

Source for file compose.php

Documentation is available at compose.php

  1. <?php
  2. /**
  3. * message package modules
  4. *
  5. @author
  6. @version  $Header: /cvsroot/bitweaver/_bit_messages/compose.php,v 1.11 2006/12/25 10:45:43 squareing Exp $
  7. @package  messages
  8. @subpackage functions
  9. */
  10.  
  11. // Copyright (c) 2002-2003, Luis Argerich, Garland Foster, Eduardo Polidor, et. al.
  12. // All Rights Reserved. See copyright.txt for details and a complete list of authors.
  13. // Licensed under the GNU LESSER GENERAL PUBLIC LICENSE. See license.txt for details.
  14.  
  15.  
  16.  
  17. /**
  18.  * required setup
  19.  */
  20. require_once'../bit_setup_inc.php' );
  21. require_onceMESSAGES_PKG_PATH.'Messages.php' );
  22.  
  23. if!$gBitUser->isRegistered() ) {
  24.     $gBitSmarty->assign('msg'tra("You are not logged in"));
  25.     $gBitSystem->display'error.tpl' );
  26.     die;
  27. }
  28.  
  29. $gBitSystem->isPackageActive'messages'TRUE );
  30. $gBitSystem->verifyPermission'p_messages_send' );
  31.  
  32. $messages new Messages();
  33.  
  34. // Configure quicktags list
  35. if$gBitSystem->isPackageActive'quicktags' ) ) {
  36.     include_onceQUICKTAGS_PKG_PATH.'quicktags_inc.php' );
  37. }
  38.  
  39. if (!isset($_REQUEST['to']))
  40.     $_REQUEST['to''';
  41.  
  42. if (!isset($_REQUEST['cc']))
  43.     $_REQUEST['cc''';
  44.  
  45. if (!isset($_REQUEST['bcc']))
  46.     $_REQUEST['bcc''';
  47.  
  48. if (!isset($_REQUEST['subject']))
  49.     $_REQUEST['subject''';
  50.  
  51. if (!isset($_REQUEST['body']))
  52.     $_REQUEST['body''';
  53.  
  54. if (!isset($_REQUEST['priority']))
  55.     $_REQUEST['priority'3;
  56.  
  57. if!empty$_REQUEST['action']['reply'|| !empty$_REQUEST['action']['replyall') ) {
  58.     $replyToUser $gBitUser->getUserInfoarray'user_id' => $_REQUEST['replyto') );
  59.     $_REQUEST['to'$replyToUser['login'];
  60.     if!empty$_REQUEST['action']['replyall') ) {
  61.         $_REQUEST['cc'preg_replace"/".$replyToUser['login'].",/"""$_REQUEST['replyallto');
  62.         $_REQUEST['cc'preg_replace"/".$gBitUser->mUsername.",/"""$_REQUEST['cc');
  63.     }
  64. }
  65.  
  66. // Strip Re:Re:Re: from subject
  67. if(isset($_REQUEST['action']['reply']|| isset($_REQUEST['action']['replyall'])) {
  68.     $_REQUEST['subject'tra("Re: ").preg_replace("/^(".tra("Re: ").")+/i"""$_REQUEST['subject']);
  69. }
  70.  
  71. $gBitSmarty->assign('to'$_REQUEST['to']);
  72. $gBitSmarty->assign('cc'$_REQUEST['cc']);
  73. $gBitSmarty->assign('bcc'$_REQUEST['bcc']);
  74. $gBitSmarty->assign('subject'$_REQUEST['subject']);
  75. $gBitSmarty->assign('body'$_REQUEST['body']);
  76. $gBitSmarty->assign('priority'$_REQUEST['priority']);
  77.  
  78. $gBitSmarty->assign('sent'0);
  79. $feedback array();
  80. $gBitSmarty->assign_by_ref'feedback'$feedback );
  81.  
  82. if (isset($_REQUEST['replyto']|| isset($_REQUEST['replyallto'])) {
  83.     $flagHash array(
  84.         'msg_id' => $_REQUEST['msg_id'],
  85.         'act'    => 'is_replied',
  86.         'actval' => 'y',
  87.     );
  88.     $messages->flagMessage$flagHash );
  89. }
  90.  
  91. if (isset($_REQUEST['send'])) {
  92.     $message '';
  93.     // Validation:
  94. // must have a subject or body non-empty (or both)
  95.     
  96.     if !empty($_REQUEST['subject']&& !empty($_REQUEST['body'])) {
  97.         // Parse the to, cc and bcc fields into an array
  98.         $arrTo explode','preg_replace'/ /'''$_REQUEST['to') );
  99.         $arrCc explode','preg_replace'/ /'''$_REQUEST['cc') );
  100.         $arrBcc explode','preg_replace'/ /'''$_REQUEST['bcc') );
  101.  
  102.         $toUsers array_uniquearray_merge$arrTo$arrCc$arrBcc ) );
  103.         // Validation: either to, cc or bcc must have a valid user
  104.         ifcount($toUsers) ) {
  105.             // Insert the message in the inboxes of each user
  106.             foreach ($toUsers as $toUser{
  107.                 if!empty$toUser ) ) {
  108.                     $_REQUEST['to_login'$toUser;
  109.                     if$messages->postMessage$_REQUEST ) ) {
  110.                         $feedback['success'][=  tra"Message will be sent to: " ).' '.$toUser;
  111.                     else {
  112.                         $feedback['error'][$messages->mErrors['compose'];
  113.                     }
  114.                 }
  115.             }
  116.             $gBitSmarty->assign('sent'1);
  117.         else {
  118.             $feedback['error'][tra('ERROR: No valid users to send the message.');
  119.         }
  120.     else {
  121.         $feedback['error'][tra'ERROR: Either the subject or body must contain text.' );
  122.     }
  123. }
  124.  
  125. $gBitSystem->display'bitpackage:messages/compose.tpl''Compose Message' );
  126. ?>

Documentation generated on Thu, 15 Feb 2007 20:35:16 +0000 by phpDocumentor 1.3.0