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.

postfixadmin_vacation.php 6.2KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141
  1. <?php
  2. require_once(dirname(__FILE__) . '/common.php');
  3. $xmlrpc = get_xmlrpc();
  4. $vacation = $xmlrpc->getProxy('vacation');
  5. $VACCONFTXT = _("I will be away from <date> until <date>. For urgent matters you can contact <contact person>.");
  6. bindtextdomain('squirrelmail', SM_PATH . 'locale');
  7. textdomain('squirrelmail');
  8. $VACCONF = <<<EOM
  9. $VACCONFTXT
  10. EOM;
  11. do_header();
  12. $USERID_USERNAME = $username;
  13. $tmp = preg_split('/@/', $USERID_USERNAME);
  14. $USERID_DOMAIN = $tmp[1];
  15. if ($_SERVER['REQUEST_METHOD'] == "GET") {
  16. $details = $vacation->getDetails();
  17. if ($vacation->checkVacation()) {
  18. bindtextdomain('postfixadmin', SM_PATH . 'plugins/postfixadmin/locale');
  19. textdomain('postfixadmin');
  20. $tMessage = _("You already have an auto response configured!");
  21. bindtextdomain('squirrelmail', SM_PATH . 'locale');
  22. textdomain('squirrelmail');
  23. bindtextdomain('postfixadmin', SM_PATH . 'plugins/postfixadmin/locale');
  24. textdomain('postfixadmin');
  25. echo "<table bgcolor=\"#b8cbdc\" align=\"center\" width=\"95%\" cellpadding=\"1\" cellspacing=\"0\" border=\"0\"><tr>
  26. <td align=\"center\"><b>". _("Options") ." - ". _("Auto Response") ."</b>
  27. <table align=\"center\" width=\"100%\" cellpadding=\"5\" cellspacing=\"0\" border=\"0\">
  28. <tr><td bgcolor=\"$color[4]\" align=\"center\"><br>
  29. <table align=\"center\" width=\"70%\" cellpadding=\"4\" cellspacing=\"0\" border=\"0\"><tr>
  30. <td bgcolor=\"$color[3]\" align=\"center\"><b>". _("Auto Response") ."\n
  31. </b></td></tr><tr>
  32. <td bgcolor=\"$color[0]\" align=\"center\"><form name=\"vacation\" method=\"post\">
  33. <table width=\"95%\" border=\"0\" cellspacing=\"0\" cellpadding=\"2\">
  34. <tr>
  35. <td><center>$tMessage<p></center></td>
  36. </tr>
  37. <tr>
  38. <td> <div align=\"center\">
  39. <input type=\"submit\" name=\"fBack\" value=\"" . _("Coming Back"). "\" />
  40. </div></td>
  41. </tr>
  42. </table>
  43. <TT></TT></FORM>
  44. </td>
  45. </tr><tr><td bgcolor=\"$color[4]\" align=\"left\">&nbsp;</td>
  46. </tr></table><BR></td></tr></table></td></tr></table>";
  47. bindtextdomain('squirrelmail', SM_PATH . 'locale');
  48. textdomain('squirrelmail');
  49. } else {
  50. $tSubject = "Out of Office";
  51. $tSubject = $details['subject'];
  52. $VACCONF = $details['body'];
  53. $tMessage = '';
  54. bindtextdomain('postfixadmin', SM_PATH . 'plugins/postfixadmin/locale');
  55. textdomain('postfixadmin');
  56. echo "<table bgcolor=\"$color[0]\" align=\"center\" width=\"95%\" cellpadding=\"1\" cellspacing=\"0\" border=\"0\">
  57. <tr>
  58. <td align=\"center\"><b>". _("Options") ." - ". _("Auto Response") ." </b>
  59. <table align=\"center\" width=\"100%\" cellpadding=\"5\" cellspacing=\"0\" border=\"0\">
  60. <tr><td bgcolor=\"$color[4]\" align=\"center\"><br>
  61. <table align=\"center\" width=\"70%\" cellpadding=\"4\" cellspacing=\"0\" border=\"0\"><tr>
  62. <td bgcolor=\"$color[3]\" align=\"center\"><b>" . _("Auto Response") ."\n
  63. </b></td></tr><tr>
  64. <td bgcolor=\"$color[0]\" align=\"center\"><form name=\"vacation\" method=\"post\">$tMessage
  65. <table width=\"95%\" border=\"0\" cellspacing=\"0\" cellpadding=\"2\"><tr>
  66. <td width=\"23%\">". _("Subject") .":\n</td>
  67. <td width=\"2%\">&nbsp;</td>
  68. <td width=\"69%\"><input type=\"text\" name=\"fSubject\" value=\"" . $tSubject . "\" /></td>
  69. <td width=\"2%\">&nbsp;</td>
  70. <td width=\"4%\">&nbsp;</td>
  71. </tr><tr>
  72. <td>". _("Body") .":\n</td>
  73. <td>&nbsp;</td>
  74. <td><textarea rows=\"10\" cols=\"80\" name=\"fBody\">$VACCONF\n
  75. </textarea></td><td>&nbsp;</td><td>&nbsp;</td></tr><tr><td>&nbsp;</td><td>&nbsp;</td>
  76. <td><input type=\"submit\" name=\"fAway\" value=\"" . _("Going Away") . "\" /></td>
  77. <td>&nbsp;</td><td>&nbsp;</td></tr>
  78. </table><TT></TT></FORM></td>
  79. </tr><tr><td bgcolor=\"$color[4]\" align=\"left\">&nbsp;</td>
  80. </tr></table><BR></td></tr></table></td></tr></table>";
  81. bindtextdomain('squirrelmail', SM_PATH . 'locale');
  82. textdomain('squirrelmail');
  83. }
  84. }
  85. if ($_SERVER['REQUEST_METHOD'] == "POST") {
  86. $fBack = null;
  87. $fAway = null;
  88. foreach (array('fBack', 'fAway', 'fSubject', 'fBody') as $key) {
  89. $$key = null;
  90. if (isset($_POST[$key])) {
  91. $$key = $_POST[$key];
  92. }
  93. }
  94. if (!empty($fBack)) {
  95. $success = $vacation->remove();
  96. if (!$success) {
  97. bindtextdomain('postfixadmin', SM_PATH . 'plugins/postfixadmin/locale');
  98. textdomain('postfixadmin');
  99. $tMessage = _("Unable to update your auto response settings!");
  100. echo "<p>This may signify an error; please contact support (1)</p>";
  101. bindtextdomain('squirrelmail', SM_PATH . 'locale');
  102. textdomain('squirrelmail');
  103. } else {
  104. bindtextdomain('postfixadmin', SM_PATH . 'plugins/postfixadmin/locale');
  105. textdomain('postfixadmin');
  106. echo "<p align=center><b>". _("Your auto response has been removed!") ."</b></p>";
  107. bindtextdomain('squirrelmail', SM_PATH . 'locale');
  108. textdomain('squirrelmail');
  109. }
  110. }
  111. if (!empty($fAway)) {
  112. // add record into vacation
  113. $success = $vacation->setAway($fSubject, $fBody);
  114. if (!$success) {
  115. $error = 1;
  116. bindtextdomain('postfixadmin', SM_PATH . 'plugins/postfixadmin/locale');
  117. textdomain('postfixadmin');
  118. $tMessage = _("Unable to update your auto response settings!");
  119. bindtextdomain('squirrelmail', SM_PATH . 'locale');
  120. textdomain('squirrelmail');
  121. } else {
  122. bindtextdomain('postfixadmin', SM_PATH . 'plugins/postfixadmin/locale');
  123. textdomain('postfixadmin');
  124. echo "<p align=center><b>". _("Your auto response has been set!") ."</b></p>";
  125. bindtextdomain('squirrelmail', SM_PATH . 'locale');
  126. textdomain('squirrelmail');
  127. }
  128. }
  129. }