public function getCMSFields() { $fields = parent::getCMSFields(); if (class_exists('AbstractQueuedJob')) { $before = _t('UnpublishItemWorkflowAction.DELAYUNPUBDAYSBEFORE', 'Delay publication '); $after = _t('UnpublishItemWorkflowAction.DELAYUNPUBDAYSAFTER', ' days'); $fields->addFieldToTab('Root.Main', new FieldGroup(_t('UnpublishItemWorkflowAction.UNPUBLICATIONDELAY', 'Delay Un-publishing'), new LabelField('UnpublishDelayBefore', $before), new NumericField('UnpublishDelay', ''), new LabelField('UnpublishDelayAfter', $after))); } return $fields; }
/** * Utility method, used in tests * @return \WorkflowDefinition */ protected function createDefinition() { $definition = new WorkflowDefinition(); $definition->Title = "Dummy Workflow Definition"; $definition->write(); $stepOne = new WorkflowAction(); $stepOne->Title = "Step One"; $stepOne->WorkflowDefID = $definition->ID; $stepOne->write(); $stepTwo = new WorkflowAction(); $stepTwo->Title = "Step Two"; $stepTwo->WorkflowDefID = $definition->ID; $stepTwo->write(); $transitionOne = new WorkflowTransition(); $transitionOne->Title = 'Step One T1'; $transitionOne->ActionID = $stepOne->ID; $transitionOne->NextActionID = $stepTwo->ID; $transitionOne->write(); return $definition; }
public function handleAdd() { $parent = $this->request->param('ParentID'); $action = WorkflowAction::get()->byID($this->request->param('ParentID')); if (!$action || $action->WorkflowDefID != $this->RootField()->Definition()->ID) { $this->httpError(404); } if (!singleton('WorkflowTransition')->canCreate()) { $this->httpError(403); } $transition = new WorkflowTransition(); $transition->ActionID = $action->ID; return new WorkflowFieldItemController($this, "new/{$parent}", $transition); }
public function getCMSFields() { $fields = parent::getCMSFields(); return $fields; }
public function testName() { $this->assertEquals('testAction', $this->action->getName()); }
public function getCMSFields() { $fields = parent::getCMSFields(); $fields->addFieldsToTab('Root.Main', array(TextField::create('Property', 'Property')->setRightTitle('Property to set; if this exists as a setter method, will be called passing the value'), TextField::create('Value', 'Value'))); return $fields; }
public function fieldLabels($relations = true) { return array_merge(parent::fieldLabels($relations), array('NotificationEmail' => _t('NotifyUsersWorkflowAction.NOTIFICATIONEMAIL', 'Notification Email'), 'NotificationNote' => _t('NotifyUsersWorkflowAction.NOTIFICATIONNOTE', 'All users attached to the workflow will be sent an email when this action is run.'), 'EmailSubject' => _t('NotifyUsersWorkflowAction.EMAILSUBJECT', 'Email subject'), 'EmailFrom' => _t('NotifyUsersWorkflowAction.EMAILFROM', 'Email from'), 'ListingTemplateID' => _t('NotifyUsersWorkflowAction.LISTING_TEMPLATE', 'Listing Template - Items will be the list of all actions in the workflow (synonym to Actions). ' . 'Also available will be all properties of the current Workflow Instance'), 'EmailTemplate' => _t('NotifyUsersWorkflowAction.EMAILTEMPLATE', 'Email template'), 'FormattingHelp' => _t('NotifyUsersWorkflowAction.FORMATTINGHELP', 'Formatting Help'))); }
public function getCurrentAction() { $join = '"WorkflowAction"."ID" = "WorkflowActionInstance"."BaseActionID"'; $action = WorkflowAction::get()->leftJoin('WorkflowActionInstance', $join)->where('"WorkflowActionInstance"."ID" = ' . $this->CurrentActionID)->first(); if (!$action) { return 'N/A'; } return $action->getField('Title'); }
/** * Update the transitions for a given action * * @param array $actionTemplate * @param WorkflowAction $action * * @return array */ protected function updateActionTransitions($actionTemplate, $action) { $transitions = array(); if (isset($actionTemplate['transitions']) && is_array($actionTemplate['transitions'])) { $existing = $action->Transitions(); $transitionMap = array(); foreach ($existing as $transition) { $transitionMap[$transition->Title] = $transition; } foreach ($actionTemplate['transitions'] as $transitionName => $transitionTemplate) { $target = $transitionTemplate; if (is_array($transitionTemplate)) { $target = $transitionTemplate['to']; } if (isset($transitionMap[$transitionName])) { $transition = $transitionMap[$transitionName]; } else { $transition = WorkflowTransition::create(); } $transition->Title = $transitionName; $transition->ActionID = $action->ID; // we don't have the NextAction yet other than the target name, so we store that against // the transition and do a second pass later on to match things up $transition->Target = $target; $transitions[] = $transition; } } return $transitions; }
public function fieldLabels($relations = true) { return array_merge(parent::fieldLabels($relations), array('AssignUsers' => _t('AssignUsersToWorkflowAction.ASSIGNUSERS', 'Assign Users'), 'Users' => _t('AssignUsersToWorkflowAction.USERS', 'Users'), 'Groups' => _t('AssignUsersToWorkflowAction.GROUPS', 'Groups'), 'AssignInitiator' => _t('AssignUsersToWorkflowAction.INITIATOR', 'Assign Initiator'))); }
/** * Adds action for state. * * @param WorkflowAction $action */ public function addAction(WorkflowAction $action) { $this->actions[$action->getName()] = $action; }
/** * Reorders actions within a definition * * @param WorkflowDefinition|WorkflowAction $objects * The objects to be reordered * @param array $newOrder * An array of IDs of the actions in the order they should be. */ public function reorder($objects, $newOrder) { $sortVals = array_values($objects->map('ID', 'Sort')->toArray()); sort($sortVals); // save the new ID values - but only use existing sort values to prevent // conflicts with items not in the table foreach ($newOrder as $key => $id) { if (!$id) { continue; } $object = $objects->find('ID', $id); $object->Sort = $sortVals[$key]; $object->write(); } }