From 9f505f0d9ad4c535d53493eae6de2c305a2e67c8 Mon Sep 17 00:00:00 2001 From: neoshops Date: Sun, 8 Sep 2013 12:16:43 +0200 Subject: [PATCH 1/2] Cronjob Clean Database --- .../Firegento/AdminLogger/Model/Clean.php | 33 +++++++++++++++++ .../Firegento/AdminLogger/Model/Observer.php | 20 ++++++++++ .../Firegento/AdminLogger/etc/adminhtml.xml | 2 +- .../Firegento/AdminLogger/etc/config.xml | 22 +++++++++++ .../Firegento/AdminLogger/etc/system.xml | 37 +++++++++++++++++++ app/locale/de_DE/Firegento_AdminLogger.csv | 5 +++ 6 files changed, 118 insertions(+), 1 deletion(-) create mode 100644 app/code/community/Firegento/AdminLogger/Model/Clean.php create mode 100644 app/code/community/Firegento/AdminLogger/etc/system.xml create mode 100644 app/locale/de_DE/Firegento_AdminLogger.csv 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 e213802..faafed2 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 @@ -190,4 +191,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 c746ed6..4e51299 100644 --- a/app/code/community/Firegento/AdminLogger/etc/config.xml +++ b/app/code/community/Firegento/AdminLogger/etc/config.xml @@ -94,6 +94,15 @@ + + + + + Firegento_AdminLogger.csv + + + + @@ -107,6 +116,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 From aab9babfb386409a5c6246c06d59312aa0519168 Mon Sep 17 00:00:00 2001 From: neoshops Date: Sun, 8 Sep 2013 12:34:20 +0200 Subject: [PATCH 2/2] update --- modman | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) 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