PostfixAdmin - web based virtual user administration interface for Postfix mail servers https://postfixadmin.github.io/postfixadmin/
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

110 lines
3.1 KiB

  1. <?php
  2. /**
  3. * Postfix Admin
  4. *
  5. * LICENSE
  6. * This source file is subject to the GPL license that is bundled with
  7. * this package in the file LICENSE.TXT.
  8. *
  9. * Further details on the project are available at :
  10. * http://www.postfixadmin.com or http://postfixadmin.sf.net
  11. *
  12. * @version $Id$
  13. * @license GNU GPL v2 or later.
  14. *
  15. * File: vacation.php
  16. * Used by users to set/change their vacation settings.
  17. *
  18. * Template File: users_vacation.php
  19. *
  20. * Template Variables:
  21. *
  22. * tMessage
  23. * tSubject
  24. * tBody
  25. *
  26. * Form POST \ GET Variables:
  27. *
  28. * fSubject
  29. * fBody
  30. * fAway
  31. * fBack
  32. */
  33. require_once('../common.php');
  34. authentication_require_role('user');
  35. $USERID_USERNAME = authentication_get_username();
  36. // is vacation support enabled in $CONF ?
  37. if($CONF['vacation'] == 'NO') {
  38. header("Location: " . $CONF['postfix_admin_url'] . "/users/main.php");
  39. exit(0);
  40. }
  41. $vh = new VacationHandler(authentication_get_username());
  42. if ($_SERVER['REQUEST_METHOD'] == "GET")
  43. {
  44. $tSubject = '';
  45. $tBody = '';
  46. $details = $vh->get_details();
  47. if($details != false) {
  48. $tSubject = $details['subject'];
  49. $tBody = $details['body'];
  50. }
  51. if($vh->check_vacation()) {
  52. $tMessage = $PALANG['pUsersVacation_welcome_text'];
  53. }
  54. if ($tSubject == '') { $tSubject = html_entity_decode($PALANG['pUsersVacation_subject_text'], ENT_QUOTES, 'UTF-8'); }
  55. if ($tBody == '') { $tBody = html_entity_decode($PALANG['pUsersVacation_body_text'], ENT_QUOTES, 'UTF-8'); }
  56. }
  57. if ($_SERVER['REQUEST_METHOD'] == "POST")
  58. {
  59. if(isset($_POST['fCancel'])) {
  60. header("Location: main.php");
  61. exit(0);
  62. }
  63. if (isset ($_POST['fSubject'])) $fSubject = $_POST['fSubject'];
  64. if (isset ($_POST['fBody'])) $fBody = $_POST['fBody'];
  65. if (isset ($_POST['fAway'])) $fAway = escape_string ($_POST['fAway']);
  66. if (isset ($_POST['fBack'])) $fBack = escape_string ($_POST['fBack']);
  67. //set a default, reset fields for coming back selection
  68. if ($tSubject == '') { $tSubject = html_entity_decode($PALANG['pUsersVacation_subject_text'], ENT_QUOTES, 'UTF-8'); }
  69. if ($tBody == '') { $tBody = html_entity_decode($PALANG['pUsersVacation_body_text'], ENT_QUOTES, 'UTF-8'); }
  70. // if they've set themselves away OR back, delete any record of vacation emails.
  71. // the user is going away - set the goto alias and vacation table as necessary.
  72. if (!empty ($fAway))
  73. {
  74. if(!$vh->set_away($fSubject, $fBody)) {
  75. $error = 1;
  76. $tMessage = $PALANG['pUsersVacation_result_error'];
  77. }
  78. flash_info($PALANG['pVacation_result_added']);
  79. header ("Location: main.php");
  80. exit;
  81. }
  82. if (!empty ($fBack)) {
  83. $vh->remove();
  84. $tMessage = $PALANG['pUsersVacation_result_success'];
  85. flash_info($tMessage);
  86. header ("Location: main.php");
  87. exit;
  88. }
  89. }
  90. include ("../templates/header.php");
  91. include ("../templates/users_menu.php");
  92. include ("../templates/users_vacation.php");
  93. include ("../templates/footer.php");
  94. /* vim: set expandtab softtabstop=4 tabstop=4 shiftwidth=4: */
  95. ?>