当前位置: 首页>>代码示例>>PHP>>正文


PHP Hybrid_Auth::isConnectedWith方法代码示例

本文整理汇总了PHP中Hybrid_Auth::isConnectedWith方法的典型用法代码示例。如果您正苦于以下问题:PHP Hybrid_Auth::isConnectedWith方法的具体用法?PHP Hybrid_Auth::isConnectedWith怎么用?PHP Hybrid_Auth::isConnectedWith使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Hybrid_Auth的用法示例。


在下文中一共展示了Hybrid_Auth::isConnectedWith方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: action_login

 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')));
     }
 }
开发者ID:JeffPedro,项目名称:project-garage-sale,代码行数:59,代码来源:social.php

示例2: getProviders

 /**
  * 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;
 }
开发者ID:OneataBogdan,项目名称:lead_coriolan,代码行数:16,代码来源:Auth.php

示例3: dirname

<?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>   
开发者ID:moxymokaya,项目名称:inoERP,代码行数:31,代码来源:facebook_pages.php

示例4: dirname

# 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";
开发者ID:318io,项目名称:318-io,代码行数:31,代码来源:index.php

示例5: socialAuthUnLink

    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;
            }
        }
    }
开发者ID:newbacknew,项目名称:owloo.com,代码行数:28,代码来源:class_usersystem.php

示例6: logout

 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;
 }
开发者ID:armpit,项目名称:e107,代码行数:13,代码来源:user_handler.php

示例7: catch

    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;
开发者ID:vkamelin,项目名称:hybridauth,代码行数:31,代码来源:index.php

示例8: wsl_process_login

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());
//.........这里部分代码省略.........
开发者ID:niQo,项目名称:WordPress-Social-Login,代码行数:101,代码来源:plugin.auth.php

示例9: getConnectedProviders

 /**
  * 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;
 }
开发者ID:rijojoy,项目名称:MyIceBerg,代码行数:13,代码来源:Auth.php

示例10: auth

 /**
  * 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;
 }
开发者ID:paolocerto,项目名称:x3cms,代码行数:72,代码来源:X4hybridauth_helper.php

示例11: wsl_process_login_hybridauth_authenticate

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)) {
//.........这里部分代码省略.........
开发者ID:adisonc,项目名称:MaineLearning,代码行数:101,代码来源:wsl.authentication.php

示例12: linkAction

 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;
     }
 }
开发者ID:Lavoaster,项目名称:PVLive,代码行数:19,代码来源:AccountController.php

示例13: foreach

         $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)) {
开发者ID:Adamawa,项目名称:websheets,代码行数:31,代码来源:auth.php

示例14: array

 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();
         }
     }
 }
开发者ID:microbye,项目名称:q2a-open-login,代码行数:22,代码来源:qa-open-login.php

示例15: SocialAuth_WP_contacts

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:3pillarlabs,项目名称:socialauth-wp,代码行数:101,代码来源:feature-friends.php


注:本文中的Hybrid_Auth::isConnectedWith方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。