Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Testing Pull Requests #2

Merged
merged 3 commits into from
Sep 8, 2013
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
33 changes: 33 additions & 0 deletions app/code/community/Firegento/AdminLogger/Model/Clean.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
<?php
class Firegento_AdminLogger_Model_Clean {

const XML_PATH_ADMINLOGGER_INTERVAL = 'admin/firegento_adminlogger/interval';
const XML_PATH_ADMINLOGGER_CLEAN_ENABLED = 'admin/firegento_adminlogger/enable_cleaning';

/**
* Cleaning database-table
*
* @return Firegento_AdminLogger_Model_Clean
*/
public function clean () {
if (!Mage::getStoreConfigFlag(self::XML_PATH_ADMINLOGGER_INTERVAL)) {
return $this;
}

if (Mage::getStoreConfig(self::XML_PATH_ADMINLOGGER_CLEAN_ENABLED)) {

$interval = Mage::getStoreConfig(self::XML_PATH_ADMINLOGGER_INTERVAL);

/** @var $adminLoggerCollection Firegento_AdminLogger_Model_Resource_History_Collection */
$adminLoggerCollection = Mage::getModel('firegento_adminlogger/history')
->getCollection()
->addFieldToFilter('created_at', array(
'lt' => new Zend_Db_Expr("DATE_SUB('" . now() . "', INTERVAL $interval DAY)")));

foreach ($adminLoggerCollection as $history) {
$history->delete();
}
}
return $this;
}
}
20 changes: 20 additions & 0 deletions app/code/community/Firegento/AdminLogger/Model/Observer.php
Original file line number Diff line number Diff line change
@@ -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);
}
}
}
2 changes: 1 addition & 1 deletion app/code/community/Firegento/AdminLogger/etc/adminhtml.xml
Original file line number Diff line number Diff line change
@@ -3,7 +3,7 @@
<menu>
<system>
<children>
<history module="firegento_adminlogger">
<history module="firegento_adminlogger" translate="title">
<title>Admin Logger</title>
<sort_order>10</sort_order>
<action>adminhtml/history</action>
22 changes: 22 additions & 0 deletions app/code/community/Firegento/AdminLogger/etc/config.xml
Original file line number Diff line number Diff line change
@@ -111,6 +111,15 @@
</firegento_adminlogger_log>

</events>
<translate>
<modules>
<Firegento_AdminLogger>
<files>
<default>Firegento_AdminLogger.csv</default>
</files>
</Firegento_AdminLogger>
</modules>
</translate>
</adminhtml>
<admin>
<routers>
@@ -124,6 +133,19 @@
</routers>
</admin>

<crontab>
<jobs>
<neoshops_adminlogger>
<schedule>
<cron_expr>0 3 * * *</cron_expr>
</schedule>
<run>
<model>firegento_adminlogger/observer::scheduledCleanAdminLogger</model>
</run>
</neoshops_adminlogger>
</jobs>
</crontab>

<phpunit>
<suite>
<modules>
37 changes: 37 additions & 0 deletions app/code/community/Firegento/AdminLogger/etc/system.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
<?xml version="1.0"?>
<config>
<sections>
<admin>
<groups>
<firegento_adminlogger translate="label">
<label>Admin Logger</label>
<frontend_type>text</frontend_type>
<sort_order>200</sort_order>
<show_in_default>1</show_in_default>
<show_in_website>1</show_in_website>
<show_in_store>0</show_in_store>
<fields>
<enable_cleaning translate="label">
<label>Enable Log Cleaning</label>
<frontend_type>select</frontend_type>
<source_model>adminhtml/system_config_source_yesno</source_model>
<sort_order>10</sort_order>
<show_in_default>1</show_in_default>
<show_in_website>0</show_in_website>
<show_in_store>0</show_in_store>
</enable_cleaning>
<interval translate="label">
<label>Save Log, Days</label>
<frontend_type>text</frontend_type>
<sort_order>20</sort_order>
<show_in_default>1</show_in_default>
<show_in_website>0</show_in_website>
<show_in_store>0</show_in_store>
<validate>validate-number</validate>
</interval>
</fields>
</firegento_adminlogger>
</groups>
</admin>
</sections>
</config>
5 changes: 5 additions & 0 deletions app/locale/de_DE/Firegento_AdminLogger.csv
Original file line number Diff line number Diff line change
@@ -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"
3 changes: 2 additions & 1 deletion modman
Original file line number Diff line number Diff line change
@@ -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
/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