Esempio n. 1
0
 public function testProcess()
 {
     $data = array('Agent' => array('contactInterval' => '1.234', 'inventoryInterval' => ''), 'Download' => array('packageDeployment' => '1', 'downloadPeriodDelay' => '1.111', 'downloadCycleDelay' => '2.222', 'downloadFragmentDelay' => '3.333', 'downloadMaxPriority' => '4.444', 'downloadTimeout' => ''), 'Scan' => array('allowScan' => '0', 'scanSnmp' => '1'));
     $this->_group->expects($this->exactly(11))->method('setConfig')->withConsecutive(array('contactInterval', $this->identicalTo(1234)), array('inventoryInterval', $this->isNull()), array('downloadPeriodDelay', $this->identicalTo(1111)), array('downloadCycleDelay', $this->identicalTo(2222)), array('downloadFragmentDelay', $this->identicalTo(3333)), array('downloadMaxPriority', $this->identicalTo(4444)), array('downloadTimeout', $this->isNull()), array('packageDeployment', $this->identicalTo('1')), array('allowScan', $this->identicalTo('0')), array('scanThisNetwork', $this->isNull()), array('scanSnmp', $this->isNull()));
     $this->_form->setValidationGroup('Agent', 'Download', 'Scan');
     $this->_form->setClientObject($this->_group);
     $this->_form->setData($data);
     $this->assertTrue($this->_form->isValid());
     $this->_form->process();
 }
 /**
  * Group configuration form
  *
  * @return array|\Zend\Http\Response array(form, group) or redirect response
  */
 public function configurationAction()
 {
     $this->setActiveMenu('Groups');
     $this->_clientConfigForm->setClientObject($this->_currentGroup);
     if ($this->getRequest()->isPost()) {
         $this->_clientConfigForm->setData($this->params()->fromPost());
         if ($this->_clientConfigForm->isValid()) {
             $this->_clientConfigForm->process();
             return $this->redirectToRoute('group', 'configuration', array('name' => $this->_currentGroup['Name']));
         }
     } else {
         $this->_clientConfigForm->setData($this->_currentGroup->getAllConfig());
     }
     return array('group' => $this->_currentGroup, 'form' => $this->_clientConfigForm);
 }
Esempio n. 3
0
 /**
  * Delete a group
  *
  * @param \Model\Group\Group $group
  * @throws \Model\Group\RuntimeException if group is locked
  */
 public function deleteGroup(\Model\Group\Group $group)
 {
     if (!$group->lock()) {
         throw new RuntimeException('Cannot delete group because it is locked');
     }
     $id = $group['Id'];
     $connection = $this->_serviceManager->get('Db')->getDriver()->getConnection();
     $connection->beginTransaction();
     try {
         $this->_serviceManager->get('Database\\Table\\GroupMemberships')->delete(array('group_id' => $id));
         $this->_serviceManager->get('Database\\Table\\ClientConfig')->delete(array('hardware_id' => $id));
         $this->_serviceManager->get('Database\\Table\\GroupInfo')->delete(array('hardware_id' => $id));
         $this->_serviceManager->get('Database\\Table\\ClientsAndGroups')->delete(array('id' => $id));
         $connection->commit();
     } catch (\Exception $e) {
         $connection->rollBack();
         $group->unlock();
         throw $e;
     }
     $group->unlock();
 }