Skip to content

Commit d118dd9

Browse files
committed
Merge pull request #59 from zendesk/jose/fix_dashboard_error
Jose/fix dashboard error
2 parents 82ba989 + 21d0ef2 commit d118dd9

File tree

3 files changed

+29
-24
lines changed

3 files changed

+29
-24
lines changed

src/app/code/community/Zendesk/Zendesk/Block/Adminhtml/Dashboard/Grids.php

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,8 @@ protected function _prepareLayout() {
3434
return parent::_prepareLayout();
3535
}
3636

37+
Mage::helper('zendesk')->storeDependenciesInCachedRegistry();
38+
3739
//check if module is setted up
3840
$configured = (bool) Mage::getStoreConfig('zendesk/general/domain');
3941
$viewsIds = Mage::getStoreConfig('zendesk/backend_features/show_views') ? Mage::helper('zendesk')->getChosenViews() : array();

src/app/code/community/Zendesk/Zendesk/Helper/Data.php

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -370,4 +370,27 @@ public function getConnectionStatus() {
370370
}
371371
}
372372

373+
public function storeDependenciesInCachedRegistry() {
374+
$cache = Mage::app()->getCache();
375+
376+
if (null == Mage::registry('zendesk_users')) {
377+
if( $cache->load('zendesk_users') === false) {
378+
$users = serialize( Mage::getModel('zendesk/api_users')->all() );
379+
$cache->save($users, 'zendesk_users', array('zendesk', 'zendesk_users'), 300);
380+
}
381+
382+
$users = unserialize( $cache->load('zendesk_users') );
383+
Mage::register('zendesk_users', $users);
384+
}
385+
386+
if (null == Mage::registry('zendesk_groups')) {
387+
if( $cache->load('zendesk_groups') === false) {
388+
$groups = serialize( Mage::getModel('zendesk/api_groups')->all() );
389+
$cache->save($groups, 'zendesk_groups', array('zendesk', 'zendesk_groups'), 1200);
390+
}
391+
392+
$groups = unserialize( $cache->load('zendesk_groups') );
393+
Mage::register('zendesk_groups', $groups);
394+
}
395+
}
373396
}

src/app/code/community/Zendesk/Zendesk/controllers/Adminhtml/ZendeskController.php

Lines changed: 4 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -35,8 +35,8 @@ public function indexAction()
3535
$this->_redirect('adminhtml/dashboard');
3636
return;
3737
}
38-
39-
$this->storeDependenciesInCachedRegistry();
38+
39+
Mage::helper('zendesk')->storeDependenciesInCachedRegistry();
4040

4141
$this->_title($this->__('Zendesk Dashboard'));
4242
$this->loadLayout();
@@ -629,7 +629,7 @@ public function ticketsAllAction() {
629629
$isAjax = Mage::app()->getRequest()->isAjax();
630630

631631
if ($isAjax) {
632-
$this->storeDependenciesInCachedRegistry();
632+
Mage::helper('zendesk')->storeDependenciesInCachedRegistry();
633633
$this->getResponse()->setBody($this->getLayout()->createBlock('zendesk/adminhtml_dashboard_tab_tickets_grid_all')->toHtml());
634634
}
635635
}
@@ -638,34 +638,14 @@ public function ticketsViewAction() {
638638
$isAjax = Mage::app()->getRequest()->isAjax();
639639

640640
if ($isAjax) {
641-
$this->storeDependenciesInCachedRegistry();
641+
Mage::helper('zendesk')->storeDependenciesInCachedRegistry();
642642
$viewId = (int) $this->getRequest()->getParam('viewid');
643643
Mage::register('zendesk_tickets_view', $viewId);
644644

645645
$this->getResponse()->setBody($this->getLayout()->createBlock('zendesk/adminhtml_dashboard_tab_tickets_grid_view')->toHtml());
646646
}
647647
}
648648

649-
protected function storeDependenciesInCachedRegistry() {
650-
$cache = Mage::app()->getCache();
651-
652-
if( $cache->load('zendesk_users') === false) {
653-
$users = serialize( Mage::getModel('zendesk/api_users')->all() );
654-
$cache->save($users, 'zendesk_users', array('zendesk', 'zendesk_users'), 300);
655-
}
656-
657-
if( $cache->load('zendesk_groups') === false) {
658-
$groups = serialize( Mage::getModel('zendesk/api_groups')->all() );
659-
$cache->save($groups, 'zendesk_groups', array('zendesk', 'zendesk_groups'), 1200);
660-
}
661-
662-
$users = unserialize( $cache->load('zendesk_users') );
663-
$groups = unserialize( $cache->load('zendesk_groups') );
664-
665-
Mage::register('zendesk_users', $users);
666-
Mage::register('zendesk_groups', $groups);
667-
}
668-
669649
protected function getMassActionResponse($response, $ids, $message = '%d out of %d ticket(s) were updated.')
670650
{
671651
if (isset($response['job_status']) && isset($response['job_status']['url'])) {

0 commit comments

Comments
 (0)