diff --git a/modules/monitoring/application/views/scripts/show/components/actions.phtml b/modules/monitoring/application/views/scripts/show/components/actions.phtml index 35077abc0..18f8a8482 100644 --- a/modules/monitoring/application/views/scripts/show/components/actions.phtml +++ b/modules/monitoring/application/views/scripts/show/components/actions.phtml @@ -1,29 +1,21 @@ %s ', $this->translate('opens in new window')); -$linkText = '%s ' . $newTabInfo . ''; -$localLinkText = '%s'; - -if ($object->action_url) { - if (strpos($object->action_url, "' ") === false) { - $links[] = sprintf($linkText, $this->resolveMacros($object->action_url, $object), 'Action'); - } else { - // TODO: We should find out document what's going on here. Looks strange :p - foreach(explode("' ", $object->action_url) as $url) { - $url = strpos($url, "'") === 0 ? substr($url, 1) : $url; - $url = strrpos($url, "'") === strlen($url) - 1 ? substr($url, 0, strlen($url) - 1) : $url; - $links[] = sprintf($linkText, $this->resolveMacros($url, $object), 'Action'); - } - } +$links = MonitoredObject::parseAttributeUrls($object->action_url); +foreach ($links as $i => $link) { + $links[$i] = sprintf( + '%s ' . $newTabInfo . '', + $this->resolveMacros($object->action_url, $object), + 'Action' + ); } if (isset($this->actions)) { foreach ($this->actions as $id => $action) { - $links[] = sprintf($localLinkText, $action, $id); + $links[] = sprintf('%s', $action, $id); } } diff --git a/modules/monitoring/library/Monitoring/Object/MonitoredObject.php b/modules/monitoring/library/Monitoring/Object/MonitoredObject.php index 236ca2aaa..37d29c82e 100644 --- a/modules/monitoring/library/Monitoring/Object/MonitoredObject.php +++ b/modules/monitoring/library/Monitoring/Object/MonitoredObject.php @@ -578,9 +578,22 @@ abstract class MonitoredObject implements Filterable */ public function getNotesUrls() {} + /** + * Get all action urls configured for this monitored object + * + * @return array All note urls as a string + */ + public function getActionUrls() + { + return MonitoredObject::parseAttributeUrls($this->action_url); + } + /** * Parse the content of the action_url or notes_url attributes * + * Find all occurences of http links, separated by whitespaces and quoted + * by single or double-ticks. + * * @link http://docs.icinga.org/latest/de/objectdefinitions.html * * @param string $urlString A string containing one or more urls