Made it possible for admins and superadmins to set a vacation message,
edit vacation messages, and remove them. main.php added to admin directory so admin and / can share more templates. the new edit-vacation.php in admin and / are identical except for template references languages/en.lang and languages/default.lang are in sync now I attempted to add some of the new .lang variables I created to the spanish file (I don't know it that well, hope its OK) fixed a bug in users/vacation.php Added a "Main" menu item to the admin menu that gets you back to where you started when you log in. git-svn-id: https://svn.code.sf.net/p/postfixadmin/code/trunk@2 a1433add-5e2c-0410-b055-b7f2511e0802postfixadmin-2.3
parent
85dc57beee
commit
a5ce5620cf
@ -0,0 +1,193 @@
|
||||
<?php
|
||||
//
|
||||
// Postfix Admin
|
||||
// by Mischa Peters <mischa at high5 dot net>
|
||||
// Copyright (c) 2002 - 2007 High5!
|
||||
// Licensed under GPL for more info check GPL-LICENSE.TXT
|
||||
//
|
||||
// File: edit-vacation.php
|
||||
//
|
||||
// Template File: edit-vacation.tpl
|
||||
//
|
||||
// Template Variables:
|
||||
//
|
||||
// tMessage
|
||||
// tSubject
|
||||
// tBody
|
||||
//
|
||||
// Form POST \ GET Variables:
|
||||
//
|
||||
// fUsername
|
||||
// fDomain
|
||||
// fCanceltarget
|
||||
// fChange
|
||||
// fBack
|
||||
// fQuota
|
||||
// fActive
|
||||
//
|
||||
//
|
||||
// This is a copy of the domain admin edit-vacation.php with
|
||||
// template references changed
|
||||
//
|
||||
require ("../variables.inc.php");
|
||||
require ("../config.inc.php");
|
||||
require ("../functions.inc.php");
|
||||
include ("../languages/" . check_language () . ".lang");
|
||||
|
||||
$SESSID_USERNAME = check_session ();
|
||||
(($CONF['vacation'] == 'NO') ? header("Location: " . $CONF['postfix_admin_url'] . "/main.php") && exit : '1');
|
||||
$tmp = preg_split ('/@/', $SESSID_USERNAME);
|
||||
$USERID_DOMAIN = $tmp[1];
|
||||
|
||||
if ($_SERVER['REQUEST_METHOD'] == "GET")
|
||||
{
|
||||
if (isset ($_GET['username'])) $fUsername = escape_string ($_GET['username']);
|
||||
if (isset ($_GET['domain'])) $fDomain = escape_string ($_GET['domain']);
|
||||
|
||||
if (check_admin($SESSID_USERNAME))
|
||||
{
|
||||
$fCanceltarget= $CONF['postfix_admin_url'] . "/admin/list-virtual.php?domain=$fDomain";
|
||||
}
|
||||
else
|
||||
{
|
||||
if (check_owner ($SESSID_USERNAME, $fDomain))
|
||||
{
|
||||
$fCanceltarget= $CONF['postfix_admin_url'] . "/overview.php?domain=$fDomain";
|
||||
}
|
||||
//unauthorized, exit
|
||||
else { exit; }
|
||||
}
|
||||
|
||||
$result = db_query("SELECT * FROM $table_vacation WHERE email='$fUsername'");
|
||||
if ($result['rows'] == 1)
|
||||
{
|
||||
$row = db_array($result['result']);
|
||||
$tMessage = '';
|
||||
$tSubject = $row['subject'];
|
||||
$tBody = $row['body'];
|
||||
}
|
||||
|
||||
$tUseremail = $fUsername;
|
||||
if ($tSubject == '') { $tSubject = $PALANG['pUsersVacation_subject_text']; }
|
||||
if ($tBody == '') { $tBody = $PALANG['pUsersVacation_body_text']; }
|
||||
|
||||
|
||||
|
||||
include ("../templates/header.tpl");
|
||||
include ("../templates/admin_menu.tpl");
|
||||
include ("../templates/edit-vacation.tpl");
|
||||
include ("../templates/footer.tpl");
|
||||
}
|
||||
|
||||
if ($_SERVER['REQUEST_METHOD'] == "POST")
|
||||
{
|
||||
$vacation_domain = $CONF['vacation_domain'];
|
||||
|
||||
if (isset ($_POST['fSubject'])) $fSubject = escape_string ($_POST['fSubject']);
|
||||
if (isset ($_POST['fBody'])) $fBody = escape_string ($_POST['fBody']);
|
||||
if (isset ($_POST['fChange'])) $fChange = escape_string ($_POST['fChange']);
|
||||
if (isset ($_POST['fBack'])) $fBack = escape_string ($_POST['fBack']);
|
||||
|
||||
if (isset ($_GET['domain'])) $fDomain = escape_string ($_GET['domain']);
|
||||
if (isset ($_GET['username'])) $fUsername = escape_string ($_GET['username']);
|
||||
|
||||
if (check_admin($SESSID_USERNAME))
|
||||
{
|
||||
$fCanceltarget= $CONF['postfix_admin_url'] . "/admin/list-virtual.php?domain=$fDomain";
|
||||
}
|
||||
else
|
||||
{
|
||||
if (check_owner ($SESSID_USERNAME, $fDomain))
|
||||
{
|
||||
$fCanceltarget= $CONF['postfix_admin_url'] . "/overview.php?domain=$fDomain";
|
||||
}
|
||||
//unauthorized, exit
|
||||
else { exit; }
|
||||
}
|
||||
|
||||
$tUseremail = $fUsername;
|
||||
if ($tSubject == '') { $tSubject = $PALANG['pUsersVacation_subject_text']; }
|
||||
if ($tBody == '') { $tBody = $PALANG['pUsersVacation_body_text']; }
|
||||
|
||||
//if change, remove old one, then set new one
|
||||
if (!empty ($fBack) || !empty ($fChange))
|
||||
{
|
||||
//if we find an existing vacation entry, delete 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;
|
||||
$tMessage = $PALANG['pVacation_result_error'];
|
||||
$tMessage = "cannot remove $fUsername from $table_vacation";
|
||||
}
|
||||
else
|
||||
{
|
||||
$tMessage = $PALANG['pVacation_result_success'];
|
||||
}
|
||||
|
||||
$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 ( "/$fUsername@$vacation_domain,/", '', $goto);
|
||||
$goto= preg_replace ( "/,$fUsername@$vacation_domain/", '', $goto);
|
||||
|
||||
$result = db_query ("UPDATE $table_alias SET goto='$goto',modified=NOW() WHERE address='$fUsername'");
|
||||
if ($result['rows'] != 1)
|
||||
{
|
||||
$error = 1;
|
||||
$tMessage = $PALANG['pVacation_result_error'];
|
||||
}
|
||||
else
|
||||
{
|
||||
$tMessage = $PALANG['pVacation_result_success'];
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
//Set the vacation data for $fUsername
|
||||
if (!empty ($fChange))
|
||||
{
|
||||
$result = db_query ("SELECT * FROM $table_alias WHERE address='$fUsername'");
|
||||
if ($result['rows'] == 1)
|
||||
{
|
||||
$row = db_array ($result['result']);
|
||||
$goto = $row['goto'];
|
||||
}
|
||||
|
||||
($CONF['database_type']=='pgsql') ? $Active='true' : $Active=1;
|
||||
$result = db_query ("INSERT INTO $table_vacation (email,subject,body,domain,created,active) VALUES ('$fUsername','$fSubject','$fBody','$fDomain',NOW(),$Active)");
|
||||
if ($result['rows'] != 1)
|
||||
{
|
||||
$error = 1;
|
||||
$tMessage = $PALANG['pVacation_result_error'];
|
||||
}
|
||||
|
||||
$goto = $goto . "," . "$fUsername@$vacation_domain";
|
||||
|
||||
$result = db_query ("UPDATE $table_alias SET goto='$goto',modified=NOW() WHERE address='$fUsername'");
|
||||
if ($result['rows'] != 1)
|
||||
{
|
||||
$error = 1;
|
||||
$tMessage = $PALANG['pVacation_result_error'];
|
||||
}
|
||||
else
|
||||
{
|
||||
header ("Location: $fCanceltarget");
|
||||
exit;
|
||||
}
|
||||
}
|
||||
|
||||
include ("../templates/header.tpl");
|
||||
include ("../templates/admin_menu.tpl");
|
||||
include ("../templates/edit-vacation.tpl");
|
||||
include ("../templates/footer.tpl");
|
||||
}
|
||||
?>
|
@ -0,0 +1,22 @@
|
||||
<?php
|
||||
//
|
||||
// Postfix Admin
|
||||
// by Mischa Peters <mischa at high5 dot net>
|
||||
// Copyright (c) 2002 - 2005 High5!
|
||||
// Licensed under GPL for more info check GPL-LICENSE.TXT
|
||||
//
|
||||
// File: main.php
|
||||
//
|
||||
// Template File: -none-
|
||||
//
|
||||
// Template Variables:
|
||||
//
|
||||
// -none-
|
||||
//
|
||||
// Form POST \ GET Variables:
|
||||
//
|
||||
// -none-
|
||||
//
|
||||
header ("Location: list-admin.php");
|
||||
exit;
|
||||
?>
|
@ -1,25 +1,44 @@
|
||||
<script type="text/javascript">
|
||||
function newLocation()
|
||||
{
|
||||
window.location="<?php print $fCanceltarget; ?>"
|
||||
|
||||
}
|
||||
</script>
|
||||
<div id="edit_form">
|
||||
|
||||
<form name="edit-vacation" method="post">
|
||||
<table>
|
||||
<tr>
|
||||
<td colspan="3"><h3><?php print $PALANG['pUsersVacation_welcome']; ?></h3></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td><?php print $PALANG['pUsersLogin_username'] . ":"; ?></td>
|
||||
<td><?php print $row['email']; ?></td>
|
||||
<td><?php print $tUseremail; ?></td>
|
||||
<td> </td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td><?php print $PALANG['pUsersVacation_subject'] . ":"; ?></td>
|
||||
<td><textarea class="flat" cols="60" disabled="disabled"><?php print $row['subject']; ?></textarea></td>
|
||||
<td><textarea class="flat" cols="60" name="fSubject" ><?php print $tSubject; ?></textarea></td>
|
||||
<td> </td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td><?php print $PALANG['pUsersVacation_body'] . ":"; ?></td>
|
||||
<td><textarea class="flat" rows="10" cols="60" disabled="disabled"><?php print htmlentities($row['body'],ENT_QUOTES); ?></textarea></td>
|
||||
<td><textarea class="flat" rows="10" cols="60" name="fBody" ><?php print htmlentities($tBody,ENT_QUOTES); ?></textarea></td>
|
||||
<td> </td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td colspan="3" class="hlp_center">
|
||||
|
||||
<input class="button" type="submit" name="fChange" value="<?php print $PALANG['pEdit_vacation_set']; ?>" />
|
||||
<input class="button" type="submit" name="fBack" value="<?php print $PALANG['pEdit_vacation_remove']; ?>" />
|
||||
<input class="button" type="button" name="fCancel" value="<?php print $PALANG['exit']; ?>" onclick="newLocation()" />
|
||||
</td>
|
||||
</tr>
|
||||
|
||||
<tr>
|
||||
<td colspan="3" class="standout"><?php print $tMessage; ?></td>
|
||||
</tr>
|
||||
</table>
|
||||
</form>
|
||||
</div>
|
||||
|
@ -1,3 +0,0 @@
|
||||
</center>
|
||||
</body>
|
||||
</html>
|
Loading…
Reference in New Issue