Ejemplo n.º 1
5
 function HandleResponse()
 {
     $config = (include "/config.php");
     $li = new LinkedIn(array('api_key' => $config['linkedin_client_id'], 'api_secret' => $config['linkedin_client_secret'], 'callback_url' => $config['domain'] . "/linkedin/login/success"));
     $token = $li->getAccessToken($_REQUEST['code']);
     $_SESSION['linkedin_token'] = $token;
     echo "<script>window.close();</script>";
     die;
 }
Ejemplo n.º 2
1
 public function demo()
 {
     session_start();
     $this->load->helper('url');
     $this->load->library('linkedin');
     $config['base_url'] = base_url('home/linkedin');
     $config['callback_url'] = base_url('home/demo');
     $config['linkedin_access'] = '75cmijp7gpecgv';
     $config['linkedin_secret'] = 'CkLc98T2vkqc4vEh';
     # 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,email-address,headline,picture-url)");
     /* echo '<pre>';
        echo 'My Profile Info';
        echo $xml_response;
        echo '<br />';
        echo '</pre>';*/
     $id = $linkedin->getProfile('~:(id)');
     $email = $linkedin->getProfile('~:(email-address)');
     $uid = trim(strip_tags($id));
     $email_address = trim(strip_tags($email));
     $response = $this->home->linkedinauth($email_address);
     if ($response == 1) {
         $this->home->set_online_status(1);
         if ($this->session->userdata('is_login')) {
             if ($this->session->userdata('is_alumni')) {
                 redirect(base_url('alumni'));
             } elseif ($this->session->userdata('is_prospective')) {
                 redirect(base_url('parents'));
             } else {
                 redirect(base_url('seeker'));
             }
         }
     } else {
         redirect(base_url('home'));
     }
     $this->data['view_file'] = 'index';
     echo Modules::run('template/home', $this->data);
 }
Ejemplo n.º 3
0
 public function onSloginCheck()
 {
     $redirect = JURI::base() . '?option=com_slogin&task=check&plugin=linkedin';
     $app = JFactory::getApplication();
     $input = $app->input;
     $oauth_problem = $input->getString('oauth_problem', '');
     if ($oauth_problem == 'user_refused') {
         $config = JComponentHelper::getParams('com_slogin');
         JModel::addIncludePath(JPATH_ROOT . '/components/com_slogin/models');
         $model = JModel::getInstance('Linking_user', 'SloginModel');
         $redirect = base64_decode($model->getReturnURL($config, 'failure_redirect'));
         $controller = JControllerLegacy::getInstance('SLogin');
         $controller->displayRedirect($redirect, true);
     }
     # First step is to initialize with your consumer key and secret. We'll use an out-of-band oauth_callback
     $linkedin = new LinkedIn($this->params->get('api_key'), $this->params->get('secret_key'), $redirect);
     //$linkedin->debug = true;
     $oauth_verifier = $input->getString('oauth_verifier', '');
     $requestToken = unserialize($app->getUserState('requestToken'));
     $linkedin->request_token = $requestToken;
     $linkedin->oauth_verifier = $app->getUserState('oauth_verifier');
     if (!empty($oauth_verifier)) {
         $app->setUserState('oauth_verifier', $oauth_verifier);
         $linkedin->getAccessToken($oauth_verifier);
         $app->setUserState('oauth_access_token', serialize($linkedin->access_token));
         header("Location: " . $redirect);
         exit;
     } else {
         $linkedin->access_token = unserialize($app->getUserState('oauth_access_token'));
     }
     # You now have a $linkedin->access_token and can make calls on behalf of the current member
     //$request = $linkedin->getProfile("~:(id,first-name,last-name,headline,picture-url)");
     $request = $linkedin->getProfile("~:(id,first-name,last-name,headline,picture-url,email-address)?format=json");
     $request = json_decode($request);
     if (empty($request)) {
         echo 'Error - empty user data';
         exit;
     } else {
         if (!empty($request->errorCode)) {
             echo 'Error - ' . $request->message;
             exit;
         }
     }
     $returnRequest = new SloginRequest();
     $returnRequest->first_name = $request->firstName;
     $returnRequest->last_name = $request->lastName;
     //            $returnRequest->email       = $request->email;
     $returnRequest->id = $request->id;
     $returnRequest->real_name = $request->firstName . ' ' . $request->lastName;
     $returnRequest->display_name = $request->firstName;
     $returnRequest->all_request = $request;
     return $returnRequest;
 }
Ejemplo n.º 4
0
// $config['linkedin_access']      =   'YMKaHlPF6xv8YTMs_FftnoC1tq_0Fgoz9Y8me0PvcR1Sm9WxzuPI18hZr2yP3fFq';//twetest
// $config['linkedin_secret']      =   'PuKdmBOQFdR1vibAe0LX3yRkKhu-NWlZaqC3EwnsiiMw1OL0EZ_J_rmh5PjzHXfg';//twetest
$config['linkedin_access'] = $linkedin_access;
//twetest
$config['linkedin_secret'] = $linkedin_secret;
//twetest
include_once $docroot . "/linkedin/linkedin.php";
logger("Ln/Page2: Top");
# 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']);
    logger("Ln/Page2: access token1: ", $linkedin->access_token);
    $_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']);
    logger("Ln/Page2: access token2: ", $linkedin->access_token);
}
# You now have a $linkedin->access_token and can make calls on behalf of the current member
//$status = "This is a test".date("Y:m:d  H-i-s");
$ln_access_token = $linkedin->access_token;
logger("Ln/Page2: access token3: ", $ln_access_token);
$status = $_SESSION['message'];
Ejemplo n.º 5
0
 public function linkedin_login()
 {
     $config['base_url'] = base_url('auth/get_linkedin_url');
     $config['callback_url'] = base_url('auth/linkedin_login');
     $config['linkedin_access'] = '78iwuorjnrw04c';
     $config['linkedin_secret'] = 'J05AYZ236vVmIc3e';
     $linkedin = new LinkedIn($config['linkedin_access'], $config['linkedin_secret'], $config['callback_url']);
     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);
         $xml_response = $linkedin->getProfile("~:(id,first-name,last-name,headline,picture-url)");
         die($linkedin->getAccessToken($_REQUEST['oauth_verifier']));
         $user_data = explode(' ', $xml_response);
         $data = array('id' => $user_data[5], 'first_name' => $user_data[7], 'last_name' => $user_data[9], 'email' => $user_data[5], 'isLogged' => TRUE, 'role' => 0);
         $this->session->set_userdata($data);
         $linkedin_users = $this->users_model->get_record_by_filed(array('email' => $user_data[5]));
         if (count($linkedin_users) == 0) {
             $last_id = $this->users_model->insert_data($data);
         } else {
             $last_id = $this->users_model->get_record(array('email' => $user_data[5]));
             $this->users_model->update_record($last_id->id, $data);
         }
         redirect('frontend/home');
     } else {
         redirect('auth/index');
     }
 }
 /**
  * Function to process Linkedin connection data
  * @author Rohan Julka
  * */
 public function linkedInOauthCallback()
 {
     $response = $this->request->query;
     require_once ROOT . DS . APP_DIR . DS . 'Plugin/linkedin/linkedin.php';
     $ln = new LinkedIn(Configure::read('linkedinApiKey'), Configure::read('linkedinApiSecret'));
     $ln->getAccessToken();
     $accessToken = $ln->getTokenData();
     $checkAccessSession = $this->Session->read('AccessedBy');
     if (isset($response['code']) && !isset($response['error'])) {
         $loginUserId = $this->Encryption->decode($this->Session->read('Auth.Front.id'));
         $this->User->id = $loginUserId;
         if ($this->User->save(array('User' => array('linkedin_connected' => 1, 'linkedin_access_token' => $accessToken['access_token'])))) {
             $buisnessOwndata = $this->BusinessOwner->find('first', array('conditions' => array('User.id' => $loginUserId)));
             if (!empty($buisnessOwndata)) {
                 $linkedinData = $buisnessOwndata['BusinessOwner']['notifications_enabled'];
                 $linkedinData .= ',linkedinReferralSend,linkedinMessageSend,linkedinInviteSend';
                 $this->BusinessOwner->id = $this->Encryption->decode($buisnessOwndata['BusinessOwner']['id']);
                 $this->BusinessOwner->saveField('notifications_enabled', $linkedinData);
             }
             $this->Session->setFlash('Your LinkedIn account has been successfully linked', 'Front/flash_good');
             if (!empty($checkAccessSession)) {
                 $this->Session->delete('AccessedBy');
                 $this->Session->delete('Auth.Front.id');
                 $this->redirect('foxhoprapplication://linkedin');
             }
         } else {
             if (!empty($checkAccessSession)) {
                 $this->Session->delete('AccessedBy');
                 $this->Session->delete('Auth.Front.id');
                 $this->redirect('foxhoprapplication://cancel');
             }
             $this->Session->setFlash('Unable to authorize. ', 'Front/flash_bad');
         }
     } else {
         $this->Session->setFlash('Connection to Linkedin failed ', 'Front/flash_bad');
         if (!empty($checkAccessSession)) {
             $this->Session->delete('AccessedBy');
             $this->Session->delete('Auth.Front.id');
             $this->redirect('foxhoprapplication://cancel');
         }
     }
     $this->redirect(array('action' => 'social', 'linkedin'));
 }
Ejemplo n.º 7
0
<?php

require_once 'linkedin.php';
include dirname(__FILE__) . "/../../ms_configura.php";
$consumer_key = $linkedinoauth["consumerkey"];
$consumer_secret = $linkedinoauth["consumersecret"];
echo "<pre>";
# First step is to initialize with your consumer key and secret. We'll use an out-of-band oauth_callback
$linkedin = new LinkedIn($consumer_key, $consumer_secret, "oob");
$linkedin->debug = true;
# Now we retrieve a request token. It will be set as $linkedin->request_token
$linkedin->getRequestToken();
# With a request token in hand, we can generate an authorization URL, which we'll direct the user to
echo "Authorization URL: " . $linkedin->generateAuthorizeUrl() . "\n\n";
# After logging in, the user will be presented with an OAuth Verifier, which you would then ask the member to enter in a UI you present. Once you have the OAuth verifier, set it here:
echo "Enter OAuth Verifier:\n";
$handle = fopen("php://stdin", "r");
$oauth_verifier = trim(fgets($handle));
$linkedin->getAccessToken($oauth_verifier);
# 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)");
echo $xml_response;
# Let's set our status
$xml_response2 = $linkedin->setStatus("setting my status using the LinkedIn API.");
echo $xml_response2;
# Let's do a search!
$search_response = $linkedin->search("?company=Google&count=10");
echo $search_response;
Ejemplo n.º 8
0
 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");
     }
 }