commit
9c3405e2eb
|
@ -30,11 +30,8 @@ namespace Icinga\Form\Config;
|
|||
|
||||
use \Zend_Config;
|
||||
use \Icinga\Application\Config as IcingaConfig;
|
||||
use \Icinga\Application\Icinga;
|
||||
use \Icinga\Application\Logger;
|
||||
use \Icinga\Application\DbAdapterFactory;
|
||||
use \Icinga\Web\Form;
|
||||
use \Icinga\Web\Form\Element\Note;
|
||||
use \Icinga\Web\Form\Decorator\ConditionalHidden;
|
||||
|
||||
/**
|
||||
|
@ -280,15 +277,7 @@ class AuthenticationForm extends Form
|
|||
$order = $this->getAuthenticationOrder();
|
||||
|
||||
foreach ($order as $name) {
|
||||
$this->addElement(
|
||||
new Note(
|
||||
array(
|
||||
'escape' => false,
|
||||
'name' => 'title_backend_' . $name,
|
||||
'value' => '<h4>Backend ' . $name . '</h4>'
|
||||
)
|
||||
)
|
||||
);
|
||||
$this->addNote('Backend ' . $name, 4);
|
||||
$this->addRemoveHint($this->filterName($name));
|
||||
$backend = $this->config->get($name, null);
|
||||
if ($backend === null) {
|
||||
|
|
|
@ -25,7 +25,6 @@
|
|||
*/
|
||||
// {{{ICINGA_LICENSE_HEADER}}}
|
||||
|
||||
use \DateTime;
|
||||
use \Zend_View_Helper_FormElement;
|
||||
|
||||
/**
|
||||
|
@ -63,7 +62,7 @@ class Zend_View_Helper_FormDateTime extends Zend_View_Helper_FormElement
|
|||
// Build the element
|
||||
$xhtml = '<div class="datetime">'
|
||||
. '<input type="text" name="' . $this->view->escape($name) . '"'
|
||||
. ' id="' . $this->view->escape($id) . '"'
|
||||
. ' id="' . $this->view->escape($name) . '"'
|
||||
. $value
|
||||
. $disabled
|
||||
. $this->_htmlAttribs($attribs)
|
||||
|
|
|
@ -33,6 +33,7 @@ use \Zend_View_Interface;
|
|||
use \Icinga\Exception\ProgrammingError;
|
||||
use \Icinga\Web\Form\Decorator\HelpText;
|
||||
use \Icinga\Web\Form\InvalidCSRFTokenException;
|
||||
use \Icinga\Web\Form\Element\Note;
|
||||
|
||||
/**
|
||||
* Base class for forms providing CSRF protection, confirmation logic and auto submission
|
||||
|
@ -94,6 +95,15 @@ abstract class Form extends Zend_Form
|
|||
*/
|
||||
private $cancelLabel;
|
||||
|
||||
/**
|
||||
* Last used note-id
|
||||
*
|
||||
* Helper to generate unique names for note elements
|
||||
*
|
||||
* @var int
|
||||
*/
|
||||
private $last_note_id = 0;
|
||||
|
||||
/**
|
||||
* Getter for the session ID
|
||||
*
|
||||
|
@ -259,14 +269,37 @@ abstract class Form extends Zend_Form
|
|||
$this->addElement($submitButton);
|
||||
}
|
||||
|
||||
/**
|
||||
* Add message to form
|
||||
*
|
||||
* @param string $message The message to be displayed
|
||||
* @param int $headingType Whether it should be displayed as heading (1-6) or not (null)
|
||||
*/
|
||||
public function addNote($message, $headingType = null)
|
||||
{
|
||||
$this->addElement(
|
||||
new Note(
|
||||
array(
|
||||
'escape' => $headingType === null ? false : true,
|
||||
'name' => sprintf('note_%s', $this->last_note_id++),
|
||||
'value' => $headingType === null ? $message : sprintf(
|
||||
'<h%1$s>%2$s</h%1$s>',
|
||||
$headingType,
|
||||
$message
|
||||
)
|
||||
)
|
||||
)
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Enable automatic form submission on the given elements
|
||||
*
|
||||
* Enables automatic submission of this form once the user edits specific elements
|
||||
*
|
||||
* @param array $triggerElements The element names which should auto-submit the form
|
||||
* @param array $triggerElements The element names which should auto-submit the form
|
||||
*
|
||||
* @throws ProgrammingError When an element is found which does not yet exist
|
||||
* @throws ProgrammingError When an element is found which does not yet exist
|
||||
*/
|
||||
final public function enableAutoSubmit($triggerElements)
|
||||
{
|
||||
|
@ -322,7 +355,7 @@ abstract class Form extends Zend_Form
|
|||
*
|
||||
* This method should be used for testing purposes only
|
||||
*
|
||||
* @param bool $disabled
|
||||
* @param bool $disabled Set true in order to disable CSRF tokens in this form (default: true), otherwise false
|
||||
*
|
||||
* @see tokenDisabled
|
||||
*/
|
||||
|
@ -355,9 +388,9 @@ abstract class Form extends Zend_Form
|
|||
/**
|
||||
* Test the submitted data for a correct CSRF token
|
||||
*
|
||||
* @param array $checkData The POST data send by the user
|
||||
* @param array $checkData The POST data send by the user
|
||||
*
|
||||
* @throws InvalidCSRFTokenException When CSRF Validation fails
|
||||
* @throws InvalidCSRFTokenException When CSRF Validation fails
|
||||
*/
|
||||
final public function assertValidCsrfToken(array $checkData)
|
||||
{
|
||||
|
|
|
@ -29,7 +29,6 @@
|
|||
namespace Monitoring\Form\Command;
|
||||
|
||||
use \Icinga\Web\Form\Element\DateTimePicker;
|
||||
use \Icinga\Web\Form\Element\Note;
|
||||
use \Icinga\Protocol\Commandpipe\Acknowledgement;
|
||||
use \Icinga\Protocol\Commandpipe\Comment;
|
||||
use \Icinga\Util\DateTimeFactory;
|
||||
|
@ -44,16 +43,11 @@ class AcknowledgeForm extends CommandForm
|
|||
*/
|
||||
protected function create()
|
||||
{
|
||||
$this->addElement(
|
||||
new Note(
|
||||
array(
|
||||
'name' => 'commanddescription',
|
||||
'value' => t(
|
||||
'This command is used to acknowledge host or service problems. When a problem is '
|
||||
. 'acknowledged, future notifications about problems are temporarily disabled until the '
|
||||
. 'host/service changes from its current state.'
|
||||
)
|
||||
)
|
||||
$this->addNote(
|
||||
t(
|
||||
'This command is used to acknowledge host or service problems. When a problem is '
|
||||
. 'acknowledged, future notifications about problems are temporarily disabled until the '
|
||||
. 'host/service changes from its current state.'
|
||||
)
|
||||
);
|
||||
|
||||
|
@ -65,18 +59,11 @@ class AcknowledgeForm extends CommandForm
|
|||
array(
|
||||
'label' => t('Comment'),
|
||||
'rows' => 4,
|
||||
'required' => true
|
||||
)
|
||||
);
|
||||
$this->addElement(
|
||||
new Note(
|
||||
array(
|
||||
'name' => 'commentnote',
|
||||
'value' => t(
|
||||
' If you work with other administrators you may find it useful to share information '
|
||||
. 'about a host or service that is having problems if more than one of you may be working on '
|
||||
. 'it. Make sure you enter a brief description of what you are doing.'
|
||||
)
|
||||
'required' => true,
|
||||
'helptext' => t(
|
||||
' If you work with other administrators you may find it useful to share information '
|
||||
. 'about a host or service that is having problems if more than one of you may be working on '
|
||||
. 'it. Make sure you enter a brief description of what you are doing.'
|
||||
)
|
||||
)
|
||||
);
|
||||
|
@ -85,18 +72,11 @@ class AcknowledgeForm extends CommandForm
|
|||
'checkbox',
|
||||
'persistent',
|
||||
array(
|
||||
'label' => t('Persistent Comment'),
|
||||
'value' => false
|
||||
)
|
||||
);
|
||||
$this->addElement(
|
||||
new Note(
|
||||
array(
|
||||
'name' => 'persistentnote',
|
||||
'value' => t(
|
||||
'If you would like the comment to remain even when the acknowledgement is removed, '
|
||||
. 'check this option.'
|
||||
)
|
||||
'label' => t('Persistent Comment'),
|
||||
'value' => false,
|
||||
'helptext' => t(
|
||||
'If you would like the comment to remain even when the acknowledgement is removed, '
|
||||
. 'check this option.'
|
||||
)
|
||||
)
|
||||
);
|
||||
|
@ -105,34 +85,21 @@ class AcknowledgeForm extends CommandForm
|
|||
'checkbox',
|
||||
'expire',
|
||||
array(
|
||||
'label' => t('Use Expire Time')
|
||||
'label' => t('Use Expire Time'),
|
||||
'helptext' => t('If the acknowledgement should expire, check this option.')
|
||||
)
|
||||
);
|
||||
$this->enableAutoSubmit(array('expire'));
|
||||
$this->addElement(
|
||||
new Note(
|
||||
array(
|
||||
'name' => 'expirenote',
|
||||
'value' => t('If the acknowledgement should expire, check this option.')
|
||||
)
|
||||
)
|
||||
);
|
||||
|
||||
if ($this->getRequest()->getPost('expire', '0') === '1') {
|
||||
$now = DateTimeFactory::create();
|
||||
$this->addElement(
|
||||
new DateTimePicker(
|
||||
array(
|
||||
'name' => 'expiretime',
|
||||
'label' => t('Expire Time'),
|
||||
'value' => $now->getTimestamp() + 3600
|
||||
)
|
||||
)
|
||||
);
|
||||
$this->addElement(
|
||||
new Note(
|
||||
array(
|
||||
'name' => 'expiretimenote',
|
||||
'value' => t(
|
||||
'name' => 'expiretime',
|
||||
'label' => t('Expire Time'),
|
||||
'value' => $now->getTimestamp() + 3600,
|
||||
'helptext' => t(
|
||||
'Enter the expire date/time for this acknowledgement here. Icinga will '
|
||||
. ' delete the acknowledgement after this date expired.'
|
||||
)
|
||||
|
@ -145,18 +112,11 @@ class AcknowledgeForm extends CommandForm
|
|||
'checkbox',
|
||||
'sticky',
|
||||
array(
|
||||
'label' => t('Sticky Acknowledgement'),
|
||||
'value' => true
|
||||
)
|
||||
);
|
||||
$this->addElement(
|
||||
new Note(
|
||||
array(
|
||||
'name' => 'stickynote',
|
||||
'value' => t(
|
||||
'If you want the acknowledgement to disable notifications until the host/service '
|
||||
. 'recovers, check this option.'
|
||||
)
|
||||
'label' => t('Sticky Acknowledgement'),
|
||||
'value' => true,
|
||||
'helptext' => t(
|
||||
'If you want the acknowledgement to disable notifications until the host/service '
|
||||
. 'recovers, check this option.'
|
||||
)
|
||||
)
|
||||
);
|
||||
|
@ -165,18 +125,11 @@ class AcknowledgeForm extends CommandForm
|
|||
'checkbox',
|
||||
'notify',
|
||||
array(
|
||||
'label' => t('Send Notification'),
|
||||
'value' => true
|
||||
)
|
||||
);
|
||||
$this->addElement(
|
||||
new Note(
|
||||
array(
|
||||
'name' => 'sendnotificationnote',
|
||||
'value' => t(
|
||||
'If you do not want an acknowledgement notification to be sent out to the appropriate '
|
||||
. 'contacts, uncheck this option.'
|
||||
)
|
||||
'label' => t('Send Notification'),
|
||||
'value' => true,
|
||||
'helptext' => t(
|
||||
'If you do not want an acknowledgement notification to be sent out to the appropriate '
|
||||
. 'contacts, uncheck this option.'
|
||||
)
|
||||
)
|
||||
);
|
||||
|
|
|
@ -29,53 +29,16 @@
|
|||
namespace Monitoring\Form\Command;
|
||||
|
||||
use Icinga\Web\Form;
|
||||
use Icinga\Web\Form\Element\Note;
|
||||
use \Zend_Form_Element_Hidden;
|
||||
use \Zend_Validate_Date;
|
||||
|
||||
/**
|
||||
* Simple confirmation command
|
||||
*/
|
||||
class CommandForm extends Form
|
||||
{
|
||||
/**
|
||||
* Array of messages
|
||||
*
|
||||
* @var string[]
|
||||
*/
|
||||
private $notes = array();
|
||||
|
||||
/**
|
||||
* Add message to stack
|
||||
*
|
||||
* @param string $message
|
||||
*/
|
||||
public function addNote($message)
|
||||
{
|
||||
$this->notes[] = $message;
|
||||
}
|
||||
|
||||
/**
|
||||
* Purge messages from stack
|
||||
*
|
||||
*/
|
||||
public function clearNotes()
|
||||
{
|
||||
$this->notes = array();
|
||||
}
|
||||
|
||||
/**
|
||||
* Getter for notes
|
||||
*
|
||||
* @return string[]
|
||||
*/
|
||||
public function getNotes()
|
||||
{
|
||||
return $this->notes;
|
||||
}
|
||||
|
||||
/**
|
||||
* Create an instance name containing hidden field
|
||||
*
|
||||
* @return Zend_Form_Element_Hidden
|
||||
*/
|
||||
private function createInstanceHiddenField()
|
||||
|
@ -93,24 +56,13 @@ class CommandForm extends Form
|
|||
*/
|
||||
protected function create()
|
||||
{
|
||||
if (count($this->getNotes())) {
|
||||
foreach ($this->getNotes() as $nodeid => $note) {
|
||||
$element = new Note(
|
||||
array(
|
||||
'name' => 'note_'. $nodeid,
|
||||
'value' => $note
|
||||
)
|
||||
);
|
||||
$this->addElement($element);
|
||||
}
|
||||
}
|
||||
|
||||
$this->addElement($this->createInstanceHiddenField());
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the author name
|
||||
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
protected function getAuthorName()
|
||||
{
|
||||
|
|
|
@ -28,7 +28,6 @@
|
|||
|
||||
namespace Monitoring\Form\Command;
|
||||
|
||||
use \Icinga\Web\Form\Element\Note;
|
||||
use \Icinga\Protocol\Commandpipe\Comment;
|
||||
|
||||
/**
|
||||
|
@ -41,14 +40,7 @@ class CommentForm extends CommandForm
|
|||
*/
|
||||
protected function create()
|
||||
{
|
||||
$this->addElement(
|
||||
new Note(
|
||||
array(
|
||||
'name' => 'commanddescription',
|
||||
'value' => t('This command is used to add a comment to hosts or services.')
|
||||
)
|
||||
)
|
||||
);
|
||||
$this->addNote(t('This command is used to add a comment to hosts or services.'));
|
||||
|
||||
$this->addElement($this->createAuthorField());
|
||||
|
||||
|
@ -58,18 +50,11 @@ class CommentForm extends CommandForm
|
|||
array(
|
||||
'label' => t('Comment'),
|
||||
'rows' => 4,
|
||||
'required' => true
|
||||
)
|
||||
);
|
||||
$this->addElement(
|
||||
new Note(
|
||||
array(
|
||||
'name' => 'commentnote',
|
||||
'value' => t(
|
||||
'If you work with other administrators, you may find it useful to share information '
|
||||
. 'about a host or service that is having problems if more than one of you may be working on '
|
||||
. 'it. Make sure you enter a brief description of what you are doing.'
|
||||
)
|
||||
'required' => true,
|
||||
'helptext' => t(
|
||||
'If you work with other administrators, you may find it useful to share information '
|
||||
. 'about a host or service that is having problems if more than one of you may be working on '
|
||||
. 'it. Make sure you enter a brief description of what you are doing.'
|
||||
)
|
||||
)
|
||||
);
|
||||
|
@ -78,18 +63,11 @@ class CommentForm extends CommandForm
|
|||
'checkbox',
|
||||
'persistent',
|
||||
array(
|
||||
'label' => t('Persistent'),
|
||||
'value' => true
|
||||
)
|
||||
);
|
||||
$this->addElement(
|
||||
new Note(
|
||||
array(
|
||||
'name' => 'persistentnote',
|
||||
'value' => t(
|
||||
'If you uncheck this option, the comment will automatically be deleted the next time '
|
||||
. 'Icinga is restarted.'
|
||||
)
|
||||
'label' => t('Persistent'),
|
||||
'value' => true,
|
||||
'helptext' => t(
|
||||
'If you uncheck this option, the comment will automatically be deleted the next time '
|
||||
. 'Icinga is restarted.'
|
||||
)
|
||||
)
|
||||
);
|
||||
|
|
|
@ -28,7 +28,6 @@
|
|||
|
||||
namespace Monitoring\Form\Command;
|
||||
|
||||
use \Icinga\Web\Form\Element\Note;
|
||||
use \Icinga\Protocol\Commandpipe\CustomNotification;
|
||||
|
||||
/**
|
||||
|
@ -41,16 +40,11 @@ class CustomNotificationForm extends CommandForm
|
|||
*/
|
||||
protected function create()
|
||||
{
|
||||
$this->addElement(
|
||||
new Note(
|
||||
array(
|
||||
'name' => 'commanddescription',
|
||||
'value' => t(
|
||||
'This command is used to send a custom notification about hosts or services. Useful in '
|
||||
. 'emergencies when you need to notify admins of an issue regarding a monitored system or '
|
||||
. 'service.'
|
||||
)
|
||||
)
|
||||
$this->addNote(
|
||||
t(
|
||||
'This command is used to send a custom notification about hosts or services. Useful in '
|
||||
. 'emergencies when you need to notify admins of an issue regarding a monitored system or '
|
||||
. 'service.'
|
||||
)
|
||||
);
|
||||
|
||||
|
@ -62,18 +56,11 @@ class CustomNotificationForm extends CommandForm
|
|||
array(
|
||||
'label' => t('Comment'),
|
||||
'rows' => 4,
|
||||
'required' => true
|
||||
)
|
||||
);
|
||||
$this->addElement(
|
||||
new Note(
|
||||
array(
|
||||
'name' => 'commentnote',
|
||||
'value' => t(
|
||||
'If you work with other administrators, you may find it useful to share information '
|
||||
. 'about a host or service that is having problems if more than one of you may be working on '
|
||||
. 'it. Make sure you enter a brief description of what you are doing.'
|
||||
)
|
||||
'required' => true,
|
||||
'helptext' => t(
|
||||
'If you work with other administrators, you may find it useful to share information '
|
||||
. 'about a host or service that is having problems if more than one of you may be working on '
|
||||
. 'it. Make sure you enter a brief description of what you are doing.'
|
||||
)
|
||||
)
|
||||
);
|
||||
|
@ -82,18 +69,11 @@ class CustomNotificationForm extends CommandForm
|
|||
'checkbox',
|
||||
'forced',
|
||||
array(
|
||||
'label' => t('Forced')
|
||||
)
|
||||
);
|
||||
$this->addElement(
|
||||
new Note(
|
||||
array(
|
||||
'name' => 'forcenote',
|
||||
'value' => t(
|
||||
'Custom notifications normally follow the regular notification logic in Icinga. Selecting this '
|
||||
. 'option will force the notification to be sent out, regardless of time restrictions, '
|
||||
. 'whether or not notifications are enabled, etc.'
|
||||
)
|
||||
'label' => t('Forced'),
|
||||
'helptext' => t(
|
||||
'Custom notifications normally follow the regular notification logic in Icinga. Selecting this '
|
||||
. 'option will force the notification to be sent out, regardless of time restrictions, '
|
||||
. 'whether or not notifications are enabled, etc.'
|
||||
)
|
||||
)
|
||||
);
|
||||
|
@ -102,18 +82,11 @@ class CustomNotificationForm extends CommandForm
|
|||
'checkbox',
|
||||
'broadcast',
|
||||
array(
|
||||
'label' => t('Broadcast')
|
||||
)
|
||||
);
|
||||
$this->addElement(
|
||||
new Note(
|
||||
array(
|
||||
'name' => 'broadcastnote',
|
||||
'value' => t(
|
||||
'Selecting this option causes the notification to be sent out to all normal (non-escalated) '
|
||||
. ' and escalated contacts. These options allow you to override the normal notification logic '
|
||||
. 'if you need to get an important message out.'
|
||||
)
|
||||
'label' => t('Broadcast'),
|
||||
'helptext' => t(
|
||||
'Selecting this option causes the notification to be sent out to all normal (non-escalated) '
|
||||
. ' and escalated contacts. These options allow you to override the normal notification logic '
|
||||
. 'if you need to get an important message out.'
|
||||
)
|
||||
)
|
||||
);
|
||||
|
@ -126,7 +99,7 @@ class CustomNotificationForm extends CommandForm
|
|||
/**
|
||||
* Create Custom Notification from request data
|
||||
*
|
||||
* @return \Icinga\Protocol\Commandpipe\CustomNotification
|
||||
* @return CustomNotification
|
||||
*/
|
||||
public function getCustomNotification()
|
||||
{
|
||||
|
|
|
@ -28,8 +28,6 @@
|
|||
|
||||
namespace Monitoring\Form\Command;
|
||||
|
||||
use \Icinga\Web\Form\Element\Note;
|
||||
|
||||
/**
|
||||
* Form for the delay notification command
|
||||
*/
|
||||
|
@ -45,14 +43,8 @@ class DelayNotificationForm extends CommandForm
|
|||
*/
|
||||
protected function create()
|
||||
{
|
||||
$this->addElement(
|
||||
new Note(
|
||||
array(
|
||||
'name' => 'commanddescription',
|
||||
'value' => t('This command is used to delay the next problem notification that is sent out.')
|
||||
)
|
||||
)
|
||||
);
|
||||
$this->addNote(t('This command is used to delay the next problem notification that is sent out.'));
|
||||
|
||||
$this->addElement(
|
||||
'text',
|
||||
'minutes',
|
||||
|
@ -70,15 +62,13 @@ class DelayNotificationForm extends CommandForm
|
|||
'max' => self::MAX_DELAY
|
||||
)
|
||||
)
|
||||
),
|
||||
'helptext' => t(
|
||||
'The notification delay will be disregarded if the host/service changes state before the next '
|
||||
. 'notification is scheduled to be sent out.'
|
||||
)
|
||||
)
|
||||
);
|
||||
$this->addNote(
|
||||
t(
|
||||
'The notification delay will be disregarded if the host/service changes state before the next '
|
||||
. 'notification is scheduled to be sent out.'
|
||||
)
|
||||
);
|
||||
|
||||
$this->setSubmitLabel(t('Delay Notification'));
|
||||
|
||||
|
|
|
@ -31,7 +31,6 @@ namespace Monitoring\Form\Command;
|
|||
use \Zend_Form_Element_Checkbox;
|
||||
use \Icinga\Web\Form\Element\DateTimePicker;
|
||||
use \Icinga\Util\DateTimeFactory;
|
||||
use \Icinga\Web\Form\Element\Note;
|
||||
|
||||
/**
|
||||
* Form for scheduling checks
|
||||
|
@ -43,33 +42,21 @@ class RescheduleNextCheckForm extends WithChildrenCommandForm
|
|||
*/
|
||||
protected function create()
|
||||
{
|
||||
$this->addElement(
|
||||
new Note(
|
||||
array(
|
||||
'name' => 'commanddescription',
|
||||
'value' => t(
|
||||
'This command is used to schedule the next check of hosts/services. Icinga will re-queue the '
|
||||
. 'check at the time you specify.'
|
||||
)
|
||||
)
|
||||
$this->addNote(
|
||||
t(
|
||||
'This command is used to schedule the next check of hosts/services. Icinga will re-queue the '
|
||||
. 'check at the time you specify.'
|
||||
)
|
||||
);
|
||||
|
||||
$this->addElement(
|
||||
new DateTimePicker(
|
||||
array(
|
||||
'name' => 'checktime',
|
||||
'label' => t('Check Time'),
|
||||
'value' => DateTimeFactory::create()->getTimestamp(),
|
||||
'required' => !$this->getRequest()->getPost('forcecheck')
|
||||
)
|
||||
)
|
||||
);
|
||||
$this->addElement(
|
||||
new Note(
|
||||
array(
|
||||
'name' => 'checktimenote',
|
||||
'value' => t('Set the date/time when this check should be executed.')
|
||||
'name' => 'checktime',
|
||||
'label' => t('Check Time'),
|
||||
'value' => DateTimeFactory::create()->getTimestamp(),
|
||||
'required' => !$this->getRequest()->getPost('forcecheck'),
|
||||
'helptext' => t('Set the date/time when this check should be executed.')
|
||||
)
|
||||
)
|
||||
);
|
||||
|
@ -77,17 +64,10 @@ class RescheduleNextCheckForm extends WithChildrenCommandForm
|
|||
$this->addElement(
|
||||
new Zend_Form_Element_Checkbox(
|
||||
array(
|
||||
'name' => 'forcecheck',
|
||||
'label' => t('Force Check'),
|
||||
'value' => true
|
||||
)
|
||||
)
|
||||
);
|
||||
$this->addElement(
|
||||
new Note(
|
||||
array(
|
||||
'name' => 'forcechecknote',
|
||||
'value' => t(
|
||||
'name' => 'forcecheck',
|
||||
'label' => t('Force Check'),
|
||||
'value' => true,
|
||||
'helptext' => t(
|
||||
'If you select this option, Icinga will force a check regardless of both what time the '
|
||||
. 'scheduled check occurs and whether or not checks are enabled.'
|
||||
)
|
||||
|
|
|
@ -35,7 +35,6 @@ use \Icinga\Web\Form\Element\DateTimePicker;
|
|||
use \Icinga\Protocol\Commandpipe\Downtime;
|
||||
use \Icinga\Protocol\Commandpipe\Comment;
|
||||
use \Icinga\Util\DateTimeFactory;
|
||||
use \Icinga\Web\Form\Element\Note;
|
||||
|
||||
/**
|
||||
* Form for scheduling downtimes
|
||||
|
@ -78,17 +77,12 @@ class ScheduleDowntimeForm extends WithChildrenCommandForm
|
|||
*/
|
||||
protected function create()
|
||||
{
|
||||
$this->addElement(
|
||||
new Note(
|
||||
array(
|
||||
'name' => 'commanddescription',
|
||||
'value' => t(
|
||||
'This command is used to schedule downtime for hosts/services. During the specified downtime, '
|
||||
. 'Icinga will not send notifications out about the affected objects. When the scheduled '
|
||||
. 'downtime expires, Icinga will send out notifications as it normally would. Scheduled '
|
||||
. 'downtimes are preserved across program shutdowns and restarts.'
|
||||
)
|
||||
)
|
||||
$this->addNote(
|
||||
t(
|
||||
'This command is used to schedule downtime for hosts/services. During the specified downtime, '
|
||||
. 'Icinga will not send notifications out about the affected objects. When the scheduled '
|
||||
. 'downtime expires, Icinga will send out notifications as it normally would. Scheduled '
|
||||
. 'downtimes are preserved across program shutdowns and restarts.'
|
||||
)
|
||||
);
|
||||
|
||||
|
@ -100,18 +94,11 @@ class ScheduleDowntimeForm extends WithChildrenCommandForm
|
|||
array(
|
||||
'label' => t('Comment'),
|
||||
'rows' => 4,
|
||||
'required' => true
|
||||
)
|
||||
);
|
||||
$this->addElement(
|
||||
new Note(
|
||||
array(
|
||||
'name' => 'commentnote',
|
||||
'value' => t(
|
||||
'If you work with other administrators, you may find it useful to share information '
|
||||
. 'about a host or service that is having problems if more than one of you may be working on '
|
||||
. 'it. Make sure you enter a brief description of what you are doing.'
|
||||
)
|
||||
'required' => true,
|
||||
'helptext' => t(
|
||||
'If you work with other administrators, you may find it useful to share information '
|
||||
. 'about a host or service that is having problems if more than one of you may be working on '
|
||||
. 'it. Make sure you enter a brief description of what you are doing.'
|
||||
)
|
||||
)
|
||||
);
|
||||
|
@ -147,34 +134,20 @@ class ScheduleDowntimeForm extends WithChildrenCommandForm
|
|||
$this->addElement(
|
||||
new DateTimePicker(
|
||||
array(
|
||||
'name' => 'starttime',
|
||||
'label' => t('Start Time'),
|
||||
'value' => $now->getTimestamp()
|
||||
)
|
||||
)
|
||||
);
|
||||
$this->addElement(
|
||||
new Note(
|
||||
array(
|
||||
'name' => 'stattimenote',
|
||||
'value' => t('Set the start date/time for the downtime.')
|
||||
'name' => 'starttime',
|
||||
'label' => t('Start Time'),
|
||||
'value' => $now->getTimestamp(),
|
||||
'helptext' => t('Set the start date/time for the downtime.')
|
||||
)
|
||||
)
|
||||
);
|
||||
$this->addElement(
|
||||
new DateTimePicker(
|
||||
array(
|
||||
'name' => 'endtime',
|
||||
'label' => t('End Time'),
|
||||
'value' => $now->getTimestamp() + 3600
|
||||
)
|
||||
)
|
||||
);
|
||||
$this->addElement(
|
||||
new Note(
|
||||
array(
|
||||
'name' => 'endtimenote',
|
||||
'value' => t('Set the end date/time for the downtime.')
|
||||
'name' => 'endtime',
|
||||
'label' => t('End Time'),
|
||||
'value' => $now->getTimestamp() + 3600,
|
||||
'helptext' => t('Set the end date/time for the downtime.')
|
||||
)
|
||||
)
|
||||
);
|
||||
|
@ -183,10 +156,10 @@ class ScheduleDowntimeForm extends WithChildrenCommandForm
|
|||
'select',
|
||||
'type',
|
||||
array(
|
||||
'label' => t('Downtime Type'),
|
||||
'multiOptions' => $this->getDowntimeTypeOptions(),
|
||||
'required' => true,
|
||||
'validators' => array(
|
||||
'label' => t('Downtime Type'),
|
||||
'multiOptions' => $this->getDowntimeTypeOptions(),
|
||||
'required' => true,
|
||||
'validators' => array(
|
||||
array(
|
||||
'InArray',
|
||||
true,
|
||||
|
@ -194,19 +167,12 @@ class ScheduleDowntimeForm extends WithChildrenCommandForm
|
|||
array_keys($this->getDowntimeTypeOptions())
|
||||
)
|
||||
)
|
||||
)
|
||||
)
|
||||
);
|
||||
$this->addElement(
|
||||
new Note(
|
||||
array(
|
||||
'name' => 'typenote',
|
||||
'value' => t(
|
||||
'If you select the fixed option, the downtime will be in effect between the start and end '
|
||||
. 'times you specify whereas a flexible downtime starts when the service enters a non-OK state '
|
||||
. '(sometime between the start and end times you specified) and lasts as long as the duration '
|
||||
. 'of time you enter. The duration fields do not apply for fixed downtime.'
|
||||
)
|
||||
),
|
||||
'helptext' => t(
|
||||
'If you select the fixed option, the downtime will be in effect between the start and end '
|
||||
. 'times you specify whereas a flexible downtime starts when the service enters a non-OK state '
|
||||
. '(sometime between the start and end times you specified) and lasts as long as the duration '
|
||||
. 'of time you enter. The duration fields do not apply for fixed downtime.'
|
||||
)
|
||||
)
|
||||
);
|
||||
|
@ -242,15 +208,10 @@ class ScheduleDowntimeForm extends WithChildrenCommandForm
|
|||
)
|
||||
);
|
||||
$this->addElements(array($hoursText, $minutesText));
|
||||
$this->addElement(
|
||||
new Note(
|
||||
array(
|
||||
'name' => 'flexiblenote',
|
||||
'value' => t(
|
||||
'Enter here the duration of the downtime. Icinga will automatically delete the downtime '
|
||||
. 'after this time expired.'
|
||||
)
|
||||
)
|
||||
$this->addNote(
|
||||
t(
|
||||
'Enter here the duration of the downtime. Icinga will automatically delete the downtime '
|
||||
. 'after this time expired.'
|
||||
)
|
||||
);
|
||||
}
|
||||
|
@ -297,8 +258,9 @@ class ScheduleDowntimeForm extends WithChildrenCommandForm
|
|||
/**
|
||||
* Change validators at runtime
|
||||
*
|
||||
* @param array $data The user provided data that will go into validation
|
||||
*
|
||||
* @see Form::preValidation
|
||||
* @param array $data
|
||||
*/
|
||||
protected function preValidation(array $data)
|
||||
{
|
||||
|
|
|
@ -29,7 +29,6 @@
|
|||
namespace Monitoring\Form\Command;
|
||||
|
||||
use \Icinga\Exception\ProgrammingError;
|
||||
use \Icinga\Web\Form\Element\Note;
|
||||
|
||||
/**
|
||||
* Form for submitting passive check results
|
||||
|
@ -125,16 +124,11 @@ class SubmitPassiveCheckResultForm extends CommandForm
|
|||
*/
|
||||
protected function create()
|
||||
{
|
||||
$this->addElement(
|
||||
new Note(
|
||||
array(
|
||||
'name' => 'commanddescription',
|
||||
'value' => t(
|
||||
'This command is used to submit a passive check result for particular hosts/services. It is '
|
||||
. 'particularly useful for resetting security-related objects to OK states once they have been '
|
||||
. 'dealt with.'
|
||||
)
|
||||
)
|
||||
$this->addNote(
|
||||
t(
|
||||
'This command is used to submit a passive check result for particular hosts/services. It is '
|
||||
. 'particularly useful for resetting security-related objects to OK states once they have been '
|
||||
. 'dealt with.'
|
||||
)
|
||||
);
|
||||
|
||||
|
@ -142,10 +136,10 @@ class SubmitPassiveCheckResultForm extends CommandForm
|
|||
'select',
|
||||
'pluginstate',
|
||||
array(
|
||||
'label' => t('Check Result'),
|
||||
'multiOptions' => $this->getOptions(),
|
||||
'required' => true,
|
||||
'validators' => array(
|
||||
'label' => t('Check Result'),
|
||||
'multiOptions' => $this->getOptions(),
|
||||
'required' => true,
|
||||
'validators' => array(
|
||||
array(
|
||||
'Digits',
|
||||
true
|
||||
|
@ -157,15 +151,8 @@ class SubmitPassiveCheckResultForm extends CommandForm
|
|||
array_keys($this->getOptions())
|
||||
)
|
||||
)
|
||||
)
|
||||
)
|
||||
);
|
||||
$this->addElement(
|
||||
new Note(
|
||||
array(
|
||||
'name' => 'checkresultnote',
|
||||
'value' => t('Set the state which should be send to Icinga for this objects.')
|
||||
)
|
||||
),
|
||||
'helptext' => t('Set the state which should be send to Icinga for this objects.')
|
||||
)
|
||||
);
|
||||
|
||||
|
@ -173,17 +160,10 @@ class SubmitPassiveCheckResultForm extends CommandForm
|
|||
'textarea',
|
||||
'checkoutput',
|
||||
array(
|
||||
'label' => t('Check Output'),
|
||||
'rows' => 2,
|
||||
'required' => true
|
||||
)
|
||||
);
|
||||
$this->addElement(
|
||||
new Note(
|
||||
array(
|
||||
'name' => 'checkoutputnote',
|
||||
'value' => t('Fill in the check output string which should be send to Icinga.')
|
||||
)
|
||||
'label' => t('Check Output'),
|
||||
'rows' => 2,
|
||||
'required' => true,
|
||||
'helptext' => t('Fill in the check output string which should be send to Icinga.')
|
||||
)
|
||||
);
|
||||
|
||||
|
@ -191,16 +171,9 @@ class SubmitPassiveCheckResultForm extends CommandForm
|
|||
'textarea',
|
||||
'performancedata',
|
||||
array(
|
||||
'label' => t('Performance Data'),
|
||||
'rows' => 2
|
||||
)
|
||||
);
|
||||
$this->addElement(
|
||||
new Note(
|
||||
array(
|
||||
'name' => 'performancedatanote',
|
||||
'value' => t('Fill in the performance data string which should be send to Icinga.')
|
||||
)
|
||||
'label' => t('Performance Data'),
|
||||
'rows' => 2,
|
||||
'helptext' => t('Fill in the performance data string which should be send to Icinga.')
|
||||
)
|
||||
);
|
||||
|
||||
|
|
|
@ -29,14 +29,9 @@
|
|||
namespace Monitoring\Form\Config\Backend;
|
||||
|
||||
use \Zend_Config;
|
||||
|
||||
use \Icinga\Application\Config as IcingaConfig;
|
||||
use \Icinga\Application\Icinga;
|
||||
use \Icinga\Application\Logger;
|
||||
use \Icinga\Application\DbAdapterFactory;
|
||||
|
||||
use \Icinga\Web\Form;
|
||||
use \Icinga\Web\Form\Element\Note;
|
||||
use \Icinga\Application\Icinga;
|
||||
use \Icinga\Application\DbAdapterFactory;
|
||||
|
||||
/**
|
||||
* Form for modifying a monitoring backend
|
||||
|
@ -88,7 +83,6 @@ class EditBackendForm extends Form
|
|||
/**
|
||||
* Set a custom array of resources to be used in this form instead of the ones from DbAdapterFactory
|
||||
* (used for testing)
|
||||
*
|
||||
*/
|
||||
public function setResources($resources)
|
||||
{
|
||||
|
@ -249,14 +243,7 @@ class EditBackendForm extends Form
|
|||
break;
|
||||
default:
|
||||
$this->removeElement('backend_type');
|
||||
$this->addElement(
|
||||
new Note(
|
||||
array(
|
||||
'name' => 'error_note',
|
||||
'value' => 'Unknown Backend Type "' . $this->backend->type. '"'
|
||||
)
|
||||
)
|
||||
);
|
||||
$this->addNote('Unknown Backend Type "' . $this->backend->type. '"');
|
||||
return;
|
||||
}
|
||||
$this->addDisableButton();
|
||||
|
|
|
@ -31,7 +31,6 @@ namespace Monitoring\Form\Config\Instance;
|
|||
|
||||
use \Zend_Config;
|
||||
use \Icinga\Web\Form;
|
||||
use \Icinga\Web\Form\Element\Note;
|
||||
|
||||
/**
|
||||
* Form for editing existing instances
|
||||
|
@ -91,14 +90,8 @@ class EditInstanceForm extends Form
|
|||
*/
|
||||
private function addRemoteInstanceForm()
|
||||
{
|
||||
$this->addElement(
|
||||
new Note(
|
||||
array(
|
||||
'name' => 'note_ssh_info',
|
||||
'value' => 'When configuring a remote host, you need to setup passwordless key authentication'
|
||||
)
|
||||
)
|
||||
);
|
||||
$this->addNote('When configuring a remote host, you need to setup passwordless key authentication');
|
||||
|
||||
$this->addElement(
|
||||
'text',
|
||||
'instance_remote_host',
|
||||
|
|
|
@ -8,7 +8,6 @@ require_once __DIR__. '/../../../../../application/forms/Command/CommandForm.php
|
|||
|
||||
|
||||
use \Zend_View;
|
||||
use \Zend_Test_PHPUnit_ControllerTestCase;
|
||||
use \Test\Icinga\Web\Form\BaseFormTest;
|
||||
|
||||
use Monitoring\Form\Command\CommandForm;
|
||||
|
@ -32,18 +31,4 @@ class CommandFormTest extends BaseFormTest
|
|||
$this->assertContains('444 NOTE 1</dd>', $content);
|
||||
$this->assertContains('555 NOTE 2</dd>', $content);
|
||||
}
|
||||
|
||||
public function testFormNotes()
|
||||
{
|
||||
$form = new CommandForm();
|
||||
$form->addNote('test1');
|
||||
$form->addNote('test2');
|
||||
|
||||
$reference = array('test1', 'test2');
|
||||
$this->assertCount(2, $form->getNotes());
|
||||
$this->assertEquals($reference, $form->getNotes());
|
||||
|
||||
$form->clearNotes();
|
||||
$this->assertCount(0, $form->getNotes());
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue