예제 #1
0
 public function actionEmployerRegister()
 {
     $model = new User();
     // uncomment the following code to enable ajax-based validation
     /*
      if(isset($_POST['ajax']) && $_POST['ajax']==='user-EmployerRegister-form')
      {
     echo CActiveForm::validate($model);
     Yii::app()->end();
     }
     */
     if (isset($_POST['User'])) {
         $model->attributes = $_POST['User'];
         //print "<pre>";print_r($model);print "</pre>";return;
         if ($model->validate()) {
             if ($this->actionVerifyEmployerRegistration() != "") {
                 $this->render('EmployerRegister');
             }
             //Form inputs are valid
             //Populate user attributes
             $model->FK_usertype = 2;
             $model->registration_date = new CDbExpression('NOW()');
             $model->activation_string = $this->genRandomString(10);
             $model->image_url = '/JobFair/images/profileimages/user-default.png';
             //Hash the password before storing it into the database
             $hasher = new PasswordHash(8, false);
             $model->password = $hasher->HashPassword($model->password);
             //Save user into database. Account still needs to be activated
             //save employers company info
             if ($model->save($runValidation = false)) {
                 $companyInfo = new CompanyInfo();
                 $companyInfo->attributes = $_POST['CompanyInfo'];
                 $companyInfo->description = $this->mynl2br($_POST['CompanyInfo']['description']);
                 $companyInfo->FK_userid = $model->id;
                 $companyInfo->save($runValidation = false);
                 $basicInfo = new BasicInfo();
                 $basicInfo->attributes = $_POST['BasicInfo'];
                 $basicInfo->about_me = $this->mynl2br($_POST['BasicInfo']['about_me']);
                 $basicInfo->userid = $model->id;
                 $basicInfo->city = $companyInfo->city;
                 $basicInfo->state = $companyInfo->state;
                 $basicInfo->save(false);
             }
             $link = 'http://' . Yii::app()->request->getServerName() . '/JobFair/index.php/profile/employer/user/' . $model->username;
             $link2 = 'http://' . Yii::app()->request->getServerName() . '/JobFair/index.php/profile/employer/user/' . $model->username;
             $message = $model->username . " just joined VJF, click here to view their profile.";
             User::sendAllStudentVerificationAlart($model->id, $model->username, $model->email, $message, $link);
             $message1 = "There is a new employer named " . $model->username . " that is waiting for acctivation";
             $admins = User::model()->findAllByAttributes(array('FK_usertype' => 3));
             User::sendAdminNotificationNewEmpolyer($model, $admins, $link2, $message1);
             $message = "You have successfully registered. Once your account has been approved, you will receive an email stating your account is active.";
             $message .= "<br/>Your username: {$model->username}";
             User::sendEmail($model->email, "Registration Notification", "Registration Notification", $message);
             $this->render('NewEmployer');
             return;
         }
     }
     $this->render('EmployerRegister', array('model' => $model));
 }
예제 #2
0
파일: Job.php 프로젝트: erick305/testing
 public static function getJobsBySkill($skill_name, $comp_name)
 {
     // 		print "<pre>"; print_r($comp_id->attributes);print "</pre>";return;
     $jobMap = null;
     $skill_id = null;
     $comp_posts = null;
     // Query dabase by skill name and retrieve the skill_id
     $skill = Skillset::model()->findByAttributes(array('name' => $skill_name));
     if ($skill != null) {
         $skill_id = $skill->id;
         // Get all jobs that have the skill_id
         $jobMap = JobSkillMap::model()->findAllByAttributes(array('skillid' => $skill_id));
     }
     // Query the database by Company name and get All job posts for that company
     $comp_id = CompanyInfo::model()->findByAttributes(array('name' => $comp_name));
     if ($comp_id != null) {
         $comp_posts = Job::model()->findAllByAttributes(array('FK_poster' => $comp_id->FK_userid));
     }
     // Array of jobs
     $jobs = array();
     if ($jobMap != null) {
         foreach ($jobMap as $aJobMap) {
             $jobid = $aJobMap->jobid;
             if ($skill_id != null && $comp_posts != null) {
                 // search for Company and Skill
                 $jobs[] = Job::model()->findByAttributes(array('id' => $jobid, 'FK_poster' => $comp_id->FK_userid));
             } elseif ($comp_id == null) {
                 $jobs[] = Job::model()->findByAttributes(array('id' => $jobid));
             }
             // search for skill only
         }
     } else {
         if ($comp_posts != null) {
             foreach ($comp_posts as $aPost) {
                 $tmp = $aPost->id;
                 $jobs[] = Job::model()->findByAttributes(array('id' => $tmp));
                 // search for Company only
             }
         }
     }
     return $jobs;
 }
예제 #3
0
파일: User.php 프로젝트: erick305/testing
 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();
 }
예제 #4
0
파일: home.php 프로젝트: erick305/testing
                if ($i < $sizeJobs) {
                    ?>
 <!-- CareerPath -->
                   <tr>
                       <td><a href="/JobFair/index.php/job/view/jobid/<?php 
                    echo $jobs[$i]->id;
                    ?>
"><?php 
                    echo $jobs[$i]->title;
                    ?>
</a></td>
                       <td><a href="/JobFair/index.php/profile/employer/user/<?php 
                    echo User::model()->findByAttributes(array('id' => $jobs[$i]->FK_poster))->username;
                    ?>
"><?php 
                    echo CompanyInfo::model()->findByAttributes(array('FK_userid' => $jobs[$i]->FK_poster))->name;
                    ?>
</a></td>
                       <td><?php 
                    echo $jobs[$i]->type;
                    ?>
</td>
                       <td><?php 
                    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 
예제 #5
0
 public static function getCompanyNamesUser($fKPoster)
 {
     $names = CompanyInfo::model()->findBySql("SELECT company_info.name FROM company_info WHERE FK_userid=:FK_poster", array(":FK_poster" => $fKPoster));
     return $names->name;
 }
예제 #6
0
 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);
 }
예제 #7
0
 public static function getParser()
 {
     if (!self::$_parser) {
         self::$_parser = new CParser();
         //            self::$_parser->proxyHost = '127.0.0.1';
         //            self::$_parser->proxyPort = '8888';
     }
     return self::$_parser;
 }
예제 #8
0
    $("#aboutmeleft").text(aboutmelimit + " characters left");
    $("#companydescleft").text(companydesclimit + " characters left");
});
</script>




<h2>Employer Register</h2>
<div class="form">

<?php 
$form = $this->beginWidget('CActiveForm', array('id' => 'user-EmployerRegister-form', 'enableAjaxValidation' => false));
?>
	<?php 
$model->companyInfo = CompanyInfo::model();
$model->basicInfo = BasicInfo::model();
?>
	<p class="note">Fields with <span class="required">*</span> are required.</p>

	<p style="color:red" id="errors"></p>
	
<h4>Personal Info.</h4>
<div id="regbox">
		<?php 
echo $form->labelEx($model, 'username');
?>
		<?php 
echo $form->textField($model, 'username');
?>
예제 #9
0
파일: main.php 프로젝트: rhalf/app_track
        Flight::ok($object);
    } catch (Exception $exception) {
        Flight::error($exception);
    }
});
Flight::route('PUT /v1/main/companyinfo/@id', function ($id) {
    try {
        $object = CompanyInfo::update($id);
        Flight::ok($object);
    } catch (Exception $exception) {
        Flight::error($exception);
    }
});
Flight::route('DELETE /v1/main/companyinfo/@id', function ($id) {
    try {
        $object = CompanyInfo::delete($id);
        Flight::ok($object);
    } catch (Exception $exception) {
        Flight::error($exception);
    }
});
//=============================================================================
//Driver
//=============================================================================
Flight::route('GET /v1/main/driver', function () {
    $company = Flight::request()->query->company;
    try {
        if ($company) {
            $array = Driver::selectByCompany($company);
        } else {
            $array = Driver::selectAll();
예제 #10
0
 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));
 }
예제 #11
0
 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!';
     }
 }