Minor - Display changes

1.10.x
baelmyhu 10 years ago committed by Yannick Warnier
parent a76c0b261e
commit 3e3e40d236
  1. 11
      index.php
  2. 31
      main/auth/external_login/facebook.inc.php
  3. 5
      main/auth/external_login/facebook.init.php

@ -14,6 +14,7 @@ $cidReset = true;
require_once 'main/inc/global.inc.php'; require_once 'main/inc/global.inc.php';
require_once 'main/chat/chat_functions.lib.php'; require_once 'main/chat/chat_functions.lib.php';
require_once 'main/auth/external_login/facebook.inc.php';
// The section (for the tabs). // The section (for the tabs).
$this_section = SECTION_CAMPUS; $this_section = SECTION_CAMPUS;
@ -23,6 +24,11 @@ if (!api_is_anonymous()) {
$header_title = " "; $header_title = " ";
} }
// Facebook connexion, if activated
if (api_is_facebook_auth_activated() && !api_get_user_id()) {
facebookConnect();
}
$controller = new IndexManager($header_title); $controller = new IndexManager($header_title);
//Actions //Actions
@ -111,11 +117,6 @@ if (api_get_setting('display_categories_on_homepage') == 'true') {
$controller->tpl->assign('course_category_block', $controller->return_courses_in_categories()); $controller->tpl->assign('course_category_block', $controller->return_courses_in_categories());
} }
// Facebook connexion, if activated
if (api_is_facebook_auth_activated() && !api_get_user_id()) {
facebook_connect();
}
$controller->set_login_form(); $controller->set_login_form();
//@todo move this inside the IndexManager //@todo move this inside the IndexManager

@ -13,7 +13,6 @@
require_once dirname(__FILE__) . '/../../inc/global.inc.php'; require_once dirname(__FILE__) . '/../../inc/global.inc.php';
require_once dirname(__FILE__) . '/facebook.init.php'; require_once dirname(__FILE__) . '/facebook.init.php';
require_once dirname(__FILE__) . '/facebook-php-sdk/autoload.php'; require_once dirname(__FILE__) . '/facebook-php-sdk/autoload.php';
use Facebook\FacebookSession; use Facebook\FacebookSession;
@ -55,7 +54,7 @@ function facebookConnect()
$username = changeToValidChamiloLogin($graphObject->getProperty('email')); $username = changeToValidChamiloLogin($graphObject->getProperty('email'));
$email = $graphObject->getProperty('email'); $email = $graphObject->getProperty('email');
$locale = $graphObject->getProperty('locale'); $locale = $graphObject->getProperty('locale');
$language = getLanguageForFacebook($locale); $language = facebookPluginGetLanguage($locale);
if (!$language) { if (!$language) {
$language='en_US'; $language='en_US';
} }
@ -70,16 +69,16 @@ function facebookConnect()
'language' => $language, 'language' => $language,
'password' => DEFAULT_PASSWORD, 'password' => DEFAULT_PASSWORD,
'auth_source' => 'facebook', 'auth_source' => 'facebook',
//'courses' => $user_info['courses'], // 'courses' => $user_info['courses'],
//'profile_link' => $user_info['profile_link'], // 'profile_link' => $user_info['profile_link'],
//'worldwide_bu' => $user_info['worlwide_bu'], // 'worldwide_bu' => $user_info['worlwide_bu'],
//'manager' => $user_info['manager'], // 'manager' => $user_info['manager'],
'extra' => array() 'extra' => array()
); );
$chamiloUinfo = api_get_user_info_from_email($email); $chamiloUinfo = api_get_user_info_from_email($email);
if ($chamiloUinfo === false) { if ($chamiloUinfo === false) {
//we have to create the user // we have to create the user
$chamilo_uid = external_add_user($u); $chamilo_uid = external_add_user($u);
if ($chamilo_uid !== false) { if ($chamilo_uid !== false) {
$_user['user_id'] = $chamilo_uid; $_user['user_id'] = $chamilo_uid;
@ -90,7 +89,8 @@ function facebookConnect()
} else { } else {
return false; return false;
} }
} else {//User already exists, update info and login } else {
// User already exists, update info and login
$chamilo_uid = $chamiloUinfo['user_id']; $chamilo_uid = $chamiloUinfo['user_id'];
$u['user_id'] = $chamilo_uid; $u['user_id'] = $chamilo_uid;
external_update_user($u); external_update_user($u);
@ -110,7 +110,7 @@ function facebookConnect()
/** /**
* Get facebook login url for the platform * Get facebook login url for the platform
* @return mixed * @return string
*/ */
function facebookGetLoginUrl() function facebookGetLoginUrl()
{ {
@ -123,8 +123,8 @@ function facebookGetLoginUrl()
} }
/** /**
* Return a valid Chamilo login
* Chamilo login only use characters lettres, des chiffres et les signes _ . - * Chamilo login only use characters lettres, des chiffres et les signes _ . -
* return a string containing valid chamilo login characters
* @param $in_txt * @param $in_txt
* @return mixed * @return mixed
*/ */
@ -138,13 +138,18 @@ function changeToValidChamiloLogin($in_txt)
* @param string $language * @param string $language
* @return bool * @return bool
*/ */
function getLanguageForFacebook($language = 'en_US') function facebookPluginGetLanguage($language = 'en_US')
{ {
$language = substr($language, 0, 2); $language = substr($language, 0, 2);
$sqlResult = Database::query("SELECT english_name FROM ".Database::get_main_table(TABLE_MAIN_LANGUAGE)." WHERE available = 1 AND isocode = '$language'"); $sqlResult = Database::query(
"SELECT english_name FROM ".
Database::get_main_table(TABLE_MAIN_LANGUAGE).
" WHERE available = 1 AND isocode = '$language'"
);
if (Database::num_rows($sqlResult)) { if (Database::num_rows($sqlResult)) {
$result = Database::fetch_array($sqlResult); $result = Database::fetch_array($sqlResult);
return $result['english_name']; return $result['english_name'];
} }
return false; return false;
} }

@ -15,11 +15,10 @@
* Facebook application setting * Facebook application setting
* */ * */
//Loads the portal facebook settings //Loads the portal facebook settings
/** /**
* Facebook application setting
* Loads the portal facebook settings
* See facebook section of the auth.conf.php file * See facebook section of the auth.conf.php file
*/ */

Loading…
Cancel
Save