public function UpdateUserInfo($job, $data) { if ($job->attempts() > 3) { $job->delete(); } $user_id = $data['id']; $user_data = User::find($user_id); $token = $user_data->token; $InsConnection = KarmaHelper::insertUserConnection($user_data); $updateMeetingRequest = KarmaHelper::updateRequestAndKarmaNote($user_data); $user = User::find($user_id); $tos = $user->termsofuse; $userstatus = $user->userstatus; if ($tos == 1 && $userstatus == 'ready for approval') { $user->userstatus = 'ready for approval'; $user->save(); } if ($tos == 0) { $user->userstatus = 'TOS not accepted'; $user->save(); } if ($tos == 1 && $userstatus == 'approved') { $user->userstatus = 'approved'; $user->save(); } if ($userstatus == 'hidden') { $user->userstatus = 'hidden'; $user->save(); } $job->delete(); }
public function searchbyskill($alpha) { list($s, $alpha) = explode('-', $alpha); $azRange = array_merge(range('A', 'Z'), range('a', 'z')); $aplhachk = in_array($alpha, $azRange); if ($aplhachk != 1 || $s != "skills") { return Redirect::to('404'); } $user_info = Auth::user(); $skills = DB::table('tags')->where('tags.name', 'LIKE', $alpha . '%')->get(); //echo"<pre>";print_r($skills);echo"</pre>"; die; if (isset($user_info)) { $user_id = $user_info->id; } else { $user_id = 0; } foreach ($skills as $key => $value) { $searchquery = DB::table('users_tags')->leftjoin('users', 'users.id', '=', 'users_tags.user_id')->where('tag_id', '=', $value->id)->where('users.userstatus', '=', 'approved')->where('users.id', '!=', $user_id)->select('users_tags.id', 'users_tags.user_id', 'users_tags.tag_id')->get(); $skills[$key]->UserCount = count($searchquery); } /* $skills = array_values(array_sort($skills, function($value) { return $value->name; })); //$skills = array_reverse($skills); */ $seter = array(); foreach ($skills as $set) { $seter[] = (array) $set; } $skills = KarmaHelper::skill_sort($seter, 'name'); return View::make('footer.search_by_skill', array('pageTitle' => 'Skills & Expertise Directory | KarmaCircles', 'pageDescription' => 'Explore the vast database of professionals and experts using skills and fields of your interest, and get instant help.', 'alpha' => $alpha, 'skills' => $skills)); }
/** * Execute the console command. * * @return mixed */ public function fire() { Log::alert('Executed Cron Job to send weekly mail for pending karma note and meeting requests.'); $KarmaNotePending = ""; $KarmaNotePending = Meetingrequest::whereIn('status', array('pending', 'accepted'))->get(); if (!empty($KarmaNotePending)) { $test_id = ""; $test_id = Adminoption::Where('option_name', '=', 'Test User Emails')->first(); $test_user_id = $getfintrorecords = array(); if (!empty($test_id)) { $test_user_id = explode(',', $test_id->option_value); } $introducer = $giver = $receiver = $connidgiver = ''; foreach ($KarmaNotePending as $key => $value) { $diffDate = KarmaHelper::dateDiff(date("Y-m-d H:i:s"), $value->created_at); if (isset($value->user_id_giver)) { $giver = in_array($value->user_id_giver, $test_user_id); } if (isset($value->user_id_receiver)) { $receiver = in_array($value->user_id_receiver, $test_user_id); } if (isset($value->connection_id_giver)) { $connidgiver = in_array($value->connection_id_giver, $test_user_id); } if (isset($value->user_id_introducer)) { $introducer = in_array($value->user_id_introducer, $test_user_id); } if ($giver != 1 && $receiver != 1 && $connidgiver != 1 && $introducer != 1) { if ($diffDate->days > 7) { $meetingtimezone = $value->meetingtimezone; $meetingdatetime = $value->meetingdatetime; $user_id_giver = $value->user_id_giver; $user_id_receiver = $value->user_id_receiver; $meetingId = $value->id; $status = $value->status; $CurrentTimeWithZone = KarmaHelper::calculateTime($meetingtimezone); if ($CurrentTimeWithZone > $meetingdatetime && $status == 'accepted') { Queue::push('MessageSender', array('type' => '4', 'user_id_giver' => $user_id_giver, 'user_id_receiver' => $user_id_receiver, 'meetingId' => $meetingId)); } if ($status == 'pending') { //echo"<pre>";print_r($value->id);echo"</pre>"; if (isset($value->user_id_giver)) { Queue::push('MessageSender', array('type' => '1', 'user_id_giver' => $user_id_giver, 'user_id_receiver' => $user_id_receiver, 'meetingId' => $meetingId)); } else { Queue::push('MessageSender', array('type' => '2', 'user_id_giver' => $value->connection_id_giver, 'user_id_receiver' => $user_id_receiver, 'meetingId' => $meetingId)); } } } } } } }
/** * Execute the console command. * * @return mixed */ public function fire() { //get test users id $getUser = KarmaHelper::getTestUsers(); //print_r($getUser);die; if (!empty($getUser)) { foreach ($getUser as $key => $value) { $helper = User::find($value); if (!empty($helper)) { $helper->karmascore = 0; $helper->save(); } } } Log::alert('Updated test user Karma score.'); }
/** * Execute the console command. * * @return mixed */ public function fire() { Log::alert('Executed Cron Job'); $KarmaNotePending = Meetingrequest::where('status', '=', 'confirmed')->where('cronjobflag', '=', '0')->get(); if (!empty($KarmaNotePending)) { foreach ($KarmaNotePending as $key => $value) { $meetingtimezone = $value->meetingtimezone; $meetingdatetime = $value->meetingdatetime; $user_id_giver = $value->user_id_giver; $user_id_receiver = $value->user_id_receiver; $meetingId = $value->id; $CurrentTimeWithZone = KarmaHelper::calculateTime($meetingtimezone); //echo "<pre>";print_r($meetingdatetime);echo "</pre>"; //echo "<pre>";print_r($meetingdatetime);echo "</pre>";die(); if ($CurrentTimeWithZone > $meetingdatetime) { $diffDate = KarmaHelper::dateDiff($CurrentTimeWithZone, $meetingdatetime); $diffDate = $diffDate->days * 24 + $diffDate->h; $EmailTriggerTime = Adminoption::where('option_name', '=', 'KarmaNote Email Trigger Time')->first(); if (!empty($EmailTriggerTime)) { $EmailTriggerTime = $EmailTriggerTime->toArray(); $EmailTriggerTime = $EmailTriggerTime['option_value']; } else { $EmailTriggerTime = '24'; } if ($diffDate >= $EmailTriggerTime) { //$date = Carbon::now()->addMinutes(5); Queue::push('MessageSender', array('type' => '4', 'user_id_giver' => $user_id_giver, 'user_id_receiver' => $user_id_receiver, 'meetingId' => $meetingId)); $Meetingrequest = Meetingrequest::find($meetingId); $Meetingrequest->cronjobflag = '1'; $Meetingrequest->status = 'over'; $Meetingrequest->save(); DB::table('users_mykarma')->where('entry_id', '=', $meetingId)->update(array('status' => 'over', 'unread_flag' => 'true', 'entry_updated_on' => Carbon::now())); $messageData = new Message(); $messageData->request_id = $meetingId; $messageData->sender_id = $user_id_giver; $messageData->giver_id = $user_id_giver; $messageData->receiver_id = $user_id_receiver; $messageData->message_type = 'system'; $messageText = 'Meeting should be over now.'; $messageData->messageText = $messageText; $messageData->save(); //Queue::push('UpdateUser', array('id' => $user_id,'result' => $result)); } } } } }
<?php if (Auth::check()) { ?> <script type="text/javascript"> $(document).ready(function(){ var authCheck = <?php if (Auth::check()) { echo "1"; } else { echo "0"; } ?> ; if(authCheck == '1'){ var notification_karmanote = <?php echo KarmaHelper::UnreadKarmaNote(); ?> ; var notification_karmameeting = <?php echo KarmaHelper::UnreadMeetingRequest(); ?> ; $("#notification_karmanote").html(notification_karmanote); $("#notification_karmameeting").html(notification_karmameeting); } }); </script> <?php }
public function loginWithLinkedin() { // get data from input $code = Input::get('code'); $linkedinService = OAuth::consumer('Linkedin'); if (!empty($code)) { // This was a callback request from linkedin, get the token $token = $linkedinService->requestAccessToken($code); //$token="7ee85959-1809-4899-a10d-626740702f5d"; // Send a request with it. Please note that XML is the default format. $result = 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); $linkedinid = $result['id']; //echo "<pre>";print_r($token->getAccessToken());echo "</pre>"; //echo $token->accessToken;die; //die(); if (!empty($token)) { //$user = User::where('linkedinid', '=', $linkedinid)->first(); $user = User::where('linkedinid', '=', $linkedinid)->first(); if (!empty($user)) { $user_data = $user->toArray(); $user_id = $user_data['id']; $user_info = User::find($user_id); $user = User::find($user_id); $user->token = $token->getAccessToken(); $user->save(); $CurrentDate = KarmaHelper::currentDate(); $profileupdatedate = $user_info->profileupdatedate; $diffDate = KarmaHelper::dateDiff($CurrentDate, $profileupdatedate); $diffDate = $diffDate->days * 24 + $diffDate->h; $refreshTime = Adminoption::where('option_name', '=', 'connection refresh time')->first(); //echo "<pre>";print_r($refreshTime);echo "</pre>";die(); $InsConnection = KarmaHelper::updateUserProfile($user, $result); 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)); } //echo "<pre>";print_r($user);echo "</pre>";die(); if (Auth::loginUsingId($user_id)) { if ($user['registrationstatus'] == '0') { return Redirect::to('register'); } else { return Redirect::to('dashboard'); } } else { return Redirect::route('/'); } } else { if (!isset($result['publicProfileUrl']) || $result['publicProfileUrl'] == '') { $publicProfileUrl = $result['siteStandardProfileRequest']['url']; } else { $publicProfileUrl = $result['publicProfileUrl']; } $user = new User(); $user->fname = $result['firstName']; $user->lname = @$result['lastName']; $user->email = $result['emailAddress']; $user->piclink = @$result['pictureUrls']['values'][0]; $user->linkedinid = $result['id']; $user->summary = @$result['summary']; $user->location = @$result['location']['name']; $user->industry = @$result['industry']; $user->headline = @$result['headline']; $user->linkedinurl = @$publicProfileUrl; $user->token = $token->getAccessToken(); $user->profileupdatedate = date('Y-m-d H:i:s'); $user->save(); $user = $user; $user_id = $user->id; $InsTag = KarmaHelper::insertUsertag($user, $result); Queue::push('MessageSender@newUserEmail', array('user_id' => $user_id)); $InsConnection = KarmaHelper::insertUserConnection($user); if (Auth::loginUsingId($user_id)) { return Redirect::to('dashboard'); } else { return Redirect::route('/'); } } } } else { // get linkedinService authorization $url = $linkedinService->getAuthorizationUri(array('state' => 'DCEEFWF45453sdffef424')); // return to linkedin login url return Redirect::to((string) $url); } }
public static function sendActivationMessage($user_info) { $subject = "Welcome to KarmaCircles"; $Content = "Your KarmaCircles account is activated now."; $type = "11"; $user_id = $user_info->id; $location = $user_info->location; // fetch user connections on KC $getUserConnection = KarmaHelper::getUserConnection($user_id, $location); $user_connection_onkc = 0; if (!empty($getUserConnection)) { foreach ($getUserConnection as $key => $value) { if (isset($value->con_user_id)) { $user_connection_onkc++; } } } // fetch pending karmanote requests $totalPendingRequest = 0; $PendingRequest = array(); $PendingRequest = KarmaHelper::getPendingKarmaNotes($user_info->id); if (!empty($PendingRequest)) { $totalPendingRequest = count($PendingRequest); } //fetch pending KM requests only received no read no unread $totalReceivedRequest = 0; $GiverInMeeting = User::find($user_info->id)->Giver()->where('status', 'pending')->orderBy('updated_at', 'DESC')->get(); if (!empty($GiverInMeeting)) { $totalReceivedRequest = count($GiverInMeeting); } //fetch pending karma intros $totalintroductionInitiated = 0; $IntroducerInitiated = User::find($user_info->id)->Introducer; if (!empty($IntroducerInitiated)) { foreach ($IntroducerInitiated as $key => $value) { $value['user_id_receiver'] = User::find($value['user_id_receiver'])->toArray(); if (!empty($value['user_id_giver'])) { $value['user_id_giver'] = User::find($value['user_id_giver'])->toArray(); } else { $value['user_id_giver'] = Connection::find($value['connection_id_giver'])->toArray(); } if ($value->status == 'pending') { $totalintroductionInitiated++; } } } // fetch queries that have been posted in the last 7 days within common groups including both public & private. $Usergroup = User::find($user_info->id)->Groups; $All_groups = ''; $group_question = 0; $totagroupquestion = 0; $yesterday = Carbon::now()->subDays(1); $one_week_ago = Carbon::now()->subWeeks(1); if (!$Usergroup->isEmpty()) { foreach ($Usergroup as $key => $value) { $All_groups[] = $value->id; } if (!empty($All_groups)) { $group_question = DB::table('group_questions')->join('questions', 'group_questions.question_id', '=', 'questions.id')->select(array('questions.id'))->whereIn('group_questions.group_id', $All_groups)->where('questions.user_id', '!=', $user_info->id)->where('questions.queryStatus', '=', 'open')->where('questions.created_at', '>=', $one_week_ago)->where('questions.created_at', '<=', $yesterday)->orderBy('questions.created_at', 'DESC')->groupBy('question_id')->get(); if (!empty($group_question)) { $totagroupquestion = count($group_question); } } } // fetch weekly suggestion option value set from admin $weekly_suggestion = "KarmaNote"; $weekly_suggestion = Adminoption::Where("option_name", "=", "Weekly Suggestion")->select("option_value")->first(); if (!empty($weekly_suggestion)) { $weekly_suggestion = $weekly_suggestion->option_value; } $getkcUser = $getsuggestion = array(); if ($weekly_suggestion == "KarmaMeeting") { // fetch a random users on KC platform with a common group of logged in user $getkcUser = KarmaHelper::fetchUserGroup($user_id); if (!empty($getkcUser)) { $getkcUser = $getkcUser[0]; } } else { // fetch a user connection either KC or NON KC $getsuggestion = KarmaHelper::getUserConnection($user_id, $location); //get test users id $getUser = KarmaHelper::getTestUsers(); if (!empty($getsuggestion)) { foreach ($getsuggestion as $key => $value) { $test_match = in_array($value->con_user_id, $getUser); if ($value->con_user_id != "" && $test_match != 1) { $getKc = DB::table('users as u')->select(array('u.userstatus', 'u.id', 'u.fname', 'u.lname', 'u.linkedinurl', 'u.piclink', 'u.headline', 'u.email', 'u.karmascore', 'u.location'))->where('u.id', '=', $value->con_user_id)->where('u.userstatus', '=', 'approved')->get(); if (!empty($getKc)) { $value->networkid = $getKc; } } } $getsuggestion = $getsuggestion[array_rand($getsuggestion)]; } } $getkcUser = (array) $getkcUser; $getsuggestion = (array) $getsuggestion; /*echo"<pre>";print_r($getkcUser);echo"</pre>"; echo"<pre>";print_r($getsuggestion);echo"</pre>"; die;*/ //fetch random 5 unique notes $getKarmanote = ""; $getKarmanote = KarmaHelper::getKarmanote(); // call send mail to user $to = $user_info->email; $url = URL::to(''); $mail_subject = "Welcome to KarmaCircles"; $count = 0; $fullname = $user_info->fname . ' ' . $user_info->lname; $html = ""; if (!empty($getKarmanote)) { $html .= "<table width='100%:''> "; foreach ($getKarmanote as $value) { if (isset($value->user_idreceiver['piclink'])) { $rcvrpiclink = $value->user_idreceiver['piclink']; $plink = $url . '/profile/' . strtolower($value->user_idreceiver['fname'] . '-' . $value->user_idreceiver['lname']) . '/' . $value->user_idreceiver['id']; $rcvrpic = "<span><a href='" . $plink . "' target='_blank'><img height='40' width='40' src='" . $rcvrpiclink . "'></a></span>"; } else { $rcvrpiclink = $url . "/images/default.png"; $plink = $url . '/profile/' . strtolower($value->user_idreceiver['fname'] . '-' . $value->user_idreceiver['lname']) . '/' . $value->user_idreceiver['id']; $rcvrpic = "<span><a href='" . $plink . "' target='_blank'><img height='40' width='40' src='" . $rcvrpiclink . "'></a></span>"; } if (isset($value->user_idgiver['piclink'])) { $gvrpiclink = $value->user_idgiver['piclink']; $plink = $url . '/profile/' . strtolower($value->user_idgiver['fname'] . '-' . $value->user_idgiver['lname']) . '/' . $value->user_idgiver['id']; $gvrpic = "<span><a href='" . $plink . "' target='_blank'><img height='40' width='40' src='" . $gvrpiclink . "'></a></span>"; } else { $plink = $url . '/profile/' . strtolower($value->user_idgiver['fname'] . '-' . $value->user_idgiver['lname']) . '/' . $value->user_idgiver['id']; if (isset($value->connection_idgiver['piclink'])) { $gvrpiclink = $value->connection_idgiver['piclink']; } else { $gvrpiclink = $url . "/images/default.png"; } $gvrpic = "<span><a href='" . $plink . "' target='_blank'><img height='40' width='40' src='" . $gvrpiclink . "'></a></span>"; } if (!empty($value->user_idgiver)) { $name = $value->user_idgiver['fname'] . ' ' . $value->user_idgiver['lname']; } else { $name = $value->connection_idgiver['fname'] . ' ' . $value->connection_idgiver['lname']; } $html .= " <tr style='margin-bottom:5px;display:block;text-decoration:none;'>\n <td>\n \t" . $rcvrpic . "\n </td> \n <td> \n <span><img src=" . $url . "/images/icon002.png height='26' width='26'></span>\n </td> \n <td>\n " . $gvrpic . "\n </td> \n <td> \n <a target='_blank' style='text-decoration:none; color: #39bb95;font-size: 15px;'\n\t\t\t\t\t\t\thref=" . $url . "/meeting/" . strtolower($value->user_idreceiver['fname'] . "-" . $value->user_idreceiver['lname'] . "-" . $value->user_idgiver['fname'] . "-" . $value->user_idgiver['lname']) . '/' . $value->req_id . ">\n <p style='margin:0px;margin-left:10px;color: #39BB95;font-size: 15px;''>\n \t" . $value->user_idreceiver['fname'] . ' ' . $value->user_idreceiver['lname'] . "\n\t\t\t\t\tsent a KarmaNote to " . $name . "\n </p> \n\n </td>\n </tr>\n "; } $html .= "</table>"; } Mail::send('emails.accountactive', array('type' => '11', 'user_id' => $user_id, 'user_connection_onkc' => $user_connection_onkc, 'totalPendingRequest' => $totalPendingRequest, 'totalReceivedRequest' => $totalReceivedRequest, 'totalintroductionInitiated' => $totalintroductionInitiated, 'totagroupquestion' => $totagroupquestion, 'getsuggestion' => $getsuggestion, 'getKcuser' => $getkcUser, 'getKarmanote' => $getKarmanote, 'url' => $url, 'UserDetail' => $user_info, 'html' => $html), function ($message) use($to, $mail_subject, $fullname) { $message->to($to, $fullname)->replyTo('*****@*****.**', "admin")->subject($mail_subject)->from('*****@*****.**', "KarmaCircles Team"); }); MessageHelper::sendWelcomeKNote($user_info); }
?> /FAQs/KarmaPoints/1"><span>{{$element['user_id_receiver']['karmascore']}}</span></a> </li> @endif </ul> </div> </div> </div> <div class="col-xs-12 col-sm-7 textR"> <h4>{{ date('F d,Y',strtotime($element->updated_at))}}</h4> <p>{{$element['user_id_receiver']['location']}}</p> <div class="clr"></div> <div class="recive"> <?php $getActionStateMessage = KarmaHelper::getMykarmaMessageForReceiverGiver($element->status, 'Receiver'); ?> @if ($element->status == 'pending' ) <button type="button" class="btn btn-success toggleBtn pending">{{$getActionStateMessage}}</button> @elseif($element->status == 'archived') <button type="button" class="btn btn-success toggleBtn">{{$getActionStateMessage}}</button> @elseif($element->status == 'accepted') <button type="button" class="btn btn-success toggleBtn accept">{{$getActionStateMessage}}</button> @elseif($element->status == 'completed') <button type="button" class="btn btn-success toggleBtn completed">{{$getActionStateMessage}}</button> @endif </div> <div class="recive"> <a href="/meeting/<?php echo strtolower($element['user_id_receiver']['fname'] . '-' . $element['user_id_receiver']['lname'] . '-' . $element['user_id_giver']['fname'] . '-' . $element['user_id_giver']['lname']); ?>
public function scriptForMyKarma() { $getMeetingData = DB::table('requests')->where('user_id_receiver', '=', '605')->orWhere('user_id_giver', '=', '605')->get(); foreach ($getMeetingData as $key => $value) { $receiverId = $value->user_id_receiver; $updatedDate = $value->updated_at; //for complete meeting if ($value->status == 'completed') { if ($value->user_id_giver != '' && $value->user_id_giver != 'NULL') { $giverId = $value->user_id_giver; $connectionGiverId = 'null'; } else { $giverId = 'null'; $connectionGiverId = $value->connection_id_giver; } $meetingStatus = $value->status; $meetingId = $value->id; $saveDataInMyKarma = KarmaHelper::saveDataInMyKarma($receiverId, $giverId, $meetingId, $meetingStatus, $connectionGiverId, $updatedDate); } else { if ($value->user_id_giver != '' && $value->user_id_giver != 'NULL') { $giverId = $value->user_id_giver; $connectionGiverId = 'null'; $meetingStatus = $value->status; $meetingId = $value->id; $saveDataInMyKarma = KarmaHelper::saveDataInMyKarma($receiverId, $giverId, $meetingId, $meetingStatus, $connectionGiverId, $updatedDate); } } //else //for uncomplete meeting status. } echo 'success'; exit; }
/** Function name: saveKarmanote() Created by : Evon Created on : 04/10/2014 **/ public function saveKarmanote() { $CurrentUser = Auth::User(); $meetingId = $receiverId = $giverId = $note = $receiverName = $giverName = $ShareKarmaNote = ''; $note = array(); if (!empty(Input::get('ShareKarmaNote'))) { $ShareKarmaNote = Input::get('ShareKarmaNote'); } if (!empty(Input::get('meetingId'))) { $meetingId = Input::get('meetingId'); } if (!empty(Input::get('receiverId'))) { $receiverId = Input::get('receiverId'); } if (!empty(Input::get('introducerId'))) { $introducerId = Input::get('introducerId'); } if (!empty(Input::get('giverId'))) { $giverId = Input::get('giverId'); } if (!empty(Input::get('skillTags'))) { $skills = Input::get('skillTags'); } if (!empty(Input::get('details'))) { $note = Input::get('details'); } if (!empty(Input::get('receiverName'))) { $receiverName = Input::get('receiverName'); } if (!empty(Input::get('giverName'))) { $giverName = Input::get('giverName'); } //print_r($ShareKarmaNote);die; if (!$this->Karmanote->isValid(Input::all())) { return Redirect::back()->withInput()->withErrors($this->Karmanote->errors); } else { $feedType = 'KarmaNote'; $karmaNote = new Karmanote(); $karmaNote->req_id = $meetingId; $karmaNote->user_idgiver = $giverId; $karmaNote->user_idreceiver = $receiverId; $karmaNote->details = strip_tags($note); if (!empty($skills)) { $karmaNote->skills = implode(',', $skills); } else { $karmaNote->skills = ''; } $karmaNote->viewstatus = 0; if ($ShareKarmaNote == 1) { $karmaNote->share_onlinkedin = $ShareKarmaNote; } $karmaNote->created_at = KarmaHelper::currentDate(); $karmaNote->save(); $karmaNoteId = $karmaNote->id; //$karmaNoteMessage=$karmaNote->details; if (!empty($skills)) { $getName = $getSkillDataName = ""; foreach ($skills as $key => $value) { $getName = Tag::where('id', '=', $value)->select('name')->first(); $getSkillDataName .= $getName->name . ","; } $result = rtrim($getSkillDataName, ","); $karmaNoteMessage = $karmaNote->details . "\nEndorsements: " . $result; } else { $karmaNoteMessage = $karmaNote->details; } $Meetingrequest = Meetingrequest::find($meetingId); $Meetingrequest->status = 'completed'; $Meetingrequest->save(); $messageData = new Message(); $messageData->request_id = $meetingId; $messageData->sender_id = $CurrentUser->id; $messageData->giver_id = $giverId; $messageData->receiver_id = $CurrentUser->id; $messageText = $CurrentUser->fname . ' ' . $CurrentUser->lname . ' has sent a KarmaNote.'; $messageData->messageText = $messageText; $messageData->save(); $messageData = new Message(); $messageData->message_type = 'user'; $messageData->request_id = $meetingId; $messageData->sender_id = $CurrentUser->id; $messageData->giver_id = $giverId; $messageData->receiver_id = $CurrentUser->id; $messageTextOfKarmaNote = $karmaNoteMessage; $messageData->messageText = $messageTextOfKarmaNote; $messageData->save(); DB::table('users_mykarma')->where('entry_id', '=', $meetingId)->update(array('status' => 'completed', 'entry_updated_on' => Carbon::now())); DB::table('requests')->where('id', '=', $meetingId)->update(array('status' => 'completed')); $userRole = 'Receiver'; $changeStatus = KarmaHelper::updateMeetingStatus($meetingId, $userRole); KarmaHelper::updateKarmaScore($giverId, $receiverId); //KarmaHelper::storeKarmacirclesRecord($giverId,$receiverId); //KarmaHelper::storeKarmacirclesRelation($giverId,$receiverId); KarmaHelper::storeKarmacirclesfeed($giverId, $receiverId, $feedType, $karmaNoteId); if (!empty($introducerId)) { KarmaHelper::updateIntroducerKarmaScore($introducerId); } if (!empty($ShareKarmaNote)) { $receiverDetail = User::find($receiverId); //MessageHelper::shareOnLinkedin($receiverDetail->token,'asdasd');die(); Queue::push('MessageSender', array('type' => '9', 'user_id_giver' => $giverId, 'user_id_receiver' => $receiverId, 'meetingId' => $meetingId)); } //$sendLinkedinMessage = MessageHelper::triggerEmailAndMessage($giverId,$receiverId,'5',$meetingId); Queue::push('MessageSender', array('type' => '5', 'user_id_giver' => $giverId, 'user_id_receiver' => $receiverId, 'meetingId' => $meetingId)); return Redirect::to('meeting/' . $receiverName . '-' . $giverName . '/' . $meetingId); } }
public function fire() { //fetch all users $getusers = DB::table('users')->select(array('users.*'))->where('users.userstatus', '=', 'approved')->orderBy('created_at', 'DESC')->get(); //process for the records found if (!empty($getusers)) { $queryOfferHelp = array(); foreach ($getusers as $user_info) { $diffDate = KarmaHelper::dateDiff(date("Y-m-d H:i:s"), $user_info->created_at); if ($diffDate->days > -1) { $user_id = $user_info->id; $location = $user_info->location; /*$myKarmaDataOfInCompleteState= DB::select(DB::raw("SELECT COUNT( * ) AS AGGREGATE FROM `users_mykarma` WHERE `status` = 'completed' AND `user_id` =".$user_id." AND created_at > DATE_SUB(NOW(), INTERVAL 1 DAY)")); $myKarmaDataOfInCompleteState= DB::select(DB::raw("SELECT COUNT( * ) AS AGGREGATE FROM `users_mykarma` WHERE `status` != 'completed' AND `user_id` =".$user_id." AND created_at > DATE_SUB(NOW(), INTERVAL 1 DAY)"));*/ $myKarmaDataOfCompleteState = Mykarma::where('status', '=', 'completed')->where('user_id', '=', $user_id)->where('unread_flag', '=', 'true')->where('created_at', '>=', Carbon::now()->subDay(1))->count(); $myKarmaDataOfInCompleteState = Mykarma::where('status', '!=', 'completed')->where('user_id', '=', $user_id)->where('entry_type', '=', 'Meeting')->where('unread_flag', '=', 'true')->where('created_at', '>=', Carbon::now()->subDay(1))->count(); $myKarmaDataOfQuery = Mykarma::where('user_id', '=', $user_id)->where('entry_type', '=', 'Query')->get(); foreach ($myKarmaDataOfQuery as $key => $value) { $allQuery[] = $value->entry_id; } if (!empty($allQuery)) { $queryOfferHelp = Mykarma::whereIn('entry_id', $allQuery)->where('users_role', '=', 'OfferedHelp')->where('unread_flag', '=', 'true')->where('created_at', '>=', Carbon::now()->subDay(1))->count(); } // fetch user connections on KC $getUserConnection = KarmaHelper::getUserConnection($user_id, $location); $user_connection_onkc = 0; if (!empty($getUserConnection)) { foreach ($getUserConnection as $key => $value) { if (isset($value->con_user_id)) { $user_connection_onkc++; } } } // fetch pending karmanote requests $totalPendingRequest = 0; $PendingRequest = array(); $PendingRequest = KarmaHelper::getPendingKarmaNotes($user_info->id); if (!empty($PendingRequest)) { $totalPendingRequest = count($PendingRequest); } //fetch pending KM requests only received no read no unread $totalReceivedRequest = 0; $GiverInMeeting = User::find($user_info->id)->Giver()->where('status', 'pending')->orderBy('updated_at', 'DESC')->get(); if (!empty($GiverInMeeting)) { $totalReceivedRequest = count($GiverInMeeting); } //fetch pending karma intros $totalintroductionInitiated = 0; $IntroducerInitiated = User::find($user_info->id)->Introducer; if (!empty($IntroducerInitiated)) { foreach ($IntroducerInitiated as $key => $value) { $value['user_id_receiver'] = User::find($value['user_id_receiver'])->toArray(); if (!empty($value['user_id_giver'])) { $value['user_id_giver'] = User::find($value['user_id_giver'])->toArray(); } else { $value['user_id_giver'] = Connection::find($value['connection_id_giver'])->toArray(); } if ($value->status == 'pending') { $totalintroductionInitiated++; } } } // fetch queries that have been posted in the last 7 days within common groups including both public & private. $Usergroup = User::find($user_info->id)->Groups; $All_groups = ''; $group_question = 0; $totagroupquestion = 0; $yesterday = Carbon::now()->subDays(1); $one_week_ago = Carbon::now()->subWeeks(1); if (!$Usergroup->isEmpty()) { foreach ($Usergroup as $key => $value) { $All_groups[] = $value->id; } if (!empty($All_groups)) { $group_question = DB::table('group_questions')->join('questions', 'group_questions.question_id', '=', 'questions.id')->select(array('questions.id'))->whereIn('group_questions.group_id', $All_groups)->where('questions.user_id', '!=', $user_info->id)->where('questions.queryStatus', '=', 'open')->where('questions.created_at', '>=', $one_week_ago)->where('questions.created_at', '<=', $yesterday)->orderBy('questions.created_at', 'DESC')->groupBy('question_id')->get(); if (!empty($group_question)) { $totagroupquestion = count($group_question); } } } // fetch weekly suggestion option value set from admin $weekly_suggestion = "KarmaNote"; $weekly_suggestion = Adminoption::Where("option_name", "=", "Weekly Suggestion")->select("option_value")->first(); if (!empty($weekly_suggestion)) { $weekly_suggestion = $weekly_suggestion->option_value; } $getkcUser = $getsuggestion = array(); if ($weekly_suggestion == "KarmaMeeting") { // fetch a random users on KC platform with a common group of logged in user $getkcUser = KarmaHelper::fetchUserGroup($user_id); if (!empty($getkcUser)) { $getkcUser = $getkcUser[0]; } } else { // fetch a user connection either KC or NON KC $getsuggestion = KarmaHelper::getUserConnection($user_id, $location); //get test users id $getUser = KarmaHelper::getTestUsers(); if (!empty($getsuggestion)) { foreach ($getsuggestion as $key => $value) { $test_match = in_array($value->con_user_id, $getUser); if ($value->con_user_id != "" && $test_match != 1) { $getKc = DB::table('users as u')->select(array('u.userstatus', 'u.id', 'u.fname', 'u.lname', 'u.linkedinurl', 'u.piclink', 'u.headline', 'u.email', 'u.karmascore', 'u.location'))->where('u.id', '=', $value->con_user_id)->where('u.userstatus', '=', 'approved')->get(); if (!empty($getKc)) { $value->networkid = $getKc; } } } $getsuggestion = $getsuggestion[array_rand($getsuggestion)]; } } //fetch random 5 unique notes $getKarmanote = ""; $getKarmanote = KarmaHelper::getKarmanote(); $type = 19; $meetingIncomplete = $myKarmaDataOfInCompleteState; $meetingComplete = $myKarmaDataOfCompleteState; $offeredHelp = $queryOfferHelp; $user_id = $user_id; $user_connection_onkc = $user_connection_onkc; $totalPendingRequest = $totalPendingRequest; $totalReceivedRequest = $totalReceivedRequest; $totalintroductionInitiated = $totalintroductionInitiated; $totagroupquestion = $totagroupquestion; $getsuggestion = $getsuggestion; $getkcUser = $getkcUser; $getKarmanote = $getKarmanote; // call a function to send email if ($meetingIncomplete > 0 || $meetingComplete > 0 || $offeredHelp > 0) { $sendLinkedinMessage = MessageHelper::dailyUpdateMykarmaScreen($type, $user_id, $meetingIncomplete, $meetingComplete, $offeredHelp, $user_connection_onkc, $totalPendingRequest, $totalReceivedRequest, $totalintroductionInitiated, $totagroupquestion, $getsuggestion, $getkcUser, $getKarmanote); } /*Queue::push('MessageSender@MyKarmaDailyUpdateScreen',array('type' =>19,'meetingIncomplete'=>$myKarmaDataOfInCompleteState,'meetingComplete'=>$myKarmaDataOfCompleteState,'offeredHelp'=>$queryOfferHelp,'user_id' => $user_id,'user_connection_onkc'=>$user_connection_onkc,'totalPendingRequest' => $totalPendingRequest,'totalReceivedRequest'=>$totalReceivedRequest,'totalintroductionInitiated'=>$totalintroductionInitiated,'totagroupquestion'=>$totagroupquestion,'getsuggestion'=>$getsuggestion,'getkcUser'=>$getkcUser,'getKarmanote'=>$getKarmanote));*/ } } //endforeach } // endif Log::alert('Executed Daily Cron Job'); }
public function submitQueryForm() { $shareOnLinkedin = ''; if (!empty(Input::get('shareOnLinkedin'))) { $shareOnLinkedin = Input::get('shareOnLinkedin'); } if (!empty(Input::get('subject'))) { $subject = Input::get('subject'); } if (!empty(Input::get('description'))) { $description = Input::get('description'); } if (!empty(Input::get('skillTags'))) { $skills = Input::get('skillTags'); } if (!empty(Input::get('privacysetting'))) { $privacysetting = Input::get('privacysetting'); } if (!empty(Input::get('receiver_id'))) { $receiver_id = Input::get('receiver_id'); } if (!empty(Input::get('user_groups'))) { $user_groups = Input::get('user_groups'); } $url_subject = $subject; $url_subject = strtolower($url_subject); //Make alphanumeric (removes all other characters) $url_subject = preg_replace("/[^a-z0-9_\\s-]/", "", $url_subject); $url_subject = trim($url_subject); //Clean up multiple dashes or whitespaces $url_subject = preg_replace("/[\\s-]+/", " ", $url_subject); //Convert whitespaces and underscore to dash $url_subject = preg_replace("/[\\s_]/", "-", $url_subject); if (!empty($receiver_id)) { $Question = new Question(); $Question->user_id = $receiver_id; $Question->subject = strip_tags($subject); $Question->description = strip_tags($description); if (!empty($skills)) { $Question->skills = implode(',', $skills); } else { $Question->skills = ''; } $Question->access = $privacysetting; $Question->question_url = strtolower($url_subject); $Question->save(); $questionId = $Question->id; $getUser = User::where('id', '=', $receiver_id)->first(); //Add data on users_mykarma table for query $myKarmaDataQuery = new Mykarma(); $myKarmaDataQuery->entry_id = $questionId; $myKarmaDataQuery->user_id = $receiver_id; $myKarmaDataQuery->fname = $getUser->fname; $myKarmaDataQuery->lname = $getUser->lname; $myKarmaDataQuery->piclink = $getUser->piclink; $myKarmaDataQuery->entry_type = 'Query'; $myKarmaDataQuery->users_role = 'PostedQuery'; $myKarmaDataQuery->status = 'Open'; $myKarmaDataQuery->unread_flag = 'false'; $myKarmaDataQuery->no_of_unread_items = '0'; $myKarmaDataQuery->entry_updated_on = Carbon::now(); $myKarmaDataQuery->save(); $user_id_giver = 'null'; $feedType = 'KarmaQuery'; KarmaHelper::storeKarmacirclesfeed($user_id_giver, $receiver_id, $feedType, $questionId); if (!empty($user_groups)) { $user_groups = explode(',', $user_groups); foreach ($user_groups as $key => $value) { $Groupquestion = new Groupquestion(); $Groupquestion->question_id = $Question->id; $Groupquestion->group_id = $value; $Groupquestion->user_id = $Question->user_id; $Groupquestion->save(); } } //echo "<pre>";print_r($_POST);echo "</pre>";die(); if ($shareOnLinkedin == '1' && $privacysetting == 'public') { Queue::push('MessageSender@shareQuestionOnLinkedin', array('type' => '9', 'question_id' => $Question->id)); } return Redirect::to('/karma-queries'); } }
public function loadmoreProfile() { //Karma notes block $karmaTrailUser = $karmaReceivedUser = $karmaSentUser = ''; $profileSelf = 0; $CurrentUserDetail = ""; $CurrentUserId = 0; if (!empty($_REQUEST)) { $start = $_REQUEST['hitcount'] + 1; $action = $_REQUEST['action']; $id = $_REQUEST['userProfile']; $perpage = 10; $profileUserDetail = User::find($id); if (Auth::check()) { $CurrentUserDetail = Auth::User(); $CurrentUserId = $CurrentUserDetail->id; if ($CurrentUserId == $profileUserDetail['id']) { $profileSelf = "1"; } else { $profileSelf = "0"; } } if ($action == 'KarmaTrail') { $karmaTrail = KarmaHelper::getKarmaTrail($id, $start, $perpage); if (count($karmaTrail) > 0) { foreach ($karmaTrail as $trail) { $userSkills = ""; $karma['user_id_receiver'] = User::find($trail->user_id_receiver)->toArray(); if (!empty($trail->user_id_giver)) { $karma['user_id_giver'] = User::find($trail->user_id_giver)->toArray(); } else { $karma['user_id_giver'] = Connection::find($trail->connection_id_giver)->toArray(); } if ($id == $trail->user_id_receiver) { $karma['status'] = $trail->statusreceiver; } else { $karma['status'] = $trail->statusgiver; } $karma['piclink'] = $trail->piclink; $karma['karmaNotes'] = $trail->details; if (!empty($trail->skills)) { $userSkills = KarmaHelper::getSkillsname($trail->skills); } $karma['skills'] = $userSkills; $karma['req_id'] = $trail->req_id; $karma['meetingdatetime'] = date('F d, Y', strtotime($trail->meetingdatetime)); $karma['created_at'] = date('F d, Y', strtotime($trail->created_at)); $karmaTrailUser[] = $karma; } } } //echo "<pre>";print_r($karmaTrailUser);echo "</pre>";die; if ($action == 'KarmaNotesReceived') { $karmaReceived = $profileUserDetail->KarmanoteReceiver()->orderBy('karmanotes.created_at', 'desc')->skip($start)->take($perpage)->get(); if (!empty($karmaReceived)) { foreach ($karmaReceived->toArray() as $received) { $userReceivedSkills = ""; $karmareceived['user_id_receiver'] = User::find($received['user_idreceiver'])->toArray(); if (!empty($received['user_id_giver'])) { $karmareceived['user_id_giver'] = User::find($received['user_idgiver'])->toArray(); } else { $karmareceived['user_id_giver'] = Connection::find($received['connection_idgiver'])->toArray(); } $karmareceived['karmaNotes'] = $received['details']; if (!empty($received['skills'])) { $userReceivedSkills = KarmaHelper::getSkillsname($received['skills']); } $karmareceived['skills'] = $userReceivedSkills; $karmareceived['status'] = $received['statusgiver']; $karmareceived['req_id'] = $received['req_id']; $karmareceived['req_detail'] = Meetingrequest::find($received['req_id']); $karmareceived['created_at'] = date('F d, Y', strtotime($received['created_at'])); $karmaReceivedUser[] = $karmareceived; } } } //echo "<pre>";print_r($karmaReceived->toArray());echo "</pre>";die; if ($action == 'KarmaNotesSent') { $karmaSent = $profileUserDetail->KarmanoteGiver()->orderBy('karmanotes.created_at', 'desc')->skip($start)->take($perpage)->get(); //echo "<pre>";print_r($karmaSent->toArray());echo "</pre>";die; if (!empty($karmaSent)) { foreach ($karmaSent->toArray() as $sent) { $userSentSkills = ""; $karmasent['user_id_receiver'] = User::find($sent['user_idreceiver'])->toArray(); if (!empty($sent['user_idgiver'])) { $karmasent['user_id_giver'] = User::find($sent['user_idgiver'])->toArray(); } else { $karmasent['user_id_giver'] = Connection::find($sent['connection_idgiver'])->toArray(); } $karmasent['karmaNotes'] = $sent['details']; if (!empty($sent['skills'])) { $userSentSkills = KarmaHelper::getSkillsname($sent['skills']); } $karmasent['skills'] = $userSentSkills; $karmasent['req_id'] = $sent['req_id']; $karmasent['req_detail'] = Meetingrequest::find($sent['req_id'])->toArray(); $karmasent['status'] = $sent['statusreceiver']; $karmasent['created_at'] = date('F d, Y', strtotime($sent['created_at'])); $karmaSentUser[] = $karmasent; } } } return View::make('ajax_loadmoreProfile', array('id' => $id, 'CurrentUserDetail' => $CurrentUserDetail, 'profileSelf' => $profileSelf, 'karmaTrail' => $karmaTrailUser, 'profileUserDetail' => $profileUserDetail, 'countTrail' => 0, 'countReceived' => 0, 'countSent' => 0, 'profielURL' => '', 'karmascore' => '', 'karmaReceived' => $karmaReceivedUser, 'karmaSent' => $karmaSentUser)); } }
/** * 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']); if ($rules->fails()) { $this->status = 'failure'; $this->message = 'There is something missing So user cant be registered'; return Response::json(array('status' => $this->status, 'message' => $this->message)); } else { $linkedinid = Request::get('linkedinid'); $email = Request::get('email'); $user = User::where('linkedinid', '=', $linkedinid)->orWhere('email', '=', $email)->first(); $randNumber = ApiController::getGUID(); if (!empty($user)) { //This code will execute when user will already register. $user_id = $user->id; $user_data = $user->toArray(); $user_id = $user_data['id']; $user_info = User::find($user_id); $user = User::find($user_id); $user->token = $result['token']; $user->site_token = $randNumber; $user->save(); $CurrentDate = KarmaHelper::currentDate(); $profileupdatedate = $user_info->profileupdatedate; $diffDate = KarmaHelper::dateDiff($CurrentDate, $profileupdatedate); $diffDate = $diffDate->days * 24 + $diffDate->h; $refreshTime = Adminoption::where('option_name', '=', 'connection refresh time')->first(); 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)); } $this->status = 'Success'; $this->message = 'You are already registered'; $userStatus = User::where('linkedinid', '=', $linkedinid)->orWhere('email', '=', $email)->select('userstatus')->first(); $userStatus = $userStatus->userstatus; } 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->termsofuse = 1; $user->userstatus = 'ready for approval'; $user->noofmeetingspm = 2; $user->profileupdatedate = date('Y-m-d H:i:s'); $user->site_token = $randNumber; $user->save(); $user = $user; $user_id = $user->id; Queue::push('MessageSender@newUserEmail', array('user_id' => $user_id)); //funtion to save data on connections table. $InsConnection = KarmaHelper::insertUserConnection($user); $this->status = 'Success'; $this->message = 'User successfully registered'; $userStatus = User::where('linkedinid', '=', $result['linkedinid'])->orWhere('email', '=', $result['email'])->select('userstatus')->first(); $userStatus = $userStatus->userstatus; } return Response::json(array('status' => $this->status, 'message' => $this->message, 'UserId' => $user_id, 'UserAccesstoken' => $user->site_token, 'UserStatus' => $userStatus)); } }
public function submitIntroform() { $payitforward = $sendKarmaNote = $buyyoucoffee = '0'; $receiverWR = Input::get('receiverWR'); if (!empty($receiverWR)) { foreach ($receiverWR as $key => $value) { if ($value == "I'd pay it forward") { $payitforward = '1'; } elseif ($value == "I'd send you a Karma Note") { $sendKarmaNote = '1'; } } } $giver_email = Input::get('giver_email'); $user_id_receiver = Input::get('receiver_id'); $connection_id_receiver = Input::get('receiver_conn_id'); if (!empty(Input::get('giver_id') && Input::get('giver_id') != 'undefined')) { echo $user_id_giver = Input::get('giver_id'); } $connection_id_giver = Input::get('giver_conn_id'); $user_id_introducer = Input::get('user_id_Intro'); $detail = Input::get('note'); if (!empty($user_id_giver)) { $Meetingrequest = new Meetingrequest(); $Meetingrequest->user_id_introducer = $user_id_introducer; $Meetingrequest->user_id_receiver = $user_id_receiver; $Meetingrequest->user_id_giver = $user_id_giver; $Meetingrequest->connection_id_giver = $connection_id_giver; $Meetingrequest->notes = strip_tags($detail); $Meetingrequest->payitforward = $payitforward; $Meetingrequest->sendKarmaNote = $sendKarmaNote; $Meetingrequest->buyyoucoffee = $buyyoucoffee; $Meetingrequest->status = 'pending'; $Meetingrequest->req_createdate = KarmaHelper::currentDate(); $Meetingrequest->save(); $meetingId = $Meetingrequest->id; Queue::push('MessageSender', array('type' => '12', 'user_id_giver' => $user_id_giver, 'user_id_receiver' => $user_id_receiver, 'meetingId' => $meetingId)); //$sendLinkedinMessage = MessageHelper::triggerEmailAndMessage($user_id_giver,$user_id_receiver,'12',$meetingId); //echo "<pre>";print_r($sendLinkedinMessage);echo "</pre>";die(); return Redirect::to('/karma-intro'); } else { $Meetingrequest = new Meetingrequest(); $Meetingrequest->user_id_introducer = $user_id_introducer; $Meetingrequest->user_id_receiver = $user_id_receiver; $Meetingrequest->connection_id_giver = $connection_id_giver; $Meetingrequest->notes = strip_tags($detail); $Meetingrequest->payitforward = $payitforward; $Meetingrequest->sendKarmaNote = $sendKarmaNote; $Meetingrequest->buyyoucoffee = $buyyoucoffee; $Meetingrequest->status = 'pending'; $Meetingrequest->req_createdate = KarmaHelper::currentDate(); $Meetingrequest->save(); $meetingId = $Meetingrequest->id; if ($giver_email != "") { Queue::push('MessageSender@IntroEmailToNonKarmaGiver', array('type' => '15', 'user_id_giver' => $connection_id_giver, 'user_id_receiver' => $user_id_receiver, 'giver_email' => $giver_email, 'meetingId' => $meetingId)); } Queue::push('MessageSender', array('type' => '13', 'user_id_giver' => $connection_id_giver, 'user_id_receiver' => $user_id_receiver, 'meetingId' => $meetingId)); return Redirect::to('/karma-intro'); /*For Sending Intro Email to Non Karma User if email id is given*/ } }
/** * Function to save confirm meeting data. * * @return Response */ public static function commonMeetingHappened($meetingId, $userRole) { $getMeetingId = Meetingrequest::where('id', '=', $meetingId)->first(); $userId = $getMeetingId->user_id_receiver; $getUser = User::find($userId); DB::table('users_mykarma')->where('entry_id', '=', $meetingId)->update(array('status' => 'happened', 'entry_updated_on' => Carbon::now())); DB::table('requests')->where('id', '=', $meetingId)->update(array('status' => 'happened')); $getGiverData = DB::table('requests')->join('users', 'requests.user_id_giver', '=', 'users.id')->where('requests.id', '=', $meetingId)->select('requests.user_id_giver', 'users.fname', 'users.lname')->get(); //Add message in requests_messages table if (!empty($getGiverData)) { $messageData = new Message(); $messageData->request_id = $meetingId; $messageData->sender_id = $getGiverData[0]->user_id_giver; $messageData->giver_id = $getGiverData[0]->user_id_giver; $messageData->receiver_id = $userId; $messageText = $getGiverData[0]->fname . ' ' . $getGiverData[0]->lname . ' has indicated that the meeting has happened.'; $messageData->messageText = $messageText; $messageData->save(); $changeStatus = KarmaHelper::updateMeetingStatus($meetingId, $userRole); } else { $getGiverData = array(); } return $getGiverData; }
@extends('common.master') @section('content') <?php $timeSlot = KarmaHelper::halfHourTimes(); ?> <section class="mainWidth"> <div class="col-lg-10 col-md-10 col-sm-12 centralize pdding0"> <!-- <div class="backlink pull-right clearfix"> <a href="/dashboard">Back to Karma Circle</a> </div> --> <div class="col-md-11 col-sm-12 centralize clearfix pull-left no-pull-md"> <div class="registrFrm sendnotes col-md-12 clearfix"> <!-- Form start --> {{ Form::open(array('url' => 'saveDirectKarmaNote' , 'method' => ' post','onsubmit'=>'return validateKCnote();')) }} <div class="sendnoteBox"> <div class="col-xs-4 pdding0 borderPic"> @if ($CurrentUser->piclink == '') <img alt="" src="/images/default.png"> @else <img alt="{{$CurrentUser->fname}}" src="{{$CurrentUser->piclink}}" title="{{$CurrentUser->fname}}"> @endif <h4>{{$CurrentUser->fname}}</h4> <div class="borderPic midicondetails"> <ul class="clearfix"> <li> <a target="_blank" href="{{$CurrentUser->linkedinurl}}"><img alt="" src="/images/linkdin.png"></a> </li> <li> <a href="/profile/<?php echo strtolower($CurrentUser->fname . '-' . $CurrentUser->lname) . '/' . $CurrentUser->id;
/** * Execute the console command. * * @return mixed */ public function fire() { Log::alert('Executed Cron Job to update user data daily.'); $getusers = DB::table('users')->select(array('users.*'))->where('users.userstatus', '=', 'approved')->orderBy('created_at', 'DESC')->get(); if (!empty($getusers)) { foreach ($getusers as $user_info) { $diffDate = KarmaHelper::dateDiff(date("Y-m-d H:i:s"), $user_info->profileupdatedate); if ($diffDate->days < 60) { $user_data = User::find($user_info->id); $token = $user_data->token; //$result = json_decode(file_get_contents("https://api.linkedin.com/v1/people/~:(id,first-name,last-name,skills,headline,summary,industry,member-url-resources,picture-urls::(original),location,public-profile-url,email-address)?format=json&oauth2_access_token=$token")); $curl_handle = curl_init(); curl_setopt($curl_handle, CURLOPT_URL, 'https://api.linkedin.com/v1/people/~:(id,first-name,last-name,skills,headline,summary,industry,member-url-resources,picture-urls::(original),location,public-profile-url,email-address)?format=json&oauth2_access_token=$token'); curl_setopt($curl_handle, CURLOPT_CONNECTTIMEOUT, 2); curl_setopt($curl_handle, CURLOPT_RETURNTRANSFER, 1); curl_setopt($curl_handle, CURLOPT_USERAGENT, 'Your application name'); $result = curl_exec($curl_handle); curl_close($curl_handle); $publicProfileUrl = ""; if (isset($result->id)) { $InsTag = KarmaHelper::insertUsertag($user_data, $result); // Close insertUserConnection due to linkedIn changes //$InsConnection = KarmaHelper::insertUserConnection($user_data); $InsConnection = KarmaHelper::updateUserProfile($user_info->id, $result); //update user profile details if (!isset($result->publicProfileUrl) || $result->publicProfileUrl == '') { $publicProfileUrl = $result->siteStandardProfileRequest['url']; } else { $publicProfileUrl = $result->publicProfileUrl; } $imageurl = ""; if (isset($result->pictureUrls->values[0])) { $imageurl = $result->pictureUrls->values[0]; } $user = User::find($user_info->id); $user->email = $result->emailAddress; if (isset($imageurl)) { $user->piclink = $imageurl; } if (isset($result->summary)) { $user->summary = $result->summary; } if (!empty($result->location)) { $user->location = $result->location->name; } if (isset($result->industry)) { $user->industry = $result->industry; } if (isset($result->headline)) { $user->headline = $result->headline; } if ($publicProfileUrl != "") { $user->linkedinurl = $publicProfileUrl; } $user->profileupdatedate = date('Y-m-d H:i:s'); $user->save(); } sleep('2'); } } } }
public function join_leaveGroup() { $group_id = $_POST['groupId']; $action = $_POST['action']; $CurrentUser = Auth::User(); $user_id = $CurrentUser->id; $UsersgroupCount = Usersgroup::where('user_id', '=', $user_id)->count(); //die($action); if ($action == 'leave') { if ($UsersgroupCount > 1) { $UsersgroupCount = Usersgroup::where('user_id', '=', $user_id)->where('group_id', '=', $group_id)->delete(); die('success'); } else { die("error"); } } if ($action == 'join') { $UsersgroupCount = Usersgroup::where('user_id', '=', $user_id)->where('group_id', '=', $group_id)->delete(); $usergroup = new Usersgroup(); $usergroup->user_id = $user_id; $usergroup->group_id = $group_id; $usergroup->save(); $user_id_giver = 'null'; $feedType = 'KarmaGroup'; KarmaHelper::storeKarmacirclesfeed($user_id_giver, $user_id, $feedType, $group_id); die('success'); } }
public function viewreq_detail($request_id, $action) { $karmaTrailMeet = KarmaHelper::getAdminReportMeet($request_id, 0, 0, 0); return View::make('admin.viewreq_detail', array('karmaTrail' => $karmaTrailMeet, 'action' => $action)); }