/** * Unlinks a JIRA issue with a Kayako ticket * * @author Abhinav Kumar * * @param string $_issueKey The issue key to be unlinked * @param int $_ticketID * * @throws SWIFT_Exception * @return bool */ public function Unlink($_issueKey, $_ticketID) { $_SWIFT = SWIFT::GetInstance(); $_JIRABridge = SWIFT_JIRABridge::GetInstance(); $_response = array(); if (!$this->GetIsClassLoaded()) { throw new SWIFT_Exception(__CLASS__ . ' - ' . SWIFT_CLASSNOTLOADED); } if (!empty($_issueKey)) { $this->Load->Library('JIRA:JIRABridge', false, false, 'jira'); $this->Language->LoadApp('jira', 'jira'); if ($_JIRABridge) { $_JIRAIssue = $_JIRABridge->GetIssueBy('issuekey', $_issueKey); if ($_JIRAIssue && $_JIRAIssue instanceof SWIFT_JIRAIssueManager && $_JIRAIssue->GetIsClassLoaded()) { $_unlinked = $_JIRABridge->UnlinkIssue($_issueKey, $_ticketID); if ($_unlinked) { $_SWIFT_TicketObject = SWIFT_Ticket::GetObjectOnID((int) $_ticketID); if ($_SWIFT_TicketObject && $_SWIFT_TicketObject instanceof SWIFT_Ticket && $_SWIFT_TicketObject->GetIsClassLoaded()) { SWIFT_TicketAuditLog::Create($_SWIFT_TicketObject, null, SWIFT_TicketAuditLog::CREATOR_STAFF, $_SWIFT->Staff->GetStaffID(), $_SWIFT->Staff->GetProperty('fullname'), SWIFT_TicketAuditLog::ACTION_UPDATESTATUS, $this->Language->Get('unlinkedFromJIRA') . ' - ' . $_JIRAIssue->GetKey(), SWIFT_TicketAuditLog::VALUE_STATUS); } $_response['code'] = 200; $_response['message'] = 'success'; } else { $_response['code'] = 500; $_response['message'] = $_JIRABridge->GetErrorMessage(); } } else { $_response['code'] = 500; $_response['message'] = 'noissuekey'; } } else { $_response['code'] = 500; $_response['message'] = $this->Language->Get('jira_error'); } } else { $_response['code'] = 500; $_response['message'] = 'noissuekey'; } echo json_encode($_response); return true; }
/** * Handle todo export form submit * * @author Atul Atri * @return bool "true" on Success, "false" otherwise * @throws SWIFT_Exception */ public function TodoExportFormSubmit() { $_pId = $_POST['todoproject']; $_todolistId = $_POST['todolist']; $_assigneeId = $_POST['assignee']; $_todo = trim($_POST['todoitem']); $_comment = trim($_POST['todocomment']); $_ticketId = $_POST['todo_ticketid']; $_date = trim($_POST['duedate']); $_fileNames = array(); //if this ticket id is already linked throw exception $_todoId = SWIFT_TodoTicketLink::getTodoInfo($_ticketId); if ($_todoId !== false) { throw new SWIFT_Exception("TIcket id {$_ticketId} is already linked to basecamp todo."); } if (isset($_POST['todo_files'])) { $_fileNames = $_POST['todo_files']; } if ($this->CheckTodoExportForm()) { $this->Load->Library('API:APITodos', false, false); $this->Load->Library('API:APIComments', false, false); $_TodoService = new SWIFT_APITodos(); try { if (!empty($_date)) { $_date = date("c", strtotime($_date)); } $_reponse = $_TodoService->PostTodo($_pId, $_todolistId, $_todo, $_assigneeId, $_date); $_reponseArr = json_decode($_reponse, true); $_newTodoId = $_reponseArr['id']; $this->PostTodoComment($_ticketId, $_pId, $_newTodoId, $_comment, $_fileNames); $this->Load->LoadModel('AuditLog:TicketAuditLog'); $_SWIFT_TicketObject = SWIFT_Ticket::GetObjectOnID($_ticketId); SWIFT_TicketAuditLog::AddToLog($_SWIFT_TicketObject, null, SWIFT_TicketAuditLog::ACTION_UPDATESTATUS, $this->Language->Get('basecamp_audit_todo_posted'), SWIFT_TicketAuditLog::VALUE_NONE, 0, '', 0, ''); //all well make link in table SWIFT_TodoTicketLink::insertTodo($_ticketId, $_newTodoId, $_pId); //return success message $this->View->TodoPostSuccess($_ticketId, $_pId, $_newTodoId); return true; } catch (Exception $_e) { $_error = $_e->getMessage(); $_SWIFT = SWIFT::GetInstance(); SWIFT::Error($_SWIFT->Language->Get('error'), $_error); } } $this->Load->TodoExportForm($_ticketId, $_pId); return true; }