Makes usage of mailbox_limit optional. User can choose wheather to use it or not by commenting in or out the define in config.inc.php
This commit is contained in:
parent
5d1f032b01
commit
bb78acda7f
4 changed files with 78 additions and 45 deletions
|
@ -146,6 +146,12 @@ At first the database access has to be configured.
|
|||
define("DBC_ALIASES_SOURCE", "source");
|
||||
define("DBC_ALIASES_DESTINATION", "destination");
|
||||
|
||||
If you have a "mailbox_limit" column to limit the size of your users' mailboxes, just comment in the line
|
||||
|
||||
define("DBC_USERS_MAILBOXLIMIT", "mailbox_limit");
|
||||
|
||||
in your configuration. WebMUM will then show a new field "Mailbox limit" in the frontend.
|
||||
|
||||
### Paths
|
||||
|
||||
Define the URL of the web application, and it's subfolder:
|
||||
|
|
|
@ -24,7 +24,7 @@ define("DBC_USERS_ID", "id");
|
|||
define("DBC_USERS_USERNAME", "username");
|
||||
define("DBC_USERS_DOMAIN", "domain");
|
||||
define("DBC_USERS_PASSWORD", "password");
|
||||
define("DBC_USERS_MAILBOXLIMIT", "mailbox_limit");
|
||||
// define("DBC_USERS_MAILBOXLIMIT", "mailbox_limit"); // (Optional)
|
||||
|
||||
// Domains table columns
|
||||
define("DBC_DOMAINS_ID", "id");
|
||||
|
|
|
@ -1,14 +1,17 @@
|
|||
<?php
|
||||
// Get mailbox_limit default value from DB
|
||||
$sql = "SELECT DEFAULT(".DBC_USERS_MAILBOXLIMIT.") AS `".DBC_USERS_MAILBOXLIMIT."` FROM `".DBT_USERS."` LIMIT 1;";
|
||||
|
||||
if(!$result = $db->query($sql)){
|
||||
die('There was an error running the query [' . $db->error . ']');
|
||||
}
|
||||
|
||||
else{
|
||||
while($row = $result->fetch_assoc()){
|
||||
$mailbox_limit_default = $row[DBC_USERS_MAILBOXLIMIT];
|
||||
// If mailbox_limit is supported in the MySQL database
|
||||
if(defined('DBC_USERS_MAILBOXLIMIT')){
|
||||
// Get mailbox_limit default value from DB
|
||||
$sql = "SELECT DEFAULT(".DBC_USERS_MAILBOXLIMIT.") AS `".DBC_USERS_MAILBOXLIMIT."` FROM `".DBT_USERS."` LIMIT 1;";
|
||||
|
||||
if(!$result = $db->query($sql)){
|
||||
die('There was an error running the query [' . $db->error . ']');
|
||||
}
|
||||
|
||||
else{
|
||||
while($row = $result->fetch_assoc()){
|
||||
$mailbox_limit_default = $row[DBC_USERS_MAILBOXLIMIT];
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -19,38 +22,39 @@
|
|||
if($savemode === "edit"){
|
||||
// Edit mode entered
|
||||
$id = $db->escape_string($_POST['id']);
|
||||
if($mailbox_limit == ""){
|
||||
$mailbox_limit = $mailbox_limit_default;
|
||||
}
|
||||
$mailbox_limit = $db->escape_string($_POST['mailbox_limit']);
|
||||
|
||||
$sql = "UPDATE `".DBT_USERS."` SET `".DBC_USERS_MAILBOXLIMIT."` = '$mailbox_limit' WHERE `".DBC_USERS_ID."` = '$id';";
|
||||
if(!$result = $db->query($sql)){
|
||||
die('There was an error running the query [' . $db->error . ']');
|
||||
if(defined('DBC_USERS_MAILBOXLIMIT')){
|
||||
if($mailbox_limit == ""){
|
||||
$mailbox_limit = $mailbox_limit_default;
|
||||
}
|
||||
$mailbox_limit = $db->escape_string($_POST['mailbox_limit']);
|
||||
|
||||
$sql = "UPDATE `".DBT_USERS."` SET `".DBC_USERS_MAILBOXLIMIT."` = '$mailbox_limit' WHERE `".DBC_USERS_ID."` = '$id';";
|
||||
if(!$result = $db->query($sql)){
|
||||
die('There was an error running the query [' . $db->error . ']');
|
||||
}
|
||||
}
|
||||
else{
|
||||
// SQL was successful
|
||||
// Is there a changed password?
|
||||
if($_POST['password'] !== ""){
|
||||
$pass_ok = check_new_pass($_POST['password'], $_POST['password_rep']);
|
||||
if($pass_ok === true){
|
||||
// Password is okay and can be set
|
||||
$pass_hash = gen_pass_hash($_POST['password']);
|
||||
write_pass_hash_to_db($pass_hash, $id);
|
||||
// $editsuccessful = true;
|
||||
add_message("success", "User edited successfully.");
|
||||
|
||||
}
|
||||
else{
|
||||
// Password is not okay
|
||||
// $editsuccessful = 2;
|
||||
add_message("fail", $PASS_ERR_MSG);
|
||||
}
|
||||
|
||||
// Is there a changed password?
|
||||
if($_POST['password'] !== ""){
|
||||
$pass_ok = check_new_pass($_POST['password'], $_POST['password_rep']);
|
||||
if($pass_ok === true){
|
||||
// Password is okay and can be set
|
||||
$pass_hash = gen_pass_hash($_POST['password']);
|
||||
write_pass_hash_to_db($pass_hash, $id);
|
||||
// $editsuccessful = true;
|
||||
add_message("success", "User edited successfully.");
|
||||
|
||||
}
|
||||
else{
|
||||
// Redirect user to user list
|
||||
header("Location: ".FRONTEND_BASE_PATH."admin/listusers/?edited=1");
|
||||
// Password is not okay
|
||||
// $editsuccessful = 2;
|
||||
add_message("fail", $PASS_ERR_MSG);
|
||||
}
|
||||
}
|
||||
else{
|
||||
// Redirect user to user list
|
||||
header("Location: ".FRONTEND_BASE_PATH."admin/listusers/?edited=1");
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -58,7 +62,13 @@
|
|||
// Create mode entered
|
||||
$username = $db->escape_string($_POST['username']);
|
||||
$domain = $db->escape_string($_POST['domain']);
|
||||
$mailbox_limit = $db->escape_string($_POST['mailbox_limit']);
|
||||
if(defined('DBC_USERS_MAILBOXLIMIT')){
|
||||
$mailbox_limit = $db->escape_string($_POST['mailbox_limit']);
|
||||
}
|
||||
else{
|
||||
// make mailbox_limit dummy for "if"
|
||||
$mailbox_limit = 0;
|
||||
}
|
||||
$pass = $_POST['password'];
|
||||
$pass_rep = $_POST['password_rep'];
|
||||
|
||||
|
@ -70,7 +80,13 @@
|
|||
// Password is okay ... continue
|
||||
$pass_hash = gen_pass_hash($pass);
|
||||
|
||||
$sql = "INSERT INTO `".DBT_USERS."` (`".DBC_USERS_USERNAME."`, `".DBC_USERS_DOMAIN."`, `".DBC_USERS_PASSWORD."`, `".DBC_USERS_MAILBOXLIMIT."`) VALUES ('$username', '$domain', '$pass_hash', '$mailbox_limit')";
|
||||
// Differ between version with mailbox_limit and version without
|
||||
if(defined('DBC_USERS_MAILBOXLIMIT')){
|
||||
$sql = "INSERT INTO `".DBT_USERS."` (`".DBC_USERS_USERNAME."`, `".DBC_USERS_DOMAIN."`, `".DBC_USERS_PASSWORD."`, `".DBC_USERS_MAILBOXLIMIT."`) VALUES ('$username', '$domain', '$pass_hash', '$mailbox_limit')";
|
||||
}
|
||||
else{
|
||||
$sql = "INSERT INTO `".DBT_USERS."` (`".DBC_USERS_USERNAME."`, `".DBC_USERS_DOMAIN."`, `".DBC_USERS_PASSWORD."`) VALUES ('$username', '$domain', '$pass_hash')";
|
||||
}
|
||||
|
||||
if(!$result = $db->query($sql)){
|
||||
die('There was an error running the query [' . $db->error . ']');
|
||||
|
@ -110,7 +126,9 @@
|
|||
while($row = $result->fetch_assoc()){
|
||||
$username = $row[DBC_USERS_USERNAME];
|
||||
$domain = $row[DBC_USERS_DOMAIN];
|
||||
$mailbox_limit = $row[DBC_USERS_MAILBOXLIMIT];
|
||||
if(defined('DBC_USERS_MAILBOXLIMIT')){
|
||||
$mailbox_limit = $row[DBC_USERS_MAILBOXLIMIT];
|
||||
}
|
||||
}
|
||||
}
|
||||
?>
|
||||
|
@ -137,7 +155,7 @@
|
|||
|
||||
<form action="" method="post">
|
||||
<table>
|
||||
<tr> <th>Username</th> <th>Domain</th> <th>Password</th> <th>Mailbox limit (in MB)</th> </tr>
|
||||
<tr> <th>Username</th> <th>Domain</th> <th>Password</th> <?php if(defined('DBC_USERS_MAILBOXLIMIT')){ ?><th>Mailbox limit (in MB)</th> <?php } ?> </tr>
|
||||
|
||||
<tr>
|
||||
<td>
|
||||
|
@ -169,9 +187,11 @@
|
|||
<input name="password_rep" class="textinput" type="password" placeholder="New password (repeat)"/>
|
||||
</td>
|
||||
|
||||
<?php if(defined('DBC_USERS_MAILBOXLIMIT')){ ?>
|
||||
<td>
|
||||
<input name="mailbox_limit" class="textinput" type="number" value="<?php if(isset($mailbox_limit)){echo $mailbox_limit;} else{echo $mailbox_limit_default;} ?>" placeholder="Mailbox size (MB)" required="required"/>
|
||||
</td>
|
||||
<?php } ?>
|
||||
</tr>
|
||||
|
||||
</table>
|
||||
|
|
|
@ -38,11 +38,18 @@ if(!$result = $db->query($sql)){
|
|||
</p>
|
||||
|
||||
<table class="list">
|
||||
<tr class="head"><th>Username</th> <th>Domain</th> <th>Mailbox Limit (MB)</th> <th></th> <th></th><tr>
|
||||
<tr class="head"><th>Username</th> <th>Domain</th> <?php if(defined('DBC_USERS_MAILBOXLIMIT')){ ?><th>Mailbox Limit (MB)</th> <?php } ?><th></th> <th></th><tr>
|
||||
|
||||
<?php
|
||||
<?php
|
||||
while($row = $result->fetch_assoc()){
|
||||
echo "<tr><td>".$row[DBC_USERS_USERNAME]."</td><td>".$row[DBC_USERS_DOMAIN]."</td><td>".$row[DBC_USERS_MAILBOXLIMIT]."<td><a href=\"".FRONTEND_BASE_PATH."admin/edituser/?id=".$row[DBC_USERS_ID]."\">[Edit]</a></td> <td><a href=\"".FRONTEND_BASE_PATH."admin/deleteuser/?id=".$row[DBC_USERS_ID]."\">[Delete]</a></td> </tr>";
|
||||
if(defined('DBC_USERS_MAILBOXLIMIT')){
|
||||
$mailbox_limit_column = '<td>'.$row[DBC_USERS_MAILBOXLIMIT].'</td>';
|
||||
}
|
||||
else{
|
||||
$mailbox_limit_column = '';
|
||||
}
|
||||
|
||||
echo "<tr> <td>".$row[DBC_USERS_USERNAME]."</td><td>".$row[DBC_USERS_DOMAIN]."</td>".$mailbox_limit_column."<td><a href=\"".FRONTEND_BASE_PATH."admin/edituser/?id=".$row[DBC_USERS_ID]."\">[Edit]</a></td> <td><a href=\"".FRONTEND_BASE_PATH."admin/deleteuser/?id=".$row[DBC_USERS_ID]."\">[Delete]</a></td> </tr>";
|
||||
}
|
||||
?>
|
||||
</table>
|
Loading…
Add table
Reference in a new issue