Ignore:
Timestamp:
Nov 22, 2015, 12:05:45 PM (9 years ago)
Author:
chronos
Message:
  • Fixed: Notify also about newly online network interfaces.
File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/Modules/Notify/Notify.php

    r763 r767  
    3535  }
    3636
    37   function OnlineList($Title, $OnlineNow, $OnlinePrevious)
     37  function OnlineList($Title, $OnlineNow, $OnlinePrevious, $MinDuration)
    3838  {
    3939    $Time = time();
    40     $MinDuration = 5;
    4140    $OnlineText = array('<span style="color:red;">Nedostupný</span>', '<span style="color:green;">Dostupný</span>');
    4241    $Output = '';
     42    $Condition = 'WHERE (`NetworkInterface`.`Online` = '.$OnlineNow.') AND (`NetworkInterface`.`OnlineNotify` = '.$OnlinePrevious.') '.
     43      'AND (`NetworkInterface`.`LastOnline` <= "'.TimeToMysqlDateTime($Time - $MinDuration).'")';
    4344    $DbResult3 = $this->Database->query('SELECT CONCAT_WS("-", `NetworkDevice`.`Name`, NULLIF(`NetworkInterface`.`Name`, "")) AS `Name`, '.
    4445      '`NetworkInterface`.`Online`, `NetworkInterface`.`LastOnline` FROM `NetworkInterface` '.
    4546      'LEFT JOIN `NetworkDevice` ON `NetworkDevice`.`Id` = `NetworkInterface`.`Device` '.
    46       'WHERE (`NetworkInterface`.`Online` = '.$OnlineNow.') AND (`NetworkInterface`.`OnlineNotify` = '.$OnlinePrevious.') '.
    47       'AND (`NetworkDevice`.`PermanentOnline`=1) AND (`NetworkDevice`.`Used`=1) '.
    48       'AND (`NetworkInterface`.`LastOnline` < "'.TimeToMysqlDateTime($Time - $MinDuration).'") ORDER BY `Name` ASC');
     47      $Condition.' AND (`NetworkDevice`.`PermanentOnline`=1) AND (`NetworkDevice`.`Used`=1) '.
     48      'ORDER BY `Name` ASC');
    4949    if($DbResult3->num_rows > 0) {
    5050      $Output .= $Title.'<br/>';
     
    6565      $Output .= '</table><br/>'."\n";
    6666    }
     67    $this->Database->query('UPDATE `NetworkInterface` SET `OnlineNotify` = `Online` '.
     68      $Condition);
    6769    return $Output;
    6870  }
     
    8385      {
    8486        if($Category['SysName'] == 'NetworkReachability') {
    85           $List = $this->OnlineList('Nově online', 1, 0);
    86           $List .= $this->OnlineList('Nově offline', 0, 1);
     87          $List = $this->OnlineList('Nově online', 1, 0, 0);
     88          $List .= $this->OnlineList('Nově offline', 0, 1, 5);
    8789          if($List != '') $List .= $this->OnlineList('Stále offline', 0, 0);
    8890          if($List != '') {
     
    9395        }
    9496      }
    95       $this->Database->query('UPDATE `NetworkInterface` SET `OnlineNotify` = `Online` '.
    96         'WHERE `OnlineNotify` != `Online`');
    9797      $this->Database->update('NotifyUser', '`Id`='.$User['Id'], array('LastTime' => TimeToMysqlDateTime($Time)));
    9898
Note: See TracChangeset for help on using the changeset viewer.