File: postfixadmin_vacation.php

package info (click to toggle)
postfixadmin 3.3.15%2Bds-2
  • links: PTS, VCS
  • area: main
  • in suites: trixie
  • size: 3,816 kB
  • sloc: php: 10,120; perl: 1,069; sh: 643; python: 169; xml: 62; sql: 3; makefile: 2
file content (141 lines) | stat: -rw-r--r-- 6,330 bytes parent folder | download | duplicates (3)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
<?php

require_once(dirname(__FILE__) . '/common.php');

$xmlrpc = get_xmlrpc();
$vacation = $xmlrpc->getProxy('vacation');

$VACCONFTXT = _("I will be away from <date> until <date>. For urgent matters you can contact <contact person>.");
bindtextdomain('squirrelmail', SM_PATH . 'locale');
textdomain('squirrelmail');
$VACCONF = <<<EOM
$VACCONFTXT
EOM;

do_header();

$USERID_USERNAME = $username;
$tmp = preg_split('/@/', $USERID_USERNAME);
$USERID_DOMAIN = $tmp[1];

if ($_SERVER['REQUEST_METHOD'] == "GET") {
    $details = $vacation->getDetails();
    if ($vacation->checkVacation()) {
        bindtextdomain('postfixadmin', SM_PATH . 'plugins/postfixadmin/locale');
        textdomain('postfixadmin');
        $tMessage = _("You already have an auto response configured!");
        bindtextdomain('squirrelmail', SM_PATH . 'locale');
        textdomain('squirrelmail');
        bindtextdomain('postfixadmin', SM_PATH . 'plugins/postfixadmin/locale');
        textdomain('postfixadmin');
        echo "<table bgcolor=\"#b8cbdc\" align=\"center\" width=\"95%\" cellpadding=\"1\" cellspacing=\"0\" border=\"0\"><tr>
            <td align=\"center\"><b>". _("Options") ." - ". _("Auto Response") ."</b>
            <table align=\"center\" width=\"100%\" cellpadding=\"5\" cellspacing=\"0\" border=\"0\">
            <tr><td bgcolor=\"$color[4]\" align=\"center\"><br>
            <table align=\"center\" width=\"70%\" cellpadding=\"4\" cellspacing=\"0\" border=\"0\"><tr>
            <td bgcolor=\"$color[3]\" align=\"center\"><b>". _("Auto Response") ."\n
            </b></td></tr><tr>
            <td bgcolor=\"$color[0]\" align=\"center\"><form name=\"vacation\" method=\"post\">
            <table width=\"95%\" border=\"0\" cellspacing=\"0\" cellpadding=\"2\">
            <tr>
            <td><center>$tMessage<p></center></td>
            </tr>
            <tr>
            <td> <div align=\"center\">
            <input type=\"submit\" name=\"fBack\" value=\"" . _("Coming Back"). "\" />
            </div></td>
            </tr>
            </table>
            <TT></TT></FORM>
            </td>
            </tr><tr><td bgcolor=\"$color[4]\" align=\"left\">&nbsp;</td>
            </tr></table><BR></td></tr></table></td></tr></table>";
        bindtextdomain('squirrelmail', SM_PATH . 'locale');
        textdomain('squirrelmail');
    } else {
        $tSubject = "Out of Office";
        $tSubject = $details['subject'];
        $VACCONF = $details['body'];

        $tMessage = '';
        bindtextdomain('postfixadmin', SM_PATH . 'plugins/postfixadmin/locale');
        textdomain('postfixadmin');
        echo "<table bgcolor=\"$color[0]\" align=\"center\" width=\"95%\" cellpadding=\"1\" cellspacing=\"0\" border=\"0\">
            <tr>
            <td align=\"center\"><b>". _("Options") ." - ". _("Auto Response") ." </b>
            <table align=\"center\" width=\"100%\" cellpadding=\"5\" cellspacing=\"0\" border=\"0\">
            <tr><td bgcolor=\"$color[4]\" align=\"center\"><br>
            <table align=\"center\" width=\"70%\" cellpadding=\"4\" cellspacing=\"0\" border=\"0\"><tr>
            <td bgcolor=\"$color[3]\" align=\"center\"><b>" . _("Auto Response") ."\n
            </b></td></tr><tr>
            <td bgcolor=\"$color[0]\" align=\"center\"><form name=\"vacation\" method=\"post\">$tMessage
            <table width=\"95%\" border=\"0\" cellspacing=\"0\" cellpadding=\"2\"><tr>
            <td width=\"23%\">". _("Subject") .":\n</td>
            <td width=\"2%\">&nbsp;</td>
            <td width=\"69%\"><input type=\"text\" name=\"fSubject\" value=\"" . $tSubject . "\" /></td>
            <td width=\"2%\">&nbsp;</td>
            <td width=\"4%\">&nbsp;</td>
            </tr><tr>
            <td>". _("Body") .":\n</td>
            <td>&nbsp;</td>
            <td><textarea rows=\"10\" cols=\"80\" name=\"fBody\">$VACCONF\n
            </textarea></td><td>&nbsp;</td><td>&nbsp;</td></tr><tr><td>&nbsp;</td><td>&nbsp;</td>
            <td><input type=\"submit\" name=\"fAway\" value=\"" . _("Going Away") . "\" /></td>
            <td>&nbsp;</td><td>&nbsp;</td></tr>
            </table><TT></TT></FORM></td>
            </tr><tr><td bgcolor=\"$color[4]\" align=\"left\">&nbsp;</td>
            </tr></table><BR></td></tr></table></td></tr></table>";
        bindtextdomain('squirrelmail', SM_PATH . 'locale');
        textdomain('squirrelmail');
    }
}

if ($_SERVER['REQUEST_METHOD'] == "POST") {
    $fBack = null;
    $fAway = null;
    foreach (array('fBack', 'fAway', 'fSubject', 'fBody') as $key) {
        $$key = null;
        if (isset($_POST[$key])) {
            $$key = $_POST[$key];
        }
    }

    if (!empty($fBack)) {
        $success = $vacation->remove();

        if (!$success) {
            bindtextdomain('postfixadmin', SM_PATH . 'plugins/postfixadmin/locale');
            textdomain('postfixadmin');
            $tMessage = _("Unable to update your auto response settings!");
            echo "<p>This may signify an error; please contact support (1)</p>";
            bindtextdomain('squirrelmail', SM_PATH . 'locale');
            textdomain('squirrelmail');
        } else {
            bindtextdomain('postfixadmin', SM_PATH . 'plugins/postfixadmin/locale');
            textdomain('postfixadmin');
            echo "<p align=center><b>". _("Your auto response has been removed!") ."</b></p>";
            bindtextdomain('squirrelmail', SM_PATH . 'locale');
            textdomain('squirrelmail');
        }
    }

    if (!empty($fAway)) {
        // add record into vacation
        $success = $vacation->setAway($fSubject, $fBody);

        if (!$success) {
            $error = 1;
            bindtextdomain('postfixadmin', SM_PATH . 'plugins/postfixadmin/locale');
            textdomain('postfixadmin');
            $tMessage = _("Unable to update your auto response settings!");
            bindtextdomain('squirrelmail', SM_PATH . 'locale');
            textdomain('squirrelmail');
        } else {
            bindtextdomain('postfixadmin', SM_PATH . 'plugins/postfixadmin/locale');
            textdomain('postfixadmin');
            echo "<p align=center><b>". _("Your auto response has been set!") ."</b></p>";
            bindtextdomain('squirrelmail', SM_PATH . 'locale');
            textdomain('squirrelmail');
        }
    }
}