Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -31,11 +31,6 @@ public function getAuthHeader() {
return 'Token token="' . Mage::helper('zendesk')->getApiToken(false) . '"';
}

public function isConnected() {
$connection = Mage::helper('zendesk')->getConnectionStatus();
return $connection['success'];
}

public function getTotals() {
return Mage::helper("zendesk")->getTicketTotals();
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ public function __construct() {
protected function _prepareLayout() {
// Check if we are on the main admin dashboard and, if so, whether we should be showing the grid
// Note: an additional check in the template is needed, but this will prevent unnecessary API calls to Zendesk
if ( !$this->getIsZendeskDashboard() && !Mage::getStoreConfig('zendesk/backend_features/show_on_dashboard') )
if ( !Mage::helper('zendesk')->isConnected() || (!$this->getIsZendeskDashboard() && !Mage::getStoreConfig('zendesk/backend_features/show_on_dashboard')) )
{
return parent::_prepareLayout();
}
Expand Down
12 changes: 11 additions & 1 deletion src/app/code/community/Zendesk/Zendesk/Helper/Data.php
Original file line number Diff line number Diff line change
Expand Up @@ -391,7 +391,17 @@ public function getConnectionStatus() {
);
}
}


/**
* Checks if the current connection details are valid.
*
* @return boolean
*/
public function isConnected() {
$connection = $this->getConnectionStatus();
return $connection['success'];
}

public function storeDependenciesInCachedRegistry() {
$cache = Mage::app()->getCache();

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -252,11 +252,12 @@ public function createAction()

public function launchAction()
{
$domain = $this->_domainConfigured();
if (!$domain) {
if (!$this->_domainConfigured()) {
return;
}

$domain = Mage::getStoreConfig('zendesk/general/domain');

$sso = Mage::getStoreConfig('zendesk/sso/enabled');

if (!$sso) {
Expand Down Expand Up @@ -749,13 +750,12 @@ protected function getMassActionResponse($response, $ids, $message = '%d out of

private function _domainConfigured()
{
$domain = Mage::getStoreConfig('zendesk/general/domain');
if(!$domain) {
Mage::getSingleton('adminhtml/session')->addError(Mage::helper('zendesk')->__('Please set up Zendesk connection.'));
if (!Mage::helper('zendesk')->isConnected()) {
Mage::getSingleton('adminhtml/session')->addError(Mage::helper('zendesk')->__('Please set up a Zendesk connection.'));
$this->_redirect('adminhtml/dashboard');
return false;
} else {
return $domain;
return true;
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
* limitations under the License.
*/
?>
<?php if( $this->isConnected() ): ?>
<?php if( Mage::helper('zendesk')->isConnected() ): ?>
<?php if ($this->getIsZendeskDashboard() || Mage::getStoreConfig('zendesk/backend_features/show_on_dashboard')): ?>
<?php if ($this->getIsZendeskDashboard()): ?>
<div class="content-header">
Expand Down