Skip to content

Commit 4d5369a

Browse files
author
Marius Burkard
committed
Merge branch '6347-notifications-to-reseller-not-working' into 'develop'
Resolve "Notifications to reseller not working" Closes #6347 See merge request ispconfig/ispconfig3!1610
2 parents f2c2137 + 48edbdf commit 4d5369a

File tree

1 file changed

+20
-54
lines changed

1 file changed

+20
-54
lines changed

server/lib/classes/cron.d/300-quota_notify.inc.php

Lines changed: 20 additions & 54 deletions
Original file line numberDiff line numberDiff line change
@@ -57,6 +57,13 @@ public function onRunJob() {
5757

5858
$web_config = $app->getconf->get_server_config($conf['server_id'], 'web');
5959

60+
// Get client email and eventual reseller email
61+
$client_group_id = $rec["sys_groupid"];
62+
$client = $app->db->queryOneRecord("SELECT client.email, client.parent_client_id FROM sys_group, client WHERE sys_group.client_id = client.client_id and sys_group.groupid = ?", $client_group_id);
63+
if($client['parent_client_id'] > 0) {
64+
$reseller = $app->db->queryOneRecord("SELECT email FROM client WHERE client_id = ?", $client['parent_client_id']);
65+
}
66+
6067
//######################################################################################################
6168
// enforce traffic quota (run only on the "master-server")
6269
//######################################################################################################
@@ -107,20 +114,13 @@ public function onRunJob() {
107114

108115
//* Send email to reseller
109116
if($web_config['overtraffic_notify_reseller'] == 'y') {
110-
$client_group_id = $rec["sys_groupid"];
111-
$app->db->queryOneRecord("SELECT parent_client_id FROM sys_group, client WHERE sys_group.client_id = client.client_id and sys_group.groupid = ?", $client_group_id);
112-
if($client['parent_client_id'] > 0) {
113-
$reseller = $app->db->queryOneRecord("SELECT email FROM client WHERE client_id = ?", $client['parent_client_id']);
114-
}
115117
if($reseller['email'] != '') {
116118
$recipients[] = $reseller['email'];
117119
}
118120
}
119121

120122
//* Send email to client
121123
if($web_config['overtraffic_notify_client'] == 'y') {
122-
$client_group_id = $rec["sys_groupid"];
123-
$client = $app->db->queryOneRecord("SELECT client.email FROM sys_group, client WHERE sys_group.client_id = client.client_id and sys_group.groupid = ?", $client_group_id);
124124
if($client['email'] != '') {
125125
$recipients[] = $client['email'];
126126
}
@@ -245,20 +245,13 @@ public function onRunJob() {
245245

246246
//* Send email to reseller
247247
if($web_config['overquota_notify_reseller'] == 'y') {
248-
$client_group_id = $rec["sys_groupid"];
249-
$app->db->queryOneRecord("SELECT parent_client_id FROM sys_group, client WHERE sys_group.client_id = client.client_id and sys_group.groupid = ?", $client_group_id);
250-
if($client['parent_client_id'] > 0) {
251-
$reseller = $app->db->queryOneRecord("SELECT email FROM client WHERE client_id = ?", $client['parent_client_id']);
252-
}
253248
if($reseller['email'] != '') {
254249
$recipients[] = $reseller['email'];
255250
}
256251
}
257252

258253
//* Send email to client
259254
if($web_config['overquota_notify_client'] == 'y') {
260-
$client_group_id = $rec["sys_groupid"];
261-
$client = $app->db->queryOneRecord("SELECT client.email FROM sys_group, client WHERE sys_group.client_id = client.client_id and sys_group.groupid = ?", $client_group_id);
262255
if($client['email'] != '') {
263256
$recipients[] = $client['email'];
264257
}
@@ -292,20 +285,13 @@ public function onRunJob() {
292285

293286
//* Send email to reseller
294287
if($web_config['overquota_notify_reseller'] == 'y') {
295-
$client_group_id = $rec["sys_groupid"];
296-
$app->db->queryOneRecord("SELECT parent_client_id FROM sys_group, client WHERE sys_group.client_id = client.client_id and sys_group.groupid = ?", $client_group_id);
297-
if($client['parent_client_id'] > 0) {
298-
$reseller = $app->db->queryOneRecord("SELECT email FROM client WHERE client_id = ?", $client['parent_client_id']);
299-
}
300288
if($reseller['email'] != '') {
301289
$recipients[] = $reseller['email'];
302290
}
303291
}
304292

305293
//* Send email to client
306294
if($web_config['overquota_notify_client'] == 'y') {
307-
$client_group_id = $rec["sys_groupid"];
308-
$client = $app->db->queryOneRecord("SELECT client.email FROM sys_group, client WHERE sys_group.client_id = client.client_id and sys_group.groupid = ?", $client_group_id);
309295
if($client['email'] != '') {
310296
$recipients[] = $client['email'];
311297
}
@@ -397,20 +383,13 @@ public function onRunJob() {
397383

398384
//* Send email to reseller
399385
if($web_config['overquota_notify_reseller'] == 'y') {
400-
$client_group_id = $rec["sys_groupid"];
401-
$app->db->queryOneRecord("SELECT parent_client_id FROM sys_group, client WHERE sys_group.client_id = client.client_id and sys_group.groupid = ?", $client_group_id);
402-
if($client['parent_client_id'] > 0) {
403-
$reseller = $app->db->queryOneRecord("SELECT email FROM client WHERE client_id = ?", $client['parent_client_id']);
404-
}
405386
if($reseller['email'] != '') {
406387
$recipients[] = $reseller['email'];
407388
}
408389
}
409390

410391
//* Send email to client
411392
if($mail_config['overquota_notify_client'] == 'y') {
412-
$client_group_id = $rec["sys_groupid"];
413-
$client = $app->db->queryOneRecord("SELECT client.email FROM sys_group, client WHERE sys_group.client_id = client.client_id and sys_group.groupid = ?", $client_group_id);
414393
if($client['email'] != '') {
415394
$recipients[] = $client['email'];
416395
}
@@ -444,20 +423,13 @@ public function onRunJob() {
444423

445424
//* Send email to reseller
446425
if($web_config['overquota_notify_reseller'] == 'y') {
447-
$client_group_id = $rec["sys_groupid"];
448-
$app->db->queryOneRecord("SELECT parent_client_id FROM sys_group, client WHERE sys_group.client_id = client.client_id and sys_group.groupid = ?", $client_group_id);
449-
if($client['parent_client_id'] > 0) {
450-
$reseller = $app->db->queryOneRecord("SELECT email FROM client WHERE client_id = ?", $client['parent_client_id']);
451-
}
452426
if($reseller['email'] != '') {
453427
$recipients[] = $reseller['email'];
454428
}
455429
}
456430

457431
//* Send email to client
458432
if($mail_config['overquota_notify_client'] == 'y') {
459-
$client_group_id = $rec["sys_groupid"];
460-
$client = $app->db->queryOneRecord("SELECT client.email FROM sys_group, client WHERE sys_group.client_id = client.client_id and sys_group.groupid = ?", $client_group_id);
461433
if($client['email'] != '') {
462434
$recipients[] = $client['email'];
463435
}
@@ -508,9 +480,6 @@ public function onRunJob() {
508480
foreach($cid as $monitor) {
509481

510482
if ($monitor['database_name'] == $database) {
511-
//* get the client
512-
$client = $app->db->queryOneRecord("SELECT client.username, client.email FROM web_database, sys_group, client WHERE web_database.sys_groupid = sys_group.groupid AND sys_group.client_id = client.client_id AND web_database.database_name=?", $database);
513-
514483
//* check quota
515484
if ($quota > 0) $used_ratio = $monitor['size'] / $quota;
516485
else $used_ratio = 0;
@@ -543,20 +512,17 @@ public function onRunJob() {
543512

544513
//* Send email to reseller
545514
if($web_config['overquota_db_notify_reseller'] == 'y') {
546-
$client_group_id = $rec["sys_groupid"];
547-
$app->db->queryOneRecord("SELECT parent_client_id FROM sys_group, client WHERE sys_group.client_id = client.client_id and sys_group.groupid = ?", $client_group_id);
548-
if($client['parent_client_id'] > 0) {
549-
$reseller = $app->db->queryOneRecord("SELECT email FROM client WHERE client_id = ?", $client['parent_client_id']);
550-
}
551515
if($reseller['email'] != '') {
552516
$recipients[] = $reseller['email'];
553517
}
554518
}
555519

556520
//* Send email to client
557-
if($web_config['overquota_db_notify_client'] == 'y' && $client['email'] != '')
558-
$recipients[] = $client['email'];
559-
521+
if($web_config['overquota_db_notify_client'] == 'y') {
522+
if($client['email'] != '') {
523+
$recipients[] = $client['email'];
524+
}
525+
}
560526
$this->_tools->send_notification_email('db_quota_notification', $placeholders, $recipients);
561527

562528
}
@@ -578,24 +544,24 @@ public function onRunJob() {
578544
$recipients = array();
579545

580546
//* send email to admin
581-
if($global_config['admin_mail'] != '' && $web_config['overquota_db_notify_admin'] == 'y')
547+
if($global_config['admin_mail'] != '' && $web_config['overquota_db_notify_admin'] == 'y') {
582548
$recipients[] = $global_config['admin_mail'];
549+
}
583550

584551
//* Send email to reseller
585552
if($web_config['overquota_db_notify_reseller'] == 'y') {
586-
$client_group_id = $rec["sys_groupid"];
587-
$app->db->queryOneRecord("SELECT parent_client_id FROM sys_group, client WHERE sys_group.client_id = client.client_id and sys_group.groupid = ?", $client_group_id);
588-
if($client['parent_client_id'] > 0) {
589-
$reseller = $app->db->queryOneRecord("SELECT email FROM client WHERE client_id = ?", $client['parent_client_id']);
590-
}
591553
if($reseller['email'] != '') {
592554
$recipients[] = $reseller['email'];
593555
}
594556
}
595557

596558
//* Send email to client
597-
if($web_config['overquota_db_notify_client'] == 'y' && $client['email'] != '')
598-
$recipients[] = $client['email'];
559+
if($mail_config['overquota_notify_client'] == 'y') {
560+
if($client['email'] != '') {
561+
$recipients[] = $client['email'];
562+
}
563+
}
564+
599565

600566
$this->_tools->send_notification_email('db_quota_ok_notification', $placeholders, $recipients);
601567

0 commit comments

Comments
 (0)