public function runConfigureWorkflowSteps(TBGRequest $request) { $this->workflow = null; $this->mode = $request->getParameter('mode', 'list'); try { $this->workflow = TBGContext::factory()->TBGWorkflow($request->getParameter('workflow_id')); if ($this->mode == 'copy_workflow') { if ($new_name = $request->getParameter('new_name')) { $new_workflow = $this->workflow->copy($new_name); return $this->renderJSON(array('content' => $this->getTemplateHTML('configuration/workflow', array('workflow' => $new_workflow)), 'total_count' => TBGWorkflow::getCustomWorkflowsCount(), 'more_available' => TBGContext::getScope()->hasCustomWorkflowsAvailable())); } else { $this->error = TBGContext::getI18n()->__('Please enter a valid name'); } } elseif ($this->mode == 'delete_workflow') { $this->workflow->delete(); return $this->renderJSON(array('success' => true, 'message' => TBGContext::getI18n()->__('The workflow was deleted'), 'total_count' => TBGWorkflow::getCustomWorkflowsCount(), 'more_available' => TBGContext::getScope()->hasCustomWorkflowsAvailable())); } } catch (Exception $e) { if ($request->getRequestedFormat() == 'json') { $this->getResponse()->setHttpStatus(400); return $this->renderJSON(array('success' => false, 'message' => TBGContext::getI18n()->__('An error occured'), 'error' => $e->getMessage())); } else { $this->error = TBGContext::getI18n()->__('This workflow does not exist'); } } }
public function runConfigureWorkflowSteps(TBGRequest $request) { $this->workflow = null; $this->mode = $request->getParameter('mode', 'list'); try { $this->workflow = TBGContext::factory()->TBGWorkflow($request['workflow_id']); // $transition = new TBGWorkflowTransition(); // $step = TBGWorkflowStepsTable::getTable()->selectById(9); // $transition->setOutgoingStep($step); // $transition->setName('Initial transition'); // $transition->setWorkflow($this->workflow); // $transition->setScope(TBGContext::getScope()); // $transition->setDescription('This is the initial transition for issues using this workflow'); // $transition->save(); // $this->workflow->setInitialTransition($transition); // $this->workflow->save(); if ($this->mode == 'copy_workflow') { if ($new_name = $request['new_name']) { $new_workflow = $this->workflow->copy($new_name); return $this->renderJSON(array('content' => $this->getTemplateHTML('configuration/workflow', array('workflow' => $new_workflow)), 'total_count' => TBGWorkflow::getCustomWorkflowsCount(), 'more_available' => TBGContext::getScope()->hasCustomWorkflowsAvailable())); } else { $this->error = $this->getI18n()->__('Please enter a valid name'); } } elseif ($this->mode == 'delete_workflow') { $this->workflow->delete(); return $this->renderJSON(array('success' => true, 'message' => $this->getI18n()->__('The workflow was deleted'), 'total_count' => TBGWorkflow::getCustomWorkflowsCount(), 'more_available' => TBGContext::getScope()->hasCustomWorkflowsAvailable())); } } catch (Exception $e) { if ($request->getRequestedFormat() == 'json') { $this->getResponse()->setHttpStatus(400); return $this->renderJSON(array('success' => false, 'message' => $this->getI18n()->__('An error occured'), 'error' => $e->getMessage())); } else { $this->error = $this->getI18n()->__('This workflow does not exist'); } } }