diff --git a/app/code/community/Firegento/AdminLogger/Model/Clean.php b/app/code/community/Firegento/AdminLogger/Model/Clean.php new file mode 100644 index 0000000..49d4b4f --- /dev/null +++ b/app/code/community/Firegento/AdminLogger/Model/Clean.php @@ -0,0 +1,33 @@ +getCollection() + ->addFieldToFilter('created_at', array( + 'lt' => new Zend_Db_Expr("DATE_SUB('" . now() . "', INTERVAL $interval DAY)"))); + + foreach ($adminLoggerCollection as $history) { + $history->delete(); + } + } + return $this; + } +} \ No newline at end of file diff --git a/app/code/community/Firegento/AdminLogger/Model/Observer.php b/app/code/community/Firegento/AdminLogger/Model/Observer.php index a2f1f29..3739eec 100644 --- a/app/code/community/Firegento/AdminLogger/Model/Observer.php +++ b/app/code/community/Firegento/AdminLogger/Model/Observer.php @@ -2,6 +2,7 @@ class Firegento_AdminLogger_Model_Observer { const ACTION_SAVE = 'save'; const ACTION_DELETE = 'delete'; + const XML_PATH_ADMINLOGGER_CLEAN_ENABLED = 'admin/firegento_adminlogger/enable_cleaning'; /** * @var Firegento_AdminLogger_Model_History_Diff @@ -207,4 +208,23 @@ function ($className) use($savedModel) { private function isUpdate (Mage_Core_Model_Abstract $savedModel) { return $this->getAction($savedModel) == Firegento_AdminLogger_Helper_Data::ACTION_UPDATE; } + + /** + * Cleaning Database Entries + * + * @param Mage_Cron_Model_Schedule $schedule + */ + public function scheduledCleanAdminLogger (Mage_Cron_Model_Schedule $schedule) { + + if (!Mage::getStoreConfigFlag(self::XML_PATH_ADMINLOGGER_CLEAN_ENABLED)) { + return $this; + } + + try { + Mage::getModel('firegento_adminlogger/clean')->clean(); + } + catch (Exception $e) { + Mage::logException($e); + } + } } \ No newline at end of file diff --git a/app/code/community/Firegento/AdminLogger/etc/adminhtml.xml b/app/code/community/Firegento/AdminLogger/etc/adminhtml.xml index 165e235..596dea6 100644 --- a/app/code/community/Firegento/AdminLogger/etc/adminhtml.xml +++ b/app/code/community/Firegento/AdminLogger/etc/adminhtml.xml @@ -3,7 +3,7 @@ - + Admin Logger 10 adminhtml/history diff --git a/app/code/community/Firegento/AdminLogger/etc/config.xml b/app/code/community/Firegento/AdminLogger/etc/config.xml index bfc432a..007c386 100644 --- a/app/code/community/Firegento/AdminLogger/etc/config.xml +++ b/app/code/community/Firegento/AdminLogger/etc/config.xml @@ -111,6 +111,15 @@ + + + + + Firegento_AdminLogger.csv + + + + @@ -124,6 +133,19 @@ + + + + + 0 3 * * * + + + firegento_adminlogger/observer::scheduledCleanAdminLogger + + + + + diff --git a/app/code/community/Firegento/AdminLogger/etc/system.xml b/app/code/community/Firegento/AdminLogger/etc/system.xml new file mode 100644 index 0000000..a53dac8 --- /dev/null +++ b/app/code/community/Firegento/AdminLogger/etc/system.xml @@ -0,0 +1,37 @@ + + + + + + + + text + 200 + 1 + 1 + 0 + + + + select + adminhtml/system_config_source_yesno + 10 + 1 + 0 + 0 + + + + text + 20 + 1 + 0 + 0 + validate-number + + + + + + + \ No newline at end of file diff --git a/app/locale/de_DE/Firegento_AdminLogger.csv b/app/locale/de_DE/Firegento_AdminLogger.csv new file mode 100644 index 0000000..470af57 --- /dev/null +++ b/app/locale/de_DE/Firegento_AdminLogger.csv @@ -0,0 +1,5 @@ +"Enable Log Cleaning","Log-Bereinigung aktivieren" +"Save Log, Days","Log speichern, Tage" +"Frequency","Häufigkeit" +"Log-Cleaning","Log Bereinigung" +"Admin Logger","Admin Benutzer-Aktionen" \ No newline at end of file diff --git a/modman b/modman index c1e1508..0ea5763 100644 --- a/modman +++ b/modman @@ -1,3 +1,4 @@ /app/code/community/Firegento/AdminLogger /app/code/community/Firegento/AdminLogger /app/etc/modules/Firegento_AdminLogger.xml /app/etc/modules/Firegento_AdminLogger.xml -/app/design/adminhtml/default/default/layout/firegento_adminlogger.xml /app/design/adminhtml/default/default/layout/firegento_adminlogger.xml \ No newline at end of file +/app/design/adminhtml/default/default/layout/firegento_adminlogger.xml /app/design/adminhtml/default/default/layout/firegento_adminlogger.xml +/app/locale/de_DE/Firegento_AdminLogger.csv /app/locale/de_DE/Firegento_AdminLogger.csv \ No newline at end of file