public function set_status() { $this->assertLoggedIn(); try { //how do we find them? if ($this->args('id')) { $bot = new Bot($this->args('id')); } else { throw new Exception("This shouldn't happen"); } //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') == 'retired') { throw new Exception("This bot is retired. You can't change it's status"); } if (($bot->get('status') == 'working' || $bot->get('status') == 'slicing') && $this->args('status') == 'offline') { throw new Exception("You cannot take a working bot offline through the web interface. You must stop the job from the client first."); } if ($this->args('status') == 'offline') { Activity::log("took the bot " . $bot->getLink() . " offline."); } else { Activity::log("brought the bot " . $bot->getLink() . " online."); } //do we need to drop a job? $job = $bot->getCurrentJob(); if ($job->isHydrated()) { $bot->dropJob($job); } //save it and clear out some junk $bot->set('temperature_data', ''); $bot->set('error_text', ''); $bot->setStatus($this->args('status')); $bot->save(); $this->forwardToUrl("/"); } catch (Exception $e) { $this->set('megaerror', $e->getMessage()); $this->setTitle("Change Bot Status - Error"); } }