Skip to content

Commit

Permalink
security fix
Browse files Browse the repository at this point in the history
  • Loading branch information
Nikhil committed Jul 13, 2017
2 parents f953054 + 8b0bd2d commit 4770048
Show file tree
Hide file tree
Showing 4 changed files with 170 additions and 170 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -17,19 +17,19 @@

class TicketThread extends \Magento\Backend\App\Action
{
/** @var \Magento\Framework\View\Result\PageFactory */
/** @var \Magento\Framework\View\Result\PageFactory */
protected $_resultPageFactory;

/**
* @param \Magento\Backend\App\Action\Context $context
* @param \Magento\Framework\View\Result\PageFactory $resultPageFactory
* @param \Webkul\UvDeskConnector\Model\TicketManager $ticketManager
*/
*/
public function __construct(
\Magento\Backend\App\Action\Context $context,
\Magento\Framework\View\Result\PageFactory $resultPageFactory,
\Webkul\UvDeskConnector\Model\TicketManager $ticketManager
)
)
{
parent::__construct($context);
$this->_resultPageFactory = $resultPageFactory;
Expand All @@ -45,7 +45,7 @@ public function execute()
$ticketId = isset($post['ticket_id'])?$post['ticket_id']:null;
$tickeIncrementId = isset($post['incremet_id'])?$post['incremet_id']:null;
$reply = isset($post['product']['description'])?$post['product']['description']:null;
// $actAsType = 'customer';
// $actAsType = 'customer';
if (isset($post['addReply']) && $post['addReply'] == 1) {
$lineEnd = "\r\n";
$mime_boundary = md5(time());
Expand Down Expand Up @@ -87,4 +87,4 @@ protected function _isAllowed()
{
return $this->_authorization->isAllowed('Webkul_UvDeskConnector::tickets');
}
}
}
78 changes: 39 additions & 39 deletions src/app/code/Webkul/UvDeskConnector/Model/TicketManager.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
namespace Webkul\UvDeskConnector\Model;

class TicketManager
{
{
public function __construct(
\Webkul\UvDeskConnector\Helper\Data $helperData,
\Magento\Framework\Message\ManagerInterface $messageManager,
Expand All @@ -33,7 +33,7 @@ public function getAllTickets($label)
{
$access_token = $this->_helperData->getAccessToken();
$company_domain = $this->_helperData->getCompanyDomainName();
// Return tickets
// Return tickets
$url = 'https://'.$company_domain.'.uvdesk.com/en/api/tickets.json?'.$label;
$ch = curl_init($url);
$headers = array(
Expand All @@ -55,7 +55,7 @@ public function getAllTickets($label)
} elseif ($info['http_code'] == 500 || $info['http_code'] == 0) {
$this->_messageManager->addError(__('Invalid credentials !'));
return ['error'=>'true'];
}
}
curl_close($ch);
}

Expand Down Expand Up @@ -102,7 +102,7 @@ public function getAllTicketss($page=null,$labels=null,$tab=null,$agent=null,$cu
if (isset($labels)) {
$str=$labels.$str;
}
// Return tickets
// Return tickets
$url = 'https://'.$company_domain.'.uvdesk.com/en/api/tickets.json?'.$str;
$ch = curl_init($url);
$headers = array(
Expand All @@ -120,7 +120,7 @@ public function getAllTicketss($page=null,$labels=null,$tab=null,$agent=null,$cu
return json_decode($response);
} else {
return false;
}
}
curl_close($ch);
}

Expand All @@ -133,7 +133,7 @@ public function getFilterDataFor($filterType)
{
$access_token = $this->_helperData->getAccessToken();
$company_domain = $this->_helperData->getCompanyDomainName();
// Return tickets
// Return tickets
$url = 'https://'.$company_domain.'.uvdesk.com/en/api/filters.json?'.$filterType.'=1';
$ch = curl_init($url);
$headers = array(
Expand All @@ -152,7 +152,7 @@ public function getFilterDataFor($filterType)
return json_decode($response);
} else {
return false;
}
}
curl_close($ch);
}

Expand All @@ -161,11 +161,11 @@ public function getFilterDataFor($filterType)
*
* @return String.
*/
public function createTicket($ticketData)
public function createTicket($ticketData)
{
$access_token = $this->_helperData->getAccessToken();
$company_domain = $this->_helperData->getCompanyDomainName();
// ticket url
// ticket url
$url = 'https://'.$company_domain.'.uvdesk.com/en/api/tickets.json';
$data = json_encode($ticketData);
$ch = curl_init($url);
Expand Down Expand Up @@ -193,7 +193,7 @@ public function createTicket($ticketData)
$customerUvDeskId = $customerUvDeskData['customers'][0]['id'];
$this->_customerSession->setCustomerUvdeskId($customerUvDeskId);
}
}
}
return true;
} elseif ($info['http_code'] == 400) {
$this->_messageManager->addError(__(' Error, request data not valid. (http-code: 400).'));
Expand All @@ -214,7 +214,7 @@ public function getCustomerFromEmail($customerEmail = null)
{
$access_token = $this->_helperData->getAccessToken();
$company_domain = $this->_helperData->getCompanyDomainName();
// ticket url
// ticket url
$url = 'https://'.$company_domain.'.uvdesk.com/en/api/customers.json?email='.$customerEmail;
$ch = curl_init($url);
$headers = [
Expand All @@ -233,7 +233,7 @@ public function getCustomerFromEmail($customerEmail = null)
} elseif ($info['http_code'] == 400) {
return "";
}
curl_close($ch);
curl_close($ch);
}

/**
Expand All @@ -245,7 +245,7 @@ public function createCustomer()
{
$access_token = $this->_helperData->getAccessToken();
$company_domain = $this->_helperData->getCompanyDomainName();
// ticket url
// ticket url
$url = 'https://'.$company_domain.'.uvdesk.com/en/api/customer.json';
$data = json_encode($ticketData);
$ch = curl_init($url);
Expand Down Expand Up @@ -273,7 +273,7 @@ public function createCustomer()
} else {
$this->_messageManager->addError(__('Error, HTTP Status Code :%1', $info['http_code']));
}
curl_close($ch);
curl_close($ch);
}

/**
Expand All @@ -285,7 +285,7 @@ public function getTicketTypes()
{
$access_token = $this->_helperData->getAccessToken();
$company_domain = $this->_helperData->getCompanyDomainName();
// ticket url
// ticket url
$url = 'https://'.$company_domain.'.uvdesk.com/en/api/ticket-types.json?';
$ch = curl_init($url);
$headers = [
Expand All @@ -304,7 +304,7 @@ public function getTicketTypes()
} elseif ($info['http_code'] == 400) {
return "";
}
curl_close($ch);
curl_close($ch);
}

/**
Expand All @@ -316,7 +316,7 @@ public function getTicketThread($ticketId = 0, $pageNo)
{
$access_token = $this->_helperData->getAccessToken();
$company_domain = $this->_helperData->getCompanyDomainName();
// Return tickets
// Return tickets
$str = "";
if (isset($pageNo)) {
$str.='page='.$pageNo;
Expand All @@ -341,7 +341,7 @@ public function getTicketThread($ticketId = 0, $pageNo)
return json_decode($response,true);
} else {
return false;
}
}
curl_close($ch);
}

Expand All @@ -354,7 +354,7 @@ public function getSingleTicketData($ticketIncrementId){
$access_token = $this->_helperData->getAccessToken();
$company_domain = $this->_helperData->getCompanyDomainName();
$str = '';
// Return tickets
// Return tickets
$url = 'https://'.$company_domain.'.uvdesk.com/en/api/ticket/'.$ticketIncrementId.'.json';
$ch = curl_init($url);
$headers = array(
Expand All @@ -372,7 +372,7 @@ public function getSingleTicketData($ticketIncrementId){
return json_decode($response, true);
} else {
return false;
}
}
curl_close($ch);
}

Expand All @@ -385,7 +385,7 @@ public function addReplyToTickett($ticketId,$ticketIncrementId ,$data){

$access_token = $this->_helperData->getAccessToken();
$company_domain = $this->_helperData->getCompanyDomainName();
// ticket url
// ticket url
$url = 'https://'.$company_domain.'.uvdesk.com/en/api/ticket/'.$ticketId.'/threads.json';
$data = json_encode($data);
$ch = curl_init($url);
Expand Down Expand Up @@ -414,21 +414,21 @@ public function addReplyToTickett($ticketId,$ticketIncrementId ,$data){
return false;
} else {
$this->_messageManager->addError(__('Error, HTTP Status Code :%1', $info['http_code']));
return false;
return false;
}
curl_close($ch);
curl_close($ch);
}

/**
* Curl request to add a reply to a tickets in UvDesk.
*
* @return String.
*/
*/
public function addReplyToTicket($ticketId,$ticketIncrementId ,$data,$mime_boundary)
{
$access_token = $this->_helperData->getAccessToken();
$company_domain = $this->_helperData->getCompanyDomainName();
// ticket url
// ticket url
$url = 'https://'.$company_domain.'.uvdesk.com/en/api/ticket/'.$ticketId.'/threads.json';
$data = $data;
$headers = array(
Expand Down Expand Up @@ -463,7 +463,7 @@ public function addReplyToTicket($ticketId,$ticketIncrementId ,$data,$mime_bound
return false;
} else {
$this->_messageManager->addError(__('Error, HTTP Status Code :%1', $info['http_code']));
return false;
return false;
}
curl_close($ch);
}
Expand All @@ -472,12 +472,12 @@ public function addReplyToTicket($ticketId,$ticketIncrementId ,$data,$mime_bound
* Curl request to download the attachment of a ticket in UvDesk.
*
* @return Json.
*/
*/
public function downloadAttachment($attachmenId)
{
$access_token = $this->_helperData->getAccessToken();
$company_domain = $this->_helperData->getCompanyDomainName();
// Return tickets
// Return tickets
$url = 'https://'.$company_domain.'.uvdesk.com/en/api/ticket/attachment/'.$attachmenId.'.json';
$ch = curl_init($url);
$headers = array(
Expand All @@ -496,20 +496,20 @@ public function downloadAttachment($attachmenId)
return ['response'=>$response,'info'=>$info] ;
} else {
return false;
}
}
curl_close($ch);
}

/**
* Curl request to delete the tickets in UvDesk.
*
* @return String.
*/
*/
public function trashTicket()
{
$access_token = $this->_helperData->getAccessToken();
$company_domain = $this->_helperData->getCompanyDomainName();
// Return tickets
// Return tickets
$url = 'https://'.$company_domain.'.uvdesk.com/en/ /api/ticket/4802/trash.json';
$ch = curl_init($url);
$headers = array(
Expand All @@ -528,15 +528,15 @@ public function trashTicket()
return ['response'=>$response,'info'=>$info] ;
} else {
return false;
}
}
curl_close($ch);
}
}

/**
* Curl request to change the agent of a ticket in UvDesk.
*
* @return String.
*/
*/
public function assignAgentToTicket($ticketId,$agentId)
{
$access_token = $this->_helperData->getAccessToken();
Expand All @@ -561,15 +561,15 @@ public function assignAgentToTicket($ticketId,$agentId)
return ['response'=>$response,'info'=>$info] ;
} else {
return false;
}
}
curl_close($ch);
}

/**
* Curl request to delete the tickets in UvDesk.
*
* @return String.
*/
*/
public function deleteTicket($ticketIds)
{
$access_token = $this->_helperData->getAccessToken();
Expand All @@ -596,6 +596,6 @@ public function deleteTicket($ticketIds)
return ['response'=>true];
} else {
return ['response'=>false];
}
}
}
}
}
}
Loading

0 comments on commit 4770048

Please sign in to comment.