@@ -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- $ client = $ 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- $ client = $ 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- $ client = $ 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- $ client = $ 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- $ client = $ 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,19 +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- $ client = $ 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 ' ];
521+ if ($ web_config ['overquota_db_notify_client ' ] == 'y ' ) {
522+ if ($ client ['email ' ] != '' ) {
523+ $ recipients [] = $ client ['email ' ];
524+ }
525+
559526
560527 $ this ->_tools ->send_notification_email ('db_quota_notification ' , $ placeholders , $ recipients );
561528
@@ -584,20 +551,13 @@ public function onRunJob() {
584551
585552 //* Send email to reseller
586553 if ($ web_config ['overquota_db_notify_reseller ' ] == 'y ' ) {
587- $ client_group_id = $ rec ["sys_groupid " ];
588- $ client = $ 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 );
589- if ($ client ['parent_client_id ' ] > 0 ) {
590- $ reseller = $ app ->db ->queryOneRecord ("SELECT email FROM client WHERE client_id = ? " , $ client ['parent_client_id ' ]);
591- }
592554 if ($ reseller ['email ' ] != '' ) {
593555 $ recipients [] = $ reseller ['email ' ];
594556 }
595557 }
596558
597559 //* Send email to client
598560 if ($ mail_config ['overquota_notify_client ' ] == 'y ' ) {
599- $ client_group_id = $ rec ["sys_groupid " ];
600- $ 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 );
601561 if ($ client ['email ' ] != '' ) {
602562 $ recipients [] = $ client ['email ' ];
603563 }
0 commit comments