email_editor.php 3.1 KB

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