email_editor.php 3.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107
  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. include_once("../inc/global.inc.php");
  26. if(empty($_user['user_id']))
  27. {
  28. api_not_allowed(true);
  29. }
  30. //api_protect_course_script(); //not a course script, so no protection
  31. if(empty($_SESSION['origin_url'])){
  32. $origin_url = $_SERVER['HTTP_REFERER'];
  33. api_session_register('origin_url');
  34. }
  35. /* Process the form and redirect to origin */
  36. if(!empty($_POST['submit_email']) && !empty($_POST['email_title']) && !empty($_POST['email_text']))
  37. {
  38. $text = $_POST['email_text']."\n\n---\n".get_lang('EmailSentFromDokeos')." ".api_get_path(WEB_PATH);
  39. if(!empty($_user['mail'])){
  40. api_send_mail($_POST['dest'],$_POST['email_title'],$text,"From: ".$_user['mail']."\r\n");
  41. }else{
  42. api_send_mail($_POST['dest'],$_POST['email_title'],$text);
  43. }
  44. $orig = $_SESSION['origin_url'];
  45. api_session_unregister('origin_url');
  46. header('location:'.$orig);
  47. }
  48. /* Header */
  49. Display::display_header(get_lang('SendEmail'));
  50. ?>
  51. <table border="0">
  52. <form action="" method="POST">
  53. <input type="hidden" name="dest" value="<?php echo $_REQUEST['dest'];?>" />
  54. <tr>
  55. <td>
  56. <label for="email_address"><?php echo get_lang('EmailDestination');?></label>
  57. </td>
  58. <td>
  59. <span id="email_address"><?php echo $_REQUEST['dest']; ?></span>
  60. </td>
  61. </tr>
  62. <tr>
  63. <td>
  64. <label for="email_title"><?php echo get_lang('EmailTitle');?></label>
  65. </td>
  66. <td>
  67. <input name="email_title" id="email_title" value="<?php echo $_POST['email_title'];?>" size="60"></input>
  68. </td>
  69. </tr>
  70. <tr>
  71. <td valign="top">
  72. <label for="email_text"><?php echo get_lang('EmailText');?></label>
  73. </td>
  74. <td>
  75. <?php
  76. echo '<textarea id="email_text" name="email_text" rows="10" cols="80">'.$_POST['email_text'].'</textarea>';
  77. //htmlarea is not used otherwise we have to deal with HTML e-mail and all the related probs
  78. //api_disp_html_area('email_text',$_POST['email_text'],'250px');
  79. ?>
  80. </td>
  81. </tr>
  82. <tr>
  83. <td colspan="2">
  84. <input type="submit" name="submit_email" value="<?php echo get_lang('Send');?>" />
  85. </td>
  86. </tr>
  87. </form>
  88. </table>
  89. <?
  90. /* Footer */
  91. Display::display_footer();
  92. ?>