コード例 #1
0
 /**
  * Get the CMS view of the instance. This is used to display the log of
  * this workflow, and options to reassign if the workflow hasn't been
  * finished yet
  *
  * @return \FieldList
  */
 public function getCMSFields()
 {
     $fields = new FieldList();
     if (Permission::check('REASSIGN_ACTIVE_WORKFLOWS')) {
         if ($this->WorkflowStatus == 'Paused' || $this->WorkflowStatus == 'Active') {
             $cmsUsers = Member::mapInCMSGroups();
             $fields->push(new HiddenField('DirectUpdate', '', 1));
             $fields->push(new HeaderField('InstanceReassignHeader', _t('WorkflowInstance.REASSIGN_HEADER', 'Reassign workflow')));
             $fields->push(new CheckboxSetField('Users', _t('WorkflowDefinition.USERS', 'Users'), $cmsUsers));
             $fields->push(new TreeMultiselectField('Groups', _t('WorkflowDefinition.GROUPS', 'Groups'), 'Group'));
         }
     }
     if ($this->canEdit()) {
         $action = $this->CurrentAction();
         if ($action->exists()) {
             $actionFields = $this->getWorkflowFields();
             $fields->merge($actionFields);
             $transitions = $action->getValidTransitions();
             if ($transitions) {
                 $fields->replaceField('TransitionID', DropdownField::create("TransitionID", "Next action", $transitions->map()));
             }
         }
     }
     $items = WorkflowActionInstance::get()->filter(array('Finished' => 1, 'WorkflowID' => $this->ID));
     $grid = new GridField('Actions', _t('WorkflowInstance.ActionLogTitle', 'Log'), $items);
     $fields->push($grid);
     return $fields;
 }
コード例 #2
0
 /**
  * When deleting an action from a workflow definition, make sure that workflows currently paused on that action
  * are deleted
  * Also removes all outbound transitions
  */
 public function onAfterDelete()
 {
     parent::onAfterDelete();
     $wfActionInstances = WorkflowActionInstance::get()->leftJoin("WorkflowInstance", '"WorkflowInstance"."ID" = "WorkflowActionInstance"."WorkflowID"')->where(sprintf('"BaseActionID" = %d AND ("WorkflowStatus" IN (\'Active\',\'Paused\'))', $this->ID));
     foreach ($wfActionInstances as $wfActionInstance) {
         $wfInstances = WorkflowInstance::get()->filter('CurrentActionID', $wfActionInstance->ID);
         foreach ($wfInstances as $wfInstance) {
             $wfInstance->Groups()->removeAll();
             $wfInstance->Users()->removeAll();
             $wfInstance->delete();
         }
         $wfActionInstance->delete();
     }
     // Delete outbound transitions
     $transitions = WorkflowTransition::get()->filter('ActionID', $this->ID);
     foreach ($transitions as $transition) {
         $transition->Groups()->removeAll();
         $transition->Users()->removeAll();
         $transition->delete();
     }
 }