/** * Render the Verify Connection Dialog * * @author Ashish Kataria * @param $_msg The message to display * @param $_displayError To show error or not * @return bool "true" on Success, "false" otherwise */ public function RenderConnectionButton($_msg, $_displayError = 0) { $_SWIFT = SWIFT::GetInstance(); if (!$this->GetIsClassLoaded()) { return false; } // Calculate the URL $this->UserInterface->Start(get_class($this) . 'verifycon', '/Base/Settings/View', SWIFT_UserInterface::MODE_EDIT, true); $this->UserInterface->SetDialogOptions(false); if ($_displayError) { $this->UserInterface->Toolbar->AddButton('Ok', 'icon_jqmcompleted.png', 'javascript: UIDestroyAllDialogs(); SWIFT.Freshbooks.AdminObject.ConnectionButtonOk();', '4', '', ''); $_statusImage = 'icon_check.gif'; $_customClass = ''; } else { $this->UserInterface->Toolbar->AddButton('Ok', 'icon_jqmcompleted.png', 'javascript: UIDestroyAllDialogs();', '4', '', ''); $_statusImage = 'icon_block.gif'; $_customClass = 'errorrow'; } $this->UserInterface->Toolbar->AddButton($this->Language->Get('help'), 'icon_help.gif', SWIFT_Help::RetrieveHelpLink('parseremailqueue'), SWIFT_UserInterfaceToolbar::LINK_NEWWINDOW); /* * ############################################### * BEGIN GENERAL TAB * ############################################### */ $_GeneralTabObject = $this->UserInterface->AddTab($this->Language->Get('tabgeneral'), 'icon_form.gif', 'general', true); $_columnContainer[0]['value'] = $_msg; $_columnContainer[0]['align'] = 'left'; $_columnContainer[1]['value'] = '<img src="' . SWIFT::Get('themepath') . 'images/' . $_statusImage . '" align="absmiddle" border="0" />'; $_columnContainer[1]['align'] = 'center'; $_columnContainer[1]['width'] = '16'; $_GeneralTabObject->Row($_columnContainer, $_customClass); /* * ############################################### * END GENERAL TAB * ############################################### */ $this->UserInterface->End(); return false; }
/** * Renders the 'Add Comment to JIRA' form * * @param string $_issueKey The JIRA issue key * * @return boolean 'TRUE' on success and 'FALSE' otherwise * @throws SWIFT_Exception if class is not loaded or $_issueKey is empty */ public function RenderCommentForm($_issueKey) { if (!$this->GetIsClassLoaded()) { throw new SWIFT_Exception(__CLASS__ . ' ' . SWIFT_CLASSNOTLOADED); } if (empty($_issueKey)) { throw new SWIFT_Exception('Issue Key' . $this->Language->Get('jira_noempty')); } $_buttonText = '<input type="button" name="submitbutton" id="%formid%_submit" class="rebuttonblue" onclick="javascript: $(\'#%formid%\').submit();PreventDoubleClicking(this);" value="' . $this->Language->Get('jira_post') . '"/> <input type="button" name="submitbutton" id="%formid%_cancel" class="rebuttonred" onclick="javascript: $(\'.ui-icon-closethick\').click();" value="' . $this->Language->Get('jira_cancel') . '" onfocus="blur();" />'; $this->UserInterface->OverrideButtonText($_buttonText); $_GeneralTabObject = $this->UserInterface->AddTab($this->Language->Get('tabgeneral'), SWIFT::Get('swiftpath') . '__modules/jira/resources/postbugtojira_b.gif', 'general', true, false); $this->Load->Library('JIRA:JIRABridge', false, false, 'jira'); $_JIRABridge = SWIFT_JIRABridge::GetInstance(); if (!$_JIRABridge || !$_JIRABridge instanceof SWIFT_JIRABridge || !$_JIRABridge->GetIsClassLoaded()) { SWIFT::Notify(SWIFT::NOTIFICATION_ERROR, $this->Language->Get('jira_error')); return false; } $_JIRAIssue = $_JIRABridge->GetIssueBy('issuekey', $_issueKey); if ($_JIRAIssue && $_JIRAIssue instanceof SWIFT_JIRAIssueManager && $_JIRAIssue->GetIsClassLoaded()) { $this->Load->Library('Ticket:Ticket', false, false, APP_TICKETS); $_project = $_JIRAIssue->GetProject(); $_RolesContainer = $_JIRABridge->GetProjectRoles($_project); $_RolesOptionContainer = array(); if ($_RolesContainer && _is_array($_RolesContainer)) { foreach ($_RolesContainer as $_Role => $_RoleURL) { $_RolesOptionContainer[] = array('title' => $_Role, 'value' => $_Role); } } $_SWIFT_TicketObject = SWIFT_Ticket::GetObjectOnID($_JIRAIssue->GetKayakoTicketID()); $_GeneralTabObject->Title('<label for="comment">' . $this->Language->Get('jira_comment') . '</label><br/><span class="tabledescription">' . $this->Language->Get('jira_sensitive') . '</span>'); $_GeneralTabObject->TextArea('comment', '', '', '', 50, 6); $_GeneralTabObject->Select('visibility', $this->Language->Get('jira_comment_visibility'), '', $_RolesOptionContainer); $_GeneralTabObject->Hidden('issueKey', $_issueKey); $this->UserInterface->Hidden('jira_ticketid', $_SWIFT_TicketObject->GetTicketID()); $this->UserInterface->Hidden('jira_listtype', 'inbox'); $this->UserInterface->Hidden('jira_departmentid', $_SWIFT_TicketObject->GetProperty('departmentid')); $this->UserInterface->Hidden('jira_ticketstatusid', $_SWIFT_TicketObject->GetProperty('ticketstatusid')); $this->UserInterface->Hidden('jira_tickettypeid', $_SWIFT_TicketObject->GetProperty('tickettypeid')); } else { SWIFT::Notify(SWIFT::NOTIFICATION_ERROR, $this->Language->Get('jira_noissuefound') . $_issueKey); } return true; }
/** * Renders the Issue History Tab * * @param mixed $_issuesContainer array of issues associated with current ticket * * @author Abhinav Kumar * @return boolean 'true' on success and 'false' otherwise * @throws SWIFT_Exception if class is not loaded */ public function RenderHistoryTab($_issuesContainer) { $_SWIFT = SWIFT::GetInstance(); $_JIRABridge = SWIFT_JIRABridge::GetInstance(); if (!$this->GetIsClassLoaded()) { throw new SWIFT_Exception(__CLASS__ . ' ' . SWIFT_CLASSNOTLOADED); } else { if (!is_array($_issuesContainer)) { throw new SWIFT_Exception(SWIFT_INVALIDDATA); } } $this->UserInterface->Start(get_class($this), '', SWIFT_UserInterface::MODE_INSERT, false); $_IssueHistoryTabObject = new SWIFT_UserInterfaceTab($this->UserInterface, 'history', '', 1, 'history', false, false, 4, ''); $_columnContainer = array(); // Issue ID $_columnContainer[0]['value'] = $this->Language->Get('jira_issueid'); $_columnContainer[0]['align'] = 'left'; $_columnContainer[0]['width'] = '10'; // Summary $_columnContainer[1]['value'] = $this->Language->Get('jira_summary'); $_columnContainer[1]['align'] = 'left'; $_columnContainer[1]['width'] = '100'; // Updated $_columnContainer[3]['value'] = $this->Language->Get('jira_updated'); $_columnContainer[3]['align'] = 'left'; $_columnContainer[3]['width'] = '10'; // Priority $_columnContainer[4]['value'] = $this->Language->Get('jira_priority'); $_columnContainer[4]['align'] = 'left'; $_columnContainer[4]['width'] = '10'; // Status $_columnContainer[5]['value'] = $this->Language->Get('jira_status'); $_columnContainer[5]['align'] = 'left'; $_columnContainer[5]['width'] = '10'; // Assigned To $_columnContainer[6]['value'] = $this->Language->Get('jira_assignedto'); $_columnContainer[6]['align'] = 'left'; $_columnContainer[6]['width'] = '10'; // Action $_columnContainer[7]['value'] = $this->Language->Get('jira_action'); $_columnContainer[7]['align'] = 'left'; $_columnContainer[7]['width'] = '10'; $_IssueHistoryTabObject->Row($_columnContainer, 'gridtabletitlerow'); if (empty($_issuesContainer)) { $_columnContainer = array(); $_columnContainer[0]['value'] = $this->Language->Get('jira_noissuefound'); $_columnContainer[0]['align'] = 'left'; $_columnContainer[0]['width'] = '100%'; $_IssueHistoryTabObject->Row($_columnContainer); $_renderHTML = $_IssueHistoryTabObject->GetDisplayHTML(true); $_renderHTML .= '<script language="Javascript" type="text/javascript">'; $_renderHTML .= 'ClearFunctionQueue();'; $_renderHTML .= '</script>'; echo $_renderHTML; return true; } foreach ($_issuesContainer as $_Issue) { $_columnContainer = array(); $_issueURL = $_SWIFT->Settings->Get('bj_jiraurl') . 'browse/' . $_Issue->GetKey(); // Key $_columnContainer[0]['value'] = '<a href="' . $_issueURL . '" target="_blank">' . htmlspecialchars($_Issue->GetKey()) . '</a>'; $_columnContainer[0]['align'] = 'left'; $_columnContainer[0]['width'] = '10'; // Summary $_columnContainer[1]['value'] = '<a href="' . $_issueURL . '" target="_blank">' . IIF(strlen($_Issue->GetSummary()) > 100, htmlspecialchars(substr($_Issue->GetSummary(), 0, 100)) . '...', htmlspecialchars($_Issue->GetSummary())) . '</a>'; $_columnContainer[1]['align'] = 'left'; $_columnContainer[1]['width'] = '100'; // Updated $_columnContainer[3]['value'] = htmlspecialchars(SWIFT_Date::EasyDate($_Issue->GetUpdated()) . IIF(SWIFT_Date::EasyDate($_Issue->GetUpdated()) == $this->Language->Get('edjustnow'), '', ' ago')); $_columnContainer[3]['align'] = 'left'; $_columnContainer[3]['width'] = '10'; // Priority $_columnContainer[4]['value'] = htmlspecialchars($_Issue->GetPriority()); $_columnContainer[4]['align'] = 'left'; $_columnContainer[4]['width'] = '10'; // Status $_columnContainer[5]['value'] = htmlspecialchars($_Issue->GetStatus()); $_columnContainer[5]['align'] = 'left'; $_columnContainer[5]['width'] = '10'; // Comments $_columnContainer[6]['value'] = htmlspecialchars($_Issue->GetAssignee()); $_columnContainer[6]['align'] = 'left'; $_columnContainer[6]['width'] = '10'; // Unlink $_columnContainer[7]['value'] = '<a title="' . $this->Language->Get('postJIRAComment') . '" href="#" onclick="postJIRAComment(\'' . $_Issue->GetKey() . '\')"> <img src="' . SWIFT::Get('swiftpath') . SWIFT_APPSDIRECTORY . '/jira/resources/icon-comment.gif' . '"/> </a>' . ' | ' . '<a title="' . $this->Language->Get('jira_unlinkissue') . '" href="#" onclick="unlinkJIRAIssue(\'' . $_Issue->GetKey() . '\')"> <img src="' . SWIFT::Get('swiftpath') . SWIFT_APPSDIRECTORY . '/jira/resources/edit_delete.png' . '"/> </a>'; $_columnContainer[7]['align'] = 'left'; $_columnContainer[7]['width'] = '10'; $_IssueHistoryTabObject->Row($_columnContainer, '', $_Issue->GetKey()); //Fetch the issue comments now if ($_JIRABridge) { $_commentsContainer = $_JIRABridge->FetchAllCommentsBy('issuekey', $_Issue->GetKey()); if (isset($_columnContainer) && _is_array($_commentsContainer)) { $_renderedNotes = array(); foreach ($_commentsContainer as $_JIRAComment) { $_renderedNotes[] = '<div class="notebackground"> <div class="notecontainer"> <div class="note">' . nl2br($_JIRAComment->GetRawBody(), true) . '</div> </div> <cite class="tip"> <strong> <img border="0" align="absmiddle" src="' . SWIFT::Get('themepath') . 'images/icon_user2.png"/> ' . $_JIRAComment->GetAuthor() . ' ' . htmlspecialchars(SWIFT_Date::EasyDate($_JIRAComment->GetUpdated())) . ' ago </strong><div style="float: right; padding-right: 4px;"></div> </cite> </div>'; } $_renderedNotes = implode('', $_renderedNotes); $_commentContainer[0]['value'] = '<div class="allnotes">' . $_renderedNotes . '</div>'; $_commentContainer[0]['width'] = '100'; $_commentContainer[0]['align'] = 'left'; $_commentContainer[0]['colspan'] = '7'; $_commentContainer[0]['style'] = 'background: none repeat scroll 0pt 0pt #F6F1E7; padding: 0px;'; $_IssueHistoryTabObject->Row($_commentContainer, '', $_Issue->GetKey()); } } } $_renderHTML = $_IssueHistoryTabObject->GetDisplayHTML(true); echo $_renderHTML; return true; }
/** * Set settings values * * @author Ashish Kataria */ public function SetSamlSsoSettings() { $_SWIFT = SWIFT::GetInstance(); $this->_samlSsoSettings = new OneLogin_Saml_Settings(); /** * When using Service Provider Initiated SSO, this URL asks the IdP to authenticate the user */ $this->_samlSsoSettings->idpSingleSignOnUrl = rtrim($_SWIFT->Settings->Get('sso_url'), '\\/'); /** * The certificate for the users account in the IdP */ $this->_samlSsoSettings->idpPublicCertificate = file_get_contents($_SWIFT->Settings->Get('sso_cer')); /** * The URL where to the SAML Response/SAML Assertion will be posted */ $this->_samlSsoSettings->spReturnUrl = SWIFT::Get('basepath') . '/Samlsso/Sso/Idp/Login'; /** * Name of this application */ $this->_samlSsoSettings->spIssuer = $_SWIFT->Settings->Get('sso_entityid'); /** * Tells the IdP to return the email address of the current user */ $this->_samlSsoSettings->requestedNameIdFormat = OneLogin_Saml_Settings::NAMEID_EMAIL_ADDRESS; }
/** * This handles logout requests * * @author Ashish Kataria * @return bool "true" */ public function Logout() { $_SWIFT = SWIFT::GetInstance(); $this->_samlSsoWrapperObject->SignOut($this->_authSource); // Update session $_SWIFT->Session->Update(0); // Unset cookies $this->Cookie->Delete('authSource'); // Redirect.. header("location: " . SWIFT::Get('basename')); return true; }
/** * This function will be used to fetch all remote links related to a JIRA issue w.r.t ticket id * * @author Amarjeet Kaur * * @param string $_issueKey * @param string $_ticketID * * @return bool * @throws SWIFT_Exception If the Class is not Loaded */ public function GetRemoteLinks($_issueKey, $_ticketID) { if (!$this->GetIsClassLoaded()) { throw new SWIFT_Exception(__CLASS__ . ': ' . SWIFT_CLASSNOTLOADED); } if (!empty($_issueKey) && !empty($_ticketID)) { $_apiURL = $this->_url . 'rest/api/latest/issue/' . $_issueKey . '/remotelink'; $_ticketURL = SWIFT::Get('basename') . '/Tickets/Ticket/View/' . $_ticketID; $_globalID = 'system=' . $_ticketURL; $this->Client->SetURI($_apiURL); $this->Client->SetParameterGet('globalId', $_globalID); $_Response = $this->Client->Request(SWIFT_HTTPBase::GET, $this->_connectionTimeout); if ($_Response->getResponseCode() == 404) { $_ResponseDecoded = json_decode($_Response->getBody()); return get_object_vars($_ResponseDecoded); } } return true; }
/** * View todo * * @author Atul Atri * * @param int $_ticketId TicketId */ public function ViewTodo($_ticketId) { $_todoInfo = SWIFT_TodoTicketLink::getTodoInfo($_ticketId); $_todoData = null; $_error = ""; if ($_todoInfo === false) { $_error = $this->Language->Get('basecamp_todo_not_linked'); } else { try { $_todoId = $_todoInfo['todoid']; $_projectId = $_todoInfo['projectid']; $_TodoSrv = new SWIFT_APITodos(); $_todoJson = $_TodoSrv->GetTodo($_projectId, $_todoId); $_todoData = json_decode($_todoJson, true); if (isset($_todoData['content'])) { $this->Template->Assign('_task', $_todoData['content']); $this->Template->Assign('_isCompleted', $_todoData['completed']); if (isset($_todoData['due_at'])) { $this->Template->Assign('_dueAt', $_todoData['due_at']); } if (isset($_todoData['assignee']) && isset($_todoData['assignee']['name'])) { $this->Template->Assign('_assignee', $_todoData['assignee']['name']); } if (isset($_todoData['comments'])) { $_commentsToSet = $_todoData; foreach ($_todoData['comments'] as $key => $_nextItem) { $_nextItemToSet = $_nextItem; $_comment = $_nextItem['content']; $_commentSanitized = preg_replace('/\\<br(\\s*)?\\/?\\>/i', "\n", $_comment); $_commentSanitized = strip_tags($_commentSanitized); $_commentSanitized = nl2br($_commentSanitized); $_nextItemToSet['content'] = $_commentSanitized; $_commentsToSet['comments'][$key] = $_nextItemToSet; } $this->Template->Assign('_comments', $_commentsToSet['comments']); } } else { $_error = $this->Language->Get('basecamp_todo_get_failure'); } } catch (Exception $_e) { $_error = $_e->getMessage(); } //print_r($_todoData); } $this->Template->Assign('_titleCompleted', $this->Language->Get('basecamp_title_completed')); $this->Template->Assign('_tipDueDate', $this->Language->Get('basecamp_tip_due_date')); $this->Template->Assign('_tipAssigned', $this->Language->Get('basecamp_tip_assigned')); $this->Template->Assign('_errorHeader', $this->Language->Get('error')); $this->Template->Assign('_swiftpath', SWIFT::Get('swiftpath')); $this->Template->Assign('_errorHeader', $this->Language->Get('error')); $this->Template->Assign('_error', $_error); $this->Template->Assign('_themePath', SWIFT::Get('themepath')); $this->View->RenderTplFile(); }
/** * Render manage form * * @author Atul Atri * * @return bool "true" on Success, "false" otherwise */ public function ManageForm() { //check if already autherised $_SWIFT = SWIFT::GetInstance(); $_authHeader = $_SWIFT->Settings->Get('bc_auth_token'); if ($_authHeader) { $this->Template->Assign('_alreadyAuthorised', true); } else { $this->Template->Assign('_alreadyAuthorised', false); } $this->Template->Assign('_settingsObj', $_SWIFT->Settings); $this->Template->Assign('_swiftpath', SWIFT::Get('swiftpath')); $this->Template->Assign('_Language', $this->Language); $this->Template->Assign('_UserInterface', $this->UserInterface); $_formTxt = ''; $_redirectUrl = SWIFT::Get('basename') . '/basecamp/Manager/CodeRedirect'; $this->Template->Assign('_redirectUrl', $_redirectUrl); //show only if user registered this application $_appName = $this->Settings->Get('bc_app_name'); $_appEmail = $this->Settings->Get('bc_email'); $_appId = $this->Settings->Get('bc_app_id'); $_appSecret = $this->Settings->Get('bc_app_secret'); if ($_appName || $_appEmail || $_appId || $_appSecret) { $_formTxt = $this->Language->Get('basecamp_update_app_txt'); $_formTxt = sprintf($_formTxt, '<b>' . $_redirectUrl . '</b>'); $_buttonTxt = 'basecamp_update_button'; } else { $_formTxt = $this->Language->Get('basecamp_new_app_txt'); $_bcCreatAppUrl = SWIFT_ConfigManager::Get('CREATE_APP_LNK'); $_clickHere = $this->Language->Get('basecamp_click_here_lnk'); $_bcCreateAppHref = "<b><a href='{$_bcCreatAppUrl}' target='_blank'>{$_clickHere}</a></b>"; $_formTxt = sprintf($_formTxt, $_bcCreateAppHref, '<b>' . $_redirectUrl . '</b>'); $_buttonTxt = 'basecamp_save_button'; } $_authLink = false; if ($_appName && $_appEmail && $_appId && $_appSecret) { $_authLink = SWIFT_APIOauth2::GetAuthReqURL(); } $this->Template->Assign('_authLink', $_authLink); $this->Template->Assign('_formTxt', $_formTxt); $this->Template->Assign('_buttonTxt', $_buttonTxt); $this->View->Assign('_buttonTxt', $_buttonTxt); $this->View->Assign('_appName', $_appName); $this->View->Assign('_appEmail', $_appEmail); $this->View->Assign('_appId', $_appId); $this->View->Assign('_appSecret', $_appSecret); $this->View->ManageForm(self::MENU_ID, self::NAV_ID); return true; }