*/ class Mage_Core_Model_Observer { /** * Check if synchronize process is finished and generate notification message * * @param Varien_Event_Observer $observer * @return Mage_Core_Model_Observer */ public function addSynchronizeNotification(Varien_Event_Observer $observer) { $adminSession = Mage::getSingleton('admin/session'); if (!$adminSession->hasSyncProcessStopWatch()) { $flag = Mage::getSingleton('core/file_storage')->getSyncFlag(); $state = $flag->getState(); if ($state == Mage_Core_Model_File_Storage_Flag::STATE_RUNNING) { $syncProcessStopWatch = true; } else { $syncProcessStopWatch = false; } $adminSession->setSyncProcessStopWatch($syncProcessStopWatch); } $adminSession->setSyncProcessStopWatch(false); if (!$adminSession->getSyncProcessStopWatch()) { if (!isset($flag)) { $flag = Mage::getSingleton('core/file_storage')->getSyncFlag(); } $state = $flag->getState(); if ($state == Mage_Core_Model_File_Storage_Flag::STATE_FINISHED) { $flagData = $flag->getFlagData(); if (isset($flagData['has_errors']) && $flagData['has_errors']) { $severity = Mage_AdminNotification_Model_Inbox::SEVERITY_MAJOR; $title = Mage::helper('adminhtml')->__('An error has occured while syncronizing media storages.'); $description = Mage::helper('adminhtml')->__('One or more media files failed to be synchronized during the media storages syncronization process. Refer to the log file for details.'); } else { $severity = Mage_AdminNotification_Model_Inbox::SEVERITY_NOTICE; $title = Mage::helper('adminhtml')->__('Media storages synchronization has completed!'); $description = Mage::helper('adminhtml')->__('Synchronization of media storages has been successfully completed.'); } $date = date('Y-m-d H:i:s'); Mage::getModel('adminnotification/inbox')->parse(array( array( 'severity' => $severity, 'date_added' => $date, 'title' => $title, 'description' => $description, 'url' => '', 'internal' => true ) )); $flag->setState(Mage_Core_Model_File_Storage_Flag::STATE_NOTIFIED)->save(); } $adminSession->setSyncProcessStopWatch(false); } return $this; } /** * Cron job method to clean old cache resources * * @param Mage_Cron_Model_Schedule $schedule */ public function cleanCache(Mage_Cron_Model_Schedule $schedule) { Mage::app()->getCache()->clean(Zend_Cache::CLEANING_MODE_OLD); Mage::dispatchEvent('core_clean_cache'); } }