#!/usr/bin/php getAllIdleWorkers(); if (empty($aWorkers)) { verbose("No idle workers found\n"); } else { foreach ($aWorkers as $aWorker) { $aData = $aWorker; $aData['username'] = $user->getUserName($aWorker['account_id']); $aData['subject'] = 'IDLE Worker : ' . $aWorker['username']; $aData['worker'] = $aWorker['username']; $aData['email'] = $user->getUserEmail($aData['username']); if (!$notification->sendNotification($aWorker['account_id'], 'idle_worker', $aData)) verbose($notification->getError() . "\n"); } } // We notified, lets check which recovered $aNotifications = $notification->getAllActive('idle_worker'); if (!empty($aNotifications)) { foreach ($aNotifications as $aNotification) { $aData = json_decode($aNotification['data'], true); $aWorker = $worker->getWorker($aData['id']); if ($aWorker['active'] == 1) { if ($notification->setInactive($aNotification['id'])) { verbose("Marked notification " . $aNotification['id'] . " as inactive\n"); } else { verbose("Failed to set notification inactive for " . $aWorker['username'] . "\n"); } } } } ?>