Skip to content

Commit 03346db

Browse files
author
Till Brehm
committed
Merge branch '6424-Notifications-to-reseller-and-clients-not-working' into 'develop'
FIX: Notifications to reseller and clients not working Issue #6424 Closes #6424 See merge request ispconfig/ispconfig3!1672
2 parents 291809c + cc39cc6 commit 03346db

File tree

1 file changed

+40
-35
lines changed

1 file changed

+40
-35
lines changed

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

Lines changed: 40 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -57,11 +57,18 @@ 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']);
60+
// Get client email and eventual reseller email in array
61+
$clients = [];
62+
$sql = "SELECT client.email,client.parent_client_id, sys_group.groupid FROM sys_group, client WHERE sys_group.client_id = client.client_id";
63+
$records = $app->db->queryAllRecords($sql);
64+
if(is_array($records)) {
65+
foreach($records as $rec) {
66+
$reseller = ($rec['parent_client_id'] > 0) ? $app->db->queryOneRecord("SELECT email FROM client WHERE client_id = ?", $rec['parent_client_id']) : '';
67+
$clients[$rec['groupid']] = [
68+
'email' => $rec['email'],
69+
'reseller' => $reseller
70+
];
71+
}
6572
}
6673

6774
//######################################################################################################
@@ -114,15 +121,15 @@ public function onRunJob() {
114121

115122
//* Send email to reseller
116123
if($web_config['overtraffic_notify_reseller'] == 'y') {
117-
if($reseller['email'] != '') {
118-
$recipients[] = $reseller['email'];
124+
if($clients[$rec['sys_groupid']]['reseller'] != '') {
125+
$recipients[] = $clients[$rec['sys_groupid']]['reseller'];
119126
}
120127
}
121128

122129
//* Send email to client
123130
if($web_config['overtraffic_notify_client'] == 'y') {
124-
if($client['email'] != '') {
125-
$recipients[] = $client['email'];
131+
if($clients[$rec['sys_groupid']]['email'] != '') {
132+
$recipients[] = $clients[$rec['sys_groupid']]['email'];
126133
}
127134
}
128135

@@ -245,15 +252,15 @@ public function onRunJob() {
245252

246253
//* Send email to reseller
247254
if($web_config['overquota_notify_reseller'] == 'y') {
248-
if($reseller['email'] != '') {
249-
$recipients[] = $reseller['email'];
255+
if($clients[$rec['sys_groupid']]['reseller'] != '') {
256+
$recipients[] = $clients[$rec['sys_groupid']]['reseller'];
250257
}
251258
}
252259

253260
//* Send email to client
254261
if($web_config['overquota_notify_client'] == 'y') {
255-
if($client['email'] != '') {
256-
$recipients[] = $client['email'];
262+
if($clients[$rec['sys_groupid']]['email'] != '') {
263+
$recipients[] = $clients[$rec['sys_groupid']]['email'];
257264
}
258265
}
259266
$this->_tools->send_notification_email('web_quota_ok_notification', $placeholders, $recipients);
@@ -285,15 +292,15 @@ public function onRunJob() {
285292

286293
//* Send email to reseller
287294
if($web_config['overquota_notify_reseller'] == 'y') {
288-
if($reseller['email'] != '') {
289-
$recipients[] = $reseller['email'];
295+
if($clients[$rec['sys_groupid']]['reseller'] != '') {
296+
$recipients[] = $clients[$rec['sys_groupid']]['reseller'];
290297
}
291298
}
292299

293300
//* Send email to client
294301
if($web_config['overquota_notify_client'] == 'y') {
295-
if($client['email'] != '') {
296-
$recipients[] = $client['email'];
302+
if($clients[$rec['sys_groupid']]['email'] != '') {
303+
$recipients[] = $clients[$rec['sys_groupid']]['email'];
297304
}
298305
}
299306
$this->_tools->send_notification_email('web_quota_notification', $placeholders, $recipients);
@@ -383,15 +390,15 @@ public function onRunJob() {
383390

384391
//* Send email to reseller
385392
if($web_config['overquota_notify_reseller'] == 'y') {
386-
if($reseller['email'] != '') {
387-
$recipients[] = $reseller['email'];
393+
if($clients[$rec['sys_groupid']]['reseller'] != '') {
394+
$recipients[] = $clients[$rec['sys_groupid']]['reseller'];
388395
}
389396
}
390397

391398
//* Send email to client
392399
if($mail_config['overquota_notify_client'] == 'y') {
393-
if($client['email'] != '') {
394-
$recipients[] = $client['email'];
400+
if($clients[$rec['sys_groupid']]['email'] != '') {
401+
$recipients[] = $clients[$rec['sys_groupid']]['email'];
395402
}
396403
}
397404

@@ -423,15 +430,15 @@ public function onRunJob() {
423430

424431
//* Send email to reseller
425432
if($web_config['overquota_notify_reseller'] == 'y') {
426-
if($reseller['email'] != '') {
427-
$recipients[] = $reseller['email'];
433+
if($clients[$rec['sys_groupid']]['reseller'] != '') {
434+
$recipients[] = $clients[$rec['sys_groupid']]['reseller'];
428435
}
429436
}
430437

431438
//* Send email to client
432439
if($mail_config['overquota_notify_client'] == 'y') {
433-
if($client['email'] != '') {
434-
$recipients[] = $client['email'];
440+
if($clients[$rec['sys_groupid']]['email'] != '') {
441+
$recipients[] = $clients[$rec['sys_groupid']]['email'];
435442
}
436443
}
437444

@@ -512,15 +519,15 @@ public function onRunJob() {
512519

513520
//* Send email to reseller
514521
if($web_config['overquota_db_notify_reseller'] == 'y') {
515-
if($reseller['email'] != '') {
516-
$recipients[] = $reseller['email'];
522+
if($clients[$rec['sys_groupid']]['reseller'] != '') {
523+
$recipients[] = $clients[$rec['sys_groupid']]['reseller'];
517524
}
518525
}
519526

520527
//* Send email to client
521528
if($web_config['overquota_db_notify_client'] == 'y') {
522-
if($client['email'] != '') {
523-
$recipients[] = $client['email'];
529+
if($clients[$rec['sys_groupid']]['email'] != '') {
530+
$recipients[] = $clients[$rec['sys_groupid']]['email'];
524531
}
525532
}
526533
$this->_tools->send_notification_email('db_quota_notification', $placeholders, $recipients);
@@ -550,19 +557,17 @@ public function onRunJob() {
550557

551558
//* Send email to reseller
552559
if($web_config['overquota_db_notify_reseller'] == 'y') {
553-
if($reseller['email'] != '') {
554-
$recipients[] = $reseller['email'];
560+
if($clients[$rec['sys_groupid']]['reseller'] != '') {
561+
$recipients[] = $clients[$rec['sys_groupid']]['reseller'];
555562
}
556563
}
557564

558565
//* Send email to client
559566
if($mail_config['overquota_notify_client'] == 'y') {
560-
if($client['email'] != '') {
561-
$recipients[] = $client['email'];
567+
if($clients[$rec['sys_groupid']]['email'] != '') {
568+
$recipients[] = $clients[$rec['sys_groupid']]['email'];
562569
}
563570
}
564-
565-
566571
$this->_tools->send_notification_email('db_quota_ok_notification', $placeholders, $recipients);
567572

568573
}

0 commit comments

Comments
 (0)