SF.net SVN: postfixadmin:[1169] trunk
Brought to you by:
christian_boltz,
gingerdog
From: <chr...@us...> - 2011-08-14 23:12:27
|
Revision: 1169 http://postfixadmin.svn.sourceforge.net/postfixadmin/?rev=1169&view=rev Author: christian_boltz Date: 2011-08-14 23:12:20 +0000 (Sun, 14 Aug 2011) Log Message: ----------- Merge users/vacation.php and edit-vacation.php into vacation.php vacation.php - result of merging edit-vacation.php and users/vacation.php - vacation.php comes with the svn history of edit-vacation.php - display "vacation already active" (only) in user mode if vacation is active (would be useful in admin mode too, but needs a text change) - various comment updates - add username in $PALANG[pVacation_result_removed] and $PALANG[pVacation_result_added] using sprintf - change compared to Jan Kruis' patch: - set return url for users to main.php instead of users/main.php - set return url for admins after setting $fDomain. Otherwise the return url does not contain the domain. - removed unused variable $tDomain users/vacation.php: - require(../vacation.php) - remove everything else - whitespace changes in the license header - note: this is completely different from Jan Kruis' patch - his intention was to remove this file and use ../vacation.php. However, with his way all links in the users menu would point to the wrong place/directory edit-vacation.php: - deleted templates/vacation.tpl - display username only in admin mode templates/list-virtual_mailbox.tpl - link changed to merged vacation.php languages/en.lang - add username in $PALANG[pVacation_result_removed] and $PALANG[pVacation_result_added] as sprintf variable - (comments added by Jan Kruis' patch are not part of this commit) languages/nl.lang - translation updates - already contains the sprintf variable in $PALANG[pVacation_result_removed] and $PALANG[pVacation_result_added] (updates for other *.lang files follow in another commit) The following parts of Jan Kruis' patch are not part of this commit: - rejected: - variables.inc.php: don't add $Admin_role and $Return_url If we initialize them, it should be done directly in (edit-)vacation.php, but the current code always sets them already in all cases. - templates/users_main.tpl: do not change url for vacation.php - postponed: - added comments in en.lang about obsolete texts Most parts of this commit (see exceptions above) were provided as patch by Jan Kruis (jan-kruis@SF), see https://sourceforge.net/tracker/?func=detail&aid=3383236&group_id=191583&atid=937966 Modified Paths: -------------- trunk/languages/en.lang trunk/languages/nl.lang trunk/templates/list-virtual_mailbox.tpl trunk/templates/vacation.tpl trunk/users/vacation.php Added Paths: ----------- trunk/vacation.php Removed Paths: ------------- trunk/edit-vacation.php Deleted: trunk/edit-vacation.php =================================================================== --- trunk/edit-vacation.php 2011-08-08 18:39:03 UTC (rev 1168) +++ trunk/edit-vacation.php 2011-08-14 23:12:20 UTC (rev 1169) @@ -1,182 +0,0 @@ -<?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$ - * @license GNU GPL v2 or later. - * - * File: edit-vacation.php - * Responsible for allowing users to update their vacation status. - * - * Template File: edit-vacation.tpl - * - * Template Variables: - * - * tUseremail - * tSubject - * tBody - * - * Form POST \ GET Variables: - * - * fRole - * fUsername - * fDomain - * fCanceltarget - * fChange - * fBack - * fQuota - * fActive - */ - -require_once('common.php'); - -if($CONF['vacation'] == 'NO') { - header("Location: list-virtual.php"); - exit(0); -} - -// TODO -// Get the $Role of who wants to modify vacation setiing [admin of user] -// on $Role get correct Username and domain of emailname -// for wtich we are going to modify thet vacation setting. -// This has to by don up front before display new windows. - - -$SESSID_USERNAME = authentication_get_username(); -$tmp = preg_split ('/@/', $SESSID_USERNAME); -$USERID_DOMAIN = $tmp[1]; - -// only allow admins to change someone else's 'stuff' -if(authentication_has_role('admin')) { - if (isset($_GET['username'])) $fUsername = escape_string ($_GET['username']); - if (isset($_GET['domain'])) $fDomain = escape_string ($_GET['domain']); -} -else { - $fUsername = $SESSID_USERNAME; - $fDomain = $USERID_DOMAIN; -} - -date_default_timezone_set(@date_default_timezone_get()); # Suppress date.timezone warnings - -$vh = new VacationHandler($fUsername); - - -if ($_SERVER['REQUEST_METHOD'] == "GET") -{ - $tSubject = ''; - $tBody = ''; - $tActiveFrom = ''; - $tActiveUntil = ''; - - $details = $vh->get_details(); - if($details != false) { - $tSubject = $details['subject']; - $tBody = $details['body']; - $tActiveFrom = $details['activeFrom']; - $tActiveUntil = $details['activeUntil']; - } - - $tUseremail = $fUsername; - $tDomain = $fDomain; - - //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 ($_SERVER['REQUEST_METHOD'] == "POST") -{ - if(isset($_POST['fCancel'])) { - header("Location: list-virtual.php?domain=$fDomain"); - 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; - - $fChange = escape_string (safepost('fChange')); - $fBack = escape_string (safepost('fBack')); - - if(authentication_has_role('admin') && isset($_GET['domain'])) { - $fDomain = escape_string ($_GET['domain']); - } - else { - $fDomain = $USERID_DOMAIN; - } - if(authentication_has_role('admin') && isset ($_GET['username'])) { - $fUsername = escape_string($_GET['username']); - } - else { - $fUsername = authentication_get_username(); - } - - $tUseremail = $fUsername; - - //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'); } - - //Set the vacation data for $fUsername - if (!empty ($fChange)) - { - if(!$vh->set_away($fSubject, $fBody, $tActiveFrom, $tActiveUntil)) { - $error = 1; - } - } - - //if change, remove old one, then perhaps set new one - if (!empty ($fBack)) - { - if(!$vh->remove()) { - $error = 1; - } - } - -} -// If NO error then diplay flash message and go back to right url where we came from -if($error == 0) { - if(!empty ($fBack)) { - $Flash_Message = $PALANG['pVacation_result_removed'] ; //TODO adding useremail to flash info depending on $Role - flash_info($Flash_Message); - header ("Location: list-virtual.php?domain=$fDomain"); - exit; - } - if(!empty($fChange)) { - $Flash_Message =( $PALANG['pVacation_result_added']); //TODO adding useremail to flash info depending on $Role - flash_info($Flash_Message); - header ("Location: list-virtual.php?domain=$fDomain"); - exit; - } -} -else { - $Flash_Message = $PALANG['pVacation_result_error'] ; //TODO adding useremail to flash info depending on $Role - flash_error($Flash_Message); -} -if (empty ($tActiveFrom)) - $tActiveFrom = date ("Y-m-d"); -if (empty ($tActiveUntil)) - $tActiveUntil = date ("Y-m-d"); - - -$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 ('smarty_template', 'vacation'); -$smarty->display ('index.tpl'); - -/* vim: set expandtab softtabstop=3 tabstop=3 shiftwidth=3: */ -?> Modified: trunk/languages/en.lang =================================================================== --- trunk/languages/en.lang 2011-08-08 18:39:03 UTC (rev 1168) +++ trunk/languages/en.lang 2011-08-14 23:12:20 UTC (rev 1169) @@ -190,8 +190,8 @@ $PALANG['pEdit_vacation_remove'] = 'Remove away message'; $PALANG['pVacation_result_error'] = 'Unable to update auto response settings!'; -$PALANG['pVacation_result_removed'] = 'Auto response has been removed!'; -$PALANG['pVacation_result_added'] = 'Auto response has been enabled!'; +$PALANG['pVacation_result_removed'] = 'Auto response for %s has been removed!'; +$PALANG['pVacation_result_added'] = 'Auto response for %s has been enabled!'; $PALANG['pViewlog_welcome'] = 'View the last 10 actions for '; $PALANG['pViewlog_timestamp'] = 'Timestamp'; Modified: trunk/languages/nl.lang =================================================================== --- trunk/languages/nl.lang 2011-08-08 18:39:03 UTC (rev 1168) +++ trunk/languages/nl.lang 2011-08-14 23:12:20 UTC (rev 1169) @@ -12,14 +12,14 @@ $PALANG['del'] = 'Verwijder'; $PALANG['exit'] = 'Beëindigen'; $PALANG['cancel'] = 'Annuleren'; -$PALANG['save'] = 'Opslaan'; # XXX Text change: "Save" -> "Save changes" +$PALANG['save'] = 'Wijzigingen opslaan'; $PALANG['confirm'] = 'Weet u het zeker dat u wilt verwijderen?\n'; $PALANG['confirm_domain'] = 'Weet u zeker dat u ALLE data van het domein wilt verwijderen? Dit kan niet ongedaan worden gemaakt!\n'; $PALANG['check_update'] = 'Zoeken naar nieuwe versie'; $PALANG['invalid_parameter'] = 'ongeldige parameter!'; $PALANG['show'] = 'Toon:'; $PALANG['all'] = 'Alle'; -$PALANG['pFooter_logged_as'] = 'aangemeld als %s'; # XXX Text change: 'logged in as %s' (the 'in' was missing) +$PALANG['pFooter_logged_as'] = 'aangemeld als %s'; $PALANG['pLogin_welcome'] = 'Mail beheerders log hier in om uw domeinen te beheren.'; $PALANG['pLogin_username'] = 'Login (e-mail)'; @@ -118,10 +118,10 @@ $PALANG['pCreate_alias_goto_text_error'] = 'De NAAR is niet geldig.'; $PALANG['pCreate_alias_result_error'] = 'Mislukt om de alias toe te voegen.'; $PALANG['pCreate_alias_result_success'] = 'De alias is toegevoegd.'; -$PALANG['pCreate_alias_catchall_text'] = 'Om een catch-all te gebruiken, dient u een "*" (asteric) in te vullen als alias. Voor domein naar domein forwarding gebruik "*@domein.tld" als naar.'; # XXX check/beautify - was split in two lines before +$PALANG['pCreate_alias_catchall_text'] = 'Om een catch-all te gebruiken, dient u een "*" (asteric) in te vullen als alias. Voor domein naar domein forwarding gebruik "*@domein.tld" als naar.'; -$PALANG['pEdit_alias_welcome'] = 'Bewerk een alias voor uw domein.'; # XXX Text change to: 'Edit forwarding settings' -$PALANG['pEdit_alias_help'] = 'Een alias per regel.'; # XXX # XXX Text change to: 'Accepts multiple targets, one entry per line.' +$PALANG['pEdit_alias_welcome'] = 'Bewerk een alias voor uw domein.'; +$PALANG['pEdit_alias_help'] = 'Meerdere e-mailadressen toegestaan. Slechts één alias per regel.'; $PALANG['pEdit_alias_address'] = 'Alias'; $PALANG['pEdit_alias_address_error'] = 'Mislukt om alias te vinden!'; # obsolete $PALANG['pEdit_alias_goto'] = 'Naar'; @@ -143,7 +143,7 @@ $PALANG['pCreate_mailbox_password'] = 'Wachtwoord'; $PALANG['pCreate_mailbox_password2'] = 'Wachtwoord nogmaals'; $PALANG['pCreate_mailbox_password_text'] = 'Wachtwoord voor POP3/IMAP'; -$PALANG['pCreate_mailbox_password_text_error'] = 'De wachtwoorden die u opgaf komen niet overeen. Of zijn leeg.'; # XXX check/beautify - was split in two lines before +$PALANG['pCreate_mailbox_password_text_error'] = 'De wachtwoorden die u opgaf komen niet overeen of zijn leeg.'; $PALANG['pCreate_mailbox_name'] = 'Naam'; # obsolete $PALANG['pCreate_mailbox_name_text'] = 'Volledige naam'; $PALANG['pCreate_mailbox_quota'] = 'Quota'; # obsolete @@ -178,7 +178,7 @@ $PALANG['pPassword_password_current_text_error'] = 'U heeft uw huidige wachtwoord niet opgegeven.'; $PALANG['pPassword_password'] = 'Nieuw wachtwoord'; $PALANG['pPassword_password2'] = 'Nieuw wachtwoord (nogmaals)'; -$PALANG['pPassword_password_text_error'] = 'De wachtwoorden komen niet overeen. Of zijn leeg.'; # XXX check/beautify - was split in two lines before +$PALANG['pPassword_password_text_error'] = 'De wachtwoorden komen niet overeen of zijn leeg.'; $PALANG['pPassword_button'] = 'Wijzig wachtwoord'; $PALANG['pPassword_result_error'] = 'Mislukt om uw wachtwoord te veranderen.'; $PALANG['pPassword_result_success'] = 'Uw wachtwoord is veranderd.'; @@ -186,8 +186,8 @@ $PALANG['pEdit_vacation_set'] = 'Verander / Activeer beantwoorden tekst'; $PALANG['pEdit_vacation_remove'] = 'Verwijder beantwoorden tekst'; $PALANG['pVacation_result_error'] = 'Niet in staat automatisch beantwoorden te wijzigen!'; -$PALANG['pVacation_result_removed'] = 'Automatisch beantwoorden is gedeactiveerd!'; -$PALANG['pVacation_result_added'] = 'Automatisch beantwoorden is geactiveerd!'; +$PALANG['pVacation_result_removed'] = 'Automatisch beantwoorden is voor %s gedeactiveerd!'; +$PALANG['pVacation_result_added'] = 'Automatisch beantwoorden is voor %s geactiveerd!'; $PALANG['pViewlog_welcome'] = 'Laat de laatste 10 actie\'s zien van '; $PALANG['pViewlog_timestamp'] = 'Tijd'; @@ -195,12 +195,12 @@ $PALANG['pViewlog_domain'] = 'Domein'; $PALANG['pViewlog_action'] = 'Actie'; $PALANG['pViewlog_data'] = 'Aanpassing'; -$PALANG['pViewlog_action_create_domain'] = 'create domain'; # XXX -$PALANG['pViewlog_action_delete_domain'] = 'delete domain'; # XXX -$PALANG['pViewlog_action_edit_domain'] = 'edit domain'; # XXX -$PALANG['pViewlog_action_create_mailbox'] = 'Mailbox toegevoegd'; -$PALANG['pViewlog_action_delete_mailbox'] = 'Mailbox verwijderd'; -$PALANG['pViewlog_action_edit_mailbox'] = 'Mailbox bewerkt'; +$PALANG['pViewlog_action_create_domain'] = 'domein toegevoegd'; +$PALANG['pViewlog_action_delete_domain'] = 'domein verwijderd'; +$PALANG['pViewlog_action_edit_domain'] = 'domein bewerkt'; +$PALANG['pViewlog_action_create_mailbox'] = 'mailbox toegevoegd'; +$PALANG['pViewlog_action_delete_mailbox'] = 'mailbox verwijderd'; +$PALANG['pViewlog_action_edit_mailbox'] = 'mailbox bewerkt'; $PALANG['pViewlog_action_edit_mailbox_state'] = 'status actieve mailbox bewerkt'; $PALANG['pViewlog_action_create_alias'] = 'alias toegevoegd'; $PALANG['pViewlog_action_create_alias_domain'] = 'maak domein alias'; @@ -247,7 +247,7 @@ $PALANG['pAdminList_domain_aliases'] = 'Aliassen'; $PALANG['pAdminList_domain_mailboxes'] = 'Mailboxen'; $PALANG['pAdminList_domain_maxquota'] = 'Quota (MB)'; # XXX no longer used -$PALANG['pAdminList_domain_quota'] = 'Domain quota (MB)'; # XXX +$PALANG['pAdminList_domain_quota'] = 'Domein quota (MB)'; # XXX $PALANG['pAdminList_domain_transport'] = 'Transport'; $PALANG['pAdminList_domain_backupmx'] = 'Back-up MX'; $PALANG['pAdminList_domain_modified'] = 'Laatst bewerkt'; @@ -285,7 +285,7 @@ $PALANG['pAdminCreate_domain_button'] = 'Voeg Domein toe'; $PALANG['pAdminCreate_domain_result_error'] = 'Mislukt om het domein toe te voegen.'; $PALANG['pAdminCreate_domain_result_success'] = 'Domein is toegevoegd!'; -$PALANG['pAdminDelete_admin_error'] = 'Unable to delete admin!'; # XXX +$PALANG['pAdminDelete_admin_error'] = 'Niet in staat beheerder te verwijderen!'; $PALANG['pAdminDelete_domain_error'] = 'Niet in staat domein te verwijderen!'; $PALANG['pAdminDelete_alias_domain_error'] = 'Niet in staat domein alias te verwijderen!'; @@ -298,9 +298,9 @@ $PALANG['pAdminEdit_domain_mailboxes_text'] = '-1 = uit | 0 = onbeperkt'; $PALANG['pAdminEdit_domain_maxquota'] = 'Max Quota'; $PALANG['pAdminEdit_domain_maxquota_text'] = 'MB | -1 = uit | 0 = onbeperkt'; -$PALANG['pAdminEdit_domain_quota'] = 'Domain Quota'; # XXX +$PALANG['pAdminEdit_domain_quota'] = 'Domein Quota'; # XXX $PALANG['pAdminEdit_domain_transport'] = 'Transport'; -$PALANG['pAdminEdit_domain_transport_text'] = 'Defineer transport'; # XXX check - Defin_i_eer or Defineer? +$PALANG['pAdminEdit_domain_transport_text'] = 'Definieer transport'; $PALANG['pAdminEdit_domain_backupmx'] = 'Mail server is back-up MX'; $PALANG['pAdminEdit_domain_active'] = 'Actief'; $PALANG['pAdminEdit_domain_button'] = 'Bewerk domein'; # XXX text no longer used @@ -313,7 +313,7 @@ $PALANG['pAdminCreate_admin_username_text_error2'] = 'De beheerder bestaat al of is niet geldig'; $PALANG['pAdminCreate_admin_password'] = 'Wachtwoord'; # obsolete $PALANG['pAdminCreate_admin_password2'] = 'Wachtwoord (nogmaals)'; # obsolete -$PALANG['pAdminCreate_admin_password_text_error'] = 'De wachtwoorden die u opgaf komen niet overeen. Of zijn leeg.'; # XXX check/beautify - was split in two lines before +$PALANG['pAdminCreate_admin_password_text_error'] = 'De wachtwoorden die u opgaf komen niet overeen of zijn leeg.'; $PALANG['pAdminCreate_admin_button'] = 'Voeg beheerder toe'; $PALANG['pAdminCreate_admin_result_error'] = 'Mislukt om beheerder toe te voegen!'; $PALANG['pAdminCreate_admin_result_success'] = 'Beheerder is toegevoegd.'; @@ -323,7 +323,7 @@ $PALANG['pAdminEdit_admin_username'] = 'Beheerder'; $PALANG['pAdminEdit_admin_password'] = 'Wachtwoord'; $PALANG['pAdminEdit_admin_password2'] = 'Wachtwoord (nogmaals)'; -$PALANG['pAdminEdit_admin_password_text_error'] = 'De wachtwoorden die u opgaf komen niet overeen. Of zijn leeg.'; # XXX check/beautify - was split in two lines before +$PALANG['pAdminEdit_admin_password_text_error'] = 'De wachtwoorden die u opgaf komen niet overeen of zijn leeg.'; $PALANG['pAdminEdit_admin_active'] = 'Actief'; $PALANG['pAdminEdit_admin_super_admin'] = 'Super administrator'; $PALANG['pAdminEdit_admin_button'] = 'Bewerk beheerder'; # XXX text no longer used @@ -360,8 +360,8 @@ $PALANG['pUsersVacation_button_back'] = 'Kom terug'; $PALANG['pUsersVacation_result_error'] = 'Mislukt om uw automatisch beantwoorden instellingen te wijzigen.'; $PALANG['pUsersVacation_result_success'] = 'Uw automatisch beantwoorden is verwijderd.'; -$PALANG['pUsersVacation_activefrom'] = 'Active from'; # XXX -$PALANG['pUsersVacation_activeuntil'] = 'Active until'; # XXX +$PALANG['pUsersVacation_activefrom'] = 'Actief vanaf'; +$PALANG['pUsersVacation_activeuntil'] = 'Actief t/m'; $PALANG['pCreate_dbLog_createmailbox'] = 'mailbox aangemaakt'; $PALANG['pCreate_dbLog_createalias'] = 'alias aangemaakt'; Modified: trunk/templates/list-virtual_mailbox.tpl =================================================================== --- trunk/templates/list-virtual_mailbox.tpl 2011-08-08 18:39:03 UTC (rev 1168) +++ trunk/templates/list-virtual_mailbox.tpl 2011-08-14 23:12:20 UTC (rev 1169) @@ -74,7 +74,7 @@ {else} {assign var="v_active" value=$PALANG.pOverview_vacation_option} {/if} - <td><a href="edit-vacation.php?username={$item.username|escape:"url"}&domain={$fDomain|escape:"url"}">{$v_active}</a></td> + <td><a href="vacation.php?username={$item.username|escape:"url"}&domain={$fDomain|escape:"url"}">{$v_active}</a></td> {/if} {else} <td> </td> Modified: trunk/templates/vacation.tpl =================================================================== --- trunk/templates/vacation.tpl 2011-08-08 18:39:03 UTC (rev 1168) +++ trunk/templates/vacation.tpl 2011-08-14 23:12:20 UTC (rev 1169) @@ -7,11 +7,13 @@ <tr> <th colspan="3">{$PALANG.pUsersVacation_welcome}</th> </tr> + {if !$authentication_has_role.user} <tr> <td class="label"><label>{$PALANG.pUsersLogin_username}:</label></td> <td><em>{$tUseremail}</em></td> <td> </td> </tr> + {/if} <tr> <td class="label"><label>{$PALANG.pUsersVacation_activefrom}:</label></td> <td><input class="flat readonly" name="fActiveFrom" value="{$tActiveFrom}" readonly="readonly" /> Modified: trunk/users/vacation.php =================================================================== --- trunk/users/vacation.php 2011-08-08 18:39:03 UTC (rev 1168) +++ trunk/users/vacation.php 2011-08-14 23:12:20 UTC (rev 1169) @@ -1,172 +1,25 @@ <?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$ - * @license GNU GPL v2 or later. - * - * File: vacation.php - * Used by users to set/change their vacation settings. +/** + * Postfix Admin * - * Template File: users_vacation.tpl + * LICENSE + * This source file is subject to the GPL license that is bundled with + * this package in the file LICENSE.TXT. * - * Template Variables: + * Further details on the project are available at : + * http://www.postfixadmin.com or http://postfixadmin.sf.net * - * tSubject - * tBody + * @version $Id$ + * @license GNU GPL v2 or later. * - * Form POST \ GET Variables: + * File: vacation.php + * Responsible for allowing users to update their vacation status. * - * fSubject - * fBody - * fChange - * fBack */ require_once('../common.php'); -authentication_require_role('user'); -$USERID_USERNAME = authentication_get_username(); -$fUsername = authentication_get_username(); +require_once('../vacation.php'); -// is vacation support enabled in $CONF ? -if($CONF['vacation'] == 'NO') { - header("Location: main.php"); - exit(0); -} - -date_default_timezone_set(@date_default_timezone_get()); # Suppress date.timezone warnings - -$vh = new VacationHandler($fUsername); -//$vh = new VacationHandler(authentication_get_username()); - -if ($_SERVER['REQUEST_METHOD'] == "GET") -{ - $tSubject = ''; - $tBody = ''; - $tActiveFrom = ''; - $tActiveUntil = ''; - - $details = $vh->get_details(); - if($details != false) { - $tSubject = $details['subject']; - $tBody = $details['body']; - $fActiveFrom = $details['activeFrom']; - $fActiveUntil = $details['activeUntil']; - } - - if($vh->check_vacation()) { - flash_info($PALANG['pUsersVacation_welcome_text']); - } - - $tUseremail = $fUsername; - - //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 ($_SERVER['REQUEST_METHOD'] == "POST") -{ - if(isset($_POST['fCancel'])) { - header("Location: main.php"); - 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; - - $fChange = escape_string (safepost('fChange')); - $fBack = escape_string (safepost('fBack')); - - $tUseremail = $fUsername; - - //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 change OR back, delete any record of vacation emails. - // the user is going away - set the goto alias and vacation table as necessary. - -// if (!empty ($fChange)) -// { -// if(!$vh->set_away($fSubject, $fBody, $tActiveFrom, $tActiveUntil)) { -// $error = 1; -// flash_error($PALANG['pUsersVacation_result_error']); -// } -// flash_info($PALANG['pVacation_result_added']); -// header ("Location: main.php"); -// exit; -// } -// -// if (!empty ($fBack)) { -// $vh->remove(); -// flash_info($PALANG['pUsersVacation_result_success']); -// header ("Location: main.php"); -// exit; -// } - - //Set the vacation data for $fUsername - if (!empty ($fChange)) - { - if(!$vh->set_away($fSubject, $fBody, $tActiveFrom, $tActiveUntil)) { - $error = 1; - } - } - - //if change, remove old one, then perhaps set new one - if (!empty ($fBack)) - { - if(!$vh->remove()) { - $error = 1; - } - } - -} -// If NO error then diplay flash message and go back to right url where we came from -if($error == 0) { - if(!empty ($fBack)) { - $Flash_Message = $PALANG['pVacation_result_removed'] ; //TODO adding useremail to flash info depending on $ - flash_info($Flash_Message); - header ("Location: main.php"); - exit; - } - if(!empty($fChange)) { - $Flash_Message =( $PALANG['pVacation_result_added']); //TODO adding useremail to flash info depending on $$ - flash_info($Flash_Message); - header ("Location: main.php"); - exit; - } -} -else { - $Flash_Message = $PALANG['pVacation_result_error'] ; //TODO adding useremail to flash info depending on $Role - flash_error($Flash_Message); -} - -if (empty ($fActiveFrom)) - $fActiveFrom = date ("Y-m-d"); -if (empty ($fActiveUntil)) - $fActiveUntil = date ("Y-m-d"); - -$smarty->assign ('tUseremail', $tUseremail); -$smarty->assign ('tSubject', $tSubject); -$smarty->assign ('tBody', $tBody); -$smarty->assign ('tActiveFrom', date ("d.m.Y", strtotime ($fActiveFrom))); -$smarty->assign ('tActiveUntil', date ("d.m.Y", strtotime ($fActiveUntil))); -$smarty->assign ('smarty_template', 'vacation'); -$smarty->display ('index.tpl'); /* vim: set expandtab softtabstop=4 tabstop=4 shiftwidth=4: */ ?> Copied: trunk/vacation.php (from rev 1168, trunk/edit-vacation.php) =================================================================== --- trunk/vacation.php (rev 0) +++ trunk/vacation.php 2011-08-14 23:12:20 UTC (rev 1169) @@ -0,0 +1,171 @@ +<?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$ + * @license GNU GPL v2 or later. + * + * File: edit-vacation.php + * Responsible for allowing users to update their vacation status. + * + * Template File: edit-vacation.tpl + * + * Template Variables: + * + * tUseremail + * tActiveFrom + * tActiveUntil + * tSubject + * tBody + * + * Form POST \ GET Variables: + * + * fUsername + * fDomain + * fCancel + * fChange + * fBack + * fQuota + * fActive + */ + +require_once('common.php'); + +$SESSID_USERNAME = authentication_get_username(); +$tmp = preg_split ('/@/', $SESSID_USERNAME); +$USERID_DOMAIN = $tmp[1]; + +// only allow admins to change someone else's 'stuff' +if(authentication_has_role('admin')) { + $Admin_role = 1 ; + + if (isset($_GET['username'])) $fUsername = escape_string ($_GET['username']); + if (isset($_GET['domain'])) $fDomain = escape_string ($_GET['domain']); + $Return_url = "list-virtual.php?domain=$fDomain"; +} +else { + $Admin_role = 0 ; +# $Return_url = "users/main.php"; + $Return_url = "main.php"; + authentication_require_role('user'); + $fUsername = $SESSID_USERNAME; + $fDomain = $USERID_DOMAIN; +} + +// is vacation support enabled in $CONF ? +if($CONF['vacation'] == 'NO') { + header ("Location: $Return_url"); + exit(0); +} + +date_default_timezone_set(@date_default_timezone_get()); # Suppress date.timezone warnings + +$vh = new VacationHandler($fUsername); + + +if ($_SERVER['REQUEST_METHOD'] == "GET") { + $tSubject = ''; + $tBody = ''; + $tActiveFrom = ''; + $tActiveUntil = ''; + $tUseremail = $fUsername; + + $details = $vh->get_details(); + if($details != false) { + $tSubject = $details['subject']; + $tBody = $details['body']; + $tActiveFrom = $details['activeFrom']; + $tActiveUntil = $details['activeUntil']; + } + + if($vh->check_vacation() and (!$Admin_role)) { + flash_info($PALANG['pUsersVacation_welcome_text']); + } + + //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 ($_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; + + $fChange = escape_string (safepost('fChange')); + $fBack = escape_string (safepost('fBack')); + + $tUseremail = $fUsername; + + //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 change OR back, delete any record of vacation emails. + // the user is going away - set the goto alias and vacation table as necessary. + + //Set the vacation data for $fUsername + if (!empty ($fChange)) + { + if(!$vh->set_away($fSubject, $fBody, $tActiveFrom, $tActiveUntil)) { + $error = 1; + } + } + + //if change, remove old one, then perhaps set new one + if (!empty ($fBack)) + { + if(!$vh->remove()) { + $error = 1; + } + } +} + +// If NO error then diplay flash message and go back to right url where we came from +if($error == 0) { + if(!empty ($fBack)) { + flash_info(sprintf($PALANG['pVacation_result_removed'],$tUseremail)); + header ("Location: $Return_url"); + exit; + } + if(!empty($fChange)) { + flash_info(sprintf($PALANG['pVacation_result_added'],$tUseremail)); + header ("Location: $Return_url"); + exit; + } +} +else { + flash_error($PALANG['pVacation_result_error']); +} +if (empty ($tActiveFrom)) + $tActiveFrom = date ("Y-m-d"); +if (empty ($tActiveUntil)) + $tActiveUntil = date ("Y-m-d"); + +$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 ('smarty_template', 'vacation'); +$smarty->display ('index.tpl'); + +/* vim: set expandtab softtabstop=3 tabstop=3 shiftwidth=3: */ +?> This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |