/**
  * @see BaseJob::run()
  */
 public function run()
 {
     $workflows = WorkflowActionsUtil::getWorkflowsMissingRequiredActionAttributes();
     if (count($workflows) > 0) {
         $message = new NotificationMessage();
         $message->htmlContent = Zurmo::t('WorkflowsModule', 'As a result of a field or fields recently ' . 'becoming required, at least 1 workflow rule will no longer work properly.');
         $message->htmlContent .= "<div><ul>";
         foreach ($workflows as $workflow) {
             $message->htmlContent .= "<li>";
             $url = Yii::app()->createUrl('workflows/default/details', array('id' => $workflow->getId()));
             $message->htmlContent .= ZurmoHtml::link(strval($workflow), $url);
             $message->htmlContent .= "</li>";
         }
         $message->htmlContent .= "</ul></div>";
         $rules = new WorkflowValidityCheckNotificationRules();
         NotificationsUtil::submit($message, $rules);
     }
     return true;
 }
 /**
  * @see BaseJob::run()
  */
 public function run()
 {
     $workflowsWithInvalidActions = WorkflowActionsUtil::getWorkflowsMissingRequiredActionAttributes();
     if (count($workflowsWithInvalidActions) > 0) {
         $commonMessage = Zurmo::t('WorkflowsModule', 'As a result of a field or fields recently ' . 'becoming required, at least 1 workflow action rule will no longer work properly:');
         $message = new NotificationMessage();
         $message = $this->updateNotificationMessage($workflowsWithInvalidActions, $message, $commonMessage);
     }
     $workflowsWithInvalidTriggers = WorkflowTriggersUtil::getWorkflowsWithInvalidTriggerCustomFieldValue();
     if (count($workflowsWithInvalidTriggers) > 0) {
         if (!isset($message)) {
             $message = new NotificationMessage();
         }
         $commonMessage = Zurmo::t('WorkflowsModule', 'As a result of modifying picklist data recently, ' . 'at least 1 workflow trigger rule will no longer work properly:');
         $message = $this->updateNotificationMessage($workflowsWithInvalidTriggers, $message, $commonMessage);
     }
     if (count($workflowsWithInvalidActions) > 0 || count($workflowsWithInvalidTriggers) > 0) {
         $rules = new WorkflowValidityCheckNotificationRules();
         NotificationsUtil::submit($message, $rules);
     }
     return true;
 }
Пример #3
0
 /**
  * @param ByTimeWorkflowInQueue $byTimeWorkflowInQueue
  * @param RedBeanModel $model
  * @throws FailedToSaveModelException
  */
 protected function processByTimeWorkflowInQueue(ByTimeWorkflowInQueue $byTimeWorkflowInQueue, RedBeanModel $model)
 {
     $workflow = SavedWorkflowToWorkflowAdapter::makeWorkflowBySavedWorkflow($byTimeWorkflowInQueue->savedWorkflow);
     if (!$workflow->getIsActive()) {
         return;
     }
     $workflow->setTimeTriggerRequireChangeToProcessToFalse();
     if (WorkflowTriggersUtil::areTriggersTrueOnByTimeWorkflowQueueJob($workflow, $model)) {
         WorkflowActionsUtil::processOnByTimeWorkflowInQueueJob($workflow, $model, Yii::app()->user->userModel);
         WorkflowEmailMessagesUtil::processAfterSave($workflow, $model, Yii::app()->user->userModel);
         if ($model->isModified()) {
             $saved = $model->save();
             if (!$saved) {
                 throw new FailedToSaveModelException();
             }
         }
     }
 }
 /**
  * Given a RedBeanModel, process afterSave actions such as update related, create, and create related.
  * Also process any email messages.  If the workflow is by-time, then we should process the ByTimeWorkflowInQueue
  * model.
  * @param Item $model
  * @param User $triggeredByUser
  * @throws NotSupportedException
  */
 public static function resolveAfterSaveByModel(Item $model, User $triggeredByUser)
 {
     foreach ($model->getWorkflowsToProcessAfterSave() as $workflow) {
         if ($workflow->getType() == Workflow::TYPE_BY_TIME) {
             static::processToByTimeWorkflowInQueue($workflow, $model);
         } elseif ($workflow->getType() == Workflow::TYPE_ON_SAVE) {
             WorkflowActionsUtil::processAfterSave($workflow, $model, $triggeredByUser);
             WorkflowEmailMessagesUtil::processAfterSave($workflow, $model, $triggeredByUser);
         } else {
             throw new NotSupportedException();
         }
     }
 }
 /**
  * @depends testProcessAfterSave
  */
 public function testProcessOnByTimeWorkflowInQueueJob()
 {
     $model = WorkflowTestHelper::createWorkflowModelTestItem('Green', '514');
     $workflow = new Workflow();
     $workflow->setDescription('aDescription');
     $workflow->setIsActive(true);
     $workflow->setOrder(5);
     $workflow->setModuleClassName('WorkflowsTestModule');
     $workflow->setName('myFirstWorkflow');
     $workflow->setTriggerOn(Workflow::TRIGGER_ON_NEW_AND_EXISTING);
     $workflow->setType(Workflow::TYPE_ON_SAVE);
     $workflow->setTriggersStructure('1');
     $workflow->setIsActive(true);
     //Add action
     $action = new ActionForWorkflowForm('WorkflowModelTestItem', Workflow::TYPE_ON_SAVE);
     $action->type = ActionForWorkflowForm::TYPE_UPDATE_SELF;
     $action->relation = 'hasOne';
     $attributes = array('string' => array('shouldSetValue' => '1', 'type' => WorkflowActionAttributeForm::TYPE_STATIC, 'value' => 'jason'));
     $action->setAttributes(array(ActionForWorkflowForm::ACTION_ATTRIBUTES => $attributes));
     $workflow->addAction($action);
     WorkflowActionsUtil::processOnByTimeWorkflowInQueueJob($workflow, $model, Yii::app()->user->userModel);
     $this->assertEquals('jason', $model->string);
 }