public function uniqueSkill($attribute, $params) { if ($this->isNewRecord) { $dup_skill = Skillset::model()->find("name=:name", array(':name' => $this->name)); } if (isset($dup_skill)) { $this->addError($attribute, 'Skill name already exists, please select a different one!'); } }
<td><?php $educ = Education::model()->findByAttributes(array('FK_user_id' => $js->id)); $school = ""; if ($educ) { $school = School::model()->findByAttributes(array('id' => $educ->FK_school_id))->name; } echo $school; ?> </td> <td class="info1"> <?php $temp = StudentSkillMap::model()->findAllByAttributes(array('userid' => $js->id)); foreach ($temp as $one) { echo Skillset::model()->findByAttributes(array('id' => $one->skillid))->name . " - "; } ?> </td> </tr> <?php } } ?> </tbody> </table> <?php } else { ?>
echo Yii::app()->dateFormatter->format('MM/dd/yyyy', $jobs[$i]->post_date); ?> </td> <!-- <td>--><?php //echo Yii::app()->dateFormatter->format('MM/dd/yyyy', $jobs[$i]->deadline); ?> <!--</td>--> <td><?php echo $jobs[$i]->compensation; ?> </td> <td> <?php $temp = JobSkillMap::model()->findAllByAttributes(array('jobid' => $jobs[$i]->id)); foreach ($temp as $one) { $cur_skill = Skillset::model()->findByAttributes(array('id' => $one->skillid))->name; $this->widget('bootstrap.widgets.TbLabel', array('type' => 'default', 'label' => strtolower($cur_skill))); echo ' '; } if (count($temp) <= 0) { $this->widget('bootstrap.widgets.TbLabel', array('type' => 'inverse', 'label' => 'N/A')); } ?> </td> <td><?php echo "CareerPath"; ?> </td> </tr> <?php $i++;
/** * 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 Skillset the loaded model * @throws CHttpException */ public function loadModel($id) { $model = Skillset::model()->findByPk($id); if ($model === null) { throw new CHttpException(404, 'The requested page does not exist.'); } return $model; }
<br> <ul id="sortable"> <script> $(document).ready(function() { $(function() { $("#sortable").sortable(); $("#sortable").disableSelection(); }); }); </script> </ul> <br/> <?php $this->widget('zii.widgets.jui.CJuiAutoComplete', array('name' => 'addskillname', 'id' => 'addskillname', 'source' => Skillset::getNames(), 'htmlOptions' => array())); ?> <br> <?php $this->widget('bootstrap.widgets.TbButton', array('label' => 'Add Skill', 'type' => 'primary', 'htmlOptions' => array('data-toggle' => 'modal', 'data-target' => '#myModal', 'style' => 'width: 120px', 'id' => "addskill", 'style' => "margin-top: 5px; margin-bottom: 5px;width: 120px;"))); ?> </div> </div> </div> <script> $.MyNamespace={ submit : "true"
public static function getJobBySkill() { $skill = Skillset::model()->findAll(); $skills = array(); if ($skill != null) { foreach ($skill as $jk) { $skills[] = $jk->name; } } return $skills; }
?> <fieldset> <p class="note">Fields with <span class="required">*</span> are required.</p> <?php echo $form->errorSummary($model); ?> <label class="required" for="Skillset_name"> Name <span class="required">*</span> </label> <?php $skills_list = Skillset::model()->getNames(); $skill_name = $model->name; $this->widget('bootstrap.widgets.TbTypeahead', array('name' => 'Skillset[name]', 'id' => 'Skillset_name', 'value' => $skill_name, 'options' => array('source' => $skills_list, 'items' => 6, 'matcher' => "js:function(item) {\n return ~item.toLowerCase().indexOf(this.query.toLowerCase());\n }"))); ?> </fieldset> <div class="form-actions"> <?php $this->widget('bootstrap.widgets.TbButton', array('type' => 'primary', 'buttonType' => 'submit', 'label' => $model->isNewRecord ? 'Create' : 'Save')); ?> <?php $this->widget('bootstrap.widgets.TbButton', array('label' => 'Cancel', 'htmlOptions' => array('onclick' => 'js:document.location.href="' . Yii::app()->createAbsoluteUrl("Skillset/index") . '"')));
public function actionPost() { // check if api is enabled $api_status = ApiStatus::getFirst(); if (!$api_status->isApiOn()) { $this->_sendResponse(200, 'API access has been disabled. Contact VJF administrator.'); } // perform routine auth $this->authenticate(); // api key is valid, now parse the json object $request_obj = Yii::app()->request->getRawBody(); $job_posting = CJSON::decode($request_obj); if (!isset($job_posting) || is_null($job_posting)) { $this->_sendResponse(500, 'Empty job posting body.'); } // dissect scis job posting information $jp_id = $job_posting['URL']; //$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)); $dup_entries = Job::model()->find("posting_url=:job_url", array(':job_url' => $jp_id)); // duplicate entry, ignore if (count($dup_entries) > 0) { $new_job_posting = $dup_entries; $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; $new_job_posting->comp_name = $jp_company; // post the job to db $new_job_posting->save(false); // send response and stop application $this->_sendResponse(400, 'Job entry has been updated in the database.'); } // 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; $new_job_posting->comp_name = $jp_company; // 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 $this->_sendResponse(200); }
if (!User::isStudent(Yii::app()->user->name) & !Yii::app()->user->isGuest) $home = '/home/employerhome'; else if (User::isStudent(Yii::app()->user->name)) $home = '/home/studenthome'; else $home = '/site/index'; */ ?> <?php $search = ""; if (User::isCurrentUserAdmin(Yii::app()->user->name)) { $home = '/home/adminhome'; } else { if (User::isCurrentUserEmployer(Yii::app()->user->name)) { $home = '/home/employerhome'; $search = '<form class="navbar-search pull-left" method="post" action="/JobFair/index.php/home/employersearch" >' . $this->widget('zii.widgets.jui.CJuiAutoComplete', array('name' => 'skillkeyword', 'source' => Skillset::getNames(), 'htmlOptions' => array('class' => 'search-query span2', 'placeholder' => 'Search Students by Skill')), true) . '<button type="submit" style="background-color:transparent ; border:0" > <img src="/JobFair/images/ico/Search-icon.png" height="25" width="25" style="margin:1px 0 0 5px"></button> </form>'; } else { if (User::isCurrentUserStudent(Yii::app()->user->name)) { $home = '/home/studenthome'; $search = '<form class="navbar-search pull-left" method="get" action="/JobFair/index.php/job/search">' . $this->widget('zii.widgets.jui.CJuiAutoComplete', array('name' => 'keyword', 'id' => 'keyword', 'value' => $_GET['keyword'], 'htmlOptions' => array('class' => 'search-query span2', 'style' => 'width: 250px', 'placeholder' => 'Search by Position, Skills, Company, Type')), true) . '<button type="submit" style="background-color:transparent ; border:0" > <img src="/JobFair/images/ico/Search-icon.png" height="25" width="25" style="margin:1px 0 0 5px"></button> </form>'; } else { $home = '/site/index'; } } } ?>
public function indeed($query, $city) { $loc = $city; $result = array(); // to call Indeed API require_once getcwd() . '/indeed/indeed.php'; // Indeed publisher number 5595740829812660 $client = new Indeed("5595740829812660"); // parameters pass to indeed API $params = array("q" => $query, "l" => $loc, "limit" => 25, "userip" => '131.94.128.231', "useragent" => "Mozilla/5.0 (Macintosh; Intel Mac OS X 10.5; rv:12.0) Gecko/20100101 Firefox/12.0"); // search results from indeed.com $results = $client->search($params); // get array of jobs $result = $this->xmlToArray($results); // convert snippets to skills $snippets = array(); $j = 0; // if there are results from indeed.com API if ($result['totalresults'] > 0) { if ($result['totalresults'] == 1) { //print_r($result);die; $snippets[$j] = strtolower($result['results']['result']['snippet']); $snippets[$j] = utf8_decode($snippets[$j]); //$snippets[$j] = iconv(mb_detect_encoding($snippets[$j], mb_detect_order(), true), "ISO-8859-1//IGNORE", $snippets[$j]); $result['results']['result']['snippet'] = ''; } else { for ($i = 0; $i < count($result['results']['result']); $i++, $j++) { $snippets[$j] = strtolower($result['results']['result'][$i]['snippet']); $snippets[$j] = utf8_decode($snippets[$j]); // $snippets[$j] = iconv(mb_detect_encoding($snippets[$j], mb_detect_order(), true), "ISO-8859-1//IGNORE", $snippets[$j]); $result['results']['result'][$i]['snippet'] = ''; } } if ($result['totalresults'] == 1) { // put back into results snippet as skill words // check each snipped for skills $cur_snippet = $snippets[0]; $cur_snippet = str_replace(array('.', '/', ',', '.'), ' ', $cur_snippet); $cur_snippet_words = explode(' ', $cur_snippet); // split into words foreach ($cur_snippet_words as $snippet_word) { // check database to see if current word is a skill $skill = Skillset::model()->find("LOWER(name)=:name", array(":name" => $snippet_word)); if ($skill) { $cur_skills = strtolower($result['results']['result']['snippet']); if (!strstr($cur_skills, $snippet_word)) { $result['results']['result']['snippet'] .= ucfirst($snippet_word) . ' '; } } } } else { // put back into results snippet as skill words for ($i = 0; $i < count($result['results']['result']); $i++) { // check each snipped for skills $cur_snippet = $snippets[$i]; $cur_snippet = str_replace(array('.', '/', ',', '.'), ' ', $cur_snippet); $cur_snippet_words = explode(' ', $cur_snippet); // split into words foreach ($cur_snippet_words as $snippet_word) { // check database to see if current word is a skill $skill = Skillset::model()->find("LOWER(name)=:name", array(":name" => $snippet_word)); if ($skill) { // append current word (skill) to results snippet (check duplicates) $cur_skills = strtolower($result['results']['result'][$i]['snippet']); if (!strstr($cur_skills, $snippet_word)) { $result['results']['result'][$i]['snippet'] .= ucfirst($snippet_word) . ' '; } } } } } } return $result; }
public function actionRegisterLinkedIn() { // if user canceled, redirect to home page if (isset($_GET['oauth_problem'])) { $problem = $_GET['oauth_problem']; if ($problem == 'user_refused') { $this->redirect('/JobFair/index.php'); } } if (!isset($_SESSION)) { session_start(); } //edit by Manuel making the link dynamic, using Yii $config['base_url'] = 'http://' . Yii::app()->request->getServerName() . '/JobFair/index.php/user/auth1.php'; $config['callback_url'] = 'http://' . Yii::app()->request->getServerName() . '/JobFair/index.php/user/RegisterLinkedIn'; $config['linkedin_access'] = '2rtmn93gu2m4'; $config['linkedin_secret'] = 'JV0fYG9ls3rclP8v'; include_once Yii::app()->basePath . "/views/user/linkedin.php"; # First step is to initialize with your consumer key and secret. We'll use an out-of-band oauth_callback $linkedin = new LinkedIn($config['linkedin_access'], $config['linkedin_secret'], $config['callback_url']); //$linkedin->debug = true; if (isset($_REQUEST['oauth_verifier'])) { $_SESSION['oauth_verifier'] = $_REQUEST['oauth_verifier']; $linkedin->request_token = unserialize($_SESSION['requestToken']); $linkedin->oauth_verifier = $_SESSION['oauth_verifier']; $linkedin->getAccessToken($_REQUEST['oauth_verifier']); $_SESSION['oauth_access_token'] = serialize($linkedin->access_token); header("Location: " . $config['callback_url']); exit; } else { $linkedin->request_token = unserialize($_SESSION['requestToken']); $linkedin->oauth_verifier = $_SESSION['oauth_verifier']; $linkedin->access_token = unserialize($_SESSION['oauth_access_token']); } # You now have a $linkedin->access_token and can make calls on behalf of the current member $xml_response = $linkedin->getProfile("~:(id,first-name,last-name,headline,picture-url,industry,email-address,languages,phone-numbers,skills,educations,location:(name),positions,picture-urls::(original))"); $data = simplexml_load_string($xml_response); // get user by linkedinid $model = new User(); $user = User::model()->findByAttributes(array('linkedinid' => $data->id)); // check if user exits in database, if so login if ($user != null) { if ($user->disable != 1) { $identity = new UserIdentity($user->username, ''); if ($identity->authenticateOutside()) { Yii::app()->user->login($identity); } $this->redirect("/JobFair/index.php/home/studenthome"); return; } else { $this->redirect("/JobFair/index.php/site/page?view=disableUser"); return; } // register } else { // print "<pre>"; print_r('user is null');print "</pre>"; // check that there is no duplicate user if so link to that account $duplicateUser = User::model()->findByAttributes(array('email' => $data->{'email-address'})); if ($duplicateUser != null) { // get username and link the accounts $username = $duplicateUser->username; $user = User::model()->find("username=:username", array(':username' => $username)); $user->linkedinid = $data->{'id'}; $user->save(false); $user_id = $user->id; // ------------------BASIC INFO--------------- $basic_info = null; $basic_info = BasicInfo::model()->findByAttributes(array('userid' => $user_id)); if ($basic_info == null) { $basic_info = new BasicInfo(); } $basic_info->userid = $user_id; $basic_info->save(false); // ------------------BASIC INFO ----------------- // -----------------EDUCATION ---------------------- // get number of educations to add $educ_count = $data->educations['total']; // delete current educations $delete_educs = Education::model()->findAllByAttributes(array('FK_user_id' => $user_id)); foreach ($delete_educs as $de) { $de->delete(); } // add educations for ($i = 0; $i < $educ_count; $i++) { // first check if current education is in school table. if not, add it $current_school_name = $data->educations->education[$i]->{'school-name'}; $school_exists = School::model()->findByAttributes(array('name' => $current_school_name)); if ($school_exists == null) { $new_school = new School(); $new_school->name = $current_school_name; $new_school->save(); $school_id = School::model()->findByAttributes(array('name' => $current_school_name))->id; } else { $school_id = $school_exists->id; } // now ready to add new education $new_educ = new Education(); $new_educ->degree = $data->educations->education[$i]->degree; $new_educ->major = $data->educations->education[$i]->{'field-of-study'}; // $model->admission_date=date('Y-m-d',strtotime($model->admission_date)); $new_educ->graduation_date = date('Y-m-d', strtotime($data->educations->education[$i]->{'end-date'}->year)); // print "<pre>"; print_r($new_educ->graduation_date);print "</pre>";return; $new_educ->FK_school_id = $school_id; $new_educ->FK_user_id = $user_id; $new_educ->additional_info = $data->educations->education[$i]->notes; $new_educ->save(false); } // -----------------EDUCATION ---------------------- // -----------------EXPERIENCE ------------------- // get number of educations to add $pos_count = $data->positions['total']; // delete current positions $delete_pos = Experience::model()->findAllByAttributes(array('FK_userid' => $user_id)); foreach ($delete_pos as $de) { $de->delete(); } for ($i = 0; $i < $pos_count; $i++) { $new_pos = new Experience(); $new_pos->FK_userid = $user_id; $new_pos->company_name = $data->positions->position[$i]->company->name; $new_pos->job_title = $data->positions->position[$i]->title; $new_pos->job_description = $data->positions->position[$i]->summary; $temp_start_date = $data->positions->position[$i]->{'start-date'}->month . '/01/' . $data->positions->position[$i]->{'start-date'}->year; $new_pos->startdate = date('Y-m-d', strtotime($temp_start_date)); if ($data->positions->position[$i]->{'is-current'} == 'true') { $new_pos->enddate = ''; } else { $temp_end_date = $data->positions->position[$i]->{'end-date'}->month . '/01/' . $data->positions->position[$i]->{'end-date'}->year; $new_pos->enddate = date('Y-m-d', strtotime($temp_end_date)); } $new_pos->city = ''; $new_pos->state = ''; $new_pos->save(false); } // -----------------EXPERIENCE ------------------- // ----------------------SKILLS---------------------- // get number of educations to add $linkedin_skill_count = $data->skills['total']; for ($i = 0; $i < $linkedin_skill_count; $i++) { // check if skill exists in skill set table, if not, add it to skill set table if (Skillset::model()->findByAttributes(array('name' => $data->skills->skill[$i]->skill->name)) == null) { $new_skill = new Skillset(); $new_skill->name = $data->skills->skill[$i]->skill->name; $new_skill->save(false); //echo 'New Skill ' . $new_skill->attributes; } // check if student has that skill, if not add it to student-skill-map table if (StudentSkillMap::model()->findByAttributes(array('userid' => $user_id, 'skillid' => Skillset::model()->findByAttributes(array('name' => $data->skills->skill[$i]->skill->name))->id)) == null) { $new_sdnt_skill = new StudentSkillMap(); $new_sdnt_skill->userid = $user_id; $new_sdnt_skill->skillid = Skillset::model()->findByAttributes(array('name' => $data->skills->skill[$i]->skill->name))->id; $new_sdnt_skill->ordering = $i + 1; $new_sdnt_skill->save(false); echo 'New Skill for student' . $new_sdnt_skill->attributes; } } // ----------------------SKILLS---------------------- if ($duplicateUser->disable != 1) { $identity = new UserIdentity($duplicateUser->username, ''); if ($identity->authenticateOutside()) { Yii::app()->user->login($identity); } $mesg = "LinkedIn"; //get variables $mesg = "LinkedIn"; $phone = $data->{'phone-numbers'}->{'phone-number'}->{'phone-number'}; if ($phone != null) { $phone = strip_tags($data->{'phone-numbers'}->{'phone-number'}->{'phone-number'}->asXML()); } $city = $data->location->name; if ($city != null) { $city = strip_tags($data->location->name->asXML()); } $state = ''; $about_me = $data->headline; if ($about_me != null) { $about_me = strip_tags($data->headline->asXML()); } $picture = $data->{'picture-urls'}->{'picture-url'}[0]; if ($picture != null) { $picture = strip_tags($data->{'picture-urls'}->{'picture-url'}[0]->asXML()); } $this->actionLinkTo($data->{'email-address'}, $data->{'first-name'}, $data->{'last-name'}, $picture, $mesg, $phone, $city, $state, $about_me); return; } else { $this->redirect("/JobFair/index.php/site/page?view=disableUser"); return; } } // Populate user attributes $model->FK_usertype = 1; $model->registration_date = new CDbExpression('NOW()'); $model->activation_string = 'linkedin'; $model->username = $data->{'email-address'}[0]; $model->first_name = $data->{'first-name'}; $model->last_name = $data->{'last-name'}; $model->email = $data->{'email-address'}; $model->image_url = $data->{'picture-urls'}->{'picture-url'}[0]; $model->linkedinid = $data->id; //Hash the password before storing it into the database $hasher = new PasswordHash(8, false); $model->password = $hasher->HashPassword('tester'); $model->activated = 1; $model->has_viewed_profile = 1; $model->save(false); // // ------------------BASIC INFO--------------- $basic_info = null; $basic_info = BasicInfo::model()->findByAttributes(array('userid' => $model->id)); if ($basic_info == null) { $basic_info = new BasicInfo(); } $basic_info->userid = $model->id; $basic_info->phone = $data->{'phone-numbers'}->{'phone-number'}->{'phone-number'}; $basic_info->city = $data->location->name; $basic_info->state = ''; $basic_info->about_me = $data->headline; $basic_info->save(false); // ------------------BASIC INFO ----------------- // -----------------EDUCATION ---------------------- // get number of educations to add $educ_count = $data->educations['total']; // delete current educations $delete_educs = Education::model()->findAllByAttributes(array('FK_user_id' => $model->id)); foreach ($delete_educs as $de) { $de->delete(); } // add educations for ($i = 0; $i < $educ_count; $i++) { // first check if current education is in school table. if not, add it $current_school_name = $data->educations->education[$i]->{'school-name'}; $school_exists = School::model()->findByAttributes(array('name' => $current_school_name)); if ($school_exists == null) { $new_school = new School(); $new_school->name = $current_school_name; $new_school->save(); $school_id = School::model()->findByAttributes(array('name' => $current_school_name))->id; } else { $school_id = $school_exists->id; } // now ready to add new education $new_educ = new Education(); $new_educ->degree = $data->educations->education[$i]->degree; $new_educ->major = $data->educations->education[$i]->{'field-of-study'}; // $model->admission_date=date('Y-m-d',strtotime($model->admission_date)); $new_educ->graduation_date = date('Y-m-d', strtotime($data->educations->education[$i]->{'end-date'}->year)); // print "<pre>"; print_r($new_educ->graduation_date);print "</pre>";return; $new_educ->FK_school_id = $school_id; $new_educ->FK_user_id = $model->id; $new_educ->additional_info = $data->educations->education[$i]->notes; $new_educ->save(false); } // -----------------EDUCATION ---------------------- // -----------------EXPERIENCE ------------------- // get number of educations to add $pos_count = $data->positions['total']; // delete current positions $delete_pos = Experience::model()->findAllByAttributes(array('FK_userid' => $model->id)); foreach ($delete_pos as $de) { $de->delete(); } for ($i = 0; $i < $pos_count; $i++) { $new_pos = new Experience(); $new_pos->FK_userid = $model->id; $new_pos->company_name = $data->positions->position[$i]->company->name; $new_pos->job_title = $data->positions->position[$i]->title; $new_pos->job_description = $data->positions->position[$i]->summary; $temp_start_date = $data->positions->position[$i]->{'start-date'}->month . '/01/' . $data->positions->position[$i]->{'start-date'}->year; $new_pos->startdate = date('Y-m-d', strtotime($temp_start_date)); if ($data->positions->position[$i]->{'is-current'} == 'true') { $new_pos->enddate = ''; } else { $temp_end_date = $data->positions->position[$i]->{'end-date'}->month . '/01/' . $data->positions->position[$i]->{'end-date'}->year; $new_pos->enddate = date('Y-m-d', strtotime($temp_end_date)); } $new_pos->city = ''; $new_pos->state = ''; $new_pos->save(false); } // -----------------EXPERIENCE ------------------- // ----------------------SKILLS---------------------- // get number of educations to add $linkedin_skill_count = $data->skills['total']; for ($i = 0; $i < $linkedin_skill_count; $i++) { // check if skill exists in skill set table, if not, add it to skill set table if (Skillset::model()->findByAttributes(array('name' => $data->skills->skill[$i]->skill->name)) == null) { $new_skill = new Skillset(); $new_skill->name = $data->skills->skill[$i]->skill->name; $new_skill->save(false); //echo 'New Skill ' . $new_skill->attributes; } // check if student has that skill, if not add it to student-skill-map table if (StudentSkillMap::model()->findByAttributes(array('userid' => $model->id, 'skillid' => Skillset::model()->findByAttributes(array('name' => $data->skills->skill[$i]->skill->name))->id)) == null) { $new_sdnt_skill = new StudentSkillMap(); $new_sdnt_skill->userid = $model->id; $new_sdnt_skill->skillid = Skillset::model()->findByAttributes(array('name' => $data->skills->skill[$i]->skill->name))->id; $new_sdnt_skill->ordering = $i + 1; $new_sdnt_skill->save(false); } } // ----------------------SKILLS---------------------- // LOGIN $user = User::model()->find("username=:username", array(':username' => $model->username)); $identity = new UserIdentity($user->username, 'tester'); if ($identity->authenticate()) { Yii::app()->user->login($identity); } $this->redirect("/JobFair/index.php/user/ChangeFirstPassword"); } }
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)); }
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!'; } }