/** {@inheritdoc} */ public function init() { parent::init(); $preferences = $this->get('Preferences'); $inputFilter = new \Zend\InputFilter\InputFilter(); $communicationServerUri = new \Zend\Form\Element\Text('communicationServerUri'); $communicationServerUri->setLabel('Communication server URI'); $preferences->add($communicationServerUri); $inputFilter->add(array('name' => 'communicationServerUri', 'validators' => array(array('name' => 'Uri', 'options' => array('uriHandler' => 'Zend\\Uri\\Http', 'allowRelative' => false))))); $lockValidity = new \Zend\Form\Element\Text('lockValidity'); $lockValidity->setLabel('Maximum seconds to lock a computer')->setAttribute('size', 5); $preferences->add($lockValidity); $inputFilter->add($this->_getIntegerFilter('lockValidity')); $sessionValidity = new \Zend\Form\Element\Text('sessionValidity'); $sessionValidity->setLabel('Maximum duration of an agent session in seconds')->setAttribute('size', 5); $preferences->add($sessionValidity); $inputFilter->add($this->_getIntegerFilter('sessionValidity')); $sessionCleanupInterval = new \Zend\Form\Element\Text('sessionCleanupInterval'); $sessionCleanupInterval->setLabel('Interval in seconds to cleanup sessions')->setAttribute('size', 5); $preferences->add($sessionCleanupInterval); $inputFilter->add($this->_getIntegerFilter('sessionCleanupInterval')); $sessionRequired = new \Zend\Form\Element\Checkbox('sessionRequired'); $sessionRequired->setLabel('Session required for inventory'); $preferences->add($sessionRequired); $logLevel = new \Library\Form\Element\SelectSimple('logLevel'); $logLevel->setLabel('Log level')->setValueOptions(array(0, 1, 2)); $preferences->add($logLevel); $autoMergeDuplicates = new \Zend\Form\Element\Checkbox('autoMergeDuplicates'); $autoMergeDuplicates->setLabel('Merge duplicates automatically (not recommended)'); $preferences->add($autoMergeDuplicates); $parentFilter = new \Zend\InputFilter\InputFilter(); $parentFilter->add($inputFilter, 'Preferences'); $this->setInputFilter($parentFilter); }
/** {@inheritdoc} */ public function init() { parent::init(); $what = new \Zend\Form\Element\Radio('What'); $what->setValueOptions(array(\Model\Client\Client::MEMBERSHIP_AUTOMATIC => $this->_('Store search parameters. Group memberships will be updated automatically.'), \Model\Client\Client::MEMBERSHIP_ALWAYS => $this->_('Add current search results. Group memberships will be set only this time.'), \Model\Client\Client::MEMBERSHIP_NEVER => $this->_('Exclude search results from a group.'))); $what->setValue(\Model\Client\Client::MEMBERSHIP_AUTOMATIC); $this->add($what); $where = new \Zend\Form\Element\Radio('Where'); $where->setValueOptions(array('new' => $this->_('Store in new group'), 'existing' => $this->_('Store in existing group'))); $where->setValue('new')->setAttribute('onchange', 'selectElements()'); $this->add($where); $newGroup = new \Zend\Form\Element\Text('NewGroup'); $newGroup->setLabel('Name'); $this->add($newGroup); $description = new \Zend\Form\Element\Text('Description'); $description->setLabel('Description'); $this->add($description); $existingGroup = new \Library\Form\Element\SelectSimple('ExistingGroup'); $existingGroup->setLabel('Group'); $groups = array(); foreach ($this->getOption('GroupManager')->getGroups(null, null, 'Name') as $group) { $groups[] = $group['Name']; } $existingGroup->setValueOptions($groups); $this->add($existingGroup); $submit = new \Library\Form\Element\Submit('Submit'); $submit->setLabel('OK'); $this->add($submit); $inputFilter = new \Zend\InputFilter\InputFilter(); $inputFilter->add(array('name' => 'NewGroup', 'continue_if_empty' => true, 'filters' => array(array('name' => 'StringTrim')), 'validators' => array(array('name' => 'Callback', 'options' => array('callback' => array($this, 'validateLength'), 'callbackOptions' => array(0, 255), 'message' => $this->_('The input is more than 255 characters long')), 'break_chain_on_failure' => true), array('name' => 'Callback', 'options' => array('callback' => array($this, 'validateLength'), 'callbackOptions' => array(1, 255), 'message' => "Value is required and can't be empty"), 'break_chain_on_failure' => true), array('name' => 'Callback', 'options' => array('callback' => array($this, 'validateGroupExists'), 'message' => $this->_('The name already exists')))))); $inputFilter->add(array('name' => 'Description', 'required' => false, 'filters' => array(array('name' => 'StringTrim'), array('name' => 'Null', 'options' => array('type' => 'string'))), 'validators' => array(array('name' => 'Callback', 'options' => array('callback' => array($this, 'validateLength'), 'callbackOptions' => array(0, 255), 'message' => $this->_('The input is more than 255 characters long')))))); $this->setInputFilter($inputFilter); }
/** {@inheritdoc} */ public function init() { parent::init(); $type = new \Library\Form\Element\SelectSimple('Type'); $type->setLabel('Type')->setValueOptions($this->getOption('DeviceManager')->getTypes()); $this->add($type); $description = new \Zend\Form\Element\Text('Description'); $description->setLabel('Description'); $this->add($description); $submit = new \Library\Form\Element\Submit('Submit'); $submit->setLabel('OK'); $this->add($submit); $inputFilter = new \Zend\InputFilter\InputFilter(); $inputFilter->add(array('name' => 'Description', 'required' => false, 'filters' => array(array('name' => 'StringTrim')), 'validators' => array(array('name' => 'StringLength', 'options' => array('max' => 255))))); $this->setInputFilter($inputFilter); }
/** {@inheritdoc} */ public function init() { parent::init(); $preferences = $this->get('Preferences'); $inputFilter = new \Zend\InputFilter\InputFilter(); $packageDeployment = new \Zend\Form\Element\Checkbox('packageDeployment'); $packageDeployment->setLabel('Enable package download'); $preferences->add($packageDeployment); $packagePath = new \Zend\Form\Element\Text('packagePath'); $packagePath->setLabel('Package storage directory'); $preferences->add($packagePath); $inputFilter->add(array('name' => 'packagePath', 'validators' => array(array('name' => 'Library\\Validator\\DirectoryWritable')))); $packageBaseUriHttp = new \Zend\Form\Element\Text('packageBaseUriHttp'); $packageBaseUriHttp->setLabel('HTTP package base URL'); $preferences->add($packageBaseUriHttp); $inputFilter->add(array('name' => 'packageBaseUriHttp', 'filters' => array(array('name' => 'StringTrim'), array('name' => 'PregReplace', 'options' => array('pattern' => '#(.*://|/$)#', 'replacement' => ''))), 'validators' => array(array('name' => 'Callback', 'options' => array('callback' => array($this, 'validateUri')))))); $packageBaseUriHttps = new \Zend\Form\Element\Text('packageBaseUriHttps'); $packageBaseUriHttps->setLabel('HTTPS package base URL'); $preferences->add($packageBaseUriHttps); $inputFilter->add(array('name' => 'packageBaseUriHttps', 'filters' => array(array('name' => 'StringTrim'), array('name' => 'PregReplace', 'options' => array('pattern' => '#(.*://|/$)#', 'replacement' => ''))), 'validators' => array(array('name' => 'Callback', 'options' => array('callback' => array($this, 'validateUri')))))); $downloadPeriodDelay = new \Zend\Form\Element\Text('downloadPeriodDelay'); $downloadPeriodDelay->setLabel('Delay (in seconds) between periods')->setAttribute('size', 5); $preferences->add($downloadPeriodDelay); $inputFilter->add($this->_getIntegerFilter('downloadPeriodDelay')); $downloadCycleDelay = new \Zend\Form\Element\Text('downloadCycleDelay'); $downloadCycleDelay->setLabel('Delay (in seconds) between cycles')->setAttribute('size', 5); $preferences->add($downloadCycleDelay); $inputFilter->add($this->_getIntegerFilter('downloadCycleDelay')); $downloadFragmentDelay = new \Zend\Form\Element\Text('downloadFragmentDelay'); $downloadFragmentDelay->setLabel('Delay (in seconds) between fragments')->setAttribute('size', 5); $preferences->add($downloadFragmentDelay); $inputFilter->add($this->_getIntegerFilter('downloadFragmentDelay')); $downloadMaxPriority = new \Library\Form\Element\SelectSimple('downloadMaxPriority'); $downloadMaxPriority->setLabel('Maximum package priority (packages with higher value will not be downloaded)')->setValueOptions(range(0, 10)); $preferences->add($downloadMaxPriority); $downloadTimeout = new \Zend\Form\Element\Text('downloadTimeout'); $downloadTimeout->setLabel('Timeout (in days)')->setAttribute('size', 5); $preferences->add($downloadTimeout); $inputFilter->add($this->_getIntegerFilter('downloadTimeout')); $parentFilter = new \Zend\InputFilter\InputFilter(); $parentFilter->add($inputFilter, 'Preferences'); $this->setInputFilter($parentFilter); }
/** {@inheritdoc} */ public function init() { parent::init(); $inputFilter = new \Zend\InputFilter\InputFilter(); // Agent options $agent = new \Zend\Form\Fieldset('Agent'); $inputFilterAgent = new \Zend\InputFilter\InputFilter(); $contactInterval = new Element\Text('contactInterval'); $contactInterval->setLabel('Agent contact interval (in hours)')->setAttribute('size', '5'); $agent->add($contactInterval); $inputFilterAgent->add($this->_getIntegerFilter('contactInterval', 1)); $inventoryInterval = new Element\Text('inventoryInterval'); $inventoryInterval->setLabel('Inventory interval (in days, 0 = always, -1 = never)')->setAttribute('size', '5'); $agent->add($inventoryInterval); $inputFilterAgent->add($this->_getIntegerFilter('inventoryInterval', -1)); $this->add($agent); $inputFilter->add($inputFilterAgent, 'Agent'); // Download options $download = new \Zend\Form\Fieldset('Download'); $inputFilterDownload = new \Zend\InputFilter\InputFilter(); $packageDeployment = new Element\Checkbox('packageDeployment'); $packageDeployment->setLabel('Enable package download')->setAttribute('onchange', 'toggle(this)'); $download->add($packageDeployment); $downloadPeriodDelay = new Element\Text('downloadPeriodDelay'); $downloadPeriodDelay->setLabel('Delay (in seconds) between periods')->setAttribute('size', '5'); $download->add($downloadPeriodDelay); $inputFilterDownload->add($this->_getIntegerFilter('downloadPeriodDelay', 1)); $downloadCycleDelay = new Element\Text('downloadCycleDelay'); $downloadCycleDelay->setLabel('Delay (in seconds) between cycles')->setAttribute('size', '5'); $download->add($downloadCycleDelay); $inputFilterDownload->add($this->_getIntegerFilter('downloadCycleDelay', 1)); $downloadFragmentDelay = new Element\Text('downloadFragmentDelay'); $downloadFragmentDelay->setLabel('Delay (in seconds) between fragments')->setAttribute('size', '5'); $download->add($downloadFragmentDelay); $inputFilterDownload->add($this->_getIntegerFilter('downloadFragmentDelay', 1)); $downloadMaxPriority = new Element\Text('downloadMaxPriority'); $downloadMaxPriority->setLabel('Maximum package priority')->setAttribute('size', '5'); $download->add($downloadMaxPriority); $inputFilterDownload->add($this->_getIntegerFilter('downloadMaxPriority', 1)); $downloadTimeout = new Element\Text('downloadTimeout'); $downloadTimeout->setLabel('Timeout (in days)')->setAttribute('size', '5'); $download->add($downloadTimeout); $inputFilterDownload->add($this->_getIntegerFilter('downloadTimeout', 1)); $this->add($download); $inputFilter->add($inputFilterDownload, 'Download'); // Network scanning options $scan = new \Zend\Form\Fieldset('Scan'); $inputFilterScan = new \Zend\InputFilter\InputFilter(); $allowScan = new Element\Checkbox('allowScan'); $allowScan->setLabel('Allow network scanning')->setAttribute('onchange', 'toggle(this)'); $scan->add($allowScan); $subnets = new \Library\Form\Element\SelectSimple('scanThisNetwork'); $subnets->setLabel('Always scan this network')->setEmptyOption(''); $scan->add($subnets); $inputFilterScan->add(array('name' => 'scanThisNetwork', 'required' => false)); $scanSnmp = new Element\Checkbox('scanSnmp'); $scanSnmp->setLabel('Use SNMP'); $scan->add($scanSnmp); $this->add($scan); $inputFilter->add($inputFilterScan, 'Scan'); $submit = new \Library\Form\Element\Submit('Submit'); $submit->setLabel('OK'); $this->add($submit); $this->setInputFilter($inputFilter); }