4 // by Mischa Peters <mischa at high5 dot nl>
5 // Copyright (c) 2022 High5!
6 // License Info: LICENSE.TXT
10 // Template File: users_vacation.tpl
12 // Template Variables:
18 // POST / GET Variables:
23 require_once './functions.inc.php';
24 include './languages/' . check_language() . '.lang';
26 $SESSID_USERNAME = check_session();
27 $ROLE = check_role($SESSID_USERNAME);
29 if ($ROLE == ADMIN_ROLE) {
30 $list_domains = list_domains();
31 $list_admins = list_admins();
33 $list_domains = list_domains($SESSID_USERNAME);
36 $USERID_DOMAIN = substr(strrchr($SESSID_USERNAME, "@"), 1);
38 if ($_SERVER['REQUEST_METHOD'] == "GET") {
40 $sth = $dbh->prepare("SELECT COUNT(*) FROM vacation WHERE email=?");
41 $sth->execute(array($SESSID_USERNAME));
43 if ($sth->fetchColumn() == 1) {
45 $message = $LANG['Vacation_welcome_text'];
51 if ($_SERVER['REQUEST_METHOD'] == "POST") {
52 $subject = filter_input(INPUT_POST, 'subject', FILTER_DEFAULT);
53 $body = filter_input(INPUT_POST, 'body', FILTER_DEFAULT);
55 if (!empty($_POST['back'])) {
58 $sth = $dbh->prepare("DELETE FROM vacation WHERE email=?");
59 $sth->bindParam(1, $SESSID_USERNAME, PDO::PARAM_STR);
61 if ($sth->rowCount() != 1) {
62 $message = $LANG['Vacation_result_error'];
65 $essage = $LANG['Vacation_result_succes'];
69 if (!empty($_POST['away'])) {
73 $sth = $dbh->prepare("INSERT INTO vacation (email,subject,body,cache,domain,created) VALUES (?,?,?,'',?,NOW())");
74 $sth->bindParam(1, $SESSID_USERNAME, PDO::PARAM_STR);
75 $sth->bindParam(2, $subject, PDO::PARAM_STR);
76 $sth->bindParam(3, $body, PDO::PARAM_STR);
77 $sth->bindParam(4, $USERID_DOMAIN, PDO::PARAM_STR);
79 header("Location: vacation.php");
80 } catch(PDOException $e) {
81 $message = $LANG['Vacation_result_error'] . " " . $e->getMessage();
86 include './templates/header.tpl';
87 include './templates/menu.tpl';
88 include './templates/vacation.tpl';
89 include './templates/footer.tpl';