public function actionEditmoreinfo($user_id) { $user_more_info = UserInfoAR::model()->findByPk($user_id); $this->assign('user_more', $user_more_info); $maritalStatus = MaritalStatus::model()->findAll(); // 'MaritalStatus', 'marital_status_id'), $hometown = Hometown::model()->findAll(); // 'Province', 'hometown_id'), $nation = Nation::model()->findAll(); // 'Nation', 'nation_id'), $bodyType = BodyType::model()->findAll(); // 'BodyType', 'body_type_id'), $education = Education::model()->findAll(); // 'Education', 'education_id'), $school = School::model()->findAll(); // 'School', 'school_id'), $province = Province::model()->findAll(); // 'Province', 'province_id'), $job = Job::model()->findAll(); // '$maritalSta, $this->assign('maritalStatus', $maritalStatus); $this->assign('hometown', $hometown); $this->assign('nation', $nation); $this->assign('bodyType', $bodyType); $this->assign('education', $education); $this->assign('school', $school); $this->assign('province', $province); $this->assign('job', $job); }
public function actionEvents() { /** * @var $task Task * @var $cmd CDbCommand */ $result = array('success' => 1); if (isset($_GET['from']) && isset($_GET['to'])) { $start = date(Task::DF_INTER, intval($_GET['from']) / 1000); $end = date(Task::DF_INTER, intval($_GET['to']) / 1000); //echo $start."\n".$end; $criteria = new CDbCriteria(); $criteria->addBetweenCondition('start_date', $start, $end); if ($this->_user()->role == User::ROLE_USER) { $cmd = Yii::app()->db->createCommand(); $taskIds = $cmd->select('task_id')->from(Job::model()->tableName())->where('organization_id = :id AND (updated_at BETWEEN :start AND :end)', array(':id' => $this->_user()->organization_id, ':start' => $start, ':end' => $end))->queryColumn(); $criteria->addInCondition('id', $taskIds); } $tasks = Task::model()->findAll($criteria, array('order' => array('priority' => 'DESC'))); $data = array(); foreach ($tasks as $task) { $data[] = array('id' => $task->id, 'title' => $task->name, 'url' => Yii::app()->createUrl('task/view', array('id' => $task->id)), 'start' => strtotime($task->created_at) . '000', 'end' => strtotime($task->created_at) + 1800 . '000', 'class' => 'priority-' . $task->priority); } $result['result'] = $data; } $this->renderJSON($result); }
/** * Returns the data model based on the primary key given in the GET variable. * If the data model is not found, an HTTP exception will be raised. * @param integer $id the ID of the model to be loaded * @return User the loaded model * @throws CHttpException */ public function loadModel($id) { $model = Job::model()->findByPk($id); if ($model === null) { throw new CHttpException(404, 'The requested page does not exist.'); } return $model; }
protected function renderContent() { $criteria = new CDbCriteria(); $criteria->condition = 'active = 1'; $criteria->order = 'publication_date DESC'; $criteria->limit = $this->maxNbrEntries; $jobs = Job::model()->findAll($criteria); $this->render('recentJobsWidget', array('jobs' => $jobs)); }
public function run() { $client = new Net_Gearman_Client(array('localhost:4730')); $this->JobSet->starttime = date('Y-m-d H:i:s'); $this->JobSet->save(); $client->runSet($this->taskList); if (!$this->background) { if ($this->taskList->finished()) { global $WorkerJobSetResults; $handles = $this->taskList->handles; $key_handles = array_keys($handles); for ($i = 0; $i < count($WorkerJobSetResults[$this->randomHash]); $i++) { if (array_key_exists($key_handles[$i], $WorkerJobSetResults[$this->randomHash])) { if ($WorkerJobSetResults[$this->randomHash][$key_handles[$i]]['done']) { $job = Job::model()->find('id=:id', array(':id' => $WorkerJobSetResults[$this->randomHash][$key_handles[$i]]['job_id'])); if ($job != null) { if ($job == null) { $job = new Job(); } $this->results[] = unserialize(base64_decode($job->result)); // echo "Done"; $job->needed = 0; $job->save(); } else { die("Some results didn't come...\n"); } } } else { die("Some results didn't come...\n"); } } $this->JobSet->finishtime = date('Y-m-d H:i:s'); if ($this->auto_destroy_results) { $this->JobSet->needed = 0; $this->JobSet->delete(); $this->JobSet = null; } else { $this->JobSet->save(); } return $this->results; } echo "Task set could not be finished!<br />\n"; return false; } else { // background work return true; } }
public function run($arg) { try { $arg = unserialize(base64_decode($arg)); if (!isset($arg['class']) || !isset($arg['function'])) { return array('result' => array('done' => false, 'job_id' => -1), 'WorkerJobSetIdentifier' => isset($arg['WorkerJobSetIdentifier']) ? $arg['WorkerJobSetIdentifier'] : -1, 'background' => isset($arg['background']) ? $arg['background'] : -1); } $log = $arg["class"] . '::' . $arg["function"]; if (defined('THREAD') && defined('THREAD_TYPE')) { print date('d.m.Y H:i:s') . ' :: ' . THREAD_TYPE . ' Thread :: ' . str_pad(THREAD, 3, '0', STR_PAD_LEFT) . ' :: ' . $log . "\n"; } $task_id = $arg['task_id']; $Job = Job::model()->find('id=:id', array(':id' => $task_id)); if ($Job == null) { $Job = new Job(); return null; } $Job->started = 1; $Job->starttime = date('Y-m-d H:i:s'); $Job->save(); $tmp = $this->runClassFunction($arg["class"], $arg["function"], $arg["params"]); $done = false; if ($tmp != null) { $Job->parameters = null; $Job->result = base64_encode(serialize($tmp)); $Job->finishtime = date('Y-m-d H:i:s'); $Job->save(); $Job->finished = 1; $Job->save(); $done = true; } } catch (CDbException $e) { if (function_exists('thread_shutdown')) { thread_shutdown(); } die; } $log = $arg["class"] . '::' . $arg["function"] . ' :: DONE'; if (defined('THREAD') && defined('THREAD_TYPE')) { print date('d.m.Y H:i:s') . ' :: ' . THREAD_TYPE . ' Thread :: ' . str_pad(THREAD, 3, '0', STR_PAD_LEFT) . ' :: ' . $log . "\n"; } return array('result' => array('done' => $done, 'job_id' => $Job->id), 'WorkerJobSetIdentifier' => $arg['WorkerJobSetIdentifier'], 'background' => $arg['background']); }
public static function MergePDF($svg_to_pdf_jobs) { $log = "Svg2Pdf :: MergePDF :: MergePDF pdf jobs: " . implode(', ', $svg_to_pdf_jobs); if (defined('THREAD') && defined('THREAD_TYPE')) { print date('d.m.Y H:i:s') . ' :: ' . THREAD_TYPE . ' Thread :: ' . str_pad(THREAD, 3, '0', STR_PAD_LEFT) . ' :: ' . $log . "\n"; } // počakat moramo, da so vsi svg 2 pdf narjeni, preden jih gremo mergat for ($i = 0; $i < 2; ++$i) { do { $job_check = Job::model()->find('id in (:ids) and (finished=:finished or result IS NULL)', array(':ids' => implode(', ', $svg_to_pdf_jobs), ':finished' => 0)); if ($job_check != null) { $log = 'Svg2Pdf :: MergePDF :: Need to wait to all SVG 2 PDF jobs are finished...'; if (defined('THREAD') && defined('THREAD_TYPE')) { print date('d.m.Y H:i:s') . ' :: ' . THREAD_TYPE . ' Thread :: ' . str_pad(THREAD, 3, '0', STR_PAD_LEFT) . ' :: ' . $log . "\n"; } sleep(1); } } while ($job_check != null); } $pdf_list = array(); foreach ($svg_to_pdf_jobs as $job_id) { $job = Job::model()->find('id=:id', array(':id' => $job_id)); if ($job == null) { $log = 'Svg2Pdf :: MergePDF :: Job with ID: ' . $job_id . ' not found!!!'; if (defined('THREAD') && defined('THREAD_TYPE')) { print date('d.m.Y H:i:s') . ' :: ' . THREAD_TYPE . ' Thread :: ' . str_pad(THREAD, 3, '0', STR_PAD_LEFT) . ' :: ' . $log . "\n"; } $job = new Job(); continue; } if (strlen($job->result) == 0) { $log = 'Svg2Pdf :: MergePDF :: Found one empty PDF, retry function MergePDF...'; if (defined('THREAD') && defined('THREAD_TYPE')) { print date('d.m.Y H:i:s') . ' :: ' . THREAD_TYPE . ' Thread :: ' . str_pad(THREAD, 3, '0', STR_PAD_LEFT) . ' :: ' . $log . "\n"; } sleep(1); return self::MergePDF($svg_to_pdf_jobs); } $log = 'Svg2Pdf :: MergePDF :: Found Job ID: ' . $job->id . ', PDF size: ' . strlen($job->result); if (defined('THREAD') && defined('THREAD_TYPE')) { print date('d.m.Y H:i:s') . ' :: ' . THREAD_TYPE . ' Thread :: ' . str_pad(THREAD, 3, '0', STR_PAD_LEFT) . ' :: ' . $log . "\n"; } $pdf_list[] = unserialize(base64_decode($job->result)); } $log = 'Svg2Pdf :: MergePDF :: PDF to merge: ' . count($pdf_list); if (defined('THREAD') && defined('THREAD_TYPE')) { print date('d.m.Y H:i:s') . ' :: ' . THREAD_TYPE . ' Thread :: ' . str_pad(THREAD, 3, '0', STR_PAD_LEFT) . ' :: ' . $log . "\n"; } $list = array(); $gs = trim(shell_exec('/usr/bin/which gs')); $cmd = $gs . ' -q -dNOPAUSE -dBATCH -sDEVICE=pdfwrite -sOutputFile='; $counter = 0; do { $new_pdf_list = array(); $output_file = tempnam(sys_get_temp_dir(), 'pdfmerge'); $list[] = $output_file; $list[] = $output_file . '.pdf'; $cmd_to_exec = $cmd . $output_file . '.pdf '; $new_pdf_list[] = $output_file . '.pdf'; for ($i = 0; $i < count($pdf_list); ++$i) { if ($i < 10) { $tmp_file = tempnam(sys_get_temp_dir(), 'pdfformerge'); file_put_contents($tmp_file . '.pdf', $pdf_list[$i]); $cmd_to_exec .= $tmp_file . '.pdf '; $list[] = $tmp_file; $list[] = $tmp_file . '.pdf'; } else { $new_pdf_list[] = $pdf_list[$i]; } } $result = shell_exec($cmd_to_exec); $counter++; $log = 'Svg2Pdf :: MergePDF :: Anti too long command handler, merging blocks of 10 pdfs, cylce number: ' . $counter; if (defined('THREAD') && defined('THREAD_TYPE')) { print date('d.m.Y H:i:s') . ' :: ' . THREAD_TYPE . ' Thread :: ' . str_pad(THREAD, 3, '0', STR_PAD_LEFT) . ' :: ' . $log . "\n"; } $new_pdf_list[0] = file_get_contents($output_file . '.pdf'); $pdf_list = $new_pdf_list; } while (count($pdf_list) > 1); for ($i = 0; $i < count($list); ++$i) { @unlink($list[$i]); } return $pdf_list[0]; }
public function actionView() { $this->_checkAuth(); // Check if id was submitted via GET if (!isset($_GET['id'])) { $this->_sendResponse(500, 'Error: Parameter <b>id</b> is missing'); } $currentModel = mb_strtolower($_GET['model'], 'UTF-8'); $return_array = array(); $return_custom = false; switch ($currentModel) { // Find respective model case 'convert': // {{{ $return_custom = true; $model = Convert::model()->findByPk($_GET['id'], 'user_id=:user_id', array(':user_id' => $this->user_id)); if ($model != null) { if ($model == null) { $model = new Convert(); } if ($model->result == null) { if (isset($model->backgroudJobSet->finalJobResult->result)) { if ($model->backgroudJobSet->finalJobResult->result != null) { $result = unserialize(base64_decode($model->backgroudJobSet->finalJobResult->result)); $model->result = base64_encode($result); } // cleanup if ($model->result != null) { $model->backgroudJobSet->delete(); $model->backgroud_job_set_id = null; } $model->save(); } } $background_done = false; $jobs_done = 0; $jobs_to_do = 0; if ($model->background) { if ($model->result != null) { $background_done = true; } $jobs_done = Job::model()->count('job_set_id=:job_set_id and finished=:finished', array(':job_set_id' => $model->backgroud_job_set_id, ':finished' => 1)); $jobs_to_do = Job::model()->count('job_set_id=:job_set_id', array(':job_set_id' => $model->backgroud_job_set_id)); } $return_array = array('id' => $model->id, 'background' => $model->background, 'background_done' => $background_done, 'result' => $model->result, 'jobs_done' => $jobs_done, 'jobs_to_do' => $jobs_to_do, 'progress' => $jobs_to_do != 0 ? round($jobs_done / $jobs_to_do * 10000) / 100 : 100); } break; // }}} // }}} default: // {{{ $this->_sendResponse(501, sprintf('Mode <b>view</b> is not implemented for model <b>%s</b>', $_GET['model'])); exit; // }}} } if (is_null($model)) { $this->_sendResponse(404, 'No Item found with id ' . $_GET['id']); } else { $this->_sendResponse(200, $this->_getObjectEncoded($_GET['model'], $return_custom ? $return_array : $model->attributes)); } }
if ($newCommand) { $diffAttr->new = $newCommand->name; } break; case 'machine_id': $oldMachine = Machine::model()->findByPk($diffAttr->old); if ($oldMachine) { $diffAttr->old = $oldMachine->name; } $newMachine = Machine::model()->findByPk($diffAttr->new); if ($newMachine) { $diffAttr->new = $newMachine->name; } break; case 'crucial': $crucials = Job::model()->getCrucialOptions(); $diffAttr->old = isset($crucials[$diffAttr->old]) ? $crucials[$diffAttr->old] : NULL; $diffAttr->new = isset($crucials[$diffAttr->new]) ? $crucials[$diffAttr->new] : NULL; break; } if ($diffAttr->old === NULL) { $diffAttr->old = '[NULL]'; } if ($diffAttr->new === NULL) { $diffAttr->new = '[NULL]'; } $model = new $diffAttr->model_name(); $html .= '<div>' . Yii::t('Diff', 'Update {name}{attribute} from "{old}" to "{new}"', array('{name}' => Yii::t('Diff', $diffAttr->model_name) . '(' . $name . ')', '{attribute}' => $model->getAttributeLabel($diffAttr->attribute), '{old}' => $diffAttr->old, '{new}' => $diffAttr->new)) . '</div>'; } } }
public static function getJobTitle() { $jobTitle = Job::model()->findAll(); $title = array(); if ($jobTitle != null) { foreach ($jobTitle as $jt) { $title[] = $jt->title; } } return $title; }
?> <span><a href="<?php echo $this->createUrl('euniversity'); ?> " id="cuniversity" onclick="showAddress(this.href);return false;">修改</a></span> <?php echo $form->error($model, 'university'); ?> </div> <hr class="space" /> <div class="row"> <?php echo $form->labelEx($model, 'job'); ?> <span id="jobHolder"><?php echo Job::model()->getJobName($model->job); ?> </span> <?php echo $form->hiddenField($model, 'job', array('size' => 20, 'maxlength' => 20, 'class' => 'span-9 poshy', 'title' => '你的职业')); ?> <span><a href="<?php echo $this->createUrl('ejob'); ?> " id="cjob" onclick="showAddress(this.href);return false;">修改</a></span> <?php echo $form->error($model, 'job'); ?> </div> <hr class="space" /> <div class="row">
public function actionFile($id) { /** * @var $file File * @var $job Job */ if ($id == intval($id) . '') { $job = Job::model()->with(array('files', 'task'))->findByPk($id); if ($job) { if ($job->task->group_id == $this->_user()->group_id || $job->organization_id == $this->_user()->organization_id || $this->_user()->role == User::ROLE_SUPER_ADMIN || $this->_user()->role == User::ROLE_ADMIN) { if (count($job->files) == 1) { return $this->downloadFile($job->files[0]); } if (count($job->files) > 1) { return $this->redirect(Yii::app()->createUrl('task/job', array('id' => $job->id))); } } else { return $this->cannotAccess(); } } } else { $file = File::model()->with(array('task', 'job'))->findByAttributes(array('realname' => $id)); if ($file) { $canAccess = $this->_user()->role == User::ROLE_SUPER_ADMIN || $this->_user()->role == User::ROLE_ADMIN; if ($file->job) { $job = $file->job; if ($canAccess || $job->task->group_id == $this->_user()->group_id || $job->organization_id == $this->_user()->organization_id) { return $this->downloadFile($file); } } elseif ($task = $file->task) { foreach ($task->jobs as $job) { if ($job->organization_id == $this->_user()->organization_id) { $canAccess = true; break; } } if ($canAccess || $task->group_id == $this->_user()->group_id) { return $this->downloadFile($file); } } return $this->cannotAccess(); } } $this->show404(); }
public function actionList() { // validate API key if (isset($_GET['key'])) { $key = $_GET['key']; } else { $this->_sendResponse(500, 'Error: Parameter <b>key</b> is missing'); Yii::app()->end(); } // this should be done against DB if ($key !== $this->API_KEY) { $this->_sendResponse(401, sprintf('Invalid API Key specified: <b>%s</b>', $key)); Yii::app()->end(); } // check if we have a range parameter if (!isset($_GET['range'])) { $this->_sendResponse(500, 'Error: Parameter <b>range</b> is missing'); Yii::app()->end(); } // grab range and convert to date $day_range = $_GET['range']; $start_date = new DateTime('now'); $date_interval = new DateInterval('P' . $day_range . 'D'); $start_date->sub($date_interval); $end_date = new DateTime('now'); // retrieve postings from DB that fall within specified date range $postings = Job::model()->find('post_date >= :startdate AND post_date <= :enddate AND active=1', array('startdate' => $start_date->format('Y-m-d H:i:s'), 'enddate' => $end_date->format('Y-m-d H:i:s'))); // check if we got results if (empty($postings)) { // no results $this->_sendResponse(200, sprintf('No active job postings found for the last <b>%s</b> day(s)', $day_range)); } else { // got results, JSON encode and send to client $this->_sendResponse(200, CJSON::encode($postings)); } }
public function actionCareerPathSync() { // using test URL retrieve mock json objects // here I would request a date range, since this script runs daily as a cron job // $request = Yii::app()->curl->run('http://www.json-generator.com/api/json/get/bRQiTpYSCq?indent=2'); $job_postings = CJSON::decode($request->getData()); // keep track of new jobs $new_jobs_count = 0; // check each object to see if it has been posted already: // criteria for duplicate jobs: // - same title, description and expiration date foreach ($job_postings as $job_posting) { // dissect scis job posting information $jp_id = $job_posting['ID']; $jp_postedTime = $job_posting['PostedTime']; $jp_expireTime = $job_posting['ExpireTime']; $jp_company = $job_posting['Company']; $jp_position = $job_posting['Position']; $jp_company_url = $job_posting['URL']; $jp_company_background = $job_posting['Background']; $jp_description = $job_posting['Description']; $jp_duties = $job_posting['Duties']; $jp_qualifications = $job_posting['Qualifications']; $jp_company_email = $job_posting['Email']; $jp_posted_by = $job_posting['PostedBy']; //$jp_posting_format = $job_posting['Format']; dont care about this, ask joshua // attempt to find user in database (by email) that corresponds to the job posting $user_found = User::model()->find('email=:jp_company_email', array(':jp_company_email' => $jp_company_email)); // if user not found in database, create a new 'dummy' user for this posting if (count($user_found) <= 0) { // user info (exclude first name and last name) $new_user = new User(); $new_user->email = $jp_company_email; $new_user->activated = 1; // activate their account, and force them to retreive password (if they ever want to login) // generate username from email $user_name = str_replace(array('@', '.'), '_', $jp_company_email); $new_user->username = $user_name; $new_user->FK_usertype = 2; // employer type $new_user->registration_date = new CDbExpression('NOW()'); $new_user->image_url = '/JobFair/images/profileimages/user-default.png'; // hash the password before storing it into the database $hasher = new PasswordHash(8, false); $new_user->password = $hasher->HashPassword($new_user->password); // add user to db $new_user->save(false); // user company info $cmpny_info = new CompanyInfo(); $cmpny_info->name = $jp_company; $cmpny_info->website = $jp_company_url; $cmpny_info->description = $jp_company_background; $cmpny_info->FK_userid = $new_user->id; // add company info to db $cmpny_info->save(false); // user basic info $basic_info = new BasicInfo(); $basic_info->about_me = $jp_posted_by; // ask professor about this mapping $basic_info->userid = $new_user->id; $basic_info->hide_phone = 1; $basic_info->allowSMS = 0; $basic_info->validated = 1; // add basic info to db $basic_info->save(false); } // we have a user, post under his/her account $current_user = isset($new_user) ? $new_user : $user_found; // check for duplicate postings $dup_entries = Job::model()->find("FK_poster=:poster AND " . "title=:title AND " . "deadline=:deadline AND " . "post_date=:post_date", array(':poster' => $current_user->id, ':title' => $jp_position, ':deadline' => date('Y-m-d H:i:s', strtotime($jp_expireTime)), ':post_date' => $jp_postedTime)); // duplicate entry, ignore if (count($dup_entries) > 0) { continue; } // no duplicates, add posting $new_job_posting = new Job(); $new_job_posting->FK_poster = $current_user->id; // need an account $new_job_posting->post_date = $jp_postedTime; $new_job_posting->title = $jp_position; $new_job_posting->deadline = date('Y-m-d H:i:s', strtotime($jp_expireTime)); $new_job_posting->description = $jp_description . $jp_duties . $jp_qualifications; $new_job_posting->type = 'CIS'; // know it was posted using this api $new_job_posting->compensation = ""; // not available from CIS $new_job_posting->posting_url = $jp_id; // post the job to db $new_job_posting->save(false); // skill match descripnt against database $decoded_desc = utf8_decode($new_job_posting->description); $decoded_desc = str_replace(array('/', ',', '.'), ' ', $decoded_desc); $description_words = explode(' ', $decoded_desc); // split into words $skill_order = 0; foreach ($description_words as $word) { // check database to see if current word is a skill $skill = Skillset::model()->find("name=:name", array(":name" => $word)); if ($skill) { // its a skill, map it to this posting on database $skill_map = new JobSkillMap(); $skill_map->jobid = $new_job_posting->id; $skill_map->skillid = $skill->id; $skill_map->ordering = $skill_order; $skill_order++; $skill_map->save(false); } } // all went good echo 'Success!'; } }
public function actionCareerpath() { // using test URL retrieve mock json objects // here I would request a date range, since this script runs daily as a cron job // $request = Yii::app()->curl->run('http://www.json-generator.com/api/json/get/cmztbPLWCq?indent=2'); $job_postings = CJSON::decode($request->getData()); // keep track of new jobs $new_jobs_count = 0; // check each object to see if it has been posted already: // criteria for duplicate jobs: // - same title, description and expiration date foreach ($job_postings as $job_posting) { // dissect job posting information $jp_id = $job_posting['ID']; $jp_postedTime = $job_posting['PostedTime']; $jp_expireTime = $job_posting['ExpireTime']; $jp_company = $job_posting['Company']; $jp_position = $job_posting['Position']; $jp_company_url = $job_posting['URL']; $jp_company_background = $job_posting['Background']; $jp_company_description = $job_posting['Description']; $jp_duties = $job_posting['Duties']; $jp_qualifications = $job_posting['Qualifications']; $jp_company_email = $job_posting['Email']; $jp_posted_by = $job_posting['PostedBy']; $jp_posting_format = $job_posting['Format']; $jp_type = $job_posting['PostingType']; $jp_website = $job_posting['website']; $jp_description = $job_posting['description']; $jp_title = $job_posting['title']; $jp_expdate = strtotime($job_posting['expiration_date']); $jp_compensation = $job_posting['compensation']; $jp_contact = $job_posting['contact']; $jp_jobtype = $job_posting['type']; // attempt to find duplicate in database: // since we are using a single user to post for SCIS CareerPath // then we can easily search through the job postings by this user $posting_user = User::model()->find("username=:username", array(':username' => 'fiuscis')); $dup_entries = Job::model()->find("FK_poster=:poster AND " . "title=:title AND " . "deadline=:deadline AND " . "description=:description", array(':poster' => $posting_user->id, ':title' => $jp_title, ':deadline' => date('Y-m-d H:i:s', $jp_expdate), ':description' => $jp_description)); if (count($dup_entries) > 0) { // duplicate found, skip it continue; } // no duplicates found, add job posting to database! $new_job_posting = new Job(); $new_job_posting->FK_poster = $posting_user->id; $new_job_posting->post_date = date('m/d/Y'); $new_job_posting->title = $jp_title; $new_job_posting->deadline = date('Y-m-d H:i:s', $jp_expdate); $new_job_posting->description = $jp_description; $new_job_posting->type = $jp_jobtype; $new_job_posting->compensation = $jp_compensation; $new_job_posting->save(false); $new_jobs_count++; } // crontab email message if ($new_jobs_count > 0) { echo date('m/d/Y H:i:s') . ' -> ' . $new_jobs_count . ' new job(s) have been imported from FIU SCIS CareerPath'; } }
public function run($args) { date_default_timezone_set('America/New_York'); $new_active_user = false; $nau_info = array(); $interval = 0; $send_empl = false; $switches = array("-u", "-e", "-i", "-h", "-m", "--help"); if (count($args) > 0) { for ($j = 0; $j < count($args); $j++) { if (in_array($args[$j], $args)) { switch ($args[$j]) { case "-u": $new_active_user = true; $nau_info['username'] = $args[$j + 1]; break; case "-m": $send_empl = true; break; case "-e": $new_active_user = true; $nau_info['email'] = $args[$j + 1]; break; case "-i": $interval = intval($args[$j + 1]); if (!in_array($interval, array(1, 7, 30))) { echo "[INVALID] Invalid interval value.\n"; $this->getHelp(); } break; case "-h": case "--help": $this->getHelp(); } } } } else { $this->getHelp(); } $now = date('Y-m-d H:i:s'); $date = date('Y-m-d'); $time = date('H:i:s'); $pasttime = $date . " " . date('H:i:s', strtotime("-30 min")); $matchnotification = MatchNotification::model()->findBySql("SELECT * FROM match_notification ORDER BY date_modified DESC limit 1"); $notfication_status = intval($matchnotification['status']); if ($notfication_status) { if ($new_active_user) { if (isset($nau_info['email']) && $nau_info['email'] != '' && isset($nau_info['username']) && $nau_info['username'] != '') { $jobs = Job::model()->findAll("active = 1"); $student = User::model()->find("username=:username", array(':username' => $nau_info['username'])); if ($student['username'] != null && $student['looking_for_job'] == 1 && $student['job_notification'] == 1) { $message = ""; $results = Yii::app()->jobmatch->getStudentMatchJobs(intval($student['id']), $jobs); if (count($results) > 0) { $message .= $this->buildTable('student', $results, $interval); User::sendEmail($student->email, "Virtual Job Fair | Job Matches", "Your Job Matches", $message); } return; } return; } return; } echo "[*] Job Matching Notification is ON\n"; $jobs = Job::model()->findAll("post_date > '{$pasttime}' AND active = 1"); #Add fecthing for user not active or validated $students = User::model()->findAll("FK_usertype = 1 AND job_notification = 1 AND looking_for_job = 1 AND activated = 1 AND disable = 0"); echo "\n::::::::::::::::::::\n[*] Matching jobs for students.\n"; foreach ($students as $st) { $message = ""; $results = array(); $saved_queries = SavedQuery::model()->findAll("FK_userid=:id AND active = 1", array(':id' => $st->id)); if (count($saved_queries) > 0 && $interval == intval($st->job_int_date) && $interval > 0) { $word = "query"; if (count($saved_queries) > 1) { $word = "queries"; } $message .= "Jobs matching your custom {$word}:<br/>"; foreach ($saved_queries as $query) { $results = Yii::app()->jobmatch->customJobSearch(html_entity_decode($query->query), $query->location); $message .= "Matches for query [{$query->query}]<br/>"; $message .= $this->buildTable('student_custom', $results, $interval); $message .= "<br/>"; } echo "[*] Sending custom search job results email to: {$st->email}\n"; User::sendEmail($st->email, "Virtual Job Fair | Job Matches", "Your Job Matches", $message); } else { if ($interval == intval($st->job_int_date) && $interval > 0) { $results = Yii::app()->jobmatch->getStudentMatchJobs($st->id, $jobs); if (count($results) > 0) { $message .= "The following jobs matched with your skills:<br/>"; $message .= $this->buildTable('student', $results, $interval); echo "[*] Sending skill matches results email to: {$st->email}\n"; User::sendEmail($st->email, "Virtual Job Fair | Job Matches", "Your Job Matches", $message); } } } } if ($send_empl) { $count = 1; foreach ($jobs as $job) { $message = ""; $job_poster_info = User::model()->findByPk($job->FK_poster); if (!$job_poster_info->job_notification) { echo "[*] Employer {$job_poster_info->username} has notifications OFF\n"; continue; } $job_poster_email = $job_poster_info->email; echo "\n[*] Working on jobid {$job->id} : {$job->title}\n"; $results = Yii::app()->jobmatch->getJobStudentsMatch($job->id); if (!isset($results['students']) || count($results) == 0 || $results['students'] == NULL) { echo "[*] No student matches found for: " . $job->title . "\n"; continue; } $message .= "The following students matched this job posting:<br/>"; $table = $this->buildTable('', $results, $interval); $message .= $table; echo $this->replaceTags($message); echo "[*] Sending email to {$job_poster_email}\n"; User::sendEmail($job_poster_email, "Virtual Job Fair | Job Matches", "Job Matches for {$job->title}", $message); } } return 0; } else { echo "[*] Job Matching Notification is OFF\n"; } }
public function cascade_delete() { $id = $this->id; // delete basic info mappings $basic_info = BasicInfo::model()->findByAttributes(array('userid' => $id)); if (isset($basic_info)) { $basic_info->delete(); } // delete company info mapping $comp_info = CompanyInfo::model()->findByAttributes(array('FK_userid' => $id)); if (isset($comp_info)) { $comp_info->delete(); } // delete sms mappings $sms_mappings = SMS::model()->findAll("sender_id=:id OR receiver_id=:id ", array(':id' => $id)); foreach ($sms_mappings as $sms_mapping) { $sms_mapping->delete(); } // delete education mapping $edu_mappings = Education::model()->findAllByAttributes(array('FK_user_id' => $id)); foreach ($edu_mappings as $edu_mapping) { $edu_mapping->delete(); } // delete skills mappings $skills_mappings = StudentSkillMap::model()->findAllByAttributes(array('userid' => $id)); foreach ($skills_mappings as $skills_mapping) { $skills_mapping->delete(); } // delete application mappings $app_mappings = Application::model()->findAllByAttributes(array('userid' => $id)); foreach ($app_mappings as $app_mapping) { $app_mapping->delete(); } // delete jobs mappings $job_mappings = Job::model()->findAllByAttributes(array('FK_poster' => $id)); foreach ($job_mappings as $job_mapping) { $job_mapping->cascade_delete(); } $this->delete(); }
public function customJobSearch($query = null, $city = null) { if ($query != null) { $job = Job::model()->findAllBySql("SELECT * FROM job WHERE MATCH(type,title,description,comp_name) AGAINST ('%" . $query . "%' IN BOOLEAN MODE) AND active = '1'"); $indeed = $this->indeed($query, $city); if (intval($indeed['totalresults']) == 0) { $indeed = array(); } $cb = $this->careerBuilder($query, $city); if (intval($cb[0]) == 0) { $cb = array(); } return array('careerpath' => $job, 'indeed' => $indeed, 'careerbuilder' => $cb); } }
/** * @param $organizationId * @return Job */ public function getJobOfOrganization($organizationId) { return Job::model()->findByAttributes(array('task_id' => $this->id, 'organization_id' => $organizationId)); }
public function actionRss() { // disabling web log foreach (Yii::app()->log->routes as $route) { if ($route instanceof CWebLogRoute) { $route->enabled = false; } } Yii::import('ext.feed.*'); $feed = new EFeed(); $feed->title = Yii::app()->name . ' | ' . Yii::t('jobModule.common', 'Offres demplois'); $feed->description = Yii::app()->name . ' | ' . Yii::t('jobModule.common', 'Offres demplois'); $feed->addChannelTag('language', Yii::app()->language); $feed->addChannelTag('pubDate', date(DATE_RSS, time())); $feed->addChannelTag('link', $this->createAbsoluteUrl('index')); if ($jobs = Job::model()->findAll(array('order' => 'publication_date DESC', 'limit' => 25, 'condition' => "publication_date <= '" . date('Y-m-d H:i:s') . "' AND active = 1"))) { foreach ($jobs as $job) { $item = $feed->createNewItem(); $item->title = $job->title; $item->link = $this->createAbsoluteUrl('/job/default/detail', array('t' => $job->title_url)); $item->date = $job->publication_date; $type = ''; switch ($job->type) { case '1': $type = "Permanent"; break; case '2': $type = "Temps partiel"; break; case '3': $type = "Saisonnier"; break; } $item->description = "\n\t\t\t\t\t<p>\n\t\t\t\t\t\tType de l’emploi : " . $type . "<br/>\n\t\t\t\t\t\tDate de début : " . ((isset($job->start_date) and $job->start_date != '0000-00-00') ? Helper::formatDate($job->start_date, "reg") : Yii::t('jobModule.common', 'Indéterminée')) . "<br/>\n\t\t\t\t\t\tDate et heure limite pour postuler : " . (isset($job->postulation_end_date) ? substr(Helper::formatDate($job->postulation_end_date, "reg+time"), 0, -3) : Yii::t('jobModule.common', 'Indéterminée')) . "\n\t\t\t\t\t</p>\t\t\n\t\t\t\t" . strip_tags($job->description); $feed->addItem($item); } } $feed->generateFeed(); Yii::app()->end(); }
<div class="titlebox">MOST WANTED SKILLS</div><br><br> <ul> <?php foreach ($mostwanted as $mmm) { ?> <li class="mostwantedskills"><?php echo $mmm->name; $thecount = 0; /*$criteria1= new CDbCriteria(); $criteria1=array( 'select'=>'count(*) as count', 'condition'=>" skillid=".$mmm->id."", );*/ $sk = JobSkillMap::model()->findAllByAttributes(array('skillid' => $mmm->id)); foreach ($sk as $sk2) { $thejob = Job::model()->findByPk($sk2->jobid); if ($thejob->active) { $thecount++; } } ?> <a class="mostwantedtext" href="/JobFair/index.php/home/Search2/?key=<?php echo $mmm->name; ?> "><?php echo " - [ " . $thecount . " ] Jobs"; ?> </a> </li> <?php }
public function actionIndex($args = array()) { Yii::app()->db->createCommand('SET AUTOCOMMIT=0')->execute(); $this->checkLongExecuted(); //READ COMMITTED отличается от изоляции по умолчанию (REPEATABLE READ), тем, //что в REPEATABLE READ второй селект вернёт данные те же что и в первом (не смотря на то, //что данные были закоммичены первой транзакцией ), //т.е. у REPEATABLE READ полная согласованноть чтения данных $this->setIsolationLevel('READ COMMITTED'); $candidateCriteria = new CDbCriteria(array('order' => 't.priority DESC, RAND()')); $db = Yii::app()->db; $c = 0; $time = time(); while (1) { $transaction = $db->beginTransaction(); try { $curJob = Job::model()->resetScope()->available(self::MAX_COUNT_FAILURES, $time)->find($candidateCriteria); //Нет задач, выходим if ($curJob === null) { break; } } catch (CDbException $e) { //Если запись залочена другой транзакцией, то пропускаем if ($e->getCode() == self::ERROR_CODE_LOCK_WAIT_TIMEOUT) { $transaction->rollback(); $candidateCriteria->addCondition('t.id_job != ' . $curJob->id_job); continue; } throw $e; } //Если время выполнения задачи еще не подошло, то пропускаем if (!$curJob->getExecutionTimeHasCome($time)) { $transaction->rollback(); continue; } //Если достигли максимального количества ошибок, исключаем эту задачу if ($curJob->failures == self::MAX_COUNT_FAILURES) { $transaction->rollback(); $candidateCriteria->addCondition('t.id_job != ' . $curJob->id_job); $this->log($curJob->name, $curJob->failures); continue; } elseif ($curJob->failures == 1) { $this->log($curJob->name, $curJob->failures); } //Увеличиваем счетчик ошибок и сохраняем //для того чтобы, если скрипт задачи упадет, //то при следующем запуске планировщика мы об этом узнаем /*if ($curJob->is_null_start_date) { $curJob->start_date = null; } else { $curJob->start_date = time(); }*/ $curJob->failures++; $curJob->save(false); $transaction->commit(); $this->setIsolationLevel('REPEATABLE READ'); //Создаем и запускаем задачу $schedulerJob = $this->createJob($curJob); if (!$schedulerJob instanceof SchedulerJob) { throw new ErrorException('Класс задачи ' . $curJob->name . ' ' . get_class($schedulerJob) . ' должен расширять класс SchedulerJob.'); } $result = (int) $schedulerJob->run(); $this->setIsolationLevel('READ COMMITTED'); $interval = $curJob->interval_value; //Если вернулся код ошибки if ($result !== SchedulerJob::RESULT_OK) { $interval = $curJob->error_repeat_interval; } else { $curJob->failures = 0; } $curJob->last_start_date = $curJob->next_start_date; $curJob->next_start_date += $interval; if ($curJob->next_start_date < $time) { $newDate = HDate::getTimestampOnBeginning($time, HDate::BEGINNING_DAY); $timeParts = getdate($curJob->next_start_date); $newDate += $timeParts['hours'] * 3600 + $timeParts['minutes'] * 60 + $timeParts['seconds']; if ($newDate - $interval > $time) { $step = floor(($newDate - $time) / $interval); $newDate = $newDate - $step * $interval; } if ($newDate < $time) { $step = floor(($time - $newDate) / $interval) + 1; $newDate = $newDate + $step * $interval; } $curJob->last_start_date = $time; $curJob->next_start_date = $newDate; } //сохраняем задачу $transaction = $db->beginTransaction(); if (empty($curJob->first_start_date)) { $curJob->first_start_date = $curJob->last_start_date; } $curJob->start_date = null; $curJob->save(false); $transaction->commit(); } }
public function userAllTasks(User $user) { $criteria = new CDbCriteria(); $criteria->alias = 'job'; $criteria->select = 'task.user_id as task_user_id, task.name as name, task.number as number, task.priority as priority, user.name as user_name, job.*'; $criteria->join = 'LEFT JOIN ' . Task::model()->tableName() . ' on task.id = job.task_id LEFT JOIN ' . User::model()->tableName() . ' on user.id = task.user_id'; $criteria->compare('job.organization_id', $user->organization_id); if ($this->number) { $criteria->compare('task.number', $this->number); } if ($this->period_id) { $criteria->compare('task.period_id', $this->period_id); } if ($this->priority) { $criteria->compare('task.priority', $this->priority); } if ($this->status) { $criteria->compare('job.status', $this->status); } return new CActiveDataProvider(Job::model(), array('criteria' => $criteria, 'sort' => array('defaultOrder' => 'task.period_id DESC, job.status ASC, task.priority DESC', 'route' => "task/user", 'attributes' => array('priority' => array('asc' => 'task.priority', 'desc' => 'task.priority DESC'), 'name' => array('asc' => 'task.name', 'desc' => 'task.name DESC'), 'number' => array('asc' => 'task.number', 'desc' => 'task.number DESC'), 'user_name' => array('asc' => 'user.name', 'desc' => 'user.name DESC'), '*')), 'pagination' => array('pageSize' => 20, 'route' => "task/user"))); }
public function actionSearch() { // flag to display results in home $flag = 2; $bool = false; $keyword = ""; $result = array(); // words to search for if (isset($_GET['keyword'])) { $keyword = $_GET['keyword']; } // array to contain the results of the search $results = array(); $result2 = array(); // there are words to search if ($keyword != null) { // operators for boolean search mode if (preg_match('/("|-)/', $keyword)) { $bool = true; } if ($bool == true) { // search FULLTEXT IN BOOLEAN MODE to allow for operations such as ' ""' and ' - ' $results = Job::model()->findAllBySql("SELECT * FROM job WHERE MATCH(type,title,description,comp_name) AGAINST ('%" . $keyword . "%' IN BOOLEAN MODE) AND active = '1';"); } if ($bool == false) { // search FULLTEXT IN NATURAL LANGUAGE MODE $results = Job::model()->findAllBySql("SELECT * FROM job WHERE MATCH(type,title,description,comp_name) AGAINST ('%" . $keyword . "%' IN NATURAL LANGUAGE MODE) AND active = '1';"); //print_r ($result); } // location will be set to "Miami, Florida" $loc = "Miami, Florida"; // call indeed API to get jobs query by user $result = $this->indeed($keyword, $loc); if ($result['totalresults'] == 0) { $result = ""; } $result2 = $this->careerBuilder($keyword, $loc); if ($result2[0] == 0) { $result2 = ""; } } // get user if (isset($_GET['user'])) { $username = $_GET['user']; } else { $username = Yii::app()->user->name; } // pass user $user = User::model()->find("username=:username", array(':username' => $username)); // pass skills $skills = Skillset::getNames(); // pass companies $companies = CompanyInfo::getNames(); //print_r($result); return; // render search results, user, skills, companies and flag to job/home $this->render('home', array('result' => $result, 'cbresults' => $result2, 'jobs' => $results, 'user' => $user, 'companies' => $companies, 'skills' => $skills, 'flag' => $flag)); }
display:inline-block; border:1px solid grey; padding:1px; margin:2px; } </style> <div id="regionContent"> <div id="regionNav"> <a href="<?php echo $this->createUrl('/archiver/ejob'); ?> " onclick="$('#cjob').trigger('click');return false;">职业</a> </div> <div id="regionNode"> <?php echo Job::model()->generateJobLinks(0, '/job/jobinfo', array('onclick' => 'eaddress($(this));return false;'), false); ?> </div> <div id="regionAdd" class="row hide"> <label>新添职业</label> <input type="text" id="schoolField"> <span class="button"><a href="javascript:void();" onclick="collegeAdd();">提交</a></span> <a href="javascript:void();" onclick="$(this).parent().hide();">收起</a> </div> </div> <input type="hidden" id="lastInputRegion" value="0" /> <script type="text/javascript"> <!-- function eaddress(object) {
<?php $form = $this->beginWidget('CActiveForm', array('id' => 'scheduled-job-form', 'enableAjaxValidation' => false)); ?> <p class="note">Fields with <span class="required">*</span> are required.</p> <?php echo $form->errorSummary($model); ?> <div class="row"> <?php echo $form->labelEx($model, 'job_id'); ?> <?php echo $form->dropDownList($model, 'job_id', Job::model()->getOptions()); ?> <?php echo $form->error($model, 'job_id'); ?> </div> <div class="row"> <?php echo $form->labelEx($model, 'params'); ?> <?php echo $form->textArea($model, 'params', array('rows' => 6, 'cols' => 50)); ?> <?php echo $form->error($model, 'params');