@ -55,7 +55,7 @@ else {
$fUsername = $SESSID_USERNAME;
$fDomain = $USERID_DOMAIN;
}
$vh = new VacationHandler($fUsername);
$vacation_domain = $CONF['vacation_domain'];
$vacation_goto = preg_replace('/@/', '#', $fUsername);
$vacation_goto = $vacation_goto . '@' . $vacation_domain;
@ -85,7 +85,7 @@ if ($_SERVER['REQUEST_METHOD'] == "GET")
if ($_SERVER['REQUEST_METHOD'] == "POST")
{
$tSubject = safepost('fSubject');
$fSubject = escape_string ($tSubject);
$tBody = safepost('fBody');
@ -114,38 +114,10 @@ if ($_SERVER['REQUEST_METHOD'] == "POST")
if ($tBody == '') { $tBody = html_entity_decode($PALANG['pUsersVacation_body_text'], ENT_QUOTES, 'UTF-8'); }
//if change, remove old one, then perhaps set new one
if (!empty ($fBack) || !empty ($fChange) )
if (!empty ($fBack))
{
//if we find an existing vacation entry, disable it
$result = db_query("SELECT * FROM $table_vacation WHERE email='$fUsername'");
if ($result['rows'] == 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("DELETE FROM $table_vacation_notification WHERE on_vacation='$fUsername'");
$result = db_query ("SELECT * FROM $table_alias WHERE address='$fUsername'");
if ($result['rows'] == 1)
{
$row = db_array ($result['result']);
$goto = $row['goto'];
//only one of these will do something, first handles address at beginning and middle, second at end
$goto= preg_replace ( "/$vacation_goto,/", '', $goto);
$goto= preg_replace ( "/,$vacation_goto/", '', $goto);
$goto= preg_replace ( "/$vacation_goto/", '', $goto);
if($goto == '') {
$sql = "DELETE FROM $table_alias WHERE address = '$fUsername'";
}
else {
$sql = "UPDATE $table_alias SET goto='$goto',modified=NOW() WHERE address='$fUsername'";
}
$result = db_query($sql);
if ($result['rows'] != 1)
{
$error = 1;
}
}
if(!$vh->remove()) {
$error = 1;
}
}
@ -153,42 +125,10 @@ if ($_SERVER['REQUEST_METHOD'] == "POST")
//Set the vacation data for $fUsername
if (!empty ($fChange))
{
$goto = '';
$result = db_query ("SELECT * FROM $table_alias WHERE address='$fUsername'");
if ($result['rows'] == 1)
{
$row = db_array ($result['result']);
$goto = $row['goto'];
}
$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', subject = '$fSubject', body = '$fBody', created = NOW(), activefrom = '$tActiveFrom', activeuntil = '$tActiveUntil' WHERE email = '$fUsername'");
}
else {
$result = db_query ("INSERT INTO $table_vacation (email,subject,body,domain,created,active, activefrom, activeuntil) VALUES ('$fUsername','$fSubject','$fBody','$fDomain',NOW(),$Active, '$tActiveFrom', '$tActiveUntil')");
}
if ($result['rows'] != 1)
{
$error = 1;
}
if($goto == '') {
$goto = $vacation_goto;
$sql = "INSERT INTO $table_alias (goto, address, domain, modified, activefrom, activeuntil) VALUES ('$goto', '$fUsername', '$fDomain', NOW(), '$tActiveFrom', '$tActiveUntil')";
}
else {
$goto = $goto . "," . $vacation_goto;
$sql = "UPDATE $table_alias SET goto='$goto',modified=NOW() WHERE address='$fUsername'";
}
$result = db_query ($sql);
if ($result['rows'] != 1)
{
$error = 1;
}
if(!$vh->set_away($fSubject, $fBody, $tActiveFrom, $tActiveUntil)) {
$error = 1;
}
}
}