vacation: maintain away message after coming back for next time

git-svn-id: https://svn.code.sf.net/p/postfixadmin/code/trunk@297 a1433add-5e2c-0410-b055-b7f2511e0802
postfixadmin-2.3
David Goodwin 17 years ago
parent f35fabc3d0
commit a633bd371c

@ -84,10 +84,10 @@ if ($_SERVER['REQUEST_METHOD'] == "GET")
if ($_SERVER['REQUEST_METHOD'] == "POST")
{
$tSubject = safepost('fSubject');
$fSubject = escape_string ( $tSubject);
$tBody = safepost('fBody');
$fBody = escape_string ( $tBody);
$tSubject = safepost('fSubject');
$fSubject = escape_string ($tSubject);
$tBody = safepost('fBody');
$fBody = escape_string ($tBody);
$fChange = escape_string (safepost('fChange'));
$fBack = escape_string (safepost('fBack'));
@ -111,15 +111,13 @@ if ($_SERVER['REQUEST_METHOD'] == "POST")
//if change, remove old one, then perhaps set new one
if (!empty ($fBack) || !empty ($fChange))
{
//if we find an existing vacation entry, delete it
//if we find an existing vacation entry, disable it
$result = db_query("SELECT * FROM $table_vacation WHERE email='$fUsername'");
if ($result['rows'] == 1)
{
$result = db_query ("DELETE FROM $table_vacation WHERE email='$fUsername'");
if ($result['rows'] != 1)
{
$error = 1;
}
$db_false = db_get_boolean(false);
// retain vacation message if possible - i.e disable vacation away-ness.
$result = db_query ("UPDATE $table_vacation SET active = $db_false WHERE email='$fUsername'");
$result = db_query ("SELECT * FROM $table_alias WHERE address='$fUsername'");
if ($result['rows'] == 1)
@ -157,7 +155,16 @@ if ($_SERVER['REQUEST_METHOD'] == "POST")
$goto = $row['goto'];
}
$Active = db_get_boolean(True);
$result = db_query ("INSERT INTO $table_vacation (email,subject,body,domain,created,active) VALUES ('$fUsername','$fSubject','$fBody','$fDomain',NOW(),$Active)");
$notActive = db_get_boolean(False);
// I don't think we need to care if the vacation entry is inactive or active.. as long as we don't try and
// insert a duplicate
$result = db_query("SELECT * FROM $table_vacation WHERE email = '$fUsername'");
if($result['rows'] == 1) {
$result = db_query("UPDATE $table_vacation SET active = $Active, created = NOW() WHERE email = '$fUsername'");
}
else {
$result = db_query ("INSERT INTO $table_vacation (email,subject,body,domain,created,active) VALUES ('$fUsername','$fSubject','$fBody','$fDomain',NOW(),$Active)");
}
if ($result['rows'] != 1)
{

@ -84,17 +84,11 @@ if ($_SERVER['REQUEST_METHOD'] == "POST")
// if they've set themselves away OR back, delete any record of vacation emails.
if (!empty ($fBack) || !empty ($fAway))
{
$result = db_query ("DELETE FROM $table_vacation WHERE email='$USERID_USERNAME'");
$result2 = db_query ("DELETE FROM $table_vacation_notification WHERE on_vacation='$USERID_USERNAME'");
if ($result['rows'] != 1)
{
$error = 1;
$tMessage = $PALANG['pUsersVacation_result_error'];
}
else
{
$tMessage = $PALANG['pUsersVacation_result_success'];
}
$notActive = db_get_boolean(False);
// this isn't very good, as $result['rows'] would be 0 if the user had not used vacation stuff before.
$result = db_query("UPDATE $table_vacation SET active = $notActive WHERE email='$USERID_USERNAME'");
$result = db_query("DELETE FROM $table_vacation_notification WHERE on_vacation='$USERID_USERNAME'");
$tMessage = $PALANG['pUsersVacation_result_error'];
// We need to see whether there is already an alias record for the user, or not.
// If not, we create one, else update the existing one.
@ -146,7 +140,14 @@ if ($_SERVER['REQUEST_METHOD'] == "POST")
$tGoto = $row['goto'];
}
$Active = db_get_boolean(True);
$result = db_query ("INSERT INTO $table_vacation (email,subject,body,domain,created,active) VALUES ('$USERID_USERNAME','$fSubject','$fBody','$USERID_DOMAIN',NOW(),$Active)");
$result = db_query("SELECT * FROM $table_vacation WHERE email = '$USERID_USERNAME'");
if($result['rows'] == 1) {
$result = db_query("UPDATE $table_vacation SET active = $Active, body = '$fBody', subject = '$fSubject', created = NOW() WHERE email = '$USERID_USERNAME'");
}
else {
$result = db_query ("INSERT INTO $table_vacation (email,subject,body,domain,created,active) VALUES ('$USERID_USERNAME','$fSubject','$fBody','$USERID_DOMAIN',NOW(),$Active)");
}
if ($result['rows'] != 1)
{
$error = 1;

Loading…
Cancel
Save