123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211 |
- <?php
- require_once('common.php');
- if(authentication_has_role('admin')) {
- $Admin_role = 1 ;
- $fUsername = safeget('username');
- list(,$fDomain) = explode('@',$fUsername);
- $Return_url = "list-virtual.php?domain=" . urlencode($fDomain);
-
-
- if ($fDomain == '' || !check_owner(authentication_get_username(), $fDomain)) {
- die("Invalid username!");
- }
- }
- else {
- $Admin_role = 0 ;
- $Return_url = "main.php";
- authentication_require_role('user');
- $fUsername = authentication_get_username();
- }
- if($CONF['vacation'] == 'NO') {
- header ("Location: $Return_url");
- exit(0);
- }
- date_default_timezone_set(@date_default_timezone_get());
- $vh = new VacationHandler($fUsername);
- $choice_of_reply = Config::read('vacation_choice_of_reply');
- foreach (array_keys($choice_of_reply) as $key) {
- $choice_of_reply[$key] = Config::Lang($choice_of_reply[$key]);
- }
- if ($_SERVER['REQUEST_METHOD'] == "GET") {
- $tSubject = '';
- $tBody = '';
- $tActiveFrom = '';
- $tActiveUntil = '';
- $tUseremail = $fUsername;
- $tInterval_Time = '';
- $details = $vh->get_details();
- if($details != false) {
- $tSubject = $details['subject'];
- $tBody = $details['body'];
- $tInterval_Time = $details['interval_time'];
- $tActiveFrom = $details['activeFrom'];
- $tActiveUntil = $details['activeUntil'];
- }
- if($vh->check_vacation()) {
- flash_info(sprintf($PALANG['pUsersVacation_welcome_text'],htmlentities($tUseremail)));
- }
-
- 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: $Return_url");
- exit(0);
- }
- $tActiveFrom = date ("Y-m-d 00:00:00", strtotime (safepost('fActiveFrom')));
- $tActiveUntil = date ("Y-m-d 23:59:59", strtotime (safepost('fActiveUntil')));
- $tSubject = safepost('fSubject');
- $fSubject = $tSubject;
- $tBody = safepost('fBody');
- $fBody = $tBody;
- $tInterval_Time = safepost('fInterval_Time');
- $fChange = escape_string (safepost('fChange'));
- $fBack = escape_string (safepost('fBack'));
- $tUseremail = $fUsername;
-
- 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 (isset($choice_of_reply[$tInterval_Time])) {
- $fInterval_Time = $tInterval_Time;
- } else {
- $fInterval_Time = 0;
- }
-
-
-
- if (!empty ($fChange))
- {
-
-
-
- if ( ($tActiveUntil >= date ("Y-m-d")) and ($tActiveUntil >= $tActiveFrom) ) {
- if (!$vh->set_away($fSubject, $fBody, $fInterval_Time, $tActiveFrom, $tActiveUntil)) {
- $error = 1;
- }
- } else {
- if ( $tActiveUntil < date ("Y-m-d") ) {
- flash_error($PALANG['pVacation_until_before_today']);
- } else {
- flash_error($PALANG['pVacation_until_before_from']);
- }
- $error = 1;
- }
- }
-
- if (!empty ($fBack))
- {
- if(!$vh->remove()) {
- $error = 1;
- }
- }
- }
- if($error == 0) {
- if(!empty ($fBack)) {
- flash_info(sprintf($PALANG['pVacation_result_removed'],htmlentities($tUseremail)));
- header ("Location: $Return_url");
- exit;
- }
- if(!empty($fChange)) {
- flash_info(sprintf($PALANG['pVacation_result_added'],htmlentities($tUseremail)));
- header ("Location: $Return_url");
- exit;
- }
- }
- else {
- flash_error(sprintf($PALANG['pVacation_result_error'],htmlentities($fUsername)));
- }
- $today = date ("Y-m-d");
- if (empty ($tActiveFrom)) $tActiveFrom = $today;
- if (empty ($tActiveUntil)) $tActiveUntil = $today;
- if ( ! $details['active']) {
-
-
-
- if ($tActiveFrom < $today) $tActiveFrom = $today;
- if ($tActiveUntil < $today) $tActiveUntil = $today;
- }
- $smarty->assign ('tUseremail', $tUseremail);
- $smarty->assign ('tSubject', $tSubject);
- $smarty->assign ('tBody', $tBody);
- $smarty->assign ('tActiveFrom', date ("d.m.Y", strtotime ($tActiveFrom)));
- $smarty->assign ('tActiveUntil', date ("d.m.Y", strtotime ($tActiveUntil)));
- $smarty->assign ('select_options', $choice_of_reply);
- $smarty->assign ('tInterval_Time', $tInterval_Time);
- $smarty->assign ('smarty_template', 'vacation');
- $smarty->display ('index.tpl');
- ?>
|