Skip to content
Closed
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 @@ -32,8 +32,7 @@ public function getAuthHeader() {
}

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

public function getTotals() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,8 +29,9 @@ 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::getStoreConfig('zendesk/general/authenticated')
|| (!$this->getIsZendeskDashboard() && !Mage::getStoreConfig('zendesk/backend_features/show_on_dashboard'))
) {
return parent::_prepareLayout();
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,7 @@ public function all()
$page = 1;
$addresses = array();

while ($page) {
$response = $this->_call('recipient_addresses.json?page=' . $page);
while ($page && !empty($response = $this->_call('recipient_addresses.json?page=' . $page))) {
$addresses = array_merge($addresses, $response['recipient_addresses']);
$page = is_null($response['next_page']) ? 0 : $page + 1;
}
Expand Down
4 changes: 4 additions & 0 deletions src/app/code/community/Zendesk/Zendesk/Model/Observer.php
Original file line number Diff line number Diff line change
Expand Up @@ -114,6 +114,10 @@ public function saveConfig(Varien_Event_Observer $observer)
} elseif (empty($zDomain)) {
Mage::getModel('core/config')->saveConfig('zendesk/frontend_features/web_widget_code_snippet', '');
}

// Save the connection status, used to check if it's okay to load pages that calls the API
$connectionStatus = Mage::helper('zendesk')->getConnectionStatus();
Mage::getModel('core/config')->saveConfig('zendesk/general/authenticated', (int) $connectionStatus['success'], $scope, $scopeId);
}

public function addTicketButton(Varien_Event_Observer $event)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -691,8 +691,9 @@ protected function getMassActionResponse($response, $ids, $message = '%d out of

private function _domainConfigured()
{
$domain = Mage::getStoreConfig('zendesk/general/domain');
if(!$domain) {
$authenticated = Mage::getStoreConfig('zendesk/general/authenticated');
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This line causes an error. 👎


if(!$authenticated) {
Mage::getSingleton('adminhtml/session')->addError(Mage::helper('zendesk')->__('Please set up Zendesk connection.'));
$this->_redirect('adminhtml/dashboard');
return false;
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
<?php
/**
* Copyright 2015 Zendesk
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/

$connectionStatus = Mage::helper('zendesk')->getConnectionStatus();
$config = new Mage_Core_Model_Config();
$config->saveConfig('zendesk/general/authenticated', (int) $connectionStatus['success'], 'default', 0);
8 changes: 8 additions & 0 deletions src/app/code/community/Zendesk/Zendesk/etc/system.xml
Original file line number Diff line number Diff line change
Expand Up @@ -110,6 +110,14 @@
<show_in_store>1</show_in_store>
<comment><![CDATA[Only if customers synchronization is enabled ]]></comment>
</sync_now>
<authenticated>
<frontend_type>hidden</frontend_type>
<source_model>adminhtml/system_config_source_yesno</source_model>
<sort_order>1</sort_order>
<show_in_default>0</show_in_default>
<show_in_website>0</show_in_website>
<show_in_store>0</show_in_store>
</authenticated>
</fields>
</general>
<sso translate="label comment">
Expand Down