/** * @param Bot $bot * @return array */ private function _getStatusButtons($bot) { $buttons = array(); $buttons['pause'] = array("url" => $bot->getUrl() . "/pause", "icon" => "icon-pause", "text" => "pause job"); $buttons['dropjob'] = array("url" => $bot->getUrl() . "/dropjob", "icon" => "icon-stop", "text" => "stop job"); $buttons['edit'] = array("url" => $bot->getUrl() . "/edit", "icon" => "icon-cog", "text" => "edit bot"); $buttons['play'] = array("url" => $bot->getUrl() . "/play", "icon" => "icon-play", "text" => "resume job"); $buttons['qa'] = array("url" => $bot->getCurrentJob()->getUrl() . "/qa", "icon" => "icon-check", "text" => "verify output"); $buttons['offline'] = array("url" => $bot->getUrl() . "/setstatus/offline", "icon" => "icon-stop", "text" => "take offline"); $buttons['online'] = array("url" => $bot->getUrl() . "/setstatus/idle", "icon" => "icon-play", "text" => "bring online"); $buttons['retire'] = array("url" => $bot->getUrl() . "/retire", "icon" => "icon-lock", "text" => "retire bot"); $buttons['delete'] = array("url" => $bot->getUrl() . "/delete", "icon" => "icon-remove", "text" => "delete bot"); $buttons['error'] = array("url" => $bot->getURL() . "/error", "icon" => "icon-exclamation-sign", "text" => "error mode"); return $buttons; }
public function play() { $this->assertLoggedIn(); try { //how do we find them? if ($this->args('id')) { $bot = new Bot($this->args('id')); } else { throw new Exception("Could not find that bot."); } //did we really get someone? if (!$bot->isHydrated()) { throw new Exception("Could not find that bot."); } if (!$bot->isMine()) { throw new Exception("You cannot view that bot."); } if ($bot->get('status') != 'paused') { throw new Exception("Bot must be paused to unpause a job."); } $job = $bot->getCurrentJob(); if (!$job->isHydrated()) { throw new Exception("Job must be a real job."); } if (!$bot->canDrop($job)) { throw new Exception("Job cannot be dropped."); } //okay, unpause it. $bot->unpause(); Activity::log("unpaused the bot " . $bot->getLink() . "."); $this->forwardToUrl("/"); } catch (Exception $e) { $this->set('megaerror', $e->getMessage()); $this->setTitle("Bot Unpause Job - Error"); } }