Skip to content

Commit

Permalink
Merge remote-tracking branch 'refs/remotes/origin/develop'
Browse files Browse the repository at this point in the history
  • Loading branch information
cliffparnitzky committed Jan 29, 2018
2 parents a8e08d7 + a3e1f5d commit 2b07ae8
Show file tree
Hide file tree
Showing 7 changed files with 34 additions and 15 deletions.
6 changes: 6 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,12 @@
Contao Extension "Monitoring"
=============================

Version 1.9.0 (2018-01-xx)
--------------------------
- extracted user agent name for global use
- replaced `$GLOBALS['TL_CONFIG']` access with `\Config::get()`
- devided `storeUrl` function into `deleteLastTestValues` and `prepareUrl` to provide better reusage possibilities

Version 1.8.2 (2018-01-25)
--------------------------
- Fix bug when loading language files in Contao 4
Expand Down
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,6 @@ The following extensions are recommended:
Documentation
-------------

[Read the manual](https://cliffparnitzky.gitbooks.io/contaomonitoring)
[Read the manual](https://contaomonitoring.gitbooks.io/contaomonitoring)

![EN](https://raw.githubusercontent.com/ContaoMonitoring/documentation/master/en/en.png) [English manual](https://cliffparnitzky.gitbooks.io/contaomonitoring/content/en/index.html)
![EN](https://raw.githubusercontent.com/ContaoMonitoring/documentation/master/en/en.png) [English manual](https://contaomonitoring.gitbooks.io/contaomonitoring/en/index.html)
2 changes: 1 addition & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@
}
},
"branch-alias": {
"dev-master": "1.8.x-dev"
"dev-master": "1.9.x-dev"
}
}
}
14 changes: 7 additions & 7 deletions system/modules/Monitoring/classes/Monitoring.php
Original file line number Diff line number Diff line change
Expand Up @@ -106,13 +106,13 @@ public function checkScheduled()
{
$errorMsg = self::EMAIL_MESSAGE_START . $this->getErroneousCheckEntriesAsString();
$this->log($errorMsg, __METHOD__, TL_ERROR);
if ($GLOBALS['TL_CONFIG']['monitoringMailingActive'] && $GLOBALS['TL_CONFIG']['monitoringAdminEmail'] != '')
if (\Config::get('monitoringMailingActive') && \Config::get('monitoringAdminEmail') != '')
{
$objEmail = new \Email();
$objEmail->subject = self::EMAIL_SUBJECT;
$objEmail->text = $errorMsg . sprintf(self::EMAIL_MESSAGE_END, \Environment::get('base') . "contao");
$objEmail->sendTo($GLOBALS['TL_CONFIG']['monitoringAdminEmail']);
$this->logDebugMsg("Scheduled monitoring check ended with errors. Monitoring admin informed via email (" . $GLOBALS['TL_CONFIG']['monitoringAdminEmail'] . ").", __METHOD__);
$objEmail->sendTo(\Config::get('monitoringAdminEmail'));
$this->logDebugMsg("Scheduled monitoring check ended with errors. Monitoring admin informed via email (" . \Config::get('monitoringAdminEmail') . ").", __METHOD__);
}
else
{
Expand All @@ -136,13 +136,13 @@ private function checkSingle($id, $checkType)
$testString = $this->valString($objMonitoringEntry->test_string, true);

$repitition = 0;
$maxRepititions = $GLOBALS['TL_CONFIG']['monitoringTestCirculation'];
$maxRepititions = \Config::get('monitoringTestCirculation');
if (!is_int($maxRepititions) || $maxRepititions < 1)
{
$maxRepititions = 1;
}

$delay = $GLOBALS['TL_CONFIG']['monitoringTestCirculationDelay'];
$delay = \Config::get('monitoringTestCirculationDelay');
if (!is_int($delay) || $delay < 1 || $delay > 99)
{
$delay = 10;
Expand Down Expand Up @@ -293,7 +293,7 @@ private function loadSite($url)
(
'http'=>array
(
'user_agent' => "ContaoMonitoringClient"
'user_agent' => \Config::get('MONITORING_AGENT_NAME')
)
);
$context = stream_context_create($opts);
Expand Down Expand Up @@ -355,7 +355,7 @@ private function returnToList($act)
*/
private function logDebugMsg($msg, $origin)
{
if ($GLOBALS['TL_CONFIG']['monitoringDebugMode'] === TRUE)
if (\Config::get('monitoringDebugMode') === TRUE)
{
$this->log($msg, $origin, TL_INFO);
}
Expand Down
5 changes: 5 additions & 0 deletions system/modules/Monitoring/config/config.php
Original file line number Diff line number Diff line change
Expand Up @@ -57,4 +57,9 @@
// Hourly cron job to check all server
$GLOBALS['TL_CRON']['hourly'][] = array('Monitoring', 'checkScheduled');

/**
* Global names
*/
$GLOBALS['TL_CONFIG']['MONITORING_AGENT_NAME'] = "ContaoMonitoringClient";

?>
16 changes: 12 additions & 4 deletions system/modules/Monitoring/dca/tl_monitoring.php
Original file line number Diff line number Diff line change
Expand Up @@ -209,7 +209,7 @@
'exclude' => true,
'search' => true,
'inputType' => 'text',
'save_callback' => array(array('tl_monitoring', 'storeUrl')),
'save_callback' => array(array('tl_monitoring', 'deleteLastTestValues'), array('tl_monitoring', 'prepareUrl')),
'eval' => array('tl_class'=>'long', 'mandatory'=>true, 'rgxp'=>'url'),
'sql' => "text NOT NULL"
),
Expand Down Expand Up @@ -363,13 +363,13 @@ public function getLabel($row, $label, DataContainer $dc, $args)
}

/**
* Empties test values when editing the url
* Empties the last test values when url has changed
*/
public function storeUrl($value, DataContainer $dc)
public function deleteLastTestValues($value, DataContainer $dc)
{
if ($value != $dc->activeRecord->url)
{
// url is new ... set unchecked
// url is changed ... set unchecked
$arrSet = array();
$arrSet['last_test_date'] = 0;
$arrSet['last_test_status'] = Monitoring::STATUS_UNTESTED;
Expand All @@ -380,6 +380,14 @@ public function storeUrl($value, DataContainer $dc)
->execute(\Input::get('id'));
}

return $value;
}

/**
* Adds `http://` if not set
*/
public function prepareUrl($value, DataContainer $dc)
{
if ($value != '' && !preg_match('@^https?://@', $value))
{
$value = 'http://' . $value;
Expand Down
2 changes: 1 addition & 1 deletion system/modules/Monitoring/dca/tl_monitoring_test.php
Original file line number Diff line number Diff line change
Expand Up @@ -234,7 +234,7 @@ public function getTestResultOutput($arrRow)
array
(
'col_0' => $GLOBALS['TL_LANG']['tl_monitoring_test']['date'][0],
'col_1' => \Date::parse($GLOBALS['TL_CONFIG']['datimFormat'], $arrRow['date'])
'col_1' => \Date::parse(\Config::get('datimFormat'), $arrRow['date'])
),
array
(
Expand Down

0 comments on commit 2b07ae8

Please sign in to comment.