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

/modules/mail/admin/mail_message_view.php

https://gitlab.com/alexprowars/bitrix
PHP | 324 lines | 280 code | 36 blank | 8 comment | 25 complexity | f4757e8d42d510db3b15d5f4761cf22b MD5 | raw file
  1. <?php
  2. /*
  3. ##############################################
  4. # Bitrix: SiteManager #
  5. # Copyright (c) 2002 - 2004 Bitrix #
  6. # http://www.bitrixsoft.com #
  7. # mailto:admin@bitrixsoft.com #
  8. ##############################################
  9. */
  10. require_once($_SERVER["DOCUMENT_ROOT"]."/bitrix/modules/main/include/prolog_admin_before.php");
  11. require_once($_SERVER["DOCUMENT_ROOT"]."/bitrix/modules/mail/prolog.php");
  12. $MOD_RIGHT = $APPLICATION->GetGroupRight("mail");
  13. if($MOD_RIGHT<"R") $APPLICATION->AuthForm(GetMessage("ACCESS_DENIED"));
  14. IncludeModuleLangFile(__FILE__);
  15. require_once($_SERVER["DOCUMENT_ROOT"]."/bitrix/modules/mail/include.php");
  16. $err_mess = "File: ".__FILE__."<br>Line: ";
  17. ClearVars("str_");
  18. $ID = intval($ID);
  19. if($_SERVER["REQUEST_METHOD"]=="POST" && $_REQUEST["save_form"]=="Y" && $MOD_RIGHT>="W" && check_bitrix_sessid())
  20. {
  21. $dbr = CMailMessage::GetByID($ID);
  22. if($dbr_arr = $dbr->Fetch())
  23. {
  24. if($_REQUEST["MARK_AS_SPAM"]=="Y")
  25. {
  26. CMailMessage::MarkAsSpam($ID, true, $dbr_arr);
  27. }
  28. elseif($_REQUEST["MARK_AS_NOT_SPAM"]=="Y")
  29. {
  30. CMailMessage::MarkAsSpam($ID, false, $dbr_arr);
  31. }
  32. elseif(($_REQUEST["MARK_SPAM"]=="Y" || $_REQUEST["MARK_SPAM"]=="N"))
  33. {
  34. CMailMessage::MarkAsSpam($ID, $_REQUEST["MARK_SPAM"]=="Y", $dbr_arr);
  35. }
  36. if($_REQUEST["MANUAL_FILTER"] <> '')
  37. {
  38. CMailFilter::FilterMessage($ID, "M", ($_REQUEST["MANUAL_FILTER"]>0?$_REQUEST["MANUAL_FILTER"]:false));
  39. }
  40. if($_REQUEST["DELETE_MESSAGE"]=="Y")
  41. {
  42. CMailMessage::Delete($ID);
  43. }
  44. }
  45. if($_REQUEST["apply"] <> '')
  46. LocalRedirect($APPLICATION->GetCurPage()."?lang=".LANG."&ID=".$ID."#tb");
  47. elseif($_REQUEST["next"] <> '' || $_REQUEST["prev"] <> '')
  48. {
  49. $md5Path = md5("/bitrix/admin/mail_message_admin.php");
  50. $FILTER = $_SESSION["SESS_ADMIN"][$md5Path];
  51. $arFilter = Array(
  52. "ID"=>$FILTER["find_id"],
  53. "MAILBOX_ID"=>$FILTER["find_mailbox_id"],
  54. "SENDER"=>$FILTER["find_from"],
  55. "RECIPIENT"=>$FILTER["find_to"],
  56. "SUBJECT"=>$FILTER["find_subject"],
  57. "BODY"=>$FILTER["find_body"],
  58. "ALL"=>$FILTER["find_all"],
  59. "NEW_MESSAGE"=>$FILTER["find_new"],
  60. "SPAM"=>$FILTER["find_spam"]
  61. );
  62. if($_REQUEST["next"] <> '')
  63. $arFilter[">ID"] = $ID;
  64. else
  65. $arFilter["<ID"] = $ID;
  66. $mailmessages = CMailMessage::GetList(Array("ID"=>($_REQUEST["next"] <> ''?"asc":"desc")), $arFilter);
  67. if($arr = $mailmessages->Fetch())
  68. LocalRedirect($APPLICATION->GetCurPage()."?lang=".LANG."&ID=".$arr["ID"]."#tb");
  69. }
  70. LocalRedirect("/bitrix/admin/mail_message_admin.php?lang=".LANG);
  71. }
  72. if($ID<=0 && $_REQUEST["MSG_ID"]!='')
  73. $dbr = CMailMessage::GetList(array(), array("MSG_ID"=>$_REQUEST["MSG_ID"]));
  74. else
  75. $dbr = CMailMessage::GetByID($ID);
  76. if($dbr_arr = $dbr->ExtractFields("str_")):
  77. $dbr_arr["SPAM_RATING"] = CMailMessage::GetSpamRating($ID, $dbr_arr);
  78. if($dbr_arr["NEW_MESSAGE"]=="Y")
  79. CMailMessage::Update($ID, Array("NEW_MESSAGE"=>"N"));
  80. if($_REQUEST['show']=='original' && COption::GetOptionString("mail", "save_src", B_MAIL_SAVE_SRC)=="Y")
  81. {
  82. echo "<pre>".htmlspecialcharsbx($dbr_arr["FULL_TEXT"])."</pre>";
  83. die();
  84. }
  85. $APPLICATION->SetTitle(GetMessage("MAIL_MSG_VIEW_TITLE"));
  86. require($_SERVER["DOCUMENT_ROOT"].BX_ROOT."/modules/main/include/prolog_admin_after.php");
  87. $aMenu = array(
  88. array(
  89. "ICON" => "btn_list",
  90. "TEXT"=>GetMessage("MAIL_MSG_VIEW_BACK_LINK"),
  91. "LINK"=>"mail_message_admin.php?lang=".LANG
  92. )
  93. );
  94. $context = new CAdminContextMenu($aMenu);
  95. $context->Show();
  96. $aTabs = array(
  97. array("DIV" => "edit1", "TAB" => GetMessage("MAIL_MSG_MESSAGE"), "ICON"=>"main_user_edit", "TITLE"=>GetMessage("MAIL_MSG_VIEW_TITLE")),
  98. );
  99. $tabControl = new CAdminTabControl("tabControl", $aTabs);
  100. ?>
  101. <form method="POST" action="<?echo $APPLICATION->GetCurPage()?>">
  102. <?=bitrix_sessid_post()?>
  103. <input type="hidden" name="lang" value="<?echo LANG?>">
  104. <input type="hidden" name="ID" value="<?echo $ID?>">
  105. <a name="tb"></a>
  106. <?$tabControl->Begin();?>
  107. <?$tabControl->BeginNextTab();?>
  108. <tr>
  109. <td width="40%"><?echo GetMessage("MAIL_MSG_VIEW_DATE")?></td>
  110. <td width="60%"><?=$str_FIELD_DATE?></td>
  111. </tr>
  112. <?if($dbr_arr["FIELD_FROM"] <> ''):?>
  113. <tr>
  114. <td><?echo GetMessage("MAIL_MSG_VIEW_FROM")?></td>
  115. <td><?=TxtToHTML($dbr_arr["FIELD_FROM"])?></td>
  116. </tr>
  117. <?endif?>
  118. <?if($dbr_arr["FIELD_TO"] <> ''):?>
  119. <tr>
  120. <td><?echo GetMessage("MAIL_MSG_VIEW_TO")?></td>
  121. <td><?=TxtToHTML($dbr_arr["FIELD_TO"])?></td>
  122. </tr>
  123. <?endif?>
  124. <?if($dbr_arr["FIELD_CC"] <> ''):?>
  125. <tr>
  126. <td><?echo GetMessage("MAIL_MSG_VIEW_CC")?></td>
  127. <td><?=TxtToHTML($dbr_arr["FIELD_CC"])?></td>
  128. </tr>
  129. <?endif?>
  130. <?if($dbr_arr["FIELD_BCC"] <> ''):?>
  131. <tr>
  132. <td><?echo GetMessage("MAIL_MSG_VIEW_BCC")?></td>
  133. <td><?=TxtToHTML($dbr_arr["FIELD_BCC"])?></td>
  134. </tr>
  135. <?endif?>
  136. <tr>
  137. <td><?echo GetMessage("MAIL_MSG_VIEW_SUBJECT")?></td>
  138. <td>
  139. <script>
  140. function hideshowhdr()
  141. {
  142. var d = BX('msghdr');
  143. if(d.style.display=='none')
  144. d.style.display = '';
  145. else
  146. d.style.display = 'none';
  147. }
  148. </script>
  149. <table width="100%"><tr>
  150. <td width="80%"><?=TxtToHTML($dbr_arr["SUBJECT"])?></td>
  151. <td width="20%" nowrap><a href="javascript:void(0)" onclick="hideshowhdr()" title="<?echo GetMessage("MMV_SHOW_HEADER_TITLE")?>"><?echo GetMessage("MMV_SHOW_HEADER")?></a><?if(COption::GetOptionString("mail", "save_src", B_MAIL_SAVE_SRC)=="Y" && $dbr_arr["FULL_TEXT"]!=''):?> | <a href="/bitrix/admin/mail_message_view.php?lang=<?=LANGUAGE_ID?>&amp;ID=<?=intval($ID)?>&amp;show=original" target="_blank" title="<?echo GetMessage("MMV_SHOW_ORIG_TITLE")?>"><?echo GetMessage("MMV_SHOW_ORIG")?></a><?endif?></td>
  152. </tr></table>
  153. </td>
  154. </tr>
  155. <tr style="display:none" id="msghdr">
  156. <td><?=GetMessage("MMV_SHOW_HEADER")?>:</td>
  157. <td><?=nl2br(htmlspecialcharsbx($dbr_arr["HEADER"]))?>
  158. </td>
  159. </tr>
  160. <?
  161. function _ConvReplies($str1, $str2)
  162. {
  163. $str2 = str_replace('\"', '"', $str2);
  164. if (mb_substr_count($str1, '&gt;') % 2 == 1)
  165. $clr = "#770000";
  166. else
  167. $clr = "#CC9933";
  168. return '<font color="'.$clr.'">'.$str1.$str2.'';
  169. }
  170. ?>
  171. <tr>
  172. <td colspan="2" style="background: white; padding: 15px; ">
  173. <?=preg_replace_callback(
  174. '/(^|\n)[\s]*([A-Za-z]*(&gt;)+)([^\n]+)/',
  175. function ($m)
  176. {
  177. return _ConvReplies($m[2], $m[4]);
  178. },
  179. txtToHtml($dbr_arr['BODY'])
  180. ) ?>
  181. </td>
  182. </tr>
  183. <?
  184. if($dbr_arr["ATTACHMENTS"]>0):
  185. $dbr_attach = CMailAttachment::GetList(Array("NAME"=>"ASC", "ID"=>"ASC"), Array("MESSAGE_ID"=>$dbr_arr["ID"]));
  186. ?>
  187. <tr>
  188. <td><?echo GetMessage("MAIL_MSG_VIEW_ATTACHMENTS")?></td>
  189. <td>
  190. <?while($dbr_attach_arr = $dbr_attach->GetNext()):?>
  191. <a target="_blank" href="mail_attachment_view.php?lang=<?=LANG?>&amp;ID=<?=$dbr_attach_arr["ID"]?>"><?=($dbr_attach_arr["FILE_NAME"] <> ''?$dbr_attach_arr["FILE_NAME"]:GetMessage("MAIL_MSG_VIEW_NNM"))?></a> (<?
  192. echo CFile::FormatSize($dbr_attach_arr["FILE_SIZE"]);
  193. ?>)<br>
  194. <?endwhile?>
  195. </td>
  196. </tr>
  197. <?endif?>
  198. <tr>
  199. <td><?echo GetMessage("MAIL_MSG_VIEW_STATUS")?></td>
  200. <td>
  201. <?if($dbr_arr["SPAM"]=="Y"):?>
  202. <?if($dbr_arr["NEW_MESSAGE"]!="Y"):?>
  203. <div class="mail-message-spam" title="<?echo GetMessage("MAIL_MSG_VIEW_READ_SPAM")?>"></div> <?echo GetMessage("MAIL_MSG_VIEW_READ_SPAM")?>
  204. <?else:?>
  205. <div class="mail-message-unread-spam" title="<?echo GetMessage("MAIL_MSG_VIEW_NOTREAD_SPAM")?>"></div> <?echo GetMessage("MAIL_MSG_VIEW_NOTREAD_SPAM")?>
  206. <?endif?>
  207. <?elseif($dbr_arr["SPAM"]=="N"):?>
  208. <?if($dbr_arr["NEW_MESSAGE"]!="Y"):?>
  209. <div class="mail-message-notspam" title="<?echo GetMessage("MAIL_MSG_VIEW_READ_NOTSPAM")?>"></div>
  210. <?else:?>
  211. <div class="mail-message-unread-notspam" title="<?echo GetMessage("MAIL_MSG_VIEW_NOTREAD_NOTSPAM")?>"></div>
  212. <?endif?>
  213. <?else:?>
  214. <?if($dbr_arr["NEW_MESSAGE"]!="Y"):?>
  215. <div class="mail-message" title="<?echo GetMessage("MAIL_MSG_VIEW_READ")?>"></div> <?echo GetMessage("MAIL_MSG_VIEW_READ_NOSTATUS")?>
  216. <?else:?>
  217. <div class="mail-message-unread" title="<?echo GetMessage("MAIL_MSG_VIEW_NOTREAD_STATUS")?>"></div> <?echo GetMessage("MAIL_MSG_VIEW_NOTREAD_NOSTATUS")?>
  218. <?endif?>
  219. <?endif?>
  220. <span title="<?=htmlspecialcharsbx(preg_replace('/(.?) ([.0-9]+) ([0-9]+) ([0-9]+)/', '\\1 = \\2% (\\3 bad, \\4 good)', $dbr_arr["SPAM_WORDS"]))?>">
  221. (<?echo GetMessage("MAIL_MSG_VIEW_SPAM_PROB")?> <?=$dbr_arr["SPAM_RATING"]?>%)
  222. </span>
  223. </td>
  224. </tr>
  225. <?if($dbr_arr["SPAM"]=="Y"):?>
  226. <tr>
  227. <td><?echo GetMessage("MAIL_MSG_VIEW_MARK_AS_NOTSPAM")?></td>
  228. <td><input type="checkbox" name="MARK_AS_NOT_SPAM" value="Y"></td>
  229. </tr>
  230. <?elseif($dbr_arr["SPAM"]=="N"):?>
  231. <tr>
  232. <td><?echo GetMessage("MAIL_MSG_VIEW_MARK_AS_SPAM")?></td>
  233. <td><input type="checkbox" name="MARK_AS_SPAM" value="Y"></td>
  234. </tr>
  235. <?else:?>
  236. <tr>
  237. <td class="adm-detail-valign-top"><?echo GetMessage("MAIL_MSG_VIEW_SPAM_LEARN")?></td>
  238. <td>
  239. <input type="radio" name="MARK_SPAM" value="?" id="MARK_SPAM_1" checked><label for="MARK_SPAM_1"><?echo GetMessage("MAIL_MSG_VIEW_SPAM_NOTLEARN")?></label><br>
  240. <input type="radio" name="MARK_SPAM" value="Y" id="MARK_SPAM_2"><label for="MARK_SPAM_2"><?echo GetMessage("MAIL_MSG_VIEW_ACT_MARK_AS_SPAM")?></label><br>
  241. <input type="radio" name="MARK_SPAM" value="N" id="MARK_SPAM_3"><label for="MARK_SPAM_3"><?echo GetMessage("MAIL_MSG_VIEW_ACT_MARK_AS_NOTSPAM")?></label><br>
  242. </td>
  243. </tr>
  244. <?endif?>
  245. <tr>
  246. <td><?echo GetMessage("MAIL_MSG_VIEW_ACT_RULE")?></td>
  247. <td>
  248. <select name="MANUAL_FILTER">
  249. <option value=""><?echo GetMessage("MAIL_MSG_VIEW_ACT_RULE_NOT")?></option>
  250. <option value="all"><?echo GetMessage("MAIL_MSG_VIEW_ACT_RULE_ALL")?></option>
  251. <?
  252. $res = CMailFilter::GetList(Array("NAME"=>"ASC"), Array("ACTIVE"=>"Y", "WHEN_MANUALLY_RUN"=>"Y", "MAILBOX_ID"=>$dbr_arr["MAILBOX_ID"]));
  253. while($flt_arr = $res->Fetch()):
  254. ?><option value="<?=htmlspecialcharsbx($flt_arr['ID']) ?>"><?=htmlspecialcharsbx($flt_arr["NAME"])?> [<?=htmlspecialcharsbx($flt_arr["ID"])?>]</option><?
  255. endwhile?>
  256. </select>
  257. </td>
  258. </tr>
  259. <tr>
  260. <td><?echo GetMessage("MAIL_MSG_VIEW_ACT_RULE_DELETE")?></td>
  261. <td><input type="checkbox" name="DELETE_MESSAGE" value="Y"></td>
  262. </tr>
  263. <tr class="heading"><td colspan="2"><?=GetMessage("MAIL_MSG_VIEW_LOG")?></td></tr>
  264. <tr>
  265. <td colspan="2" align="center">
  266. <?$ml_res = CMailLog::GetList(Array("ID"=>"ASC"), Array("MESSAGE_ID"=>$ID));?>
  267. <select style="width:80%;" size="5">
  268. <?while($arr_log = $ml_res->GetNext()):?>
  269. <option>(<?=$arr_log["DATE_INSERT"]?>) <?=$arr_log["MESSAGE_TEXT"]?></option>
  270. <?endwhile;?>
  271. </select>
  272. </td>
  273. </tr>
  274. <?$tabControl->Buttons();?>
  275. <input type="hidden" name="save_form" value="Y">
  276. <input <?if ($MOD_RIGHT<"W") echo "disabled" ?> type="submit" name="save" class="adm-btn-save" value="<?echo GetMessage("MAIL_MSG_VIEW_SAVE")?>">
  277. &nbsp;<input <?if ($MOD_RIGHT<"W") echo "disabled" ?> type="submit" name="apply" value="<?echo GetMessage("MAIL_MSG_VIEW_APPLY")?>">
  278. &nbsp;<input <?if ($MOD_RIGHT<"W") echo "disabled" ?> type="submit" name="prev" value="&lt;&lt;" title="<?echo GetMessage("MAIL_MSG_VIEW_SAVE_PREV")?>">
  279. &nbsp;<input <?if ($MOD_RIGHT<"W") echo "disabled" ?> type="submit" name="next" value="&gt;&gt;" title="<?echo GetMessage("MAIL_MSG_VIEW_SAVE_NEXT")?>">
  280. <?$tabControl->End();?>
  281. </form>
  282. <?
  283. else:
  284. $APPLICATION->SetTitle(GetMessage("MAIL_MSG_VIEW_TITLE"));
  285. require($_SERVER["DOCUMENT_ROOT"].BX_ROOT."/modules/main/include/prolog_admin_after.php");
  286. CAdminMessage::ShowMessage(GetMessage("MAIL_MSG_NOTFOUND"));
  287. endif;
  288. require($_SERVER["DOCUMENT_ROOT"].BX_ROOT."/modules/main/include/epilog_admin.php");?>