コード例 #1
0
ファイル: apiv1.php プロジェクト: eric116/BotQueue
 public function api_grabslicejob()
 {
     $sj = new SliceJob($this->args('job_id'));
     if (!$sj->isHydrated()) {
         throw new Exception("Slice job does not exist.");
     }
     if ($sj->get('user_id') != User::$me->id && !User::$me->isAdmin()) {
         throw new Exception("This slice job is not yours to grab.");
     }
     if (!$sj->get('status') != 'available') {
         throw new Exception("You cannot grab this job.");
     }
     //attempt to grab our job.  will throw exceptions on failure.
     $sj->grab($this->args('_uid'));
     //return the bot data w/ all our info.
     $data = $sj->getAPIData();
     Activity::log($this->args('_uid') . " uid grabbed the " . $sj->getLink() . " slice job via the API.");
     return $data;
 }