email_editor.php 3.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112
  1. <?php // $Id$
  2. /*
  3. ==============================================================================
  4. Dokeos - elearning and course management software
  5. Copyright (c) 2006 Dokeos S.A.
  6. For a full list of contributors, see "credits.txt".
  7. The full license can be read in "license.txt".
  8. This program is free software; you can redistribute it and/or
  9. modify it under the terms of the GNU General Public License
  10. as published by the Free Software Foundation; either version 2
  11. of the License, or (at your option) any later version.
  12. See the GNU General Public License for more details.
  13. Contact: Dokeos, 44 rue des Palais, B-1030 Brussels, Belgium, info@dokeos.com
  14. ==============================================================================
  15. */
  16. /**
  17. * This script contains the code to edit and send an e-mail to one of
  18. * Dokeos' users.
  19. * It can be called from the JavaScript library email_links.lib.php which
  20. * overtakes the mailto: links to use the internal interface instead.
  21. * @author Yannick Warnier <ywarnier@beeznest.org>
  22. */
  23. // name of the language file that needs to be included
  24. $language_file = "index";
  25. require_once"../inc/global.inc.php";
  26. require_once"../inc/lib/usermanager.lib.php";
  27. if(empty($_user['user_id']))
  28. {
  29. api_not_allowed(true);
  30. }
  31. //api_protect_course_script(); //not a course script, so no protection
  32. if(empty($_SESSION['origin_url'])){
  33. $origin_url = $_SERVER['HTTP_REFERER'];
  34. api_session_register('origin_url');
  35. }
  36. /* Process the form and redirect to origin */
  37. if(!empty($_POST['submit_email']) && !empty($_POST['email_title']) && !empty($_POST['email_text']))
  38. {
  39. $text = Security::remove_XSS($_POST['email_text'])."\n\n---\n".get_lang('EmailSentFromDokeos')." ".api_get_path(WEB_PATH);
  40. $email_administrator=Security::remove_XSS($_POST['dest']);
  41. $user_id=api_get_user_id();
  42. $title=Security::remove_XSS($_POST['email_title']);
  43. $content=Security::remove_XSS($_POST['email_text']);
  44. if(!empty($_user['mail'])){
  45. api_send_mail($email_administrator,$title,$text,"From: ".$_user['mail']."\r\n");
  46. UserManager::send_message_in_outbox ($email_administrator,$user_id,$title, $content);
  47. }else{
  48. api_send_mail($email_administrator,$title,$text);
  49. }
  50. $orig = $_SESSION['origin_url'];
  51. api_session_unregister('origin_url');
  52. header('location:'.$orig);
  53. }
  54. /* Header */
  55. Display::display_header(get_lang('SendEmail'));
  56. ?>
  57. <table border="0">
  58. <form action="" method="POST">
  59. <input type="hidden" name="dest" value="<?php echo Security::remove_XSS($_REQUEST['dest']);?>" />
  60. <tr>
  61. <td>
  62. <label for="email_address"><?php echo get_lang('EmailDestination');?></label>
  63. </td>
  64. <td>
  65. <span id="email_address"><?php echo Security::remove_XSS($_REQUEST['dest']); ?></span>
  66. </td>
  67. </tr>
  68. <tr>
  69. <td>
  70. <label for="email_title"><?php echo get_lang('EmailTitle');?></label>
  71. </td>
  72. <td>
  73. <input name="email_title" id="email_title" value="<?php echo Security::remove_XSS($_POST['email_title']);?>" size="60"></input>
  74. </td>
  75. </tr>
  76. <tr>
  77. <td valign="top">
  78. <label for="email_text"><?php echo get_lang('EmailText');?></label>
  79. </td>
  80. <td>
  81. <?php
  82. echo '<textarea id="email_text" name="email_text" rows="10" cols="80">'.Security::remove_XSS($_POST['email_text']).'</textarea>';
  83. //htmlarea is not used otherwise we have to deal with HTML e-mail and all the related probs
  84. //api_disp_html_area('email_text',$_POST['email_text'],'250px');
  85. ?>
  86. </td>
  87. </tr>
  88. <tr>
  89. <td colspan="2">
  90. <button class="save" type="submit" name="submit_email" value="<?php echo get_lang('SendMail');?>"><?php echo get_lang('SendMail');?></button>
  91. </td>
  92. </tr>
  93. </form>
  94. </table>
  95. <?
  96. /* Footer */
  97. Display::display_footer();
  98. ?>