Przeglądaj źródła

Merge branch 'master' of github.com:chamilo/chamilo-lms

Angel Fernando Quiroz Campos 8 lat temu
rodzic
commit
3447e259fb
66 zmienionych plików z 612 dodań i 933 usunięć
  1. 0 0
      LICENSE.txt
  2. 5 4
      README.md
  3. 1 1
      app/AppKernel.php
  4. 3 0
      app/Migrations/Schema/V200/Version200.php
  5. 1 1
      app/Resources/docs/installation.md
  6. 4 2
      app/Resources/docs/upgrade.md
  7. 0 3
      app/Resources/public/css/base.css
  8. 41 7
      app/config/config.yml
  9. 1 1
      app/config/fos/fos_user.yml
  10. 21 8
      app/config/routing.yml
  11. 20 3
      app/config/security.yml
  12. 3 2
      app/config/sonata/sonata_page.yml
  13. 1 1
      composer.json
  14. 1 1
      main/admin/user_edit.php
  15. 0 217
      main/auth/external_login/facebook.inc.php
  16. 0 26
      main/auth/external_login/facebook.init.php
  17. 0 225
      main/auth/external_login/functions.inc.php
  18. 4 4
      main/document/record_audio.php
  19. 1 1
      main/document/showinframes.php
  20. 116 132
      main/inc/lib/api.lib.php
  21. BIN
      main/inc/lib/flv_player/player_flv_mini.swf
  22. 0 6
      main/inc/lib/mp3player/index.html
  23. 0 25
      main/inc/lib/mp3player/is_autostart.as.php
  24. BIN
      main/inc/lib/mp3player/player_mp3.fla
  25. BIN
      main/inc/lib/mp3player/player_mp3.swf
  26. 0 1
      main/inc/lib/mp3player/readme.txt
  27. 2 24
      main/inc/lib/template.lib.php
  28. 2 2
      main/inc/lib/usermanager.lib.php
  29. 0 6
      main/inc/lib/wami-recorder/index.html
  30. 1 1
      main/lp/learnpath.class.php
  31. 4 4
      main/lp/lp_add_audio.php
  32. 8 0
      src/Chamilo/CoreBundle/Framework/Container.php
  33. 33 18
      src/Chamilo/CoreBundle/Menu/SimpleMenuBuilder.php
  34. 4 64
      src/Chamilo/CoreBundle/Resources/config/routing.yml
  35. 3 3
      src/Chamilo/CoreBundle/Resources/views/default/admin/settings_index.html.twig
  36. 1 1
      src/Chamilo/CoreBundle/Resources/views/default/create_course/add_course.html.twig
  37. 1 1
      src/Chamilo/CoreBundle/Resources/views/default/layout/hot_courses.html.twig
  38. 1 1
      src/Chamilo/CoreBundle/Resources/views/default/layout/login_form.html.twig
  39. 1 1
      src/Chamilo/CoreBundle/Resources/views/default/layout/menu.html.twig
  40. 1 1
      src/Chamilo/CoreBundle/Resources/views/default/sequence_resource/session_requirements.html.twig
  41. 2 2
      src/Chamilo/CoreBundle/Resources/views/default/session/about.html.twig
  42. 9 3
      src/Chamilo/CoreBundle/Security/Authorization/Voter/CourseVoter.php
  43. 57 0
      src/Chamilo/CourseBundle/Resources/config/routing.yml
  44. 0 20
      src/Chamilo/PageBundle/Resources/views/Security/login.html.twig
  45. 3 3
      src/Chamilo/ThemeBundle/Resources/views/Layout/topbar.html.twig
  46. 4 4
      src/Chamilo/ThemeBundle/Resources/views/Navbar/user.html.twig
  47. 0 62
      src/Chamilo/ThemeBundle/Resources/views/Security/login.html.twig
  48. 11 4
      src/Chamilo/ThemeBundle/Resources/views/Sidebar/login.html.twig
  49. 13 0
      src/Chamilo/ThemeBundle/Resources/views/Sidebar/menu_knp.html.twig
  50. 1 0
      src/Chamilo/UserBundle/DependencyInjection/ChamiloUserExtension.php
  51. 1 1
      src/Chamilo/UserBundle/Entity/Manager/UserManager.php
  52. 132 3
      src/Chamilo/UserBundle/Entity/User.php
  53. 5 0
      src/Chamilo/UserBundle/Resources/config/services.yml
  54. 20 33
      src/Chamilo/UserBundle/Resources/views/Security/login.html.twig
  55. 69 0
      src/Chamilo/UserBundle/Security/FOSUBUserProvider.php
  56. 0 0
      web/js/swfobject/index.html
  57. 0 0
      web/js/swfobject/swfobject.js
  58. 0 0
      web/js/swfobject/swfobject_source/index.html
  59. 0 0
      web/js/swfobject/swfobject_source/swfobject_1_5.zip
  60. 0 0
      web/js/swfobject/swfobject_source/swfobject_2_2.zip
  61. 0 0
      web/js/swfobject/swfobject_source/swfobject_source.js
  62. 0 0
      web/js/wami-recorder/Wami.swf
  63. 0 0
      web/js/wami-recorder/buttons.png
  64. 0 0
      web/js/wami-recorder/gui.js
  65. 0 0
      web/js/wami-recorder/index.html
  66. 0 0
      web/js/wami-recorder/recorder.js

+ 0 - 0
license.txt → LICENSE.txt


+ 5 - 4
README.md

@@ -10,11 +10,11 @@
 ## Installation
 
 The installation instructions are located in the documentation here: 
-[Installation](app/Resources/installation.md)
+[Installation](app/Resources/docs/installation.md)
 
 ## Upgrade
 The upgrade instructions are located in the documentation here: 
- [Upgrade](https://github.com/chamilo/chamilo-lms/blob/master/app/Resources/upgrade.md)
+ [Upgrade](app/Resources/docs/upgrade.md)
 
 ## Changes from 1.x 
 
@@ -35,13 +35,14 @@ The upgrade instructions are located in the documentation here:
 * Language list is now loaded using the iso code not the english name.
   Example: "es" instead of "spanish" 
 * PHPMailer replaced with Swift Mailer
- 
-  
+   
 ## Todo
 * Template system to work with current Symfony2 structure
 * Auth (CAS, Shibboleth, Oath2) 
 * URL course changes "cidReq" to "c", "session_id" to "s"
 * Fix plugins that use api_get_setting directly in the code
+* Fix plugins render using tpl or PHP files
+* CAPTCHA
 
 
 ## Contributing

+ 1 - 1
app/AppKernel.php

@@ -71,7 +71,7 @@ class AppKernel extends Kernel
             //new Sonata\DoctrinePHPCRAdminBundle\SonataDoctrinePHPCRAdminBundle(),
 
             // Oauth
-            //new HWI\Bundle\OAuthBundle\HWIOAuthBundle(),
+            new HWI\Bundle\OAuthBundle\HWIOAuthBundle(),
 
             //new Gregwar\CaptchaBundle\GregwarCaptchaBundle(),
             new Mopa\Bundle\BootstrapBundle\MopaBootstrapBundle(),

+ 3 - 0
app/Migrations/Schema/V200/Version200.php

@@ -158,6 +158,9 @@ class Version200 extends AbstractMigrationChamilo
         $sql = "UPDATE sys_announcement SET lang = (SELECT isocode FROM language WHERE english_name = lang);";
         $this->addSql($sql);
         $this->addSql('ALTER TABLE c_tool_intro CHANGE id tool VARCHAR(255) NOT NULL');
+
+        $this->addSql('ALTER TABLE user ADD facebook_id VARCHAR(255) DEFAULT NULL, ADD facebook_access_token VARCHAR(255) DEFAULT NULL, ADD google_id VARCHAR(255) DEFAULT NULL, ADD google_access_token VARCHAR(255) DEFAULT NULL, ADD github_id VARCHAR(255) DEFAULT NULL, ADD github_access_token VARCHAR(255) DEFAULT NULL;');
+
     }
 
     /**

+ 1 - 1
app/Resources/docs/installation.md

@@ -1,4 +1,4 @@
-## Installation
+## Chamilo 2.x Installation
 
 This installation guide is for development environments only.
 

+ 4 - 2
app/Resources/docs/upgrade.md

@@ -1,4 +1,6 @@
-## Upgrade from 1.11.x
+## Upgrade to Chamilo v2 
+
+## From 1.11.x
 
 2.x is a major version. It contains a series of new features, that
 also mean a series of new database changes in regards with versions 1.x. As 
@@ -26,7 +28,7 @@ Typically:
     DELETE FROM access_url_rel_course WHERE access_url_id NOT IN (SELECT id FROM access_url);
 </pre>
 
-### Upgrading from non-Git Chamilo 1.11 ###
+### From non-Git Chamilo 1.11 ###
 
 In the *very unlikely* case of upgrading a "normal" Chamilo 1.x installation (done with the downloadable zip package) to a Git-based installation, 
 make sure you delete the contents of a few folders first. 

+ 0 - 3
app/Resources/public/css/base.css

@@ -111,9 +111,6 @@ a.thumbnail:hover{
   margin-top: 10px;
   margin-bottom: 10px;
 }
-#formLogin label{
-    display: none;
-}
 #login_block #formLogin .form-group{
   display: none;
 }

+ 41 - 7
app/config/config.yml

@@ -281,13 +281,47 @@ fm_elfinder:
 knp_menu:
     twig: true
 #
-#hwi_oauth:
-#    firewall_names: [main]
-#    resource_owners:
-#        any_name:
-#            type:                github
-#            client_id:           <client_id>
-#            client_secret:       <client_secret>
+hwi_oauth:
+    connect:
+        account_connector: chamilo_user_provider
+    firewall_names: [secured_area]
+    resource_owners:
+        github:
+            type:                github
+            client_id:           <client_id>
+            client_secret:       <client_secret>
+        facebook:
+            type:                facebook
+            client_id:           <client_id>
+            client_secret:       <client_secret>
+        google:
+            type:                google
+            client_id:           <client_id>
+            client_secret:       <client_secret>
+            scope:               "email profile"
+        my_custom_oauth2:
+            type:                oauth2
+            client_id:           <client_id>
+            client_secret:       <client_secret>
+            access_token_url:    https://path.to/oauth/v2/token
+            authorization_url:   https://path.to/oauth/v2/authorize
+            infos_url:           https://path.to/api/user
+            scope:               "user_details"
+            user_response_class: HWI\Bundle\OAuthBundle\OAuth\Response\PathUserResponse
+            paths:
+                identifier: id
+                nickname:   username
+                realname:   fullname
+    fosub:
+        # try 30 times to check if a username is available (foo, foo1, foo2 etc)
+        username_iterations: 30
+
+        # mapping between resource owners (see below) and properties
+        properties:
+            github: githubId
+            google: googleId
+            facebook: facebookId
+            my_custom_provider: customId
 
 #gregwar_captcha:
 

+ 1 - 1
app/config/fos/fos_user.yml

@@ -1,6 +1,6 @@
 fos_user:
     db_driver: orm # can be orm or odm
-    firewall_name:  main
+    firewall_name:  secured_area
 
     # if you change the class configuration, please also alter the sonata_user.yml file
     user_class:     Chamilo\UserBundle\Entity\User

+ 21 - 8
app/config/routing.yml

@@ -1,4 +1,3 @@
-
 home:
     path: ../../index.php
 
@@ -33,13 +32,27 @@ admin:
     resource: '@SonataAdminBundle/Resources/config/routing/sonata_admin.xml'
     prefix: /{_locale}/administration
 
-#hwi_oauth_redirect:
-#    resource: "@HWIOAuthBundle/Resources/config/routing/redirect.xml"
-#    prefix:   /connect
-#
-#hwi_oauth_login:
-#    resource: "@HWIOAuthBundle/Resources/config/routing/login.xml"
-#    prefix:   /login
+# HWIOAuthBundle routes
+hwi_oauth_redirect:
+    resource: "@HWIOAuthBundle/Resources/config/routing/redirect.xml"
+    prefix:   /connect
+
+hwi_oauth_connect:
+    resource: "@HWIOAuthBundle/Resources/config/routing/connect.xml"
+    prefix:   /connect
+
+hwi_oauth_login:
+    resource: "@HWIOAuthBundle/Resources/config/routing/login.xml"
+    prefix:   /connect
+
+facebook_login:
+    path: /connect/check-facebook
+
+google_login:
+    path: /connect/check-google
+
+github_login:
+    path: /connect/check-github
 
 logout:
     path: /logout

+ 20 - 3
app/config/security.yml

@@ -22,7 +22,6 @@ security:
             - ROLE_CURRENT_COURSE_TEACHER
             - SONATA
         ROLE_SUPER_ADMIN: [ROLE_SONATA_ADMIN, ROLE_ADMIN, ROLE_ALLOWED_TO_SWITCH]
-
         ROLE_GLOBAL_ADMIN: [ROLE_ADMIN, ROLE_ALLOWED_TO_SWITCH]
         ROLE_RRHH: [ROLE_TEACHER]
         ROLE_TEACHER: [ROLE_STUDENT]
@@ -55,7 +54,7 @@ security:
             pattern: ^/(_(profiler|wdt)|css|images|js)/
             security: false
 
-        main:
+        secured_area:
             pattern: .*
             context: user
             form_login:
@@ -66,12 +65,30 @@ security:
                 failure_path:   null
                 default_target_path: /admin
                 success_handler: chamilo_core.listener.login_success_handler
+                remember_me: true
+            remember_me:
+                secret:   '%secret%'
+                lifetime: 604800 # 1 week in seconds
+                path:     /
             logout:
                 path:   /logout
                 target: /
                 success_handler: chamilo_core.listener.logout_success_handler
                 invalidate_session: false
 #                handlers: ['sonata.page.cms_manager_selector']
-            anonymous: ~
+            anonymous: true
+            oauth:
+                resource_owners:
+                    facebook:        "/login/check-facebook"
+                    google:          "/login/check-google"
+                    github:          "/login/check-github"
+                login_path:        /login
+                failure_path:      /connect
+                use_forward:       false
+
+
+                oauth_user_provider:
+                    service: chamilo_user_provider
+
             switch_user: false
 

+ 3 - 2
app/config/sonata/sonata_page.yml

@@ -22,13 +22,14 @@ sonata_page:
     ignore_uri_patterns:
         - ^/administration(.*) # sonata admin
         - ^/admin(.*) # chamilo admin
-        - ^/admin/settings/(.*)
-        - ^/admin/settings
+        - ^/admin/(.*) # chamilo admin
         - ^/main(.*)
         - /(.*)/(.*)administration(.*)/
         - ^/api/(.*)
         - ^install
         - ^/install/(.*)
+        - ^/login/(.*)
+        - ^/connect/(.*)
         - ^/packages/(.*)
         - ^/package/(.*)
         - install.php

+ 1 - 1
composer.json

@@ -162,7 +162,7 @@
         "jeroendesloovere/vcard": "^1.2",
         "stof/doctrine-extensions-bundle": "~1.0",
         "alchemy/zippy": "^0.2.1",
-        "hwi/oauth-bundle": "^0.4.0",
+        "hwi/oauth-bundle": "~0.5",
         "genemu/form-bundle": "2.2.*",
         "oneup/flysystem-bundle": "1.7.*",
         "intervention/image": "^2.3",

+ 1 - 1
main/admin/user_edit.php

@@ -426,7 +426,7 @@ if ($form->validate()) {
             null,
             $send_mail,
             $reset_password,
-			$user['address']
+			isset($user['address']) ? $user['address'] : ''
         );
 
         if (isset($user['student_boss'])) {

+ 0 - 217
main/auth/external_login/facebook.inc.php

@@ -1,217 +0,0 @@
-<?php
-/**
- * Licence: GPL
- * Please contact CBlue regarding any licences issues.
- * Author: noel@cblue.be
- *  Copyright: CBlue SPRL, 20XX
- *
- * External login module : FACEBOOK
- *
- * This files provides the facebookConnect()  and facebook_get_url functions
- * Please edit the facebook.conf.php file to adapt it to your fb application parameter
- */
-
-require_once dirname(__FILE__) . '/../../inc/global.inc.php';
-require_once dirname(__FILE__) . '/facebook.init.php';
-
-require_once dirname(__FILE__) . '/functions.inc.php';
-
-/**
- * This function connect to facebook and retrieves the user info
- * If user does not exist in chamilo, it creates it and logs in
- * If user already exists, it updates his info
- */
-function facebookConnect()
-{
-    $fb = new \Facebook\Facebook([
-        'app_id' => $GLOBALS['facebook_config']['appId'],
-        'app_secret' => $GLOBALS['facebook_config']['secret'],
-        'default_graph_version' => 'v2.2'
-    ]);
-
-    $helper = $fb->getRedirectLoginHelper();
-
-    try {
-        $accessToken = $helper->getAccessToken();
-    } catch(Facebook\Exceptions\FacebookResponseException $e) {
-        Display::addFlash(
-            Display::return_message('Facebook Graph returned an error: ' . $e->getMessage(), 'error')
-        );
-
-        header('Location: ' . api_get_path(WEB_PATH));
-        exit;
-    } catch(Facebook\Exceptions\FacebookSDKException $e) {
-        Display::addFlash(
-            Display::return_message('Facebook SDK returned an error: ' . $e->getMessage(), 'error')
-        );
-
-        header('Location: ' . api_get_path(WEB_PATH));
-        exit;
-    }
-
-    if (!isset($accessToken)) {
-        if (!$helper->getError()) {
-            return;
-        }
-
-        if (isset($_GET['loginFailed'])) {
-            return;
-        }
-
-        $error = implode('<br>', [
-            'Error: ' . $helper->getError(),
-            'Error Code: ' . $helper->getErrorCode(),
-            'Error Reason: ' . $helper->getErrorReason(),
-            'Error Description: ' . $helper->getErrorDescription()
-        ]);
-
-        Display::addFlash(
-            Display::return_message($error, 'error', false)
-        );
-
-        header('Location: ' . api_get_path(WEB_PATH));
-        exit;
-    }
-
-    $oAuth2Client = $fb->getOAuth2Client();
-    $tokenMetadata = $oAuth2Client->debugToken($accessToken);
-    $tokenMetadata->validateAppId($GLOBALS['facebook_config']['appId']);
-    $tokenMetadata->validateExpiration();
-
-    if (!$accessToken->isLongLived()) {
-        try {
-            $accessToken = $oAuth2Client->getLongLivedAccessToken($accessToken);
-        } catch (Facebook\Exceptions\FacebookSDKException $e) {
-            Display::addFlash(
-                Display::return_message('Error getting long-lived access token: ' . $e->getMessage(), 'error')
-            );
-
-            header('Location: ' . api_get_path(WEB_PATH));
-            exit;
-        }
-    }
-
-    try {
-        $response = $fb->get('/me?fields=id,first_name,last_name,locale,email', $accessToken->getValue());
-    } catch(Facebook\Exceptions\FacebookResponseException $e) {
-        Display::addFlash(
-            Display::return_message('Graph returned an error: ' . $e->getMessage(), 'error')
-        );
-
-        header('Location: ' . api_get_path(WEB_PATH));
-        exit;
-    } catch(Facebook\Exceptions\FacebookSDKException $e) {
-        Display::addFlash(
-            Display::return_message('Facebook SDK returned an error: ' . $e->getMessage(), 'error')
-        );
-
-        header('Location: ' . api_get_path(WEB_PATH));
-        exit;
-    }
-
-    $user = $response->getGraphUser();
-    $language = facebookPluginGetLanguage($user['locale']);
-
-    if (!$language) {
-        $language = 'en_US';
-    }
-
-    $u = [
-        'firstname' => $user->getFirstName(),
-        'lastname' => $user->getLastName(),
-        'status' => STUDENT,
-        'email' => $user->getEmail(),
-        'username' => changeToValidChamiloLogin($user->getEmail()),
-        'language' => $language,
-        'password' => 'facebook',
-        'auth_source' => 'facebook',
-        'extra' => array()
-    ];
-    $chamiloUinfo = api_get_user_info_from_email($user->getEmail());
-
-    $_user['uidReset'] = true;
-    $_user['language'] = $language;
-
-    if ($chamiloUinfo === false) {
-        // We have to create the user
-        $chamilo_uid = external_add_user($u);
-
-        if ($chamilo_uid === false) {
-            Display::addFlash(
-                Display::return_message(get_lang('UserNotRegistered'), 'error')
-            );
-
-            header('Location: ' . api_get_path(WEB_PATH));
-            exit;
-        }
-
-        $_user['user_id'] = $chamilo_uid;
-        $_SESSION['_user'] = $_user;
-
-        header('Location: ' . api_get_path(WEB_PATH));
-        exit();
-    }
-
-    // User already exists, update info and login
-    $chamilo_uid = $chamiloUinfo['user_id'];
-    $u['user_id'] = $chamilo_uid;
-    external_update_user($u);
-    $_user['user_id'] = $chamilo_uid;
-    $_SESSION['_user'] = $_user;
-
-    header('Location: ' . api_get_path(WEB_PATH));
-    exit();
-}
-
-/**
- * Get facebook login url for the platform
- * @return string
- */
-function facebookGetLoginUrl()
-{
-    $fb = new \Facebook\Facebook([
-        'app_id' => $GLOBALS['facebook_config']['appId'],
-        'app_secret' => $GLOBALS['facebook_config']['secret'],
-        'default_graph_version' => 'v2.2'
-    ]);
-
-    $helper = $fb->getRedirectLoginHelper();
-    $loginUrl = $helper->getLoginUrl(api_get_path(WEB_PATH) . '?action=fbconnect', [
-        'email'
-    ]);
-
-    return $loginUrl;
-}
-
-/**
- * Return a valid Chamilo login
- * Chamilo login only use characters lettres, des chiffres et les signes _ . -
- * @param $in_txt
- * @return mixed
- */
-function changeToValidChamiloLogin($in_txt)
-{
-    return preg_replace("/[^a-zA-Z1-9_\-.]/", "_", $in_txt);
-}
-
-/**
- * Get user language
- * @param string $language
- * @return bool
- */
-function facebookPluginGetLanguage($language = 'en_US')
-{
-    $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'"
-    );
-    if (Database::num_rows($sqlResult)) {
-        $result = Database::fetch_array($sqlResult);
-        return $result['english_name'];
-    }
-
-    return false;
-}
-

+ 0 - 26
main/auth/external_login/facebook.init.php

@@ -1,26 +0,0 @@
-<?php
-
-/**
- * Licence: GPL
- * Please contact CBlue regarding any licences issues.
- * Author: noel@cblue.be
- *  Copyright: CBlue SPRL, 20XX
- *
- * External login module : FACEBOOK
- *
- * Configuration file 
- * Please edit this file to match with your FACEBOOK settings
- * */
-/**
- * Facebook application setting
- * */
-
-//Loads the portal facebook settings
-/**
- * Facebook application setting
- * Loads the portal facebook settings
- * See facebook section of the auth.conf.php file
- */
-
-require dirname(__FILE__) . '/../../../app/config/auth.conf.php';
-

+ 0 - 225
main/auth/external_login/functions.inc.php

@@ -1,225 +0,0 @@
-<?php
-
-//define('USERINFO_TABLE', 'danone_userinfo');
-//define('DEFAULT_PASSWORD', 'danonelearning');
-//TODO : Please implements this function for this module to work.
-/**
- * Gets user info from external source
- * @param string login
- * @param string password
- * @return user array with at least the following fields:
- *       firstname
- *       lastname
- *       status
- *       email
- *       login
- *       password
- *   or false if no data
- * */
-function external_get_user_info($login, $password)
-{
-    //Those are the mandatory fields for user creation.
-    //See external_add_user function for all the fields you can have.
-    $table = USERINFO_TABLE;
-    $sql = "SELECT * from $table where username='" . Database::escape_string($login) . "'";
-    $result = Database::query($sql);
-
-    if (Database::num_rows($result) == 0) { //false password
-        return false;
-    }
-    $user_info = Database::fetch_assoc($result);
-    // User status
-    $admin = false;
-    switch ($user_info['status']) {
-        case 'admin':
-            $status = COURSEMANAGER;
-            $admin = true;
-            break;
-        case 'teacher':
-            $status = COURSEMANAGER;
-            break;
-        case 'user':
-            $status = STUDENT;
-            break;
-        default:
-            $status = STUDENT;
-    }
-
-    // Language
-    switch ($user_info['language']) {
-        case 'FR':
-            $language = 'french';
-            break;
-        case 'EN':
-            $language = 'english';
-            break;
-        default:
-            $language = 'english';
-            break;
-    }
-    //Can Send Message ?
-    $can_send_message = ($user_info['can_send_message'] == 1) ? 'yes' : 'no';
-
-    $u = array(
-        'firstname' => $user_info['firstname'],
-        'lastname' => $user_info['lastname'],
-        'status' => $status,
-        'admin' => $admin,
-        'email' => $user_info['email'],
-        'username' => $user_info['username'],
-        'language' => $language,
-        'password' => DEFAULT_PASSWORD,
-        'courses' => $user_info['courses'],
-        'profile_link' => $user_info['profile_link'],
-        'worldwide_bu' => $user_info['worlwide_bu'],
-        'manager' => $user_info['manager'],
-        'extra' => array(
-            'position_title' => $user_info['position_title'],
-            'country' => $user_info['country'],
-            'job_family' => $user_info['job_family'],
-            'country_bu' => $user_info['country_bu'],
-            'worldwide_bu' => $user_info['worldwide_bu'],
-            'profile_link' => $user_info['profile_link'],
-            'can_send_message' => $can_send_message,
-            'update_type' => 'external_logininfo')
-    );
-
-    return $u; //Please return false if user does not exist
-    //return false;
-}
-
-/**
- * Return an array with all user info
- * @param associative array with at least thes fields setted :
-  firstname, lastname, status, email, login, password
- * @return mixed   new user id - if the new user creation succeeds, false otherwise
- * */
-function external_add_user($u)
-{
-    //Setting default
-    if (empty($u['password'])) {
-        $u['password'] = null;
-    }
-    if (empty($u['status'])) {
-        $u['status'] = 5;
-    }
-    if (!isset($u['official_code'])) {
-        $u['official_code'] = '';
-    }
-    if (!isset($u['language'])) {
-        $u['language'] = '';
-    }
-    if (!isset($u['phone'])) {
-        $u['phone'] = '';
-    }
-    if (!isset($u['picture_uri'])) {
-        $u['picture_uri'] = '';
-    }
-    if (!isset($u['auth_source'])) {
-        $u['auth_source'] = PLATFORM_AUTH_SOURCE;
-    }
-    if (!isset($u['expiration_date'])) {
-        $u['expiration_date'] = '';
-    }
-    if (!isset($u['active'])) {
-        $u['active'] = 1;
-    }
-    if (!isset($u['hr_dept_id'])) {
-        $u['hr_dept_id'] = 0;
-    } //id of responsible HR
-    if (!isset($u['extra'])) {
-        $u['extra'] = null;
-    }
-    if (!isset($u['encrypt_method'])) {
-        $u['encrypt_method'] = '';
-    }
-
-    $chamilo_uid = UserManager::create_user(
-        $u['firstname'],
-        $u['lastname'],
-        $u['status'],
-        $u['email'],
-        $u['username'],
-        $u['password'],
-        $u['official_code'],
-        $u['language'],
-        $u['phone'],
-        $u['picture_uri'],
-        $u['auth_source'],
-        $u['expiration_date'],
-        $u['active'],
-        $u['hr_dept_id'],
-        $u['extra'],
-        $u['encrypt_method']
-    );
-    return $chamilo_uid;
-}
-
-/**
- * Update the user in chamilo database. It upgrade only info that is present in the
- * new_user array
- *
- * @param $new_user associative array with the value to upgrade
- *    WARNING user_id key is MANDATORY
- *    Possible keys are :
- *      - firstname
- *      - lastname
- *      - username
- *      - auth_source
- *      - email
- *      - status
- *      - official_code
- *      - phone
- *      - picture_uri
- *      - expiration_date
- *      - active
- *      - creator_id
- *      - hr_dept_id
- *      - extra : array of custom fields
- *      - language
- *      - courses : string of all courses code separated by '|'
- *      - admin : boolean
- * @return boolean|null
- * @author ndiechburg <noel@cblue.be>
- * */
-function external_update_user($new_user)
-{
-    $old_user = api_get_user_info($new_user['user_id']);
-    $u = array_merge($old_user, $new_user);
-    $updated = UserManager::update_user(
-        $u['user_id'],
-        $u['firstname'],
-        $u['lastname'],
-        $u['username'],
-        null,
-        $u['auth_source'],
-        $u['email'],
-        $u['status'],
-        $u['official_code'],
-        $u['phone'],
-        $u['picture_uri'],
-        $u['expiration_date'],
-        $u['active'],
-        $u['creator_id'],
-        $u['hr_dept_id'],
-        $u['extra'],
-        $u['language'],
-        ''
-    );
-    if (isset($u['courses']) && !empty($u['courses'])) {
-        $autoSubscribe = explode('|', $u['courses']);
-        foreach ($autoSubscribe as $code) {
-            if (CourseManager::course_exists($code)) {
-                CourseManager::subscribe_user($u['user_id'], $code);
-            }
-        }
-    }
-    // Is User Admin ?
-    //TODO decomments and check that user_is is not already in admin table
-    /*
-      if (isset($u['admin']) && $u['admin']){
-
-      $table = Database::get_main_table(TABLE_MAIN_ADMIN);
-      $res = Database::query("SELECT * from $table WHERE user_id = ".$u['user_id']);
-      } */
-}

+ 4 - 4
main/document/record_audio.php

@@ -119,10 +119,10 @@ if (isset($document_data['parents'])) {
 //make some vars
 $wamiuserid = api_get_user_id();
 
-$htmlHeadXtra[] = '<script src="' . api_get_path(WEB_LIBRARY_JS_PATH) . 'rtc/RecordRTC.js"></script>';
-$htmlHeadXtra[] = '<script src="' . api_get_path(WEB_LIBRARY_JS_PATH) . 'wami-recorder/recorder.js"></script>';
-$htmlHeadXtra[] = '<script src="' . api_get_path(WEB_LIBRARY_JS_PATH) . 'wami-recorder/gui.js"></script>';
-$htmlHeadXtra[] = '<script type="text/javascript" src="' . api_get_path(WEB_LIBRARY_JS_PATH) . 'swfobject/swfobject.js"></script>';
+$htmlHeadXtra[] = api_get_js('js/rtc/RecordRTC.js');
+$htmlHeadXtra[] = api_get_js('js/wami-recorder/recorder.js');
+$htmlHeadXtra[] = api_get_js('js/wami-recorder/gui.js');
+$htmlHeadXtra[] = api_get_js('js/swfobject/swfobject.js');
 
 $actions = Display::toolbarButton(
 	get_lang('BackTo') . ' ' . get_lang('DocumentsOverview'),

+ 1 - 1
main/document/showinframes.php

@@ -368,7 +368,7 @@ if ($jplayer_supported) {
 
 if ($is_freemind_available) {
     ?>
-    <script type="text/javascript" src="<?php echo api_get_path(WEB_LIBRARY_JS_PATH) ?>swfobject/swfobject.js"></script>
+    <?php echo api_get_js('js/swfobject/swfobject.js'); ?>
     <style type="text/css">
         #flashcontent {
             height: 500px;

+ 116 - 132
main/inc/lib/api.lib.php

@@ -1285,74 +1285,55 @@ function api_get_user_courses($userid, $fetch_session = true)
  *
  * @return array Standard user array
  */
-function _api_format_user($user, $add_password = false)
-{
+function _api_format_user(
+    User $user,
+    $checkIfUserOnline = false,
+    $showPassword = false,
+    $loadExtraData = false,
+    $loadOnlyVisibleExtraData = false
+) {
     $result = array();
 
-    $firstname = null;
-    $lastname = null;
-    if (isset($user['firstname']) && isset($user['lastname'])) {
-        $firstname = $user['firstname'];
-        $lastname = $user['lastname'];
-    } elseif (isset($user['firstName']) && isset($user['lastName'])) {
-        $firstname = isset($user['firstName']) ? $user['firstName'] : null;
-        $lastname = isset($user['lastName']) ? $user['lastName'] : null;
+    $result['username'] = $user->getUsername();
+    $result['firstname'] = $user->getFirstname();
+    $result['lastname'] = $user->getLastname();
+    $result['firstName'] = $user->getFirstname();
+    $result['lastName'] = $user->getLastname();
+    $result['complete_name'] = api_get_person_name($result['firstname'], $result['lastname']);
+    $result['complete_name_with_username'] = $result['complete_name'];
+    if (!empty($result['username'])) {
+        $result['complete_name_with_username'] = $result['complete_name'].' ('.$user->getUsername().')';
     }
 
-    $result['complete_name'] = api_get_person_name($firstname, $lastname);
 
-    $result['complete_name_with_username'] = $result['complete_name'];
+    $result['phone'] = $user->getPhone();
+    $result['address'] = $user->getAddress();
+    $result['official_code'] = $user->getOfficialCode();
+    $result['status'] = $user->getStatus();
+    $result['active'] = $user->getActive();
+    $result['auth_source'] = $user->getAuthSource();
+    $result['theme'] = $user->getTheme();
+    $result['language'] = $user->getLanguage();
+    $result['creator_id'] = $user->getCreatorId();
+    $result['registration_date'] = $user->getRegistrationDate() ? $user->getRegistrationDate()->format('Y-m-d h:i:s') : '';
+    $result['hr_dept_id'] = $user->getHrDeptId();
+    $result['expiration_date'] = $user->getExpirationDate() ? $user->getExpirationDate()->format('Y-m-d h:i:s') : '';
+    $result['picture_uri'] = $user->getPictureUri();
 
-    if (!empty($user['username'])) {
-        $result['complete_name_with_username'] = $result['complete_name'].' ('.$user['username'].')';
-    }
-
-    $result['firstname'] = $firstname;
-    $result['lastname'] = $lastname;
-
-    // Kept for historical reasons
-    $result['firstName'] = $firstname;
-    $result['lastName'] = $lastname;
-
-    $attributes = array(
-        'phone',
-        'address',
-        'picture_uri',
-        'official_code',
-        'status',
-        'active',
-        'auth_source',
-        'username',
-        'theme',
-        'language',
-        'creator_id',
-        'registration_date',
-        'hr_dept_id',
-        'expiration_date',
-        'last_login'
-    );
     if (api_get_setting('extended_profile') === 'true') {
-        $attributes[] = 'competences';
-        $attributes[] = 'diplomas';
-        $attributes[] = 'teach';
-        $attributes[] = 'openarea';
+        $result['competences'] = $user->getCompetences();
+        $result['diplomas']  = $user->getDiplomas();
+        $result['teach'] = $user->getTeach();
+        $result['openarea'] = $user->getOpenarea();
     }
 
-    foreach ($attributes as $attribute) {
-        $result[$attribute] = isset($user[$attribute]) ? $user[$attribute] : null;
-    }
+    $result['mail'] = $user->getEmail();
+    $result['email'] = $user->getEmail();
 
-    if (isset($user['email'])) {
-        $result['mail'] = isset($user['email']) ? $user['email'] : null;
-        $result['email'] = isset($user['email'])? $user['email'] : null;
-    } else {
-        $result['mail'] = isset($user['mail']) ? $user['mail'] : null;
-        $result['email'] = isset($user['mail'])? $user['mail'] : null;
-    }
-    $user_id = intval($user['user_id']);
+    $user_id = $user->getId();
     // Maintain the user_id index for backwards compatibility
     $result['user_id'] = $result['id'] = $user_id;
-    $result['last_login'] = $user['last_login'];
+    $result['last_login'] = $user->getLastLogin() ? $user->getLastLogin()->format('Y-m-d h:i:s') : '';
 
     // Getting user avatar.
     $originalFile = UserManager::getUserPicture($user_id, USER_IMAGE_SIZE_ORIGINAL, null, $result);
@@ -1365,25 +1346,40 @@ function _api_format_user($user, $add_password = false)
     $result['avatar_small'] = $smallFile;
     $result['avatar_medium'] = $mediumFile;
 
-    if (isset($user['user_is_online'])) {
-        $result['user_is_online'] = $user['user_is_online'] == true ? 1 : 0;
-    }
-    if (isset($user['user_is_online_in_chat'])) {
-        $result['user_is_online_in_chat'] = intval($user['user_is_online_in_chat']);
+    if ($showPassword) {
+        $result['password'] = $user->getPassword();
     }
 
-    if ($add_password) {
-        $result['password'] = $user['password'];
-    }
+    $result['profile_completed'] = $user->isProfileCompleted();
+    $result['profile_url'] = api_get_path(WEB_CODE_PATH).'social/profile.php?u='.$user_id;
+
+    if ($checkIfUserOnline) {
+        $use_status_in_platform = UserManager::user_is_online($user_id);
 
-    if (isset($result['profile_completed'])) {
-        $result['profile_completed'] = $user['profile_completed'];
+        $result['user_is_online'] = $use_status_in_platform;
+        $user_online_in_chat = 0;
+
+        if ($use_status_in_platform) {
+            $user_status = UserManager::get_extra_user_data_by_field(
+                $user_id,
+                'user_chat_status',
+                false,
+                true
+            );
+            if (intval($user_status['user_chat_status']) == 1) {
+                $user_online_in_chat = 1;
+            }
+        }
+        $result['user_is_online_in_chat'] = $user_online_in_chat;
     }
 
-    $result['profile_url'] = api_get_path(WEB_CODE_PATH).'social/profile.php?u='.$user_id;
+    if ($loadExtraData) {
+        $fieldValue = new ExtraFieldValue('user');
 
-    if (isset($user['extra'])) {
-        $result['extra'] = $user['extra'];
+        $result['extra'] = $fieldValue->getAllValuesForAnItem(
+            $user_id,
+            $loadOnlyVisibleExtraData
+        );
     }
 
     return $result;
@@ -1410,50 +1406,32 @@ function api_get_user_info(
     $loadOnlyVisibleExtraData = false
 ) {
     if (empty($user_id)) {
-        $userFromSession = Session::read('_user');
-        if (isset($userFromSession)) {
-            return _api_format_user($userFromSession);
+        $storage = Container::getTokenStorage();
+        $token = $storage->getToken();
+        $user = $token->getUser();
+        if ($user instanceof User) {
+            return _api_format_user(
+                $token->getUser(),
+                $checkIfUserOnline,
+                $showPassword,
+                $loadExtraData,
+                $loadOnlyVisibleExtraData
+            );
         }
 
         return false;
     }
 
-    $sql = "SELECT * FROM ".Database :: get_main_table(TABLE_MAIN_USER)."
-            WHERE id='".intval($user_id)."'";
-    $result = Database::query($sql);
-    if (Database::num_rows($result) > 0) {
-        $result_array = Database::fetch_array($result);
-        if ($checkIfUserOnline) {
-            $use_status_in_platform = UserManager::user_is_online($user_id);
-
-            $result_array['user_is_online'] = $use_status_in_platform;
-            $user_online_in_chat = 0;
-
-            if ($use_status_in_platform) {
-                $user_status = UserManager::get_extra_user_data_by_field(
-                    $user_id,
-                    'user_chat_status',
-                    false,
-                    true
-                );
-                if (intval($user_status['user_chat_status']) == 1) {
-                    $user_online_in_chat = 1;
-                }
-            }
-            $result_array['user_is_online_in_chat'] = $user_online_in_chat;
-        }
-
-        if ($loadExtraData) {
-            $fieldValue = new ExtraFieldValue('user');
-
-            $result_array['extra'] = $fieldValue->getAllValuesForAnItem(
-                $user_id,
-                $loadOnlyVisibleExtraData
-            );
-        }
-        $user = _api_format_user($result_array, $showPassword);
+    $user = UserManager::getManager()->find($user_id);
 
-        return $user;
+    if ($user) {
+        return _api_format_user(
+            $user,
+            $checkIfUserOnline,
+            $showPassword,
+            $loadExtraData,
+            $loadOnlyVisibleExtraData
+        );
     }
     return false;
 }
@@ -1496,12 +1474,10 @@ function api_get_user_info_from_username($username = '')
     }
     $username = trim($username);
 
-    $sql = "SELECT * FROM ".Database :: get_main_table(TABLE_MAIN_USER)."
-            WHERE username='".Database::escape_string($username)."'";
-    $result = Database::query($sql);
-    if (Database::num_rows($result) > 0) {
-        $result_array = Database::fetch_array($result);
-        return _api_format_user($result_array);
+
+    $user = UserManager::getManager()->findUserByUsername($username);
+    if ($user) {
+        return _api_format_user($user);
     }
     return false;
 }
@@ -1511,17 +1487,15 @@ function api_get_user_info_from_username($username = '')
  * @param string $email
  * @return array|bool
  */
-function api_get_user_info_from_email($email = '')
+function api_get_user_info_from_email($email)
 {
     if (empty($email)) {
         return false;
     }
-    $sql = "SELECT * FROM ".Database :: get_main_table(TABLE_MAIN_USER)."
-            WHERE email ='".Database::escape_string($email)."' LIMIT 1";
-    $result = Database::query($sql);
-    if (Database::num_rows($result) > 0) {
-        $result_array = Database::fetch_array($result);
-        return _api_format_user($result_array);
+
+    $user = UserManager::getManager()->findUserByEmail($email);
+    if ($user) {
+        return _api_format_user($user);
     }
 
     return false;
@@ -2021,7 +1995,7 @@ function get_status_from_code($status_code)
  * @return bool     true if set user as anonymous, false if user was already logged in or anonymous id could not be found
  */
 function api_set_anonymous() {
-    global $_user;
+    $_user = Session::read('_user');
 
     if (!empty($_user['user_id'])) {
         return false;
@@ -2360,6 +2334,7 @@ function api_get_setting($variable, $subVariable = '')
         case 'add_shibboleth_login_button_shibboleth_button_label':
         case 'add_shibboleth_login_button_shibboleth_button_comment':
         case 'add_shibboleth_login_button_shibboleth_image_url':
+        case 'formLogin_hide_unhide_label':
 
             break;
         default:
@@ -2374,6 +2349,7 @@ function api_get_setting($variable, $subVariable = '')
  */
 function api_get_plugin_setting($plugin, $variable)
 {
+    return null;
     $variableName = $plugin.'_'.$variable;
     $result = api_get_setting($variableName);
     if (isset($result[$plugin])) {
@@ -2428,8 +2404,8 @@ function api_is_platform_admin($allowSessionAdmins = false, $allowDrh = false)
     $checker = Container::getAuthorizationChecker();
     if ($checker) {
         if ($checker->isGranted('ROLE_ADMIN')) {
-        return true;
-    }
+            return true;
+        }
         if ($allowSessionAdmins) {
             if ($checker->isGranted('ROLE_SESSION_MANAGER')) {
                 return true;
@@ -3141,11 +3117,10 @@ function api_is_allowed($tool, $action, $task_id = 0)
  */
 function api_is_anonymous($user_id = null, $db_check = false)
 {
-    if (!isset($user_id)) {
-        $user_id = api_get_user_id();
-    }
-
     if ($db_check) {
+         if (!isset($user_id)) {
+            $user_id = api_get_user_id();
+        }
         $info = api_get_user_info($user_id);
 
         if ($info['status'] == 6 || $user_id == 0 || empty($info)) {
@@ -3153,6 +3128,15 @@ function api_is_anonymous($user_id = null, $db_check = false)
         }
     }
 
+    $checker = Container::getAuthorizationChecker();
+    if ($checker) {
+        if ($checker->isGranted('IS_AUTHENTICATED_FULLY')) {
+            return false;
+        }
+    }
+
+    return true;
+
     $_user = Session::read('_user');
 
     if (!isset($_user) || (isset($_user['user_id']) && $_user['user_id'] == 0)) {
@@ -6297,11 +6281,11 @@ function api_get_js_plumb()
  */
 function api_get_js_epiclock()
 {
-    $html = api_get_css('bundles/chamilocore/js/epiclock/stylesheet/jquery.epiclock.css');
-    $html .= api_get_css('bundles/chamilocore/js/epiclock/renderers/minute/epiclock.minute.css');
-    $html .= api_get_js('bundles/chamilocore/js/epiclock/javascript/jquery.dateformat.min.js');
-    $html .= api_get_js('bundles/chamilocore/js/epiclock/javascript/jquery.epiclock.min.js');
-    $html .= api_get_js('bundles/chamilocore/js/epiclock/renderers/minute/epiclock.minute.js');
+    $html = api_get_css('js/epiclock/stylesheet/jquery.epiclock.css');
+    $html .= api_get_css('js/epiclock/renderers/minute/epiclock.minute.css');
+    $html .= api_get_js('js/epiclock/javascript/jquery.dateformat.min.js');
+    $html .= api_get_js('js/epiclock/javascript/jquery.epiclock.min.js');
+    $html .= api_get_js('js/epiclock/renderers/minute/epiclock.minute.js');
 
     return $html;
 }

BIN
main/inc/lib/flv_player/player_flv_mini.swf


+ 0 - 6
main/inc/lib/mp3player/index.html

@@ -1,6 +0,0 @@
-<html>
-<head>
-</head>
-<body>
-</body>
-</html>

+ 0 - 25
main/inc/lib/mp3player/is_autostart.as.php

@@ -1,25 +0,0 @@
-<?php
-/* For licensing terms, see /license.txt */
-/**
- * This script is used by the mp3 player to see if it should start 
- * automatically or not
- * @package chamilo.include
- */
-/**
- * Code
- */
-require ('../../global.inc.php');
-switch ($_SESSION['whereami']) {
-
-
-	case 'lp/build' :
-	case 'document/create' :
-	case 'document/edit' :
-		$autostart = 'false';
-	break;
-	default :
-		$autostart = 'true';
-
-}
-echo utf8_encode('autostart='.$autostart);
-?>

BIN
main/inc/lib/mp3player/player_mp3.fla


BIN
main/inc/lib/mp3player/player_mp3.swf


+ 0 - 1
main/inc/lib/mp3player/readme.txt

@@ -1 +0,0 @@
-Where we can find some documentation : http://www.podcastgenerator.net/

+ 2 - 24
main/inc/lib/template.lib.php

@@ -610,34 +610,12 @@ class Template
             'gamification_mode' => api_get_setting('gamification_mode')
         );
 
-        $user_info = array();
-        $user_info['logged'] = 0;
-        //$this->user_is_logged_in = false;
-        if (api_user_is_login()) {
-            $user_info = api_get_user_info(api_get_user_id(), true);
-            $user_info['logged'] = 1;
-            $user_info['is_admin'] = 0;
-            /*if (api_is_platform_admin()) {
-                $user_info['is_admin'] = 1;
-            }*/
-            //$user_info['messages_count'] = MessageManager::get_new_messages();
-
-        }
+        //$user_info = api_get_user_info();
 
         return [
             '_p' => $_p,
             '_s' => $_s,
-            '_u' => $user_info,
-            'plugin_main_top' => '',
-            'plugin_content_top' => '',
-            'plugin_content_bottom' => '',
-            'plugin_main_bottom' => '',
-            'plugin_main_top' => '',
-            'breadcrumb' => '',
-            'plugin_main_top' => '',
-            'plugin_main_top' => '',
-            'plugin_main_top' => '',
-            'plugin_main_top' => '',
+     //       '_u' => $user_info,
             'template' => 'default' // @todo setup template folder in config.yml;
         ];
     }

+ 2 - 2
main/inc/lib/usermanager.lib.php

@@ -937,8 +937,8 @@ class UserManager
         }
 
         // Checking the user language
-        $languages = api_get_languages();
-        if (!in_array($language, $languages['folder'])) {
+        $languages = api_get_platform_isocodes();
+        if (!in_array($language, $languages)) {
             $language = api_get_setting('platformLanguage');
         }
 

+ 0 - 6
main/inc/lib/wami-recorder/index.html

@@ -1,6 +0,0 @@
-<html>
-<head>
-</head>
-<body>
-</body>
-</html>

+ 1 - 1
main/lp/learnpath.class.php

@@ -8347,7 +8347,7 @@ class learnpath
             $audio_player .= '<div class="lp_mediaplayer" id="container">
                               <a href="http://www.macromedia.com/go/getflashplayer">Get the Flash Player</a> to see this player.
                               </div>';
-            $audio_player .= api_get_js('mediaplayer/swfobject.js');
+            $audio_player .= api_get_js('js/mediaplayer/swfobject.js');
             $audio_player .= '<script>
                 var s1 = new SWFObject("'.api_get_path(WEB_LIBRARY_JS_PATH).'mediaplayer/player.swf","ply","250","20","9","#FFFFFF");
                 s1.addParam("allowscriptaccess","always");

+ 4 - 4
main/lp/lp_add_audio.php

@@ -108,10 +108,10 @@ $recordVoiceForm = Display::page_subheader(get_lang('RecordYourVoice'));
 
 $page .= '<div id="doc_form" class="col-md-8">';
 
-$htmlHeadXtra[] = '<script src="' . api_get_path(WEB_LIBRARY_JS_PATH) . 'rtc/RecordRTC.js"></script>';
-$htmlHeadXtra[] = '<script src="' . api_get_path(WEB_LIBRARY_JS_PATH) . 'wami-recorder/recorder.js"></script>';
-$htmlHeadXtra[] = '<script src="' . api_get_path(WEB_LIBRARY_JS_PATH) . 'wami-recorder/gui.js"></script>';
-$htmlHeadXtra[] = '<script type="text/javascript" src="' . api_get_path(WEB_LIBRARY_JS_PATH) . 'swfobject/swfobject.js"></script>';
+$htmlHeadXtra[] = api_get_js('js/rtc/RecordRTC.js');
+$htmlHeadXtra[] = api_get_js('js/wami-recorder/recorder.js');
+$htmlHeadXtra[] = api_get_js('js/wami-recorder/gui.js');
+$htmlHeadXtra[] = api_get_js('js/swfobject/swfobject.js');
 
 $tpl = new Template(null);
 $tpl->assign('unique_file_id', api_get_unique_id());

+ 8 - 0
src/Chamilo/CoreBundle/Framework/Container.php

@@ -213,6 +213,14 @@ class Container
         return self::$container->get('security.authorization_checker');
     }
 
+    /**
+     * @return object|\Symfony\Component\Security\Core\Authentication\Token\Storage\TokenStorage
+     */
+    public static function getTokenStorage()
+    {
+        return self::$container->get('security.token_storage');
+    }
+
     /**
      * @return TranslatorInterface
      */

+ 33 - 18
src/Chamilo/CoreBundle/Menu/SimpleMenuBuilder.php

@@ -21,6 +21,7 @@ class SimpleMenuBuilder implements ContainerAwareInterface
 
     /**
      * Register/reset password menu
+     * @todo
      * @param FactoryInterface $factory
      * @param array $options
      * @return \Knp\Menu\ItemInterface
@@ -29,24 +30,38 @@ class SimpleMenuBuilder implements ContainerAwareInterface
     {
         $menu = $factory->createItem('main');
         $translator = $this->container->get('translator.default');
-        $menu->addChild(
-            $translator->trans('registration.submit', array(), 'FOSUserBundle'),
-            array(
-                'route' => 'main',
-                'routeParameters' => ['name' => 'auth/inscription.php'],
-                array("attributes" => array("id" => 'nav'))
-            )
-        );
-
-        $menu->addChild(
-            $translator->trans('resetting.request.submit', array(), 'FOSUserBundle'),
-            array(
-                //'route' => 'fos_user_resetting_request',
-                'route' => 'main',
-                'routeParameters' => ['name' => 'auth/lostPassword.php'],
-                array("attributes" => array("id" => 'nav'))
-            )
-        );
+        $settingManager = $this->container->get('chamilo.settings.manager');
+
+        if ($settingManager->getSetting('allow_registration') == 'true') {
+            $menu->addChild(
+                $translator->trans(
+                    'registration.submit',
+                    array(),
+                    'FOSUserBundle'
+                ),
+                array(
+                    'route' => 'main',
+                    'routeParameters' => ['name' => 'auth/inscription.php'],
+                    array("attributes" => array("id" => 'nav'))
+                )
+            );
+        }
+
+        if ($settingManager->getSetting('allow_lostpassword') == 'true') {
+            $menu->addChild(
+                $translator->trans(
+                    'resetting.request.submit',
+                    array(),
+                    'FOSUserBundle'
+                ),
+                array(
+                    //'route' => 'fos_user_resetting_request',
+                    'route' => 'main',
+                    'routeParameters' => ['name' => 'auth/lostPassword.php'],
+                    array("attributes" => array("id" => 'nav'))
+                )
+            );
+        }
 
         return $menu;
     }

+ 4 - 64
src/Chamilo/CoreBundle/Resources/config/routing.yml

@@ -1,12 +1,12 @@
 index:
     resource: '@ChamiloCoreBundle/Controller/IndexController.php'
     type:     annotation
-#userportal:
+
 userportal:
     resource: '@ChamiloCoreBundle/Controller/UserPortalController.php'
     type:     annotation
     prefix:   /userportal
-#    resource: '@ChamiloCoreBundle/Controller/UserPortalController.php'
+
 front:
     resource: '@ChamiloCoreBundle/Controller/FrontController.php'
     type:     annotation
@@ -50,70 +50,10 @@ core_admin:
     type: annotation
     prefix: /admin
 
-course_url:
-    path: courses
-#    resource: '@ChamiloCoreBundle/Controller/Admin'
-
-core_tool:
-    resource: '@ChamiloCourseBundle/Controller'
-    type: annotation
-    prefix: /courses/{course}/
-#    type: annotation
-
-core_tool_document:
-    pattern: /courses/{course}/document/{file}
-    defaults:
-        _controller: ChamiloCoreBundle:Resource:getDocument
-    requirements:
-        file: .+ # allow "/" in {file}
-
-chamilo_course_tool_intro_create:
-    path: /courses/{course}/introduction/{tool}/create/
-    methods: [GET, POST]
-    defaults:
-        _controller: ChamiloCourseBundle:CToolIntro:create
-    requirements:
-        tool: "[a-zA-Z_]+"
-
-chamilo_course_tool_intro_update:
-    path: /courses/{course}/introduction/{tool}/update/
-    methods: [GET]
-    defaults:
-        _controller: chamilo_course.controller.c_tool_intro:updateAction
-
-chamilo_course_tool_list:
-    path: /courses/{course}/introduction
-    methods: [GET]
-    defaults:
-        _controller: chamilo_course.controller.tool:indexAction
-
-
-#chamilo_course.c_tool_intro:
-#    resource: |
-#        alias: chamilo_course.c_tool_intro
-#        path: /courses/{course}/introduction/{tool}
-#        templates: :Admin/Book
-#    type: sylius.resource_api
-
-
-# Redirects /url/ to /url
+# Redirects /url/ to /url always located at the end
 remove_trailing_slash:
     path: /{url}
     defaults: { _controller: ChamiloCoreBundle:Redirecting:removeTrailingSlash }
     requirements:
         url: .*/$
-        _method: GET
-
-
-## Course settings
-chamilo_course_settings:
-    pattern: /courses/{course}/settings/{namespace}
-    defaults:
-        _controller: ChamiloCourseBundle:Settings:update
-        template: ChamiloCourseBundle:Settings:default.html.twig
-#chamilo_course_settings:
-chamilo_course_tool_index:
-    pattern: /courses/{course}/tools
-    methods: [GET, POST, HEAD, DELETE]
-    defaults:
-        _controller: chamilo_course.controller.tool:indexAction
+        _method: GET

+ 3 - 3
src/Chamilo/CoreBundle/Resources/views/default/admin/settings_index.html.twig

@@ -7,7 +7,7 @@ $(document).ready(function() {
         }
     });
 
-{% if _u.is_admin %}
+{% if is_granted('ROLE_ADMIN') %}
     (function(CKEDITOR) {
         CKEDITOR.replace('extra_content');
 
@@ -49,7 +49,7 @@ $(document).ready(function() {
             <div class="panel panel-default {{ block_item.class }}">
                 <div class="panel-heading">
                     {{ block_item.icon }} {{ block_item.label }}
-                    {% if block_item.editable and _u.is_admin %}
+                    {% if block_item.editable and is_granted('ROLE_ADMIN') %}
                         <a class="admin-edit-block pull-right" href="#" data-label="{{ block_item.label }}" title="{{ 'Edit' | get_lang }}" data-id="{{ block_item.class }}">
                             <img src="{{ "edit.png"|icon(22) }}" width="22" height="22" alt="{{ "Edit"|get_lang }}" title="{{ "Edit"|get_lang }}" />
                         </a>
@@ -92,7 +92,7 @@ $(document).ready(function() {
     {% endfor %}
 </section>
 
-{% if _u.is_admin %}
+{% if is_granted('ROLE_ADMIN') %}
     <div class="modal fade" id="modal-extra">
         <div class="modal-dialog">
             <div class="modal-content">

+ 1 - 1
src/Chamilo/CoreBundle/Resources/views/default/create_course/add_course.html.twig

@@ -39,7 +39,7 @@
             </div>
         </div>
     </div>
-    {% if ("allow_user_course_subscription_by_course_admin" | get_setting) == 'true' or _u.is_admin == 1 %}
+    {% if ("allow_user_course_subscription_by_course_admin" | get_setting) == 'true' or is_granted('ROLE_ADMIN') %}
     <div class="col-md-3">
         <div class="thumbnail">
 

+ 1 - 1
src/Chamilo/CoreBundle/Resources/views/default/layout/hot_courses.html.twig

@@ -24,7 +24,7 @@ $(document).ready( function() {
     <div class="hot-course-head">
         <h4 class="hot-course-title">
             {{ "HottestCourses"|get_lang}}
-            {% if _u.is_admin %}
+            {% if is_granted('ROLE_ADMIN') %}
             <span class="pull-right">
                 <a title="{{ "Hide"|get_lang }}" alt="{{ "Hide"|get_lang }}" href="{{ _p.web_main }}admin/settings.php?search_field=show_hot_courses&submit_button=&_qf__search_settings=&category=search_setting">
                     <i class="fa fa-eye" aria-hidden="true"></i>

+ 1 - 1
src/Chamilo/CoreBundle/Resources/views/default/layout/login_form.html.twig

@@ -1,4 +1,4 @@
-{% if _u.logged  == 0 %}
+{% if not is_granted('IS_AUTHENTICATED_FULLY') %}
 {% if login_form %}
     <div id="login_block" class="panel panel-default">
         <div class="panel-body">

+ 1 - 1
src/Chamilo/CoreBundle/Resources/views/default/layout/menu.html.twig

@@ -15,7 +15,7 @@
                     <li class="{{ item.current }}"><a href="{{ item.url }}" target="{{ item.target }}" title="{{ item.title }}">{{ item.title }}</a></li>
                 {% endfor %}
             </ul>
-           {% if _u.logged == 1 %}
+           {% if is_granted('IS_AUTHENTICATED_FULLY') %}
            <ul class="nav navbar-nav navbar-right">
                {% if user_notifications is not null %}
                <li><a href="{{ message_url }}">{{ user_notifications }}</a></li>

+ 1 - 1
src/Chamilo/CoreBundle/Resources/views/default/sequence_resource/session_requirements.html.twig

@@ -9,7 +9,7 @@
                     <img src="{{ 'item-sequence.png'|icon(48) }}" width="48" height="48">
                     <p class="sequence-course">{{ session.name }}</p>
 
-                    {% if _u.logged %}
+                    {% if is_granted('IS_AUTHENTICATED_FULLY') %}
                         <span class="label {{ session.status ? 'label-success' : 'label-danger' }}">
                             {% if session.status %}
                                 <em class="fa fa-check"></em> {{ 'Complete'|get_lang }}

+ 2 - 2
src/Chamilo/CoreBundle/Resources/views/default/session/about.html.twig

@@ -177,11 +177,11 @@
 
     <div class="row">
         <div class="col-md-4 col-md-offset-4">
-            {% if _u.logged and not is_subscribed %}
+            {% if is_granted('IS_AUTHENTICATED_FULLY') and not is_subscribed %}
                 <div class="text-center">
                     {{ subscribe_button }}
                 </div>
-            {% elseif not _u.logged %}
+            {% elseif not is_granted('IS_AUTHENTICATED_FULLY') %}
                 {% if 'allow_registration'|get_setting == 'true' %}
                     <a href="{{ _p.web_main ~ 'auth/inscription.php' }}" class="btn btn-info btn-lg">
                         <em class="fa fa-sign-in fa-fw"></em> {{ 'SignUp'|get_lang }}

+ 9 - 3
src/Chamilo/CoreBundle/Security/Authorization/Voter/CourseVoter.php

@@ -81,10 +81,11 @@ class CourseVoter extends AbstractVoter
      */
     protected function isGranted($attribute, $course, $user = null)
     {
-        // make sure there is a user object (i.e. that the user is logged in)
-        if (!$user instanceof UserInterface) {
+        // Make sure there is a user object (i.e. that the user is logged in)
+        // Anons can enter a course depending of the course visibility
+        /*if (!$user instanceof UserInterface) {
             return false;
-        }
+        }*/
 
         $authChecker = $this->container->get('security.authorization_checker');
 
@@ -108,6 +109,11 @@ class CourseVoter extends AbstractVoter
                     return true;
                 }
 
+                // Other course visibility need to have a user set
+                if (!$user instanceof UserInterface) {
+                    return false;
+                }
+
                 // User is subscribed in the course no matter if is teacher/student
                 if ($course->hasUser($user)) {
 

+ 57 - 0
src/Chamilo/CourseBundle/Resources/config/routing.yml

@@ -0,0 +1,57 @@
+course_url:
+    path: courses
+#    resource: '@ChamiloCoreBundle/Controller/Admin'
+
+core_tool:
+    resource: '@ChamiloCourseBundle/Controller'
+    type: annotation
+    prefix: /courses/{course}/
+#    type: annotation
+
+core_tool_document:
+    pattern: /courses/{course}/document/{file}
+    defaults:
+        _controller: ChamiloCoreBundle:Resource:getDocument
+    requirements:
+        file: .+ # allow "/" in {file}
+
+chamilo_course_tool_intro_create:
+    path: /courses/{course}/introduction/{tool}/create/
+    methods: [GET, POST]
+    defaults:
+        _controller: ChamiloCourseBundle:CToolIntro:create
+    requirements:
+        tool: "[a-zA-Z_]+"
+
+chamilo_course_tool_intro_update:
+    path: /courses/{course}/introduction/{tool}/update/
+    methods: [GET]
+    defaults:
+        _controller: chamilo_course.controller.c_tool_intro:updateAction
+
+chamilo_course_tool_list:
+    path: /courses/{course}/introduction
+    methods: [GET]
+    defaults:
+        _controller: chamilo_course.controller.tool:indexAction
+
+
+#chamilo_course.c_tool_intro:
+#    resource: |
+#        alias: chamilo_course.c_tool_intro
+#        path: /courses/{course}/introduction/{tool}
+#        templates: :Admin/Book
+#    type: sylius.resource_api
+
+# Course settings
+chamilo_course_settings:
+    pattern: /courses/{course}/settings/{namespace}
+    defaults:
+        _controller: ChamiloCourseBundle:Settings:update
+        template: ChamiloCourseBundle:Settings:default.html.twig
+
+chamilo_course_tool_index:
+    pattern: /courses/{course}/tools
+    methods: [GET, POST, HEAD, DELETE]
+    defaults:
+        _controller: chamilo_course.controller.tool:indexAction

+ 0 - 20
src/Chamilo/PageBundle/Resources/views/Security/login.html.twig

@@ -1,20 +0,0 @@
-{#
-
-This file is part of the Sonata package.
-
-(c) Thomas Rabaix <thomas.rabaix@sonata-project.org>
-
-For the full copyright and license information, please view the LICENSE
-file that was distributed with this source code.
-
-#}
-
-{% extends "SonataUserBundle:Security:base_login.html.twig" %}
-
-{% block fos_user_content %}
-    {% if app.request.session.get('sonata_basket_delivery_redirect') %}
-        {% include 'SonataBasketBundle:Basket:stepper.html.twig' with {step: 'identification'} %}
-    {% endif %}
-
-    {{ parent() }}
-{% endblock fos_user_content %}

+ 3 - 3
src/Chamilo/ThemeBundle/Resources/views/Layout/topbar.html.twig

@@ -13,7 +13,7 @@
                     <img src="{{ "icon-chamilo.png"|icon(22) }}" title="{{ "siteName" | get_setting }}">
                 </a>
             </div>
-            {% if _u.logged %}
+            {% if is_granted('IS_AUTHENTICATED_FULLY') %}
                 <div class="collapse navbar-collapse" id="toolbar">
                     <ul class="nav navbar-nav">
                         <li class="active"><a href="{{ _p.web }}user_portal.php"> {{ "MyCourses"|get_lang }}</a></li>
@@ -27,7 +27,7 @@
                                 <li><a href="{{ _p.web_main }}dashboard/">{{ "Dashboard"|get_lang }}</a></li>
                             </ul>
                         </li>
-                        {% if _u.is_admin == 1 %}
+                        {% if is_granted('ROLE_ADMIN') == 1 %}
                         <li class="dropdown">
                             <a class="dropdown-toggle" data-toggle="dropdown" href="#">{{'Administration'|get_lang }}<b class="caret"></b></a>
                             <ul class="dropdown-menu">
@@ -54,7 +54,7 @@
                         {% endif %}
                     </ul>
 
-                    {% if _u.is_admin == 1 %}
+                    {% if is_granted('ROLE_ADMIN') == 1 %}
                     <form class="navbar-form navbar-left" role="search" action="{{ _p.web_main }}admin/user_list.php" method="get">
                         <input type="text" class="form-control" placeholder="{{'SearchUsers'|get_lang }}" name="keyword">
                     </form>

+ 4 - 4
src/Chamilo/ThemeBundle/Resources/views/Navbar/user.html.twig

@@ -2,20 +2,20 @@
 {% import "ChamiloThemeBundle:Macros:image.html.twig" as macro_image %}
 <li class="dropdown user user-menu">
     <a href="#" class="dropdown-toggle" data-toggle="dropdown" role="button" aria-expanded="false">
-        <img class="img-circle" src="{{ _u.avatar_small }}" alt="{{ _u.complete_name }}" />
+        <img class="img-circle" src="{{ asset(user.avatarOrAnonymous(32)) }}" alt="{{ user.completeName }}" />
         <span class="caret"></span>
     </a>
 
     <ul class="dropdown-menu" role="menu">
         <li class="user-header">
             <div class="text-center">
-            <img class="img-circle" src="{{ _u.avatar_medium }}" alt="{{ _u.complete_name }}" />
+            <img class="img-circle" src="{{ asset(user.avatarOrAnonymous(64)) }}" alt="{{ user.completeName }}" />
             <p class="name">
                 <a href="{{ url('main', { 'name' : 'social/home.php' })}}">
-                    {{ _u.complete_name }}
+                    {{ user.completeName }}
                 </a>
             </p>
-            <p><i class="fa fa-envelope-o" aria-hidden="true"></i> {{ _u.email }}</p>
+            <p><i class="fa fa-envelope-o" aria-hidden="true"></i> {{ user.email }}</p>
             </div>
         </li>
         <li role="separator" class="divider"></li>

+ 0 - 62
src/Chamilo/ThemeBundle/Resources/views/Security/login.html.twig

@@ -1,62 +0,0 @@
-<!DOCTYPE html>
-<html class="bg-black">
-<head>
-    <meta charset="UTF-8">
-    <title>{% block title %} Log in {% endblock %}</title>
-    <meta content='width=device-width, initial-scale=1, maximum-scale=1, user-scalable=no' name='viewport'>
-
-    {#{% stylesheets '@admin_lte_css' %}#}
-    {#<link href="{{ asset_url }}" rel="stylesheet" type="text/css" />#}
-    {#{% endstylesheets %}#}
-
-    <!-- HTML5 Shim and Respond.js IE8 support of HTML5 elements and media queries -->
-    <!-- WARNING: Respond.js doesn't work if you view the page via file:// -->
-    <!--[if lt IE 9]>
-
-    <![endif]-->
-</head>
-<body class="bg-black">
-
-<div class="form-box" id="login-box">
-    <div class="header">Sign In</div>
-    <form action="{{ path('login_check') }}" method="post">
-        <div class="body bg-gray">
-            <div class="form-group">
-                <input type="text" name="_username" class="form-control" placeholder="username" value="{{ last_username }}"/>
-            </div>
-            <div class="form-group">
-                <input type="password" name="_password" class="form-control" placeholder="Password"/>
-            </div>
-            {#
-            <div class="form-group">
-                <input type="checkbox" name="remember_me"/> Remember me
-            </div>
-            #}
-        </div>
-        <div class="footer">
-            <button type="submit" class="btn bg-olive btn-block">Sign me in</button>
-
-            <p><a href="#">I forgot my password</a></p>
-
-            <a href="register.html" class="text-center">Register a new membership</a>
-        </div>
-    </form>
-
-    <div class="margin text-center">
-        <span>Sign in using social networks</span>
-        <br/>
-        <button class="btn bg-light-blue btn-circle"><i class="fa fa-facebook"></i></button>
-        <button class="btn bg-aqua btn-circle"><i class="fa fa-twitter"></i></button>
-        <button class="btn bg-red btn-circle"><i class="fa fa-google-plus"></i></button>
-
-    </div>
-</div>
-
-
-<!-- jQuery 2.0.2 -->
-<script src="//ajax.googleapis.com/ajax/libs/jquery/2.0.2/jquery.min.js"></script>
-<!-- Bootstrap -->
-<script src="../../js/bootstrap.min.js" type="text/javascript"></script>
-
-</body>
-</html>

+ 11 - 4
src/Chamilo/ThemeBundle/Resources/views/Sidebar/login.html.twig

@@ -3,23 +3,30 @@
 <form class="form-horizontal" action="{{ path("fos_user_security_check") }}" method="post" name="formLogin" id="formLogin">
     <input type="hidden" name="_csrf_token" value="{{ csrf_token('authenticate') }}"/>
     <fieldset>
-        <label for="login">{{ 'UserName' | trans }}</label>
         <div class="input-group">
             <div class="input-group-addon">
                 <em class="fa fa-user fa-fw"></em>
             </div>
-            <input id="login" autofocus="autofocus" placeholder="Username"
+            <input id="login" autofocus="autofocus" placeholder="{{ 'UserName' | trans }}"
                    autocapitalize="none" class="form-control" name="_username"
                    type="text">
         </div>
-        <label for="password">{{ 'Pass' | trans }}</label>
+
         <div class="input-group">
             <div class="input-group-addon">
                 <em class="fa fa-lock fa-fw"></em>
             </div>
-            <input id="password" placeholder="Pass" autocapitalize="none"
+            <input id="password" placeholder="{{ 'Pass' | trans }}" autocapitalize="none"
                    class="form-control" name="_password" type="password">
         </div>
+
+        <div class="input-group">
+            <div class="checkbox">
+                <label for="remember_me">
+                    <input type="checkbox" id="remember_me" name="_remember_me" value="on"/>{{ 'security.login.remember_me'|trans({}, 'FOSUserBundle') }}
+                </label>
+            </div>
+        </div>
         <button class="btn-block btn btn-primary " name="submitAuth" type="submit">
             {{ 'LoginEnter' | trans }}
         </button>

+ 13 - 0
src/Chamilo/ThemeBundle/Resources/views/Sidebar/menu_knp.html.twig

@@ -17,7 +17,20 @@
         )
     }}
 {% else %}
+    {% if plugin_login_top is not null %}
+        <div id="plugin_login_top">
+            {{ plugin_login_top }}
+        </div>
+    {% endif %}
+
     {% include '@ChamiloTheme/Sidebar/login.html.twig' %}
+
+    {% if plugin_login_bottom is not null %}
+        <div id="plugin_login_bottom">
+            {{ plugin_login_bottom }}
+        </div>
+    {% endif %}
+
 {% endif %}
 
 {% endautoescape %}

+ 1 - 0
src/Chamilo/UserBundle/DependencyInjection/ChamiloUserExtension.php

@@ -22,5 +22,6 @@ class ChamiloUserExtension extends Extension
     {
         $loader = new Loader\YamlFileLoader($container, new FileLocator(__DIR__.'/../Resources/config'));
         $loader->load('admin.yml');
+        $loader->load('services.yml');
     }
 }

+ 1 - 1
src/Chamilo/UserBundle/Entity/Manager/UserManager.php

@@ -17,7 +17,7 @@ class UserManager extends BaseUserManager
      *
      * @param string $token
      *
-     * @return UserInterface
+     * @return UserManager
      */
     public function findUserByConfirmationToken($token)
     {

+ 132 - 3
src/Chamilo/UserBundle/Entity/User.php

@@ -321,6 +321,36 @@ class User extends BaseUser implements ThemeUser
      */
     //protected $lastLogin;
 
+    /**
+     * @ORM\Column(name="facebook_id", type="string", length=255, nullable=true)
+     */
+    protected $facebookId;
+
+    /**
+     * @ORM\Column(name="facebook_access_token", type="string", length=255, nullable=true)
+     */
+    protected $facebookAccessToken;
+
+    /**
+     * @ORM\Column(name="google_id", type="string", length=255, nullable=true)
+     */
+    protected $googleId;
+
+    /**
+     * @ORM\Column(name="google_access_token", type="string", length=255, nullable=true)
+     */
+    protected $googleAccessToken;
+
+    /**
+     * @ORM\Column(name="github_id", type="string", length=255, nullable=true)
+     */
+    protected $githubId;
+
+    /**
+     * @ORM\Column(name="github_access_token", type="string", length=255, nullable=true)
+     */
+    protected $githubAccessToken;
+
     /**
      * @var \DateTime
      * @ORM\Column(name="created_at", type="datetime", nullable=true, unique=false)
@@ -1311,7 +1341,7 @@ class User extends BaseUser implements ThemeUser
     }
 
     /**
-     * @return Media
+     * @return string
      */
     public function getAvatar()
     {
@@ -1321,12 +1351,12 @@ class User extends BaseUser implements ThemeUser
     /**
      * @return string
      */
-    public function getAvatarOrAnonymous()
+    public function getAvatarOrAnonymous($size = 22)
     {
         $avatar = $this->getAvatar();
 
         if (empty($avatar)) {
-            return 'bundles/chamilocore/img/unknown.jpg';
+            return "img/icons/$size/unknown.png";
         }
 
         return $avatar;
@@ -2486,4 +2516,103 @@ class User extends BaseUser implements ThemeUser
     {
         return $this->currentUrl;
     }
+
+    /**
+     * @return mixed
+     */
+    public function getFacebookId()
+    {
+        return $this->facebookId;
+    }
+
+    /**
+     * @param mixed $facebookId
+     */
+    public function setFacebookId($facebookId)
+    {
+        $this->facebookId = $facebookId;
+    }
+
+    /**
+     * @return mixed
+     */
+    public function getFacebookAccessToken()
+    {
+        return $this->facebookAccessToken;
+    }
+
+    /**
+     * @param mixed $facebookAccessToken
+     */
+    public function setFacebookAccessToken($facebookAccessToken)
+    {
+        $this->facebookAccessToken = $facebookAccessToken;
+    }
+
+    /**
+     * @return mixed
+     */
+    public function getGoogleId()
+    {
+        return $this->googleId;
+    }
+
+    /**
+     * @param mixed $googleId
+     */
+    public function setGoogleId($googleId)
+    {
+        $this->googleId = $googleId;
+    }
+
+    /**
+     * @return mixed
+     */
+    public function getGoogleAccessToken()
+    {
+        return $this->googleAccessToken;
+    }
+
+    /**
+     * @param mixed $googleAccessToken
+     */
+    public function setGoogleAccessToken($googleAccessToken)
+    {
+        $this->googleAccessToken = $googleAccessToken;
+    }
+
+    /**
+     * @return mixed
+     */
+    public function getGithubId()
+    {
+        return $this->githubId;
+    }
+
+    /**
+     * @param mixed $githubId
+     */
+    public function setGithubId($githubId)
+    {
+        $this->githubId = $githubId;
+    }
+
+    /**
+     * @return mixed
+     */
+    public function getGithubAccessToken()
+    {
+        return $this->githubAccessToken;
+    }
+
+    /**
+     * @param mixed $githubAccessToken
+     */
+    public function setGithubAccessToken($githubAccessToken)
+    {
+        $this->githubAccessToken = $githubAccessToken;
+    }
+
+
+
 }

+ 5 - 0
src/Chamilo/UserBundle/Resources/config/services.yml

@@ -0,0 +1,5 @@
+services:
+    chamilo_user_provider:
+        class: Chamilo\UserBundle\Security\FOSUBUserProvider
+        #this is the place where the properties are passed to the UserProvider - see config.yml
+        arguments: [@fos_user.user_manager,{facebook: facebookId, google: googleId, github: githubId}]

+ 20 - 33
src/Chamilo/UserBundle/Resources/views/Security/login.html.twig

@@ -9,51 +9,38 @@
         {% endblock %}
         <div class="login-box-body">
             {% block sonata_user_login_form %}
-                <form action="{{ path("fos_user_security_check") }}"
-                      method="post" role="form">
-                    <input type="hidden" name="_csrf_token"
-                           value="{{ csrf_token('authenticate') }}"/>
+                <form action="{{ path("sonata_user_admin_security_check") }}" method="post" role="form">
+                    <input type="hidden" name="_csrf_token" value="{{ csrf_token }}"/>
 
                     <div class="form-group has-feedback">
-                        <label for="username"
-                               class="col-sm-4 control-label">{{ 'security.login.username'|trans({}, 'FOSUserBundle') }}</label>
-
-                        <input type="text" class="form-control" id="username"
-                               name="_username" value="{{ last_username }}"
-                               required="required"/>
+                        <input type="text" class="form-control" id="username"  name="_username" value="{{ last_username }}" required="required" placeholder="{{ 'security.login.username'|trans({}, 'SonataUserBundle') }}"/>
+                        <span class="glyphicon glyphicon-user form-control-feedback"></span>
                     </div>
 
                     <div class="form-group has-feedback">
-                        <label for="password"
-                               class="col-sm-4 control-label">{{ 'security.login.password'|trans({}, 'FOSUserBundle') }}</label>
-
-                        <input type="password" class="form-control"
-                               id="password"
-                               name="_password" required="required"/>
+                        <input type="password" class="form-control" id="password" name="_password" required="required" placeholder="{{ 'security.login.password'|trans({}, 'SonataUserBundle') }}"/>
+                        <span class="glyphicon glyphicon-lock form-control-feedback"></span>
                     </div>
 
-                    <div class="form-group has-feedback">
-                        <div class="checkbox control-group">
-                            <label for="remember_me">
-                                <input type="checkbox" id="remember_me"
-                                       name="_remember_me" value="on"/>
-                                {{ 'security.login.remember_me'|trans({}, 'FOSUserBundle') }}
-                            </label>
-                        </div>
+                     <div class="form-group has-feedback">
+                        <div class="checkbox">
+                                <label>
+                                    <input type="checkbox" id="remember_me" name="_remember_me" value="on"/>
+                                    {{ 'security.login.remember_me'|trans({}, 'FOSUserBundle') }}
+                                </label>
+                            </div>
                     </div>
 
-                    <div class="form-group has-feedback">
-                        <a href="{{ path('main', { name: 'auth/lostPassword.php' }) }}">{{ 'forgotten_password'|trans({}, 'SonataUserBundle') }}</a>
-                    </div>
-
-                    <div class="form-group">
-                        <div class="col-sm-offset-4 col-sm-8">
-                            <input type="submit" id="_submit" name="_submit"
-                                   class="btn btn-primary"
-                                   value="{{ 'security.login.submit'|trans({}, 'FOSUserBundle') }}"/>
+                    <div class="row">
+                        <div class="col-xs-12">
+                            <button type="submit" class="btn btn-primary btn-block btn-flat">
+                                {{ 'security.login.submit'|trans({}, 'FOSUserBundle') }}</button>
                         </div>
                     </div>
                 </form>
+
+                <a href="{{ path('main', { name: 'auth/lostPassword.php' }) }}">{{ 'forgotten_password'|trans({}, 'SonataUserBundle') }}</a>
+
             {% endblock %}
         </div>
     {% endblock %}

+ 69 - 0
src/Chamilo/UserBundle/Security/FOSUBUserProvider.php

@@ -0,0 +1,69 @@
+<?php
+/* For licensing terms, see /license.txt */
+
+namespace Chamilo\UserBundle\Security;
+use HWI\Bundle\OAuthBundle\OAuth\Response\UserResponseInterface;
+use HWI\Bundle\OAuthBundle\Security\Core\User\FOSUBUserProvider as BaseFOSUBProvider;
+use Symfony\Component\Security\Core\User\UserInterface;
+
+class FOSUBUserProvider extends BaseFOSUBProvider
+{
+    /**
+     * {@inheritDoc}
+     */
+    public function connect(UserInterface $user, UserResponseInterface $response)
+    {
+        $property = $this->getProperty($response);
+        $username = $response->getUsername();
+        //on connect - get the access token and the user ID
+        $service = $response->getResourceOwner()->getName();
+        $setter = 'set'.ucfirst($service);
+        $setterId = $setter.'Id';
+        $setter_token = $setter.'AccessToken';
+        //we "disconnect" previously connected users
+        if (null !== $previousUser = $this->userManager->findUserBy(array($property => $username))) {
+            $previousUser->$setterId(null);
+            $previousUser->$setter_token(null);
+            $this->userManager->updateUser($previousUser);
+        }
+        // We connect current user
+        $user->$setterId($username);
+        $user->$setter_token($response->getAccessToken());
+        $this->userManager->updateUser($user);
+    }
+
+    /**
+     * {@inheritdoc}
+     */
+    public function loadUserByOAuthUserResponse(UserResponseInterface $response)
+    {
+        $username = $response->getUsername();
+        $user = $this->userManager->findUserBy(array($this->getProperty($response) => $username));
+        // User creation
+        if (null === $user) {
+            $service = $response->getResourceOwner()->getName();
+            $setter = 'set'.ucfirst($service);
+            $setterId = $setter.'Id';
+            $setterToken = $setter.'AccessToken';
+            // create new user here
+            $user = $this->userManager->createUser();
+            $user->$setterId($username);
+            $user->$setterToken($response->getAccessToken());
+            //I have set all requested data with the user's username
+            //modify here with relevant data
+            $user->setUsername($username);
+            $user->setEmail($username);
+            $user->setPassword($username);
+            $user->setEnabled(true);
+            $this->userManager->updateUser($user);
+            return $user;
+        }
+        //if user exists - go with the HWIOAuth way
+        $user = parent::loadUserByOAuthUserResponse($response);
+        $serviceName = $response->getResourceOwner()->getName();
+        $setter = 'set' . ucfirst($serviceName) . 'AccessToken';
+        //update access token
+        $user->$setter($response->getAccessToken());
+        return $user;
+    }
+}

+ 0 - 0
main/inc/lib/swfobject/index.html → web/js/swfobject/index.html


+ 0 - 0
main/inc/lib/swfobject/swfobject.js → web/js/swfobject/swfobject.js


+ 0 - 0
main/inc/lib/swfobject/swfobject_source/index.html → web/js/swfobject/swfobject_source/index.html


+ 0 - 0
main/inc/lib/swfobject/swfobject_source/swfobject_1_5.zip → web/js/swfobject/swfobject_source/swfobject_1_5.zip


+ 0 - 0
main/inc/lib/swfobject/swfobject_source/swfobject_2_2.zip → web/js/swfobject/swfobject_source/swfobject_2_2.zip


+ 0 - 0
main/inc/lib/swfobject/swfobject_source/swfobject_source.js → web/js/swfobject/swfobject_source/swfobject_source.js


+ 0 - 0
main/inc/lib/wami-recorder/Wami.swf → web/js/wami-recorder/Wami.swf


+ 0 - 0
main/inc/lib/wami-recorder/buttons.png → web/js/wami-recorder/buttons.png


+ 0 - 0
main/inc/lib/wami-recorder/gui.js → web/js/wami-recorder/gui.js


+ 0 - 0
main/inc/lib/flv_player/index.html → web/js/wami-recorder/index.html


+ 0 - 0
main/inc/lib/wami-recorder/recorder.js → web/js/wami-recorder/recorder.js