Source of file MonitoringController.php
Size: 4,660 Bytes - Last Modified: 2015-05-15T11:18:15+02:00
/www-data/git/Hackathon_MageMonitoring/src/app/code/community/FireGento/MageMonitoring/controllers/Adminhtml/MonitoringController.php
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158 | <?php /** * This file is part of a FireGento e.V. module. * * This FireGento e.V. module is free software; you can redistribute it and/or * modify it under the terms of the GNU General Public License version 3 as * published by the Free Software Foundation. * * This script is distributed in the hope that it will be useful, but WITHOUT * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS * FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. * * PHP version 5 * * @category FireGento * @package FireGento_MageMonitoring * @author FireGento Team <team@firegento.com> * @copyright 2015 FireGento Team (http://www.firegento.com) * @license http://opensource.org/licenses/gpl-3.0 GNU General Public License, version 3 (GPLv3) */ /** * Monitoring Controller * * @category FireGento * @package FireGento_MageMonitoring * @author FireGento Team <team@firegento.com> */ class FireGento_MageMonitoring_Adminhtml_MonitoringController extends Mage_Adminhtml_Controller_Action { /** * Index action */ public function indexAction() { $this->loadLayout(); $this->_setActiveMenu('system/monitoring'); $this->_addBreadcrumb( Mage::helper('magemonitoring')->__('Monitoring'), Mage::helper('magemonitoring')->__('Monitoring') ); $this->_title('Mage Monitoring'); $this->_addContent( $this->getLayout()->createBlock('magemonitoring/tab', 'magemonitoring_main') ); $this->renderLayout(); } /** * Config tabs action */ public function config_tabsAction() { $this->loadLayout(); $this->_setActiveMenu('system/monitoring'); $this->_addBreadcrumb( Mage::helper('magemonitoring')->__('Monitoring'), Mage::helper('magemonitoring')->__('Monitoring') ); $this->_title('Mage Monitoring - Tab Config'); $this->_addContent( $this->getLayout()->createBlock('magemonitoring/tab_config', 'magemonitoring_tab_config') ); $this->renderLayout(); } /** * Reset config action * * @return mixed */ public function resetConfigAction() { $transaction = Mage::getSingleton('core/resource')->getConnection('core_write'); try { $config = Mage::getStoreConfig('magemonitoring'); $transaction->beginTransaction(); $this->deleteConfigData($config); $transaction->commit(); Mage::getConfig()->reinit(); $this->_getSession()->addSuccess($this->__('Wiped all module configuration from database.')); } catch (Exception $e) { $transaction->rollback(); $this->_getSession()->addError($e->__toString()); } return $this->_redirect('*/*/index'); } /** * Deletes entries in $config from core_config_data. Recursive. Locked to entries below path 'magemonitoring/' * * @param array $config Configuration array * @param string $prefix Prefix */ protected function deleteConfigData($config, $prefix='') { foreach ($config as $key => $value) { if (is_array($value) && !empty($value)) { $this->deleteConfigData($value, $prefix.$key.'/'); } $c = Mage::getModel('core/config'); $c->deleteConfig( 'magemonitoring/'.$prefix.$key, 'default', 0 ); } } /** * Flush Cache action * * @return mixed */ public function flushAllCacheAction() { try { $caches = Mage::helper('magemonitoring')->getActiveWidgets( '*', null, false, 'FireGento_MageMonitoring_Model_Widget_CacheStat' ); foreach ($caches as $cache) { if ($cache instanceof FireGento_MageMonitoring_Model_Widget_CacheStat) { $cache->flushCache(); } } $this->_getSession()->addSuccess($this->__('All caches flushed with success')); } catch (Exception $e) { Mage::logException($e); $this->_getSession()->addError($e->__toString()); } return $this->_redirect('*/*/index'); } /** * Permission check * * @return mixed */ protected function _isAllowed() { return Mage::getSingleton('admin/session')->isAllowed('magemonitoring'); } } |