Ejemplo n.º 1
0
 function createExceptionPolicy($company_id)
 {
     $epcf = new ExceptionPolicyControlFactory();
     $epcf->setCompany($company_id);
     $epcf->setName('Default');
     if ($epcf->isValid()) {
         $epc_id = $epcf->Save();
         Debug::Text('aException Policy Control ID: ' . $epc_id, __FILE__, __LINE__, __METHOD__, 10);
         if ($epc_id === TRUE) {
             $epc_id = $data['id'];
         }
         Debug::Text('bException Policy Control ID: ' . $epc_id, __FILE__, __LINE__, __METHOD__, 10);
         $data['exceptions'] = array('S1' => array('active' => TRUE, 'severity_id' => 10), 'S2' => array('active' => TRUE, 'severity_id' => 30), 'S3' => array('active' => TRUE, 'severity_id' => 10, 'grace' => 300, 'watch_window' => 3600), 'S4' => array('active' => TRUE, 'severity_id' => 20, 'grace' => 300, 'watch_window' => 3600), 'S5' => array('active' => TRUE, 'severity_id' => 20, 'grace' => 300, 'watch_window' => 3600), 'S6' => array('active' => TRUE, 'severity_id' => 10, 'grace' => 300, 'watch_window' => 3600), 'S7' => array('active' => TRUE, 'severity_id' => 30), 'S8' => array('active' => TRUE, 'severity_id' => 10), 'M1' => array('active' => TRUE, 'severity_id' => 30), 'M2' => array('active' => TRUE, 'severity_id' => 30), 'L3' => array('active' => TRUE, 'severity_id' => 30), 'M3' => array('active' => TRUE, 'severity_id' => 30));
         if (count($data['exceptions']) > 0) {
             foreach ($data['exceptions'] as $code => $exception_data) {
                 Debug::Text('Looping Code: ' . $code, __FILE__, __LINE__, __METHOD__, 10);
                 $epf = new ExceptionPolicyFactory();
                 $epf->setExceptionPolicyControl($epc_id);
                 if (isset($exception_data['active'])) {
                     $epf->setActive(TRUE);
                 } else {
                     $epf->setActive(FALSE);
                 }
                 $epf->setType($code);
                 $epf->setSeverity($exception_data['severity_id']);
                 if (isset($exception_data['demerit']) and $exception_data['demerit'] != '') {
                     $epf->setDemerit($exception_data['demerit']);
                 }
                 if (isset($exception_data['grace']) and $exception_data['grace'] != '') {
                     $epf->setGrace($exception_data['grace']);
                 }
                 if (isset($exception_data['watch_window']) and $exception_data['watch_window'] != '') {
                     $epf->setWatchWindow($exception_data['watch_window']);
                 }
                 if ($epf->isValid()) {
                     $epf->Save();
                 }
             }
             Debug::Text('Creating Exception Policy ID: ' . $epc_id, __FILE__, __LINE__, __METHOD__, 10);
             return $epc_id;
         }
     }
     Debug::Text('Failed Creating Exception Policy!', __FILE__, __LINE__, __METHOD__, 10);
     return FALSE;
 }
        }
    }
}
$epf = new ExceptionPolicyFactory();
$epcf = new ExceptionPolicyControlFactory();
$action = Misc::findSubmitButton();
$action = strtolower($action);
switch ($action) {
    case 'submit':
        //Debug::setVerbosity(11);
        Debug::Text('Submit!', __FILE__, __LINE__, __METHOD__, 10);
        $epcf->setId($data['id']);
        $epcf->setCompany($current_company->getId());
        $epcf->setName($data['name']);
        if ($epcf->isValid()) {
            $epc_id = $epcf->Save();
            Debug::Text('aException Policy Control ID: ' . $epc_id, __FILE__, __LINE__, __METHOD__, 10);
            if ($epc_id === TRUE) {
                $epc_id = $data['id'];
            }
            Debug::Text('bException Policy Control ID: ' . $epc_id, __FILE__, __LINE__, __METHOD__, 10);
            if (count($data['exceptions']) > 0) {
                foreach ($data['exceptions'] as $code => $exception_data) {
                    Debug::Text('Looping Code: ' . $code . ' ID: ' . $exception_data['id'], __FILE__, __LINE__, __METHOD__, 10);
                    if ($exception_data['id'] != '' and $exception_data['id'] > 0) {
                        $epf->setId($exception_data['id']);
                    }
                    $epf->setExceptionPolicyControl($epc_id);
                    if (isset($exception_data['active'])) {
                        $epf->setActive(TRUE);
                    } else {