/** * Process the Export to JIRA form on submission * * @author Abhinav Kumar * * @return boolean 'true' on success and 'false' otherwise * @throws SWIFT_Exception if class is not loaded */ public function ProcessIssueForm() { $_JIRABridge = SWIFT_JIRABridge::GetInstance(); $_SWIFT = SWIFT::GetInstance(); if (!$this->GetIsClassLoaded()) { throw new SWIFT_Exception(SWIFT_CLASSNOTLOADED); } if (array_key_exists('ticketId', $_POST)) { $_ticketID = $_POST['ticketId']; } else { throw new SWIFT_Exception('Ticket ID' . $this->Language->Get('jira_noempty')); } if (array_key_exists('project', $_POST)) { $_projectKey = $_POST['project']; } else { throw new SWIFT_Exception('Project Key' . $this->Language->Get('jira_noempty')); } if (array_key_exists('issueType', $_POST)) { $_issueType = $_POST['issueType']; } else { throw new SWIFT_Exception('Issue Type' . $this->Language->Get('jira_noempty')); } if (array_key_exists('summary', $_POST)) { $_summary = $_POST['summary']; } else { throw new SWIFT_Exception('Summary' . $this->Language->Get('jira_noempty')); } if (array_key_exists('description', $_POST)) { $_description = $_POST['description']; } else { throw new SWIFT_Exception('Description' . $this->Language->Get('jira_noempty')); } if (array_key_exists('priority', $_POST)) { $_priority = $_POST['priority']; } else { throw new SWIFT_Exception('Priority' . $this->Language->Get('jira_noempty')); } if (isset($_POST['summary'])) { if (!$_JIRABridge) { if ($_SWIFT->Settings->Get('bj_isenabled')) { SWIFT::Alert($this->Language->Get('jira_error'), $this->Language->Get('connection_error') . $_SWIFT->Settings->Get('bj_jiraurl')); } return false; } $_Data = array('kayakoTicketId' => $_ticketID, 'project' => $_projectKey, 'issueType' => $_issueType, 'summary' => $_summary, 'description' => $_description, 'priority' => $_priority); $_JIRAIssue = $_JIRABridge->CreateIssue($_Data); if ($_JIRAIssue !== false) { $_SWIFT->Language->LoadApp('jira', 'jira'); $_SWIFT_TicketObject = SWIFT_Ticket::GetObjectOnID($_JIRAIssue->GetKayakoTicketId()); SWIFT::Notify(SWIFT::NOTIFICATION_INFO, $this->Language->Get('exportedToJIRA')); SWIFT_TicketAuditLog::Create($_SWIFT_TicketObject, null, SWIFT_TicketAuditLog::CREATOR_STAFF, $_SWIFT->Staff->GetStaffID(), $_SWIFT->Staff->GetProperty('fullname'), SWIFT_TicketAuditLog::ACTION_UPDATESTATUS, $this->Language->Get('exportedToJIRA') . ' - ' . $_JIRAIssue->GetKey(), SWIFT_TicketAuditLog::VALUE_STATUS); } else { SWIFT::Notify(SWIFT::NOTIFICATION_ERROR, strip_tags($this->Language->Get('jira_error') . $_JIRABridge->GetErrorMessage())); } $this->Load->Controller('Ticket', APP_TICKETS)->Load->Method('View', $_POST['jira_ticketid'], $_POST['jira_listtype'], $_POST['jira_departmentid'], $_POST['jira_ticketstatusid'], $_POST['jira_tickettypeid']); return true; } return false; }