public function notify() { //check if notification has not already been send if ($this->getNotify() == true) { //check which event to test if ($this->getAction() == 'router_offline') { $crawl_cycles = ConfigLine::configByName('event_notification_router_offline_crawl_cycles'); $router = new Router((int) $this->getObject()); $router->fetch(); $statusdata_history = new RouterStatusList($router->getRouterId(), 0, (int) $crawl_cycles, "status_id", "desc"); if ($statusdata_history->getTotalCount() >= $crawl_cycles) { $statusdata_history = $statusdata_history->getRouterStatuslist(); $online = false; foreach ($statusdata_history as $key => $statusdata) { if ($statusdata->getStatus() == 'online') { $online = true; break; } } if (!$online and $this->getNotified() == 0) { //if router is marked as offline in each of the $crawl_cycles last crawl cycles, then //send a notification $user = new User($this->getUserId()); if ($user->fetch()) { $this->notifyRouterOffline($user, $router, $statusdata_history[$crawl_cycles - 1]->getCreateDate()); //store into database that the router has been notified $this->setNotified(1); $this->setNotificationDate(time()); $this->store(); } } elseif ($online and $this->getNotified() == 1) { //if the router has been notified but is not offline anymore, then reset notification $this->setNotified(0); $this->store(); } } } elseif ($this->getAction() == 'network_down') { } } }