|
50 | 50 |
|
51 | 51 | class page_action extends tform_actions { |
52 | 52 |
|
| 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 | + |
53 | 75 | function onSubmit() { |
54 | 76 | global $app, $conf; |
55 | 77 |
|
| 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 | + |
56 | 94 | // Set the server ID according to the selected destination |
57 | 95 | $tmp = $app->db->queryOneRecord("SELECT server_id FROM mail_user WHERE email = '".addslashes($this->dataRecord["destination"])."'"); |
58 | 96 | $this->dataRecord["server_id"] = $tmp["server_id"]; |
|
0 commit comments