/** * @param Controller $controller * @param Job $job (optional) */ public function __construct($controller, $job = null) { if ($job) { $fields = $job->getFields(); $required = $job->getValidator(); } else { $fields = singleton('Job')->getFields(); $required = singleton('Job')->getValidator(); } $fields->merge(new FieldList(new LiteralField('Conditions', $controller->TermsAndConditionsText), new HiddenField('BackURL', '', $controller->Link('thanks')), new HiddenField('EmailFrom', '', $controller->getJobEmailFromAddress()), new HiddenField('EmailSubject', '', $controller->getJobEmailSubject()), $jobId = new HiddenField('JobID'))); if ($job) { $jobId->setValue($job->ID); $actions = new FieldList(new FormAction('doEditJob', _t('Jobboard.EDITLISTING', 'Edit Listing'))); } else { $actions = new FieldList(new FormAction('doAddJob', _t('JobBoard.CONFIRM', 'Confirm'))); } parent::__construct($controller, 'AddJobForm', $fields, $actions, $required); $this->setFormAction('JobBoardFormProcessor/doJobForm'); $this->setFormMethod('POST'); if ($job) { $this->loadDataFrom($job); } else { $this->enableSpamProtection(); } }
/** * args: * jobid Job ID * action Action (started, finished, failed). */ public function perform() { $token = Config::get('ircbridgetoken'); $job = new Job($this->args['jobid']); $jobdata = $job->getJobData(); $msg = sprintf('[%%02%s%%0f] (%s) - %s - ', $jobdata['jail'], $jobdata['creator'], $jobdata['port']); switch ($this->args['action']) { case 'started': $msg .= 'started'; break; case 'finished': $msg .= 'finished (' . $jobdata['buildreason'] . ')'; break; case 'failed': $msg .= 'failed'; break; default: $msg .= 'unknown'; break; } if (file_get_contents('https://redportsircbot-bluelife.rhcloud.com/?token=' . $token . '&msg=' . urlencode($msg)) === false) { return false; } return true; }
private function checkJobs() { $job = new Job(); // $sql = "SELECT * FROM jobs WHERE type!='time' and datetime<'".date("Y-m-d H:i:s")."'"; $this->todolist = $job->findAll("type!='time' and datetime<:datetime", array('datetime' => date("Y-m-d H:i:s"))); return count($this->todolist); }
public function Display() { global $db; $rss_writer_object = new rss_writer_class(); $rss_writer_object->specification = '1.0'; $rss_writer_object->about = BASE_URL . 'rss.xml'; $rss_writer_object->rssnamespaces['dc'] = 'http://purl.org/dc/elements/1.1/'; $properties = array(); if ($this->mCategoryId == 'all') { $properties['description'] = 'Latest jobs'; } else { $properties['description'] = 'Latest jobs for ' . ucwords($this->mCategoryName); } $properties['link'] = BASE_URL; $properties['title'] = SITE_NAME; $properties['dc:date'] = date('d-m-Y'); $rss_writer_object->addchannel($properties); $count = 0; $jobb = new Job(); if ($this->mCategoryId == 'all') { $jobs = $jobb->GetJobs(0, 0, 0, 0, 0, true); } else { $jobs = $jobb->GetJobs(0, $this->mCategoryId, 0, 0, 0, true); } foreach ($jobs as $job) { $count++; if ($count > 10) { break; } $properties = array(); $properties['description'] = '<strong>Location:</strong> ' . $job['location'] . '<br />'; if ($job['url'] != '' && $job['url'] != 'http://') { $properties['description'] .= '<strong>URL:</strong> <a href="' . $job['url'] . '">' . $job['url'] . '</a><br /><br />'; } $properties['description'] .= '<strong>Description:</strong><br />' . $job['description'] . '<br /><br />'; $properties['description'] .= '<a href="' . BASE_URL . URL_JOB . '/' . $job['id'] . '/' . $job['url_title'] . '/' . '">Apply to this job</a><br />'; $properties['link'] = BASE_URL . URL_JOB . '/' . $job['id'] . '/' . $job['url_title'] . '/'; $type = '[' . $job['type_name'] . ']'; $properties['title'] = $type . ' ' . $job['title'] . ' at ' . $job['company']; $properties['dc:date'] = $job['mysql_date']; $rss_writer_object->additem($properties); } if (empty($jobs)) { $properties = array(); $properties['description'] = ' '; $properties['description'] .= ' '; $properties['link'] = ' '; $properties['title'] = ' '; $properties['dc:date'] = ' '; $rss_writer_object->additem($properties); } if ($rss_writer_object->writerss($output)) { header('Content-Type: text/xml; charset="utf-8"'); header('Content-Length: ' . strval(strlen($output))); echo $output; } else { //header('Content-Type: text/plain'); //echo ('Error: '.$rss_writer_object->error); } }
private function get_employers() { $branch = $this->employee->getBranch(); $criteria = array('columns' => "DISTINCT employers.name AS employer, employers.id", 'joins' => "employers ON employers.id = jobs.employer, \n employees ON employees.id = employers.registered_by", 'match' => "employees.branch = " . $branch[0]['id'], 'order' => "employers.name"); $job = new Job(); return $job->find($criteria); }
private function get_countries() { $criteria = array('columns' => "countries.country_code, countries.country, COUNT(jobs.id) AS job_count", 'joins' => "countries ON countries.country_code = jobs.country", 'match' => "jobs.deleted = FALSE AND jobs.expire_on >= CURDATE() AND jobs.closed = 'N'", 'group' => "countries.country_code", 'order' => "countries.country ASC"); $job = new Job(); $countries = $job->find($criteria); return $countries === false ? array() : $countries; }
/** * @param array $stats * @param string $expectedMethod * @param array $expectedParams * @dataProvider failedJobDataProvider */ public function testHandleFailedJob(array $stats, $expectedMethod, array $expectedParams) { $this->job->expects($this->once())->method('stats')->willReturn($stats); $invocationMocker = $this->job->expects($this->once())->method($expectedMethod); call_user_func_array([$invocationMocker, 'with'], $expectedParams); $this->strategy->handleFailedJob($this->job); }
function getById($jobid) { // do Bacula ACLs Zend_Loader::loadClass('Job'); $table = new Job(); if (!$table->isJobIdExists($jobid)) { return FALSE; } $select = new Zend_Db_Select($this->db); switch ($this->db_adapter) { case 'PDO_SQLITE': // bug http://framework.zend.com/issues/browse/ZF-884 $select->distinct(); $select->from(array('l' => 'Log'), array('logid' => 'LogId', 'jobid' => 'JobId', 'LogTime' => 'Time', 'logtext' => 'LogText')); $select->where("JobId = ?", $jobid); $select->order(array('LogId', 'LogTime')); break; default: // mysql, postgresql $select->distinct(); $select->from(array('l' => 'Log'), array('LogId', 'JobId', 'LogTime' => 'Time', 'LogText')); $select->where("JobId = ?", $jobid); $select->order(array('LogId', 'LogTime')); } //$sql = $select->__toString(); echo "<pre>$sql</pre>"; exit; // for !!!debug!!! $stmt = $select->query(); return $stmt->fetchAll(); }
public function getInitData($req) { $data = array(); $employees = new Employee(); $data['numberOfEmployees'] = $employees->Count("1 = 1"); $company = new CompanyStructure(); $data['numberOfCompanyStuctures'] = $company->Count("1 = 1"); $user = new User(); $data['numberOfUsers'] = $user->Count("1 = 1"); $project = new Project(); $data['numberOfProjects'] = $project->Count("status = 'Active'"); $attendance = new Attendance(); $data['numberOfAttendanceLastWeek'] = $attendance->Count("in_time > '" . date("Y-m-d H:i:s", strtotime("-1 week")) . "'"); if (empty($data['numberOfAttendanceLastWeek'])) { $data['numberOfAttendanceLastWeek'] = 0; } $empLeave = new EmployeeLeave(); $data['numberOfLeaves'] = $empLeave->Count("date_start > '" . date("Y-m-d") . "'"); $timeEntry = new EmployeeTimeEntry(); $data['numberOfAttendanceLastWeek'] = $timeEntry->Count("in_time > '" . date("Y-m-d H:i:s", strtotime("-1 week")) . "'"); $candidate = new Candidate(); $data['numberOfCandidates'] = $candidate->Count("1 = 1"); $job = new Job(); $data['numberOfJobs'] = $job->Count("status = 'Active'"); $course = new Course(); $data['numberOfCourses'] = $course->Count("1 = 1"); return new IceResponse(IceResponse::SUCCESS, $data); }
public function apply() { $id = (int) $_POST['id']; //find the offer $market = new JobMarket(); $offer = $market->get($id); if (empty($offer)) { throw new Exception('offer not found'); } //check if matches the requirements $skill = new Skill(); $skill = $skill->get($this->user->id); if ($skill->economic < $offer->skill) { throw new Exception("you don't meet the requirements"); } //give him the job $data = array('uid' => $this->user->id, 'company' => $offer->company, 'salary' => $offer->salary); $job = new Job($data); $saved = $job->save(); // update the offer if (!empty($saved)) { $offer->quantity--; if ($offer->quantity == 0) { $offer->delete(); } else { $offer->save(); } return true; } else { return false; } }
public function pushSync($name, array $args = array()) { $job = new Job($this->config, $name, $args); $job->isSynchronous(); $this->engine->push($job); $this->listening[$job->id] = $job; return $job; }
/** * Get a duplicate no-op version of a job * * @param Job $job * @return Job */ public static function newFromJob(Job $job) { $djob = new self($job->getTitle(), $job->getParams()); $djob->command = $job->getType(); $djob->params = is_array($djob->params) ? $djob->params : array(); $djob->params = array('isDuplicate' => true) + $djob->params; $djob->metadata = $job->metadata; return $djob; }
function installJobs() { global $jobsData, $jobs; foreach ($jobsData as $jobTitle) { $job = new Job(); $job->setName($jobTitle); $jobs[$jobTitle] = $job; } }
public function perform() { $job = new Job($this->args['jobid']); $jobdata = $job->getJobData(); $to = ''; $subject = 'Build ' . $this->args['action']; $content = 'Build ' . $this->args['action']; return mail($to, $subject, $content, implode("\r\n", $this->_headers)); }
/** * Add an array of refreshLinks jobs to the queue * @param array $titles Array of title objects. * @static */ function queueLinksJobs($titles) { $fname = 'Job::queueLinksJobs'; wfProfileIn($fname); foreach ($titles as $title) { $job = new Job('refreshLinks', $title); $job->insert(); } wfProfileOut($fname); }
public function enqueue(Job $job, $trackStatus = false) { if ($job instanceof ContainerAwareJob) { $job->setKernelOptions($this->kernelOptions); } $result = \Resque::enqueue($job->queue, \get_class($job), $job->args, $trackStatus); if ($trackStatus) { return new \Resque_Job_Status($result); } return null; }
/** * Executes the job * * @param Job $job * @return boolean Returns false if the job failed */ public function runJob(Job $job) { try { $command = $this->instantiateCommand($job->getClassName()); $result = call_user_func_array([$command, 'handle'], $job->getArguments()); } catch (\Exception $e) { error_log($e); $result = false; } return $result; }
function do_post_testcancelphp_continuation_v1($job, $resp) { // we have do_post with a continuation of do_finish. The do_finish // is only called via on-completion handler for do_run $run = $this->job_manager()->job("do_run_testcancelphp_continuation_v1"); $finish = new Job($job); $finish->name("do_finish_testcancelphp_continuation_v1"); $run->on(Job::EVENT_COMPLETED, $finish); $this->afterwards($run); return Worker::WORKER_CONTINUE; }
function delete($id) { $o = new Job($id); if ($o->delete()) { flash_message('success', 'Level đã được xóa thành công'); redirect($this->admin_url . 'jobs/listAll'); } else { flash_message('error', 'Có lỗi. Vui lòng kiểm tra lại'); redirect($this->admin_url . 'jobs/listAll'); } }
public function executeAction() { Assert::found($id = (int) $this->dispatcher->getParam('0', 'uint')); Assert::found($task = Task::findFirst($id), "Task not found"); $job = Job::findFirst(['task_id = ?0 and executed_at is null', 'bind' => [$task->task_id]]); if (!$job) { $job = new Job(); $job->save(['task_id' => $task->task_id]); Assert::noMessages($job); } return $this->response->redirect('/task/run/' . $job->job_id, true); }
/** * @return void */ public function testExceptionApplyAll() { $ruleProcessorMock = $this->getMock('Magento\\CatalogRule\\Model\\Indexer\\Rule\\RuleProductProcessor', ['markIndexerAsInvalid'], [], '', false); $exceptionMessage = 'Test exception message'; $exceptionCallback = function () use($exceptionMessage) { throw new \Magento\Framework\Model\Exception($exceptionMessage); }; $ruleProcessorMock->expects($this->once())->method('markIndexerAsInvalid')->will($this->returnCallback($exceptionCallback)); $jobModel = new Job($ruleProcessorMock); $jobModel->applyAll(); $this->assertEquals($exceptionMessage, $jobModel->getError()); }
public function run() { $replace = \Config::get('laravel-jobs::seed.replace'); if ($replace) { \DB::table('fbf_jobs')->delete(); } $faker = \Faker\Factory::create(); $statuses = array(Job::DRAFT, Job::APPROVED); $types = array(Job::PERMANENT, Job::TEMPORARY); $times = array(Job::FULL_TIME, Job::PART_TIME); for ($i = 0; $i < 100; $i++) { $job = new Job(); $job->title = $faker->sentence(rand(1, 4)); if (\Config::get('laravel-jobs::use_reference_field')) { $job->reference = 'JOB/' . rand(1000, 9999); } if (\Config::get('laravel-jobs::use_location_field')) { $job->location = $faker->city(); } if (\Config::get('laravel-jobs::use_type_field')) { $job->type = $faker->randomElement($types); } if (\Config::get('laravel-jobs::use_time_field')) { $job->time = $faker->randomElement($times); } if (\Config::get('laravel-jobs::use_closing_date_field')) { $job->closing_date = $faker->dateTimeBetween('-1 week', '+3 months'); } switch (\Config::get('laravel-jobs::salary_field')) { case 'text': $job->salary_text = $this->salaryText(); break; case 'number': $job->salary_from = rand(20000, 200000); break; case 'range': $number1 = rand(20000, 200000); $number2 = rand(20000, 200000); $job->salary_from = min($number1, $number2); $job->salary_to = max($number1, $number2); break; } $job->description = '<p>' . implode('</p><p>', $faker->paragraphs(rand(1, 10))) . '</p>'; $job->meta_description = $faker->paragraph(rand(1, 4)); $keywords = $faker->words(10, true); $job->search_extra = $keywords; $job->meta_keywords = $keywords; $job->status = $faker->randomElement($statuses); $job->published_date = $faker->dateTimeBetween('-6 weeks', '+1 week'); $job->save(); } echo 'Database seeded' . PHP_EOL; }
/** * Parse crontab line into Job object * * @param $jobLine * * @return Job * @throws \InvalidArgumentException */ static function parse($jobLine) { // split the line $parts = preg_split('@ @', $jobLine, NULL, PREG_SPLIT_NO_EMPTY); // check the number of part if (count($parts) < 5) { throw new \InvalidArgumentException('Wrong job number of arguments.'); } // analyse command $command = implode(' ', array_slice($parts, 5)); // prepare variables $lastRunTime = $logFile = $logSize = $errorFile = $errorSize = $comments = null; // extract comment if (strpos($command, '#')) { list($command, $comment) = explode('#', $command); $comments = trim($comment); } // extract error file if (strpos($command, '2>>')) { list($command, $errorFile) = explode('2>>', $command); $errorFile = trim($errorFile); } // extract log file if (strpos($command, '>>')) { list($command, $logPart) = explode('>>', $command); $logPart = explode(' ', trim($logPart)); $logFile = trim($logPart[0]); } // compute last run time, and file size if (isset($logFile) && file_exists($logFile)) { $lastRunTime = filemtime($logFile); $logSize = filesize($logFile); } if (isset($errorFile) && file_exists($errorFile)) { $lastRunTime = max($lastRunTime ?: 0, filemtime($errorFile)); $errorSize = filesize($errorFile); } $command = trim($command); // compute status $status = 'error'; if ($logSize === null && $errorSize === null) { $status = 'unknown'; } else { if ($errorSize === null || $errorSize == 0) { $status = 'success'; } } // set the Job object $job = new Job(); $job->setMinute($parts[0])->setHour($parts[1])->setDayOfMonth($parts[2])->setMonth($parts[3])->setDayOfWeek($parts[4])->setCommand($command)->setErrorFile($errorFile)->setErrorSize($errorSize)->setLogFile($logFile)->setLogSize($logSize)->setComments($comments)->setLastRunTime($lastRunTime)->setStatus($status); return $job; }
function schedule_recurring_event($event) { global $wpdb; $schedules = wp_get_schedules(); $schedule = $event->schedule; $job = new Job(); $job->hook = $event->hook; $job->site = get_current_blog_id(); $job->start = $job->nextrun = $event->timestamp; $job->interval = $event->interval; $job->args = $event->args; $job->save(); }
/** * Returns an array of jobs for the specified job identifiers, keyed by job identifier * * @param string[] $jids * * @return array|Job[] */ public function multiget($jids) { if (empty($jids)) { return []; } $results = call_user_func_array([$this->client, 'multiget'], $jids); $jobs = json_decode($results, true); $ret = []; foreach ($jobs as $job_data) { $job = new Job($this->client, $job_data); $ret[$job->getId()] = $job; } return $ret; }
function job_board_news() { global $db; $news = array(); $job = new Job(); $result = $job->getAllJobs('created_date', 'desc'); if (is_array($result)) { foreach ($result as $row) { $title = htmlentities_utf8($row['title']); $news[] = array('time' => $row['revised_date'], 'object' => $row, 'thumb' => AT_JB_BASENAME . 'images/jb_icon_tiny.png', 'link' => '<span title="' . strip_tags($title) . '"><a href="' . AT_JB_BASENAME . 'view_post.php?jid=' . $row['id'] . '">' . $title . "</a></span>"); } } return $news; }
/** * Returns a new job ordered by most recent first * why this? * run newest first, some jobs get left behind * run oldest first, all jobs get left behind * @return DJJob */ public function getNewJob() { # we can grab a locked job if we own the lock $now = date('Y-m-d H:i:s'); $rs = $this->runQuery("\n SELECT id\n FROM " . self::$dbPre . self::$tableName . "\n WHERE queue = ?\n AND (run_at IS NULL OR '" . $now . "' >= run_at)\n AND (locked_at IS NULL OR locked_by = ?)\n AND failed_at IS NULL\n AND attempts < ?\n ORDER BY created_at DESC\n LIMIT 10\n ", array($this->queue, $this->name, $this->max_attempts)); // randomly order the 10 to prevent lock contention among workers shuffle($rs); foreach ($rs as $r) { $job = new Job($this->name, $r["id"], array("max_attempts" => $this->max_attempts, "fail_on_output" => $this->fail_on_output, "queue" => $this->queue)); if ($job->acquireLock()) { return $job; } } return false; }
private function _isDestinationDirWritable(Job $job) { if (!$job->destinationInfo()->isDir()) { $this->_logger->goingToCreateDestinationDir($job); if (false == mkdir($job->getDestination())) { $this->_logger->cannotCreateDestinationDir($job); return false; } } if (!$job->destinationInfo()->isWritable()) { $this->_logger->destinationDirIsNotWritable($job); return false; } return true; }
public function get() { $uid = (int) $_REQUEST['uid']; if ($uid == 0) { $uid = $this->user->id; } $where = array(array('uid', '=', $uid)); $userClass = new Job(); $results = $userClass->find($where); if (sizeof($results) == 0) { return false; } $data = $this->parse($results[0]); return $data; }
function save($object = '', $related_field = '') { if (!$this->exists()) { $o = new Job(); $o->select_max('position'); $o->get(); if (count($o->all) != 0) { $max = $o->position + 1; $this->position = $max; } else { $this->postion = 1; } } return parent::save($object, $related_field); }