File: vacation.php

package info (click to toggle)
postfixadmin 2.3.5-2%2Bdeb7u1
  • links: PTS, VCS
  • area: main
  • in suites: wheezy
  • size: 6,200 kB
  • sloc: php: 25,767; xml: 14,485; perl: 964; sh: 664; python: 169; makefile: 84
file content (110 lines) | stat: -rw-r--r-- 3,182 bytes parent folder | download | duplicates (2)
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
<?php
/** 
 * Postfix Admin 
 * 
 * LICENSE 
 * This source file is subject to the GPL license that is bundled with  
 * this package in the file LICENSE.TXT. 
 * 
 * Further details on the project are available at : 
 *     http://www.postfixadmin.com or http://postfixadmin.sf.net 
 * 
 * @version $Id: vacation.php 646 2009-04-25 17:58:56Z christian_boltz $ 
 * @license GNU GPL v2 or later. 
 * 
 * File: vacation.php
 * Used by users to set/change their vacation settings.
 *
 * Template File: users_vacation.php
 *
 * Template Variables:
 *
 * tMessage
 * tSubject
 * tBody
 *
 * Form POST \ GET Variables:
 *
 * fSubject
 * fBody
 * fAway
 * fBack
 */

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

authentication_require_role('user');
$USERID_USERNAME = authentication_get_username();

// is vacation support enabled in $CONF ?
if($CONF['vacation'] == 'NO') {
    header("Location: " . $CONF['postfix_admin_url'] . "/users/main.php");
    exit(0);
}

$vh = new VacationHandler(authentication_get_username());

if ($_SERVER['REQUEST_METHOD'] == "GET")
{
    $tSubject = '';
    $tBody = '';

    $details = $vh->get_details();
    if($details != false) {
        $tSubject = $details['subject'];
        $tBody = $details['body'];
    }
    if($vh->check_vacation()) {
        $tMessage = $PALANG['pUsersVacation_welcome_text'];
    }

    if ($tSubject == '') { $tSubject = html_entity_decode($PALANG['pUsersVacation_subject_text'], ENT_QUOTES, 'UTF-8'); }
    if ($tBody == '') { $tBody = html_entity_decode($PALANG['pUsersVacation_body_text'], ENT_QUOTES, 'UTF-8'); }
}

if ($_SERVER['REQUEST_METHOD'] == "POST")
{
    if(isset($_POST['fCancel'])) {
        header("Location: main.php");
        exit(0);
    }

    if (isset ($_POST['fSubject'])) $fSubject = $_POST['fSubject'];
    if (isset ($_POST['fBody']))    $fBody    = $_POST['fBody'];
    if (isset ($_POST['fAway'])) $fAway = escape_string ($_POST['fAway']);
    if (isset ($_POST['fBack'])) $fBack = escape_string ($_POST['fBack']);

    //set a default, reset fields for coming back selection
    if ($tSubject == '') { $tSubject = html_entity_decode($PALANG['pUsersVacation_subject_text'], ENT_QUOTES, 'UTF-8'); }
    if ($tBody == '') { $tBody = html_entity_decode($PALANG['pUsersVacation_body_text'], ENT_QUOTES, 'UTF-8'); }

    // if they've set themselves away OR back, delete any record of vacation emails.

    // the user is going away - set the goto alias and vacation table as necessary.
    if (!empty ($fAway))
    {
        if(!$vh->set_away($fSubject, $fBody)) {
            $error = 1;
            $tMessage = $PALANG['pUsersVacation_result_error'];
        }
        flash_info($PALANG['pVacation_result_added']);
        header ("Location: main.php");
        exit;
    }

    if (!empty ($fBack)) {
        $vh->remove();
        $tMessage = $PALANG['pUsersVacation_result_success'];
        flash_info($tMessage);
        header ("Location: main.php");
        exit;
    }
}

include ("../templates/header.php");
include ("../templates/users_menu.php");
include ("../templates/users_vacation.php");
include ("../templates/footer.php");

/* vim: set expandtab softtabstop=4 tabstop=4 shiftwidth=4: */
?>