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); }
/** * Key-value pairs of all categories * @return array [category_id => category_name] */ public static function all() { static $result; if (!is_null($result)) { return $result; } $command = Yii::app()->db; /* @var CDbConnection $command */ $rows = $command->createCommand()->select('id, name')->from(Education::model()->tableName())->queryAll(); $result = []; foreach ($rows as $row) { $result[$row['id']] = $row['name']; } return $result; }
<tr> <td class="info"><a href="/JobFair/index.php/profile/student/user/<?php echo $js->username; ?> "><?php echo $js->username; ?> </a></td> <td><?php echo $js->first_name . " " . $js->last_name; ?> </td> <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 . " - "; } ?>
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 actionUpload() { parent::actionUpload(); $folder = $_SERVER['DOCUMENT_ROOT'] . Yii::app()->request->baseUrl . '/upload/'; // folder for uploaded files $file = $folder . basename($_FILES['uploadfile']['name']); if (move_uploaded_file($_FILES['uploadfile']['tmp_name'], $file)) { $row = 0; if (($handle = fopen($file, "r")) !== FALSE) { while (($data = fgetcsv($handle, 1000, ",")) !== FALSE) { if ($row > 0) { $model = Educationmajor::model()->findByPk((int) $data[0]); if ($model === null) { $model = new Educationmajor(); } $model->educationmajorid = (int) $data[0]; $education = Education::model()->findbyattributes(array('educationname' => $data[1])); if ($education != null) { $model->educationid = $education->educationid; } $model->educationmajorname = $data[2]; $model->recordstatus = (int) $data[3]; try { if (!$model->save()) { $this->messages = $this->messages . Catalogsys::model()->getcatalog(' upload error at ' . $data[0]); } } catch (Exception $e) { $this->messages = $this->messages . $e->getMessage(); } } $row++; } } else { $this->messages = $this->messages . ' memory or harddisk full'; } fclose($handle); } else { $this->messages = $this->messages . ' check your directory permission'; } if ($this->messages == '') { $this->messages = 'success'; } echo $this->messages; }
/** * 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 the ID of the model to be loaded */ public function loadModel($id) { $model = Education::model()->findByPk((int) $id); if ($model === null) { throw new CHttpException(404, 'The requested page does not exist.'); } return $model; }
<?php $this->widget('ToolbarButton', array('isSave' => true, 'UrlSave' => 'educationmajor/write', 'isCancel' => true, 'UrlCancel' => 'educationmajor/cancelwrite')); ?> </div> <?php echo $form->hiddenField($model, 'educationmajorid'); ?> <div class="row"> <?php echo $form->labelEx($model, 'educationid'); ?> <?php echo $form->hiddenField($model, 'educationid'); ?> <input type="text" name="educationname" id="educationname" readonly value="<?php echo Education::model()->findByPk($model->educationid) !== null ? Education::model()->findByPk($model->educationid)->educationname : ''; ?> "> <?php $this->beginWidget('zii.widgets.jui.CJuiDialog', array('id' => 'education_dialog', 'options' => array('title' => Yii::t('app', 'Education'), 'width' => 'auto', 'autoOpen' => false, 'modal' => true))); $this->widget('zii.widgets.grid.CGridView', array('id' => 'catering-grid', 'dataProvider' => $education->Searchwstatus(), 'filter' => $education, 'template' => '{summary}{pager}<br>{items}{pager}{summary}', 'columns' => array(array('header' => '', 'type' => 'raw', 'value' => 'CHtml::Button("+", array("name" => "send_absschedule", "id" => "send_absschedule", "onClick" => "$(\\"#education_dialog\\").dialog(\\"close\\"); $(\\"#educationname\\").val(\\"$data->educationname\\"); $(\\"#Educationmajor_educationid\\").val(\\"$data->educationid\\"); "))'), array('name' => 'educationid', 'visible' => false, 'value' => '$data->educationid', 'htmlOptions' => array('width' => '1%')), 'educationname', array('class' => 'CCheckBoxColumn', 'name' => 'recordstatus', 'selectableRows' => '0', 'header' => 'Record Status', 'checked' => '$data->recordstatus')))); $this->endWidget('zii.widgets.jui.CJuiDialog'); echo CHtml::Button('...', array('onclick' => '$("#education_dialog").dialog("open"); return false;')); ?> <?php echo $form->error($model, 'educationid'); ?>
public function actionMergeAccounts() { $model = new LinkTooForm(); $error = ''; if (isset($_POST['LinkTooForm'])) { $model = new LinkTooForm(); $model->attributes = $_POST['LinkTooForm']; $username = $model->email; $password = $model->password; $login = new LoginForm(); $login->username = $username; $login->password = $password; $user1 = User::model()->findByAttributes(array('username' => $username)); $user2 = User::getCurrentUser(); if ($user1 == null || !$login->validate()) { $error = "Username or password was incorrect."; $this->render('MergeAccounts', array('model' => $model, 'error' => $error)); } elseif ($user1->disable == 1) { $error = "User's account is disable."; $this->render('MergeAccounts', array('model' => $model, 'error' => $error)); } else { $basic_info = BasicInfo::model()->findByAttributes(array('userid' => $user1->id)); //link the third party accounts; $linkedinid = $user1->linkedinid; $googleid = $user1->googleid; $fiucsid = $user1->fiucsid; $fiu_account_id = $user1->fiu_account_id; if ($user2->linkedinid == null && $linkedinid != null) { $user2->linkedinid = $linkedinid; $user1->linkedinid = null; $user2->save(false); } if ($user2->googleid == null && $googleid != null) { $user2->googleid = $googleid; $user1->googleid = null; $user2->save(false); } if ($user2->fiucsid == null && $fiucsid != null) { $user2->fiucsid = $fiucsid; $user1->fiucsid = null; $user2->save(false); } if ($user2->fiu_account_id == null && $fiu_account_id != null) { $user2->fiu_account_id = $fiu_account_id; $user1->fiu_account_id = null; $user2->save(false); } //disable user $user1->disable = 1; $user1->save(false); //get basic info $first_name = $user1->first_name; $last_name = $user1->last_name; $email = $user1->email; $picture = $user1->image_url; $mesg = "Virtual Job Fair"; $phone = $basic_info->phone; $city = $basic_info->city; $state = $basic_info->state; $about_me = $basic_info->about_me; //get education $education1 = Education::model()->find('FK_user_id=:id', array(':id' => $user1->id)); $education2 = Education::model()->find('FK_user_id=:id', array(':id' => $user2->id)); if ($education1 != null && $education2 == null) { $education1->FK_user_id = $user2->id; $education1->save(false); } if ($education1 != null && $education2 != null) { if ($education1->FK_school_id != $education2->FK_school_id) { $education1->FK_user_id = $user2->id; $education1->save(false); } } //get experience $experience1 = Experience::model()->find('FK_userid=:id', array(':id' => $user1->id)); $experience2 = Experience::model()->find('FK_userid=:id', array(':id' => $user2->id)); if ($experience1 != null && $experience2 == null) { $experience1->FK_userid = $user2->id; $experience1->save(false); } if ($experience1 != null && $experience2 != null) { if ($experience1->company_name != $experience2->company_name) { $experience1->FK_userid = $user2->id; $experience1->save(false); } } //get skill $this->actionLinkTo($email, $first_name, $last_name, $picture, $mesg, $phone, $city, $state, $about_me); return; } // } else { $this->render('MergeAccounts', array('model' => $model, 'error' => $error)); } }
public function actionDemo() { // 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. and changing how the account will be link so if the student //decide to login with his linkedIn account it will be taken to the account that it is link to. $config['base_url'] = 'http://' . Yii::app()->request->getServerName() . '/JobFair/index.php/profile/auth.php'; $config['callback_url'] = 'http://' . Yii::app()->request->getServerName() . '/JobFair/index.php/profile/demo'; $config['linkedin_access'] = '2rtmn93gu2m4'; $config['linkedin_secret'] = 'JV0fYG9ls3rclP8v'; include_once Yii::app()->basePath . "/views/profile/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); // print "<pre>"; print_r($xml_response);print "</pre>"; //print "<pre>"; print_r($data->{'picture-urls'}->{'picture-url'}[0]);print "</pre>"; // print "<pre>"; print_r($data->{'id'});print "</pre>"; //return; // check that there is no duplicate id $duplicateUser = User::model()->findByAttributes(array('linkedinid' => $data->{'id'})); if ($duplicateUser != null) { $this->actionDuplicationError(); return; } // get username and link the accounts $username = Yii::app()->user->name; $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; } } // ----------------------end SKILLS---------------------- //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()); } $xemail = $data->{'email-address'}; if ($xemail != null) { $xemail = strip_tags($data->{'email-address'}->asXML()); } $fname = $data->{'first-name'}; if ($fname != null) { $fname = strip_tags($data->{'first-name'}->asXML()); } $lname = $data->{'last-name'}; if ($lname != null) { $lname = strip_tags($data->{'last-name'}->asXML()); } $this->actionLinkToo($xemail, $fname, $lname, $picture, $mesg, $phone, $city, $state, $about_me); // return; }
public function actionEmployersearch() { $srch_keyword = $_POST['skillkeyword']; // Get skill keyword to search $pieces = trim($srch_keyword); $pieces = explode(" ", $pieces); // split words to search $count = sizeof($pieces); // get number of word to search $query = ''; for ($i = 0; $i < $count; $i++) { if ($i == $count - 1) { $query = $query . 'name like \'%' . $pieces[$i] . '%\''; } else { $query = $query . 'name like \'%' . $pieces[$i] . '%\' OR '; } } $criteria = new CDbCriteria(); $criteria->condition = $query; $results = array(); if ($srch_keyword != null) { $skillsArray = Skillset::model()->findAll($criteria); foreach ($skillsArray as $sk) { $student_ids = StudentSkillMap::model()->findAllByAttributes(array('skillid' => $sk->id)); // search student skill map for students with that skill foreach ($student_ids as $tmp) { $duplicate = 0; if (sizeof($results) > 0) { foreach ($results as $t) { if ($t->id == $tmp->userid) { $duplicate = 1; } } } if ($duplicate == 0) { $results[] = User::model()->findByAttributes(array('id' => $tmp->userid)); } } } $school_id = School::model()->findAll($criteria); // get school ID foreach ($school_id as $si) { $student_ids = Education::model()->findAllByAttributes(array('FK_school_id' => $si->id)); // search educations with school ID foreach ($student_ids as $tmp) { $duplicate = 0; if (sizeof($results) > 0) { foreach ($results as $t) { if ($t->id == $tmp->FK_user_id) { $duplicate = 1; } } } if ($duplicate == 0) { $results[] = User::model()->findByAttributes(array('id' => $tmp->FK_user_id)); } } } } if (isset($_GET['user'])) { $username = $_GET['user']; } else { $username = Yii::app()->user->name; } $user = User::model()->find("username=:username", array(':username' => $username)); // pass user $skills = Skillset::getNames(); // pass skills $universites = School::getAllSchools(); // pass companies // foreach ($results as $tr){ // print "<pre>"; print_r($tr->attributes);print "</pre>"; // } // return; $this->render('employerSearchResults', array('results' => $results, 'skills' => $skills, 'universities' => $universites, 'user' => $user)); }