PageRenderTime 48ms CodeModel.GetById 21ms RepoModel.GetById 0ms app.codeStats 0ms

/modules/intranet_email/intra-email-read.php

https://github.com/timschofield/2.8
PHP | 280 lines | 210 code | 34 blank | 36 comment | 17 complexity | 7e1d7398b88b2a12b79d389ec2241808 MD5 | raw file
Possible License(s): LGPL-2.1, BSD-3-Clause, GPL-2.0
  1. <?php
  2. error_reporting(E_COMPILE_ERROR|E_ERROR|E_CORE_ERROR);
  3. require('./roots.php');
  4. require('../../include/helpers/inc_environment_global.php');
  5. /**
  6. * CARE2X Integrated Hospital Information System Deployment 2.1 - 2004-10-02
  7. * GNU General Public License
  8. * Copyright 2002,2003,2004,2005 Elpidio Latorilla
  9. * elpidio@care2x.org,
  10. *
  11. * See the file "copy_notice.txt" for the licence notice
  12. */
  13. define('MODULE','intranet_email');
  14. define('LANG_FILE_MODULAR','intranet_email.php');
  15. $local_user='ck_intra_email_user';
  16. require_once($root_path.'include/helpers/inc_front_chain_lang.php');
  17. $thisfile='intra-email-read.php';
  18. $dbtable='care_mail_private';
  19. //$db->debug=1;
  20. $linecount=0;
  21. $modetypes=array('sendmail','listmail');
  22. $breakfile="intra-email.php".URL_APPEND."&mode=listmail";
  23. switch($folder)
  24. {
  25. case 'inbox':$sql="SELECT * FROM $dbtable WHERE sender='$from'
  26. AND send_dt='$date'
  27. AND send_stamp='$s_stamp'"; break;
  28. case 'sent': $sql="SELECT * FROM $dbtable WHERE recipient='$from'
  29. AND send_dt='$date'
  30. AND send_stamp='$s_stamp'"; break;
  31. default: $sql="SELECT * FROM $dbtable WHERE ( sender='$from' OR recipient='$from' )
  32. AND send_dt='$date'
  33. AND send_stamp='$s_stamp'"; break;
  34. }
  35. if($ergebnis=$db->Execute($sql))
  36. {
  37. if($ergebnis->RecordCount())
  38. {
  39. $content=$ergebnis->FetchRow();
  40. // update user to tag the file as read
  41. if(!isset($read)||!$read)
  42. {
  43. $dbtable='care_mail_private_users';
  44. $sql="SELECT $folder, lastcheck FROM $dbtable WHERE email='".$_COOKIE[$local_user.$sid]."'";
  45. if($ergebnis=$db->Execute($sql))
  46. {
  47. if($ergebnis->RecordCount())
  48. {
  49. $result=$ergebnis->FetchRow();
  50. $inb=explode('_',trim($result[$folder]));
  51. for($i=0;$i<sizeof($inb);$i++)
  52. {
  53. $buf="t=$s_stamp&r=$read&f=$from&s=$subj&d=$date&z=$size";
  54. //echo "$buf<br>$inb[$i]<br>";
  55. if(!strcmp($buf,trim($inb[$i])))
  56. {
  57. $inb[$i]=str_replace('r=0','r=1',$inb[$i]);
  58. $result[$folder]=implode('_',$inb);
  59. $sql="UPDATE $dbtable SET $folder='".$result[$folder]."', lastcheck='".$result[lastcheck]."'
  60. WHERE email='".$_COOKIE[$local_user.$sid]."'";
  61. $db->BeginTrans();
  62. $ok=$db->Execute($sql);
  63. if($ok){
  64. $db->CommitTrans();
  65. } else {
  66. $db->RollbackTrans();
  67. echo "$LDDbNoUpdate<br>$sql";
  68. }
  69. }
  70. }
  71. }
  72. }else { echo "$LDDbNoRead<br>$sql"; }
  73. }// end of if !read
  74. } //end of if rows
  75. else
  76. {
  77. $mailok=0;
  78. }
  79. }else { echo "$LDDbNoRead<br>$sql"; }
  80. # Start Smarty templating here
  81. /**
  82. * LOAD Smarty
  83. */
  84. # Note: it is advisable to load this after the inc_front_chain_lang.php so
  85. # that the smarty script can use the user configured template theme
  86. require_once(CARE_BASE.'/include/helpers/smarty_care.class.php');
  87. $smarty = new smarty_care('common');
  88. # Title in toolbar
  89. $smarty->assign('sToolbarTitle',"$LDIntraEmail - $LDRead");
  90. $smarty->assign('LDBack', $LDBack);
  91. $smarty->assign('LDHelp', $LDHelp);
  92. $smarty->assign('LDClose', $LDClose);
  93. # href for help button
  94. $smarty->assign('pbHelp',CARE_GUI . "modules/" . MODULE . "/help/" . $lang . "/intramail.html");
  95. # href for close button
  96. $smarty->assign('breakfile',$breakfile);
  97. # Window bar title
  98. $smarty->assign('title',"$LDIntraEmail - $LDRead");
  99. # Collect extra javascript code
  100. ob_start();
  101. ?>
  102. <script language="javascript" >
  103. <!--
  104. function submitForm(r)
  105. {
  106. d=document.mailform;
  107. d.reply.value=r;
  108. d.submit();
  109. }
  110. function printer_v()
  111. {
  112. <?php $buf="&s_stamp=$content[send_stamp]&from=$content[sender]&date=".strtr($content['send_dt']," ","+")."&folder=$folder";
  113. ?>
  114. urlholder="intra-email-printer.php?sid=<?php echo "$sid&lang=$lang$buf"; ?>";
  115. <?php echo 'echowin'.$sid ?>=window.open(urlholder,"<?php echo 'echowin'.$sid ?>","width=700,height=600,menubar=no,resizable=yes,scrollbars=yes");
  116. //window.location.href=urlholder
  117. }
  118. // -->
  119. </script>
  120. <?php
  121. $sTemp = ob_get_contents();
  122. ob_end_clean();
  123. $smarty->append('JavaScript',$sTemp);
  124. # Start buffering page output
  125. ob_start();
  126. ?>
  127. <table width=100% border=0 height=100% cellpadding="0" cellspacing="0">
  128. <tr valign=top >
  129. <td valign=top colspan=2>
  130. <?php
  131. if(!isset($mode)) $mode='';
  132. echo '
  133. &nbsp; <b><a href="intra-email.php'.URL_APPEND.'&mode=listmail">'.$LDInbox.'</a> | <a href="intra-email.php'.URL_APPEND.'&mode=compose">'.$LDNewEmail.'</a> | <a href="intra-email-addrbook.php'.URL_APPEND.'&mode='.$mode.'&folder='.$folder.'">'.$LDAddrBook.'</a> | <a href="intra-email-options.php'.URL_APPEND.'">'.$LDOptions.'</a> | <a href="javascript:gethelp(\'intramail.php\',\'read\',\''.$mode.'\',\''.$folder.'\')">'.$LDHelp.'</a></b>
  134. <hr color=#000080>
  135. &nbsp; <FONT color="#800000">'.$_COOKIE[$local_user.$sid].'</font> &nbsp; &nbsp; &nbsp; &nbsp;&nbsp; &nbsp; &nbsp; &nbsp;
  136. <font size=1><a href="intra-email.php'.URL_APPEND.'&mode=listmail&l2h='.$l2h.'&folder='.$folder.'">
  137. <img '.createComIcon($root_path,'l_arrowgrnsm.gif','0','middle').'> '.$LDBack2.' ';
  138. switch($folder)
  139. {
  140. case 'inbox': echo $LDInbox; break;
  141. case 'sent': echo $LDSent; break;
  142. case 'drafts': echo $LDDrafts; break;
  143. case 'trash': echo $LDRecycle; break;
  144. }
  145. echo '</a></font>';
  146. // ******************************** Read email ***************************************
  147. if(1)
  148. {
  149. echo '<ul><form name="mailform" action="intra-email.php" method="post">
  150. <table border=0 cellspacing=1 cellpadding=3>
  151. <tr>
  152. <td bgcolor="#f9f9f9" align=right><FONT size=1 color="#000080">'.$LDFrom.':</td>
  153. <td bgcolor="#f9f9f9"><FONT size=1 >'.$content['sender'].'
  154. </td>
  155. </tr>
  156. <tr>
  157. <td bgcolor="#f9f9f9" align=right><FONT size=1 color="#000080">'.$LDReply2.':</td>
  158. <td bgcolor="#f9f9f9"><FONT size=1 >'.$content['reply2'].'
  159. </td>
  160. </tr>
  161. <tr>
  162. <td bgcolor="#f9f9f9" align=right><FONT size=1 color="#000080">'.$LDTo.':</td>
  163. <td bgcolor="#f9f9f9"><FONT size=1 >'.$content['recipient'].'
  164. </td>
  165. </tr>
  166. <td bgcolor="#f9f9f9" align=right><FONT size=1 color="#000080">'.$LDCC.' (CC)</td>
  167. <td bgcolor="#f9f9f9"><FONT size=1 >'.$content['cc'].'</td>
  168. </tr>
  169. <tr>
  170. <td bgcolor="#f9f9f9" align=right><FONT size=1 color="#000080">'.$LDBCC.' <a href="#" title="'.$LDBCCTxt.'"><font color=#0000ff><u>(BCC)</u></font></a></td>
  171. <td bgcolor="#f9f9f9"><FONT size=1 >'.$content['bcc'].'</td>
  172. </tr>
  173. <tr>
  174. <td bgcolor="#f9f9f9" align=right><FONT size=1 color="#000080">'.$LDSubject.':</td>
  175. <td bgcolor="#f9f9f9"><FONT size=1 >'.$content['subject'].'</td>
  176. </tr>';
  177. /*
  178. <tr>
  179. <td bgcolor="#f9f9f9" align=right><FONT size=1 color="#000080">Anhang:</td>
  180. <td bgcolor="#f9f9f9"><FONT size=1 color="#000080"><a href="#">Zeigen <img src="../img/bul_arrowgrnsm.gif" width=12 height=12 border=0 align=absmiddle></a></td>
  181. </tr>
  182. */
  183. echo '
  184. </table>
  185. <input type="hidden" name="sid" value="'.$sid.'">
  186. <input type="hidden" name="lang" value="'.$lang.'">
  187. <input type="hidden" name="mode" value="compose">
  188. <input type="hidden" name="recipient" value="'.$content['recipient'].'">
  189. <input type="hidden" name="sender" value="'.$content['sender'].'">
  190. <input type="hidden" name="reply2" value="'.$content['reply2'].'">
  191. <input type="hidden" name="send_dt" value="'.$content['send_dt'].'">
  192. <input type="hidden" name="send_stamp" value="'.$content['send_stamp'].'">
  193. <input type="hidden" name="folder" value="'.$folder.'">
  194. <input type="hidden" name="reply" value="0">';
  195. switch($folder)
  196. {
  197. case 'inbox': if($_COOKIE[$local_user.$sid]!=$content['sender'])
  198. { $inp=0; echo '<input type="button" value="'.$LDReply.'" onClick="submitForm(1)"> '; break; }
  199. else echo '<input type="button" value="'.$LDBack.'" onClick="window.location.href=\'intra-email.php'.URL_REDIRECT_APPEND.'&mode=listmail&folder=inbox&l2h='.$l2h.'\'"> '; break;
  200. case 'sent': if($_COOKIE[$local_user.$sid]!=$content['recipient'])
  201. { $inp=1; echo '<input type="button" value="'.$LDResend.'" onClick="submitForm(2)"> ';break; }
  202. else echo '<input type="button" value="'.$LDBack.'" onClick="window.location.href=\'intra-email.php'.URL_REDIRECT_APPEND.'&mode=listmail&folder=sent&l2h='.$l2h.'\'"> '; break;
  203. case 'drafts':$inp=1; echo '
  204. <input type="button" value="'.$LDNewEmail.'" onClick="submitForm(2)"> '; break;
  205. case 'trash':if($_COOKIE[$local_user.$sid]!=$content['recipient'])
  206. { $inp=1; echo ' <input type="button" value="'.$LDResend.'" onClick="submitForm(2)"> '; break;}
  207. else { $inp=0; echo ' <input type="button" value="'.$LDReplyAgain.'" onClick="submitForm(1)"> ';} break;
  208. }
  209. $buf="&t=$s_stamp&r=$read&f=$from&s=".strtr($subj," ","+")."&d=".strtr($date," ","+")."&z=$size";
  210. if($folder!="drafts") echo '
  211. <input type="button" value="'.$LDForward.'" onClick="submitForm(3)"> ';
  212. $buf="&t=$s_stamp&r=$read&f=$from&s=".strtr($subj," ","+")."&d=".strtr($date," ","+")."&z=$size";
  213. echo '
  214. <input type="button" value="'.$LDDelete.'" onClick="if(confirm(\''.$LDAskDeleteMail.'\')) window.location.href=\'intra-email-delete.php'.URL_REDIRECT_APPEND.'&maxrow=1&create=1&folder='.$folder.'&l2h='.$l2h.$buf.'\';">';
  215. echo '
  216. &nbsp; &nbsp; &nbsp; <a href="javascript:printer_v()" title="'.$LDClk4printer.'">'.$LDPrinterVersion.' <img '.createComIcon($root_path,'bul_arrowgrnsm.gif','0','bottom').'></a>
  217. </form>
  218. </ul>
  219. ';
  220. }
  221. ?>
  222. <p>
  223. </td>
  224. </tr>
  225. <tr>
  226. <td bgcolor="#ffffee" colspan=2 height=50% valign=top>
  227. <UL><p><br><pre>
  228. <?php
  229. echo nl2br($content['body']);
  230. ?>
  231. </pre>
  232. </ul>
  233. </td>
  234. </tr>
  235. </table>
  236. <?php
  237. $sTemp = ob_get_contents();
  238. ob_end_clean();
  239. # Assign to main template object
  240. $smarty->assign('sMainFrameBlockData',$sTemp);
  241. /**
  242. * show Template
  243. */
  244. $smarty->display(CARE_BASE . 'main/view/mainframe.tpl');
  245. ?>