/** * Load user data from social net when edit Leads/Contacts/Accounts * @param Vtiger_Request $request */ function loadProfile(Vtiger_Request $request) { $url = vtlib_purify($request->get('URL')); $source_module = vtlib_purify($request->get('sourcemodule')); $recordid = vtlib_purify($request->get('recordid')); $module = $request->getModule(); $response = SPSocialConnectorHelper::parseURL($url); $user_profile = SPSocialConnectorHelper::hybridauthUserProfile($response->id, $response->domen); if (!empty($user_profile->birthDay) && !empty($user_profile->birthMonth) && !empty($user_profile->birthYear)) { $date = $user_profile->birthDay . '-' . $user_profile->birthMonth . '-' . $user_profile->birthYear; $date = date('Y-m-d', strtotime($date)); } else { $date = NULL; } $region = trim($user_profile->region, ','); $regionlist = explode(',', $region); $user_profile->birthDay = $date; $user_profile->city = $regionlist[0]; $user_profile->country = $regionlist[1]; $updated_fields = SPSocialConnectorHelper::addDataByModule($source_module, $recordid, $user_profile); $viewer = $this->getViewer($request); $viewer->assign('MODULE', $module); $viewer->assign('UPDATED_FIELDS', $updated_fields); $viewer->view('LoadProfileStatus.tpl', $module); }