Skip to content

Commit aac96e2

Browse files
Merge branch 'release/1.11.0'
2 parents 9b62312 + 573a01a commit aac96e2

24 files changed

Lines changed: 982 additions & 102 deletions

CHANGELOG.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,12 @@
11
Contao Extension "Monitoring"
22
=============================
33

4+
Version 1.11.0 (2019-12-19)
5+
--------------------------
6+
- added parameterization of colors to be color blind friendly (see #28)
7+
- added CSS for more space for the action buttons (see #25)
8+
- added sending mails via notification center (exclusively) (see #1)
9+
410
Version 1.10.0 (2018-03-20)
511
--------------------------
612
- added sending an email, when test result changes to OKAY again (see #14)

LICENSE

Lines changed: 165 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,165 @@
1+
GNU LESSER GENERAL PUBLIC LICENSE
2+
Version 3, 29 June 2007
3+
4+
Copyright (C) 2007 Free Software Foundation, Inc. <http://fsf.org/>
5+
Everyone is permitted to copy and distribute verbatim copies
6+
of this license document, but changing it is not allowed.
7+
8+
9+
This version of the GNU Lesser General Public License incorporates
10+
the terms and conditions of version 3 of the GNU General Public
11+
License, supplemented by the additional permissions listed below.
12+
13+
0. Additional Definitions.
14+
15+
As used herein, "this License" refers to version 3 of the GNU Lesser
16+
General Public License, and the "GNU GPL" refers to version 3 of the GNU
17+
General Public License.
18+
19+
"The Library" refers to a covered work governed by this License,
20+
other than an Application or a Combined Work as defined below.
21+
22+
An "Application" is any work that makes use of an interface provided
23+
by the Library, but which is not otherwise based on the Library.
24+
Defining a subclass of a class defined by the Library is deemed a mode
25+
of using an interface provided by the Library.
26+
27+
A "Combined Work" is a work produced by combining or linking an
28+
Application with the Library. The particular version of the Library
29+
with which the Combined Work was made is also called the "Linked
30+
Version".
31+
32+
The "Minimal Corresponding Source" for a Combined Work means the
33+
Corresponding Source for the Combined Work, excluding any source code
34+
for portions of the Combined Work that, considered in isolation, are
35+
based on the Application, and not on the Linked Version.
36+
37+
The "Corresponding Application Code" for a Combined Work means the
38+
object code and/or source code for the Application, including any data
39+
and utility programs needed for reproducing the Combined Work from the
40+
Application, but excluding the System Libraries of the Combined Work.
41+
42+
1. Exception to Section 3 of the GNU GPL.
43+
44+
You may convey a covered work under sections 3 and 4 of this License
45+
without being bound by section 3 of the GNU GPL.
46+
47+
2. Conveying Modified Versions.
48+
49+
If you modify a copy of the Library, and, in your modifications, a
50+
facility refers to a function or data to be supplied by an Application
51+
that uses the facility (other than as an argument passed when the
52+
facility is invoked), then you may convey a copy of the modified
53+
version:
54+
55+
a) under this License, provided that you make a good faith effort to
56+
ensure that, in the event an Application does not supply the
57+
function or data, the facility still operates, and performs
58+
whatever part of its purpose remains meaningful, or
59+
60+
b) under the GNU GPL, with none of the additional permissions of
61+
this License applicable to that copy.
62+
63+
3. Object Code Incorporating Material from Library Header Files.
64+
65+
The object code form of an Application may incorporate material from
66+
a header file that is part of the Library. You may convey such object
67+
code under terms of your choice, provided that, if the incorporated
68+
material is not limited to numerical parameters, data structure
69+
layouts and accessors, or small macros, inline functions and templates
70+
(ten or fewer lines in length), you do both of the following:
71+
72+
a) Give prominent notice with each copy of the object code that the
73+
Library is used in it and that the Library and its use are
74+
covered by this License.
75+
76+
b) Accompany the object code with a copy of the GNU GPL and this license
77+
document.
78+
79+
4. Combined Works.
80+
81+
You may convey a Combined Work under terms of your choice that,
82+
taken together, effectively do not restrict modification of the
83+
portions of the Library contained in the Combined Work and reverse
84+
engineering for debugging such modifications, if you also do each of
85+
the following:
86+
87+
a) Give prominent notice with each copy of the Combined Work that
88+
the Library is used in it and that the Library and its use are
89+
covered by this License.
90+
91+
b) Accompany the Combined Work with a copy of the GNU GPL and this license
92+
document.
93+
94+
c) For a Combined Work that displays copyright notices during
95+
execution, include the copyright notice for the Library among
96+
these notices, as well as a reference directing the user to the
97+
copies of the GNU GPL and this license document.
98+
99+
d) Do one of the following:
100+
101+
0) Convey the Minimal Corresponding Source under the terms of this
102+
License, and the Corresponding Application Code in a form
103+
suitable for, and under terms that permit, the user to
104+
recombine or relink the Application with a modified version of
105+
the Linked Version to produce a modified Combined Work, in the
106+
manner specified by section 6 of the GNU GPL for conveying
107+
Corresponding Source.
108+
109+
1) Use a suitable shared library mechanism for linking with the
110+
Library. A suitable mechanism is one that (a) uses at run time
111+
a copy of the Library already present on the user's computer
112+
system, and (b) will operate properly with a modified version
113+
of the Library that is interface-compatible with the Linked
114+
Version.
115+
116+
e) Provide Installation Information, but only if you would otherwise
117+
be required to provide such information under section 6 of the
118+
GNU GPL, and only to the extent that such information is
119+
necessary to install and execute a modified version of the
120+
Combined Work produced by recombining or relinking the
121+
Application with a modified version of the Linked Version. (If
122+
you use option 4d0, the Installation Information must accompany
123+
the Minimal Corresponding Source and Corresponding Application
124+
Code. If you use option 4d1, you must provide the Installation
125+
Information in the manner specified by section 6 of the GNU GPL
126+
for conveying Corresponding Source.)
127+
128+
5. Combined Libraries.
129+
130+
You may place library facilities that are a work based on the
131+
Library side by side in a single library together with other library
132+
facilities that are not Applications and are not covered by this
133+
License, and convey such a combined library under terms of your
134+
choice, if you do both of the following:
135+
136+
a) Accompany the combined library with a copy of the same work based
137+
on the Library, uncombined with any other library facilities,
138+
conveyed under the terms of this License.
139+
140+
b) Give prominent notice with the combined library that part of it
141+
is a work based on the Library, and explaining where to find the
142+
accompanying uncombined form of the same work.
143+
144+
6. Revised Versions of the GNU Lesser General Public License.
145+
146+
The Free Software Foundation may publish revised and/or new versions
147+
of the GNU Lesser General Public License from time to time. Such new
148+
versions will be similar in spirit to the present version, but may
149+
differ in detail to address new problems or concerns.
150+
151+
Each version is given a distinguishing version number. If the
152+
Library as you received it specifies that a certain numbered version
153+
of the GNU Lesser General Public License "or any later version"
154+
applies to it, you have the option of following the terms and
155+
conditions either of that published version or of any later version
156+
published by the Free Software Foundation. If the Library as you
157+
received it does not specify a version number of the GNU Lesser
158+
General Public License, you may choose any version of the GNU Lesser
159+
General Public License ever published by the Free Software Foundation.
160+
161+
If the Library as you received it specifies that a proxy can decide
162+
whether future versions of the GNU Lesser General Public License shall
163+
apply, that proxy's public statement of acceptance of any version is
164+
permanent authorization for you to choose that version for the
165+
Library.

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,7 @@ Dependency
5252

5353
This extension is dependent on the following extensions:
5454

55-
- [[menatwork/contao-multicolumnwizard]](https://packagist.org/packages/menatwork/contao-multicolumnwizard)
55+
- [[terminal42/notification_center]](https://packagist.org/packages/terminal42/notification_center)
5656

5757
The following extensions are recommended:
5858

composer.json

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,8 @@
2424
"require":{
2525
"php":">=5.3",
2626
"contao/core-bundle":"~3.2 || ~4.4",
27-
"contao-community-alliance/composer-plugin":"~2.4 || ~3.0"
27+
"contao-community-alliance/composer-plugin":"~2.4 || ~3.0",
28+
"terminal42/notification_center":"~1.5"
2829
},
2930
"suggest" : {
3031
"cliffparnitzky/backend-custom-startpage" : "Provides the possibility for each user to select an individual startpage in the backend."
@@ -36,7 +37,7 @@
3637
}
3738
},
3839
"branch-alias": {
39-
"dev-master": "1.9.x-dev"
40+
"dev-master": "1.11.x-dev"
4041
}
4142
}
4243
}
Lines changed: 25 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -1,26 +1,33 @@
1-
a.tl_monitoring_check_all{ background-image: url('check_all.png'); } a.tl_monitoring_check_one{ background-image: url('check_one.png'); } .col_last_test_status { text-align: center; }
2-
3-
4-
.tl_message_monitoring_status_okay, .tl_message_monitoring_status_okay a {
5-
color: #049f04;
1+
a.tl_monitoring_check_all{
2+
background-image: url('check_all.png');
63
}
7-
p.tl_message_monitoring_status_okay {
8-
background: url("status_okay.png") no-repeat scroll 6px center #ceffce;
4+
a.tl_monitoring_check_one{
5+
background-image: url('check_one.png');
96
}
10-
.tl_message_monitoring_status_error, .tl_message_monitoring_status_error a {
11-
color: #cb032b;
7+
.col_last_test_status {
8+
text-align: center;
129
}
13-
p.tl_message_monitoring_status_error {
14-
background: url("status_error.png") no-repeat scroll 6px center #ffdcdc;
10+
p.tl_message_monitoring_status.monitoring_status_okay {
11+
background-image: url("status_okay.png");
1512
}
16-
.tl_message_monitoring_status_incomplete, .tl_message_monitoring_status_incomplete a {
17-
color: #bd9500;
13+
p.tl_message_monitoring_status.monitoring_status_incomplete {
14+
background-image: url("status_incomplete.png");
1815
}
19-
p.tl_message_monitoring_status_incomplete {
20-
background: url("status_incomplete.png") no-repeat scroll 6px center #ffffd2;
16+
p.tl_message_monitoring_status.monitoring_status_error {
17+
background-image: url("status_error.png");
18+
}
19+
p.tl_message_monitoring_status,
20+
p.tl_message_monitoring_status a {
21+
color: #ffffff;
2122
}
2223
p.tl_message_monitoring_status {
23-
border-radius: 3px;
24-
margin: 1px 0 0;
25-
padding: 4px 5px 5px 25px;
24+
border-radius: 3px;
25+
margin: 1px 0 0;
26+
padding: 4px 5px 5px 25px;
27+
background-repeat: no-repeat;
28+
background-position: 6px center;
29+
}
30+
#tl_buttons > a[class*="tl_monitoring"] {
31+
margin-bottom: 5px;
32+
display: inline-block;
2633
}

system/modules/Monitoring/classes/Monitoring.php

Lines changed: 19 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
/**
44
* Contao Open Source CMS
5-
* Copyright (C) 2005-2017 Leo Feyer
5+
* Copyright (C) 2005-2019 Leo Feyer
66
*
77
* Formerly known as TYPOlight Open Source CMS.
88
*
@@ -21,7 +21,7 @@
2121
* Software Foundation website at <http://www.gnu.org/licenses/>.
2222
*
2323
* PHP version 5
24-
* @copyright Cliff Parnitzky 2014-2017
24+
* @copyright Cliff Parnitzky 2014-2019
2525
* @author Cliff Parnitzky
2626
* @package Monitoring
2727
* @license LGPL
@@ -37,7 +37,7 @@
3737
* Class Monitoring
3838
*
3939
* Read the text from the given url and compare with test string.
40-
* @copyright Cliff Parnitzky 2014-2017
40+
* @copyright Cliff Parnitzky 2014-2019
4141
* @author Cliff Parnitzky
4242
* @package Controller
4343
*/
@@ -51,12 +51,8 @@ class Monitoring extends \Backend
5151
const CHECK_TYPE_MANUAL = 'MANUAL';
5252
const CHECK_TYPE_AUTOMATIC = 'AUTOMATIC';
5353

54-
const EMAIL_SUBJECT_ERROR = 'Monitoring errors detected';
55-
const EMAIL_SUBJECT_OKAY = 'Monitoring entries okay again';
56-
const EMAIL_MESSAGE_START_ERROR = "Scheduled monitoring check ended.\n\nThe following checks ended erroneous:\n\n";
57-
const EMAIL_MESSAGE_START_OKAY = "Scheduled monitoring check ended.\n\nThe following checks are okay again:\n\n";
58-
const EMAIL_MESSAGE_ENTRY = "- %s %s %s [%s] (%s)\n";
59-
const EMAIL_MESSAGE_END = "\nPlease check your system for further information: %s\n\nThis is an automatically generated email by Contao extension [Monitoring].";
54+
const ERROR_MESSAGE_START = "Scheduled monitoring check ended.\n\nThe following checks ended erroneous:\n\n";
55+
const ERROR_MESSAGE_ENTRY = "- %s %s %s [%s] (%s)\n";
6056

6157
const TEST_CIRCULATION = 1;
6258
const TEST_CIRCULATION_DELAY = 10;
@@ -105,6 +101,8 @@ public function checkAll()
105101
*/
106102
public function checkScheduled()
107103
{
104+
$mailSender = new MonitoringMailSender();
105+
108106
$oldErroneousCheckEntries = $this->removeMailingDeactivatedEntries($this->getErroneousCheckEntries());
109107

110108
$status = $this->checkMultiple(self::CHECK_TYPE_AUTOMATIC);
@@ -116,15 +114,15 @@ public function checkScheduled()
116114
// only needed when there where errors detected
117115
if ($status != self::STATUS_OKAY)
118116
{
119-
$errorMsg = self::EMAIL_MESSAGE_START_ERROR . $this->getCheckEntriesAsString($allErroneousCheckEntries);
117+
$errorMsg = self::ERROR_MESSAGE_START . $this->getCheckEntriesAsString($allErroneousCheckEntries);
120118
$this->log($errorMsg, __METHOD__, TL_ERROR);
121119

122120
if (!empty($newErroneousCheckEntries) && \Config::get('monitoringMailingActive') && \Config::get('monitoringAdminEmail') != '')
123121
{
124-
$objEmail = new \Email();
125-
$objEmail->subject = self::EMAIL_SUBJECT_ERROR;
126-
$objEmail->text = self::EMAIL_MESSAGE_START_ERROR . $this->getCheckEntriesAsString($newErroneousCheckEntries) . sprintf(self::EMAIL_MESSAGE_END, \Environment::get('base') . "contao");
127-
$objEmail->sendTo(\Config::get('monitoringAdminEmail'));
122+
foreach($newErroneousCheckEntries as $entry)
123+
{
124+
$mailSender->sendErrorEmail($entry);
125+
}
128126
$this->logDebugMsg("Scheduled monitoring check ended. Some checks ended erroneous. The monitoring admin was informed via email (" . \Config::get('monitoringAdminEmail') . ").", __METHOD__);
129127
}
130128
else
@@ -137,10 +135,10 @@ public function checkScheduled()
137135
$againOkayCheckEntries = array_diff_key($oldErroneousCheckEntries, $newErroneousCheckEntries);
138136
if (!empty($againOkayCheckEntries) && \Config::get('monitoringMailingActive') && \Config::get('monitoringAdminEmail') != '')
139137
{
140-
$objEmail = new \Email();
141-
$objEmail->subject = self::EMAIL_SUBJECT_OKAY;
142-
$objEmail->text = self::EMAIL_MESSAGE_START_OKAY . $this->getCheckEntriesAsString($againOkayCheckEntries, true) . sprintf(self::EMAIL_MESSAGE_END, \Environment::get('base') . "contao");
143-
$objEmail->sendTo(\Config::get('monitoringAdminEmail'));
138+
foreach($againOkayCheckEntries as $entry)
139+
{
140+
$mailSender->sendAgainOkayEmail($entry);
141+
}
144142
$this->logDebugMsg("Scheduled monitoring check ended. Some checks are okay again. The monitoring admin was informed via email (" . \Config::get('monitoringAdminEmail') . ").", __METHOD__);
145143
}
146144
}
@@ -294,12 +292,12 @@ private function getErroneousCheckEntries()
294292
/**
295293
* Return the list of erroneous check entries as string
296294
*/
297-
private function getCheckEntriesAsString($arrErroneousCheckEntries, $blnOverwriteStatus=false)
295+
private function getCheckEntriesAsString($arrErroneousCheckEntries)
298296
{
299297
$strReturn = '';
300298
foreach ($arrErroneousCheckEntries as $key=>$entry)
301299
{
302-
$strReturn .= sprintf(self::EMAIL_MESSAGE_ENTRY, $entry->customer, $entry->website, $entry->system, $blnOverwriteStatus ? self::STATUS_OKAY : $entry->last_test_status, $entry->url);
300+
$strReturn .= sprintf(self::ERROR_MESSAGE_ENTRY, $entry->customer, $entry->website, $entry->system, $entry->last_test_status, $entry->url);
303301
}
304302

305303
return $strReturn;
@@ -412,7 +410,7 @@ private function logDebugMsg($msg, $origin)
412410
*/
413411
private function addCheckMessage($intEntryId, $strStatus)
414412
{
415-
$this->addRawMessage('<p class="tl_message_monitoring_status tl_message_monitoring_status_' . strtolower($strStatus) . '">' . sprintf($GLOBALS['TL_LANG']['MSC']['monitoringCheckResult'], $intEntryId, $GLOBALS['TL_LANG']['tl_monitoring']['statusTypes'][$strStatus][0]) . '</p>');
413+
$this->addRawMessage('<p class="tl_message_monitoring_status monitoring_status_' . strtolower($strStatus) . '">' . sprintf($GLOBALS['TL_LANG']['MSC']['monitoringCheckResult'], $intEntryId, $GLOBALS['TL_LANG']['tl_monitoring']['statusTypes'][$strStatus][0]) . '</p>');
416414
}
417415
}
418416
?>

0 commit comments

Comments
 (0)