[Home]WikiPatches/EmbeddedLastMaintenDate

UseModWiki | WikiPatches | RecentChanges | Preferences

This patch lets to check date of last action=maintain. So there's no attempt less than twelve hours. (See Actions, AdminFeatures)

You can choose GetMinimumFooter for location (preferably in accordance with WikiPatches/CommonMinimumFooter as follow)


sub GetMinimumFooter {
  my ($html);
  + my ($fname, $status, $fileData);

  + $fname = "$DataDir/maintain";
  + ($status, $fileData) = &ReadFile($fname);

  if ($FooterNote ne '') {
    $html .= T($FooterNote);
  }
  + if ((-f $fname) && ((-M $fname) > 0.5)) {
  + $html .= T('(Maintenance done more than 12 hours.)');
  + }
  
  $html .= $q->end_html;
  return $html;
}
if you prefer date pretty exact from this last action (for instance visible only for admins), then in somewhere place of script, best after CalcTime?:

+ sub CalcTimeSince { # based on OddMuse
  + my $total = shift;
  
  + if ($total > 7200) {
    + return Ts('at least %s hours ago',int($total/3600));
  + } elsif ($total > 3600) {
    + return T('more than 1 hour ago');
  + } elsif ($total == 3600) {  
    + return T('1 hour ago');
  + } elsif ($total >= 120) {
    + return Ts('more than %s minutes ago',int($total/60));
  + } elsif ($total > 60) {
    return T('more than 1 minute ago');
  + } elsif ($total == 60) {
    + return T('1 minute ago');
  + } elsif ($total >= 2) {
    + return Ts('%s seconds ago',int($total));
  + } elsif ($total == 1) {
    + return T('1 second ago');
  + } else {
    + return T('just now');
  + }
+ }

then, please change above where it says


  + if ((-f $fname) && ((-M $fname) > 0.5)) {
  + $html .= T('(Maintenance done more than 12 hours.)');
  + }
for this:
  + $html .= '<br>' . T('Last Mainten: ') . &CalcTimeSince((-M $fname)/0.000011574);

--JuanmaMP


UseModWiki | WikiPatches | RecentChanges | Preferences
Edit text of this page | View other revisions | Search MetaWiki
Last edited July 18, 2009 2:10 am by JuanmaMP (diff)
Search: