コード例 #1
0
ファイル: main.php プロジェクト: eric116/BotQueue
 /**
  * @param Job $job
  * @return array
  */
 private function _getJobData($job)
 {
     $jobData = array();
     $jobData['id'] = $job->id;
     $jobData['name'] = $job->getName();
     $jobData['url'] = $job->getUrl();
     $jobData['elapsed'] = $job->getElapsedText();
     $jobData['queue_name'] = $job->getQueue()->getName();
     $jobData['queue_url'] = $job->getQueue()->getUrl();
     return $jobData;
 }
コード例 #2
0
ファイル: apiv1.php プロジェクト: eric116/BotQueue
 public function api_canceljob()
 {
     /* @var $job Job */
     $job = new Job($this->args('job_id'));
     if (!$job->isHydrated()) {
         throw new Exception("Job does not exist.");
     }
     if (!$job->getQueue()->isMine()) {
         throw new Exception("This job is not in your queue.");
     }
     //TODO Figure out if this should be implemented
     //if (!$job->canDelete($job))
     //	throw new Exception("You cannot delete this job.");
     Activity::log("cancelled the <strong>" . $job->getName() . "</strong> job via the API.");
     $job->cancelJob();
     return $job->getAPIData();
 }
コード例 #3
0
ファイル: JobTest.php プロジェクト: Chris7/JoliCi
 public function testToStringReturnsTheNameOfTheJob()
 {
     $jobMock = new Job('project', 'strategy', uniqid());
     $this->assertEquals($jobMock->getName(), $jobMock->__toString());
 }
コード例 #4
0
ファイル: job.php プロジェクト: ricberw/BotQueue
 public function edit()
 {
     $this->assertLoggedIn();
     try {
         //how do we find them?
         if ($this->args('id')) {
             $job = new Job($this->args('id'));
         }
         //did we really get someone?
         if (!$job->isHydrated()) {
             throw new Exception("Could not find that job.");
         }
         if ($job->get('user_id') != User::$me->id) {
             throw new Exception("You do not own this job.");
         }
         if ($job->get('status') != 'available') {
             throw new Exception("You can only edit jobs that have not been taken yet.");
         }
         $this->setTitle('Edit Job - ' . $job->getName());
         $this->set('job', $job);
         //load up our queues.
         $queues = User::$me->getQueues()->getAll();
         foreach ($queues as $row) {
             $q = $row['Queue'];
             $data[$q->id] = $q->getName();
         }
         $this->set('queues', $data);
         if ($this->args('submit')) {
             $queue = new Queue($this->args('queue_id'));
             if (!$queue->canAdd()) {
                 throw new Exception("That is not a valid queue.");
             }
             $job->set('queue_id', $queue->id);
             $job->save();
             Activity::log("edited the job " . $job->getLink() . ".");
             $this->forwardToUrl($job->getUrl());
         }
         //errors?
         if (!$this->get('megaerror')) {
             $this->set('file', $job->getFile());
             $this->set('queue', $job->getQueue());
             $this->set('bot', $job->getBot());
             $this->set('creator', $job->getUser());
         }
     } catch (Exception $e) {
         $this->setTitle('Edit Job - Error');
         $this->set('megaerror', $e->getMessage());
     }
 }
コード例 #5
0
 public function update(Job $job)
 {
     echo "Человек получил обновление о новой вакансии {$job->getName()} с зарплатой {$job->getSalary()} USD";
     echo '<br>';
 }