Skip to content

Commit

Permalink
Proposed fix for agnostack#85
Browse files Browse the repository at this point in the history
  • Loading branch information
dave-swift committed Mar 7, 2016
1 parent 752ca53 commit f4c4434
Show file tree
Hide file tree
Showing 6 changed files with 21 additions and 51 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,8 @@ public function __construct() {
}

public function getIsZendeskDashboard() {
return Mage::app()->getFrontController()->getRequest()->getControllerName() === 'zendesk';
$request = Mage::app()->getFrontController()->getRequest();
return $request && $request->getControllerName() === 'zendesk';
}

public function getAuthHeader() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -120,6 +120,7 @@ protected function _prepareLayout() {
}

public function getIsZendeskDashboard() {
return Mage::app()->getFrontController()->getRequest()->getControllerName() === 'zendesk';
$request = Mage::app()->getFrontController()->getRequest();
return $request && $request->getControllerName() === 'zendesk';
}
}
32 changes: 0 additions & 32 deletions src/app/code/community/Zendesk/Zendesk/Model/Observer.php
Original file line number Diff line number Diff line change
Expand Up @@ -18,38 +18,6 @@

class Zendesk_Zendesk_Model_Observer
{
public function setHook(Varien_Event_Observer $observer)
{
if (Mage::app()->getFrontController()->getAction()->getFullActionName() === 'adminhtml_dashboard_index')
{
$block = $observer->getBlock();
if ($block->getNameInLayout() === 'dashboard')
{
$block->getChild('totals')->setUseAsDashboardHook(true);
}
}
}

public function insertBlock(Varien_Event_Observer $observer)
{
if (Mage::app()->getFrontController()->getAction()->getFullActionName() === 'adminhtml_dashboard_index')
{
if ($observer->getBlock()->getUseAsDashboardHook())
{
$html = $observer->getTransport()->getHtml();
$zendeskDash = $observer->getBlock()->getLayout()
->createBlock('zendesk/adminhtml_dashboard')
->setName('zendesk_dashboard');
$zendeskGrid = $zendeskDash->getLayout()
->createBlock('zendesk/adminhtml_dashboard_grids')
->setName('zendesk_dashboard_grids');
$zendeskDash->setChild('zendesk_dashboard_grids', $zendeskGrid);
$html .= $zendeskDash->toHtml();
$observer->getTransport()->setHtml($html);
}
}
}

public function saveConfig(Varien_Event_Observer $observer)
{
// Defaults for "global" scope
Expand Down
16 changes: 0 additions & 16 deletions src/app/code/community/Zendesk/Zendesk/etc/config.xml
Original file line number Diff line number Diff line change
Expand Up @@ -149,22 +149,6 @@
</zendesk>
</observers>
</core_block_abstract_prepare_layout_before>
<core_block_abstract_prepare_layout_after>
<observers>
<zendesk>
<class>zendesk/observer</class>
<method>setHook</method>
</zendesk>
</observers>
</core_block_abstract_prepare_layout_after>
<core_block_abstract_to_html_after>
<observers>
<zendesk>
<class>zendesk/observer</class>
<method>insertBlock</method>
</zendesk>
</observers>
</core_block_abstract_to_html_after>
<admin_system_config_changed_section_zendesk>
<observers>
<zendesk>
Expand Down
8 changes: 8 additions & 0 deletions src/app/design/adminhtml/default/default/layout/zendesk.xml
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,14 @@
*/
-->
<layout>
<adminhtml_dashboard_index>
<reference name="content">
<block type="zendesk/adminhtml_dashboard" name="zendesk_dashboard">
<block type="zendesk/adminhtml_dashboard_grids" name="zendesk_dashboard_grids" />
</block>
</reference>
</adminhtml_dashboard_index>

<adminhtml_system_config_edit>
<reference name="head">
<action method="addCss">
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,16 @@
</tr>
</table>
</div>
<?php else: ?>
<script>
document.observe('dom:loaded', function(){
if($('dashboard_diagram_totals')) {
$('dashboard_diagram_totals').insert({ after:$('zendesk_dashboard_container') });
}
});
</script>
<?php endif; ?>
<div class="zendesk_dashboard_container">
<div class="zendesk_dashboard_container" id="zendesk_dashboard_container">
<?php echo $this->getChildHtml('zendesk_dashboard_grids') ?>
<div id="tickets_grid_tab_content"></div>
<?php if (!$this->getIsZendeskDashboard()): ?>
Expand Down

0 comments on commit f4c4434

Please sign in to comment.