public static function refillRequestActionHandler(Audit $auditOrm, array $dataSourceData)
 {
     if (!count($dataSourceData) > 0) {
         WebVista::debug('Received an empty datasource');
         return false;
     }
     $orm = new GeneralAlert();
     $orm->populateWithArray($dataSourceData);
     $orm->persist();
     return true;
 }
Esempio n. 2
0
 protected function _doProcess(GeneralAlertHandler $handler, Audit $audit)
 {
     $handlerName = Handler::normalizeHandlerName($handler->name);
     $classHandlerObject = $handlerName . 'GeneralAlertHandlerObject';
     if (!parent::isParentOf($classHandlerObject, 'GeneralAlertHandlerObjectAbstract')) {
         trigger_error($classHandlerObject . ' is not an instance of GeneralAlertHandlerObjectAbstract', E_USER_NOTICE);
         return false;
     }
     $ret = false;
     if (call_user_func_array(array($classHandlerObject, 'matchAudit'), array($audit))) {
         do {
             $classDatasource = $handlerName . 'GeneralAlertDatasource';
             if (!parent::isParentOf($classDatasource, 'GeneralAlertDatasourceAbstract')) {
                 trigger_error($classDatasource . ' is not an instance of GeneralAlertDatasourceAbstract', E_USER_NOTICE);
                 break;
             }
             try {
                 $data = call_user_func_array(array($classDatasource, 'sourceData'), array($audit));
             } catch (Exception $e) {
                 trigger_error('Exception error (' . $e->getCode() . '): ' . $e->getMessage(), E_USER_NOTICE);
                 break;
             }
             $ret = true;
             if (!strlen($handler->template) > 0) {
                 $handler->template = $handler->generateDefaultTemplate();
             }
             foreach ($data as $row) {
                 $message = TemplateXSLT::render($row, $handler->template);
                 $generalAlert = new GeneralAlert();
                 $generalAlert->message = $message;
                 $generalAlert->urgency = 'Med';
                 $generalAlert->status = 'new';
                 $generalAlert->dateTime = date('Y-m-d H:i:s');
                 if (isset($row['teamId'])) {
                     $generalAlert->teamId = $row['teamId'];
                 }
                 if (isset($row['signingUserId'])) {
                     $generalAlert->userId = $row['signingUserId'];
                 }
                 if (isset($row['objectId'])) {
                     $generalAlert->objectId = $row['objectId'];
                 }
                 if (isset($row['objectClass'])) {
                     $generalAlert->objectClass = $row['objectClass'];
                 }
                 $generalAlert->persist();
             }
         } while (false);
     }
     return $ret;
 }
 public function markAlertDoneAction()
 {
     $generalAlertId = (int) $this->_getParam('generalAlertId');
     $alert = new GeneralAlert();
     $alert->generalAlertId = $generalAlertId;
     $alert->populate();
     $alert->status = 'processed';
     $alert->persist();
     $ret = true;
     $json = Zend_Controller_Action_HelperBroker::getStaticHelper('json');
     $json->suppressExit = true;
     $json->direct($ret);
 }