[75] | 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 | |
---|
| 15 | /** |
---|
| 16 | * copyright notice for the functions highlightQuotes and _countQuoteChars |
---|
| 17 | * |
---|
| 18 | * The Text:: class provides common methods for manipulating text. |
---|
| 19 | * |
---|
| 20 | * $Horde: horde/lib/Text.php,v 1.80 2003/09/16 23:06:15 jan Exp $ |
---|
| 21 | * |
---|
| 22 | * Copyright 1999-2003 Jon Parise <jon@horde.org> |
---|
| 23 | * |
---|
| 24 | * See the enclosed file COPYING for license information (LGPL). If you |
---|
| 25 | * did not receive this file, see http://www.fsf.org/copyleft/lgpl.html. |
---|
| 26 | * |
---|
| 27 | */ |
---|
| 28 | |
---|
| 29 | /* $Id: class.uidisplay.inc.php 24409 2007-09-03 20:21:45Z nelius_weiss $ */ |
---|
| 30 | |
---|
| 31 | class uidisplay |
---|
| 32 | { |
---|
| 33 | |
---|
| 34 | var $public_functions = array |
---|
| 35 | ( |
---|
| 36 | 'display' => 'True', |
---|
| 37 | 'displayBody' => 'True', |
---|
| 38 | 'displayHeader' => 'True', |
---|
| 39 | 'displayImage' => 'True', |
---|
| 40 | 'printMessage' => 'True', |
---|
| 41 | 'saveMessage' => 'True', |
---|
| 42 | 'showHeader' => 'True', |
---|
| 43 | 'getAttachment' => 'True', |
---|
| 44 | ); |
---|
| 45 | |
---|
| 46 | var $icServerID=0; |
---|
| 47 | |
---|
| 48 | // the object storing the data about the incoming imap server |
---|
| 49 | var $icServer=0; |
---|
| 50 | |
---|
| 51 | // the non permanent id of the message |
---|
| 52 | var $id; |
---|
| 53 | |
---|
| 54 | // the permanent id of the message |
---|
| 55 | var $uid; |
---|
| 56 | |
---|
| 57 | function uidisplay() |
---|
| 58 | { |
---|
| 59 | $this->t =& CreateObject('phpgwapi.Template',EGW_APP_TPL); |
---|
| 60 | $this->displayCharset = $GLOBALS['egw']->translation->charset(); |
---|
| 61 | $this->bofelamimail =& CreateObject('felamimail.bofelamimail',$this->displayCharset); |
---|
| 62 | $this->bopreferences =& CreateObject('felamimail.bopreferences'); |
---|
| 63 | $this->kses =& CreateObject('phpgwapi.kses'); |
---|
| 64 | $this->botranslation =& CreateObject('phpgwapi.translation'); |
---|
| 65 | |
---|
| 66 | $this->mailPreferences = $this->bopreferences->getPreferences(); |
---|
| 67 | |
---|
| 68 | $this->bofelamimail->openConnection($this->icServerID); |
---|
| 69 | |
---|
| 70 | $this->mailbox = $this->bofelamimail->sessionData['mailbox']; |
---|
| 71 | $this->sort = $this->bofelamimail->sessionData['sort']; |
---|
| 72 | |
---|
| 73 | if(isset($_GET['uid'])) { |
---|
| 74 | $this->uid = (int)$_GET['uid']; |
---|
| 75 | } |
---|
| 76 | |
---|
| 77 | if(isset($_GET['id'])) { |
---|
| 78 | $this->id = (int)$_GET['id']; |
---|
| 79 | } |
---|
| 80 | |
---|
| 81 | if(isset($this->id) && !isset($this->uid)) { |
---|
| 82 | if($uid = $this->bofelamimail->idToUid($this->mailbox, $this->id)) { |
---|
| 83 | $this->uid = $uid; |
---|
| 84 | } |
---|
| 85 | } |
---|
| 86 | |
---|
| 87 | if(isset($_GET['part'])) { |
---|
| 88 | $this->partID = (int)$_GET['part']; |
---|
| 89 | } |
---|
| 90 | |
---|
| 91 | $this->rowColor[0] = $GLOBALS['egw_info']["theme"]["bg01"]; |
---|
| 92 | $this->rowColor[1] = $GLOBALS['egw_info']["theme"]["bg02"]; |
---|
| 93 | } |
---|
| 94 | |
---|
| 95 | function highlightQuotes($text, $level = 5) |
---|
| 96 | { |
---|
| 97 | // Use a global var since the class is called statically. |
---|
| 98 | $GLOBALS['_tmp_maxQuoteChars'] = 0; |
---|
| 99 | |
---|
| 100 | // Tack a newline onto the beginning of the string so that we |
---|
| 101 | // correctly highlight when the first character in the string |
---|
| 102 | // is a quote character. |
---|
| 103 | $text = "\n$text"; |
---|
| 104 | |
---|
| 105 | preg_replace_callback("/^\s*((>\s?)+)/m", array(&$this, '_countQuoteChars'), $text); |
---|
| 106 | |
---|
| 107 | // Go through each level of quote block and put the |
---|
| 108 | // appropriate style around it. Important to work downwards so |
---|
| 109 | // blocks with fewer quote chars aren't matched until their |
---|
| 110 | // turn. |
---|
| 111 | for ($i = $GLOBALS['_tmp_maxQuoteChars']; $i > 0; $i--) |
---|
| 112 | { |
---|
| 113 | $text = preg_replace( |
---|
| 114 | // Finds a quote block across multiple newlines. |
---|
| 115 | "/(\n)( *(>\s?)\{$i}(?! ?>).*?)(\n|$)(?! *(> ?)\{$i})/s", |
---|
| 116 | '\1<span class="quoted' . ((($i - 1) % $level) + 1) . '">\2</span>\4',$text); |
---|
| 117 | } |
---|
| 118 | |
---|
| 119 | /* Unset the global variable. */ |
---|
| 120 | unset($GLOBALS['_tmp_maxQuoteChars']); |
---|
| 121 | |
---|
| 122 | /* Remove the leading newline we added above. */ |
---|
| 123 | return substr($text, 1); |
---|
| 124 | } |
---|
| 125 | |
---|
| 126 | function _countQuoteChars($matches) |
---|
| 127 | { |
---|
| 128 | $num = count(preg_split('/>\s?/', $matches[1])) - 1; |
---|
| 129 | if ($num > $GLOBALS['_tmp_maxQuoteChars']) |
---|
| 130 | { |
---|
| 131 | $GLOBALS['_tmp_maxQuoteChars'] = $num; |
---|
| 132 | } |
---|
| 133 | } |
---|
| 134 | |
---|
| 135 | function display() |
---|
| 136 | { |
---|
| 137 | $partID = $_GET['part']; |
---|
| 138 | $transformdate =& CreateObject('felamimail.transformdate'); |
---|
| 139 | $htmlFilter =& CreateObject('felamimail.htmlfilter'); |
---|
| 140 | $uiWidgets =& CreateObject('felamimail.uiwidgets'); |
---|
| 141 | // (regis) seems to be necessary to reopen... |
---|
| 142 | $this->bofelamimail->reopen($this->mailbox); |
---|
| 143 | #print "$this->mailbox, $this->uid, $partID<br>"; |
---|
| 144 | $headers = $this->bofelamimail->getMessageHeader($this->uid, $partID); |
---|
| 145 | #_debug_array($headers);exit; |
---|
| 146 | $rawheaders = $this->bofelamimail->getMessageRawHeader($this->uid, $partID); |
---|
| 147 | $attachments = $this->bofelamimail->getMessageAttachments($this->uid, $partID); |
---|
| 148 | #_debug_array($attachments); exit; |
---|
| 149 | $envelope = $this->bofelamimail->getMessageEnvelope($this->uid, $partID); |
---|
| 150 | |
---|
| 151 | $nextMessage = $this->bofelamimail->getNextMessage($this->mailbox, $this->uid); |
---|
| 152 | |
---|
| 153 | $webserverURL = $GLOBALS['egw_info']['server']['webserver_url']; |
---|
| 154 | |
---|
| 155 | $nonDisplayAbleCharacters = array('[\016]','[\017]', |
---|
| 156 | '[\020]','[\021]','[\022]','[\023]','[\024]','[\025]','[\026]','[\027]', |
---|
| 157 | '[\030]','[\031]','[\032]','[\033]','[\034]','[\035]','[\036]','[\037]'); |
---|
| 158 | |
---|
| 159 | #print "<pre>";print_r($rawheaders);print"</pre>";exit; |
---|
| 160 | |
---|
| 161 | // add line breaks to $rawheaders |
---|
| 162 | $newRawHeaders = explode("\n",$rawheaders); |
---|
| 163 | reset($newRawHeaders); |
---|
| 164 | |
---|
| 165 | if(isset($headers['ORGANIZATION'])) { |
---|
| 166 | $organization = $this->bofelamimail->decode_header(trim($headers['ORGANIZATION'])); |
---|
| 167 | } |
---|
| 168 | |
---|
| 169 | // reset $rawheaders |
---|
| 170 | $rawheaders = ""; |
---|
| 171 | // create it new, with good line breaks |
---|
| 172 | reset($newRawHeaders); |
---|
| 173 | while(list($key,$value) = @each($newRawHeaders)) { |
---|
| 174 | $rawheaders .= wordwrap($value, 90, "\n "); |
---|
| 175 | } |
---|
| 176 | |
---|
| 177 | $this->bofelamimail->closeConnection(); |
---|
| 178 | |
---|
| 179 | $this->display_app_header(); |
---|
| 180 | if(!isset($_GET['printable'])) { |
---|
| 181 | $this->t->set_file(array("displayMsg" => "view_message.tpl")); |
---|
| 182 | } else { |
---|
| 183 | $this->t->set_file(array("displayMsg" => "view_message_printable.tpl")); |
---|
| 184 | $this->t->set_var('charset',$GLOBALS['egw']->translation->charset()); |
---|
| 185 | } |
---|
| 186 | |
---|
| 187 | $this->t->set_block('displayMsg','message_main'); |
---|
| 188 | $this->t->set_block('displayMsg','message_main_attachment'); |
---|
| 189 | $this->t->set_block('displayMsg','message_header'); |
---|
| 190 | $this->t->set_block('displayMsg','message_raw_header'); |
---|
| 191 | $this->t->set_block('displayMsg','message_navbar'); |
---|
| 192 | $this->t->set_block('displayMsg','message_onbehalfof'); |
---|
| 193 | $this->t->set_block('displayMsg','message_cc'); |
---|
| 194 | $this->t->set_block('displayMsg','message_attachement_row'); |
---|
| 195 | $this->t->set_block('displayMsg','previous_message_block'); |
---|
| 196 | $this->t->set_block('displayMsg','next_message_block'); |
---|
| 197 | $this->t->set_block('displayMsg','message_org'); |
---|
| 198 | |
---|
| 199 | $this->t->egroupware_hack = False; |
---|
| 200 | |
---|
| 201 | $this->translate(); |
---|
| 202 | |
---|
| 203 | // if(!isset($_GET['printable'])) |
---|
| 204 | // { |
---|
| 205 | // navbar start |
---|
| 206 | // reply url |
---|
| 207 | $linkData = array ( |
---|
| 208 | 'menuaction' => 'felamimail.uicompose.reply', |
---|
| 209 | 'icServer' => $this->icServer, |
---|
| 210 | 'folder' => base64_encode($this->mailbox), |
---|
| 211 | 'reply_id' => $this->uid, |
---|
| 212 | ); |
---|
| 213 | if($partID != '') { |
---|
| 214 | $linkData['part_id'] = $partID; |
---|
| 215 | } |
---|
| 216 | $replyURL = $GLOBALS['egw']->link('/index.php',$linkData); |
---|
| 217 | |
---|
| 218 | // reply all url |
---|
| 219 | $linkData = array ( |
---|
| 220 | 'menuaction' => 'felamimail.uicompose.replyAll', |
---|
| 221 | 'icServer' => $this->icServer, |
---|
| 222 | 'folder' => base64_encode($this->mailbox), |
---|
| 223 | 'reply_id' => $this->uid, |
---|
| 224 | ); |
---|
| 225 | if($partID != '') { |
---|
| 226 | $linkData['part_id'] = $partID; |
---|
| 227 | } |
---|
| 228 | $replyAllURL = $GLOBALS['egw']->link('/index.php',$linkData); |
---|
| 229 | |
---|
| 230 | // forward url |
---|
| 231 | $linkData = array ( |
---|
| 232 | 'menuaction' => 'felamimail.uicompose.forward', |
---|
| 233 | 'reply_id' => $this->uid, |
---|
| 234 | 'folder' => base64_encode($this->mailbox), |
---|
| 235 | ); |
---|
| 236 | if($partID != '') { |
---|
| 237 | $linkData['part_id'] = $partID; |
---|
| 238 | } |
---|
| 239 | $forwardURL = $GLOBALS['egw']->link('/index.php',$linkData); |
---|
| 240 | |
---|
| 241 | //delete url |
---|
| 242 | $linkData = array ( |
---|
| 243 | 'menuaction' => 'felamimail.uifelamimail.deleteMessage', |
---|
| 244 | 'icServer' => $this->icServer, |
---|
| 245 | 'folder' => base64_encode($this->mailbox), |
---|
| 246 | 'message' => $this->uid, |
---|
| 247 | ); |
---|
| 248 | $deleteURL = $GLOBALS['egw']->link('/index.php',$linkData); |
---|
| 249 | |
---|
| 250 | $navbarImages = array( |
---|
| 251 | 'mail_reply' => array( |
---|
| 252 | 'action' => "window.location.href = '$replyURL'", |
---|
| 253 | 'tooltip' => lang('reply'), |
---|
| 254 | ), |
---|
| 255 | 'mail_replyall' => array( |
---|
| 256 | 'action' => "window.location.href = '$replyAllURL'", |
---|
| 257 | 'tooltip' => lang('reply all'), |
---|
| 258 | ), |
---|
| 259 | 'mail_forward' => array( |
---|
| 260 | 'action' => "window.location.href = '$forwardURL'", |
---|
| 261 | 'tooltip' => lang('forward'), |
---|
| 262 | ), |
---|
| 263 | 'delete' => array( |
---|
| 264 | 'action' => "window.location.href = '$deleteURL'", |
---|
| 265 | 'tooltip' => lang('delete'), |
---|
| 266 | ), |
---|
| 267 | ); |
---|
| 268 | foreach($navbarImages as $buttonName => $buttonInfo) { |
---|
| 269 | $navbarButtons .= $uiWidgets->navbarButton($buttonName, $buttonInfo['action'], $buttonInfo['tooltip']); |
---|
| 270 | } |
---|
| 271 | $navbarButtons .= $uiWidgets->navbarSeparator(); |
---|
| 272 | |
---|
| 273 | // print url |
---|
| 274 | $linkData = array ( |
---|
| 275 | 'menuaction' => 'felamimail.uidisplay.printMessage', |
---|
| 276 | 'uid' => $this->uid |
---|
| 277 | ); |
---|
| 278 | if($partID != '') { |
---|
| 279 | $linkData['part'] = $partID; |
---|
| 280 | } |
---|
| 281 | $printURL = $GLOBALS['egw']->link('/index.php',$linkData); |
---|
| 282 | $to_infologURL = $GLOBALS['egw']->link('/index.php',array( |
---|
| 283 | 'menuaction' => 'infolog.uiinfolog.import_mail', |
---|
| 284 | 'uid' => $this->uid, |
---|
| 285 | 'mailbox' => $this->mailbox |
---|
| 286 | )); |
---|
| 287 | |
---|
| 288 | |
---|
| 289 | // viewheader url |
---|
| 290 | $linkData = array ( |
---|
| 291 | 'menuaction' => 'felamimail.uidisplay.displayHeader', |
---|
| 292 | 'uid' => $this->uid |
---|
| 293 | ); |
---|
| 294 | if($partID != '') { |
---|
| 295 | $linkData['part'] = $partID; |
---|
| 296 | } |
---|
| 297 | $viewHeaderURL = $GLOBALS['egw']->link('/index.php',$linkData); |
---|
| 298 | |
---|
| 299 | $navbarImages = array(); |
---|
| 300 | |
---|
| 301 | // viewheader url |
---|
| 302 | $linkData = array ( |
---|
| 303 | 'menuaction' => 'felamimail.uidisplay.saveMessage', |
---|
| 304 | 'uid' => $this->uid |
---|
| 305 | ); |
---|
| 306 | if($partID != '') { |
---|
| 307 | $linkData['part'] = $partID; |
---|
| 308 | } |
---|
| 309 | $saveMessageURL = $GLOBALS['egw']->link('/index.php',$linkData); |
---|
| 310 | |
---|
| 311 | $navbarImages = array(); |
---|
| 312 | |
---|
| 313 | //print email |
---|
| 314 | $navbarImages = array( |
---|
| 315 | 'fileprint' => array( |
---|
| 316 | 'action' => "window.location.href = '$printURL'", |
---|
| 317 | 'tooltip' => lang('print it'), |
---|
| 318 | ), |
---|
| 319 | 'to_infolog' => array( |
---|
| 320 | 'action' => "window.open('$to_infologURL','_blank','dependent=yes,width=750,height=550,scrollbars=yes,status=yes')", |
---|
| 321 | 'tooltip' => lang('save as infolog'), |
---|
| 322 | ), |
---|
| 323 | ); |
---|
| 324 | |
---|
| 325 | // save email as |
---|
| 326 | $navbarImages['fileexport'] = array( |
---|
| 327 | 'action' => "window.location.href = '$saveMessageURL'", |
---|
| 328 | 'tooltip' => lang('save message to disk'), |
---|
| 329 | ); |
---|
| 330 | |
---|
| 331 | // view header lines |
---|
| 332 | $navbarImages['kmmsgread'] = array( |
---|
| 333 | 'action' => "fm_displayHeaderLines('$viewHeaderURL')", |
---|
| 334 | 'tooltip' => lang('view header lines'), |
---|
| 335 | ); |
---|
| 336 | |
---|
| 337 | foreach($navbarImages as $buttonName => $buttonData) { |
---|
| 338 | $navbarButtons .= $uiWidgets->navbarButton($buttonName, $buttonData['action'], $buttonData['tooltip']); |
---|
| 339 | } |
---|
| 340 | $this->t->set_var('navbarButtonsLeft',$navbarButtons); |
---|
| 341 | |
---|
| 342 | $navbarButtons = ''; |
---|
| 343 | $navbarImages = array(); |
---|
| 344 | #_debug_array($nextMessage); exit; |
---|
| 345 | |
---|
| 346 | if($nextMessage['previous']) { |
---|
| 347 | $linkData = array ( |
---|
| 348 | 'menuaction' => 'felamimail.uidisplay.display', |
---|
| 349 | 'showHeader' => 'false', |
---|
| 350 | 'uid' => $nextMessage['previous'] |
---|
| 351 | ); |
---|
| 352 | $previousURL = $GLOBALS['egw']->link('/index.php',$linkData); |
---|
| 353 | $previousURL = "window.location.href = '$previousURL'"; |
---|
| 354 | $navbarImages['up.button'] = array( |
---|
| 355 | 'action' => $previousURL, |
---|
| 356 | 'tooltip' => lang('previous message'), |
---|
| 357 | ); |
---|
| 358 | } else { |
---|
| 359 | $previousURL = ''; |
---|
| 360 | } |
---|
| 361 | |
---|
| 362 | if($nextMessage['next']) { |
---|
| 363 | $linkData = array ( |
---|
| 364 | 'menuaction' => 'felamimail.uidisplay.display', |
---|
| 365 | 'showHeader' => 'false', |
---|
| 366 | 'uid' => $nextMessage['next'] |
---|
| 367 | ); |
---|
| 368 | $nextURL = $GLOBALS['egw']->link('/index.php',$linkData); |
---|
| 369 | $nextURL = "window.location.href = '$nextURL'"; |
---|
| 370 | $navbarImages['down.button'] = array( |
---|
| 371 | 'action' => $nextURL, |
---|
| 372 | 'tooltip' => lang('next message'), |
---|
| 373 | ); |
---|
| 374 | } else { |
---|
| 375 | $nextURL = ''; |
---|
| 376 | } |
---|
| 377 | |
---|
| 378 | |
---|
| 379 | foreach($navbarImages as $buttonName => $buttonData) { |
---|
| 380 | $navbarButtons .= $uiWidgets->navbarButton($buttonName, $buttonData['action'], $buttonData['tooltip'], 'right'); |
---|
| 381 | } |
---|
| 382 | |
---|
| 383 | $this->t->set_var('navbarButtonsRight',$navbarButtons); |
---|
| 384 | |
---|
| 385 | $this->t->parse('navbar','message_navbar',True); |
---|
| 386 | |
---|
| 387 | // navbar end |
---|
| 388 | // header |
---|
| 389 | // sent by a mailinglist?? |
---|
| 390 | // parse the from header |
---|
| 391 | if($envelope['FROM'][0] != $envelope['SENDER'][0]) { |
---|
| 392 | $senderAddress = $this->emailAddressToHTML($envelope['SENDER']); |
---|
| 393 | $fromAddress = $this->emailAddressToHTML($envelope['FROM'], $organization); |
---|
| 394 | $this->t->set_var("from_data",$senderAddress); |
---|
| 395 | $this->t->set_var("onbehalfof_data",$fromAddress); |
---|
| 396 | $this->t->parse('on_behalf_of_part','message_onbehalfof',True); |
---|
| 397 | } else { |
---|
| 398 | $fromAddress = $this->emailAddressToHTML($envelope['FROM'], $organization); |
---|
| 399 | $this->t->set_var("from_data", $fromAddress); |
---|
| 400 | $this->t->set_var('on_behalf_of_part',''); |
---|
| 401 | } |
---|
| 402 | |
---|
| 403 | // parse the to header |
---|
| 404 | $toAddress = $this->emailAddressToHTML($envelope['TO']); |
---|
| 405 | $this->t->set_var("to_data",$toAddress); |
---|
| 406 | |
---|
| 407 | // parse the cc header |
---|
| 408 | if(count($envelope['CC'])) { |
---|
| 409 | $ccAddress = $this->emailAddressToHTML($envelope['CC']); |
---|
| 410 | $this->t->set_var("cc_data",$ccAddress); |
---|
| 411 | $this->t->parse('cc_data_part','message_cc',True); |
---|
| 412 | } else { |
---|
| 413 | $this->t->set_var("cc_data_part",''); |
---|
| 414 | } |
---|
| 415 | |
---|
| 416 | $this->t->set_var("date_received", |
---|
| 417 | @htmlspecialchars($GLOBALS['egw']->common->show_date(strtotime($headers['DATE'])), |
---|
| 418 | ENT_QUOTES,$this->displayCharset)); |
---|
| 419 | |
---|
| 420 | $this->t->set_var("subject_data", |
---|
| 421 | @htmlspecialchars($this->bofelamimail->decode_header(preg_replace($nonDisplayAbleCharacters,'',$envelope['SUBJECT'])), |
---|
| 422 | ENT_QUOTES,$this->displayCharset)); |
---|
| 423 | |
---|
| 424 | $this->t->parse("header","message_header",True); |
---|
| 425 | |
---|
| 426 | $this->t->set_var("rawheader",@htmlentities(preg_replace($nonDisplayAbleCharacters,'',$rawheaders),ENT_QUOTES,$this->displayCharset)); |
---|
| 427 | |
---|
| 428 | $linkData = array ( |
---|
| 429 | 'menuaction' => 'felamimail.uidisplay.displayBody', |
---|
| 430 | 'uid' => $this->uid, |
---|
| 431 | 'part' => $partID |
---|
| 432 | ); |
---|
| 433 | $this->t->set_var('url_displayBody', $GLOBALS['egw']->link('/index.php',$linkData)); |
---|
| 434 | |
---|
| 435 | #$this->t->set_var("signature", $sessionData['signature']); |
---|
| 436 | |
---|
| 437 | // attachments |
---|
| 438 | if(is_array($attachments) && count($attachments) > 0) { |
---|
| 439 | $this->t->set_var('attachment_count',count($attachments)); |
---|
| 440 | } else { |
---|
| 441 | $this->t->set_var('attachment_count','0'); |
---|
| 442 | } |
---|
| 443 | |
---|
| 444 | if (is_array($attachments) && count($attachments) > 0) { |
---|
| 445 | $this->t->set_var('row_color',$this->rowColor[0]); |
---|
| 446 | $this->t->set_var('name',lang('name')); |
---|
| 447 | $this->t->set_var('type',lang('type')); |
---|
| 448 | $this->t->set_var('size',lang('size')); |
---|
| 449 | $this->t->set_var('url_img_save',$GLOBALS['egw']->html->image('felamimail','fileexport', lang('save'))); |
---|
| 450 | #$this->t->parse('attachment_rows','attachment_row_bold',True); |
---|
| 451 | |
---|
| 452 | foreach ($attachments as $key => $value) |
---|
| 453 | { |
---|
| 454 | $this->t->set_var('row_color',$this->rowColor[($key+1)%2]); |
---|
| 455 | $this->t->set_var('filename',$value['name'] ? @htmlentities($value['name'], ENT_QUOTES, $this->displayCharset) : |
---|
| 456 | lang('(no subject)')); |
---|
| 457 | $this->t->set_var('mimetype',$value['mimeType']); |
---|
| 458 | $this->t->set_var('size',$value['size']); |
---|
| 459 | $this->t->set_var('attachment_number',$key); |
---|
| 460 | |
---|
| 461 | switch($value['mimeType']) |
---|
| 462 | { |
---|
| 463 | case 'MESSAGE/RFC822': |
---|
| 464 | $linkData = array |
---|
| 465 | ( |
---|
| 466 | 'menuaction' => 'felamimail.uidisplay.display', |
---|
| 467 | 'uid' => $this->uid, |
---|
| 468 | 'part' => $value['partID'] |
---|
| 469 | ); |
---|
| 470 | $windowName = 'displayMessage_'. $this->uid; |
---|
| 471 | $linkView = "egw_openWindowCentered('".$GLOBALS['egw']->link('/index.php',$linkData)."','$windowName',700,egw_getWindowOuterHeight());"; |
---|
| 472 | break; |
---|
| 473 | case 'IMAGE/JPEG': |
---|
| 474 | case 'IMAGE/PNG': |
---|
| 475 | case 'IMAGE/GIF': |
---|
| 476 | #case 'application/pdf': |
---|
| 477 | $linkData = array |
---|
| 478 | ( |
---|
| 479 | 'menuaction' => 'felamimail.uidisplay.getAttachment', |
---|
| 480 | 'uid' => $this->uid, |
---|
| 481 | 'part' => $value['partID'] |
---|
| 482 | ); |
---|
| 483 | $windowName = 'displayAttachment_'. $this->uid; |
---|
| 484 | $linkView = "egw_openWindowCentered('".$GLOBALS['egw']->link('/index.php',$linkData)."','$windowName',800,600);"; |
---|
| 485 | break; |
---|
| 486 | default: |
---|
| 487 | $linkData = array |
---|
| 488 | ( |
---|
| 489 | 'menuaction' => 'felamimail.uidisplay.getAttachment', |
---|
| 490 | 'uid' => $this->uid, |
---|
| 491 | 'part' => $value['partID'] |
---|
| 492 | ); |
---|
| 493 | $linkView = "window.location.href = '".$GLOBALS['egw']->link('/index.php',$linkData)."';"; |
---|
| 494 | break; |
---|
| 495 | } |
---|
| 496 | $this->t->set_var("link_view",$linkView); |
---|
| 497 | $this->t->set_var("target",$target); |
---|
| 498 | |
---|
| 499 | $linkData = array |
---|
| 500 | ( |
---|
| 501 | 'menuaction' => 'felamimail.uidisplay.getAttachment', |
---|
| 502 | 'mode' => 'save', |
---|
| 503 | 'uid' => $this->uid, |
---|
| 504 | 'part' => $value['partID'] |
---|
| 505 | ); |
---|
| 506 | $this->t->set_var("link_save",$GLOBALS['egw']->link('/index.php',$linkData)); |
---|
| 507 | |
---|
| 508 | $this->t->parse('attachment_rows','message_attachement_row',True); |
---|
| 509 | } |
---|
| 510 | } else { |
---|
| 511 | $this->t->set_var('attachment_rows',''); |
---|
| 512 | } |
---|
| 513 | |
---|
| 514 | #$this->t->pparse("out","message_attachment_rows"); |
---|
| 515 | |
---|
| 516 | // print it out |
---|
| 517 | if(is_array($attachments) && count($attachments) > 0) { |
---|
| 518 | $this->t->pparse('out','message_main_attachment'); |
---|
| 519 | } else { |
---|
| 520 | $this->t->pparse('out','message_main'); |
---|
| 521 | } |
---|
| 522 | |
---|
| 523 | } |
---|
| 524 | |
---|
| 525 | function displayBody() |
---|
| 526 | { |
---|
| 527 | $partID = $_GET['part']; |
---|
| 528 | |
---|
| 529 | $this->bofelamimail->reopen($this->mailbox); |
---|
| 530 | $bodyParts = $this->bofelamimail->getMessageBody($this->uid,'',$partID); |
---|
| 531 | |
---|
| 532 | $this->bofelamimail->closeConnection(); |
---|
| 533 | |
---|
| 534 | $this->display_app_header(); |
---|
| 535 | |
---|
| 536 | $body = $this->getdisplayableBody($bodyParts); |
---|
| 537 | |
---|
| 538 | print '<style type="text/css"> |
---|
| 539 | body,html { |
---|
| 540 | height:100%; |
---|
| 541 | width:100%; |
---|
| 542 | padding:0px; |
---|
| 543 | margin:0px; |
---|
| 544 | } |
---|
| 545 | .td_display { |
---|
| 546 | font-family: Verdana, Arial, Helvetica, sans-serif; |
---|
| 547 | font-size: 110%; |
---|
| 548 | background-color: #FFFFFF; |
---|
| 549 | } |
---|
| 550 | </style> |
---|
| 551 | <div style="height:100%;width:100%; background-color:white; padding:0px; margin:0px;"><table width="100%" style="table-layout:fixed"><tr><td class="td_display">'; |
---|
| 552 | |
---|
| 553 | print $body.'</td></tr></table>'; |
---|
| 554 | |
---|
| 555 | print "</body></html>"; |
---|
| 556 | } |
---|
| 557 | |
---|
| 558 | function displayHeader() |
---|
| 559 | { |
---|
| 560 | $partID = $_GET['part']; |
---|
| 561 | $transformdate =& CreateObject('felamimail.transformdate'); |
---|
| 562 | $htmlFilter =& CreateObject('felamimail.htmlfilter'); |
---|
| 563 | $uiWidgets =& CreateObject('felamimail.uiwidgets'); |
---|
| 564 | // (regis) seems to be necessary to reopen... |
---|
| 565 | $this->bofelamimail->reopen($this->mailbox); |
---|
| 566 | #$headers = $this->bofelamimail->getMessageHeader($this->mailbox, $this->uid, $partID); |
---|
| 567 | $rawheaders = $this->bofelamimail->getMessageRawHeader($this->uid, $partID); |
---|
| 568 | |
---|
| 569 | $webserverURL = $GLOBALS['egw_info']['server']['webserver_url']; |
---|
| 570 | |
---|
| 571 | #$nonDisplayAbleCharacters = array('[\016]','[\017]', |
---|
| 572 | # '[\020]','[\021]','[\022]','[\023]','[\024]','[\025]','[\026]','[\027]', |
---|
| 573 | # '[\030]','[\031]','[\032]','[\033]','[\034]','[\035]','[\036]','[\037]'); |
---|
| 574 | |
---|
| 575 | #print "<pre>";print_r($rawheaders);print"</pre>";exit; |
---|
| 576 | |
---|
| 577 | // add line breaks to $rawheaders |
---|
| 578 | $newRawHeaders = explode("\n",$rawheaders); |
---|
| 579 | reset($newRawHeaders); |
---|
| 580 | |
---|
| 581 | // reset $rawheaders |
---|
| 582 | $rawheaders = ""; |
---|
| 583 | // create it new, with good line breaks |
---|
| 584 | reset($newRawHeaders); |
---|
| 585 | while(list($key,$value) = @each($newRawHeaders)) { |
---|
| 586 | $rawheaders .= wordwrap($value, 90, "\n "); |
---|
| 587 | } |
---|
| 588 | |
---|
| 589 | $this->bofelamimail->closeConnection(); |
---|
| 590 | |
---|
| 591 | header('Content-type: text/html; charset=iso-8859-1'); |
---|
| 592 | print '<pre>'. htmlspecialchars($rawheaders, ENT_QUOTES, 'iso-8859-1') .'</pre>'; |
---|
| 593 | |
---|
| 594 | } |
---|
| 595 | |
---|
| 596 | function displayImage() |
---|
| 597 | { |
---|
| 598 | $cid = base64_decode($_GET['cid']); |
---|
| 599 | $partID = urldecode($_GET['partID']); |
---|
| 600 | |
---|
| 601 | $this->bofelamimail->reopen($this->mailbox); |
---|
| 602 | |
---|
| 603 | $attachment = $this->bofelamimail->getAttachmentByCID($this->uid, $cid, $partID); |
---|
| 604 | |
---|
| 605 | $this->bofelamimail->closeConnection(); |
---|
| 606 | |
---|
| 607 | $GLOBALS['egw']->session->commit_session(); |
---|
| 608 | |
---|
| 609 | if(is_array($attachment)) { |
---|
| 610 | error_log("Content-Type: ".$attachment['type']."; name=\"". $attachment['filename'] ."\""); |
---|
| 611 | header ("Content-Type: ". strtolower($attachment['type']) ."; name=\"". $attachment['filename'] ."\""); |
---|
| 612 | header ('Content-Disposition: inline; filename="'. $attachment['filename'] .'"'); |
---|
| 613 | header("Expires: 0"); |
---|
| 614 | // the next headers are for IE and SSL |
---|
| 615 | header("Cache-Control: must-revalidate, post-check=0, pre-check=0"); |
---|
| 616 | header("Pragma: public"); |
---|
| 617 | |
---|
| 618 | echo trim($attachment['attachment']); |
---|
| 619 | exit; |
---|
| 620 | } |
---|
| 621 | |
---|
| 622 | $GLOBALS['egw']->common->egw_exit(); |
---|
| 623 | |
---|
| 624 | exit; |
---|
| 625 | } |
---|
| 626 | |
---|
| 627 | function display_app_header() |
---|
| 628 | { |
---|
| 629 | if(!@is_object($GLOBALS['egw']->js)) { |
---|
| 630 | $GLOBALS['egw']->js =& CreateObject('phpgwapi.javascript'); |
---|
| 631 | } |
---|
| 632 | |
---|
| 633 | if($_GET['menuaction'] != 'felamimail.uidisplay.printMessage' && |
---|
| 634 | $_GET['menuaction'] != 'felamimail.uidisplay.displayBody') { |
---|
| 635 | $GLOBALS['egw']->js->validate_file('tabs','tabs'); |
---|
| 636 | $GLOBALS['egw']->js->validate_file('jscode','view_message','felamimail'); |
---|
| 637 | $GLOBALS['egw']->js->set_onload('javascript:initAll();'); |
---|
| 638 | } |
---|
| 639 | |
---|
| 640 | if($_GET['menuaction'] == 'felamimail.uidisplay.printMessage') { |
---|
| 641 | $GLOBALS['egw']->js->set_onload('javascript:window.print()'); |
---|
| 642 | } |
---|
| 643 | |
---|
| 644 | if($_GET['menuaction'] == 'felamimail.uidisplay.printMessage' || |
---|
| 645 | $_GET['menuaction'] == 'felamimail.uidisplay.displayBody') { |
---|
| 646 | $GLOBALS['egw_info']['flags']['nofooter'] = true; |
---|
| 647 | } |
---|
| 648 | |
---|
| 649 | $GLOBALS['egw']->common->egw_header(); |
---|
| 650 | } |
---|
| 651 | |
---|
| 652 | function emailAddressToHTML($_emailAddress, $_organisation='', $allwaysShowMailAddress=false, $showAddToAdrdessbookLink=true) { |
---|
| 653 | #_debug_array($_emailAddress); |
---|
| 654 | // create some nice formated HTML for senderaddress |
---|
| 655 | #if($_emailAddress['EMAIL'] == 'undisclosed-recipients: ;') |
---|
| 656 | # return $_emailAddress['EMAIL']; |
---|
| 657 | |
---|
| 658 | #$addressData = imap_rfc822_parse_adrlist |
---|
| 659 | # ($this->bofelamimail->decode_header($_emailAddress),''); |
---|
| 660 | if(is_array($_emailAddress)) { |
---|
| 661 | $senderAddress = ''; |
---|
| 662 | foreach($_emailAddress as $addressData) { |
---|
| 663 | #_debug_array($addressData); |
---|
| 664 | if($addressData['MAILBOX_NAME'] == 'NIL') { |
---|
| 665 | continue; |
---|
| 666 | } |
---|
| 667 | |
---|
| 668 | if(!empty($senderAddress)) $senderAddress .= ', '; |
---|
| 669 | |
---|
| 670 | if(strtolower($addressData['MAILBOX_NAME']) == 'undisclosed-recipients') { |
---|
| 671 | $senderAddress .= 'undisclosed-recipients'; |
---|
| 672 | continue; |
---|
| 673 | } |
---|
| 674 | |
---|
| 675 | if($addressData['PERSONAL_NAME'] != 'NIL') { |
---|
| 676 | $newSenderAddress = $addressData['RFC822_EMAIL'] != 'NIL' ? $addressData['RFC822_EMAIL'] : $addressData['EMAIL']; |
---|
| 677 | $newSenderAddress = $this->bofelamimail->decode_header($newSenderAddress); |
---|
| 678 | $decodedPersonalName = $this->bofelamimail->decode_header($addressData['PERSONAL_NAME']); |
---|
| 679 | |
---|
| 680 | $realName = $decodedPersonalName; |
---|
| 681 | // add mailaddress |
---|
| 682 | if ($allwaysShowMailAddress) { |
---|
| 683 | $realName .= ' <'.$addressData['EMAIL'].'>'; |
---|
| 684 | } |
---|
| 685 | // add organization |
---|
| 686 | if(!empty($_organisation)) { |
---|
| 687 | $realName .= ' ('. $_organisation . ')'; |
---|
| 688 | } |
---|
| 689 | |
---|
| 690 | $linkData = array ( |
---|
| 691 | 'menuaction' => 'felamimail.uicompose.compose', |
---|
| 692 | 'send_to' => base64_encode($newSenderAddress) |
---|
| 693 | ); |
---|
| 694 | $link = $GLOBALS['egw']->link('/index.php',$linkData); |
---|
| 695 | $senderAddress .= sprintf('<a href="%s" title="%s">%s</a>', |
---|
| 696 | $link, |
---|
| 697 | @htmlentities($newSenderAddress,ENT_QUOTES,$this->displayCharset), |
---|
| 698 | @htmlentities($realName, ENT_QUOTES, $this->displayCharset)); |
---|
| 699 | |
---|
| 700 | $linkData = array ( |
---|
| 701 | 'menuaction' => 'addressbook.uicontacts.edit', |
---|
| 702 | 'presets[email]' => @htmlentities($addressData['EMAIL'], ENT_QUOTES, $this->displayCharset), |
---|
| 703 | 'presets[org_name]' => @htmlentities($_organisation, ENT_QUOTES, $this->displayCharset), |
---|
| 704 | 'referer' => $_SERVER['PHP_SELF'].'?'.$_SERVER['QUERY_STRING'] |
---|
| 705 | ); |
---|
| 706 | |
---|
| 707 | if($spacePos = strrpos($decodedPersonalName, ' ')) { |
---|
| 708 | $linkData['presets[n_family]'] = @htmlentities(substr($decodedPersonalName, $spacePos+1), ENT_QUOTES, $this->displayCharset); |
---|
| 709 | $linkData['presets[n_given]'] = @htmlentities(substr($decodedPersonalName, 0, $spacePos), ENT_QUOTES, $this->displayCharset); |
---|
| 710 | } else { |
---|
| 711 | $linkData['presets[n_family]'] = @htmlentities($decodedPersonalName, ENT_QUOTES, $this->displayCharset); |
---|
| 712 | } |
---|
| 713 | |
---|
| 714 | if ($showAddToAdrdessbookLink) { |
---|
| 715 | $urlAddToAddressbook = $GLOBALS['egw']->link('/index.php',$linkData); |
---|
| 716 | $onClick = "window.open(this,this.target,'dependent=yes,width=850,height=440,location=no,menubar=no,toolbar=no,scrollbars=yes,status=yes'); return false;"; |
---|
| 717 | $image = $GLOBALS['egw']->common->image('felamimail','sm_envelope'); |
---|
| 718 | $senderAddress .= sprintf('<a href="%s" onClick="%s"> |
---|
| 719 | <img src="%s" width="10" height="8" border="0" |
---|
| 720 | align="absmiddle" alt="%s" |
---|
| 721 | title="%s"></a>', |
---|
| 722 | $urlAddToAddressbook, |
---|
| 723 | $onClick, |
---|
| 724 | $image, |
---|
| 725 | lang('add to addressbook'), |
---|
| 726 | lang('add to addressbook')); |
---|
| 727 | } |
---|
| 728 | } else { |
---|
| 729 | $linkData = array ( |
---|
| 730 | 'menuaction' => 'felamimail.uicompose.compose', |
---|
| 731 | 'send_to' => base64_encode($addressData['EMAIL']) |
---|
| 732 | ); |
---|
| 733 | $link = $GLOBALS['egw']->link('/index.php',$linkData); |
---|
| 734 | $senderAddress .= sprintf('<a href="%s">%s</a>', |
---|
| 735 | $link,@htmlentities($addressData['EMAIL'], ENT_QUOTES, $this->displayCharset)); |
---|
| 736 | //TODO: This uses old addressbook code, which should be removed in Version 1.4 |
---|
| 737 | //Please use addressbook.uicontacts.edit with proper paramenters |
---|
| 738 | $linkData = array |
---|
| 739 | ( |
---|
| 740 | 'menuaction' => 'addressbook.uicontacts.edit', |
---|
| 741 | 'presets[email]' => @htmlentities($addressData['EMAIL'], ENT_QUOTES, $this->displayCharset), |
---|
| 742 | 'presets[org_name]' => @htmlentities($_organisation, ENT_QUOTES, $this->displayCharset), |
---|
| 743 | 'referer' => $_SERVER['PHP_SELF'].'?'.$_SERVER['QUERY_STRING'] |
---|
| 744 | ); |
---|
| 745 | |
---|
| 746 | if ($showAddToAdrdessbookLink) { |
---|
| 747 | $urlAddToAddressbook = $GLOBALS['egw']->link('/index.php',$linkData); |
---|
| 748 | $onClick = "window.open(this,this.target,'dependent=yes,width=850,height=440,location=no,menubar=no,toolbar=no,scrollbars=yes,status=yes'); return false;"; |
---|
| 749 | $image = $GLOBALS['egw']->common->image('felamimail','sm_envelope'); |
---|
| 750 | $senderAddress .= sprintf('<a href="%s" onClick="%s"> |
---|
| 751 | <img src="%s" width="10" height="8" border="0" |
---|
| 752 | align="absmiddle" alt="%s" |
---|
| 753 | title="%s"></a>', |
---|
| 754 | $urlAddToAddressbook, |
---|
| 755 | $onClick, |
---|
| 756 | $image, |
---|
| 757 | lang('add to addressbook'), |
---|
| 758 | lang('add to addressbook')); |
---|
| 759 | } |
---|
| 760 | } |
---|
| 761 | } |
---|
| 762 | |
---|
| 763 | return $senderAddress; |
---|
| 764 | } |
---|
| 765 | |
---|
| 766 | // if something goes wrong, just return the original address |
---|
| 767 | return $_emailAddress; |
---|
| 768 | } |
---|
| 769 | |
---|
| 770 | function getAttachment() |
---|
| 771 | { |
---|
| 772 | |
---|
| 773 | $part = $_GET['part']; |
---|
| 774 | |
---|
| 775 | $this->bofelamimail->reopen($this->mailbox); |
---|
| 776 | $attachment = $this->bofelamimail->getAttachment($this->uid,$part); |
---|
| 777 | $this->bofelamimail->closeConnection(); |
---|
| 778 | |
---|
| 779 | $GLOBALS['egw']->session->commit_session(); |
---|
| 780 | |
---|
| 781 | header ("Content-Type: ".$attachment['type']."; name=\"". $attachment['filename'] ."\""); |
---|
| 782 | if($_GET['mode'] == "save") { |
---|
| 783 | // ask for download |
---|
| 784 | header ("Content-Disposition: attachment; filename=\"". $attachment['filename'] ."\""); |
---|
| 785 | } else { |
---|
| 786 | // display it |
---|
| 787 | header ("Content-Disposition: inline; filename=\"". $attachment['filename'] ."\""); |
---|
| 788 | } |
---|
| 789 | header("Expires: 0"); |
---|
| 790 | // the next headers are for IE and SSL |
---|
| 791 | header("Cache-Control: must-revalidate, post-check=0, pre-check=0"); |
---|
| 792 | header("Pragma: public"); |
---|
| 793 | |
---|
| 794 | echo $attachment['attachment']; |
---|
| 795 | |
---|
| 796 | $GLOBALS['egw']->common->egw_exit(); |
---|
| 797 | exit; |
---|
| 798 | } |
---|
| 799 | |
---|
| 800 | function getdisplayableBody($_bodyParts) |
---|
| 801 | { |
---|
| 802 | $bodyParts = $_bodyParts; |
---|
| 803 | |
---|
| 804 | $webserverURL = $GLOBALS['egw_info']['server']['webserver_url']; |
---|
| 805 | |
---|
| 806 | $nonDisplayAbleCharacters = array('[\016]','[\017]', |
---|
| 807 | '[\020]','[\021]','[\022]','[\023]','[\024]','[\025]','[\026]','[\027]', |
---|
| 808 | '[\030]','[\031]','[\032]','[\033]','[\034]','[\035]','[\036]','[\037]'); |
---|
| 809 | |
---|
| 810 | $this->kses->AddProtocol('cid'); |
---|
| 811 | $this->kses->AddHTML( |
---|
| 812 | 'p', array( |
---|
| 813 | 'align' => array('minlen' => 1, 'maxlen' => 10) |
---|
| 814 | ) |
---|
| 815 | ); |
---|
| 816 | $this->kses->AddHTML("tbody"); |
---|
| 817 | $this->kses->AddHTML("tt"); |
---|
| 818 | $this->kses->AddHTML("br"); |
---|
| 819 | $this->kses->AddHTML("b"); |
---|
| 820 | $this->kses->AddHTML("u"); |
---|
| 821 | $this->kses->AddHTML("s"); |
---|
| 822 | $this->kses->AddHTML("i"); |
---|
| 823 | $this->kses->AddHTML('em'); |
---|
| 824 | $this->kses->AddHTML("strong"); |
---|
| 825 | $this->kses->AddHTML("strike"); |
---|
| 826 | $this->kses->AddHTML("center"); |
---|
| 827 | $this->kses->AddHTML( |
---|
| 828 | "font",array( |
---|
| 829 | "color" => array('maxlen' => 10) |
---|
| 830 | ) |
---|
| 831 | ); |
---|
| 832 | $this->kses->AddHTML( |
---|
| 833 | "hr",array( |
---|
| 834 | "class" => array('maxlen' => 20), |
---|
| 835 | "style" => array('minlen' => 1), |
---|
| 836 | ) |
---|
| 837 | ); |
---|
| 838 | $this->kses->AddHTML( |
---|
| 839 | "div",array( |
---|
| 840 | 'align' => array('maxlen' => 10) |
---|
| 841 | ) |
---|
| 842 | ); |
---|
| 843 | $this->kses->AddHTML("ul"); |
---|
| 844 | $this->kses->AddHTML( |
---|
| 845 | "ol",array( |
---|
| 846 | "type" => array('maxlen' => 20) |
---|
| 847 | ) |
---|
| 848 | ); |
---|
| 849 | $this->kses->AddHTML("li"); |
---|
| 850 | $this->kses->AddHTML("h1"); |
---|
| 851 | $this->kses->AddHTML("h2"); |
---|
| 852 | $this->kses->AddHTML( |
---|
| 853 | "style",array( |
---|
| 854 | "type" => array('maxlen' => 20) |
---|
| 855 | ) |
---|
| 856 | ); |
---|
| 857 | $this->kses->AddHTML("select"); |
---|
| 858 | $this->kses->AddHTML( |
---|
| 859 | "option",array( |
---|
| 860 | "value" => array('maxlen' => 45), |
---|
| 861 | "selected" => array() |
---|
| 862 | ) |
---|
| 863 | ); |
---|
| 864 | |
---|
| 865 | $this->kses->AddHTML( |
---|
| 866 | "a", array( |
---|
| 867 | "href" => array('maxlen' => 145, 'minlen' => 10), |
---|
| 868 | "name" => array('minlen' => 2), |
---|
| 869 | 'target' => array('maxlen' => 10) |
---|
| 870 | ) |
---|
| 871 | ); |
---|
| 872 | |
---|
| 873 | $this->kses->AddHTML( |
---|
| 874 | "pre", array( |
---|
| 875 | "wrap" => array('maxlen' => 10) |
---|
| 876 | ) |
---|
| 877 | ); |
---|
| 878 | |
---|
| 879 | // Allows 'td' tag with colspan|rowspan|class|style|width|nowrap attributes, |
---|
| 880 | // colspan has minval of 2 and maxval of 5 |
---|
| 881 | // rowspan has minval of 3 and maxval of 6 |
---|
| 882 | // class has minlen of 1 char and maxlen of 10 chars |
---|
| 883 | // style has minlen of 10 chars and maxlen of 100 chars |
---|
| 884 | // width has maxval of 100 |
---|
| 885 | // nowrap is valueless |
---|
| 886 | $this->kses->AddHTML( |
---|
| 887 | "table",array( |
---|
| 888 | "class" => array("minlen" => 1, 'maxlen' => 20), |
---|
| 889 | "border" => array("minlen" => 1, 'maxlen' => 10), |
---|
| 890 | "cellpadding" => array("minlen" => 0, 'maxlen' => 10), |
---|
| 891 | "cellspacing" => array("minlen" => 0, 'maxlen' => 10), |
---|
| 892 | "width" => array("maxlen" => 5), |
---|
| 893 | "style" => array('minlen' => 10, 'maxlen' => 100), |
---|
| 894 | "bgcolor" => array('maxlen' => 10), |
---|
| 895 | "align" => array('maxlen' => 10), |
---|
| 896 | "valign" => array('maxlen' => 10), |
---|
| 897 | "bordercolor" => array('maxlen' => 10) |
---|
| 898 | ) |
---|
| 899 | ); |
---|
| 900 | $this->kses->AddHTML( |
---|
| 901 | "tr",array( |
---|
| 902 | "colspan" => array('minval' => 2, 'maxval' => 5), |
---|
| 903 | "rowspan" => array('minval' => 3, 'maxval' => 6), |
---|
| 904 | "class" => array("minlen" => 1, 'maxlen' => 20), |
---|
| 905 | "width" => array("maxlen" => 5), |
---|
| 906 | "style" => array('minlen' => 10, 'maxlen' => 100), |
---|
| 907 | "align" => array('maxlen' => 10), |
---|
| 908 | 'bgcolor' => array('maxlen' => 10), |
---|
| 909 | "valign" => array('maxlen' => 10), |
---|
| 910 | "nowrap" => array('valueless' => 'y') |
---|
| 911 | ) |
---|
| 912 | ); |
---|
| 913 | $this->kses->AddHTML( |
---|
| 914 | "td",array( |
---|
| 915 | "colspan" => array('minval' => 2, 'maxval' => 5), |
---|
| 916 | "rowspan" => array('minval' => 3, 'maxval' => 6), |
---|
| 917 | "class" => array("minlen" => 1, 'maxlen' => 20), |
---|
| 918 | "width" => array("maxlen" => 5), |
---|
| 919 | "style" => array('minlen' => 10, 'maxlen' => 100), |
---|
| 920 | "align" => array('maxlen' => 10), |
---|
| 921 | 'bgcolor' => array('maxlen' => 10), |
---|
| 922 | "valign" => array('maxlen' => 10), |
---|
| 923 | "nowrap" => array('valueless' => 'y') |
---|
| 924 | ) |
---|
| 925 | ); |
---|
| 926 | $this->kses->AddHTML( |
---|
| 927 | "th",array( |
---|
| 928 | "colspan" => array('minval' => 2, 'maxval' => 5), |
---|
| 929 | "rowspan" => array('minval' => 3, 'maxval' => 6), |
---|
| 930 | "class" => array("minlen" => 1, 'maxlen' => 20), |
---|
| 931 | "width" => array("maxlen" => 5), |
---|
| 932 | "style" => array('minlen' => 10, 'maxlen' => 100), |
---|
| 933 | "align" => array('maxlen' => 10), |
---|
| 934 | "valign" => array('maxlen' => 10), |
---|
| 935 | "nowrap" => array('valueless' => 'y') |
---|
| 936 | ) |
---|
| 937 | ); |
---|
| 938 | $this->kses->AddHTML( |
---|
| 939 | "span",array( |
---|
| 940 | "class" => array("minlen" => 1, 'maxlen' => 20) |
---|
| 941 | ) |
---|
| 942 | ); |
---|
| 943 | $this->kses->AddHTML( |
---|
| 944 | "blockquote",array( |
---|
| 945 | "class" => array("minlen" => 1, 'maxlen' => 20), |
---|
| 946 | "style" => array("minlen" => 1), |
---|
| 947 | "cite" => array('maxlen' => 30), |
---|
| 948 | "type" => array('maxlen' => 10), |
---|
| 949 | "dir" => array("minlen" => 1, 'maxlen' => 10) |
---|
| 950 | ) |
---|
| 951 | ); |
---|
| 952 | // se modifico el valor de src maxlen para que se puedan ver imagenes remotas con mas de |
---|
| 953 | // 60 caracteres en la direccion |
---|
| 954 | |
---|
| 955 | $this->kses->AddHTML( |
---|
| 956 | 'img',array( |
---|
| 957 | "src" => array("minlen" => 4, 'maxlen' => 260, $GLOBALS['egw_info']['user']['preferences']['felamimail']['allowExternalIMGs'] ? '' : 'match' => '/^cid:.*/'), |
---|
| 958 | "align" => array("minlen" => 1), |
---|
| 959 | "border" => array('maxlen' => 30), |
---|
| 960 | ) |
---|
| 961 | ); |
---|
| 962 | |
---|
| 963 | $body = ''; |
---|
| 964 | |
---|
| 965 | #_debug_array($bodyParts); exit; |
---|
| 966 | |
---|
| 967 | foreach($bodyParts as $singleBodyPart) { |
---|
| 968 | if(!empty($body)) { |
---|
| 969 | $body .= '<hr style="border:dotted 1px silver;">'; |
---|
| 970 | } |
---|
| 971 | $singleBodyPart['body'] = $this->botranslation->convert( |
---|
| 972 | $singleBodyPart['body'], |
---|
| 973 | strtolower($singleBodyPart['charSet']) |
---|
| 974 | ); |
---|
| 975 | |
---|
| 976 | if($singleBodyPart['mimeType'] == 'text/plain') |
---|
| 977 | { |
---|
| 978 | $newBody = $singleBodyPart['body']; |
---|
| 979 | |
---|
| 980 | $newBody = @htmlentities($singleBodyPart['body'],ENT_QUOTES,$this->displayCharset); |
---|
| 981 | #$newBody = $this->bofelamimail->wordwrap($newBody, 90, "\n"); |
---|
| 982 | |
---|
| 983 | // search http[s] links and make them as links available again |
---|
| 984 | // to understand what's going on here, have a look at |
---|
| 985 | // http://www.php.net/manual/en/function.preg-replace.php |
---|
| 986 | |
---|
| 987 | // create links for websites |
---|
| 988 | $newBody = preg_replace("/((http(s?):\/\/)|(www\.))([\w,\-,\/,\?,\=,\.,&,!\n,!>,\%,@,\*,#,:,~,\+]+)/ie", |
---|
| 989 | "'<a href=\"$webserverURL/redirect.php?go='.@htmlentities(urlencode('http$3://$4$5'),ENT_QUOTES,\"$this->displayCharset\").'\" target=\"_blank\"><font color=\"blue\">$2$4$5</font></a>'", $newBody); |
---|
| 990 | |
---|
| 991 | // create links for ftp sites |
---|
| 992 | $newBody = preg_replace("/((ftp:\/\/)|(ftp\.))([\w\.,-.,\/.,\?.,\=.,&]+)/i", |
---|
| 993 | "<a href=\"ftp://$3$4\" target=\"_blank\"><font color=\"blue\">ftp://$3$4</font></a>", $newBody); |
---|
| 994 | |
---|
| 995 | // create links for email addresses |
---|
| 996 | $linkData = array |
---|
| 997 | ( |
---|
| 998 | 'menuaction' => 'felamimail.uicompose.compose' |
---|
| 999 | ); |
---|
| 1000 | $link = $GLOBALS['egw']->link('/index.php',$linkData); |
---|
| 1001 | $newBody = preg_replace("/(?<=\s{1}|<)(([\w\.,-.,_.,0-9.]+)(@)([\w\.,-.,_.,0-9.]+))/ie", |
---|
| 1002 | "'<a href=\"$link&send_to='.base64_encode('$0').'\"><font color=\"blue\">$0</font></a>'", $newBody); |
---|
| 1003 | |
---|
| 1004 | $newBody = $this->highlightQuotes($newBody); |
---|
| 1005 | $newBody = nl2br($newBody); |
---|
| 1006 | } |
---|
| 1007 | else |
---|
| 1008 | { |
---|
| 1009 | $newBody = $singleBodyPart['body']; |
---|
| 1010 | $newBody = $this->highlightQuotes($newBody); |
---|
| 1011 | $newBody = $this->kses->Parse($newBody); |
---|
| 1012 | |
---|
| 1013 | // create links for websites |
---|
| 1014 | #$newBody = preg_replace("/(?<!\>)((http(s?):\/\/)|(www\.))([\w,\-,\/,\?,\=,\.,&,!\n,\%,@,\*,#,:,~,\+]+)/ie", |
---|
| 1015 | # "'<a href=\"$webserverURL/redirect.php?go='.htmlentities(urlencode('http$3://$4$5'),ENT_QUOTES,\"$this->displayCharset\").'\" target=\"_blank\"><font color=\"blue\">$2$4$5</font></a>'", $newBody); |
---|
| 1016 | $newBody = preg_replace("/(?<!>|\/|\")((http(s?):\/\/)|(www\.))([\w,\-,\/,\?,\=,\.,&,!\n,\%,@,\*,#,:,~,\+]+)/ie", |
---|
| 1017 | "'<a href=\"$webserverURL/redirect.php?go='.@htmlentities(urlencode('http$3://$4$5'),ENT_QUOTES,\"$this->displayCharset\").'\" target=\"_blank\"><font color=\"blue\">$2$4$5</font></a>'", $newBody); |
---|
| 1018 | |
---|
| 1019 | // create links for websites |
---|
| 1020 | $newBody = preg_replace("/href=(\"|\')((http(s?):\/\/)|(www\.))([\w,\-,\/,\?,\=,\.,&,!\n,\%,@,\(,\),\*,#,:,~,\+]+)(\"|\')/ie", |
---|
| 1021 | "'href=\"$webserverURL/redirect.php?go='.@htmlentities(urlencode('http$4://$5$6'),ENT_QUOTES,\"$this->displayCharset\").'\" target=\"_blank\"'", $newBody); |
---|
| 1022 | |
---|
| 1023 | // create links for ftp sites |
---|
| 1024 | $newBody = preg_replace("/href=(\"|\')((ftp:\/\/)|(ftp\.))([\w\.,-.,\/.,\?.,\=.,&]+)(\"|\')/i", |
---|
| 1025 | "href=\"ftp://$4$5\" target=\"_blank\"", $newBody); |
---|
| 1026 | |
---|
| 1027 | // create links for inline images |
---|
| 1028 | $linkData = array ( |
---|
| 1029 | 'menuaction' => 'felamimail.uidisplay.displayImage', |
---|
| 1030 | 'uid' => $this->uid, |
---|
| 1031 | ); |
---|
| 1032 | $imageURL = $GLOBALS['egw']->link('/index.php', $linkData); |
---|
| 1033 | $newBody = preg_replace("/(\"|\')cid:(.*)(\"|\')/iUe", |
---|
| 1034 | "'\"$imageURL&cid='.base64_encode('$2').'&partID='.urlencode($this->partID).'\"'", $newBody); |
---|
| 1035 | |
---|
| 1036 | // create links for email addresses |
---|
| 1037 | $linkData = array |
---|
| 1038 | ( |
---|
| 1039 | 'menuaction' => 'felamimail.uicompose.compose' |
---|
| 1040 | ); |
---|
| 1041 | $link = $GLOBALS['egw']->link('/index.php',$linkData); |
---|
| 1042 | $newBody = preg_replace("/href=(\"|\')mailto:([\w,\-,\/,\?,\=,\.,&,!\n,\%,@,\*,#,:,~,\+]+)(\"|\')/ie", |
---|
| 1043 | "'href=\"$link&send_to='.base64_encode('$2').'\"'", $newBody); |
---|
| 1044 | #print "<pre>".htmlentities($newBody)."</pre><hr>"; |
---|
| 1045 | |
---|
| 1046 | $link = $GLOBALS['egw']->link('/index.php',$linkData); |
---|
| 1047 | #$newBody = preg_replace("/(?<!:)(?<=\s{1}|<)(([\w\.,-.,_.,0-9.]+)(@)([\w\.,-.,_.,0-9.]+))/ie", |
---|
| 1048 | $newBody = preg_replace("/(?<!:)(([\w\.,-.,_.,0-9.]+)(@)([\w\.,-.,_.,0-9.]+))/ie", |
---|
| 1049 | "'<a href=\"$link&send_to='.base64_encode('$0').'\"><font color=\"blue\">$0</font></a>'", $newBody); |
---|
| 1050 | } |
---|
| 1051 | $body .= $newBody; |
---|
| 1052 | #print "<hr><pre>$body</pre><hr>"; |
---|
| 1053 | } |
---|
| 1054 | |
---|
| 1055 | // create links for windows shares |
---|
| 1056 | // \\\\\\\\ == '\\' in real life!! :) |
---|
| 1057 | $body = preg_replace("/(\\\\\\\\)([\w,\\\\,-]+)/i", |
---|
| 1058 | "<a href=\"file:$1$2\" target=\"_blank\"><font color=\"blue\">$1$2</font></a>", $body); |
---|
| 1059 | |
---|
| 1060 | $body = preg_replace($nonDisplayAbleCharacters,'',$body); |
---|
| 1061 | |
---|
| 1062 | return $body; |
---|
| 1063 | } |
---|
| 1064 | |
---|
| 1065 | function printMessage() |
---|
| 1066 | { |
---|
| 1067 | $partID = $_GET['part']; |
---|
| 1068 | $transformdate =& CreateObject('felamimail.transformdate'); |
---|
| 1069 | $htmlFilter =& CreateObject('felamimail.htmlfilter'); |
---|
| 1070 | $uiWidgets =& CreateObject('felamimail.uiwidgets'); |
---|
| 1071 | // (regis) seems to be necessary to reopen... |
---|
| 1072 | $this->bofelamimail->reopen($this->mailbox); |
---|
| 1073 | # print "$this->mailbox, $this->uid, $partID<br>"; |
---|
| 1074 | $headers = $this->bofelamimail->getMessageHeader($this->uid, $partID); |
---|
| 1075 | $envelope = $this->bofelamimail->getMessageEnvelope($this->uid, $partID); |
---|
| 1076 | # _debug_array($headers);exit; |
---|
| 1077 | $rawheaders = $this->bofelamimail->getMessageRawHeader($this->uid, $partID); |
---|
| 1078 | $bodyParts = $this->bofelamimail->getMessageBody($this->uid,'',$partID); |
---|
| 1079 | $attachments = $this->bofelamimail->getMessageAttachments($this->uid,$partID); |
---|
| 1080 | # _debug_array($nextMessage); exit; |
---|
| 1081 | |
---|
| 1082 | $webserverURL = $GLOBALS['egw_info']['server']['webserver_url']; |
---|
| 1083 | |
---|
| 1084 | $nonDisplayAbleCharacters = array('[\016]','[\017]', |
---|
| 1085 | '[\020]','[\021]','[\022]','[\023]','[\024]','[\025]','[\026]','[\027]', |
---|
| 1086 | '[\030]','[\031]','[\032]','[\033]','[\034]','[\035]','[\036]','[\037]'); |
---|
| 1087 | |
---|
| 1088 | #print "<pre>";print_r($rawheaders);print"</pre>";exit; |
---|
| 1089 | |
---|
| 1090 | // add line breaks to $rawheaders |
---|
| 1091 | $newRawHeaders = explode("\n",$rawheaders); |
---|
| 1092 | reset($newRawHeaders); |
---|
| 1093 | |
---|
| 1094 | // find the Organization header |
---|
| 1095 | // the header can also span multiple rows |
---|
| 1096 | while(is_array($newRawHeaders) && list($key,$value) = each($newRawHeaders)) { |
---|
| 1097 | #print $value."<br>"; |
---|
| 1098 | if(preg_match("/Organization: (.*)/",$value,$matches)) { |
---|
| 1099 | $organization = $this->bofelamimail->decode_header(chop($matches[1])); |
---|
| 1100 | continue; |
---|
| 1101 | } |
---|
| 1102 | if(!empty($organization) && preg_match("/^\s+(.*)/",$value,$matches)) { |
---|
| 1103 | $organization .= $this->bofelamimail->decode_header(chop($matches[1])); |
---|
| 1104 | break; |
---|
| 1105 | } elseif(!empty($organization)) { |
---|
| 1106 | break; |
---|
| 1107 | } |
---|
| 1108 | } |
---|
| 1109 | |
---|
| 1110 | $this->bofelamimail->closeConnection(); |
---|
| 1111 | |
---|
| 1112 | $this->display_app_header(); |
---|
| 1113 | $this->t->set_file(array("displayMsg" => "view_message_printable.tpl")); |
---|
| 1114 | # $this->t->set_var('charset',$GLOBALS['egw']->translation->charset()); |
---|
| 1115 | |
---|
| 1116 | $this->t->set_block('displayMsg','message_main'); |
---|
| 1117 | # $this->t->set_block('displayMsg','message_main_attachment'); |
---|
| 1118 | $this->t->set_block('displayMsg','message_header'); |
---|
| 1119 | # $this->t->set_block('displayMsg','message_raw_header'); |
---|
| 1120 | # $this->t->set_block('displayMsg','message_navbar'); |
---|
| 1121 | $this->t->set_block('displayMsg','message_onbehalfof'); |
---|
| 1122 | $this->t->set_block('displayMsg','message_cc'); |
---|
| 1123 | $this->t->set_block('displayMsg','message_attachement_row'); |
---|
| 1124 | # $this->t->set_block('displayMsg','previous_message_block'); |
---|
| 1125 | # $this->t->set_block('displayMsg','next_message_block'); |
---|
| 1126 | $this->t->set_block('displayMsg','message_org'); |
---|
| 1127 | |
---|
| 1128 | # $this->t->egroupware_hack = False; |
---|
| 1129 | |
---|
| 1130 | $this->translate(); |
---|
| 1131 | |
---|
| 1132 | if($envelope['FROM'][0] != $envelope['SENDER'][0]) { |
---|
| 1133 | $senderAddress = $this->emailAddressToHTML($envelope['SENDER'], '', true, false); |
---|
| 1134 | $fromAddress = $this->emailAddressToHTML($envelope['FROM'], $organization, true, false); |
---|
| 1135 | $this->t->set_var("from_data",$senderAddress); |
---|
| 1136 | $this->t->set_var("onbehalfof_data",$fromAddress); |
---|
| 1137 | $this->t->parse('on_behalf_of_part','message_onbehalfof',True); |
---|
| 1138 | } else { |
---|
| 1139 | $fromAddress = $this->emailAddressToHTML($envelope['FROM'], $organization, true, false); |
---|
| 1140 | $this->t->set_var("from_data", $fromAddress); |
---|
| 1141 | $this->t->set_var('on_behalf_of_part',''); |
---|
| 1142 | } |
---|
| 1143 | |
---|
| 1144 | // parse the to header |
---|
| 1145 | $toAddress = $this->emailAddressToHTML($envelope['TO'], '', true, false); |
---|
| 1146 | $this->t->set_var("to_data",$toAddress); |
---|
| 1147 | |
---|
| 1148 | // parse the cc header |
---|
| 1149 | if(count($envelope['CC'])) { |
---|
| 1150 | $ccAddress = $this->emailAddressToHTML($envelope['CC'], '', true, false); |
---|
| 1151 | $this->t->set_var("cc_data",$ccAddress); |
---|
| 1152 | $this->t->parse('cc_data_part','message_cc',True); |
---|
| 1153 | } else { |
---|
| 1154 | $this->t->set_var("cc_data_part",''); |
---|
| 1155 | } |
---|
| 1156 | |
---|
| 1157 | $this->t->set_var("date_data", |
---|
| 1158 | @htmlspecialchars($GLOBALS['egw']->common->show_date(strtotime($headers['DATE'])), ENT_QUOTES,$this->displayCharset)); |
---|
| 1159 | $this->t->set_var("subject_data", |
---|
| 1160 | @htmlspecialchars($this->bofelamimail->decode_header(preg_replace($nonDisplayAbleCharacters, '', $envelope['SUBJECT'])), ENT_QUOTES, $this->displayCharset)); |
---|
| 1161 | |
---|
| 1162 | //if(isset($organization)) exit; |
---|
| 1163 | $this->t->parse("header","message_header",True); |
---|
| 1164 | |
---|
| 1165 | $this->t->set_var('body', $this->getdisplayableBody($bodyParts)); |
---|
| 1166 | |
---|
| 1167 | // attachments |
---|
| 1168 | if(is_array($attachments)) |
---|
| 1169 | $this->t->set_var('attachment_count',count($attachments)); |
---|
| 1170 | else |
---|
| 1171 | $this->t->set_var('attachment_count','0'); |
---|
| 1172 | |
---|
| 1173 | if (is_array($attachments) && count($attachments) > 0) { |
---|
| 1174 | $this->t->set_var('row_color',$this->rowColor[0]); |
---|
| 1175 | $this->t->set_var('name',lang('name')); |
---|
| 1176 | $this->t->set_var('type',lang('type')); |
---|
| 1177 | $this->t->set_var('size',lang('size')); |
---|
| 1178 | $this->t->set_var('url_img_save',$GLOBALS['egw']->common->image('felamimail','fileexport')); |
---|
| 1179 | #$this->t->parse('attachment_rows','attachment_row_bold',True); |
---|
| 1180 | foreach ($attachments as $key => $value) { |
---|
| 1181 | $this->t->set_var('row_color',$this->rowColor[($key+1)%2]); |
---|
| 1182 | $this->t->set_var('filename',@htmlentities($this->bofelamimail->decode_header($value['name']),ENT_QUOTES,$this->displayCharset)); |
---|
| 1183 | $this->t->set_var('mimetype',$value['mimeType']); |
---|
| 1184 | $this->t->set_var('size',$value['size']); |
---|
| 1185 | $this->t->set_var('attachment_number',$key); |
---|
| 1186 | |
---|
| 1187 | switch($value['mimeType']) |
---|
| 1188 | { |
---|
| 1189 | case 'message/rfc822': |
---|
| 1190 | $linkData = array |
---|
| 1191 | ( |
---|
| 1192 | 'menuaction' => 'felamimail.uidisplay.display', |
---|
| 1193 | 'uid' => $this->uid, |
---|
| 1194 | 'part' => $value['partID'] |
---|
| 1195 | ); |
---|
| 1196 | $windowName = 'displayMessage_'.$this->uid; |
---|
| 1197 | $linkView = "egw_openWindowCentered('".$GLOBALS['egw']->link('/index.php',$linkData)."','$windowName',700,egw_getWindowOuterHeight());"; |
---|
| 1198 | break; |
---|
| 1199 | case 'image/jpeg': |
---|
| 1200 | case 'image/png': |
---|
| 1201 | case 'image/gif': |
---|
| 1202 | #case 'application/pdf': |
---|
| 1203 | $linkData = array |
---|
| 1204 | ( |
---|
| 1205 | 'menuaction' => 'felamimail.uidisplay.getAttachment', |
---|
| 1206 | 'uid' => $this->uid, |
---|
| 1207 | 'part' => $value['partID'] |
---|
| 1208 | ); |
---|
| 1209 | $windowName = 'displayAttachment_'.$this->uid; |
---|
| 1210 | $linkView = "egw_openWindowCentered('".$GLOBALS['egw']->link('/index.php',$linkData)."','$windowName',800,600);"; |
---|
| 1211 | break; |
---|
| 1212 | default: |
---|
| 1213 | $linkData = array |
---|
| 1214 | ( |
---|
| 1215 | 'menuaction' => 'felamimail.uidisplay.getAttachment', |
---|
| 1216 | 'uid' => $this->uid, |
---|
| 1217 | 'part' => $value['partID'] |
---|
| 1218 | ); |
---|
| 1219 | $linkView = "window.location.href = '".$GLOBALS['egw']->link('/index.php',$linkData)."';"; |
---|
| 1220 | break; |
---|
| 1221 | } |
---|
| 1222 | $this->t->set_var("link_view",$linkView); |
---|
| 1223 | $this->t->set_var("target",$target); |
---|
| 1224 | |
---|
| 1225 | $linkData = array |
---|
| 1226 | ( |
---|
| 1227 | 'menuaction' => 'felamimail.uidisplay.getAttachment', |
---|
| 1228 | 'mode' => 'save', |
---|
| 1229 | 'uid' => $this->uid, |
---|
| 1230 | 'part' => $value['partID'] |
---|
| 1231 | ); |
---|
| 1232 | $this->t->set_var("link_save",$GLOBALS['egw']->link('/index.php',$linkData)); |
---|
| 1233 | |
---|
| 1234 | $this->t->parse('attachment_rows','message_attachement_row',True); |
---|
| 1235 | } |
---|
| 1236 | } |
---|
| 1237 | else |
---|
| 1238 | { |
---|
| 1239 | $this->t->set_var('attachment_rows',''); |
---|
| 1240 | } |
---|
| 1241 | |
---|
| 1242 | #$this->t->pparse("out","message_attachment_rows"); |
---|
| 1243 | |
---|
| 1244 | // print it out |
---|
| 1245 | # if(is_array($attachments)) { |
---|
| 1246 | # $this->t->pparse('out','message_main_attachment'); |
---|
| 1247 | # } else { |
---|
| 1248 | $this->t->pparse('out','message_main'); |
---|
| 1249 | # } |
---|
| 1250 | print "</body></html>"; |
---|
| 1251 | |
---|
| 1252 | } |
---|
| 1253 | |
---|
| 1254 | function saveMessage() |
---|
| 1255 | { |
---|
| 1256 | $partID = $_GET['part']; |
---|
| 1257 | // (regis) seems to be necessary to reopen... |
---|
| 1258 | $this->bofelamimail->reopen($this->mailbox); |
---|
| 1259 | |
---|
| 1260 | $message = $this->bofelamimail->getMessageRawBody($this->uid, $partID); |
---|
| 1261 | $headers = $this->bofelamimail->getMessageHeader($this->uid, $partID); |
---|
| 1262 | |
---|
| 1263 | $this->bofelamimail->closeConnection(); |
---|
| 1264 | |
---|
| 1265 | $GLOBALS['egw']->session->commit_session(); |
---|
| 1266 | |
---|
| 1267 | header ("Content-Type: message/rfc822; name=\"". $headers['SUBJECT'] .".eml\""); |
---|
| 1268 | header ("Content-Disposition: attachment; filename=\"". $headers['SUBJECT'] .".eml\""); |
---|
| 1269 | header("Expires: 0"); |
---|
| 1270 | // the next headers are for IE and SSL |
---|
| 1271 | header("Cache-Control: must-revalidate, post-check=0, pre-check=0"); |
---|
| 1272 | header("Pragma: public"); |
---|
| 1273 | |
---|
| 1274 | echo $message; |
---|
| 1275 | |
---|
| 1276 | $GLOBALS['egw']->common->egw_exit(); |
---|
| 1277 | exit; |
---|
| 1278 | } |
---|
| 1279 | |
---|
| 1280 | function showHeader() |
---|
| 1281 | { |
---|
| 1282 | if($this->bofelamimail->sessionData['showHeader'] == 'True') |
---|
| 1283 | { |
---|
| 1284 | $this->bofelamimail->sessionData['showHeader'] = 'False'; |
---|
| 1285 | } |
---|
| 1286 | else |
---|
| 1287 | { |
---|
| 1288 | $this->bofelamimail->sessionData['showHeader'] = 'True'; |
---|
| 1289 | } |
---|
| 1290 | $this->bofelamimail->saveSessionData(); |
---|
| 1291 | |
---|
| 1292 | $this->display(); |
---|
| 1293 | } |
---|
| 1294 | |
---|
| 1295 | function translate() |
---|
| 1296 | { |
---|
| 1297 | $this->t->set_var("lang_message_list",lang('Message List')); |
---|
| 1298 | $this->t->set_var("lang_to",lang('to')); |
---|
| 1299 | $this->t->set_var("lang_cc",lang('cc')); |
---|
| 1300 | $this->t->set_var("lang_bcc",lang('bcc')); |
---|
| 1301 | $this->t->set_var("lang_from",lang('from')); |
---|
| 1302 | $this->t->set_var("lang_reply_to",lang('reply to')); |
---|
| 1303 | $this->t->set_var("lang_subject",lang('subject')); |
---|
| 1304 | $this->t->set_var("lang_addressbook",lang('addressbook')); |
---|
| 1305 | $this->t->set_var("lang_search",lang('search')); |
---|
| 1306 | $this->t->set_var("lang_send",lang('send')); |
---|
| 1307 | $this->t->set_var("lang_back_to_folder",lang('back to folder')); |
---|
| 1308 | $this->t->set_var("lang_attachments",lang('attachments')); |
---|
| 1309 | $this->t->set_var("lang_add",lang('add')); |
---|
| 1310 | $this->t->set_var("lang_remove",lang('remove')); |
---|
| 1311 | $this->t->set_var("lang_priority",lang('priority')); |
---|
| 1312 | $this->t->set_var("lang_normal",lang('normal')); |
---|
| 1313 | $this->t->set_var("lang_high",lang('high')); |
---|
| 1314 | $this->t->set_var("lang_low",lang('low')); |
---|
| 1315 | $this->t->set_var("lang_signature",lang('signature')); |
---|
| 1316 | $this->t->set_var("lang_compose",lang('compose')); |
---|
| 1317 | $this->t->set_var("lang_date",lang('date')); |
---|
| 1318 | $this->t->set_var("lang_view",lang('view')); |
---|
| 1319 | $this->t->set_var("lang_organization",lang('organization')); |
---|
| 1320 | $this->t->set_var("lang_save",lang('save')); |
---|
| 1321 | $this->t->set_var("lang_printable",lang('print it')); |
---|
| 1322 | $this->t->set_var("lang_reply",lang('reply')); |
---|
| 1323 | $this->t->set_var("lang_reply_all",lang('reply all')); |
---|
| 1324 | $this->t->set_var("lang_forward",lang('forward')); |
---|
| 1325 | $this->t->set_var("lang_delete",lang('delete')); |
---|
| 1326 | $this->t->set_var("lang_previous_message",lang('previous message')); |
---|
| 1327 | $this->t->set_var("lang_next_message",lang('next message')); |
---|
| 1328 | $this->t->set_var("lang_organisation",lang('organisation')); |
---|
| 1329 | $this->t->set_var("lang_on_behalf_of",lang('on behalf of')); |
---|
| 1330 | $this->t->set_var("lang_Message", lang('Message')); |
---|
| 1331 | $this->t->set_var("lang_Attachment", lang('attachments')); |
---|
| 1332 | $this->t->set_var("lang_Header_Lines", lang('Header Lines')); |
---|
| 1333 | |
---|
| 1334 | $this->t->set_var("th_bg",$GLOBALS['egw_info']["theme"]["th_bg"]); |
---|
| 1335 | $this->t->set_var("bg01",$GLOBALS['egw_info']["theme"]["bg01"]); |
---|
| 1336 | $this->t->set_var("bg02",$GLOBALS['egw_info']["theme"]["bg02"]); |
---|
| 1337 | $this->t->set_var("bg03",$GLOBALS['egw_info']["theme"]["bg03"]); |
---|
| 1338 | } |
---|
| 1339 | } |
---|
| 1340 | |
---|
| 1341 | ?> |
---|