public function __construct() { // Will requrire that the API authenticiation is reqired! parent::__construct(); }
public function __construct() { parent::__construct(); }
/** * Function to save user information. * * @return Response */ public function saveuserInfo() { $result = Request::all(); $rules = Validator::make(Request::all(), ['fname' => 'required', 'lname' => 'required', 'email' => 'required', 'linkedinid' => 'required', 'token' => 'required', 'linkedinurl' => 'required', 'headline' => 'required']); if ($rules->fails()) { $this->status = 'failure'; $this->message = "There is something missing so user can't be registered"; return Response::json(array('status' => $this->status, 'message' => $this->message)); } else { $linkedinid = Request::get('linkedinid'); $location = Request::get('location'); $email = Request::get('email'); $user = User::where('email', '=', $email)->first(); $randNumber = ApiController::getGUID(); if (!empty($user)) { //This code will execute when user is already registered. $user_id = $user->id; $user_data = $user->toArray(); $user_id = $user_data['id']; /************* Change it **********/ $user = User::find($user_id); /************* Change it **********/ $user->token = $result['token']; $user->site_token = $randNumber; $user->industry = $result['industry']; $user->headline = $result['headline']; $user->linkedinurl = @$result['linkedinurl']; $user->location = $location; $user->piclink = $result['piclink']; $user->save(); $userStatus = $user->userstatus; $userActivationKey = $user->user_activation_key; $userPhonenumber = $user->phone_number; if ($userStatus == 'approved') { $CurrentDate = KarmaHelper::currentDate(); $profileupdatedate = $user->profileupdatedate; $diffDate = KarmaHelper::dateDiff($CurrentDate, $profileupdatedate); $diffDate = $diffDate->days * 24 + $diffDate->h; $refreshTime = Adminoption::where('option_name', '=', 'connection refresh time')->first(); //$resultData = json_decode($linkedinService->request('/people/~:(id,first-name,last-name,skills,headline,summary,industry,member-url-resources,picture-urls::(original),location,public-profile-url,email-address,site-standard-profile-request)?format=json'), true); if (!empty($refreshTime)) { $refreshTime = $refreshTime->toArray(); $refreshTime = $refreshTime['option_value']; } else { $refreshTime = '360'; } if ($diffDate >= $refreshTime) { $date = Carbon::now()->addMinutes(5); Queue::push('UpdateUser', array('id' => $user_id, 'result' => $result)); } //$InsConnection = KarmaHelper::updateUserProfile($user,$result); //$checkPhoneNumber=DB::select(DB::raw("SELECT IF(phone_number IS NULL or phone_number = '', '0', phone_number) as phone_number from users where id=".$user_id." limit 1")); if ($userActivationKey == '' && $userActivationKey == 'null') { $this->status = 'Success'; $this->userstatus = 'NotRegisteredWithApp'; $this->message = 'This user is not registered with app.'; } else { if ($userActivationKey == '0') { $this->status = 'Success'; $this->userstatus = 'approvedWithPhone'; $this->message = 'This user is approved with app.'; } else { $this->status = 'Success'; $this->userstatus = 'approvedWithoutPhone'; $this->message = 'This user is approved from web but not from app.'; } } } else { if ($userStatus == 'ready for approval') { $this->status = 'Success'; $this->userstatus = 'ready for approval'; $this->message = 'User is in ready for approval State'; } else { if ($userStatus == 'TOS not accepted') { $user->termsofuse = 1; $user->userstatus = 'ready for approval'; $user->save(); $groupId = 1; $usersgroupDelete = Usersgroup::where('user_id', '=', $user_id)->where('group_id', '=', $groupId)->delete(); $addUserGroup = new Usersgroup(); $addUserGroup->user_id = $user_id; $addUserGroup->group_id = 1; $addUserGroup->save(); $user_id_giver = 'null'; $feedType = 'KarmaGroup'; KarmaHelper::storeKarmacirclesfeed($user_id_giver, $user_id, $feedType, $groupId); $this->status = 'Success'; $this->userstatus = 'Tos State'; $this->message = 'User is in TOS State'; } } } } else { //This code will execute when new user will register. $user = new User(); $user->fname = $result['fname']; $user->lname = @$result['lname']; $user->email = $result['email']; $user->piclink = @$result['piclink']; $user->linkedinid = $result['linkedinid']; $user->summary = @$result['summary']; $user->location = @$result['location']; $user->industry = @$result['industry']; $user->headline = @$result['headline']; $user->linkedinurl = @$result['linkedinurl']; $user->token = @$result['token']; $user->userstatus = 'ready for approval'; $user->termsofuse = 1; $user->noofmeetingspm = 2; $user->profileupdatedate = date('Y-m-d H:i:s'); $user->site_token = $randNumber; $user->save(); $user = $user; $user_id = $user->id; $this->userstatus = $user->userstatus; Queue::push('MessageSender@newUserEmail', array('user_id' => $user_id)); //funtion to save data on connections table. //$InsConnection = KarmaHelper::insertUserConnection($user); $this->userstatus = 'ready for approval'; $this->status = 'Success'; $this->message = 'User successfully registered'; Queue::push('MessageSender@newUserEmail', array('user_id' => $user_id)); /************* Change it **********/ //$userStatus = User::where('linkedinid', '=', $result['linkedinid']) ->orWhere('email', '=', $result['email'])->select('userstatus')->first(); //$userStatus=$userStatus->userstatus; /************* Change it **********/ } return Response::json(array('status' => $this->status, 'message' => $this->message, 'UserId' => $user_id, 'UserAccesstoken' => $user->site_token, 'UserStatus' => $this->userstatus)); } }