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

@ -85,9 +85,9 @@ if ($_SERVER['REQUEST_METHOD'] == "POST")
{ {
$tSubject = safepost('fSubject'); $tSubject = safepost('fSubject');
$fSubject = escape_string ( $tSubject); $fSubject = escape_string ($tSubject);
$tBody = safepost('fBody'); $tBody = safepost('fBody');
$fBody = escape_string ( $tBody); $fBody = escape_string ($tBody);
$fChange = escape_string (safepost('fChange')); $fChange = escape_string (safepost('fChange'));
$fBack = escape_string (safepost('fBack')); $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 change, remove old one, then perhaps set new one
if (!empty ($fBack) || !empty ($fChange)) 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'"); $result = db_query("SELECT * FROM $table_vacation WHERE email='$fUsername'");
if ($result['rows'] == 1) if ($result['rows'] == 1)
{ {
$result = db_query ("DELETE FROM $table_vacation WHERE email='$fUsername'"); $db_false = db_get_boolean(false);
if ($result['rows'] != 1) // retain vacation message if possible - i.e disable vacation away-ness.
{ $result = db_query ("UPDATE $table_vacation SET active = $db_false WHERE email='$fUsername'");
$error = 1;
}
$result = db_query ("SELECT * FROM $table_alias WHERE address='$fUsername'"); $result = db_query ("SELECT * FROM $table_alias WHERE address='$fUsername'");
if ($result['rows'] == 1) if ($result['rows'] == 1)
@ -157,7 +155,16 @@ if ($_SERVER['REQUEST_METHOD'] == "POST")
$goto = $row['goto']; $goto = $row['goto'];
} }
$Active = db_get_boolean(True); $Active = db_get_boolean(True);
$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)"); $result = db_query ("INSERT INTO $table_vacation (email,subject,body,domain,created,active) VALUES ('$fUsername','$fSubject','$fBody','$fDomain',NOW(),$Active)");
}
if ($result['rows'] != 1) 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 they've set themselves away OR back, delete any record of vacation emails.
if (!empty ($fBack) || !empty ($fAway)) if (!empty ($fBack) || !empty ($fAway))
{ {
$result = db_query ("DELETE FROM $table_vacation WHERE email='$USERID_USERNAME'"); $notActive = db_get_boolean(False);
$result2 = db_query ("DELETE FROM $table_vacation_notification WHERE on_vacation='$USERID_USERNAME'"); // this isn't very good, as $result['rows'] would be 0 if the user had not used vacation stuff before.
if ($result['rows'] != 1) $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'");
$error = 1;
$tMessage = $PALANG['pUsersVacation_result_error']; $tMessage = $PALANG['pUsersVacation_result_error'];
}
else
{
$tMessage = $PALANG['pUsersVacation_result_success'];
}
// We need to see whether there is already an alias record for the user, or not. // 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. // If not, we create one, else update the existing one.
@ -146,7 +140,14 @@ if ($_SERVER['REQUEST_METHOD'] == "POST")
$tGoto = $row['goto']; $tGoto = $row['goto'];
} }
$Active = db_get_boolean(True); $Active = db_get_boolean(True);
$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)"); $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) if ($result['rows'] != 1)
{ {
$error = 1; $error = 1;

Loading…
Cancel
Save