public function processIncomingEmailCommand($content, Issue $issue) { if (!$issue->isWorkflowTransitionsAvailable()) { return false; } $lines = preg_split("/(\r?\n)/", $content); $first_line = array_shift($lines); $commands = explode(" ", trim($first_line)); $command = array_shift($commands); foreach ($issue->getAvailableWorkflowTransitions() as $transition) { if (strpos(str_replace(array(' ', '/'), array('', ''), mb_strtolower($transition->getName())), str_replace(array(' ', '/'), array('', ''), mb_strtolower($command))) !== false) { foreach ($commands as $single_command) { if (mb_strpos($single_command, '=')) { list($key, $val) = explode('=', $single_command); switch ($key) { case 'resolution': if (($resolution = Resolution::getByKeyish($val)) instanceof Resolution) { framework\Context::getRequest()->setParameter('resolution_id', $resolution->getID()); } break; case 'status': if (($status = Status::getByKeyish($val)) instanceof Status) { framework\Context::getRequest()->setParameter('status_id', $status->getID()); } break; } } } framework\Context::getRequest()->setParameter('comment_body', join("\n", $lines)); return $transition->transitionIssueToOutgoingStepWithoutRequest($issue); } } }
public function componentBulkWorkflow() { $workflow_items = array(); $project = null; $issues = array(); $first = true; foreach ($this->issue_ids as $issue_id) { $issue = new entities\Issue($issue_id); $issues[$issue_id] = $issue; if ($first) { $workflow_items = $issue->getAvailableWorkflowTransitions(); $project = $issue->getProject(); $first = false; } else { $transitions = $issue->getAvailableWorkflowTransitions(); foreach ($workflow_items as $transition_id => $transition) { if (!array_key_exists($transition_id, $transitions)) { unset($workflow_items[$transition_id]); } } if ($issue->getProject()->getID() != $project->getID()) { $project = null; break; } } if (!count($workflow_items)) { break; } } $this->issues = $issues; $this->project = $project; $this->available_transitions = $workflow_items; }