[ Index ]
 

Code source de eGroupWare 1.2.106-2

Accédez au Source d'autres logiciels libresSoutenez Angelica Josefina !

title

Body

[fermer]

/felamimail/inc/ -> class.uicompose.inc.php (source)

   1  <?php
   2      /***************************************************************************\
   3      * eGroupWare - FeLaMiMail                                                   *
   4      * http://www.linux-at-work.de                                               *
   5      * http://www.phpgw.de                                                       *
   6      * http://www.egroupware.org                                                 *
   7      * Written by : Lars Kneschke [lkneschke@linux-at-work.de]                   *
   8      * -------------------------------------------------                         *
   9      * This program is free software; you can redistribute it and/or modify it   *
  10      * under the terms of the GNU General Public License as published by the     *
  11      * Free Software Foundation; either version 2 of the License, or (at your    *
  12      * option) any later version.                                                *
  13      \***************************************************************************/
  14      /* $Id: class.uicompose.inc.php 20043 2005-11-28 18:24:40Z lkneschke $ */
  15  
  16      class uicompose
  17      {
  18  
  19          var $public_functions = array
  20          (
  21              'compose'    => 'True',
  22              'reply'        => 'True',
  23              'replyAll'    => 'True',
  24              'forward'    => 'True',
  25              'action'    => 'True'
  26          );
  27  
  28  		function uicompose()
  29          {
  30              $this->displayCharset   = $GLOBALS['egw']->translation->charset();
  31              if (!isset($_POST['composeid']) && !isset($_GET['composeid']))
  32              {
  33                  // create new compose session
  34                  $this->bocompose   =& CreateObject('felamimail.bocompose','',$this->displayCharset);
  35                  $this->composeID = $this->bocompose->getComposeID();
  36              }
  37              else
  38              {
  39                  // reuse existing compose session
  40                  if (isset($_POST['composeid']))
  41                      $this->composeID = $_POST['composeid'];
  42                  else
  43                      $this->composeID = $_GET['composeid'];
  44                  $this->bocompose   =& CreateObject('felamimail.bocompose',$this->composeID,$this->displayCharset);
  45              }            
  46              $this->t         =& CreateObject('phpgwapi.Template',EGW_APP_TPL);
  47              $this->bofelamimail    =& CreateObject('felamimail.bofelamimail',$this->displayCharset);
  48              $this->mailPreferences  = ExecMethod('felamimail.bopreferences.getPreferences');
  49  
  50              $this->t->set_unknowns('remove');
  51              
  52              $this->rowColor[0] = $GLOBALS['egw_info']["theme"]["bg01"];
  53              $this->rowColor[1] = $GLOBALS['egw_info']["theme"]["bg02"];
  54  
  55  
  56          }
  57          
  58  		function unhtmlentities ($string)
  59          {
  60              $trans_tbl = get_html_translation_table (HTML_ENTITIES);
  61              $trans_tbl = array_flip ($trans_tbl);
  62              return strtr ($string, $trans_tbl);
  63          }
  64  
  65  		function action()
  66          {
  67              $formData['to']     = $this->bocompose->stripSlashes($_POST['to']);
  68              $formData['cc']     = $this->bocompose->stripSlashes($_POST['cc']);
  69              $formData['bcc']     = $this->bocompose->stripSlashes($_POST['bcc']);
  70              $formData['reply_to']     = $this->bocompose->stripSlashes($_POST['reply_to']);
  71              $formData['subject']     = $this->bocompose->stripSlashes($_POST['subject']);
  72              $formData['body']     = $this->bocompose->stripSlashes($_POST['body']);
  73              $formData['priority']     = $this->bocompose->stripSlashes($_POST['priority']);
  74              $formData['signature']     = $this->bocompose->stripSlashes($_POST['signature']);
  75              $formData['mailbox']    = $_GET['mailbox'];
  76  
  77              if (isset($_POST['send'])) 
  78              {
  79                  $action="send";
  80              }
  81              elseif (isset($_POST['addfile'])) 
  82              {
  83                  $action="addfile";
  84              }
  85              elseif (isset($_POST['removefile']))
  86              {
  87                  $action="removefile";
  88              }
  89              
  90              switch ($action)
  91              {
  92                  case "addfile":
  93                      $formData['name']    = $_FILES['attachfile']['name'];
  94                      $formData['type']    = $_FILES['attachfile']['type'];
  95                      $formData['file']    = $_FILES['attachfile']['tmp_name'];
  96                      $formData['size']    = $_FILES['attachfile']['size'];
  97                      $this->bocompose->addAttachment($formData);
  98                      $this->compose();
  99                      break;
 100  
 101                  case "removefile":
 102                      $formData['removeAttachments']    = $_POST['attachment'];
 103                      $this->bocompose->removeAttachment($formData);
 104                      $this->compose();
 105                      break;
 106                      
 107                  case "send":
 108                      if(!$this->bocompose->send($formData))
 109                      {
 110                          $this->compose();
 111                          return;
 112                      }
 113                      
 114                      #$linkData = array
 115                      #(
 116                      #    'mailbox'    => $_GET['mailbox'],
 117                      #    'startMessage'    => '1'
 118                      #);
 119                      #$link = $GLOBALS['egw']->link('/felamimail/index.php',$linkData);
 120                      #$GLOBALS['egw']->redirect($link);
 121                      #$GLOBALS['egw']->common->egw_exit();
 122                      print "<script type=\"text/javascript\">window.close();</script>";
 123                      break;
 124              }
 125          }
 126  
 127  		function compose($_focusElement="to")
 128          {
 129              // read the data from session
 130              // all values are empty for a new compose window
 131              $sessionData = $this->bocompose->getSessionData();
 132              if (is_array($_GET['preset']))
 133              {
 134                  $this->bocompose->addAttachment(array_merge($sessionData,$_GET['preset']));
 135                  $sessionData = $this->bocompose->getSessionData();
 136              }
 137              $preferences = ExecMethod('felamimail.bopreferences.getPreferences');
 138              #_debug_array($preferences);
 139              
 140              // is the to address set already?
 141              if (!empty($_GET['send_to']))
 142              {
 143                  $sessionData['to'] = base64_decode($_GET['send_to']);
 144              }
 145              $this->display_app_header();
 146              
 147              $this->t->set_file(array("composeForm" => "composeForm.tpl"));
 148              $this->t->set_block('composeForm','header','header');
 149              $this->t->set_block('composeForm','body_input');
 150              $this->t->set_block('composeForm','attachment','attachment');
 151              $this->t->set_block('composeForm','attachment_row','attachment_row');
 152              $this->t->set_block('composeForm','attachment_row_bold');
 153              
 154              $this->translate();
 155              
 156              $this->t->set_var("link_addressbook",$GLOBALS['egw']->link('/felamimail/addressbook.php'));
 157              $this->t->set_var("focusElement",$_focusElement);
 158  
 159              $linkData = array
 160              (
 161                  'menuaction'    => 'felamimail.uifelamimail.viewMainScreen'
 162              );
 163  
 164              $linkData = array
 165              (
 166                  'menuaction'    => 'felamimail.uicompose.action',
 167                  'composeid'    => $this->composeID
 168              );
 169              $this->t->set_var("link_action",$GLOBALS['egw']->link('/index.php',$linkData));
 170              $this->t->set_var('folder_name',$this->bofelamimail->sessionData['mailbox']);
 171  
 172              // check for some error messages from last posting attempt
 173              if($errorInfo = $this->bocompose->getErrorInfo())
 174              {
 175                  $this->t->set_var('errorInfo',"<font color=\"red\"><b>$errorInfo</b></font>");
 176              }
 177              else
 178              {
 179                  $this->t->set_var('errorInfo','&nbsp;');
 180              }
 181              
 182              // header
 183              $displayFrom = @htmlentities($preferences['emailAddress'][0][name].' <'.$preferences['emailAddress'][0][address].'>',ENT_QUOTES,$this->displayCharset);
 184              $this->t->set_var("from",$displayFrom);
 185              $this->t->set_var("to",@htmlentities($sessionData['to'],ENT_QUOTES,$this->displayCharset));
 186              $this->t->set_var("cc",@htmlentities($sessionData['cc'],ENT_QUOTES,$this->displayCharset));
 187              $this->t->set_var("bcc",@htmlentities($sessionData['bcc'],ENT_QUOTES,$this->displayCharset));
 188              $this->t->set_var("reply_to",@htmlentities($sessionData['reply_to'],ENT_QUOTES,$this->displayCharset));
 189              $this->t->set_var("subject",@htmlentities($sessionData['subject'],ENT_QUOTES,$this->displayCharset));
 190              $this->t->set_var('addressbookImage',$GLOBALS['egw']->common->image('phpgwapi/templates/phpgw_website','users'));
 191              $this->t->pparse("out","header");
 192  
 193              // body
 194              $this->t->set_var("body",$sessionData['body']);
 195              $this->t->set_var("signature",$sessionData['signature']);
 196              $this->t->pparse("out","body_input");
 197  
 198              // attachments
 199              if (is_array($sessionData['attachments']) && count($sessionData['attachments']) > 0)
 200              {
 201                  $this->t->set_var('row_color',$this->rowColor[0]);
 202                  $this->t->set_var('name',lang('name'));
 203                  $this->t->set_var('type',lang('type'));
 204                  $this->t->set_var('size',lang('size'));
 205                  $this->t->parse('attachment_rows','attachment_row_bold',True);
 206                  while (list($key,$value) = each($sessionData['attachments']))
 207                  {
 208                      #print "$key : $value<br>";
 209                      $this->t->set_var('row_color',$this->rowColor[($key+1)%2]);
 210                      $this->t->set_var('name',$value['name']);
 211                      $this->t->set_var('type',$value['type']);
 212                      $this->t->set_var('size',$value['size']);
 213                      $this->t->set_var('attachment_number',$key);
 214                      $this->t->parse('attachment_rows','attachment_row',True);
 215                  }
 216              }
 217              else
 218              {
 219                  $this->t->set_var('attachment_rows','');
 220              }
 221              
 222              $this->t->pparse("out","attachment");
 223          }
 224  
 225  		function display_app_header()
 226          {
 227              $GLOBALS['egw']->common->egw_header();
 228          }
 229          
 230  		function forward()
 231          {
 232              $replyID = $_GET['reply_id'];
 233              $partID  = $_GET['part_id'];
 234  
 235              if (!empty($replyID))
 236              {
 237                  // this fill the session data with the values from the original email
 238                  $this->bocompose->getForwardData($replyID, $partID, 
 239                      $this->bofelamimail->sessionData['mailbox']);
 240              }
 241              $this->compose();
 242          }
 243  
 244  		function reply()
 245          {
 246              $replyID = $_GET['reply_id'];
 247              $partID     = $_GET['part_id'];
 248              if (!empty($replyID))
 249              {
 250                  // this fill the session data with the values from the original email
 251                  $this->bocompose->getReplyData('single', $replyID, $partID);
 252              }
 253              $this->compose(@htmlentities('body'));
 254          }
 255          
 256  		function replyAll()
 257          {
 258              $replyID = $_GET['reply_id'];
 259              $partID     = $_GET['part_id'];
 260              if (!empty($replyID))
 261              {
 262                  // this fill the session data with the values from the original email
 263                  $this->bocompose->getReplyData('all', $replyID, $partID);
 264              }
 265              $this->compose('body');
 266          }
 267          
 268  		function translate()
 269          {
 270              $this->t->set_var("lang_message_list",lang('Message List'));
 271              $this->t->set_var("lang_to",lang('to'));
 272              $this->t->set_var("lang_cc",lang('cc'));
 273              $this->t->set_var("lang_bcc",lang('bcc'));
 274              $this->t->set_var("lang_from",lang('from'));
 275              $this->t->set_var("lang_reply_to",lang('reply to'));
 276              $this->t->set_var("lang_subject",lang('subject'));
 277              $this->t->set_var("lang_addressbook",lang('addressbook'));
 278              $this->t->set_var("lang_search",lang('search'));
 279              $this->t->set_var("lang_send",lang('send'));
 280              $this->t->set_var("lang_back_to_folder",lang('back to folder'));
 281              $this->t->set_var("lang_attachments",lang('attachments'));
 282              $this->t->set_var("lang_add",lang('add'));
 283              $this->t->set_var("lang_remove",lang('remove'));
 284              $this->t->set_var("lang_priority",lang('priority'));
 285              $this->t->set_var("lang_normal",lang('normal'));
 286              $this->t->set_var("lang_high",lang('high'));
 287              $this->t->set_var("lang_low",lang('low'));
 288              $this->t->set_var("lang_signature",lang('signature'));
 289              
 290              $this->t->set_var("th_bg",$GLOBALS['egw_info']["theme"]["th_bg"]);
 291              $this->t->set_var("bg01",$GLOBALS['egw_info']["theme"]["bg01"]);
 292              $this->t->set_var("bg02",$GLOBALS['egw_info']["theme"]["bg02"]);
 293              $this->t->set_var("bg03",$GLOBALS['egw_info']["theme"]["bg03"]);
 294          }
 295  }
 296  
 297  ?>


Généré le : Sun Feb 25 17:20:01 2007 par Balluche grâce à PHPXref 0.7