Check if the current user is connected to a given provider
public static isConnectedWith ( string $providerId ) : boolean | ||
$providerId | string | ID of the provider |
Résultat | boolean |
public function action_login() { //if user loged in redirect home if (Auth::instance()->logged_in()) { Auth::instance()->login_redirect(); } Social::include_vendor(); $user = FALSE; $config = Social::get(); if ($this->request->query('hauth_start') or $this->request->query('hauth_done')) { try { Hybrid_Endpoint::process($this->request->query()); } catch (Exception $e) { Alert::set(Alert::ERROR, $e->getMessage()); $this->redirect(Route::url('default')); } } else { $provider_name = $this->request->param('id'); try { // initialize Hybrid_Auth with a given file $hybridauth = new Hybrid_Auth($config); // try to authenticate with the selected provider if ($provider_name == 'openid') { $params = array('openid_identifier' => 'https://openid.stackexchange.com/'); } else { $params = NULL; } $adapter = $hybridauth->authenticate($provider_name, $params); if ($hybridauth->isConnectedWith($provider_name)) { //var_dump($adapter->getUserProfile()); $user_profile = $adapter->getUserProfile(); } } catch (Exception $e) { Alert::set(Alert::ERROR, __('Error: please try again!') . " " . $e->getMessage()); $this->redirect(Route::url('default')); } //try to login the user with same provider and identifier $user = Auth::instance()->social_login($provider_name, $user_profile->identifier); //we couldnt login create account if ($user == FALSE) { $email = $user_profile->emailVerified != NULL ? $user_profile->emailVerified : $user_profile->email; $name = $user_profile->firstName != NULL ? $user_profile->firstName . ' ' . $user_profile->lastName : $user_profile->displayName; //if not email provided if (!Valid::email($email, TRUE)) { Alert::set(Alert::INFO, __('We need your email address to complete')); //redirect him to select the email to register $this->redirect(Route::url('default', array('controller' => 'social', 'action' => 'register', 'id' => $provider_name)) . '?uid=' . $user_profile->identifier . '&name=' . $name); } else { //register the user in DB Model_User::create_social($email, $name, $provider_name, $user_profile->identifier); //log him in Auth::instance()->social_login($provider_name, $user_profile->identifier); } } else { Alert::set(Alert::SUCCESS, __('Welcome!')); } $this->redirect(Session::instance()->get_once('auth_redirect', Route::url('default'))); } }
/** * Return array listing all enabled providers as well as a flag if you are connected. */ public static function getProviders() { $idps = array(); foreach (Hybrid_Auth::$config["providers"] as $idpid => $params) { if ($params['enabled']) { $idps[$idpid] = array('connected' => false); if (Hybrid_Auth::isConnectedWith($idpid)) { $idps[$idpid]['connected'] = true; } } } return $idps; }
<?php // config and whatnot $config = dirname(__FILE__) . '/../../hybridauth/config.php'; require_once "../../hybridauth/Hybrid/Auth.php"; // initialise hybridauth $hybridauth = new Hybrid_Auth($config); // selected provider name $provider = @trim(strip_tags($_GET["provider"])); // check if the user is currently connected to the selected provider if (!$hybridauth->isConnectedWith($provider)) { // redirect him back to login page header("Location: login.php?error=Your are not connected to {$provider} or your session has expired"); } ?> <!DOCTYPE html> <html lang="en"> <head> <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> <link rel="stylesheet" href="public/css.css" type="text/css"> </head> <body> <table width="90%" border="0" cellpadding="2" cellspacing="2"> <tr> <td valign="top"> <?php include "includes/menu.php"; ?> <fieldset> <legend>Post feed to Facebook pages</legend>
# start a new PHP session session_start(); // we need to know it $CURRENT_URL = !empty($_SERVER['HTTPS']) ? "https://" . $_SERVER['SERVER_NAME'] . $_SERVER['REQUEST_URI'] : "http://" . $_SERVER['SERVER_NAME'] . $_SERVER['REQUEST_URI']; // change the following paths if necessary $config = dirname(__FILE__) . '/../../../hybridauth/config.php'; require_once "../../../hybridauth/Hybrid/Auth.php"; try { $hybridauth = new Hybrid_Auth($config); } catch (Exception $e) { echo "Ooophs, we got an error: " . $e->getMessage(); } $provider = ""; // handle logout request if (isset($_GET["logout"])) { $provider = $_GET["logout"]; $adapter = $hybridauth->getAdapter($provider); $adapter->logout(); header("Location: index.php"); die; } elseif (isset($_GET["connected_with"]) && $hybridauth->isConnectedWith($_GET["connected_with"])) { $provider = $_GET["connected_with"]; $adapter = $hybridauth->getAdapter($provider); $user_data = $adapter->getUserProfile(); // include authenticated user view include "inc_authenticated_user.php"; die; } // if user connected to the selected provider // if not, include unauthenticated user view include "inc_unauthenticated_user.php";
public function socialAuthUnLink() { if (!empty($_GET['unlink'])) { // change the following paths if necessary $config = SYSTEM_PATH . '/hybridauth/config.php'; require_once SYSTEM_PATH . '/hybridauth/Hybrid/Auth.php'; // the selected provider $provider_name = $this->sanitize($_GET['unlink'], 'string'); try { // initialize Hybrid_Auth with a given file $hybridauth = new Hybrid_Auth($config); //prepare the sql query $social_login = $this->sql->prepare('DELETE FROM social_connect WHERE provider_identify = ?'); $social_login->execute(array($this->uid . $provider_name)); $this->queries++; if ($hybridauth->isConnectedWith($provider_name)) { unset($_SESSION['HA::CONFIG']); unset($_SESSION['HA::STORE']); } return true; } catch (Exception $e) { return false; } } }
public function logout() { if (!e107::getPref('social_login_active', false) || !$this->adapter || !Hybrid_Auth::isConnectedWith($this->getProvider())) { return true; } try { $this->adapter->logout(); $this->adapter = null; } catch (Exception $e) { return $e->getMessage(); } return true; }
echo $e->getTraceAsString(); ?> </pre> </td> </tr> </table> <?php // diplay error and RIP die; } $provider = @$_GET["provider"]; $return_to = @$_GET["return_to"]; if (!$return_to) { echo "Invalid params!"; } if (!empty($provider) && $hybridauth->isConnectedWith($provider)) { $return_to = $return_to . (strpos($return_to, '?') ? '&' : '?') . "connected_with=" . $provider; ?> <script language="javascript"> if( window.opener ){ try { window.opener.parent.$.colorbox.close(); } catch(err) {} window.opener.parent.location.href = "<?php echo $return_to; ?> "; } window.self.close(); </script> <?php die;
function wsl_process_login() { if (!isset($_REQUEST['action']) || $_REQUEST['action'] != "wordpress_social_login") { return; } if (isset($_REQUEST['redirect_to']) && $_REQUEST['redirect_to'] != '') { $redirect_to = $_REQUEST['redirect_to']; // Redirect to https if user wants ssl if (isset($secure_cookie) && $secure_cookie && false !== strpos($redirect_to, 'wp-admin')) { $redirect_to = preg_replace('|^http://|', 'https://', $redirect_to); } if (strpos($redirect_to, 'wp-admin')) { $redirect_to = get_option('wsl_settings_redirect_url'); } } if (empty($redirect_to)) { $redirect_to = get_option('wsl_settings_redirect_url'); } if (empty($redirect_to)) { $redirect_to = site_url(); } try { // load hybridauth require_once dirname(__FILE__) . "/../hybridauth/Hybrid/Auth.php"; // selected provider name $provider = @trim(strip_tags($_REQUEST["provider"])); // build required configuratoin for this provider if (!get_option('wsl_settings_' . $provider . '_enabled')) { throw new Exception('Unknown or disabled provider'); } $config = array(); $config["base_url"] = plugins_url() . '/' . basename(dirname(__FILE__)) . '/hybridauth/'; $config["providers"] = array(); $config["providers"][$provider] = array(); $config["providers"][$provider]["enabled"] = true; // provider application id ? if (get_option('wsl_settings_' . $provider . '_app_id')) { $config["providers"][$provider]["keys"]["id"] = get_option('wsl_settings_' . $provider . '_app_id'); } // provider application key ? if (get_option('wsl_settings_' . $provider . '_app_key')) { $config["providers"][$provider]["keys"]["key"] = get_option('wsl_settings_' . $provider . '_app_key'); } // provider application secret ? if (get_option('wsl_settings_' . $provider . '_app_secret')) { $config["providers"][$provider]["keys"]["secret"] = get_option('wsl_settings_' . $provider . '_app_secret'); } // create an instance for Hybridauth $hybridauth = new Hybrid_Auth($config); // try to authenticate the selected $provider if ($hybridauth->isConnectedWith($provider)) { $adapter = $hybridauth->getAdapter($provider); $hybridauth_user_profile = $adapter->getUserProfile(); } else { throw new Exception('User not connected with ' . $provider . '!'); } $user_email = $hybridauth_user_profile->email; } catch (Exception $e) { die("Unspecified error. #" . $e->getCode()); } $user_id = null; // if the user email is verified, then try to map to legacy account if exist // > Currently only Facebook, Google, Yhaoo and Foursquare do provide the verified user email. if (!empty($hybridauth_user_profile->emailVerified)) { $user_id = (int) email_exists($hybridauth_user_profile->emailVerified); } // try to get user by meta if not if (!$user_id) { $user_id = (int) wsl_get_user_by_meta($provider, $hybridauth_user_profile->identifier); } // if user found if ($user_id) { $user_data = get_userdata($user_id); $user_login = $user_data->user_login; } else { // generate a valid user login $user_login = str_replace(' ', '_', strtolower($hybridauth_user_profile->displayName)); if (!validate_username($user_login)) { $user_login = strtolower($provider) . "_user_" . md5($hybridauth_user_profile->identifier); } // user name should be unique if (username_exists($user_login)) { $i = 1; $user_login_tmp = $user_login; do { $user_login_tmp = $user_login . "_" . $i++; } while (username_exists($user_login_tmp)); $user_login = $user_login_tmp; } // generate an email if none if (!isset($user_email) or !is_email($user_email)) { $user_email = strtolower($provider . "_user_" . $user_login) . "@example.com"; } // email should be unique if (email_exists($user_email)) { do { $user_email = md5(uniqid(wp_rand(10000, 99000))) . "@example.com"; } while (email_exists($user_email)); } $userdata = array('user_login' => $user_login, 'user_email' => $user_email, 'first_name' => $hybridauth_user_profile->firstName, 'last_name' => $hybridauth_user_profile->lastName, 'user_nicename' => $hybridauth_user_profile->displayName, 'display_name' => $hybridauth_user_profile->displayName, 'user_url' => $hybridauth_user_profile->profileURL, 'description' => $hybridauth_user_profile->description, 'user_pass' => wp_generate_password()); // Create a new user $user_id = wp_insert_user($userdata); // update user metadata if ($user_id && is_integer($user_id)) { update_user_meta($user_id, $provider, $hybridauth_user_profile->identifier); } else { die("An error occurred while creating a new user!"); } } $user_age = $hybridauth_user_profile->age; // not that precise you say... well welcome to my world if (!$user_age && (int) $hybridauth_user_profile->birthYear) { $user_age = (int) date("Y") - (int) $hybridauth_user_profile->birthYear; } update_user_meta($user_id, 'wsl_user', $provider); update_user_meta($user_id, 'wsl_user_gender', $hybridauth_user_profile->gender); update_user_meta($user_id, 'wsl_user_age', $user_age); update_user_meta($user_id, 'wsl_user_image', $hybridauth_user_profile->photoURL); wp_set_auth_cookie($user_id); wp_safe_redirect($redirect_to); exit; }
/** * Return array listing all authenticated providers */ public static function getConnectedProviders() { $idps = array(); foreach (Hybrid_Auth::$config["providers"] as $idpid => $params) { if (Hybrid_Auth::isConnectedWith($idpid)) { $idps[] = $idpid; } } return $idps; }
/** * auth * * @static * @param string $provider Provider name * @param string $status Status text * @return boolean */ public static function auth($provider, $status) { $chk = 0; // load library X4Core_core::auto_load('hybridauth_library'); try { // hybridauth EP $hybridauth = new Hybrid_Auth(SPATH . 'libraries/hybridauth/config.php'); // auth $adapter = $hybridauth->authenticate($provider); if ($hybridauth->isConnectedWith($provider)) { // status $adapter->setUserStatus($status); /* // get the user profile $user_profile = $adapter->getUserProfile(); echo "<pre>" . print_r( $user_profile, true ) . "</pre><br />"; */ // logout $adapter->logout(); $chk = 1; } } catch (Exception $e) { if (DEBUG) { // Display the recived error, // to know more please refer to Exceptions handling section on the userguide switch ($e->getCode()) { case 0: echo "Unspecified error."; break; case 1: echo "Hybridauth configuration error."; break; case 2: echo "Provider not properly configured."; break; case 3: echo "Unknown or disabled provider."; break; case 4: echo "Missing provider application credentials."; break; case 5: echo "Authentication failed. " . "The user has canceled the authentication or the provider refused the connection."; break; case 6: echo "User profile request failed. Most likely the user is not connected " . "to the provider and he should to authenticate again."; $twitter->logout(); break; case 7: echo "User not connected to the provider."; $twitter->logout(); break; case 8: echo "Provider does not support this feature."; break; } // well, basically your should not display this to the end user, just give him a hint and move on.. echo "<br /><br /><b>Original error message:</b> " . $e->getMessage(); echo "<hr /><h3>Trace</h3> <pre>" . $e->getTraceAsString() . "</pre>"; } } return $chk; }
function wsl_process_login_hybridauth_authenticate($provider, $redirect_to) { try { # Hybrid_Auth already used? if (class_exists('Hybrid_Auth', false)) { return wsl_render_notices_pages(_wsl__("Error: Another plugin seems to be using HybridAuth Library and made WordPress Social Login unusable. We recommand to find this plugin and to kill it with fire!", 'wordpress-social-login')); } // load hybridauth require_once WORDPRESS_SOCIAL_LOGIN_ABS_PATH . "/hybridauth/Hybrid/Auth.php"; // build required configuratoin for this provider if (!get_option('wsl_settings_' . $provider . '_enabled')) { throw new Exception('Unknown or disabled provider'); } $config = array(); $config["providers"] = array(); $config["providers"][$provider] = array(); $config["providers"][$provider]["enabled"] = true; // provider application id ? if (get_option('wsl_settings_' . $provider . '_app_id')) { $config["providers"][$provider]["keys"]["id"] = get_option('wsl_settings_' . $provider . '_app_id'); } // provider application key ? if (get_option('wsl_settings_' . $provider . '_app_key')) { $config["providers"][$provider]["keys"]["key"] = get_option('wsl_settings_' . $provider . '_app_key'); } // provider application secret ? if (get_option('wsl_settings_' . $provider . '_app_secret')) { $config["providers"][$provider]["keys"]["secret"] = get_option('wsl_settings_' . $provider . '_app_secret'); } // create an instance for Hybridauth $hybridauth = new Hybrid_Auth($config); // try to authenticate the selected $provider if ($hybridauth->isConnectedWith($provider)) { $adapter = $hybridauth->getAdapter($provider); $hybridauth_user_profile = $adapter->getUserProfile(); // check hybridauth user email $hybridauth_user_id = (int) wsl_get_user_by_meta($provider, $hybridauth_user_profile->identifier); $hybridauth_user_email = sanitize_email($hybridauth_user_profile->email); $hybridauth_user_login = sanitize_user($hybridauth_user_profile->displayName); $request_user_login = ""; $request_user_email = ""; # {{{ linking new accounts // Bouncer :: Accounts Linking is enabled if (get_option('wsl_settings_bouncer_linking_accounts_enabled') == 1) { // if user is linking account // . we DO import contacts // . we DO store the user profile // // . we DONT create another entry on user table // . we DONT create nor update his data on usermeata table if ($_REQUEST['action'] == "wordpress_social_link") { global $current_user; get_currentuserinfo(); $user_id = $current_user->ID; return wsl_process_login_authenticate_wp_user_linked_account($user_id, $provider, $redirect_to, $adapter, $hybridauth_user_profile); } // check if connected user is linked account $linked_account = wsl_get_user_linked_account_by_provider_and_identifier($provider, $hybridauth_user_profile->identifier); // if linked account found, we connect the actual user if ($linked_account) { if (count($linked_account) > 1) { return wsl_render_notices_pages(_wsl__("This {$provider} is linked to many accounts!", 'wordpress-social-login')); } $user_id = $linked_account[0]->user_id; if (!$user_id) { return wsl_render_notices_pages(_wsl__("Something wrong!", 'wordpress-social-login')); } return wsl_process_login_authenticate_wp_user($user_id, $provider, $redirect_to, $adapter, $hybridauth_user_profile); } } # }}} linking new accounts # {{{ module Bouncer // Bouncer :: Filters by emails domains name if (get_option('wsl_settings_bouncer_new_users_restrict_domain_enabled') == 1) { if (empty($hybridauth_user_email)) { return wsl_render_notices_pages(get_option('wsl_settings_bouncer_new_users_restrict_domain_text_bounce')); } $list = get_option('wsl_settings_bouncer_new_users_restrict_domain_list'); $list = preg_split('/$\\R?^/m', $list); $current = strstr($hybridauth_user_email, '@'); $shall_pass = false; foreach ($list as $item) { if (trim(strtolower("@{$item}")) == strtolower($current)) { $shall_pass = true; } } if (!$shall_pass) { return wsl_render_notices_pages(get_option('wsl_settings_bouncer_new_users_restrict_domain_text_bounce')); } } // Bouncer :: Filters by e-mails addresses if (get_option('wsl_settings_bouncer_new_users_restrict_email_enabled') == 1) { if (empty($hybridauth_user_email)) { return wsl_render_notices_pages(get_option('wsl_settings_bouncer_new_users_restrict_email_text_bounce')); } $list = get_option('wsl_settings_bouncer_new_users_restrict_email_list'); $list = preg_split('/$\\R?^/m', $list); $shall_pass = false; foreach ($list as $item) { if (trim(strtolower($item)) == strtolower($hybridauth_user_email)) { $shall_pass = true; } } if (!$shall_pass) { return wsl_render_notices_pages(get_option('wsl_settings_bouncer_new_users_restrict_email_text_bounce')); } } // Bouncer :: Filters by profile urls if (get_option('wsl_settings_bouncer_new_users_restrict_profile_enabled') == 1) { $list = get_option('wsl_settings_bouncer_new_users_restrict_profile_list'); $list = preg_split('/$\\R?^/m', $list); $shall_pass = false; foreach ($list as $item) { if (trim(strtolower($item)) == strtolower($hybridauth_user_profile->profileURL)) { $shall_pass = true; } } if (!$shall_pass) { return wsl_render_notices_pages(get_option('wsl_settings_bouncer_new_users_restrict_profile_text_bounce')); } } // if user do not exist if (!$hybridauth_user_id) { // Bouncer :: Accept new registrations if (get_option('wsl_settings_bouncer_registration_enabled') == 2) { return wsl_render_notices_pages(_wsl__("registration is now closed!", 'wordpress-social-login')); } // Bouncer :: Profile Completion if (get_option('wsl_settings_bouncer_profile_completion_require_email') == 1 && empty($hybridauth_user_email) || get_option('wsl_settings_bouncer_profile_completion_change_username') == 1) { do { list($shall_pass, $request_user_login, $request_user_email) = wsl_process_login_complete_registration($provider, $redirect_to, $hybridauth_user_email, $hybridauth_user_login); } while (!$shall_pass); } } # }}} module Bouncer } else { throw new Exception('User not connected with ' . $provider . '!'); } } catch (Exception $e) { return wsl_render_notices_pages(sprintf(_wsl__("Unspecified error. #%d", 'wordpress-social-login'), $e->getCode())); } $user_id = null; // if the user email is verified, then try to map to legacy account if exist // > Currently only Facebook, Google, Yahaoo and Foursquare do provide the verified user email. if (!empty($hybridauth_user_profile->emailVerified)) { $user_id = (int) email_exists($hybridauth_user_profile->emailVerified); } // try to get user by meta if not if (!$user_id) { $user_id = (int) wsl_get_user_by_meta($provider, $hybridauth_user_profile->identifier); } return array($user_id, $adapter, $hybridauth_user_profile, $hybridauth_user_id, $hybridauth_user_email, $request_user_login, $request_user_email); }
public function linkAction() { $this->acl->checkPermission('is logged in'); $this->doNotRender(); // Link external account. $user = $this->auth->getLoggedInUser(); $provider_name = $this->getParam('provider'); $ha_config = $this->_getHybridConfig(); $hybridauth = new \Hybrid_Auth($ha_config); // try to authenticate with the selected provider $adapter = $hybridauth->authenticate($provider_name); if ($hybridauth->isConnectedWith($provider_name)) { $user_profile = $adapter->getUserProfile(); UserExternal::processExternal($provider_name, $user_profile, $user); $this->alert('<b>Account successfully linked!</b>', 'green'); $this->redirectToRoute(array('module' => 'default', 'controller' => 'profile')); return; } }
$cookied = true; $WS_AUTHINFO = $_SESSION['WS_AUTHINFO']; } } // else try logging in, also build a list of providers if (!$cookied) { foreach ($ha_config["providers"] as $authdomain => $domaininfo) { $WS_AUTHINFO['providers'][] = $authdomain; // tries to log in twice. the reason is that an exception can be thrown // on the first attempt. if two exceptions, just log out. // however, it actually reloads the page on the second time, // so a persistent hybridauth bug could cause an infinite redirect loop. for ($i = 0; $i < 2; $i++) { // hybridauth doesn't let you authenticate through ajax. so ajax // (which won't use 'auth') will only reuse existing connection if ($_REQUEST['auth'] == $authdomain || $_REQUEST['auth'] == '' && $hybridauth->isConnectedWith($authdomain)) { $adapter = $hybridauth->authenticate($authdomain); try { $user_profile = $adapter->getUserProfile(); $un = $user_profile->emailVerified; // github seems to verify addresses, even though the // Hybrid_User_Profile doesn't acknowledge this. if (!$un && $authdomain == 'GitHub') { $un = $user_profile->email; } // the user might not have a public email at all if (!$un && $authdomain == 'GitHub') { $things = explode('/', $user_profile->profileURL); $un = $things[count($things) - 1] . "@users.noreply.github.com"; } if (array_key_exists("required_username_suffix", $WS_CONFIG)) {
function do_logout() { // after login come back to the same page $loginCallback = qa_path('', array(), qa_opt('site_url')); require_once "Hybrid/Auth.php"; // prepare the configuration of HybridAuth $config = $this->getConfig($loginCallback); try { // try to logout $hybridauth = new Hybrid_Auth($config); if ($hybridauth->isConnectedWith($this->provider)) { $adapter = $hybridauth->getAdapter($this->provider); $adapter->logout(); } } catch (Exception $e) { // not really interested in the error message - for now // however, in case we have errors 6 or 7, then we have to call logout to clean everything up if ($e->getCode() == 6 || $e->getCode() == 7) { $adapter->logout(); } } }
function SocialAuth_WP_contacts() { ini_set("display_errors", 0); $noContactMsg = "Either you do not have any contact(s) or your login provider is not supporting this feature at the moment."; echo '<div class="wrap">'; echo '<div class="icon32 icon32-posts-post" id="icon-edit"><br></div>'; echo "<h2>My Contacts</h2> <br/>"; // load hybridauth require_once dirname(__FILE__) . "/hybridauth/Hybrid/Auth.php"; // load wp-load.php $wp_load = dirname(dirname(dirname(dirname(__FILE__)))) . '/wp-load.php'; require_once $wp_load; include_once 'common.php'; $user_id = get_current_user_id(); $provider = null; if ($user_id != 0) { $provider = get_user_meta($user_id, 'ha_login_provider', true); } // selected provider name if ($provider == null) { echo $noContactMsg; return; } //global $HA_PROVIDER_CONFIG; $SocialAuth_WP_providers = get_option('SocialAuth_WP_providers'); if (is_array($SocialAuth_WP_providers) && count($SocialAuth_WP_providers)) { $config = array(); if (isset($SocialAuth_WP_providers[$provider])) { $config["base_url"] = plugin_dir_url(__FILE__) . 'hybridauth/'; $config["providers"] = array(); //this si same as orig config, no need to amke config again $config["providers"][$provider] = $SocialAuth_WP_providers[$provider]; } else { echo "Current Provider is unknowun to system."; return; } } else { echo "It seems SocialAuth-WP plugin is not configured properly. Please contact site administrator."; return; } // create an instance for Hybridauth $hybridauth = new Hybrid_Auth($config); $adapter = null; // try to check is provider still authenticated if ($hybridauth->isConnectedWith($provider)) { $adapter = $hybridauth->getAdapter($provider); } else { echo "It seems your session with Login provider has expired. Please logout and login again to system to continue."; return; } $contacts = array(); try { $contacts = $adapter->getUserContacts(); } catch (exception $e) { echo $noContactMsg; return; } if (count($contacts)) { require SOCIALAUTH_WP_PLUGIN_PATH . '/pagination.class.php'; $pagination = new pagination($contacts, isset($_GET['pageNum']) ? $_GET['pageNum'] : 1, 15); $ContactPages = $pagination->getResults(); $tbHeaders = array('Name', 'Profile URL', 'Email'); ?> <?php if (count($ContactPages) != 0) { echo $pageNumbers = '<div class="numbers" style="text-align:right;" >' . $pagination->getLinks(array('page' => 'SocialAuth-WP-contacts')) . '</div>'; ?> <table class="wp-list-table widefat fixed users"> <thead> <tr> <?php foreach ($tbHeaders as $header) { echo '<th style="" class="manage-column column-username" id="" scope="col">' . $header . '</th>'; } ?> </tr> </thead> <tfoot> <tr> <?php foreach ($tbHeaders as $header) { echo '<th style="" class="manage-column column-username" id="" scope="col">' . $header . '</th>'; } ?> </tr> </tfoot> <tbody class="list:user" id="the-list"> <?php foreach ($ContactPages as $index => $contact) { $alternate = $index % 2 == 0 ? "alternate" : ""; ?> <tr class="<?php echo $alternate; ?> " id="user-12"> <td class="column-username"> <?php if (strlen($contact->photoURL)) { ?> <img height="32" width="32" src="<?php echo $contact->photoURL; ?> " > <?php } else { ?> <img height="32" width="32" class="avatar avatar-32 photo" src="http://0.gravatar.com/avatar/8af77eb212190822af34f1725a01922d?s=32&d=http%3A%2F%2F0.gravatar.com%2Favatar%2Fad516503a11cd5ca435acc9bb6523536%3Fs%3D32&r=G" alt=""> <?php } ?> <?php echo $contact->displayName; ?> </td> <td class="posts"> <a href="<?php echo $contact->profileURL; ?> "> <?php echo $contact->profileURL; ?> </a> </td> <td class="posts"> <?php echo empty($contact->email) ? " " : $contact->email; ?> </td> </tr> <?php } ?> </tbody> </table> <?php echo $pageNumbers = '<div class="numbers" style="text-align:right;" >' . $pagination->getLinks(array('page' => 'SocialAuth-WP-contacts')) . '</div>'; } ?> <?php } else { echo $noContactMsg; return; } echo '</div>'; }