Skip to content

Commit 0837aff

Browse files
committed
- Fetchmail limits of Client were not obeyed.
1 parent 81b5e26 commit 0837aff

File tree

2 files changed

+39
-0
lines changed

2 files changed

+39
-0
lines changed

interface/web/mail/lib/lang/en_mail_get.lng

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,4 +9,5 @@ $wb["destination_txt"] = 'Destination';
99
$wb["active_txt"] = 'Active';
1010
$wb["btn_save_txt"] = 'Save';
1111
$wb["btn_cancel_txt"] = 'Cancel';
12+
$wb["limit_fetchmail_txt"] = 'The max. number of Fetchmail records for your account is reached.';
1213
?>

interface/web/mail/mail_get_edit.php

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -50,9 +50,47 @@
5050

5151
class page_action extends tform_actions {
5252

53+
function onShowNew() {
54+
global $app, $conf;
55+
56+
// we will check only users, not admins
57+
if($_SESSION["s"]["user"]["typ"] == 'user') {
58+
59+
// Get the limits of the client
60+
$client_group_id = $_SESSION["s"]["user"]["default_group"];
61+
$client = $app->db->queryOneRecord("SELECT limit_fetchmail FROM sys_group, client WHERE sys_group.client_id = client.client_id and sys_group.groupid = $client_group_id");
62+
63+
// Check if the user may add another transport.
64+
if($client["limit_fetchmail"] >= 0) {
65+
$tmp = $app->db->queryOneRecord("SELECT count(mailget_id) as number FROM mail_get WHERE sys_groupid = $client_group_id");
66+
if($tmp["number"] >= $client["limit_fetchmail"]) {
67+
$app->error($app->tform->wordbook["limit_fetchmail_txt"]);
68+
}
69+
}
70+
}
71+
72+
parent::onShowNew();
73+
}
74+
5375
function onSubmit() {
5476
global $app, $conf;
5577

78+
// Check the client limits, if user is not the admin
79+
if($_SESSION["s"]["user"]["typ"] != 'admin') { // if user is not admin
80+
// Get the limits of the client
81+
$client_group_id = $_SESSION["s"]["user"]["default_group"];
82+
$client = $app->db->queryOneRecord("SELECT limit_fetchmail FROM sys_group, client WHERE sys_group.client_id = client.client_id and sys_group.groupid = $client_group_id");
83+
84+
// Check if the user may add another transport.
85+
if($this->id == 0 && $client["limit_fetchmail"] >= 0) {
86+
$tmp = $app->db->queryOneRecord("SELECT count(mailget_id) as number FROM mail_get WHERE sys_groupid = $client_group_id");
87+
if($tmp["number"] >= $client["limit_fetchmail"]) {
88+
$app->tform->errorMessage .= $app->tform->wordbook["limit_fetchmail_txt"]."<br>";
89+
}
90+
unset($tmp);
91+
}
92+
} // end if user is not admin
93+
5694
// Set the server ID according to the selected destination
5795
$tmp = $app->db->queryOneRecord("SELECT server_id FROM mail_user WHERE email = '".addslashes($this->dataRecord["destination"])."'");
5896
$this->dataRecord["server_id"] = $tmp["server_id"];

0 commit comments

Comments
 (0)