2020import org .apache .logging .log4j .Logger ;
2121import org .jetbrains .annotations .NotNull ;
2222import org .jetbrains .annotations .Nullable ;
23+ import org .labkey .api .audit .AuditLogService ;
24+ import org .labkey .api .audit .provider .SiteSettingsAuditProvider ;
25+ import org .labkey .api .data .Container ;
2326import org .labkey .api .data .PropertyManager ;
2427import org .labkey .api .data .PropertyManager .WritablePropertyMap ;
2528import org .labkey .api .module .ModuleLoader ;
29+ import org .labkey .api .security .User ;
30+ import org .labkey .api .settings .AbstractWriteableSettingsGroup ;
2631import org .labkey .api .settings .AdminConsole ;
2732import org .labkey .api .settings .StartupProperty ;
2833import org .labkey .api .util .logging .LogHelper ;
@@ -158,9 +163,16 @@ public static boolean isTimerDisabled()
158163 return _timerDisabled ;
159164 }
160165
161- public static void setTimeDisabled (boolean disable )
166+ public static void setTimeDisabled (Container container , User user , boolean disable )
162167 {
163168 _timerDisabled = disable ;
169+
170+ StringBuilder html = new StringBuilder ("<table>" );
171+ SiteSettingsAuditProvider .SiteSettingsAuditEvent event = new SiteSettingsAuditProvider .SiteSettingsAuditEvent (container , "The system maintenance setting was changed (see details)." );
172+ AbstractWriteableSettingsGroup .appendDiffRow (html , "Timer Enabled" , null , Boolean .toString (!disable ));
173+ html .append ("</table>" );
174+ event .setChanges (html .toString ());
175+ AuditLogService .get ().addEvent (user , event );
164176 }
165177
166178 private final static String SET_NAME = "SystemMaintenance" ;
@@ -176,7 +188,7 @@ public static SystemMaintenanceProperties getProperties()
176188 }
177189
178190 // For all tasks that can be disabled, set the enabledTasks to enabled and set the rest to disabled
179- public static void setProperties (Set <String > enabledTasks , String time )
191+ public static void setProperties (Container container , User user , Set <String > enabledTasks , String time )
180192 {
181193 WritablePropertyMap writableProps = PropertyManager .getWritableProperties (SET_NAME , true );
182194
@@ -192,6 +204,18 @@ public static void setProperties(Set<String> enabledTasks, String time)
192204
193205 writableProps .save ();
194206 setTimer ();
207+
208+ StringBuilder html = new StringBuilder ("<table>" );
209+ SiteSettingsAuditProvider .SiteSettingsAuditEvent event = new SiteSettingsAuditProvider .SiteSettingsAuditEvent (container ,
210+ "The system maintenance tasks were changed (see details)." );
211+ AbstractWriteableSettingsGroup .appendDiffRow (html , TIME_PROPERTY_NAME , null , time );
212+ for (String task : enabled )
213+ AbstractWriteableSettingsGroup .appendDiffRow (html , task , null , "ENABLED" );
214+ for (String task : disabled )
215+ AbstractWriteableSettingsGroup .appendDiffRow (html , task , null , "DISABLED" );
216+ html .append ("</table>" );
217+ event .setChanges (html .toString ());
218+ AuditLogService .get ().addEvent (user , event );
195219 }
196220
197221 // Enable all tasksToEnable, disable all tasksToDisable, and don't modify the enabled property for all other tasks
0 commit comments