diff --git a/composer.json b/composer.json
index 29c6f12d9..17dade230 100644
--- a/composer.json
+++ b/composer.json
@@ -20,6 +20,7 @@
"vendor-dir": "e107_handlers/vendor"
},
"require": {
- "php": ">=5.6"
+ "php": ">=5.6",
+ "hybridauth/hybridauth": "^3.1.1"
}
}
diff --git a/composer.lock b/composer.lock
index 676168c17..b01290613 100644
--- a/composer.lock
+++ b/composer.lock
@@ -4,8 +4,66 @@
"Read more about it at https://getcomposer.org/doc/01-basic-usage.md#installing-dependencies",
"This file is @generated automatically"
],
- "content-hash": "f117caf65293d124a673a0a20b0e6fe4",
- "packages": [],
+ "content-hash": "2b9cc480eb532146a79c7735c57e9d56",
+ "packages": [
+ {
+ "name": "hybridauth/hybridauth",
+ "version": "v3.1.1",
+ "source": {
+ "type": "git",
+ "url": "https://github.com/hybridauth/hybridauth.git",
+ "reference": "020be6991e7ae9f1ffaabae6586245d2a9626273"
+ },
+ "dist": {
+ "type": "zip",
+ "url": "https://api.github.com/repos/hybridauth/hybridauth/zipball/020be6991e7ae9f1ffaabae6586245d2a9626273",
+ "reference": "020be6991e7ae9f1ffaabae6586245d2a9626273",
+ "shasum": ""
+ },
+ "require": {
+ "php": ">=5.4.0"
+ },
+ "require-dev": {
+ "ext-curl": "*",
+ "phpunit/phpunit": "~4.8.35"
+ },
+ "type": "library",
+ "extra": {
+ "branch-alias": {
+ "dev-master": "3.0-dev"
+ }
+ },
+ "autoload": {
+ "psr-4": {
+ "Hybridauth\\": "src/"
+ }
+ },
+ "notification-url": "https://packagist.org/downloads/",
+ "license": [
+ "MIT"
+ ],
+ "authors": [
+ {
+ "name": "Miled",
+ "email": "hybridauth@gmail.com"
+ }
+ ],
+ "description": "PHP Social Authentication Library",
+ "homepage": "https://hybridauth.github.io",
+ "keywords": [
+ "Authentication",
+ "OpenId",
+ "api",
+ "authorization",
+ "facebook",
+ "google",
+ "oauth",
+ "social",
+ "twitter"
+ ],
+ "time": "2019-12-27T09:26:40+00:00"
+ }
+ ],
"packages-dev": [],
"aliases": [],
"minimum-stability": "stable",
diff --git a/e107_admin/core_image.php b/e107_admin/core_image.php
index 5ed634fdd..21df03d44 100644
--- a/e107_admin/core_image.php
+++ b/e107_admin/core_image.php
@@ -338,84 +338,7 @@ $core_image = array (
),
$coredir['handlers'] =>
array (
- 'hybridauth' =>
- array (
- 'Hybrid' =>
- array (
- 'Providers' =>
- array (
- 'AOL.php' => '363b16cae1ffd55db3ac5cc2f7e4733e',
- 'Facebook.php' => '4aee3d317fe69953e01bb46725d43f94',
- 'Foursquare.php' => '397589be7475ebaad8970ca4b6eb60fd',
- 'Github.php' => '2e2d5834cc8a82235c16e40aa00ce541',
- 'Google.php' => 'be4864960167e6b37de048b946c0d379',
- 'GoogleOpenID.php' => 'bb90e3e12d87f0726ff58c1f5569bc4e',
- 'LinkedIn.php' => '5523c4f074fe4e1861df527d73e49da4',
- 'Live.php' => '995b6de787eae81944909613e070bb4c',
- 'MySpace.php' => '0a0064690cfff91854cd21e89ee94949',
- 'OpenID.php' => 'cac0c4f546bf7cadd3e0e08045e9496e',
- 'Steam.php' => 'ed4d5df2401d5bda0310902950b5ae63',
- 'Twitter.php' => 'b75922ec5b73dac7048e60628b779723',
- 'Yahoo.php' => '54e31f108103ff5ae541d4b429d4eed2',
- ),
- 'resources' =>
- array (
- 'config.php.tpl' => 'a98e1313d7f3cb3b09c66be1a173bbe5',
- 'index.html' => '2b328c302ed608451171b3db0f6b92b3',
- 'openid_policy.html' => 'adaae0d22f0b9003a44534a64081d02d',
- 'openid_realm.html' => 'e2930bae092b00340ee16362ec5ac729',
- 'openid_xrds.xml' => 'b46a8e43108e0eca7dca32acca4decac',
- 'windows_live_channel.html' => '479decb220963b4ebb8e0dedd2a399a0',
- ),
- 'thirdparty' =>
- array (
- 'Facebook' =>
- array (
- 'base_facebook.php' => '765cff749aa16cc4500f9bd81cbd21ab',
- 'facebook.php' => '6bf73e0998383aaf604c54bc7942b9ab',
- 'fb_ca_chain_bundle.crt' => '98ad487c6bcd023914be60299202eee0',
- ),
- 'LinkedIn' =>
- array (
- 'LinkedIn.php' => '1cd8fcbb82418c7f81d0de47f02f59c7',
- ),
- 'OAuth' =>
- array (
- 'OAuth.php' => '50bae8f493620f1fdfb2063b26ebe2a5',
- 'OAuth1Client.php' => 'e6992197dabf5e1bd7f4f4e3c7525ecd',
- 'OAuth2Client.php' => 'f7a5499ef47177ac1ca106e886382872',
- ),
- 'OpenID' =>
- array (
- 'LightOpenID.php' => '9fa681804a627f14911e458e7a102299',
- ),
- 'WindowsLive' =>
- array (
- 'OAuthWrapHandler.php' => '7080d96d73a963730a4b3d69c7a7083f',
- ),
- 'index.html' => '2b328c302ed608451171b3db0f6b92b3',
- ),
- 'Auth.php' => '8aaaec7085b894e0554ef19520f59f58',
- 'Endpoint.php' => 'be7e05c19af2a69d4db3e82a2cff5db2',
- 'Error.php' => 'd94721e20cb24b0730acc07fa8a95a14',
- 'Exception.php' => 'd49e817a88114c2dd431335530e9db74',
- 'Logger.php' => 'c5d7d3a272b8c57c83a8d33bbb0e5e7d',
- 'Provider_Adapter.php' => '9ba762f0f1e4ed0e2aa120ca30590ff2',
- 'Provider_Model.php' => '43641d00761ed128767cc4957e2198c4',
- 'Provider_Model_OAuth1.php' => '12aad5fd49338c606c754b398e7323dd',
- 'Provider_Model_OAuth2.php' => '83a61d2bd9a345c0b9bfc8ac411119c3',
- 'Provider_Model_OpenID.php' => '1c5133bc57c3d45aacb522b7b918b8b8',
- 'Storage.php' => '9c58abd4e46c9fecdf248db1022d2289',
- 'StorageInterface.php' => '7a52a9b9bdc3569a98a0e32fc630d424',
- 'User.php' => 'c219b2c31b17127f044e7d425dcd06db',
- 'User_Activity.php' => '4b8c29b5c442915664f864ee4e18ac6b',
- 'User_Contact.php' => 'b7f17423d61d42cb30b36a127f6e0e78',
- 'User_Profile.php' => '4165786a0cc8d26ae683eda0669bf635',
- 'index.html' => '2b328c302ed608451171b3db0f6b92b3',
- ),
- 'index.php' => '9e3830ed561ec508dc00344aebad5152',
- ),
- 'jsshrink' =>
+ 'jsshrink' =>
array (
'Minifier.php' => '10226dbede9950509b846658cac86c28',
),
diff --git a/e107_core/controllers/system/xup.php b/e107_core/controllers/system/xup.php
index 9700a781f..04fe190ce 100644
--- a/e107_core/controllers/system/xup.php
+++ b/e107_core/controllers/system/xup.php
@@ -143,22 +143,4 @@ class core_system_xup_controller extends eController
*/
}
-
- public function actionEndpoint()
- {
- require_once( e_HANDLER."hybridauth/Hybrid/Auth.php" );
- require_once( e_HANDLER."hybridauth/Hybrid/Endpoint.php" );
- require_once( e_HANDLER."hybridauth/vendor/autoload.php");
-
- try
- {
- Hybrid_Endpoint::process();
- }
- catch (Exception $e)
- {
- e107::getMessage()->addError('['.$e->getCode().']'.$e->getMessage(), 'default', true);
- $session = e107::getSession();
- $session->set('HAuthError', true);
- }
- }
}
diff --git a/e107_handlers/e107_class.php b/e107_handlers/e107_class.php
index 3fb4a1019..a7b62dce9 100644
--- a/e107_handlers/e107_class.php
+++ b/e107_handlers/e107_class.php
@@ -236,7 +236,6 @@ class e107
'eUrl' => '{e_HANDLER}e107Url.php',
'eUrlConfig' => '{e_HANDLER}application.php',
'eUrlRule' => '{e_HANDLER}application.php',
- 'Hybrid_Auth' => '{e_HANDLER}hybridauth/Hybrid/Auth.php',
'language' => '{e_HANDLER}language_class.php',
'news' => '{e_HANDLER}news_class.php',
'notify' => '{e_HANDLER}notify_class.php',
@@ -1693,22 +1692,22 @@ class e107
}
/**
- * Retrieve HybridAuth object
+ * Create a new Hybridauth object based on the provided configuration
*
- * @return object
+ * @return Hybridauth\Hybridauth
*/
public static function getHybridAuth($config = null)
{
if(null === $config)
{
$config = array(
- 'base_url' => self::getUrl()->create('system/xup/endpoint', array(), array('full' => true)),
+ 'callback' => self::getUrl()->create('system/xup/login', array(), array('full' => true)),
'providers' => self::getPref('social_login', array()),
'debug_mode' => false,
'debug_file' => ''
);
}
- return new Hybrid_Auth($config);
+ return new Hybridauth\Hybridauth($config);
}
/**
diff --git a/e107_handlers/hybridauth/Hybrid/Auth.php b/e107_handlers/hybridauth/Hybrid/Auth.php
deleted file mode 100644
index 5642b5091..000000000
--- a/e107_handlers/hybridauth/Hybrid/Auth.php
+++ /dev/null
@@ -1,414 +0,0 @@
-getSessionData());
- Hybrid_Logger::info("Hybrid_Auth initialize: check if any error is stored on the endpoint...");
-
- if (Hybrid_Error::hasError()) {
- $m = Hybrid_Error::getErrorMessage();
- $c = Hybrid_Error::getErrorCode();
- $p = Hybrid_Error::getErrorPrevious();
-
- Hybrid_Logger::error("Hybrid_Auth initialize: A stored Error found, Throw an new Exception and delete it from the store: Error#$c, '$m'");
-
- Hybrid_Error::clearError();
-
- // try to provide the previous if any
- // Exception::getPrevious (PHP 5 >= 5.3.0) http://php.net/manual/en/exception.getprevious.php
- if (version_compare(PHP_VERSION, '5.3.0', '>=') && ($p instanceof Exception)) {
- throw new Exception($m, $c, $p);
- } else {
- throw new Exception($m, $c);
- }
- }
-
- Hybrid_Logger::info("Hybrid_Auth initialize: no error found. initialization succeed.");
- }
-
- /**
- * Hybrid storage system accessor
- *
- * Users sessions are stored using HybridAuth storage system ( HybridAuth 2.0 handle PHP Session only) and can be accessed directly by
- * Hybrid_Auth::storage()->get($key) to retrieves the data for the given key, or calling
- * Hybrid_Auth::storage()->set($key, $value) to store the key => $value set.
- *
- * @return Hybrid_Storage
- */
- public static function storage() {
- return Hybrid_Auth::$store;
- }
-
- /**
- * Get hybridauth session data
- * @return string|null
- */
- function getSessionData() {
- return Hybrid_Auth::storage()->getSessionData();
- }
-
- /**
- * Restore hybridauth session data
- *
- * @param string $sessiondata Serialized session data
- * @retun void
- */
- function restoreSessionData($sessiondata = null) {
- Hybrid_Auth::storage()->restoreSessionData($sessiondata);
- }
-
- /**
- * Try to authenticate the user with a given provider.
- *
- * If the user is already connected we just return and instance of provider adapter,
- * ELSE, try to authenticate and authorize the user with the provider.
- *
- * $params is generally an array with required info in order for this provider and HybridAuth to work,
- * like :
- * hauth_return_to: URL to call back after authentication is done
- * openid_identifier: The OpenID identity provider identifier
- * google_service: can be "Users" for Google user accounts service or "Apps" for Google hosted Apps
- *
- * @param string $providerId ID of the provider
- * @param array $params Params
- * @return
- */
- public static function authenticate($providerId, $params = null) {
- Hybrid_Logger::info("Enter Hybrid_Auth::authenticate( $providerId )");
-
- if (!Hybrid_Auth::storage()->get("hauth_session.$providerId.is_logged_in")) {
- // if user not connected to $providerId then try setup a new adapter and start the login process for this provider
- Hybrid_Logger::info("Hybrid_Auth::authenticate( $providerId ), User not connected to the provider. Try to authenticate..");
- $provider_adapter = Hybrid_Auth::setup($providerId, $params);
- $provider_adapter->login();
- } else {
- // else, then return the adapter instance for the given provider
- Hybrid_Logger::info("Hybrid_Auth::authenticate( $providerId ), User is already connected to this provider. Return the adapter instance.");
- return Hybrid_Auth::getAdapter($providerId);
- }
- }
-
- /**
- * Return the adapter instance for an authenticated provider
- *
- * @param string $providerId ID of the provider
- * @return Hybrid_Provider_Adapter
- */
- public static function getAdapter($providerId = null) {
- Hybrid_Logger::info("Enter Hybrid_Auth::getAdapter( $providerId )");
- return Hybrid_Auth::setup($providerId);
- }
-
- /**
- * Setup an adapter for a given provider
- *
- * @param string $providerId ID of the provider
- * @param array $params Adapter params
- * @return Hybrid_Provider_Adapter
- */
- public static function setup($providerId, $params = null) {
- Hybrid_Logger::debug("Enter Hybrid_Auth::setup( $providerId )", $params);
-
- if (!$params) {
- $params = Hybrid_Auth::storage()->get("hauth_session.$providerId.id_provider_params");
-
- Hybrid_Logger::debug("Hybrid_Auth::setup( $providerId ), no params given. Trying to get the stored for this provider.", $params);
- }
-
- if (!$params) {
- $params = array();
- Hybrid_Logger::info("Hybrid_Auth::setup( $providerId ), no stored params found for this provider. Initialize a new one for new session");
- }
-
- if (is_array($params) && !isset($params["hauth_return_to"])) {
- $params["hauth_return_to"] = Hybrid_Auth::getCurrentUrl();
- Hybrid_Logger::debug("Hybrid_Auth::setup( $providerId ). HybridAuth Callback URL set to: ", $params["hauth_return_to"]);
- }
-
- # instantiate a new IDProvider Adapter
- $provider = new Hybrid_Provider_Adapter();
- $provider->factory($providerId, $params);
- return $provider;
- }
-
- /**
- * Check if the current user is connected to a given provider
- *
- * @param string $providerId ID of the provider
- * @return bool
- */
- public static function isConnectedWith($providerId) {
- return (bool) Hybrid_Auth::storage()->get("hauth_session.{$providerId}.is_logged_in");
- }
-
- /**
- * Return array listing all authenticated providers
- * @return array
- */
- public static function getConnectedProviders() {
- $idps = array();
-
- foreach (Hybrid_Auth::$config["providers"] as $idpid => $params) {
- if (Hybrid_Auth::isConnectedWith($idpid)) {
- $idps[] = $idpid;
- }
- }
-
- return $idps;
- }
-
- /**
- * Return array listing all enabled providers as well as a flag if you are connected
- *
- *
- * array(
- * 'Facebook' => array(
- * 'connected' => true
- * )
- * )
- *
- * @return array
- */
- 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;
- }
-
- /**
- * A generic function to logout all connected provider at once
- * @return void
- */
- public static function logoutAllProviders() {
- $idps = Hybrid_Auth::getConnectedProviders();
-
- foreach ($idps as $idp) {
- $adapter = Hybrid_Auth::getAdapter($idp);
- $adapter->logout();
- }
- }
-
- /**
- * Utility function, redirect to a given URL with php header or using javascript location.href
- *
- * @param string $url URL to redirect to
- * @param string $mode PHP|JS
- */
- public static function redirect($url, $mode = "PHP") {
- if(!$mode){
- $mode = 'PHP';
- }
- Hybrid_Logger::info("Enter Hybrid_Auth::redirect( $url, $mode )");
-
- // Ensure session is saved before sending response, see https://github.com/symfony/symfony/pull/12341
- if ((PHP_VERSION_ID >= 50400 && PHP_SESSION_ACTIVE === session_status()) || (PHP_VERSION_ID < 50400 && isset($_SESSION) && session_id())) {
- session_write_close();
- }
-
- if ($mode == "PHP") {
- header("Location: $url");
- } elseif ($mode == "JS") {
- echo '';
- echo '
- * array(
- * 'access_token' => '',
- * 'access_token_secret' => '',
- * 'refresh_token' => '',
- * 'expires_in' => '',
- * 'expires_at' => '',
- * )
- *
- * @return array
- */
- public function getAccessToken() {
- if (!$this->adapter->isUserConnected()) {
- Hybrid_Logger::error("User not connected to the provider.");
- throw new Exception("User not connected to the provider.", 7);
- }
-
- return array(
- "access_token" => $this->adapter->token("access_token"), // OAuth access token
- "access_token_secret" => $this->adapter->token("access_token_secret"), // OAuth access token secret
- "refresh_token" => $this->adapter->token("refresh_token"), // OAuth refresh token
- "expires_in" => $this->adapter->token("expires_in"), // OPTIONAL. The duration in seconds of the access token lifetime
- "expires_at" => $this->adapter->token("expires_at"), // OPTIONAL. Timestamp when the access_token expire. if not provided by the social api, then it should be calculated: expires_at = now + expires_in
- );
- }
-
- /**
- * Naive getter of the current connected IDp API client
- * @return stdClass
- * @throws Exception
- */
- function api() {
- if (!$this->adapter->isUserConnected()) {
- Hybrid_Logger::error("User not connected to the provider.");
-
- throw new Exception("User not connected to the provider.", 7);
- }
- return $this->adapter->api;
- }
-
- /**
- * Redirect the user to hauth_return_to (the callback url)
- * @return void
- */
- function returnToCallbackUrl() {
- // get the stored callback url
- $callback_url = Hybrid_Auth::storage()->get("hauth_session.{$this->id}.hauth_return_to");
-
- // if the user presses the back button in the browser and we already deleted the hauth_return_to from
- // the session in the previous request, we will redirect to '/' instead of displaying a blank page.
- if (!$callback_url) {
- $callback_url = '/';
- }
-
- // remove some unneeded stored data
- Hybrid_Auth::storage()->delete("hauth_session.{$this->id}.hauth_return_to");
- Hybrid_Auth::storage()->delete("hauth_session.{$this->id}.hauth_endpoint");
- Hybrid_Auth::storage()->delete("hauth_session.{$this->id}.id_provider_params");
-
- // back to home
- Hybrid_Auth::redirect($callback_url);
- }
-
- /**
- * Return the provider config by id
- *
- * @param string $id Config key
- * @return mixed
- */
- function getConfigById($id) {
- if (isset(Hybrid_Auth::$config["providers"][$id])) {
- return Hybrid_Auth::$config["providers"][$id];
- }
- return null;
- }
-
- /**
- * Return the provider config by id; case insensitive
- *
- * @param string $id Provider id
- * @return mixed
- */
- function getProviderCiId($id) {
- foreach (Hybrid_Auth::$config["providers"] as $idpid => $params) {
- if (strtolower($idpid) == strtolower($id)) {
- return $idpid;
- }
- }
- return null;
- }
-
-}
diff --git a/e107_handlers/hybridauth/Hybrid/Provider_Model.php b/e107_handlers/hybridauth/Hybrid/Provider_Model.php
deleted file mode 100644
index 320cee9e1..000000000
--- a/e107_handlers/hybridauth/Hybrid/Provider_Model.php
+++ /dev/null
@@ -1,247 +0,0 @@
-params = Hybrid_Auth::storage()->get("hauth_session.$providerId.id_provider_params");
- } else {
- $this->params = $params;
- }
-
- // idp id
- $this->providerId = $providerId;
-
- // set HybridAuth endpoint for this provider
- $this->endpoint = Hybrid_Auth::storage()->get("hauth_session.$providerId.hauth_endpoint");
-
- // idp config
- $this->config = $config;
-
- // new user instance
- $this->user = new Hybrid_User();
- $this->user->providerId = $providerId;
-
- // initialize the current provider adapter
- $this->initialize();
-
- Hybrid_Logger::debug("Hybrid_Provider_Model::__construct( $providerId ) initialized. dump current adapter instance: ", serialize($this));
- }
-
- /**
- * IDp wrappers initializer
- *
- * The main job of wrappers initializer is to performs (depend on the IDp api client it self):
- * - include some libs needed by this provider,
- * - check IDp key and secret,
- * - set some needed parameters (stored in $this->params) by this IDp api client
- * - create and setup an instance of the IDp api client on $this->api
- *
- * @return void
- * @throws Exception
- */
- abstract protected function initialize();
-
- /**
- * Begin login
- *
- * @return void
- * @throws Exception
- */
- abstract public function loginBegin();
-
- /**
- * Finish login
- * @return void
- * @throws Exception
- */
- abstract public function loginFinish();
-
- /**
- * Generic logout, just erase current provider adapter stored data to let Hybrid_Auth all forget about it
- * @return bool
- */
- function logout() {
- Hybrid_Logger::info("Enter [{$this->providerId}]::logout()");
- $this->clearTokens();
- return true;
- }
-
- /**
- * Grab the user profile from the IDp api client
- * @return Hybrid_User_Profile
- * @throws Exception
- */
- function getUserProfile() {
- Hybrid_Logger::error("HybridAuth do not provide users contacts list for {$this->providerId} yet.");
- throw new Exception("Provider does not support this feature.", 8);
- }
-
- /**
- * Load the current logged in user contacts list from the IDp api client
- * @return Hybrid_User_Contact[]
- * @throws Exception
- */
- function getUserContacts() {
- Hybrid_Logger::error("HybridAuth do not provide users contacts list for {$this->providerId} yet.");
- throw new Exception("Provider does not support this feature.", 8);
- }
-
- /**
- * Return the user activity stream
- * @return Hybrid_User_Activity[]
- * @throws Exception
- */
- function getUserActivity($stream) {
- Hybrid_Logger::error("HybridAuth do not provide user's activity stream for {$this->providerId} yet.");
- throw new Exception("Provider does not support this feature.", 8);
- }
-
- /**
- * Set user status
- * @return mixed Provider response
- * @throws Exception
- */
- function setUserStatus($status) {
- Hybrid_Logger::error("HybridAuth do not provide user's activity stream for {$this->providerId} yet.");
- throw new Exception("Provider does not support this feature.", 8);
- }
-
- /**
- * Return the user status
- * @return mixed Provider response
- * @throws Exception
- */
- function getUserStatus($statusid) {
- Hybrid_Logger::error("HybridAuth do not provide user's status for {$this->providerId} yet.");
- throw new Exception("Provider does not support this feature.", 8);
- }
-
- /**
- * Return true if the user is connected to the current provider
- * @return bool
- */
- public function isUserConnected() {
- return (bool) Hybrid_Auth::storage()->get("hauth_session.{$this->providerId}.is_logged_in");
- }
-
- /**
- * Set user to connected
- * @return void
- */
- public function setUserConnected() {
- Hybrid_Logger::info("Enter [{$this->providerId}]::setUserConnected()");
- Hybrid_Auth::storage()->set("hauth_session.{$this->providerId}.is_logged_in", 1);
- }
-
- /**
- * Set user to unconnected
- * @return void
- */
- public function setUserUnconnected() {
- Hybrid_Logger::info("Enter [{$this->providerId}]::setUserUnconnected()");
- Hybrid_Auth::storage()->set("hauth_session.{$this->providerId}.is_logged_in", 0);
- }
-
- /**
- * Get or set a token
- * @return string
- */
- public function token($token, $value = null) {
- if ($value === null) {
- return Hybrid_Auth::storage()->get("hauth_session.{$this->providerId}.token.$token");
- } else {
- Hybrid_Auth::storage()->set("hauth_session.{$this->providerId}.token.$token", $value);
- }
- }
-
- /**
- * Delete a stored token
- * @return void
- */
- public function deleteToken($token) {
- Hybrid_Auth::storage()->delete("hauth_session.{$this->providerId}.token.$token");
- }
-
- /**
- * Clear all existent tokens for this provider
- * @return void
- */
- public function clearTokens() {
- Hybrid_Auth::storage()->deleteMatch("hauth_session.{$this->providerId}.");
- }
-
-}
diff --git a/e107_handlers/hybridauth/Hybrid/Provider_Model_OAuth1.php b/e107_handlers/hybridauth/Hybrid/Provider_Model_OAuth1.php
deleted file mode 100644
index 6f5f239ae..000000000
--- a/e107_handlers/hybridauth/Hybrid/Provider_Model_OAuth1.php
+++ /dev/null
@@ -1,174 +0,0 @@
- "OK: Success!",
- 304 => "Not Modified: There was no new data to return.",
- 400 => "Bad Request: The request was invalid.",
- 401 => "Unauthorized.",
- 403 => "Forbidden: The request is understood, but it has been refused.",
- 404 => "Not Found: The URI requested is invalid or the resource requested does not exists.",
- 406 => "Not Acceptable.",
- 500 => "Internal Server Error: Something is broken.",
- 502 => "Bad Gateway.",
- 503 => "Service Unavailable."
- );
-
- if (!$code && $this->api) {
- $code = $this->api->http_code;
- }
-
- if (isset($http_status_codes[$code])) {
- return $code . " " . $http_status_codes[$code];
- }
- }
-
- /**
- * {@inheritdoc}
- */
- function initialize() {
- // 1 - check application credentials
- if (!$this->config["keys"]["key"] || !$this->config["keys"]["secret"]) {
- throw new Exception("Your application key and secret are required in order to connect to {$this->providerId}.", 4);
- }
-
- // 2 - include OAuth lib and client
- if (! class_exists('OAuthConsumer') ) {
- require_once Hybrid_Auth::$config["path_libraries"] . "OAuth/OAuth.php";
- }
- require_once Hybrid_Auth::$config["path_libraries"] . "OAuth/OAuth1Client.php";
-
- // 3.1 - setup access_token if any stored
- if ($this->token("access_token")) {
- $this->api = new OAuth1Client(
- $this->config["keys"]["key"], $this->config["keys"]["secret"], $this->token("access_token"), $this->token("access_token_secret")
- );
- }
-
- // 3.2 - setup request_token if any stored, in order to exchange with an access token
- elseif ($this->token("request_token")) {
- $this->api = new OAuth1Client(
- $this->config["keys"]["key"], $this->config["keys"]["secret"], $this->token("request_token"), $this->token("request_token_secret")
- );
- }
-
- // 3.3 - instanciate OAuth client with client credentials
- else {
- $this->api = new OAuth1Client($this->config["keys"]["key"], $this->config["keys"]["secret"]);
- }
-
- // Set curl proxy if exist
- if (isset(Hybrid_Auth::$config["proxy"])) {
- $this->api->curl_proxy = Hybrid_Auth::$config["proxy"];
- }
- }
-
- /**
- * {@inheritdoc}
- */
- function loginBegin() {
- $tokens = $this->api->requestToken($this->endpoint);
-
- // request tokens as received from provider
- $this->request_tokens_raw = $tokens;
-
- // check the last HTTP status code returned
- if ($this->api->http_code != 200) {
- throw new Exception("Authentication failed! {$this->providerId} returned an error. " . $this->errorMessageByStatus($this->api->http_code), 5);
- }
-
- if (!isset($tokens["oauth_token"])) {
- throw new Exception("Authentication failed! {$this->providerId} returned an invalid oauth token.", 5);
- }
-
- $this->token("request_token", $tokens["oauth_token"]);
- $this->token("request_token_secret", $tokens["oauth_token_secret"]);
-
- # redirect the user to the provider authentication url
- Hybrid_Auth::redirect($this->api->authorizeUrl($tokens));
- }
-
- /**
- * {@inheritdoc}
- */
- function loginFinish() {
- $oauth_token = (array_key_exists('oauth_token', $_REQUEST)) ? $_REQUEST['oauth_token'] : "";
- $oauth_verifier = (array_key_exists('oauth_verifier', $_REQUEST)) ? $_REQUEST['oauth_verifier'] : "";
-
- if (!$oauth_token || !$oauth_verifier) {
- throw new Exception("Authentication failed! {$this->providerId} returned an invalid oauth verifier.", 5);
- }
-
- // request an access token
- $tokens = $this->api->accessToken($oauth_verifier);
-
- // access tokens as received from provider
- $this->access_tokens_raw = $tokens;
-
- // check the last HTTP status code returned
- if ($this->api->http_code != 200) {
- throw new Exception("Authentication failed! {$this->providerId} returned an error. " . $this->errorMessageByStatus($this->api->http_code), 5);
- }
-
- // we should have an access_token, or else, something has gone wrong
- if (!isset($tokens["oauth_token"])) {
- throw new Exception("Authentication failed! {$this->providerId} returned an invalid access token.", 5);
- }
-
- // we no more need to store request tokens
- $this->deleteToken("request_token");
- $this->deleteToken("request_token_secret");
-
- // store access_token for later user
- $this->token("access_token", $tokens['oauth_token']);
- $this->token("access_token_secret", $tokens['oauth_token_secret']);
-
- // set user as logged in to the current provider
- $this->setUserConnected();
- }
-
-}
diff --git a/e107_handlers/hybridauth/Hybrid/Provider_Model_OAuth2.php b/e107_handlers/hybridauth/Hybrid/Provider_Model_OAuth2.php
deleted file mode 100644
index 17a2103bd..000000000
--- a/e107_handlers/hybridauth/Hybrid/Provider_Model_OAuth2.php
+++ /dev/null
@@ -1,184 +0,0 @@
- "OK: Success!",
- 304 => "Not Modified: There was no new data to return.",
- 400 => "Bad Request: The request was invalid.",
- 401 => "Unauthorized.",
- 403 => "Forbidden: The request is understood, but it has been refused.",
- 404 => "Not Found: The URI requested is invalid or the resource requested does not exists.",
- 406 => "Not Acceptable.",
- 500 => "Internal Server Error: Something is broken.",
- 502 => "Bad Gateway.",
- 503 => "Service Unavailable."
- );
-
- if (!$code && $this->api) {
- $code = $this->api->http_code;
- }
-
- if (isset($http_status_codes[$code])) {
- return $code . " " . $http_status_codes[$code];
- }
- }
-
- /**
- * Adapter initializer
- */
- function initialize() {
- if (!$this->config["keys"]["id"] || !$this->config["keys"]["secret"]) {
- throw new Exception("Your application id and secret are required in order to connect to {$this->providerId}.", 4);
- }
-
- // override requested scope
- if (isset($this->config["scope"]) && !empty($this->config["scope"])) {
- $this->scope = $this->config["scope"];
- }
-
- // include OAuth2 client
- require_once Hybrid_Auth::$config["path_libraries"] . "OAuth/OAuth2Client.php";
-
- // create a new OAuth2 client instance
- $this->api = new OAuth2Client($this->config["keys"]["id"], $this->config["keys"]["secret"], $this->endpoint, $this->compressed);
-
- // If we have an access token, set it
- if ($this->token("access_token")) {
- $this->api->access_token = $this->token("access_token");
- $this->api->refresh_token = $this->token("refresh_token");
- $this->api->access_token_expires_in = $this->token("expires_in");
- $this->api->access_token_expires_at = $this->token("expires_at");
- }
-
- // Set curl proxy if exist
- if (isset(Hybrid_Auth::$config["proxy"])) {
- $this->api->curl_proxy = Hybrid_Auth::$config["proxy"];
- }
- }
-
- /**
- * {@inheritdoc}
- */
- function loginBegin() {
- // redirect the user to the provider authentication url
- Hybrid_Auth::redirect($this->api->authorizeUrl(array("scope" => $this->scope)));
- }
-
- /**
- * {@inheritdoc}
- */
- function loginFinish() {
- $error = (array_key_exists('error', $_REQUEST)) ? $_REQUEST['error'] : "";
-
- // check for errors
- if ($error) {
- throw new Exception("Authentication failed! {$this->providerId} returned an error: $error", 5);
- }
-
- // try to authenticate user
- $code = (array_key_exists('code', $_REQUEST)) ? $_REQUEST['code'] : "";
-
- try {
- $this->api->authenticate($code);
- } catch (Exception $e) {
- throw new Exception("User profile request failed! {$this->providerId} returned an error: " . $e->getMessage(), 6);
- }
-
- // check if authenticated
- if (!$this->api->access_token) {
- throw new Exception("Authentication failed! {$this->providerId} returned an invalid access token.", 5);
- }
-
- // store tokens
- $this->token("access_token", $this->api->access_token);
- $this->token("refresh_token", $this->api->refresh_token);
- $this->token("expires_in", $this->api->access_token_expires_in);
- $this->token("expires_at", $this->api->access_token_expires_at);
-
- // set user connected locally
- $this->setUserConnected();
- }
-
- /**
- * {@inheritdoc}
- */
- function refreshToken() {
- // have an access token?
- if ($this->api->access_token) {
-
- // have to refresh?
- if ($this->api->refresh_token && $this->api->access_token_expires_at) {
-
- // expired?
- if ($this->api->access_token_expires_at <= time()) {
- $response = $this->api->refreshToken(array("refresh_token" => $this->api->refresh_token));
-
- if (!isset($response->access_token) || !$response->access_token) {
- // set the user as disconnected at this point and throw an exception
- $this->setUserUnconnected();
-
- throw new Exception("The Authorization Service has return an invalid response while requesting a new access token. " . (string) $response->error);
- }
-
- // set new access_token
- $this->api->access_token = $response->access_token;
-
- if (isset($response->refresh_token))
- $this->api->refresh_token = $response->refresh_token;
-
- if (isset($response->expires_in)) {
- $this->api->access_token_expires_in = $response->expires_in;
-
- // even given by some idp, we should calculate this
- $this->api->access_token_expires_at = time() + $response->expires_in;
- }
- }
- }
-
- // re store tokens
- $this->token("access_token", $this->api->access_token);
- $this->token("refresh_token", $this->api->refresh_token);
- $this->token("expires_in", $this->api->access_token_expires_in);
- $this->token("expires_at", $this->api->access_token_expires_at);
- }
- }
-
-}
diff --git a/e107_handlers/hybridauth/Hybrid/Provider_Model_OpenID.php b/e107_handlers/hybridauth/Hybrid/Provider_Model_OpenID.php
deleted file mode 100644
index d3ec7cab5..000000000
--- a/e107_handlers/hybridauth/Hybrid/Provider_Model_OpenID.php
+++ /dev/null
@@ -1,170 +0,0 @@
-public $openidIdentifier = "";
- *
- * Hybrid_Provider_Model_OpenID use LightOpenID lib which can be found on
- * Hybrid/thirdparty/OpenID/LightOpenID.php
- */
-class Hybrid_Provider_Model_OpenID extends Hybrid_Provider_Model {
-
- /**
- * Provider API client
- * @var LightOpenID
- */
- public $api = null;
-
- /**
- * Openid provider identifier
- * @var string
- */
- public $openidIdentifier = "";
-
- /**
- * {@inheritdoc}
- */
- function initialize() {
- if (isset($this->params["openid_identifier"])) {
- $this->openidIdentifier = $this->params["openid_identifier"];
- }
-
- // include LightOpenID lib
- require_once Hybrid_Auth::$config["path_libraries"] . "OpenID/LightOpenID.php";
-
- // An error was occurring when proxy wasn't set. Not sure where proxy was meant to be set/initialized.
- Hybrid_Auth::$config['proxy'] = isset(Hybrid_Auth::$config['proxy']) ? Hybrid_Auth::$config['proxy'] : '';
-
- $hostPort = parse_url(Hybrid_Auth::$config["base_url"], PHP_URL_PORT);
- $hostUrl = parse_url(Hybrid_Auth::$config["base_url"], PHP_URL_HOST);
-
- // Check for port on url
- if ($hostPort) {
- $hostUrl .= ':' . $hostPort;
- }
-
- $this->api = new LightOpenID($hostUrl, Hybrid_Auth::$config["proxy"]);
- }
-
- /**
- * {@inheritdoc}
- */
- function loginBegin() {
- if (empty($this->openidIdentifier)) {
- throw new Exception("OpenID adapter require the identity provider identifier 'openid_identifier' as an extra parameter.", 4);
- }
-
- $this->api->identity = $this->openidIdentifier;
- $this->api->returnUrl = $this->endpoint;
- $this->api->required = array(
- 'namePerson/first',
- 'namePerson/last',
- 'namePerson/friendly',
- 'namePerson',
- 'contact/email',
- 'birthDate',
- 'birthDate/birthDay',
- 'birthDate/birthMonth',
- 'birthDate/birthYear',
- 'person/gender',
- 'pref/language',
- 'contact/postalCode/home',
- 'contact/city/home',
- 'contact/country/home',
- 'media/image/default',
- );
-
- # redirect the user to the provider authentication url
- Hybrid_Auth::redirect($this->api->authUrl());
- }
-
- /**
- * {@inheritdoc}
- */
- function loginFinish() {
- # if user don't grant access of their data to your site, halt with an Exception
- if ($this->api->mode == 'cancel') {
- throw new Exception("Authentication failed! User has canceled authentication!", 5);
- }
-
- # if something goes wrong
- if (!$this->api->validate()) {
- throw new Exception("Authentication failed. Invalid request received!", 5);
- }
-
- # fetch received user data
- $response = $this->api->getAttributes();
-
- # store the user profile
- $this->user->profile->identifier = $this->api->identity;
-
- $this->user->profile->firstName = (array_key_exists("namePerson/first", $response)) ? $response["namePerson/first"] : "";
- $this->user->profile->lastName = (array_key_exists("namePerson/last", $response)) ? $response["namePerson/last"] : "";
- $this->user->profile->displayName = (array_key_exists("namePerson", $response)) ? $response["namePerson"] : "";
- $this->user->profile->email = (array_key_exists("contact/email", $response)) ? $response["contact/email"] : "";
- $this->user->profile->language = (array_key_exists("pref/language", $response)) ? $response["pref/language"] : "";
- $this->user->profile->country = (array_key_exists("contact/country/home", $response)) ? $response["contact/country/home"] : "";
- $this->user->profile->zip = (array_key_exists("contact/postalCode/home", $response)) ? $response["contact/postalCode/home"] : "";
- $this->user->profile->gender = (array_key_exists("person/gender", $response)) ? $response["person/gender"] : "";
- $this->user->profile->photoURL = (array_key_exists("media/image/default", $response)) ? $response["media/image/default"] : "";
-
- $this->user->profile->birthDay = (array_key_exists("birthDate/birthDay", $response)) ? $response["birthDate/birthDay"] : "";
- $this->user->profile->birthMonth = (array_key_exists("birthDate/birthMonth", $response)) ? $response["birthDate/birthMonth"] : "";
- $this->user->profile->birthYear = (array_key_exists("birthDate/birthDate", $response)) ? $response["birthDate/birthDate"] : "";
-
- if (isset($response['namePerson/friendly']) && !empty($response['namePerson/friendly']) && !$this->user->profile->displayName) {
- $this->user->profile->displayName = $response["namePerson/friendly"];
- }
-
- if (isset($response['birthDate']) && !empty($response['birthDate']) && !$this->user->profile->birthDay) {
- list( $birthday_year, $birthday_month, $birthday_day ) = $response['birthDate'];
-
- $this->user->profile->birthDay = (int) $birthday_day;
- $this->user->profile->birthMonth = (int) $birthday_month;
- $this->user->profile->birthYear = (int) $birthday_year;
- }
-
- if (!$this->user->profile->displayName) {
- $this->user->profile->displayName = trim($this->user->profile->firstName . " " . $this->user->profile->lastName);
- }
-
- if ($this->user->profile->gender == "f") {
- $this->user->profile->gender = "female";
- }
-
- if ($this->user->profile->gender == "m") {
- $this->user->profile->gender = "male";
- }
-
- // set user as logged in
- $this->setUserConnected();
-
- // with openid providers we get the user profile only once, so store it
- Hybrid_Auth::storage()->set("hauth_session.{$this->providerId}.user", $this->user);
- }
-
- /**
- * {@inheritdoc}
- */
- function getUserProfile() {
- // try to get the user profile from stored data
- $this->user = Hybrid_Auth::storage()->get("hauth_session.{$this->providerId}.user");
-
- // if not found
- if (!is_object($this->user)) {
- throw new Exception("User profile request failed! User is not connected to {$this->providerId} or his session has expired.", 6);
- }
-
- return $this->user->profile;
- }
-
-}
diff --git a/e107_handlers/hybridauth/Hybrid/Providers/AOL.php b/e107_handlers/hybridauth/Hybrid/Providers/AOL.php
deleted file mode 100644
index d2aa66730..000000000
--- a/e107_handlers/hybridauth/Hybrid/Providers/AOL.php
+++ /dev/null
@@ -1,18 +0,0 @@
-config['keys']['id'] || ! $this->config['keys']['secret'] ) {
- throw new Exception( "Your application id and secret are required in order to connect to {$this->providerId}.", 4 );
- }
-
- // override requested scope
- if ( isset( $this->config['scope'] ) && ! empty( $this->config['scope'] ) ) {
- $this->scope = $this->config['scope'];
- }
-
- // include OAuth2 client
- require_once Hybrid_Auth::$config['path_libraries'] . 'OAuth/OAuth2Client.php';
- require_once Hybrid_Auth::$config['path_libraries'] . 'Amazon/AmazonOAuth2Client.php';
-
- // create a new OAuth2 client instance
- $this->api = new AmazonOAuth2Client( $this->config['keys']['id'], $this->config['keys']['secret'], $this->endpoint, $this->compressed );
-
- $this->api->api_base_url = 'https://api.amazon.com';
- $this->api->authorize_url = 'https://www.amazon.com/ap/oa';
- $this->api->token_url = 'https://api.amazon.com/auth/o2/token';
-
- $this->api->curl_header = array( 'Content-Type: application/x-www-form-urlencoded' );
-
- // If we have an access token, set it
- if ( $this->token( 'access_token' ) ) {
- $this->api->access_token = $this->token('access_token');
- $this->api->refresh_token = $this->token('refresh_token');
- $this->api->access_token_expires_in = $this->token('expires_in');
- $this->api->access_token_expires_at = $this->token('expires_at');
- }
-
- // Set curl proxy if exists
- if ( isset( Hybrid_Auth::$config['proxy'] ) ) {
- $this->api->curl_proxy = Hybrid_Auth::$config['proxy'];
- }
- }
-
- /**
- * load the user profile from the IDp api client
- */
- function getUserProfile() {
-
- $data = $this->api->get( '/user/profile' );
-
- if ( ! isset( $data->user_id ) ){
- throw new Exception( "User profile request failed! {$this->providerId} returned an invalid response.", 6 );
- }
-
- $this->user->profile->identifier = @ $data->user_id;
- $this->user->profile->email = @ $data->email;
- $this->user->profile->displayName = @ $data->name;
- $this->user->profile->zip = @ $data->postal_code;
-
- return $this->user->profile;
- }
-}
diff --git a/e107_handlers/hybridauth/Hybrid/Providers/Facebook.php b/e107_handlers/hybridauth/Hybrid/Providers/Facebook.php
deleted file mode 100644
index b537854c4..000000000
--- a/e107_handlers/hybridauth/Hybrid/Providers/Facebook.php
+++ /dev/null
@@ -1,406 +0,0 @@
-config["keys"]["id"] || !$this->config["keys"]["secret"]) {
- throw new Exception("Your application id and secret are required in order to connect to {$this->providerId}.", 4);
- }
-
- if (isset($this->config['scope'])) {
- $scope = $this->config['scope'];
- if (is_string($scope)) {
- $scope = explode(",", $scope);
- }
- $scope = array_map('trim', $scope);
- $this->scope = $scope;
- }
-
- $trustForwarded = isset($this->config['trustForwarded']) ? (bool)$this->config['trustForwarded'] : false;
-
- // Check if there is Graph SDK in thirdparty/Facebook.
- if (file_exists(Hybrid_Auth::$config["path_libraries"] . "Facebook/autoload.php")) {
- require_once Hybrid_Auth::$config["path_libraries"] . "Facebook/autoload.php";
- }
- else {
- // If Composer install was executed, try to find autoload.php.
- $vendorDir = dirname(Hybrid_Auth::$config['path_base']);
- do {
- if (file_exists($vendorDir . "/vendor/autoload.php")) {
- require_once $vendorDir . "/vendor/autoload.php";
- break;
- }
- } while (($vendorDir = dirname($vendorDir)) !== '/');
- }
-
- $this->api = new FacebookSDK([
- 'app_id' => $this->config["keys"]["id"],
- 'app_secret' => $this->config["keys"]["secret"],
- 'default_graph_version' => 'v2.8',
- 'trustForwarded' => $trustForwarded,
- ]);
- }
-
- /**
- * {@inheritdoc}
- */
- function loginBegin() {
-
- $this->endpoint = $this->params['login_done'];
- $helper = $this->api->getRedirectLoginHelper();
-
- // Use re-request, because this will trigger permissions window if not all permissions are granted.
- $url = $helper->getReRequestUrl($this->endpoint, $this->scope);
-
- // Redirect to Facebook
- Hybrid_Auth::redirect($url);
- }
-
- /**
- * {@inheritdoc}
- */
- function loginFinish() {
-
- $helper = $this->api->getRedirectLoginHelper();
- try {
- $accessToken = $helper->getAccessToken($this->params['login_done']);
- } catch (Facebook\Exceptions\FacebookResponseException $e) {
- throw new Hybrid_Exception('Facebook Graph returned an error: ' . $e->getMessage());
- } catch (Facebook\Exceptions\FacebookSDKException $e) {
- throw new Hybrid_Exception('Facebook SDK returned an error: ' . $e->getMessage());
- }
-
- if (!isset($accessToken)) {
- if ($helper->getError()) {
- throw new Hybrid_Exception(sprintf("Could not authorize user, reason: %s (%d)", $helper->getErrorDescription(), $helper->getErrorCode()));
- } else {
- throw new Hybrid_Exception("Could not authorize user. Bad request");
- }
- }
-
- try {
- // Validate token
- $oAuth2Client = $this->api->getOAuth2Client();
- $tokenMetadata = $oAuth2Client->debugToken($accessToken);
- $tokenMetadata->validateAppId($this->config["keys"]["id"]);
- $tokenMetadata->validateExpiration();
-
- // Exchanges a short-lived access token for a long-lived one
- if (!$accessToken->isLongLived()) {
- $accessToken = $oAuth2Client->getLongLivedAccessToken($accessToken);
- }
- } catch (FacebookSDKException $e) {
- throw new Hybrid_Exception($e->getMessage(), 0, $e);
- }
-
- $this->setUserConnected();
- $this->token("access_token", $accessToken->getValue());
- }
-
- /**
- * {@inheritdoc}
- */
- function logout() {
- parent::logout();
- }
-
- /**
- * Update user status
- *
- * @param mixed $status An array describing the status, or string
- * @param string $pageid (optional) User page id
- * @return array
- * @throw Exception
- */
- function setUserStatus($status, $pageid = null) {
-
- if (!is_array($status)) {
- $status = array('message' => $status);
- }
-
- $access_token = null;
-
- if (is_null($pageid)) {
- $pageid = 'me';
- $access_token = $this->token('access_token');
-
- // if post on page, get access_token page
- } else {
-
- foreach ($this->getUserPages(true) as $p) {
- if (isset($p['id']) && intval($p['id']) == intval($pageid)) {
- $access_token = $p['access_token'];
- break;
- }
- }
-
- if (is_null($access_token)) {
- throw new Exception("Update user page failed, page not found or not writable!");
- }
- }
-
- try {
- $response = $this->api->post('/' . $pageid . '/feed', $status, $access_token);
- } catch (FacebookSDKException $e) {
- throw new Exception("Update user status failed! {$this->providerId} returned an error {$e->getMessage()}", 0, $e);
- }
-
- return $response;
- }
-
- /**
- * {@inheridoc}
- */
- function getUserPages($writableonly = false) {
- if (( isset($this->config['scope']) && strpos($this->config['scope'], 'manage_pages') === false ) || (!isset($this->config['scope']) && strpos($this->scope, 'manage_pages') === false ))
- throw new Exception("User status requires manage_page permission!");
-
- try {
- $pages = $this->api->get("/me/accounts", $this->token('access_token'));
- $pages = $pages->getDecodedBody();
- } catch (FacebookApiException $e) {
- throw new Exception("Cannot retrieve user pages! {$this->providerId} returned an error: {$e->getMessage()}", 0, $e);
- }
-
- if (!isset($pages['data'])) {
- return array();
- }
-
- if (!$writableonly) {
- return $pages['data'];
- }
-
- $wrpages = array();
- foreach ($pages['data'] as $p) {
- if (isset($p['perms']) && in_array('CREATE_CONTENT', $p['perms'])) {
- $wrpages[] = $p;
- }
- }
-
- return $wrpages;
- }
-
- /**
- * {@inheritdoc}
- */
- function getUserProfile() {
- try {
- $fields = [
- 'id',
- 'name',
- 'first_name',
- 'last_name',
- 'link',
- 'website',
- 'gender',
- 'locale',
- 'about',
- 'email',
- 'hometown',
- 'location',
- 'birthday'
- ];
- $response = $this->api->get('/me?fields=' . implode(',', $fields), $this->token('access_token'));
- $data = $response->getDecodedBody();
- } catch (FacebookSDKException $e) {
- throw new Exception("User profile request failed! {$this->providerId} returned an error: {$e->getMessage()}", 6, $e);
- }
-
- // Store the user profile.
- $this->user->profile->identifier = (array_key_exists('id', $data)) ? $data['id'] : "";
- $this->user->profile->displayName = (array_key_exists('name', $data)) ? $data['name'] : "";
- $this->user->profile->firstName = (array_key_exists('first_name', $data)) ? $data['first_name'] : "";
- $this->user->profile->lastName = (array_key_exists('last_name', $data)) ? $data['last_name'] : "";
- $this->user->profile->photoURL = $this->getUserPhoto($this->user->profile->identifier);
- $this->user->profile->profileURL = (array_key_exists('link', $data)) ? $data['link'] : "";
- $this->user->profile->webSiteURL = (array_key_exists('website', $data)) ? $data['website'] : "";
- $this->user->profile->gender = (array_key_exists('gender', $data)) ? $data['gender'] : "";
- $this->user->profile->language = (array_key_exists('locale', $data)) ? $data['locale'] : "";
- $this->user->profile->description = (array_key_exists('about', $data)) ? $data['about'] : "";
- $this->user->profile->email = (array_key_exists('email', $data)) ? $data['email'] : "";
- $this->user->profile->emailVerified = (array_key_exists('email', $data)) ? $data['email'] : "";
- $this->user->profile->region = (array_key_exists("location", $data) && array_key_exists("name", $data['location'])) ? $data['location']["name"] : "";
-
- if (!empty($this->user->profile->region)) {
- $regionArr = explode(',', $this->user->profile->region);
- if (count($regionArr) > 1) {
- $this->user->profile->city = trim($regionArr[0]);
- $this->user->profile->country = trim(end($regionArr));
- }
- }
-
- if (array_key_exists('birthday', $data)) {
- $birtydayPieces = explode('/', $data['birthday']);
-
- if (count($birtydayPieces) == 1) {
- $this->user->profile->birthYear = (int)$birtydayPieces[0];
- } elseif (count($birtydayPieces) == 2) {
- $this->user->profile->birthMonth = (int)$birtydayPieces[0];
- $this->user->profile->birthDay = (int)$birtydayPieces[1];
- } elseif (count($birtydayPieces) == 3) {
- $this->user->profile->birthMonth = (int)$birtydayPieces[0];
- $this->user->profile->birthDay = (int)$birtydayPieces[1];
- $this->user->profile->birthYear = (int)$birtydayPieces[2];
- }
- }
-
- return $this->user->profile;
- }
-
- /**
- * Since the Graph API 2.0, the /friends endpoint only returns friend that also use your Facebook app.
- * {@inheritdoc}
- */
- function getUserContacts() {
- $apiCall = '?fields=link,name';
- $returnedContacts = [];
- $pagedList = true;
-
- while ($pagedList) {
- try {
- $response = $this->api->get('/me/friends' . $apiCall, $this->token('access_token'));
- $response = $response->getDecodedBody();
- } catch (FacebookSDKException $e) {
- throw new Hybrid_Exception("User contacts request failed! {$this->providerId} returned an error {$e->getMessage()}", 0, $e);
- }
-
- // Prepare the next call if paging links have been returned
- if (array_key_exists('paging', $response) && array_key_exists('next', $response['paging'])) {
- $pagedList = true;
- $next_page = explode('friends', $response['paging']['next']);
- $apiCall = $next_page[1];
- } else {
- $pagedList = false;
- }
-
- // Add the new page contacts
- $returnedContacts = array_merge($returnedContacts, $response['data']);
- }
-
- $contacts = [];
- foreach ($returnedContacts as $item) {
-
- $uc = new Hybrid_User_Contact();
- $uc->identifier = (array_key_exists("id", $item)) ? $item["id"] : "";
- $uc->displayName = (array_key_exists("name", $item)) ? $item["name"] : "";
- $uc->profileURL = (array_key_exists("link", $item)) ? $item["link"] : "https://www.facebook.com/profile.php?id=" . $uc->identifier;
- $uc->photoURL = $this->getUserPhoto($uc->identifier);
-
- $contacts[] = $uc;
- }
-
- return $contacts;
- }
-
- /**
- * Load the user latest activity, needs 'read_stream' permission
- *
- * @param string $stream Which activity to fetch:
- * - timeline : all the stream
- * - me : the user activity only
- * {@inheritdoc}
- */
- function getUserActivity($stream = 'timeline') {
- try {
- if ($stream == "me") {
- $response = $this->api->get('/me/feed', $this->token('access_token'));
- } else {
- $response = $this->api->get('/me/home', $this->token('access_token'));
- }
- $response = $response->getDecodedBody();
- } catch (FacebookSDKException $e) {
- throw new Hybrid_Exception("User activity stream request failed! {$this->providerId} returned an error: {$e->getMessage()}", 0, $e);
- }
-
- if (!$response || !count($response['data'])) {
- return [];
- }
-
- $activities = [];
- foreach ($response['data'] as $item) {
-
- $ua = new Hybrid_User_Activity();
-
- $ua->id = (array_key_exists("id", $item)) ? $item["id"] : "";
- $ua->date = (array_key_exists("created_time", $item)) ? strtotime($item["created_time"]) : "";
-
- if ($item["type"] == "video") {
- $ua->text = (array_key_exists("link", $item)) ? $item["link"] : "";
- }
-
- if ($item["type"] == "link") {
- $ua->text = (array_key_exists("link", $item)) ? $item["link"] : "";
- }
-
- if (empty($ua->text) && isset($item["story"])) {
- $ua->text = (array_key_exists("link", $item)) ? $item["link"] : "";
- }
-
- if (empty($ua->text) && isset($item["message"])) {
- $ua->text = (array_key_exists("message", $item)) ? $item["message"] : "";
- }
-
- if (!empty($ua->text)) {
- $ua->user->identifier = (array_key_exists("id", $item["from"])) ? $item["from"]["id"] : "";
- $ua->user->displayName = (array_key_exists("name", $item["from"])) ? $item["from"]["name"] : "";
- $ua->user->profileURL = "https://www.facebook.com/profile.php?id=" . $ua->user->identifier;
- $ua->user->photoURL = $this->getUserPhoto($ua->user->identifier);
-
- $activities[] = $ua;
- }
- }
-
- return $activities;
- }
-
- /**
- * Returns a photo URL for give user.
- *
- * @param string $id
- * The User ID.
- *
- * @return string
- * A photo URL.
- */
- function getUserPhoto($id) {
- $photo_size = isset($this->config['photo_size']) ? $this->config['photo_size'] : 150;
-
- return "https://graph.facebook.com/{$id}/picture?width={$photo_size}&height={$photo_size}";
- }
-
-}
diff --git a/e107_handlers/hybridauth/Hybrid/Providers/Foursquare.php b/e107_handlers/hybridauth/Hybrid/Providers/Foursquare.php
deleted file mode 100644
index b1156804a..000000000
--- a/e107_handlers/hybridauth/Hybrid/Providers/Foursquare.php
+++ /dev/null
@@ -1,121 +0,0 @@
- array (
- * "enabled" => true,
- * "keys" => ...,
- * "params" => array( "photo_size" => "16x16" )
- * ),
- * ...
- * - list of valid photo_size values is described here https://developer.foursquare.com/docs/responses/photo.html
- * - default photo_size is 100x100
- */
-class Hybrid_Providers_Foursquare extends Hybrid_Provider_Model_OAuth2 {
-
- private static $apiVersion = array("v" => "20120610");
- private static $defPhotoSize = "100x100";
-
- /**
- * {@inheritdoc}
- */
- function initialize() {
- parent::initialize();
-
- // Provider apis end-points
- $this->api->api_base_url = "https://api.foursquare.com/v2/";
- $this->api->authorize_url = "https://foursquare.com/oauth2/authenticate";
- $this->api->token_url = "https://foursquare.com/oauth2/access_token";
-
- $this->api->sign_token_name = "oauth_token";
- }
-
- /**
- * {@inheritdoc}
- */
- function getUserProfile() {
- $data = $this->api->api("users/self", "GET", Hybrid_Providers_Foursquare::$apiVersion);
-
- if (!isset($data->response->user->id)) {
- throw new Exception("User profile request failed! {$this->providerId} returned an invalid response:" . Hybrid_Logger::dumpData( $data ), 6);
- }
-
- $data = $data->response->user;
-
- $this->user->profile->identifier = $data->id;
- $this->user->profile->firstName = $data->firstName;
- $this->user->profile->lastName = $data->lastName;
- $this->user->profile->displayName = $this->buildDisplayName($this->user->profile->firstName, $this->user->profile->lastName);
- $this->user->profile->photoURL = $this->buildPhotoURL($data->photo->prefix, $data->photo->suffix);
- $this->user->profile->profileURL = "https://www.foursquare.com/user/" . $data->id;
- $this->user->profile->gender = $data->gender;
- $this->user->profile->city = $data->homeCity;
- $this->user->profile->email = $data->contact->email;
- $this->user->profile->emailVerified = $data->contact->email;
-
- return $this->user->profile;
- }
-
- /**
- * {@inheritdoc}
- */
- function getUserContacts() {
- // refresh tokens if needed
- $this->refreshToken();
-
- //
- $response = array();
- $contacts = array();
- try {
- $response = $this->api->api("users/self/friends", "GET", Hybrid_Providers_Foursquare::$apiVersion);
- } catch (Exception $e) {
- throw new Exception("User contacts request failed! {$this->providerId} returned an error: {$e->getMessage()}", 0, $e);
- }
-
- if (isset($response) && $response->meta->code == 200) {
- foreach ($response->response->friends->items as $contact) {
- $uc = new Hybrid_User_Contact();
- //
- $uc->identifier = $contact->id;
- //$uc->profileURL = ;
- //$uc->webSiteURL = ;
- $uc->photoURL = $this->buildPhotoURL($contact->photo->prefix, $contact->photo->suffix);
- $uc->displayName = $this->buildDisplayName((isset($contact->firstName) ? ($contact->firstName) : ("")), (isset($contact->lastName) ? ($contact->lastName) : ("")));
- //$uc->description = ;
- $uc->email = (isset($contact->contact->email) ? ($contact->contact->email) : (""));
- //
- $contacts[] = $uc;
- }
- }
- return $contacts;
- }
-
- /**
- * {@inheritdoc}
- */
- private function buildDisplayName($firstName, $lastName) {
- return trim($firstName . " " . $lastName);
- }
-
- private function buildPhotoURL($prefix, $suffix) {
- if (isset($prefix) && isset($suffix)) {
- return $prefix . ((isset($this->config["params"]["photo_size"])) ? ($this->config["params"]["photo_size"]) : (Hybrid_Providers_Foursquare::$defPhotoSize)) . $suffix;
- }
- return ("");
- }
-
-}
diff --git a/e107_handlers/hybridauth/Hybrid/Providers/Github.php b/e107_handlers/hybridauth/Hybrid/Providers/Github.php
deleted file mode 100644
index f2e02c8d8..000000000
--- a/e107_handlers/hybridauth/Hybrid/Providers/Github.php
+++ /dev/null
@@ -1,127 +0,0 @@
- public read-only access (includes public user profile info, public repo info, and gists).
- public $scope = "";
-
- /**
- * IDp wrappers initializer
- */
- function initialize()
- {
- parent::initialize();
-
- // Provider api end-points
- $this->api->api_base_url = "https://api.github.com/";
- $this->api->authorize_url = "https://github.com/login/oauth/authorize";
- $this->api->token_url = "https://github.com/login/oauth/access_token";
- }
-
- /**
- * load the user profile from the IDp api client
- */
- function getUserProfile()
- {
- $data = $this->api->api( "user" );
-
- if ( ! isset( $data->id ) ){
- throw new Exception( "User profile request failed! {$this->providerId} returned an invalid response.", 6 );
- }
-
- $this->user->profile->identifier = @ $data->id;
- $this->user->profile->displayName = @ $data->name;
- $this->user->profile->description = @ $data->bio;
- $this->user->profile->photoURL = @ $data->avatar_url;
- $this->user->profile->profileURL = @ $data->html_url;
- $this->user->profile->email = @ $data->email;
- $this->user->profile->webSiteURL = @ $data->blog;
- $this->user->profile->region = @ $data->location;
-
- if( empty($this->user->profile->displayName) ){
- $this->user->profile->displayName = @ $data->login;
- }
-
- // request user emails from github api
- if( empty($data->email) ){
- try{
- $emails = $this->api->api("user/emails");
-
- // fail gracefully, and let apps collect the email if not present
- if (is_array($emails)) {
- foreach ($emails as $email) {
- if ($email instanceof stdClass
- && property_exists($email, 'primary')
- && true === $email->primary
- && property_exists($email, 'email')
- ) {
- $this->user->profile->email = $email->email;
-
- // record whether the email address is verified
- if (property_exists($email, 'verified')
- && true === $email->verified
- ) {
- $this->user->profile->emailVerified = $email->email;
- }
-
- break;
- }
- }
- }
- }
- catch( GithubApiException $e ){
- throw new Exception( "User email request failed! {$this->providerId} returned an error: $e", 6 );
- }
- }
-
- return $this->user->profile;
- }
- /**
- *
- */
- function getUserContacts() {
- // refresh tokens if needed
- $this->refreshToken();
-
- //
- $response = array();
- $contacts = array();
- try {
- $response = $this->api->api( "user/followers" );
- } catch (Exception $e) {
- throw new Exception("User contacts request failed! {$this->providerId} returned an error: $e");
- }
- //
- if ( isset( $response ) ) {
- foreach ($response as $contact) {
- try {
- $contactInfo = $this->api->api( "users/".$contact->login );
- } catch (Exception $e) {
- throw new Exception("Contact info request failed for user {$contact->login}! {$this->providerId} returned an error: $e");
- }
- //
- $uc = new Hybrid_User_Contact();
- //
- $uc->identifier = $contact->id;
- $uc->profileURL = @$contact->html_url;
- $uc->webSiteURL = @$contact->blog;
- $uc->photoURL = @$contact->avatar_url;
- $uc->displayName = ( isset( $contactInfo->name )?( $contactInfo->name ):( $contact->login ) );
- //$uc->description = ;
- $uc->email = @$contactInfo->email;
- //
- $contacts[] = $uc;
- }
- }
- return $contacts;
- }
-}
diff --git a/e107_handlers/hybridauth/Hybrid/Providers/Google.php b/e107_handlers/hybridauth/Hybrid/Providers/Google.php
deleted file mode 100644
index 3c936725f..000000000
--- a/e107_handlers/hybridauth/Hybrid/Providers/Google.php
+++ /dev/null
@@ -1,306 +0,0 @@
- more infos on google APIs: http://developer.google.com (official site)
- * or here: http://discovery-check.appspot.com/ (unofficial but up to date)
- * default permissions
- * {@inheritdoc}
- */
- public $scope = "https://www.googleapis.com/auth/plus.login https://www.googleapis.com/auth/plus.me https://www.googleapis.com/auth/plus.profile.emails.read https://www.google.com/m8/feeds/";
-
- /**
- * {@inheritdoc}
- */
- function initialize() {
- parent::initialize();
-
- // Provider api end-points
- $this->api->authorize_url = "https://accounts.google.com/o/oauth2/auth";
- $this->api->token_url = "https://accounts.google.com/o/oauth2/token";
- $this->api->token_info_url = "https://www.googleapis.com/oauth2/v2/tokeninfo";
-
- // Google POST methods require an access_token in the header
- $this->api->curl_header = array("Authorization: OAuth " . $this->api->access_token);
-
- // Override the redirect uri when it's set in the config parameters. This way we prevent
- // redirect uri mismatches when authenticating with Google.
- if (isset($this->config['redirect_uri']) && !empty($this->config['redirect_uri'])) {
- $this->api->redirect_uri = $this->config['redirect_uri'];
- }
- }
-
- /**
- * {@inheritdoc}
- */
- function loginBegin() {
- $parameters = array("scope" => $this->scope, "access_type" => "offline");
- $optionals = array("scope", "access_type", "redirect_uri", "approval_prompt", "hd", "state");
-
- foreach ($optionals as $parameter) {
- if (isset($this->config[$parameter]) && !empty($this->config[$parameter])) {
- $parameters[$parameter] = $this->config[$parameter];
- }
- if (isset($this->config["scope"]) && !empty($this->config["scope"])) {
- $this->scope = $this->config["scope"];
- }
- }
-
- if (isset($this->config['force']) && $this->config['force'] === true) {
- $parameters['approval_prompt'] = 'force';
- }
-
- Hybrid_Auth::redirect($this->api->authorizeUrl($parameters));
- }
-
- /**
- * {@inheritdoc}
- */
- function getUserProfile() {
- // refresh tokens if needed
- $this->refreshToken();
-
- // ask google api for user infos
- if (strpos($this->scope, '/auth/plus.profile.emails.read') !== false) {
- $verified = $this->api->api("https://www.googleapis.com/plus/v1/people/me");
-
- if (!isset($verified->id) || isset($verified->error))
- $verified = new stdClass();
- } else {
- $verified = $this->api->api("https://www.googleapis.com/plus/v1/people/me/openIdConnect");
-
- if (!isset($verified->sub) || isset($verified->error))
- $verified = new stdClass();
- }
-
- $response = $this->api->api("https://www.googleapis.com/plus/v1/people/me");
- if (!isset($response->id) || isset($response->error)) {
- throw new Exception("User profile request failed! {$this->providerId} returned an invalid response:" . Hybrid_Logger::dumpData( $response ), 6);
- }
-
- $this->user->profile->identifier = (property_exists($verified, 'id')) ? $verified->id : ((property_exists($response, 'id')) ? $response->id : "");
- $this->user->profile->firstName = (property_exists($response, 'name')) ? $response->name->givenName : "";
- $this->user->profile->lastName = (property_exists($response, 'name')) ? $response->name->familyName : "";
- $this->user->profile->displayName = (property_exists($response, 'displayName')) ? $response->displayName : "";
- $this->user->profile->photoURL = (property_exists($response, 'image')) ? ((property_exists($response->image, 'url')) ? substr($response->image->url, 0, -2) . "200" : '') : '';
- $this->user->profile->profileURL = (property_exists($response, 'url')) ? $response->url : "";
- $this->user->profile->description = (property_exists($response, 'aboutMe')) ? $response->aboutMe : "";
- $this->user->profile->gender = (property_exists($response, 'gender')) ? $response->gender : "";
- $this->user->profile->language = (property_exists($response, 'locale')) ? $response->locale : ((property_exists($verified, 'locale')) ? $verified->locale : "");
- $this->user->profile->email = (property_exists($response, 'email')) ? $response->email : ((property_exists($verified, 'email')) ? $verified->email : "");
- $this->user->profile->emailVerified = (property_exists($verified, 'email')) ? $verified->email : "";
- if (property_exists($response, 'emails')) {
- if (count($response->emails) == 1) {
- $this->user->profile->email = $response->emails[0]->value;
- } else {
- foreach ($response->emails as $email) {
- if ($email->type == 'account') {
- $this->user->profile->email = $email->value;
- break;
- }
- }
- }
- if (property_exists($verified, 'emails')) {
- if (count($verified->emails) == 1) {
- $this->user->profile->emailVerified = $verified->emails[0]->value;
- } else {
- foreach ($verified->emails as $email) {
- if ($email->type == 'account') {
- $this->user->profile->emailVerified = $email->value;
- break;
- }
- }
- }
- }
- }
- $this->user->profile->phone = (property_exists($response, 'phone')) ? $response->phone : "";
- $this->user->profile->country = (property_exists($response, 'country')) ? $response->country : "";
- $this->user->profile->region = (property_exists($response, 'region')) ? $response->region : "";
- $this->user->profile->zip = (property_exists($response, 'zip')) ? $response->zip : "";
- if (property_exists($response, 'placesLived')) {
- $this->user->profile->city = "";
- $this->user->profile->address = "";
- foreach ($response->placesLived as $c) {
- if (property_exists($c, 'primary')) {
- if ($c->primary == true) {
- $this->user->profile->address = $c->value;
- $this->user->profile->city = $c->value;
- break;
- }
- } else {
- if (property_exists($c, 'value')) {
- $this->user->profile->address = $c->value;
- $this->user->profile->city = $c->value;
- }
- }
- }
- }
-
- // google API returns multiple urls, but a "website" only if it is verified
- // see http://support.google.com/plus/answer/1713826?hl=en
- if (property_exists($response, 'urls')) {
- foreach ($response->urls as $u) {
- if (property_exists($u, 'primary') && $u->primary == true)
- $this->user->profile->webSiteURL = $u->value;
- }
- } else {
- $this->user->profile->webSiteURL = '';
- }
- // google API returns age ranges min and/or max as of https://developers.google.com/+/web/api/rest/latest/people#resource
- if (property_exists($response, 'ageRange')) {
- if (property_exists($response->ageRange, 'min') && property_exists($response->ageRange, 'max')) {
- $this->user->profile->age = $response->ageRange->min . ' - ' . $response->ageRange->max;
- } else {
- if (property_exists($response->ageRange, 'min')) {
- $this->user->profile->age = '>= ' . $response->ageRange->min;
- } else {
- if (property_exists($response->ageRange, 'max')) {
- $this->user->profile->age = '<= ' . $response->ageRange->max;
- } else {
- $this->user->profile->age = '';
- }
- }
- }
- } else {
- $this->user->profile->age = '';
- }
- // google API returns birthdays only if a user set 'show in my account'
- if (property_exists($response, 'birthday')) {
- list($birthday_year, $birthday_month, $birthday_day) = explode('-', $response->birthday);
-
- $this->user->profile->birthDay = (int) $birthday_day;
- $this->user->profile->birthMonth = (int) $birthday_month;
- $this->user->profile->birthYear = (int) $birthday_year;
- } else {
- $this->user->profile->birthDay = 0;
- $this->user->profile->birthMonth = 0;
- $this->user->profile->birthYear = 0;
- }
-
- return $this->user->profile;
- }
-
- /**
- * {@inheritdoc}
- */
- function getUserContacts() {
- // refresh tokens if needed
- $this->refreshToken();
-
- $contacts = array();
- if (!isset($this->config['contacts_param'])) {
- $this->config['contacts_param'] = array("max-results" => 500);
- }
-
- // Google Gmail and Android contacts
- if (strpos($this->scope, '/m8/feeds/') !== false) {
-
- $response = $this->api->api("https://www.google.com/m8/feeds/contacts/default/full?"
- . http_build_query(array_merge(array('alt' => 'json'), $this->config['contacts_param'])));
-
- if (!$response) {
- return array();
- }
-
- if (isset($response->feed->entry)) {
- foreach ($response->feed->entry as $idx => $entry) {
- $uc = new Hybrid_User_Contact();
- $uc->email = isset($entry->{'gd$email'}[0]->address) ? (string) $entry->{'gd$email'}[0]->address : '';
- $uc->displayName = isset($entry->title->{'$t'}) ? (string) $entry->title->{'$t'} : '';
- $uc->identifier = ($uc->email != '') ? $uc->email : '';
- $uc->description = '';
- if (property_exists($entry, 'link')) {
- /**
- * sign links with access_token
- */
- if (is_array($entry->link)) {
- foreach ($entry->link as $l) {
- if (property_exists($l, 'gd$etag') && $l->type == "image/*") {
- $uc->photoURL = $this->addUrlParam($l->href, array('access_token' => $this->api->access_token));
- } else if ($l->type == "self") {
- $uc->profileURL = $this->addUrlParam($l->href, array('access_token' => $this->api->access_token));
- }
- }
- }
- } else {
- $uc->profileURL = '';
- }
- if (property_exists($response, 'website')) {
- if (is_array($response->website)) {
- foreach ($response->website as $w) {
- if ($w->primary == true)
- $uc->webSiteURL = $w->value;
- }
- } else {
- $uc->webSiteURL = $response->website->value;
- }
- } else {
- $uc->webSiteURL = '';
- }
-
- $contacts[] = $uc;
- }
- }
- }
-
- // Google social contacts
- if (strpos($this->scope, '/auth/plus.login') !== false) {
-
- $response = $this->api->api("https://www.googleapis.com/plus/v1/people/me/people/visible?"
- . http_build_query($this->config['contacts_param']));
-
- if (!$response) {
- return array();
- }
-
- foreach ($response->items as $idx => $item) {
- $uc = new Hybrid_User_Contact();
- $uc->email = (property_exists($item, 'email')) ? $item->email : '';
- $uc->displayName = (property_exists($item, 'displayName')) ? $item->displayName : '';
- $uc->identifier = (property_exists($item, 'id')) ? $item->id : '';
-
- $uc->description = (property_exists($item, 'objectType')) ? $item->objectType : '';
- $uc->photoURL = (property_exists($item, 'image')) ? ((property_exists($item->image, 'url')) ? $item->image->url : '') : '';
- $uc->profileURL = (property_exists($item, 'url')) ? $item->url : '';
- $uc->webSiteURL = '';
-
- $contacts[] = $uc;
- }
- }
-
- return $contacts;
- }
-
- /**
- * Add query parameters to the $url
- *
- * @param string $url URL
- * @param array $params Parameters to add
- * @return string
- */
- function addUrlParam($url, array $params){
- $query = parse_url($url, PHP_URL_QUERY);
-
- // Returns the URL string with new parameters
- if ($query) {
- $url .= '&' . http_build_query($params);
- } else {
- $url .= '?' . http_build_query($params);
- }
- return $url;
- }
-
-}
-
diff --git a/e107_handlers/hybridauth/Hybrid/Providers/GoogleOpenID.php b/e107_handlers/hybridauth/Hybrid/Providers/GoogleOpenID.php
deleted file mode 100644
index 4d3d3e07f..000000000
--- a/e107_handlers/hybridauth/Hybrid/Providers/GoogleOpenID.php
+++ /dev/null
@@ -1,40 +0,0 @@
- array (
- * "enabled" => true,
- * "wrapper" => array( "path" => "Providers/GoogleOpenID.php", "class" => "Hybrid_Providers_Google" )
- * )
- */
-class Hybrid_Providers_Google extends Hybrid_Provider_Model_OpenID
-{
- var $openidIdentifier = "https://www.google.com/accounts/o8/id";
-
- /**
- * finish login step
- */
- function loginFinish()
- {
- parent::loginFinish();
-
- $this->user->profile->emailVerified = $this->user->profile->email;
-
- // restore the user profile
- Hybrid_Auth::storage()->set( "hauth_session.{$this->providerId}.user", $this->user );
- }
-}
diff --git a/e107_handlers/hybridauth/Hybrid/Providers/LinkedIn.php b/e107_handlers/hybridauth/Hybrid/Providers/LinkedIn.php
deleted file mode 100644
index f74f827f0..000000000
--- a/e107_handlers/hybridauth/Hybrid/Providers/LinkedIn.php
+++ /dev/null
@@ -1,170 +0,0 @@
-api->api_base_url = "https://api.linkedin.com/v1/";
- $this->api->authorize_url = "https://www.linkedin.com/oauth/v2/authorization";
- $this->api->token_url = "https://www.linkedin.com/oauth/v2/accessToken";
- }
-
- /**
- * {@inheritdoc}
- */
- function loginBegin() {
- if (is_array($this->scope)) {
- $this->scope = implode(" ", $this->scope);
- }
- parent::loginBegin();
- }
-
- /**
- * {@inheritdoc}
- *
- * @see https://developer.linkedin.com/docs/rest-api
- */
- function getUserProfile() {
- // Refresh tokens if needed.
- $this->setHeaders("token");
- $this->refreshToken();
-
- // https://developer.linkedin.com/docs/fields.
- $fields = isset($this->config["fields"]) ? $this->config["fields"] : [
- "id",
- "email-address",
- "first-name",
- "last-name",
- "headline",
- "location",
- "industry",
- "picture-url",
- "public-profile-url",
- ];
-
- $this->setHeaders();
- $response = $this->api->get(
- "people/~:(" . implode(",", $fields) . ")",
- array(
- "format" => "json",
- )
- );
-
- if (!isset($response->id)) {
- throw new Exception("User profile request failed! {$this->providerId} returned an invalid response: " . Hybrid_Logger::dumpData($response), 6);
- }
-
- $this->user->profile->identifier = isset($response->id) ? $response->id : "";
- $this->user->profile->firstName = isset($response->firstName) ? $response->firstName : "";
- $this->user->profile->lastName = isset($response->lastName) ? $response->lastName : "";
- $this->user->profile->photoURL = isset($response->pictureUrl) ? $response->pictureUrl : "";
- $this->user->profile->profileURL = isset($response->publicProfileUrl) ? $response->publicProfileUrl : "";
- $this->user->profile->email = isset($response->emailAddress) ? $response->emailAddress : "";
- $this->user->profile->description = isset($response->headline) ? $response->headline : "";
- $this->user->profile->country = isset($response->location) ? $response->location->name : "";
- $this->user->profile->emailVerified = $this->user->profile->email;
- $this->user->profile->displayName = trim($this->user->profile->firstName . " " . $this->user->profile->lastName);
-
- return $this->user->profile;
- }
-
- /**
- * {@inheritdoc}
- *
- * @param array $status
- * An associative array containing:
- * - content: A collection of fields describing the shared content.
- * - comment: A comment by the member to associated with the share.
- * - visibility: A collection of visibility information about the share.
- *
- * @return object
- * An object containing:
- * - updateKey - A unique ID for the shared content posting that was just created.
- * - updateUrl - A direct link to the newly shared content on LinkedIn.com that you can direct the user's web browser to.
- * @throws Exception
- * @see https://developer.linkedin.com/docs/share-on-linkedin
- */
- function setUserStatus($status) {
- // Refresh tokens if needed.
- $this->setHeaders("token");
- $this->refreshToken();
-
- try {
- // Define default visibility.
- if (!isset($status["visibility"])) {
- $status["visibility"]["code"] = "anyone";
- }
-
- $this->setHeaders("share");
- $response = $this->api->post(
- "people/~/shares?format=json",
- array(
- "body" => $status,
- )
- );
- } catch (Exception $e) {
- throw new Exception("Update user status failed! {$this->providerId} returned an error: {$e->getMessage()}", 0, $e);
- }
-
- if (!isset($response->updateKey)) {
- throw new Exception("Update user status failed! {$this->providerId} returned an error: {$response->message}", $response->errorCode);
- }
-
- return $response;
- }
-
- /**
- * Set correct request headers.
- *
- * @param string $api_type
- * (optional) Specify api type.
- *
- * @return void
- */
- private function setHeaders($api_type = null) {
- $this->api->curl_header = array(
- "Authorization: Bearer {$this->api->access_token}",
- );
-
- switch ($api_type) {
- case "share":
- $this->api->curl_header = array_merge(
- $this->api->curl_header,
- array(
- "Content-Type: application/json",
- "x-li-format: json",
- )
- );
- break;
-
- case "token":
- $this->api->curl_header = array_merge(
- $this->api->curl_header,
- array(
- "Content-Type: application/x-www-form-urlencoded",
- )
- );
- break;
- }
- }
-
-}
diff --git a/e107_handlers/hybridauth/Hybrid/Providers/Live.php b/e107_handlers/hybridauth/Hybrid/Providers/Live.php
deleted file mode 100644
index da177a30d..000000000
--- a/e107_handlers/hybridauth/Hybrid/Providers/Live.php
+++ /dev/null
@@ -1,100 +0,0 @@
-
- * @version 0.2
- * @license BSD License
- */
-
-/**
- * Hybrid_Providers_Live - Windows Live provider adapter based on OAuth2 protocol
- */
-class Hybrid_Providers_Live extends Hybrid_Provider_Model_OAuth2 {
-
- /**
- * {@inheritdoc}
- */
- public $scope = 'wl.basic wl.contacts_emails wl.emails wl.signin wl.share wl.birthday';
-
- /**
- * {@inheritdoc}
- */
- function initialize() {
- parent::initialize();
-
- // Provider api end-points
- $this->api->api_base_url = 'https://apis.live.net/v5.0/';
- $this->api->authorize_url = 'https://login.live.com/oauth20_authorize.srf';
- $this->api->token_url = 'https://login.live.com/oauth20_token.srf';
- }
-
- /**
- * {@inheritdoc}
- */
- function getUserProfile() {
- $data = $this->api->get("me");
-
- if (!isset($data->id)) {
- throw new Exception("User profile request failed! {$this->providerId} returned an invalid response: " . Hybrid_Logger::dumpData( $data ), 6);
- }
-
- $this->user->profile->identifier = (property_exists($data, 'id')) ? $data->id : "";
- $this->user->profile->firstName = (property_exists($data, 'first_name')) ? $data->first_name : "";
- $this->user->profile->lastName = (property_exists($data, 'last_name')) ? $data->last_name : "";
- $this->user->profile->displayName = (property_exists($data, 'name')) ? trim($data->name) : "";
- $this->user->profile->gender = (property_exists($data, 'gender')) ? $data->gender : "";
-
- //wl.basic
- $this->user->profile->profileURL = (property_exists($data, 'link')) ? $data->link : "";
-
- //wl.emails
- $this->user->profile->email = (property_exists($data, 'emails')) ? $data->emails->preferred : "";
- $this->user->profile->emailVerified = (property_exists($data, 'emails')) ? $data->emails->account : "";
-
- //wl.birthday
- $this->user->profile->birthDay = (property_exists($data, 'birth_day')) ? $data->birth_day : "";
- $this->user->profile->birthMonth = (property_exists($data, 'birth_month')) ? $data->birth_month : "";
- $this->user->profile->birthYear = (property_exists($data, 'birth_year')) ? $data->birth_year : "";
-
- return $this->user->profile;
- }
-
- /**
- * Windows Live api does not support retrieval of email addresses (only hashes :/)
- * {@inheritdoc}
- */
- function getUserContacts() {
- $response = $this->api->get('me/contacts');
-
- if ($this->api->http_code != 200) {
- throw new Exception('User contacts request failed! ' . $this->providerId . ' returned an error: ' . $this->errorMessageByStatus($this->api->http_code));
- }
-
- if (!isset($response->data) || ( isset($response->errcode) && $response->errcode != 0 )) {
- return array();
- }
-
- $contacts = array();
-
- foreach ($response->data as $item) {
- $uc = new Hybrid_User_Contact();
-
- $uc->identifier = (property_exists($item, 'id')) ? $item->id : "";
- $uc->displayName = (property_exists($item, 'name')) ? $item->name : "";
- $uc->email = (property_exists($item, 'emails')) ? $item->emails->preferred : "";
- $contacts[] = $uc;
- }
-
- return $contacts;
- }
-
-}
diff --git a/e107_handlers/hybridauth/Hybrid/Providers/MySpace.php b/e107_handlers/hybridauth/Hybrid/Providers/MySpace.php
deleted file mode 100644
index 8ce0ffe35..000000000
--- a/e107_handlers/hybridauth/Hybrid/Providers/MySpace.php
+++ /dev/null
@@ -1,164 +0,0 @@
-api->api_endpoint_url = "http://api.myspace.com/v1/";
- $this->api->authorize_url = "http://api.myspace.com/authorize";
- $this->api->request_token_url = "http://api.myspace.com/request_token";
- $this->api->access_token_url = "http://api.myspace.com/access_token";
- }
-
- /**
- * get the connected uid from myspace api
- */
- public function getCurrentUserId()
- {
- $response = $this->api->get( 'http://api.myspace.com/v1/user.json' );
-
- if ( ! isset( $response->userId ) ){
- throw new Exception( "User id request failed! {$this->providerId} returned an invalid response." );
- }
-
- return $response->userId;
- }
-
- /**
- * load the user profile from the IDp api client
- */
- function getUserProfile()
- {
- $userId = $this->getCurrentUserId();
-
- $data = $this->api->get( 'http://api.myspace.com/v1/users/' . $userId . '/profile.json' );
-
- if ( ! is_object( $data ) ){
- throw new Exception( "User profile request failed! {$this->providerId} returned an invalid response.", 6 );
- }
-
- $this->user->profile->identifier = $userId;
- $this->user->profile->displayName = $data->basicprofile->name;
- $this->user->profile->description = $data->aboutme;
- $this->user->profile->gender = $data->basicprofile->gender;
- $this->user->profile->photoURL = $data->basicprofile->image;
- $this->user->profile->profileURL = $data->basicprofile->webUri;
- $this->user->profile->age = $data->age;
- $this->user->profile->country = $data->country;
- $this->user->profile->region = $data->region;
- $this->user->profile->city = $data->city;
- $this->user->profile->zip = $data->postalcode;
-
- return $this->user->profile;
- }
-
- /**
- * load the user contacts
- */
- function getUserContacts()
- {
- $userId = $this->getCurrentUserId();
-
- $response = $this->api->get( "http://api.myspace.com/v1/users/" . $userId . "/friends.json" );
-
- if ( ! is_object( $response ) ){
- throw new Exception( "User profile request failed! {$this->providerId} returned an invalid response.", 6 );
- }
-
- $contacts = ARRAY();
-
- foreach( $response->Friends as $item ){
- $uc = new Hybrid_User_Contact();
-
- $uc->identifier = $item->userId;
- $uc->displayName = $item->name;
- $uc->profileURL = $item->webUri;
- $uc->photoURL = $item->image;
- $uc->description = $item->status;
-
- $contacts[] = $uc;
- }
-
- return $contacts;
- }
-
- /**
- * update user status
- */
- function setUserStatus( $status )
- {
- // crappy myspace... gonna see this asaic
- $userId = $this->getCurrentUserId();
-
- $parameters = array( 'status' => $status );
-
- $response = $this->api->api( "http://api.myspace.com/v1/users/" . $userId . "/status", 'PUT', $parameters );
-
- // check the last HTTP status code returned
- if ( $this->api->http_code != 200 )
- {
- throw new Exception( "Update user status failed! {$this->providerId} returned an error. " . $this->errorMessageByStatus( $this->api->http_code ) );
- }
- }
-
- /**
- * load the user latest activity
- * - timeline : all the stream
- * - me : the user activity only
- */
- function getUserActivity( $stream )
- {
- $userId = $this->getCurrentUserId();
-
- if( $stream == "me" ){
- $response = $this->api->get( "http://api.myspace.com/v1/users/" . $userId . "/status.json" );
- }
- else{
- $response = $this->api->get( "http://api.myspace.com/v1/users/" . $userId . "/friends/status.json" );
- }
-
- if ( ! is_object( $response ) ){
- throw new Exception( "User profile request failed! {$this->providerId} returned an invalid response.", 6 );
- }
-
- $activities = ARRAY();
-
- if( $stream == "me" ){
- // todo
- }
- else{
- foreach( $response->FriendsStatus as $item ){
- $ua = new Hybrid_User_Activity();
-
- $ua->id = $item->statusId;
- $ua->date = NULL; // to find out!!
- $ua->text = $item->status;
-
- $ua->user->identifier = $item->user->userId;
- $ua->user->displayName = $item->user->name;
- $ua->user->profileURL = $item->user->uri;
- $ua->user->photoURL = $item->user->image;
-
- $activities[] = $ua;
- }
- }
-
- return $activities;
- }
-}
diff --git a/e107_handlers/hybridauth/Hybrid/Providers/OpenID.php b/e107_handlers/hybridauth/Hybrid/Providers/OpenID.php
deleted file mode 100644
index 61e71e560..000000000
--- a/e107_handlers/hybridauth/Hybrid/Providers/OpenID.php
+++ /dev/null
@@ -1,16 +0,0 @@
-user->profile->identifier = str_ireplace("http://steamcommunity.com/openid/id/",
- "", $this->user->profile->identifier);
-
- if (!$this->user->profile->identifier) {
- throw new Exception("Authentication failed! {$this->providerId} returned an invalid user ID.", 5);
- }
-
- // If API key is not provided, use legacy API methods
- if (!empty($this->config['keys']['key'])) {
- $this->getUserProfileWebAPI($this->config['keys']['key']);
- } else {
- $this->getUserProfileLegacyAPI();
- }
-
- Hybrid_Auth::storage()->set("hauth_session.{$this->providerId}.user", $this->user);
- }
-
- function getUserProfileWebAPI($apiKey)
- {
- $apiUrl = 'http://api.steampowered.com/ISteamUser/GetPlayerSummaries/v0002/?key='
- . $apiKey . '&steamids=' . $this->user->profile->identifier;
-
- $data = @file_get_contents($apiUrl);
- $data = json_decode($data);
-
- if (!is_object($data) || !isset($data->response->players[0])) {
- return false;
- }
-
- // Get the first index in 'players' array
- $data = $data->response->players[0];
-
- $this->user->profile->displayName = property_exists($data, 'personaname') ? $data->personaname : '';
- $this->user->profile->firstName = property_exists($data, 'realname') ? $data->realname : '';
- $this->user->profile->photoURL = property_exists($data, 'avatarfull') ? $data->avatarfull : '';
- $this->user->profile->profileURL = property_exists($data, 'profileurl') ? $data->profileurl : '';
- $this->user->profile->country = property_exists($data, 'loccountrycode') ? $data->loccountrycode : '';
- }
-
- function getUserProfileLegacyAPI()
- {
- $apiUrl = 'http://steamcommunity.com/profiles/' . $this->user->profile->identifier . '/?xml=1';
-
- try {
- $data = @file_get_contents($apiUrl);
- $data = @ new SimpleXMLElement($data);
- } catch(Exception $e) {
- Hybrid_Logger::error( "Steam::getUserProfileLegacyAPI() error: ", $e->getMessage());
- return false;
- }
-
- if (!is_object($data)) {
- return false;
- }
-
- # store the user profile.
- //$this->user->profile->identifier = "";
- if (property_exists($data, 'customURL') && (string) $data->customURL != '') {
- $this->user->profile->profileURL = 'http://steamcommunity.com/id/' . (string) $data->customURL . '/';
- }
- else {
- $this->user->profile->profileURL = "http://steamcommunity.com/profiles/{$this->user->profile->identifier}/";
- }
-
- $this->user->profile->webSiteURL = "";
- $this->user->profile->photoURL = property_exists($data, 'avatarFull') ? (string)$data->avatarFull : '';
- $this->user->profile->displayName = property_exists($data, 'steamID') ? (string)$data->steamID : '';
- $this->user->profile->description = property_exists($data, 'summary') ? (string)$data->summary : '';
- $this->user->profile->firstName = property_exists($data, 'realname') ? (string)$data->realname : '';
- $this->user->profile->lastName = "";
- $this->user->profile->gender = "";
- $this->user->profile->language = "";
- $this->user->profile->age = "";
- $this->user->profile->birthDay = "";
- $this->user->profile->birthMonth = "";
- $this->user->profile->birthYear = "";
- $this->user->profile->email = "";
- $this->user->profile->emailVerified = "";
- $this->user->profile->phone = "";
- $this->user->profile->address = "";
- $this->user->profile->country = "";
- $this->user->profile->region = property_exists($data, 'location') ? (string)$data->location : '';
- $this->user->profile->city = "";
- $this->user->profile->zip = "";
- }
-}
diff --git a/e107_handlers/hybridauth/Hybrid/Providers/Twitter.php b/e107_handlers/hybridauth/Hybrid/Providers/Twitter.php
deleted file mode 100644
index 5353779dd..000000000
--- a/e107_handlers/hybridauth/Hybrid/Providers/Twitter.php
+++ /dev/null
@@ -1,264 +0,0 @@
-api->api_base_url = "https://api.twitter.com/1.1/";
- $this->api->authorize_url = "https://api.twitter.com/oauth/authenticate";
- $this->api->request_token_url = "https://api.twitter.com/oauth/request_token";
- $this->api->access_token_url = "https://api.twitter.com/oauth/access_token";
-
- if (isset($this->config['api_version']) && $this->config['api_version']) {
- $this->api->api_base_url = "https://api.twitter.com/{$this->config['api_version']}/";
- }
-
- if (isset($this->config['authorize']) && $this->config['authorize']) {
- $this->api->authorize_url = "https://api.twitter.com/oauth/authorize";
- }
-
- $this->api->curl_auth_header = false;
- }
-
- /**
- * {@inheritdoc}
- */
- function loginBegin() {
- // Initiate the Reverse Auth flow; cf. https://dev.twitter.com/docs/ios/using-reverse-auth
- if (isset($_REQUEST['reverse_auth']) && ($_REQUEST['reverse_auth'] == 'yes')) {
- $stage1 = $this->api->signedRequest($this->api->request_token_url, 'POST', array('x_auth_mode' => 'reverse_auth'));
- if ($this->api->http_code != 200) {
- throw new Exception("Authentication failed! {$this->providerId} returned an error. " . $this->errorMessageByStatus($this->api->http_code), 5);
- }
- $responseObj = array('x_reverse_auth_parameters' => $stage1, 'x_reverse_auth_target' => $this->config["keys"]["key"]);
- $response = json_encode($responseObj);
- header("Content-Type: application/json", true, 200);
- echo $response;
- die();
- }
- $tokens = $this->api->requestToken($this->endpoint);
-
- // request tokens as received from provider
- $this->request_tokens_raw = $tokens;
-
- // check the last HTTP status code returned
- if ($this->api->http_code != 200) {
- throw new Exception("Authentication failed! {$this->providerId} returned an error. " . $this->errorMessageByStatus($this->api->http_code), 5);
- }
-
- if (!isset($tokens["oauth_token"])) {
- throw new Exception("Authentication failed! {$this->providerId} returned an invalid oauth token.", 5);
- }
-
- $this->token("request_token", $tokens["oauth_token"]);
- $this->token("request_token_secret", $tokens["oauth_token_secret"]);
-
- // redirect the user to the provider authentication url with force_login
- if (( isset($this->config['force_login']) && $this->config['force_login'] ) || ( isset($this->config['force']) && $this->config['force'] === true )) {
- Hybrid_Auth::redirect($this->api->authorizeUrl($tokens, array('force_login' => true)));
- }
-
- // else, redirect the user to the provider authentication url
- Hybrid_Auth::redirect($this->api->authorizeUrl($tokens));
- }
-
- /**
- * {@inheritdoc}
- */
- function loginFinish() {
- // in case we are completing a Reverse Auth flow; cf. https://dev.twitter.com/docs/ios/using-reverse-auth
- if (isset($_REQUEST['oauth_token_secret'])) {
- $tokens = $_REQUEST;
- $this->access_tokens_raw = $tokens;
-
- // we should have an access_token unless something has gone wrong
- if (!isset($tokens["oauth_token"])) {
- throw new Exception("Authentication failed! {$this->providerId} returned an invalid access token.", 5);
- }
-
- // Get rid of tokens we don't need
- $this->deleteToken("request_token");
- $this->deleteToken("request_token_secret");
-
- // Store access_token and secret for later use
- $this->token("access_token", $tokens['oauth_token']);
- $this->token("access_token_secret", $tokens['oauth_token_secret']);
-
- // set user as logged in to the current provider
- $this->setUserConnected();
- return;
- }
- parent::loginFinish();
- }
-
- /**
- * {@inheritdoc}
- */
- function getUserProfile() {
- $includeEmail = isset($this->config['includeEmail']) ? (bool) $this->config['includeEmail'] : false;
- $response = $this->api->get('account/verify_credentials.json'. ($includeEmail ? '?include_email=true' : ''));
-
- // check the last HTTP status code returned
- if ($this->api->http_code != 200) {
- throw new Exception("User profile request failed! {$this->providerId} returned an error. " . $this->errorMessageByStatus($this->api->http_code), 6);
- }
-
- if (!is_object($response) || !isset($response->id)) {
- throw new Exception("User profile request failed! {$this->providerId} api returned an invalid response: " . Hybrid_Logger::dumpData( $response ), 6);
- }
-
- # store the user profile.
- $this->user->profile->identifier = (property_exists($response, 'id')) ? $response->id : "";
- $this->user->profile->displayName = (property_exists($response, 'screen_name')) ? $response->screen_name : "";
- $this->user->profile->description = (property_exists($response, 'description')) ? $response->description : "";
- $this->user->profile->firstName = (property_exists($response, 'name')) ? $response->name : "";
- $this->user->profile->photoURL = (property_exists($response, 'profile_image_url')) ? (str_replace('_normal', '', $response->profile_image_url)) : "";
- $this->user->profile->profileURL = (property_exists($response, 'screen_name')) ? ("http://twitter.com/" . $response->screen_name) : "";
- $this->user->profile->webSiteURL = (property_exists($response, 'url')) ? $response->url : "";
- $this->user->profile->region = (property_exists($response, 'location')) ? $response->location : "";
- if($includeEmail) $this->user->profile->email = (property_exists($response, 'email')) ? $response->email : "";
- if($includeEmail) $this->user->profile->emailVerified = (property_exists($response, 'email')) ? $response->email : "";
-
- return $this->user->profile;
- }
-
- /**
- * {@inheritdoc}
- */
- function getUserContacts() {
- $parameters = array('cursor' => '-1');
- $response = $this->api->get('friends/ids.json', $parameters);
-
- // check the last HTTP status code returned
- if ($this->api->http_code != 200) {
- throw new Exception("User contacts request failed! {$this->providerId} returned an error. " . $this->errorMessageByStatus($this->api->http_code));
- }
-
- if (!$response || !count($response->ids)) {
- return array();
- }
-
- // 75 id per time should be okey
- $contactsids = array_chunk($response->ids, 75);
-
- $contacts = array();
-
- foreach ($contactsids as $chunk) {
- $parameters = array('user_id' => implode(",", $chunk));
- $response = $this->api->get('users/lookup.json', $parameters);
-
- // check the last HTTP status code returned
- if ($this->api->http_code != 200) {
- throw new Exception("User contacts request failed! {$this->providerId} returned an error. " . $this->errorMessageByStatus($this->api->http_code));
- }
-
- if ($response && count($response)) {
- foreach ($response as $item) {
- $uc = new Hybrid_User_Contact();
-
- $uc->identifier = (property_exists($item, 'id')) ? $item->id : "";
- $uc->displayName = (property_exists($item, 'name')) ? $item->name : "";
- $uc->profileURL = (property_exists($item, 'screen_name')) ? ("http://twitter.com/" . $item->screen_name) : "";
- $uc->photoURL = (property_exists($item, 'profile_image_url')) ? $item->profile_image_url : "";
- $uc->description = (property_exists($item, 'description')) ? $item->description : "";
-
- $contacts[] = $uc;
- }
- }
- }
-
- return $contacts;
- }
-
- /**
- * {@inheritdoc}
- */
- function setUserStatus($status) {
-
- if (is_array($status) && isset($status['message']) && isset($status['picture'])) {
- $response = $this->api->post('statuses/update_with_media.json', array('status' => $status['message'], 'media[]' => file_get_contents($status['picture'])), null, null, true);
- } else {
- $response = $this->api->post('statuses/update.json', array('status' => $status));
- }
-
- // check the last HTTP status code returned
- if ($this->api->http_code != 200) {
- throw new Exception("Update user status failed! {$this->providerId} returned an error. " . $this->errorMessageByStatus($this->api->http_code));
- }
-
- return $response;
- }
-
- /**
- * {@inheritdoc}
- */
- function getUserStatus($tweetid) {
- $info = $this->api->get('statuses/show.json?id=' . $tweetid . '&include_entities=true');
-
- // check the last HTTP status code returned
- if ($this->api->http_code != 200 || !isset($info->id)) {
- throw new Exception("Cannot retrieve user status! {$this->providerId} returned an error. " . $this->errorMessageByStatus($this->api->http_code));
- }
-
- return $info;
- }
-
- /**
- * load the user latest activity
- * - timeline : all the stream
- * - me : the user activity only
- *
- * by default return the timeline
- * {@inheritdoc}
- */
- function getUserActivity($stream) {
- if ($stream == "me") {
- $response = $this->api->get('statuses/user_timeline.json');
- } else {
- $response = $this->api->get('statuses/home_timeline.json');
- }
-
- // check the last HTTP status code returned
- if ($this->api->http_code != 200) {
- throw new Exception("User activity stream request failed! {$this->providerId} returned an error. " . $this->errorMessageByStatus($this->api->http_code));
- }
-
- if (!$response) {
- return array();
- }
-
- $activities = array();
-
- foreach ($response as $item) {
- $ua = new Hybrid_User_Activity();
-
- $ua->id = (property_exists($item, 'id')) ? $item->id : "";
- $ua->date = (property_exists($item, 'created_at')) ? strtotime($item->created_at) : "";
- $ua->text = (property_exists($item, 'text')) ? $item->text : "";
-
- $ua->user->identifier = (property_exists($item->user, 'id')) ? $item->user->id : "";
- $ua->user->displayName = (property_exists($item->user, 'name')) ? $item->user->name : "";
- $ua->user->profileURL = (property_exists($item->user, 'screen_name')) ? ("http://twitter.com/" . $item->user->screen_name) : "";
- $ua->user->photoURL = (property_exists($item->user, 'profile_image_url')) ? $item->user->profile_image_url : "";
-
- $activities[] = $ua;
- }
-
- return $activities;
- }
-
-}
diff --git a/e107_handlers/hybridauth/Hybrid/Providers/Yahoo.php b/e107_handlers/hybridauth/Hybrid/Providers/Yahoo.php
deleted file mode 100644
index 44534244a..000000000
--- a/e107_handlers/hybridauth/Hybrid/Providers/Yahoo.php
+++ /dev/null
@@ -1,269 +0,0 @@
-
- * @author Oleg Kuzava Directory access is forbidden.
- - -