Browse Source

Updating global.inc.php, composer, autoload, using a controller way to call funcion only for index.php and userportal.php

Julio Montoya 12 years ago
parent
commit
c3c338cf39

+ 2 - 0
.hgignore

@@ -122,3 +122,5 @@ syntax: regexp
 ^\.settings$
 
 nbproject/*
+
+

+ 11 - 6
composer.json

@@ -1,7 +1,7 @@
-{       
+{
     "autoload": {
         "psr-0": { "Chamilo": "src/" },
-        "classmap": [            
+        "classmap": [
             "main/auth",
             "main/admin",
             "main/cron/lang",
@@ -9,14 +9,19 @@
             "main/exercice",
             "main/gradebook/lib",
             "main/newscorm",
-            "main/inc/lib",            
-            "main/install",        
+            "main/inc/lib",
+            "main/install",
             "main/inc/lib/getid3",
             "main/survey"
         ]
-    },   
+    },
     "require": {
-        "php": ">=5.3.2"      
+        "php": ">=5.3.2",
+        "silex/silex"           : "1.0.*",
+        "twig/twig"             : ">=1.8,<2.0-dev",
+        "monolog/monolog"       : ">=1.0.0",
+        "symfony/config"        : "2.1.*",
+        "symfony/yaml"          : "2.1.*"
     },
     "minimum-stability": "dev"
 }

+ 567 - 0
composer.lock

@@ -0,0 +1,567 @@
+{
+    "hash": "eab1ecd3b0836c6aa9a6058b64dfc275",
+    "packages": [
+        {
+            "name": "monolog/monolog",
+            "version": "dev-master",
+            "source": {
+                "type": "git",
+                "url": "https://github.com/Seldaek/monolog",
+                "reference": "546225bed27bea7d00b836e0f7d8954272e0cf42"
+            },
+            "dist": {
+                "type": "zip",
+                "url": "https://github.com/Seldaek/monolog/archive/546225bed27bea7d00b836e0f7d8954272e0cf42.zip",
+                "reference": "546225bed27bea7d00b836e0f7d8954272e0cf42",
+                "shasum": ""
+            },
+            "require": {
+                "php": ">=5.3.0"
+            },
+            "require-dev": {
+                "mlehner/gelf-php": "1.0.*"
+            },
+            "suggest": {
+                "mlehner/gelf-php": "Allow sending log messages to a GrayLog2 server",
+                "ext-amqp": "Allow sending log messages to an AMQP server (1.0+ required)",
+                "ext-mongo": "Allow sending log messages to a MongoDB server"
+            },
+            "time": "2012-12-04 11:59:29",
+            "type": "library",
+            "extra": {
+                "branch-alias": {
+                    "dev-master": "1.3.x-dev"
+                }
+            },
+            "installation-source": "source",
+            "autoload": {
+                "psr-0": {
+                    "Monolog": "src/"
+                }
+            },
+            "notification-url": "https://packagist.org/downloads/",
+            "license": [
+                "MIT"
+            ],
+            "authors": [
+                {
+                    "name": "Jordi Boggiano",
+                    "email": "j.boggiano@seld.be",
+                    "homepage": "http://seld.be",
+                    "role": "Developer"
+                }
+            ],
+            "description": "Logging for PHP 5.3",
+            "homepage": "http://github.com/Seldaek/monolog",
+            "keywords": [
+                "log",
+                "logging"
+            ]
+        },
+        {
+            "name": "pimple/pimple",
+            "version": "dev-master",
+            "source": {
+                "type": "git",
+                "url": "git://github.com/fabpot/Pimple.git",
+                "reference": "86df0604a10c5faf20b466ae6a0b762cc6ed0a35"
+            },
+            "dist": {
+                "type": "zip",
+                "url": "https://github.com/fabpot/Pimple/archive/86df0604a10c5faf20b466ae6a0b762cc6ed0a35.zip",
+                "reference": "86df0604a10c5faf20b466ae6a0b762cc6ed0a35",
+                "shasum": ""
+            },
+            "require": {
+                "php": ">=5.3.0"
+            },
+            "time": "2012-11-11 08:32:34",
+            "type": "library",
+            "extra": {
+                "branch-alias": {
+                    "dev-master": "1.0.x-dev"
+                }
+            },
+            "installation-source": "source",
+            "autoload": {
+                "psr-0": {
+                    "Pimple": "lib/"
+                }
+            },
+            "notification-url": "https://packagist.org/downloads/",
+            "license": [
+                "MIT"
+            ],
+            "authors": [
+                {
+                    "name": "Fabien Potencier",
+                    "email": "fabien@symfony.com"
+                }
+            ],
+            "description": "Pimple is a simple Dependency Injection Container for PHP 5.3",
+            "homepage": "http://pimple.sensiolabs.org",
+            "keywords": [
+                "dependency injection",
+                "container"
+            ]
+        },
+        {
+            "name": "silex/silex",
+            "version": "dev-master",
+            "source": {
+                "type": "git",
+                "url": "git://github.com/fabpot/Silex.git",
+                "reference": "7e5862934aa831ededc9ca188a56816dc46e70b4"
+            },
+            "dist": {
+                "type": "zip",
+                "url": "https://github.com/fabpot/Silex/archive/7e5862934aa831ededc9ca188a56816dc46e70b4.zip",
+                "reference": "7e5862934aa831ededc9ca188a56816dc46e70b4",
+                "shasum": ""
+            },
+            "require": {
+                "php": ">=5.3.3",
+                "pimple/pimple": "1.*",
+                "symfony/event-dispatcher": ">=2.1,<2.3-dev",
+                "symfony/http-foundation": ">=2.1,<2.3-dev",
+                "symfony/http-kernel": ">=2.1,<2.3-dev",
+                "symfony/routing": ">=2.1,<2.3-dev"
+            },
+            "require-dev": {
+                "monolog/monolog": ">=1.0.0,<1.2-dev",
+                "twig/twig": ">=1.8.0,<2.0-dev",
+                "swiftmailer/swiftmailer": "4.2.*",
+                "doctrine/dbal": ">=2.2.0,<2.4.0-dev",
+                "symfony/security": ">=2.1,<2.3-dev",
+                "symfony/config": ">=2.1,<2.3-dev",
+                "symfony/locale": ">=2.1,<2.3-dev",
+                "symfony/form": ">=2.1,<2.3-dev",
+                "symfony/browser-kit": ">=2.1,<2.3-dev",
+                "symfony/css-selector": ">=2.1,<2.3-dev",
+                "symfony/finder": ">=2.1,<2.3-dev",
+                "symfony/monolog-bridge": ">=2.1,<2.3-dev",
+                "symfony/process": ">=2.1,<2.3-dev",
+                "symfony/translation": ">=2.1,<2.3-dev",
+                "symfony/twig-bridge": ">=2.1,<2.3-dev",
+                "symfony/validator": ">=2.1,<2.3-dev",
+                "symfony/serializer": ">=2.1,<2.3-dev"
+            },
+            "suggest": {
+                "symfony/browser-kit": ">=2.1,<2.3-dev",
+                "symfony/css-selector": ">=2.1,<2.3-dev",
+                "symfony/dom-crawler": ">=2.1,<2.3-dev"
+            },
+            "time": "2012-12-02 18:04:58",
+            "type": "library",
+            "extra": {
+                "branch-alias": {
+                    "dev-master": "1.0.x-dev"
+                }
+            },
+            "installation-source": "source",
+            "autoload": {
+                "psr-0": {
+                    "Silex": "src/"
+                }
+            },
+            "notification-url": "https://packagist.org/downloads/",
+            "license": [
+                "MIT"
+            ],
+            "authors": [
+                {
+                    "name": "Fabien Potencier",
+                    "email": "fabien@symfony.com"
+                },
+                {
+                    "name": "Igor Wiedler",
+                    "email": "igor@wiedler.ch",
+                    "homepage": "http://wiedler.ch/igor/"
+                }
+            ],
+            "description": "The PHP micro-framework based on the Symfony2 Components",
+            "homepage": "http://silex.sensiolabs.org",
+            "keywords": [
+                "microframework"
+            ]
+        },
+        {
+            "name": "symfony/config",
+            "version": "2.1.x-dev",
+            "target-dir": "Symfony/Component/Config",
+            "source": {
+                "type": "git",
+                "url": "https://github.com/symfony/Config",
+                "reference": "160ce63c9e75a94b9da126967fcb6d15e4cb878e"
+            },
+            "dist": {
+                "type": "zip",
+                "url": "https://github.com/symfony/Config/archive/160ce63c9e75a94b9da126967fcb6d15e4cb878e.zip",
+                "reference": "160ce63c9e75a94b9da126967fcb6d15e4cb878e",
+                "shasum": ""
+            },
+            "require": {
+                "php": ">=5.3.3"
+            },
+            "time": "2012-12-06 10:00:55",
+            "type": "library",
+            "installation-source": "source",
+            "autoload": {
+                "psr-0": {
+                    "Symfony\\Component\\Config": ""
+                }
+            },
+            "notification-url": "https://packagist.org/downloads/",
+            "license": [
+                "MIT"
+            ],
+            "authors": [
+                {
+                    "name": "Fabien Potencier",
+                    "email": "fabien@symfony.com"
+                },
+                {
+                    "name": "Symfony Community",
+                    "homepage": "http://symfony.com/contributors"
+                }
+            ],
+            "description": "Symfony Config Component",
+            "homepage": "http://symfony.com"
+        },
+        {
+            "name": "symfony/event-dispatcher",
+            "version": "dev-master",
+            "target-dir": "Symfony/Component/EventDispatcher",
+            "source": {
+                "type": "git",
+                "url": "https://github.com/symfony/EventDispatcher",
+                "reference": "eb290a447c0af5bea0d3de5d95d498afd8c82f89"
+            },
+            "dist": {
+                "type": "zip",
+                "url": "https://github.com/symfony/EventDispatcher/archive/eb290a447c0af5bea0d3de5d95d498afd8c82f89.zip",
+                "reference": "eb290a447c0af5bea0d3de5d95d498afd8c82f89",
+                "shasum": ""
+            },
+            "require": {
+                "php": ">=5.3.3"
+            },
+            "require-dev": {
+                "symfony/dependency-injection": "2.2.*"
+            },
+            "suggest": {
+                "symfony/dependency-injection": "2.2.*",
+                "symfony/http-kernel": "2.2.*"
+            },
+            "time": "2012-11-13 14:08:04",
+            "type": "library",
+            "extra": {
+                "branch-alias": {
+                    "dev-master": "2.2-dev"
+                }
+            },
+            "installation-source": "source",
+            "autoload": {
+                "psr-0": {
+                    "Symfony\\Component\\EventDispatcher\\": ""
+                }
+            },
+            "notification-url": "https://packagist.org/downloads/",
+            "license": [
+                "MIT"
+            ],
+            "authors": [
+                {
+                    "name": "Fabien Potencier",
+                    "email": "fabien@symfony.com"
+                },
+                {
+                    "name": "Symfony Community",
+                    "homepage": "http://symfony.com/contributors"
+                }
+            ],
+            "description": "Symfony EventDispatcher Component",
+            "homepage": "http://symfony.com"
+        },
+        {
+            "name": "symfony/http-foundation",
+            "version": "dev-master",
+            "target-dir": "Symfony/Component/HttpFoundation",
+            "source": {
+                "type": "git",
+                "url": "https://github.com/symfony/HttpFoundation",
+                "reference": "0acee754b149537dd90ae1e97508e8767802811b"
+            },
+            "dist": {
+                "type": "zip",
+                "url": "https://github.com/symfony/HttpFoundation/archive/0acee754b149537dd90ae1e97508e8767802811b.zip",
+                "reference": "0acee754b149537dd90ae1e97508e8767802811b",
+                "shasum": ""
+            },
+            "require": {
+                "php": ">=5.3.3"
+            },
+            "time": "2012-12-07 09:33:24",
+            "type": "library",
+            "extra": {
+                "branch-alias": {
+                    "dev-master": "2.2-dev"
+                }
+            },
+            "installation-source": "source",
+            "autoload": {
+                "psr-0": {
+                    "Symfony\\Component\\HttpFoundation\\": ""
+                },
+                "classmap": [
+                    "Symfony/Component/HttpFoundation/Resources/stubs"
+                ]
+            },
+            "notification-url": "https://packagist.org/downloads/",
+            "license": [
+                "MIT"
+            ],
+            "authors": [
+                {
+                    "name": "Fabien Potencier",
+                    "email": "fabien@symfony.com"
+                },
+                {
+                    "name": "Symfony Community",
+                    "homepage": "http://symfony.com/contributors"
+                }
+            ],
+            "description": "Symfony HttpFoundation Component",
+            "homepage": "http://symfony.com"
+        },
+        {
+            "name": "symfony/http-kernel",
+            "version": "dev-master",
+            "target-dir": "Symfony/Component/HttpKernel",
+            "source": {
+                "type": "git",
+                "url": "https://github.com/symfony/HttpKernel",
+                "reference": "323b8c877fdf1f47ce23ac5b882092dce0beeb9a"
+            },
+            "dist": {
+                "type": "zip",
+                "url": "https://github.com/symfony/HttpKernel/archive/323b8c877fdf1f47ce23ac5b882092dce0beeb9a.zip",
+                "reference": "323b8c877fdf1f47ce23ac5b882092dce0beeb9a",
+                "shasum": ""
+            },
+            "require": {
+                "php": ">=5.3.3",
+                "symfony/event-dispatcher": "2.2.*",
+                "symfony/http-foundation": "2.2.*"
+            },
+            "require-dev": {
+                "symfony/browser-kit": "2.2.*",
+                "symfony/class-loader": "2.2.*",
+                "symfony/config": "2.2.*",
+                "symfony/console": "2.2.*",
+                "symfony/dependency-injection": "2.2.*",
+                "symfony/finder": "2.2.*",
+                "symfony/process": "2.2.*",
+                "symfony/routing": "2.2.*",
+                "symfony/stopwatch": "2.2.*"
+            },
+            "suggest": {
+                "symfony/browser-kit": "2.2.*",
+                "symfony/class-loader": "2.2.*",
+                "symfony/config": "2.2.*",
+                "symfony/console": "2.2.*",
+                "symfony/dependency-injection": "2.2.*",
+                "symfony/finder": "2.2.*"
+            },
+            "time": "2012-12-07 10:04:59",
+            "type": "library",
+            "extra": {
+                "branch-alias": {
+                    "dev-master": "2.2-dev"
+                }
+            },
+            "installation-source": "source",
+            "autoload": {
+                "psr-0": {
+                    "Symfony\\Component\\HttpKernel\\": ""
+                }
+            },
+            "notification-url": "https://packagist.org/downloads/",
+            "license": [
+                "MIT"
+            ],
+            "authors": [
+                {
+                    "name": "Fabien Potencier",
+                    "email": "fabien@symfony.com"
+                },
+                {
+                    "name": "Symfony Community",
+                    "homepage": "http://symfony.com/contributors"
+                }
+            ],
+            "description": "Symfony HttpKernel Component",
+            "homepage": "http://symfony.com"
+        },
+        {
+            "name": "symfony/routing",
+            "version": "dev-master",
+            "target-dir": "Symfony/Component/Routing",
+            "source": {
+                "type": "git",
+                "url": "https://github.com/symfony/Routing",
+                "reference": "d5ecbda302b4704e374cea1e733967897675ee2c"
+            },
+            "dist": {
+                "type": "zip",
+                "url": "https://github.com/symfony/Routing/archive/d5ecbda302b4704e374cea1e733967897675ee2c.zip",
+                "reference": "d5ecbda302b4704e374cea1e733967897675ee2c",
+                "shasum": ""
+            },
+            "require": {
+                "php": ">=5.3.3"
+            },
+            "require-dev": {
+                "doctrine/common": ">=2.2,<2.4-dev",
+                "symfony/config": "2.2.*",
+                "symfony/yaml": "2.2.*",
+                "symfony/http-kernel": "2.2.*"
+            },
+            "suggest": {
+                "doctrine/common": ">=2.2,<2.4-dev",
+                "symfony/config": "2.2.*",
+                "symfony/yaml": "2.2.*"
+            },
+            "time": "2012-12-07 21:24:45",
+            "type": "library",
+            "extra": {
+                "branch-alias": {
+                    "dev-master": "2.2-dev"
+                }
+            },
+            "installation-source": "source",
+            "autoload": {
+                "psr-0": {
+                    "Symfony\\Component\\Routing\\": ""
+                }
+            },
+            "notification-url": "https://packagist.org/downloads/",
+            "license": [
+                "MIT"
+            ],
+            "authors": [
+                {
+                    "name": "Fabien Potencier",
+                    "email": "fabien@symfony.com"
+                },
+                {
+                    "name": "Symfony Community",
+                    "homepage": "http://symfony.com/contributors"
+                }
+            ],
+            "description": "Symfony Routing Component",
+            "homepage": "http://symfony.com"
+        },
+        {
+            "name": "symfony/yaml",
+            "version": "2.1.x-dev",
+            "target-dir": "Symfony/Component/Yaml",
+            "source": {
+                "type": "git",
+                "url": "https://github.com/symfony/Yaml",
+                "reference": "4fdae9fa28b7abd1135afc5227a4e59af4b64e5a"
+            },
+            "dist": {
+                "type": "zip",
+                "url": "https://github.com/symfony/Yaml/archive/4fdae9fa28b7abd1135afc5227a4e59af4b64e5a.zip",
+                "reference": "4fdae9fa28b7abd1135afc5227a4e59af4b64e5a",
+                "shasum": ""
+            },
+            "require": {
+                "php": ">=5.3.3"
+            },
+            "time": "2012-12-06 10:00:55",
+            "type": "library",
+            "installation-source": "source",
+            "autoload": {
+                "psr-0": {
+                    "Symfony\\Component\\Yaml": ""
+                }
+            },
+            "notification-url": "https://packagist.org/downloads/",
+            "license": [
+                "MIT"
+            ],
+            "authors": [
+                {
+                    "name": "Fabien Potencier",
+                    "email": "fabien@symfony.com"
+                },
+                {
+                    "name": "Symfony Community",
+                    "homepage": "http://symfony.com/contributors"
+                }
+            ],
+            "description": "Symfony Yaml Component",
+            "homepage": "http://symfony.com"
+        },
+        {
+            "name": "twig/twig",
+            "version": "dev-master",
+            "source": {
+                "type": "git",
+                "url": "git://github.com/fabpot/Twig.git",
+                "reference": "de5aaf2c1d43baafde255a042f5c7cf6122ea3ce"
+            },
+            "dist": {
+                "type": "zip",
+                "url": "https://github.com/fabpot/Twig/archive/de5aaf2c1d43baafde255a042f5c7cf6122ea3ce.zip",
+                "reference": "de5aaf2c1d43baafde255a042f5c7cf6122ea3ce",
+                "shasum": ""
+            },
+            "require": {
+                "php": ">=5.2.4"
+            },
+            "time": "2012-12-10 14:12:12",
+            "type": "library",
+            "extra": {
+                "branch-alias": {
+                    "dev-master": "1.12-dev"
+                }
+            },
+            "installation-source": "source",
+            "autoload": {
+                "psr-0": {
+                    "Twig_": "lib/"
+                }
+            },
+            "notification-url": "https://packagist.org/downloads/",
+            "license": [
+                "BSD-3"
+            ],
+            "authors": [
+                {
+                    "name": "Fabien Potencier",
+                    "email": "fabien@symfony.com"
+                },
+                {
+                    "name": "Armin Ronacher",
+                    "email": "armin.ronacher@active-4.com"
+                }
+            ],
+            "description": "Twig, the flexible, fast, and secure template language for PHP",
+            "homepage": "http://twig.sensiolabs.org",
+            "keywords": [
+                "templating"
+            ]
+        }
+    ],
+    "packages-dev": null,
+    "aliases": [
+
+    ],
+    "minimum-stability": "dev",
+    "stability-flags": [
+
+    ]
+}

+ 172 - 136
index.php

@@ -3,176 +3,212 @@
 
 /**
  * @package chamilo.main
- */
-
-
-use \ChamiloSession as Session;
+*/
 
 define('CHAMILO_HOMEPAGE', true);
 
 $language_file = array('courses', 'index');
 
-/* Flag forcing the 'current course' reset, as we're not inside a course anymore. */
+// Flag forcing the 'current course' reset, as we're not inside a course anymore.
 // Maybe we should change this into an api function? an example: CourseManager::unset();
 $cidReset = true;
 
 require_once 'main/inc/global.inc.php';
-require_once api_get_path(LIBRARY_PATH).'userportal.lib.php';
 require_once 'main/chat/chat_functions.lib.php';
 
 // The section (for the tabs).
 $this_section = SECTION_CAMPUS;
 
-$header_title = null;
-if (!api_is_anonymous()) {
-	$header_title = " ";
-}
-
 $htmlHeadXtra[] = api_get_jquery_libraries_js(array('bxslider'));
 $htmlHeadXtra[] ='
-<script type="text/javascript">
+<script>
 	$(document).ready(function(){
 		$("#slider").bxSlider({
 			infiniteLoop	: true,
 			auto			: true,
 			pager			: true,
 			autoHover		: true,
-			pause			: 10000
+		pause			: 10000
 		});
 	});
 </script>';
 
 //set cookie for check if client browser are cookies enabled
-setcookie('TestCookie', 'cookies_yes', time()+3600*24*31*12);
-
-$controller = new IndexManager($header_title);
-
-//Actions
-$loginFailed = isset($_GET['loginFailed']) ? true : isset($loginFailed);
-
-if (!empty($_GET['logout'])) {
-	$controller->logout();
-}
-
-/* Table definitions */
-
-/* Constants and CONFIGURATION parameters */
-/** @todo these configuration settings should move to the Chamilo config settings. */
-
-/** Defines wether or not anonymous visitors can see a list of the courses on the Chamilo homepage that are open to the world. */
-$_setting['display_courses_to_anonymous_users'] = 'true';
-
-/* LOGIN */
-
-/**
- * @todo This piece of code should probably move to local.inc.php where the actual login / logout procedure is handled.
- * @todo Consider removing this piece of code because does nothing.
- */
-if (isset($_GET['submitAuth']) && $_GET['submitAuth'] == 1) {
-	// nice lie!!!
-	echo 'Attempted breakin - sysadmins notified.';
-	session_destroy();
-	die();
-}
+//setcookie('TestCookie', 'cookies_yes', time()+3600*24*31*12);
+//use Symfony\Component\HttpFoundation\Cookie;
+//$cookie = new Cookie('TestCookie', 'cookies_yes', time()+3600*24*31*12);
+//$response->headers->setCookie($cookie);
+
+use Silex\Application;
+use Symfony\Component\HttpFoundation\Response;
+
+class IndexController
+{
+    public function indexAction(Application $app)
+    {
+        $request = $app['request'];
+        //Actions
+        $logout = $request->get('logout');
+
+        if (!empty($logout)) {
+            $this->logout();
+        }
+
+        // Defines wether or not anonymous visitors can see a list of the courses on the Chamilo homepage that are open to the world.
+        //$_setting['display_courses_to_anonymous_users'] = 'true';
+
+        // Delete session neccesary for legal terms
+        if (api_get_setting('allow_terms_conditions') == 'true') {
+            unset($_SESSION['term_and_condition']);
+        }
+
+        //If we are not logged in and customapages activated
+        if (!api_get_user_id() && CustomPages::enabled()) {
+            $loggedout = $request->get('loggedout');
+            if ($loggedout) {
+                CustomPages::display(CustomPages::LOGGED_OUT);
+            } else {
+                CustomPages::display(CustomPages::INDEX_UNLOGGED);
+            }
+        }
+
+        $this->check_last_login();
+
+        if (api_get_setting('display_categories_on_homepage') == 'true') {
+            $app['template']->assign('course_category_block', PageController::return_courses_in_categories());
+        }
+
+        // Facebook connexion, if activated
+        if (api_is_facebook_auth_activated() && !api_get_user_id()) {
+            facebook_connect();
+        }
+
+        $this->set_login_form($app);
+
+        //@todo move this inside the IndexManager
+        if (!api_is_anonymous()) {
+            $app['template']->assign('profile_block', PageController::return_profile_block());
+            $app['template']->assign('user_image_block', PageController::return_user_image_block());
+
+            if (api_is_platform_admin()) {
+                $app['template']->assign('course_block', PageController::return_course_block());
+            } else {
+                $app['template']->assign('teacher_block',  PageController::return_teacher_link());
+            }
+        }
+
+        $hot_courses = null;
+        $announcements_block = null;
+
+        // When loading a chamilo page do not include the hot courses and news
+        if (!isset($_REQUEST['include'])) {
+            if (api_get_setting('show_hot_courses') == 'true') {
+                $hot_courses = PageController::return_hot_courses();
+            }
+            $announcements_block = PageController::return_announcements();
+        }
+
+        $app['template']->assign('hot_courses',             $hot_courses);
+        $app['template']->assign('announcements_block', 	 $announcements_block);
+        $app['template']->assign('home_page_block', 		 PageController::return_home_page());
+
+        $nav_links = $app['template']->return_navigation_links();
+        $app['template']->assign('navigation_course_links',  $nav_links);
+        $app['template']->assign('main_navigation_block',	 $nav_links);
+
+        $app['template']->assign('notice_block',			PageController::return_notice());
+        $app['template']->assign('help_block',              PageController::return_help());
+
+        if (api_is_platform_admin() || api_is_drh()) {
+            $app['template']->assign('skills_block',            PageController::return_skills_links());
+        }
+        $response = $app['template']->render_layout('layout_2_col.tpl');
+        return new Response($response, 200, array('Cache-Control' => 's-maxage=3600, public'));
+        //return new Response($response, 200, array());
+    }
 
-// Delete session neccesary for legal terms
-if (api_get_setting('allow_terms_conditions') == 'true') {
-	unset($_SESSION['term_and_condition']);
-}
-//If we are not logged in and customapages activated
-if (!api_get_user_id() && CustomPages::enabled()) {
-    if (Request::get('loggedout')) {
-        CustomPages::display(CustomPages::LOGGED_OUT);
-    } else {
-        CustomPages::display(CustomPages::INDEX_UNLOGGED);
+    function check_last_login() {
+//
+//         * @todo This piece of code should probably move to local.inc.php where the actual login procedure is handled.
+//         * @todo Check if this code is used. I think this code is never executed because after clicking the submit button
+//         *       the code does the stuff in local.inc.php and then redirects to index.php or user_portal.php depending
+//         *       on api_get_setting('page_after_login').
+//
+
+        if (!empty($_POST['submitAuth'])) {
+            // The user has been already authenticated, we are now to find the last login of the user.
+            if (!empty($this->user_id)) {
+                $track_login_table      = Database :: get_statistic_table(TABLE_STATISTIC_TRACK_E_LOGIN);
+                $sql_last_login = "SELECT login_date
+                                    FROM $track_login_table
+                                    WHERE login_user_id = '".$this->user_id."'
+                                    ORDER BY login_date DESC LIMIT 1";
+                $result_last_login = Database::query($sql_last_login);
+                if (!$result_last_login) {
+                    if (Database::num_rows($result_last_login) > 0) {
+                        $user_last_login_datetime = Database::fetch_array($result_last_login);
+                        $user_last_login_datetime = $user_last_login_datetime[0];
+                        Session::write('user_last_login_datetime', $user_last_login_datetime);
+                    }
+                }
+                Database::free_result($result_last_login);
+
+                if (api_is_platform_admin()) {
+                    // decode all open event informations and fill the track_c_* tables
+                    include api_get_path(LIBRARY_PATH).'stats.lib.inc.php';
+                    decodeOpenInfos();
+                }
+            }
+            // End login -- if ($_POST['submitAuth'])
+        } else {
+            // Only if login form was not sent because if the form is sent the user was already on the page.
+            event_open();
+        }
     }
-}
 
-/**
- * @todo This piece of code should probably move to local.inc.php where the actual login procedure is handled.
- * @todo Check if this code is used. I think this code is never executed because after clicking the submit button
- *       the code does the stuff in local.inc.php and then redirects to index.php or user_portal.php depending
- *       on api_get_setting('page_after_login').
- */
-
-if (!empty($_POST['submitAuth'])) {
-	// The user has been already authenticated, we are now to find the last login of the user.
-	if (isset ($_user['user_id'])) {
-		$track_login_table      = Database :: get_statistic_table(TABLE_STATISTIC_TRACK_E_LOGIN);
-		$sql_last_login = "SELECT UNIX_TIMESTAMP(login_date)
-                                FROM $track_login_table
-                                WHERE login_user_id = '".$_user['user_id']."'
-                                ORDER BY login_date DESC LIMIT 1";
-		$result_last_login = Database::query($sql_last_login);
-		if (!$result_last_login) {
-			if (Database::num_rows($result_last_login) > 0) {
-				$user_last_login_datetime = Database::fetch_array($result_last_login);
-				$user_last_login_datetime = $user_last_login_datetime[0];
-				Session::write('user_last_login_datetime',$user_last_login_datetime);
+    function set_login_form(Application $app) {
+		$login_form = '';
+        $user_id = api_get_user_id();
+
+        if (!($user_id) || api_is_anonymous($user_id)) {
+
+			// Only display if the user isn't logged in.
+			$app['template']->assign('login_language_form', api_display_language_form(true));
+			$app['template']->assign('login_form',  self::display_login_form());
+
+			if (api_get_setting('allow_lostpassword') == 'true' || api_get_setting('allow_registration') == 'true') {
+				$login_form .= '<ul class="nav nav-list">';
+				if (api_get_setting('allow_registration') != 'false') {
+					$login_form .= '<li><a href="main/auth/inscription.php">'.get_lang('Reg').'</a></li>';
+				}
+				if (api_get_setting('allow_lostpassword') == 'true') {
+					$login_form .= '<li><a href="main/auth/lostPassword.php">'.get_lang('LostPassword').'</a></li>';
+				}
+				$login_form .= '</ul>';
 			}
-		}
-		Database::free_result($result_last_login);
+			$app['template']->assign('login_options',  $login_form);
+        }
+    }
 
-		//event_login();
-		if (api_is_platform_admin()) {
-			// decode all open event informations and fill the track_c_* tables
-			include api_get_path(LIBRARY_PATH).'stats.lib.inc.php';
-			decodeOpenInfos();
-		}
+    function logout() {
+        $user_id = api_get_user_id();
+        online_logout($user_id, true);
 	}
-	// End login -- if ($_POST['submitAuth'])
-} else {
-	// Only if login form was not sent because if the form is sent the user was already on the page.
-	event_open();
-}
-
-if (api_get_setting('display_categories_on_homepage') == 'true') {
-	$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();
-
-//@todo move this inside the IndexManager
-if (!api_is_anonymous()) {
-	$controller->tpl->assign('profile_block', $controller->return_profile_block());
-    $controller->tpl->assign('user_image_block', $controller->return_user_image_block());    
-
-	if (api_is_platform_admin()) {
-		$controller->tpl->assign('course_block',			$controller->return_course_block());
-	} else {
-		$controller->tpl->assign('teacher_block', 			$controller->return_teacher_link());
+    function display_login_form() {
+		$form = new FormValidator('formLogin', 'POST', null,  null, array('class'=>'form-vertical'));
+        $form->addElement('text', 'login', get_lang('UserName'), array('class' => 'span2 autocapitalize_off', 'autofocus' => 'autofocus'));
+		$form->addElement('password', 'password', get_lang('Pass'), array('class' => 'span2'));
+		$form->addElement('style_submit_button','submitAuth', get_lang('LoginEnter'), array('class' => 'btn'));
+		$html = $form->return_form();
+		if (api_get_setting('openid_authentication') == 'true') {
+			include_once 'main/auth/openid/login.php';
+			$html .= '<div>'.openid_form().'</div>';
+		}
+		return $html;
 	}
 }
 
-$hot_courses = null;
-$announcements_block = null;
-
-// When loading a chamilo page do not include the hot courses and news
-
-if (!isset($_REQUEST['include'])) {
-    if (api_get_setting('show_hot_courses') == 'true') {
-        $hot_courses = $controller->return_hot_courses();
-    }
-    $announcements_block = $controller->return_announcements();
-}
-
-$controller->tpl->assign('hot_courses',             $hot_courses);
-$controller->tpl->assign('announcements_block', 	$announcements_block);
-$controller->tpl->assign('home_page_block', 		$controller->return_home_page());
-
-$controller->tpl->assign('navigation_course_links', 	$controller->return_navigation_links());
-
-$controller->tpl->assign('notice_block',			$controller->return_notice());
-$controller->tpl->assign('main_navigation_block',	$controller->return_navigation_links());
-$controller->tpl->assign('help_block',              $controller->return_help());
-
-if (api_is_platform_admin() || api_is_drh()) {
-    $controller->tpl->assign('skills_block',            $controller->return_skills_links());
-}
-
-$controller->tpl->display_two_col_template();
+$app->match('/', 'IndexController::indexAction', 'POST|GET');
+$app->run();
+//$app['http_cache']->run();

+ 22 - 21
main/calendar/agenda_js.php

@@ -35,12 +35,12 @@ $htmlHeadXtra[] = api_get_js('fullcalendar/gcal.js');
 $htmlHeadXtra[] = api_get_css(api_get_path(WEB_LIBRARY_PATH).'javascript/fullcalendar/fullcalendar.css');
 $htmlHeadXtra[] = api_get_css(api_get_path(WEB_LIBRARY_PATH).'javascript/qtip2/jquery.qtip.min.css');
 
-if (api_is_platform_admin() && $type == 'admin') {	
+if (api_is_platform_admin() && $type == 'admin') {
 	$type = 'admin';
 }
 
 //if (api_get_course_id() != -1 && $type == 'course') {
-if (isset($_REQUEST['cidReq']) && !empty($_REQUEST['cidReq'])) {	
+if (isset($_REQUEST['cidReq']) && !empty($_REQUEST['cidReq'])) {
 	$type = 'course';
 }
 
@@ -64,23 +64,23 @@ $tpl->assign('use_google_calendar', 0);
 $can_add_events = 0;
 
 switch($type) {
-	case 'admin':		
+	case 'admin':
         api_protect_admin_script();
-		$this_section = SECTION_PLATFORM_ADMIN;        
+		$this_section = SECTION_PLATFORM_ADMIN;
         if (api_is_platform_admin()) {
             $can_add_events = 1;
         }
 		break;
 	case 'course':
         api_protect_course_script();
-		$this_section = SECTION_COURSES;        
+		$this_section = SECTION_COURSES;
         if (api_is_allowed_to_edit()) {
             $can_add_events = 1;
         }
         if (!empty($group_id)) {
             if ($is_group_tutor) {
-                $can_add_events = 1;                
-            }                    
+                $can_add_events = 1;
+            }
         }
 		break;
 	case 'personal':
@@ -88,7 +88,7 @@ switch($type) {
             api_not_allowed(true);
         }
         $extra_field_data = UserManager::get_extra_user_data_by_field(api_get_user_id(), 'google_calendar_url');
-        if (!empty($extra_field_data) && isset($extra_field_data['google_calendar_url']) && !empty($extra_field_data['google_calendar_url'])) {            
+        if (!empty($extra_field_data) && isset($extra_field_data['google_calendar_url']) && !empty($extra_field_data['google_calendar_url'])) {
             $tpl->assign('use_google_calendar', 1);
             $tpl->assign('google_calendar_url', $extra_field_data['google_calendar_url']);
         }
@@ -111,9 +111,9 @@ $tpl->assign('month_names', 		json_encode($months));
 $tpl->assign('month_names_short', 	json_encode($months_short));
 $tpl->assign('day_names', 			json_encode($days));
 $tpl->assign('day_names_short', 	json_encode($day_short));
-$tpl->assign('button_text', 		json_encode(array(	'today'	=> get_lang('Today'), 
-														'month'	=> get_lang('Month'), 
-														'week'	=> get_lang('Week'), 
+$tpl->assign('button_text', 		json_encode(array(	'today'	=> get_lang('Today'),
+														'month'	=> get_lang('Month'),
+														'week'	=> get_lang('Week'),
 														'day'	=> get_lang('Day'))));
 
 //see http://docs.jquery.com/UI/Datepicker/$.datepicker.formatDate
@@ -124,16 +124,17 @@ $region_value = api_get_language_isocode();
 if ($region_value == 'en') {
     $region_value = 'en-GB';
 }
-$tpl->assign('region_value', 	$region_value);
 
+$tpl->assign('region_value', 	$region_value);
 
 $export_icon = '../img/export.png';
 $export_icon_low = '../img/export_low_fade.png';
 $export_icon_high = '../img/export_high_fade.png';
-            
+
 $tpl->assign('export_ical_confidential_icon', 	Display::return_icon($export_icon_high, get_lang('ExportiCalConfidential')));
 
 if (api_is_allowed_to_edit(false,true) OR (api_get_course_setting('allow_user_edit_agenda') && !api_is_anonymous()) && api_is_allowed_to_session_edit(false,true) OR $is_group_tutor) {
+    $actions = null;
     if ($type == 'course') {
         $actions = display_courseadmin_links();
     }
@@ -146,12 +147,12 @@ $tpl->assign('type', $type);
 $type_event_class = $type.'_event';
 $type_label = get_lang(ucfirst($type).'Calendar');
 if ($type == 'course' && !empty($group_id)) {
-    $type_event_class = 'group_event';    
+    $type_event_class = 'group_event';
     $type_label = get_lang('GroupCalendar');
 }
 
 if ($type == 'course' && !empty($session_id)) {
-    $type_event_class = 'session_event';    
+    $type_event_class = 'session_event';
     $type_label = get_lang('SessionCalendar');
 }
 
@@ -170,16 +171,16 @@ $course_code  = api_get_course_id();
 if ((api_is_allowed_to_edit() || $is_group_tutor) && $course_code != '-1' && $type == 'course') {
     $order = 'lastname';
     if (api_is_western_name_order) {
-        $order = 'firstname';    
-    }    
-    if (!empty($group_id)) {        
-        $group_list  = array($group_id => $group_properties);                
+        $order = 'firstname';
+    }
+    if (!empty($group_id)) {
+        $group_list  = array($group_id => $group_properties);
         $user_list  = GroupManager::get_subscribed_users($group_id);
     } else {
         $user_list  = CourseManager::get_user_list_from_course_code(api_get_course_id(), api_get_session_id(), null, $order);
         $group_list = CourseManager::get_group_list_of_course(api_get_course_id(), api_get_session_id());
     }
-    
+
 
     $agenda = new Agenda();
     //This will fill the select called #users_to_send_id
@@ -190,7 +191,7 @@ if ((api_is_allowed_to_edit() || $is_group_tutor) && $course_code != '-1' && $ty
 //Loading Agenda template
 //$content .= gettext('Hello');
 //$content .= gettext('Admin');
-$content .= $tpl->fetch('default/agenda/month.tpl');
+$content = $tpl->fetch('default/agenda/month.tpl');
 
 $tpl->assign('content', $content);
 

+ 112 - 96
main/inc/global.inc.php

@@ -22,10 +22,12 @@
  */
 
  //@todo will be removed before a stable release
-$mtime = microtime(); 
-$mtime = explode(" ",$mtime); 
-$mtime = $mtime[1] + $mtime[0]; 
-$starttime = $mtime; 
+//require '/var/www/chamilo11/tests/xhprof/header.php';
+
+$mtime = microtime();
+$mtime = explode(" ",$mtime);
+$mtime = $mtime[1] + $mtime[0];
+$starttime = $mtime;
 define('START', $starttime);
 
 // Showing/hiding error codes in global error messages.
@@ -106,7 +108,7 @@ ini_set('auto_detect_line_endings', '1');
 //require_once dirname(__FILE__).'/autoload.inc.php';
 
 //Fixes Htmlpurifier autoloader issue with composer
-define('HTMLPURIFIER_PREFIX', $lib_path.'htmlpurifier/library'); 
+define('HTMLPURIFIER_PREFIX', $lib_path.'htmlpurifier/library');
 
 //mpdf constants
 define("_MPDF_TEMP_PATH", api_get_path(SYS_ARCHIVE_PATH));
@@ -115,6 +117,85 @@ define('_MPDF_PATH', api_get_path(LIBRARY_PATH).'mpdf/');
 //Composer autoloader
 require_once __DIR__.'../../../vendor/autoload.php';
 
+use Silex\Application;
+$app = new Application();
+
+require_once __DIR__.'/../../resources/config/prod.php';
+//require_once __DIR__.'/../../resources/config/dev.php';
+
+//Setting HttpCacheService provider in order to use do: $app['http_cache']->run();
+$app->register(new Silex\Provider\HttpCacheServiceProvider(), array(
+    'http_cache.cache_dir' => $app['http_cache.cache_dir'].'/',
+));
+
+//Setting the Twig service provider
+$app->register(new Silex\Provider\TwigServiceProvider(), array(
+    'twig.path' => array(
+        api_get_path(SYS_CODE_PATH).'template', //template folder
+        api_get_path(SYS_PLUGIN_PATH)             //plugin folder
+    ),
+    'twig.options'          => array(
+        //'twig.form.templates' => array('form_div_layout.html.twig', 'common/form_div_layout.html.twig'),
+        'debug'             => $app['debug'],
+        'charset'           => 'utf-8',
+        'strict_variables'  => false,
+        'autoescape'        => false,
+        'cache'             => $app['debug'] ? false : $app['cache.path'].'twig',
+        'optimizations' => -1, // turn on optimizations with -1
+    )
+));
+
+//Setting Twig options
+$app['twig'] = $app->share($app->extend('twig', function($twig, $app) {
+    $twig->addFilter('get_lang', new Twig_Filter_Function('get_lang'));
+    $twig->addFilter('get_path', new Twig_Filter_Function('api_get_path'));
+    $twig->addFilter('get_setting', new Twig_Filter_Function('api_get_setting'));
+    $twig->addFilter('var_dump', new Twig_Filter_Function('var_dump'));
+    $twig->addFilter('return_message', new Twig_Filter_Function('Display::return_message_and_translate'));
+    $twig->addFilter('display_page_header', new Twig_Filter_Function('Display::page_header_and_translate'));
+    $twig->addFilter('display_page_subheader', new Twig_Filter_Function('Display::page_subheader_and_translate'));
+    $twig->addFilter('icon', new Twig_Filter_Function('Template::get_icon_path'));
+    $twig->addFilter('format_date', new Twig_Filter_Function('Template::format_date'));
+    return $twig;
+}));
+
+//Creating Chamilo service provider
+use Silex\ServiceProviderInterface;
+
+class ChamiloServiceProvider implements ServiceProviderInterface {
+    public function register(Application $app) {
+        //Template
+        $app['template'] = $app->share(function() use($app){
+            return new Template(null, $app);
+        });
+
+        //Formvalidator
+        $app['form_validator'] = $app->share(function() use($app){
+            return new FormValidator();
+        });
+    }
+    public function boot(Application $app) {
+    }
+}
+//Registering Chamilo service provider
+$app->register(new ChamiloServiceProvider(), array());
+
+$app->finish(function() {
+    //require '/var/www/chamilo11/tests/xhprof/footer.php';
+    //error_log($xhprof);
+});
+
+$app['template.show_header']        = true;
+$app['template.show_footer']        = true;
+$app['template.show_learnpath']     = true;
+$app['template.hide_global_chat']   = true;
+$app['template.load_plugins']       = true;
+
+//Default template style
+$app['template_style'] = 'default';
+$app['default_layout'] = 'layout_1_col.tpl';
+
+
 //Database constants
 require_once $lib_path.'database.constants.inc.php';
 
@@ -156,6 +237,7 @@ if (!$_configuration['db_host']) {
     die();
 }
 
+
 /* RETRIEVING ALL THE CHAMILO CONFIG SETTINGS FOR MULTIPLE URLs FEATURE*/
 if (!empty($_configuration['multiple_access_urls'])) {
     $_configuration['access_url'] = 1;
@@ -216,84 +298,18 @@ if (api_is_utf8($charset)) {
 // Start session after the internationalization library has been initialized.
 Chamilo::session()->start($already_installed);
 
-// Remove quotes added by PHP  - get_magic_quotes_gpc() is deprecated in PHP 5 see #2970
- 
-if (function_exists('get_magic_quotes_gpc') && get_magic_quotes_gpc()) {	
-	array_walk_recursive_limited($_GET,     	'stripslashes', true);	
-	array_walk_recursive_limited($_POST, 	'stripslashes', true);
-	array_walk_recursive_limited($_COOKIE,  'stripslashes', true);
-	array_walk_recursive_limited($_REQUEST, 'stripslashes', true);
-}
-
-// access_url == 1 is the default chamilo location
-if ($_configuration['access_url'] != 1) {
-    $url_info = api_get_access_url($_configuration['access_url']);
-    if ($url_info['active'] == 1) {
-        $settings_by_access = & api_get_settings(null, 'list', $_configuration['access_url'], 1);
-        foreach ($settings_by_access as & $row) {
-            if (empty($row['variable'])) {
-                $row['variable'] = 0;
-            }
-            if (empty($row['subkey'])) {
-                $row['subkey'] = 0;
-            }
-            if (empty($row['category'])) {
-                $row['category'] = 0;
-            }
-            $settings_by_access_list[$row['variable']][$row['subkey']][$row['category']] = $row;
-        }
-    }
-}
-
-$result = & api_get_settings(null, 'list', 1);
-foreach ($result as & $row) {
-    if ($_configuration['access_url'] != 1) {
-        if ($url_info['active'] == 1) {
-            $var = empty($row['variable']) ? 0 : $row['variable'];
-            $subkey = empty($row['subkey']) ? 0 : $row['subkey'];
-            $category = empty($row['category']) ? 0 : $row['category'];
-        }
+$settings_refresh_info = api_get_settings_params_simple(array('variable = ?' => 'settings_date_refresh'));
+$settings_date_refresh = $settings_refresh_info ? $settings_refresh_info['selected_value'] : null;
 
-        if ($row['access_url_changeable'] == 1 && $url_info['active'] == 1) {
-            if (isset($settings_by_access_list[$var]) &&
-                $settings_by_access_list[$var][$subkey][$category]['selected_value'] != '') {
-                if ($row['subkey'] == null) {
-                    $_setting[$row['variable']] = $settings_by_access_list[$var][$subkey][$category]['selected_value'];
-                } else {
-                    $_setting[$row['variable']][$row['subkey']] = $settings_by_access_list[$var][$subkey][$category]['selected_value'];
-                }
-            } else {
-                if ($row['subkey'] == null) {
-                    $_setting[$row['variable']] = $row['selected_value'];
-                } else {
-                    $_setting[$row['variable']][$row['subkey']] = $row['selected_value'];
-                }
-            }
-        } else {
-            if ($row['subkey'] == null) {
-                $_setting[$row['variable']] = $row['selected_value'];
-            } else {
-                $_setting[$row['variable']][$row['subkey']] = $row['selected_value'];
-            }
-        }
-    } else {
-        if ($row['subkey'] == null) {
-            $_setting[$row['variable']] = $row['selected_value'];
-        } else {
-            $_setting[$row['variable']][$row['subkey']] = $row['selected_value'];
-        }
-    }
-}
+$_setting = isset($_SESSION['_setting']) ? $_SESSION['_setting'] : null;
+$_plugins = isset($_SESSION['_plugins']) ? $_SESSION['_plugins'] : null;
 
-$result = & api_get_settings('Plugins', 'list', $_configuration['access_url']);
-$_plugins = array();
-foreach ($result as & $row) {
-    $key = & $row['variable'];
-    if (is_string($_setting[$key])) {
-        $_setting[$key] = array();
+if (!isset($_setting)) {
+    api_set_settings_and_plugins();
+} else {
+    if (isset($_setting['settings_date_refresh']) && $_setting['settings_date_refresh'] != $settings_date_refresh) {
+        api_set_settings_and_plugins();
     }
-    $_setting[$key][] = $row['selected_value'];
-    $_plugins[$key][] = $row['selected_value'];
 }
 
 // Load allowed tag definitions for kses and/or HTMLPurifier.
@@ -301,7 +317,7 @@ require_once $lib_path.'formvalidator/Rule/allowed_tags.inc.php';
 // Load HTMLPurifier.
 //require_once $lib_path.'htmlpurifier/library/HTMLPurifier.auto.php'; // It will be loaded later, in a lazy manner.
 
-// Before we call local.inc.php, let's define a global $this_section variable 
+// Before we call local.inc.php, let's define a global $this_section variable
 // which will then be usable from the banner and header scripts
 $this_section = SECTION_GLOBAL;
 
@@ -313,10 +329,10 @@ require $includePath.'/local.inc.php';
 //Fixes bug in Chamilo 1.8.7.1 array was not set
 $administrator['email'] = isset($administrator['email']) ? $administrator['email'] : 'admin@example.com';
 $administrator['name']  = isset($administrator['name']) ? $administrator['name'] : 'Admin';
- 
+
 $mail_conf = api_get_path(CONFIGURATION_PATH).'mail.conf.php';
 if (file_exists($mail_conf)) {
-	require_once $mail_conf; 
+	require_once $mail_conf;
 }
 
 // ===== "who is logged in?" module section =====
@@ -327,9 +343,9 @@ if (!$x = strpos($_SERVER['PHP_SELF'], 'whoisonline.php')) {
 }
 
 // ===== end "who is logged in?" module section =====
-
-if (api_get_setting('server_type') == 'test') {    
-    error_reporting(E_ALL & ~E_NOTICE & ~E_DEPRECATED);
+//error_reporting(-1);
+if (api_get_setting('server_type') == 'test') {
+    //error_reporting(E_ALL & ~E_NOTICE & ~E_DEPRECATED);
 } else {
     /*
     Server type is not test
@@ -393,18 +409,18 @@ if (isset($this_script) && $this_script == 'sub_language') {
     //getting parent info
     $parent_language = SubLanguageManager::get_all_information_of_language($_REQUEST['id']);
     //getting sub language info
-    $sub_language = SubLanguageManager::get_all_information_of_language($_REQUEST['sub_language_id']);    
+    $sub_language = SubLanguageManager::get_all_information_of_language($_REQUEST['sub_language_id']);
 
     $english_language_array = $parent_language_array = $sub_language_array = array();
 
     foreach ($language_files_to_load as $language_file_item) {
         $lang_list_pre = array_keys($GLOBALS);
-        //loading english        
-        $path = $langpath.'english/'.$language_file_item.'.inc.php';        
+        //loading english
+        $path = $langpath.'english/'.$language_file_item.'.inc.php';
         if (file_exists($path)) {
             include $path;
         }
-        
+
         $lang_list_post = array_keys($GLOBALS);
         $lang_list_result = array_diff($lang_list_post, $lang_list_pre);
         unset($lang_list_pre);
@@ -417,7 +433,7 @@ if (isset($this_script) && $this_script == 'sub_language') {
             unset(${$item});
         }
         $parent_file = $langpath.$parent_language['dokeos_folder'].'/'.$language_file_item.'.inc.php';
-        
+
         if (file_exists($parent_file) && is_file($parent_file)) {
             include_once $parent_file;
         }
@@ -428,7 +444,7 @@ if (isset($this_script) && $this_script == 'sub_language') {
         foreach($lang_list_result as $item) {
             unset(${$item});
         }
-        
+
         $sub_file = $langpath.$sub_language['dokeos_folder'].'/'.$language_file_item.'.inc.php';
         if (file_exists($sub_file) && is_file($sub_file)) {
             include $sub_file;
@@ -493,7 +509,7 @@ if (!empty($valid_languages)) {
         }
     }
 }
-  
+
 // Sometimes the variable $language_interface is changed
 // temporarily for achieving translation in different language.
 // We need to save the genuine value of this variable and
@@ -591,8 +607,8 @@ if (!isset($_SESSION['login_as']) && isset($_user)) {
         Database::query($s_sql_update_logout_date);
     }
 }
-// Add language_measure_frequency to your main/inc/conf/configuration.php in 
-// order to generate language variables frequency measurements (you can then 
+// Add language_measure_frequency to your main/inc/conf/configuration.php in
+// order to generate language variables frequency measurements (you can then
 // see them through main/cron/lang/langstats.php)
 // The langstat object will then be used in the get_lang() function.
 // This block can be removed to speed things up a bit as it should only ever
@@ -604,7 +620,7 @@ if (isset($_configuration['language_measure_frequency']) && $_configuration['lan
 
 //Default quota for the course documents folder
 $default_quota = api_get_setting('default_document_quotum');
-//Just in case the setting is not correctly set 
+//Just in case the setting is not correctly set
 if (empty($default_quota)) {
     $default_quota = 100000000;
 }

File diff suppressed because it is too large
+ 167 - 170
main/inc/lib/course.lib.php


+ 31 - 6
main/inc/lib/group_portal_manager.lib.php

@@ -156,7 +156,7 @@ class GroupPortalManager {
 	public static function get_group_data($group_id)
 	{
 		$table	= Database :: get_main_table(TABLE_MAIN_GROUP);
-		$group_id = intval($group_id);		
+		$group_id = intval($group_id);
 		$sql = "SELECT id, name, description, picture_uri, url, visibility  FROM $table WHERE id = $group_id ";
 		$res = Database::query($sql);
 		$item = array();
@@ -294,7 +294,7 @@ class GroupPortalManager {
 		$tag					= Database :: get_main_table(TABLE_MAIN_TAG);
 		$table_group_rel_tag	= Database :: get_main_table(TABLE_MAIN_GROUP_REL_TAG);
 		$group_id 				= intval($group_id);
-		
+
 		$sql = "SELECT tag FROM $tag t INNER JOIN $table_group_rel_tag gt ON (gt.tag_id= t.id) WHERE gt.group_id = $group_id ";
 		$res = Database::query($sql);
 		$tags = array();
@@ -323,7 +323,7 @@ class GroupPortalManager {
 	 * @return array   Database::store_result of the result
 	 * @author Julio Montoya
 	 * */
-	public static function get_groups_by_user($user_id = '', $relation_type = GROUP_USER_PERMISSION_READER, $with_image = false) {		
+	public static function get_groups_by_user($user_id = '', $relation_type = GROUP_USER_PERMISSION_READER, $with_image = false) {
 		$table_group_rel_user	= Database::get_main_table(TABLE_MAIN_USER_REL_GROUP);
 		$tbl_group				= Database::get_main_table(TABLE_MAIN_GROUP);
 		$user_id 				= intval($user_id);
@@ -361,7 +361,7 @@ class GroupPortalManager {
 	 * @return array  with group content
 	 * @author Julio Montoya
 	 * */
-	public static function get_groups_by_popularity($num = 6, $with_image = true) {		
+	public static function get_groups_by_popularity($num = 6, $with_image = true) {
 		$table_group_rel_user	= Database::get_main_table(TABLE_MAIN_USER_REL_GROUP);
 		$tbl_group				= Database::get_main_table(TABLE_MAIN_GROUP);
 		if (empty($num)) {
@@ -398,7 +398,7 @@ class GroupPortalManager {
 	 * @return array  with group content
 	 * @author Julio Montoya
 	 * */
-	public static function get_groups_by_age($num = 6, $with_image = true) {		
+	public static function get_groups_by_age($num = 6, $with_image = true) {
 		$table_group_rel_user	= Database::get_main_table(TABLE_MAIN_USER_REL_GROUP);
 		$tbl_group				= Database::get_main_table(TABLE_MAIN_GROUP);
 
@@ -817,7 +817,7 @@ class GroupPortalManager {
 		$medium = self::resize_picture($source_file, 85);
 		$normal = self::resize_picture($source_file, 200);
 
-		$big = new Image($source_file); // This is the original picture.		
+		$big = new Image($source_file); // This is the original picture.
 		$ok = $small->send_image($path.'small_'.$filename)
 				&& $medium->send_image($path.'medium_'.$filename)
 				&& $normal->send_image($path.'big_'.$filename)
@@ -1104,4 +1104,29 @@ class GroupPortalManager {
         $sql = "UPDATE $table_message SET msg_status=3 WHERE group_id = $group_id AND (id = '$topic_id' OR parent_id = $topic_id) ";
         Database::query($sql);
     }
+    
+    public static function get_groups_by_user_count($user_id = '', $relation_type = GROUP_USER_PERMISSION_READER, $with_image = false) {
+        $table_group_rel_user	= Database::get_main_table(TABLE_MAIN_USER_REL_GROUP);
+		$tbl_group				= Database::get_main_table(TABLE_MAIN_GROUP);
+		$user_id 				= intval($user_id);
+
+		if ($relation_type == 0) {
+			$where_relation_condition = '';
+		} else {
+			$relation_type 			= intval($relation_type);
+			$where_relation_condition = "AND gu.relation_type = $relation_type ";
+		}
+
+		$sql = "SELECT count(g.id) as count
+				FROM $tbl_group g
+				INNER JOIN $table_group_rel_user gu
+				ON gu.group_id = g.id WHERE gu.user_id = $user_id $where_relation_condition ";
+
+		$result = Database::query($sql);
+		if (Database::num_rows($result) > 0) {
+			$row = Database::fetch_array($result, 'ASSOC');
+            return $row['count'];
+		}
+		return 0;
+    }
 }

+ 95 - 0
main/inc/lib/main_api.lib.php

@@ -2167,6 +2167,12 @@ function api_get_settings_params($params) {
     return $result;
 }
 
+function api_get_settings_params_simple($params) {
+    $table = Database::get_main_table(TABLE_MAIN_SETTINGS_CURRENT);
+    $result = Database::select('*', $table, array('where' => $params), 'one');
+    return $result;
+}
+
 /**
  * Returns the value of a setting from the web-adjustable admin config settings.
  **/
@@ -6415,3 +6421,92 @@ function api_coach_can_edit_view_results($course_code = null, $session_id = null
         return false;
     }
 }
+
+function api_get_js_simple($file) {
+    return '<script type="text/javascript" src="'.$file.'"></script>'."\n";
+}
+
+
+function api_set_settings_and_plugins() {
+    global $_configuration;
+    //error_log('Loading settings from DB');
+    $_setting = array();
+    $_plugins = array();
+
+    // access_url == 1 is the default chamilo location
+    $settings_by_access_list = array();
+
+    if ($_configuration['access_url'] != 1) {
+        $url_info = api_get_access_url($_configuration['access_url']);
+        if ($url_info['active'] == 1) {
+            $settings_by_access = & api_get_settings(null, 'list', $_configuration['access_url'], 1);
+            foreach ($settings_by_access as & $row) {
+                if (empty($row['variable'])) {
+                    $row['variable'] = 0;
+                }
+                if (empty($row['subkey'])) {
+                    $row['subkey'] = 0;
+                }
+                if (empty($row['category'])) {
+                    $row['category'] = 0;
+                }
+                $settings_by_access_list[$row['variable']][$row['subkey']][$row['category']] = $row;
+            }
+        }
+    }
+
+    $result = api_get_settings(null, 'list', 1);
+
+    foreach ($result as & $row) {
+        if ($_configuration['access_url'] != 1) {
+            if ($url_info['active'] == 1) {
+                $var = empty($row['variable']) ? 0 : $row['variable'];
+                $subkey = empty($row['subkey']) ? 0 : $row['subkey'];
+                $category = empty($row['category']) ? 0 : $row['category'];
+            }
+
+            if ($row['access_url_changeable'] == 1 && $url_info['active'] == 1) {
+                if (isset($settings_by_access_list[$var]) &&
+                    $settings_by_access_list[$var][$subkey][$category]['selected_value'] != '') {
+                    if ($row['subkey'] == null) {
+                        $_setting[$row['variable']] = $settings_by_access_list[$var][$subkey][$category]['selected_value'];
+                    } else {
+                        $_setting[$row['variable']][$row['subkey']] = $settings_by_access_list[$var][$subkey][$category]['selected_value'];
+                    }
+                } else {
+                    if ($row['subkey'] == null) {
+                        $_setting[$row['variable']] = $row['selected_value'];
+                    } else {
+                        $_setting[$row['variable']][$row['subkey']] = $row['selected_value'];
+                    }
+                }
+            } else {
+                if ($row['subkey'] == null) {
+                    $_setting[$row['variable']] = $row['selected_value'];
+                } else {
+                    $_setting[$row['variable']][$row['subkey']] = $row['selected_value'];
+                }
+            }
+        } else {
+            if ($row['subkey'] == null) {
+                $_setting[$row['variable']] = $row['selected_value'];
+            } else {
+                $_setting[$row['variable']][$row['subkey']] = $row['selected_value'];
+            }
+        }
+    }
+
+    $result = api_get_settings('Plugins', 'list', $_configuration['access_url']);
+    $_plugins = array();
+    foreach ($result as & $row) {
+        $key = & $row['variable'];
+        if (is_string($_setting[$key])) {
+            $_setting[$key] = array();
+        }
+        $_setting[$key][] = $row['selected_value'];
+        $_plugins[$key][] = $row['selected_value'];
+    }
+    //global $app;
+    $_SESSION['_setting'] = $_setting;
+    $_SESSION['_plugins'] = $_plugins;
+}

+ 910 - 0
main/inc/lib/page.lib.php

@@ -0,0 +1,910 @@
+<?php
+
+/**
+ *
+ * @license see /license.txt
+ * @author Julio Montoya <gugli100@gmail.com>
+ */
+
+class PageController {
+
+    static function return_user_image_block($user_id = null) {
+        if (empty($user_id)) {
+            $user_id = api_get_user_id();
+        }
+
+		//Always show the user image
+		$img_array = UserManager::get_user_picture_path_by_id($user_id, 'web', true, true);
+		$no_image = false;
+		if ($img_array['file'] == 'unknown.jpg') {
+			$no_image = true;
+		}
+		$img_array = UserManager::get_picture_user($user_id, $img_array['file'], 50, USER_IMAGE_SIZE_MEDIUM, ' width="90" height="90" ');
+
+        $profile_content = null;
+
+        if (api_get_setting('allow_social_tool') == 'true') {
+            if (!$no_image) {
+				$profile_content .='<a style="text-align:center" href="'.api_get_path(WEB_PATH).'main/social/home.php"><img src="'.$img_array['file'].'"  '.$img_array['style'].' ></a>';
+			} else {
+				$profile_content .='<a style="text-align:center"  href="'.api_get_path(WEB_PATH).'main/auth/profile.php"><img title="'.get_lang('EditProfile').'" src="'.$img_array['file'].'" '.$img_array['style'].'></a>';
+			}
+		}
+        $html = self::show_right_block(null, $profile_content, 'user_image_block', array('style' => 'text-align:center;'));
+        return $html;
+    }
+
+	static function return_course_block() {
+		$html = '';
+
+		$show_create_link = false;
+		$show_course_link = false;
+
+        if ((api_get_setting('allow_users_to_create_courses') == 'false' && !api_is_platform_admin()) || api_is_student()) {
+            $display_add_course_link = false;
+        } else {
+            $display_add_course_link = true;
+        }
+		//$display_add_course_link = api_is_allowed_to_create_course() && ($_SESSION['studentview'] != 'studentenview');
+
+		if ($display_add_course_link) {
+			$show_create_link = true;
+		}
+
+		if (api_is_platform_admin() || api_is_course_admin() || api_is_allowed_to_create_course()) {
+			$show_course_link = true;
+		} else {
+			if (api_get_setting('allow_students_to_browse_courses') == 'true') {
+				$show_course_link = true;
+			}
+		}
+
+		// My account section
+		$my_account_content = '<ul class="nav nav-list">';
+
+		if ($show_create_link) {
+			$my_account_content .= '<li><a href="main/create_course/add_course.php" class="add course">'.(api_get_setting('course_validation') == 'true' ? get_lang('CreateCourseRequest') : get_lang('CourseCreate')).'</a></li>';
+		}
+
+        //Sort courses
+        $url = api_get_path(WEB_CODE_PATH).'auth/courses.php?action=sortmycourses';
+        $my_account_content .= '<li>'.Display::url(get_lang('SortMyCourses'), $url, array('class' => 'sort course')).'</li>';
+
+        //Course management
+		if ($show_course_link) {
+			if (!api_is_drh()) {
+				$my_account_content .= '<li><a href="main/auth/courses.php" class="list course">'.get_lang('CourseCatalog').'</a></li>';
+
+                if (isset($_GET['history']) && intval($_GET['history']) == 1) {
+                    $my_account_content .= '<li><a href="user_portal.php">'.get_lang('DisplayTrainingList').'</a></li>';
+                } else {
+                    $my_account_content .= '<li><a href="user_portal.php?history=1"  class="history course">'.get_lang('HistoryTrainingSessions').'</a></li>';
+                }
+
+			} else {
+				$my_account_content .= '<li><a href="main/dashboard/index.php">'.get_lang('Dashboard').'</a></li>';
+			}
+		}
+
+		$my_account_content .= '</ul>';
+
+		if (!empty($my_account_content)) {
+			$html =  self::show_right_block(get_lang('Courses'), $my_account_content, 'course_block');
+		}
+		return $html;
+	}
+
+    static function return_profile_block() {
+		$user_id = api_get_user_id();
+
+		if (empty($user_id)) {
+			return;
+		}
+
+		$profile_content = '<ul class="nav nav-list">';
+
+		//  @todo Add a platform setting to add the user image.
+		if (api_get_setting('allow_message_tool') == 'true') {
+
+			// New messages.
+			$number_of_new_messages = MessageManager::get_new_messages();
+
+			// New contact invitations.
+			$number_of_new_messages_of_friend   = SocialManager::get_message_number_invitation_by_user_id($user_id);
+
+			// New group invitations sent by a moderator.
+			$group_pending_invitations = GroupPortalManager::get_groups_by_user_count($user_id, GROUP_USER_PERMISSION_PENDING_INVITATION, false);
+
+			$total_invitations = $number_of_new_messages_of_friend + $group_pending_invitations;
+            $cant_msg = Display::badge($number_of_new_messages);
+
+			$link = '';
+			if (api_get_setting('allow_social_tool') == 'true') {
+				$link = '?f=social';
+			}
+			$profile_content .= '<li><a href="'.api_get_path(WEB_PATH).'main/messages/inbox.php'.$link.'">'.get_lang('Inbox').$cant_msg.' </a></li>';
+			$profile_content .= '<li><a href="'.api_get_path(WEB_PATH).'main/messages/new_message.php'.$link.'">'.get_lang('Compose').' </a></li>';
+
+			if (api_get_setting('allow_social_tool') == 'true') {
+				$total_invitations = Display::badge($total_invitations);
+				$profile_content .= '<li><a href="'.api_get_path(WEB_PATH).'main/social/invitations.php">'.get_lang('PendingInvitations').$total_invitations.'</a></li>';
+			}
+            $profile_content .= '<li><a href="'.api_get_path(WEB_PATH).'main/auth/profile.php">'.get_lang('EditProfile').'</a></li>';
+		}
+        $profile_content .= '</ul>';
+		$html = self::show_right_block(get_lang('Profile'), $profile_content, 'profile_block');
+		return $html;
+	}
+
+    static function return_hot_courses() {
+		return CourseManager::return_hot_courses();
+	}
+
+    static function return_help() {
+        $home = api_get_home_path();
+        $user_selected_language = api_get_interface_language();
+        $sys_path               = api_get_path(SYS_PATH);
+        $platformLanguage       = api_get_setting('platformLanguage');
+
+		// Help section.
+		/* Hide right menu "general" and other parts on anonymous right menu. */
+
+		if (!isset($user_selected_language)) {
+			$user_selected_language = $platformLanguage;
+		}
+
+        $html = null;
+		$home_menu = @(string)file_get_contents($sys_path.$home.'home_menu_'.$user_selected_language.'.html');
+		if (!empty($home_menu)) {
+			$home_menu_content = '<ul class="nav nav-list">';
+			$home_menu_content .= api_to_system_encoding($home_menu, api_detect_encoding(strip_tags($home_menu)));
+			$home_menu_content .= '</ul>';
+			$html .= self::show_right_block(get_lang('MenuGeneral'), $home_menu_content, 'help_block');
+		}
+		return $html;
+	}
+
+    static function return_skills_links() {
+        $html = '';
+        if (api_get_setting('allow_skills_tool') == 'true') {
+            $content = '<ul class="nav nav-list">';
+
+            $content .= Display::tag('li', Display::url(get_lang('MySkills'), api_get_path(WEB_CODE_PATH).'social/skills_wheel.php'));
+
+            if (api_get_setting('allow_hr_skills_management') == 'true' || api_is_platform_admin()) {
+                $content .= Display::tag('li', Display::url(get_lang('ManageSkills'), api_get_path(WEB_CODE_PATH).'admin/skills_wheel.php'));
+            }
+            $content .= '</ul>';
+            $html = self::show_right_block(get_lang("Skills"), $content, 'skill_block');
+        }
+        return $html;
+    }
+
+    static function return_notice() {
+		$sys_path               = api_get_path(SYS_PATH);
+		$user_selected_language = api_get_interface_language();
+        $home = api_get_home_path();
+
+		$html = '';
+		// Notice
+		$home_notice = @(string)file_get_contents($sys_path.$home.'home_notice_'.$user_selected_language.'.html');
+		if (empty($home_notice)) {
+			$home_notice = @(string)file_get_contents($sys_path.$home.'home_notice.html');
+		}
+
+		if (!empty($home_notice)) {
+			$home_notice = api_to_system_encoding($home_notice, api_detect_encoding(strip_tags($home_notice)));
+            $home_notice = Display::div($home_notice, array('class'  => 'homepage_notice'));
+			$html = self::show_right_block(get_lang('Notice'), $home_notice, 'notice_block');
+		}
+        return $html;
+    }
+
+    /**
+     * @todo use the template system
+     */
+	static function show_right_block($title, $content, $id = null, $params = null) {
+	    if (!empty($id)) {
+            $params['id'] = $id;
+        }
+        $params['class'] = 'well sidebar-nav';
+        $html = null;
+		if (!empty($title)) {
+			$html.= '<h4>'.$title.'</h4>';
+		}
+		$html.= $content;
+        $html = Display::div($html, $params);
+		return $html;
+	}
+
+    /**
+	 * Adds a form to let users login
+	 * @version 1.1
+	 */
+	static function display_login_form() {
+		$form = new FormValidator('formLogin', 'POST', null,  null, array('class'=>'form-vertical'));
+        // 'placeholder'=>get_lang('UserName')
+        //'autocomplete'=>"off",
+
+		$form->addElement('text', 'login', get_lang('UserName'), array('class' => 'span2 autocapitalize_off', 'autofocus' => 'autofocus'));
+		$form->addElement('password', 'password', get_lang('Pass'), array('class' => 'span2'));
+		$form->addElement('style_submit_button','submitAuth', get_lang('LoginEnter'), array('class' => 'btn'));
+		$html = $form->return_form();
+		if (api_get_setting('openid_authentication') == 'true') {
+			include_once 'main/auth/openid/login.php';
+			$html .= '<div>'.openid_form().'</div>';
+		}
+		return $html;
+	}
+
+	static function return_search_block() {
+		$html = '';
+		if (api_get_setting('search_enabled') == 'true') {
+			$html .= '<div class="searchbox">';
+			$search_btn = get_lang('Search');
+			$search_content = '<br />
+		    	<form action="main/search/" method="post">
+		    	<input type="text" id="query" class="span2" name="query" value="" />
+		    	<button class="save" type="submit" name="submit" value="'.$search_btn.'" />'.$search_btn.' </button>
+		    	</form></div>';
+			$html .= self::show_right_block(get_lang('Search'), $search_content, 'search_block');
+		}
+		return $html;
+	}
+
+    static function return_announcements($user_id = null, $show_slide = true) {
+        // Display System announcements
+		$announcement = isset($_GET['announcement']) ? intval($_GET['announcement']) : null;
+
+		if (!api_is_anonymous() && $user_id) {
+			$visibility = api_is_allowed_to_create_course() ? SystemAnnouncementManager::VISIBLE_TEACHER : SystemAnnouncementManager::VISIBLE_STUDENT;
+			if ($show_slide) {
+				$announcements = SystemAnnouncementManager :: display_announcements_slider($visibility, $announcement);
+			} else {
+				$announcements = SystemAnnouncementManager :: display_all_announcements($visibility, $announcement);
+			}
+		} else {
+			if ($show_slide) {
+				$announcements = SystemAnnouncementManager :: display_announcements_slider(SystemAnnouncementManager::VISIBLE_GUEST, $announcement);
+			} else {
+				$announcements = SystemAnnouncementManager :: display_all_announcements(SystemAnnouncementManager::VISIBLE_GUEST, $announcement);
+			}
+		}
+		return $announcements;
+	}
+
+    static function return_home_page() {
+		// Including the page for the news
+		$html = null;
+        $home = api_get_home_path();
+        $home_top_temp = null;
+
+		if (!empty($_GET['include']) && preg_match('/^[a-zA-Z0-9_-]*\.html$/', $_GET['include'])) {
+			$open = @(string)file_get_contents(api_get_path(SYS_PATH).$home.$_GET['include']);
+			$html = api_to_system_encoding($open, api_detect_encoding(strip_tags($open)));
+		} else {
+			if (!empty($_SESSION['user_language_choice'])) {
+				$user_selected_language = $_SESSION['user_language_choice'];
+			} elseif (!empty($_SESSION['_user']['language'])) {
+				$user_selected_language = $_SESSION['_user']['language'];
+			} else {
+				$user_selected_language = api_get_setting('platformLanguage');
+			}
+			if (!file_exists($home.'home_news_'.$user_selected_language.'.html')) {
+				if (file_exists($home.'home_top.html')) {
+					$home_top_temp = file($home.'home_top.html');
+				} else {
+					//$home_top_temp = file('home/'.'home_top.html');
+				}
+                if (!empty($home_top_temp)) {
+                    $home_top_temp = implode('', $home_top_temp);
+                }
+			} else {
+				if (file_exists($home.'home_top_'.$user_selected_language.'.html')) {
+					$home_top_temp = file_get_contents($home.'home_top_'.$user_selected_language.'.html');
+				} else {
+					$home_top_temp = file_get_contents($home.'home_top.html');
+				}
+			}
+            //trim($home_top_temp) == ''
+			if (empty($home_top_temp) && api_is_platform_admin()) {
+				$home_top_temp = get_lang('PortalHomepageDefaultIntroduction');
+			}
+			$open = str_replace('{rel_path}', api_get_path(REL_PATH), $home_top_temp);
+            if (!empty($open)) {
+                $html = api_to_system_encoding($open, api_detect_encoding(strip_tags($open)));
+            }
+		}
+		return $html;
+	}
+
+
+
+    static function return_reservation_block() {
+		$html = '';
+		if (api_get_setting('allow_reservation') == 'true' && api_is_allowed_to_create_course()) {
+			$booking_content .='<ul class="nav nav-list">';
+			$booking_content .='<a href="main/reservation/reservation.php">'.get_lang('ManageReservations').'</a><br />';
+			$booking_content .='</ul>';
+			$html .= self::show_right_block(get_lang('Booking'), $booking_content, 'reservation_block');
+		}
+		return $html;
+	}
+
+    static function return_classes_block() {
+		$html = '';
+		if (api_get_setting('show_groups_to_users') == 'true') {
+			require_once api_get_path(LIBRARY_PATH).'usergroup.lib.php';
+			$usergroup = new Usergroup();
+			$usergroup_list = $usergroup->get_usergroup_by_user(api_get_user_id());
+			$classes = '';
+			if (!empty($usergroup_list)) {
+				foreach($usergroup_list as $group_id) {
+					$data = $usergroup->get($group_id);
+					$data['name'] = Display::url($data['name'], api_get_path(WEB_CODE_PATH).'user/classes.php?id='.$data['id']);
+					$classes .= Display::tag('li', $data['name']);
+				}
+			}
+			if (api_is_platform_admin()) {
+				$classes .= Display::tag('li',  Display::url(get_lang('AddClasses') ,api_get_path(WEB_CODE_PATH).'admin/usergroups.php?action=add'));
+			}
+			if (!empty($classes)) {
+				$classes = Display::tag('ul', $classes, array('class'=>'nav nav-list'));
+				$html .= self::show_right_block(get_lang('Classes'), $classes, 'classes_block');
+			}
+		}
+		return $html;
+	}
+
+    static function return_exercise_block($personal_course_list) {
+		require_once api_get_path(SYS_CODE_PATH).'exercice/exercise.lib.php';
+		$exercise_list = array();
+		if (!empty($personal_course_list)) {
+			foreach($personal_course_list as  $course_item) {
+				$course_code 	= $course_item['c'];
+				$session_id 	= $course_item['id_session'];
+
+				$exercises = get_exercises_to_be_taken($course_code, $session_id);
+
+				foreach($exercises as $exercise_item) {
+					$exercise_item['course_code'] 	= $course_code;
+					$exercise_item['session_id'] 	= $session_id;
+					$exercise_item['tms'] 	= api_strtotime($exercise_item['end_time'], 'UTC');
+
+					$exercise_list[] = $exercise_item;
+				}
+			}
+			if (!empty($exercise_list)) {
+				$exercise_list = msort($exercise_list, 'tms');
+				$my_exercise = $exercise_list[0];
+				$url = Display::url($my_exercise['title'], api_get_path(WEB_CODE_PATH).'exercice/overview.php?exerciseId='.$my_exercise['id'].'&cidReq='.$my_exercise['course_code'].'&id_session='.$my_exercise['session_id']);
+				$this->page->assign('exercise_url', $url);
+				$this->page->assign('exercise_end_date', api_convert_and_format_date($my_exercise['end_time'], DATE_FORMAT_SHORT));
+			}
+		}
+	}
+
+    static function return_teacher_link() {
+		$html = '';
+        $user_id = api_get_user_id();
+
+		if (!empty($user_id)) {
+			// tabs that are deactivated are added here
+
+			$show_menu = false;
+			$show_create_link = false;
+			$show_course_link = false;
+
+			if (api_is_platform_admin() || api_is_course_admin() || api_is_allowed_to_create_course()) {
+				$show_menu = true;
+				$show_course_link = true;
+			} else {
+				if (api_get_setting('allow_students_to_browse_courses') == 'true') {
+					$show_menu = true;
+					$show_course_link = true;
+				}
+			}
+
+			if ($show_menu && ($show_create_link || $show_course_link )) {
+				$show_menu = true;
+			} else {
+				$show_menu = false;
+			}
+		}
+
+		// My Account section
+
+		if ($show_menu) {
+			$html .= '<ul class="nav nav-list">';
+			if ($show_create_link) {
+				$html .= '<li><a href="main/create_course/add_course.php" class="add course">'.(api_get_setting('course_validation') == 'true' ? get_lang('CreateCourseRequest') : get_lang('CourseCreate')).'</a></li>';
+			}
+
+			if ($show_course_link) {
+				if (!api_is_drh() && !api_is_session_admin()) {
+					$html .=  '<li><a href="main/auth/courses.php" class="list course">'.get_lang('CourseCatalog').'</a></li>';
+				} else {
+					$html .= '<li><a href="main/dashboard/index.php">'.get_lang('Dashboard').'</a></li>';
+				}
+			}
+			$html .= '</ul>';
+		}
+
+		if (!empty($html)) {
+			$html = self::show_right_block(get_lang('Courses'), $html, 'teacher_block');
+		}
+		return $html;
+	}
+
+    /**
+	 * Display list of courses in a category.
+	 * (for anonymous users)
+	 *
+	 * @version 1.1
+	 * @author Patrick Cool <patrick.cool@UGent.be>, Ghent University - refactoring and code cleaning
+     * @author Julio Montoya <gugli100@gmail.com>, Beeznest template modifs
+	 */
+	static function return_courses_in_categories() {
+        $result = '';
+		$stok = Security::get_token();
+
+		// Initialization.
+		$user_identified = (api_get_user_id() > 0 && !api_is_anonymous());
+		$web_course_path = api_get_path(WEB_COURSE_PATH);
+		$category = Database::escape_string($_GET['category']);
+		$setting_show_also_closed_courses = api_get_setting('show_closed_courses') == 'true';
+
+		// Database table definitions.
+		$main_course_table      = Database :: get_main_table(TABLE_MAIN_COURSE);
+		$main_category_table    = Database :: get_main_table(TABLE_MAIN_CATEGORY);
+
+		// Get list of courses in category $category.
+		$sql_get_course_list = "SELECT * FROM $main_course_table cours
+	                                WHERE category_code = '".Database::escape_string($_GET['category'])."'
+	                                ORDER BY title, UPPER(visual_code)";
+
+		// Showing only the courses of the current access_url_id.
+		global $_configuration;
+		if ($_configuration['multiple_access_urls']) {
+			$url_access_id = api_get_current_access_url_id();
+			if ($url_access_id != -1) {
+				$tbl_url_rel_course = Database::get_main_table(TABLE_MAIN_ACCESS_URL_REL_COURSE);
+				$sql_get_course_list = "SELECT * FROM $main_course_table as course INNER JOIN $tbl_url_rel_course as url_rel_course
+	                    ON (url_rel_course.course_code=course.code)
+	                    WHERE access_url_id = $url_access_id AND category_code = '".Database::escape_string($_GET['category'])."' ORDER BY title, UPPER(visual_code)";
+			}
+		}
+
+		// Removed: AND cours.visibility='".COURSE_VISIBILITY_OPEN_WORLD."'
+		$sql_result_courses = Database::query($sql_get_course_list);
+
+		while ($course_result = Database::fetch_array($sql_result_courses)) {
+			$course_list[] = $course_result;
+		}
+
+		$platform_visible_courses = '';
+		// $setting_show_also_closed_courses
+		if ($user_identified) {
+			if ($setting_show_also_closed_courses) {
+				$platform_visible_courses = '';
+			} else {
+				$platform_visible_courses = "  AND (t3.visibility='".COURSE_VISIBILITY_OPEN_WORLD."' OR t3.visibility='".COURSE_VISIBILITY_OPEN_PLATFORM."' )";
+			}
+		} else {
+			if ($setting_show_also_closed_courses) {
+				$platform_visible_courses = '';
+			} else {
+				$platform_visible_courses = "  AND (t3.visibility='".COURSE_VISIBILITY_OPEN_WORLD."' )";
+			}
+		}
+		$sqlGetSubCatList = "
+	                SELECT t1.name,t1.code,t1.parent_id,t1.children_count,COUNT(DISTINCT t3.code) AS nbCourse
+	                FROM $main_category_table t1
+	                LEFT JOIN $main_category_table t2 ON t1.code=t2.parent_id
+	                LEFT JOIN $main_course_table t3 ON (t3.category_code=t1.code $platform_visible_courses)
+	                WHERE t1.parent_id ". (empty ($category) ? "IS NULL" : "='$category'")."
+	                GROUP BY t1.name,t1.code,t1.parent_id,t1.children_count ORDER BY t1.tree_pos, t1.name";
+
+
+		// Showing only the category of courses of the current access_url_id
+		if ($_configuration['multiple_access_urls']) {
+			$url_access_id = api_get_current_access_url_id();
+			if ($url_access_id != -1) {
+				$tbl_url_rel_course = Database::get_main_table(TABLE_MAIN_ACCESS_URL_REL_COURSE);
+				$sqlGetSubCatList = "
+	                SELECT t1.name,t1.code,t1.parent_id,t1.children_count,COUNT(DISTINCT t3.code) AS nbCourse
+	                FROM $main_category_table t1
+	                LEFT JOIN $main_category_table t2 ON t1.code=t2.parent_id
+	                LEFT JOIN $main_course_table t3 ON (t3.category_code=t1.code $platform_visible_courses)
+	                INNER JOIN $tbl_url_rel_course as url_rel_course
+	                    ON (url_rel_course.course_code=t3.code)
+	                WHERE access_url_id = $url_access_id AND t1.parent_id ".(empty($category) ? "IS NULL" : "='$category'")."
+	                GROUP BY t1.name,t1.code,t1.parent_id,t1.children_count ORDER BY t1.tree_pos, t1.name";
+			}
+		}
+
+		$resCats = Database::query($sqlGetSubCatList);
+		$thereIsSubCat = false;
+		if (Database::num_rows($resCats) > 0) {
+			$htmlListCat = Display::page_header(get_lang('CatList'));
+            $htmlListCat .= '<ul>';
+			while ($catLine = Database::fetch_array($resCats)) {
+				if ($catLine['code'] != $category) {
+					$category_has_open_courses = self::category_has_open_courses($catLine['code']);
+					if ($category_has_open_courses) {
+						// The category contains courses accessible to anonymous visitors.
+						$htmlListCat .= '<li>';
+						$htmlListCat .= '<a href="'.api_get_self().'?category='.$catLine['code'].'">'.$catLine['name'].'</a>';
+						if (api_get_setting('show_number_of_courses') == 'true') {
+							$htmlListCat .= ' ('.$catLine['nbCourse'].' '.get_lang('Courses').')';
+						}
+						$htmlListCat .= "</li>";
+						$thereIsSubCat = true;
+					} elseif ($catLine['children_count'] > 0) {
+						// The category has children, subcategories.
+						$htmlListCat .= '<li>';
+						$htmlListCat .= '<a href="'.api_get_self().'?category='.$catLine['code'].'">'.$catLine['name'].'</a>';
+						$htmlListCat .= "</li>";
+						$thereIsSubCat = true;
+					}
+					/* End changed code to eliminate the (0 courses) after empty categories. */
+					elseif (api_get_setting('show_empty_course_categories') == 'true') {
+						$htmlListCat .= '<li>';
+						$htmlListCat .= $catLine['name'];
+						$htmlListCat .= "</li>";
+						$thereIsSubCat = true;
+					} // Else don't set thereIsSubCat to true to avoid printing things if not requested.
+				} else {
+					$htmlTitre = '<p>';
+					if (api_get_setting('show_back_link_on_top_of_tree') == 'true') {
+						$htmlTitre .= '<a href="'.api_get_self().'">&lt;&lt; '.get_lang('BackToHomePage').'</a>';
+					}
+					if (!is_null($catLine['parent_id']) || (api_get_setting('show_back_link_on_top_of_tree') != 'true' && !is_null($catLine['code']))) {
+						$htmlTitre .= '<a href="'.api_get_self().'?category='.$catLine['parent_id'].'">&lt;&lt; '.get_lang('Up').'</a>';
+					}
+					$htmlTitre .= "</p>";
+					if ($category != "" && !is_null($catLine['code'])) {
+						$htmlTitre .= '<h3>'.$catLine['name']."</h3>";
+					} else {
+						$htmlTitre .= '<h3>'.get_lang('Categories')."</h3>";
+					}
+				}
+			}
+			$htmlListCat .= "</ul>";
+		}
+		$result .= $htmlTitre;
+		if ($thereIsSubCat) {
+			$result .=  $htmlListCat;
+		}
+		while ($categoryName = Database::fetch_array($resCats)) {
+			$result .= '<h3>' . $categoryName['name'] . "</h3>\n";
+		}
+		$numrows = Database::num_rows($sql_result_courses);
+		$courses_list_string = '';
+		$courses_shown = 0;
+		if ($numrows > 0) {
+
+			$courses_list_string .= Display::page_header(get_lang('CourseList'));
+            $courses_list_string .= "<ul>";
+
+			if (api_get_user_id()) {
+				$courses_of_user = self::get_courses_of_user(api_get_user_id());
+			}
+
+			foreach ($course_list as $course) {
+				// $setting_show_also_closed_courses
+				if (!$setting_show_also_closed_courses) {
+					// If we do not show the closed courses
+					// we only show the courses that are open to the world (to everybody)
+					// and the courses that are open to the platform (if the current user is a registered user.
+					if( ($user_identified && $course['visibility'] == COURSE_VISIBILITY_OPEN_PLATFORM) || ($course['visibility'] == COURSE_VISIBILITY_OPEN_WORLD)) {
+						$courses_shown++;
+						$courses_list_string .= "<li>\n";
+						$courses_list_string .= '<a href="'.$web_course_path.$course['directory'].'/">'.$course['title'].'</a><br />';
+                        $course_details = array();
+						if (api_get_setting('display_coursecode_in_courselist') == 'true') {
+							$course_details[] = $course['visual_code'];
+						}
+						if (api_get_setting('display_teacher_in_courselist') == 'true') {
+							$course_details[] = $course['tutor_name'];
+						}
+						if (api_get_setting('show_different_course_language') == 'true' && $course['course_language'] != api_get_setting('platformLanguage')) {
+							$course_details[] = $course['course_language'];
+						}
+                        $courses_list_string .= implode(' - ', $course_details);
+						$courses_list_string .= "</li>\n";
+					}
+				} else {
+                    // We DO show the closed courses.
+                    // The course is accessible if (link to the course homepage):
+                    // 1. the course is open to the world (doesn't matter if the user is logged in or not): $course['visibility'] == COURSE_VISIBILITY_OPEN_WORLD);
+                    // 2. the user is logged in and the course is open to the world or open to the platform: ($user_identified && $course['visibility'] == COURSE_VISIBILITY_OPEN_PLATFORM);
+                    // 3. the user is logged in and the user is subscribed to the course and the course visibility is not COURSE_VISIBILITY_CLOSED;
+                    // 4. the user is logged in and the user is course admin of te course (regardless of the course visibility setting);
+                    // 5. the user is the platform admin api_is_platform_admin().
+                    //
+                    $courses_shown++;
+					$courses_list_string .= "<li>\n";
+					if ($course['visibility'] == COURSE_VISIBILITY_OPEN_WORLD
+                        || ($user_identified && $course['visibility'] == COURSE_VISIBILITY_OPEN_PLATFORM)
+                        || ($user_identified && key_exists($course['code'], $courses_of_user) && $course['visibility'] != COURSE_VISIBILITY_CLOSED)
+                        || $courses_of_user[$course['code']]['status'] == '1'
+                        || api_is_platform_admin()) {
+                            $courses_list_string .= '<a href="'.$web_course_path.$course['directory'].'/">';
+                        }
+                        $courses_list_string .= $course['title'];
+                    if ($course['visibility'] == COURSE_VISIBILITY_OPEN_WORLD
+						|| ($user_identified && $course['visibility'] == COURSE_VISIBILITY_OPEN_PLATFORM)
+						|| ($user_identified && key_exists($course['code'], $courses_of_user) && $course['visibility'] != COURSE_VISIBILITY_CLOSED)
+	                        || $courses_of_user[$course['code']]['status'] == '1'
+						|| api_is_platform_admin()) {
+                        $courses_list_string .= '</a><br />';
+                    }
+                    $course_details = array();
+                    if (api_get_setting('display_coursecode_in_courselist') == 'true') {
+                        $course_details[] = $course['visual_code'];
+                    }
+//						if (api_get_setting('display_coursecode_in_courselist') == 'true' && api_get_setting('display_teacher_in_courselist') == 'true') {
+//	                    $courses_list_string .= ' - ';
+//				}
+                    if (api_get_setting('display_teacher_in_courselist') == 'true') {
+						$course_details[] = $course['tutor_name'];
+	                }
+	                if (api_get_setting('show_different_course_language') == 'true' && $course['course_language'] != api_get_setting('platformLanguage')) {
+						$course_details[] = $course['course_language'];
+	                }
+                    if (api_get_setting('show_different_course_language') == 'true' && $course['course_language'] != api_get_setting('platformLanguage')) {
+	                    $course_details[] = $course['course_language'];
+	                }
+
+                    $courses_list_string .= implode(' - ', $course_details);
+					// We display a subscription link if:
+	                // 1. it is allowed to register for the course and if the course is not already in the courselist of the user and if the user is identiefied
+	                // 2.
+                    if ($user_identified && !key_exists($course['code'], $courses_of_user)) {
+                        if ($course['subscribe'] == '1') {
+                        $courses_list_string .= '<form action="main/auth/courses.php?action=subscribe&category='.Security::remove_XSS($_GET['category']).'" method="post">';
+                        $courses_list_string .= '<input type="hidden" name="sec_token" value="'.$stok.'">';
+                        $courses_list_string .= '<input type="hidden" name="subscribe" value="'.$course['code'].'" />';
+                            $courses_list_string .= '<input type="image" name="unsub" src="main/img/enroll.gif" alt="'.get_lang('Subscribe').'" />'.get_lang('Subscribe').'</form>';
+                        } else {
+                            $courses_list_string .= '<br />'.get_lang('SubscribingNotAllowed');
+                        }
+                    }
+                    $courses_list_string .= "</li>";
+	            } //end else
+	        } // end foreach
+	        $courses_list_string .= "</ul>";
+        }
+        if ($courses_shown > 0) {
+            // Only display the list of courses and categories if there was more than
+                    // 0 courses visible to the world (we're in the anonymous list here).
+            $result .=  $courses_list_string;
+        }
+		if ($category != '') {
+			$result .=  '<p><a href="'.api_get_self().'"> ' . Display :: return_icon('back.png', get_lang('BackToHomePage')) . get_lang('BackToHomePage') . '</a></p>';
+		}
+        return $result;
+	}
+
+	/**
+	 * The most important function here, prints the session and course list (user_portal.php)
+	 *
+	 * */
+	static function return_courses_and_sessions($user_id) {
+        $session_categories = array();
+        $load_history = (isset($_GET['history']) && intval($_GET['history']) == 1) ? true : false;
+
+		if ($load_history) {
+            //Load sessions in category in *history*
+			$session_categories = UserManager::get_sessions_by_category($user_id, true);
+		} else {
+            //Load sessions in category
+			$session_categories = UserManager::get_sessions_by_category($user_id, false);
+		}
+
+        $html = '';
+        //Showing history title
+		if ($load_history) {
+			$html .= Display::page_subheader(get_lang('HistoryTrainingSession'));
+			if (empty($session_categories)) {
+				$html .=  get_lang('YouDoNotHaveAnySessionInItsHistory');
+			}
+		}
+
+        $courses_html = '';
+        $special_courses = '';
+
+        $load_directories_preview = api_get_setting('show_documents_preview') == 'true' ? true : false;
+
+        // If we're not in the history view...
+        if (!isset($_GET['history'])) {
+            //Display special courses
+            $special_courses = CourseManager::display_special_courses($user_id, $load_directories_preview);
+            //Display courses
+            $courses_html .= CourseManager::display_courses($user_id, $load_directories_preview);
+        }
+
+        $sessions_with_category = '';
+        $sessions_with_no_category = '';
+
+        $load_directories_preview = api_get_setting('show_documents_preview') == 'true' ? true : false;
+
+		if (is_array($session_categories)) {
+            foreach ($session_categories as $session_category) {
+                $session_category_id = $session_category['session_category']['id'];
+                // Sessions and courses that are not in a session category
+                if ($session_category_id == 0) {
+
+                    // Independent sessions
+                    if (isset($session_category['sessions'])) {
+                        foreach ($session_category['sessions'] as $session) {
+
+                            $session_id = $session['session_id'];
+
+                            // Don't show empty sessions.
+                            if (count($session['courses']) < 1) {
+                                continue;
+                            }
+
+                            $html_courses_session = '';
+                            $count_courses_session = 0;
+
+                            foreach ($session['courses'] as $course) {
+                                //read only and accesible
+                                if (api_get_setting('hide_courses_in_sessions') == 'false') {
+                                    $html_courses_session .= CourseManager :: get_logged_user_course_html($course, $session_id, $load_directories_preview);
+                                }
+                                $count_courses_session++;
+                            }
+
+                            if ($count_courses_session > 0) {
+                                $params = array();
+                                $params['icon'] =  Display::return_icon('window_list.png', $session['session_name'], array('id' => 'session_img_'.$session_id), ICON_SIZE_LARGE);
+
+                                if (api_is_drh()) {
+                                    $session_link = $session['session_name'];
+                                    $params['link'] = null;
+                                } else {
+                                    $session_link = Display::tag('a', $session['session_name'], array('href'=>api_get_path(WEB_CODE_PATH).'session/index.php?session_id='.$session_id));
+                                    $params['link'] = api_get_path(WEB_CODE_PATH).'session/index.php?session_id='.$session_id;
+                                }
+
+                                $params['title'] = $session_link;
+
+                                $moved_status = SessionManager::get_session_change_user_reason($session['moved_status']);
+                                $moved_status = isset($moved_status) && !empty($moved_status) ? ' ('.$moved_status.')' : null;
+
+                                $params['subtitle'] = isset($session['coach_info']) ? $session['coach_info']['complete_name'] : null.$moved_status;
+                                $params['dates'] = $session['date_message'];
+
+                                $params['right_actions'] = '';
+                                if (api_is_platform_admin()) {
+                                    $params['right_actions'] .= '<a href="'.api_get_path(WEB_CODE_PATH).'admin/resume_session.php?id_session='.$session_id.'">';
+                                    $params['right_actions'] .= Display::return_icon('edit.png', get_lang('Edit'), array('align' => 'absmiddle'), ICON_SIZE_SMALL).'</a>';
+                                }
+
+                                if (api_get_setting('hide_courses_in_sessions') == 'false') {
+                                //	$params['extra'] .=  $html_courses_session;
+                                }
+                                $sessions_with_no_category .= CourseManager::course_item_parent(CourseManager::course_item_html($params, true), $html_courses_session);
+                            }
+                        }
+                    }
+
+				} else {
+					// All sessions included in
+                    $count_courses_session = 0;
+                    $html_sessions = '';
+                    foreach ($session_category['sessions'] as $session) {
+                        $session_id = $session['session_id'];
+                        // Don't show empty sessions.
+                        if (count($session['courses']) < 1) {
+                            continue;
+                        }
+
+                        $html_courses_session = '';
+                        $count = 0;
+                        foreach ($session['courses'] as $course) {
+                            if (api_get_setting('hide_courses_in_sessions') == 'false') {
+                                $html_courses_session .= CourseManager :: get_logged_user_course_html($course, $session_id);
+                            }
+                            $count_courses_session++;
+                            $count++;
+                        }
+
+                        $params = array();
+                        if ($count > 0) {
+                            $params['icon'] = Display::return_icon('window_list.png', $session['session_name'], array('id' => 'session_img_'.$session_id), ICON_SIZE_LARGE);
+
+                            if (api_is_drh()) {
+                                $session_link = $session['session_name'];
+                                $params['link'] = null;
+                            } else {
+                                $session_link   = Display::tag('a', $session['session_name'], array('href'=>api_get_path(WEB_CODE_PATH).'session/index.php?session_id='.$session_id));
+                                $params['link'] =  api_get_path(WEB_CODE_PATH).'session/index.php?session_id='.$session_id;
+                            }
+
+                            $params['title'] .=  $session_link;
+
+                            $moved_status = SessionManager::get_session_change_user_reason($session['moved_status']);
+                            $moved_status = isset($moved_status) && !empty($moved_status) ? ' ('.$moved_status.')' : null;
+
+                            $params['subtitle'] = isset($session['coach_info']) ? $session['coach_info']['complete_name'] : null.$moved_status;
+                            $params['dates'] = $session['date_message'];
+
+                            if (api_is_platform_admin()) {
+                                $params['right_actions'] .=  '<a href="'.api_get_path(WEB_CODE_PATH).'admin/resume_session.php?id_session='.$session_id.'">'.Display::return_icon('edit.png', get_lang('Edit'), array('align' => 'absmiddle'), ICON_SIZE_SMALL).'</a>';
+                            }
+                            $html_sessions .= CourseManager::course_item_html($params, true).$html_courses_session;
+                        }
+                    }
+
+                    if ($count_courses_session > 0) {
+                        $params = array();
+                        $params['icon'] = Display::return_icon('folder_blue.png', $session_category['session_category']['name'], array(), ICON_SIZE_LARGE);
+
+                        if (api_is_platform_admin()) {
+                            $params['right_actions'] .= '<a href="'.api_get_path(WEB_CODE_PATH).'admin/session_category_edit.php?&id='.$session_category['session_category']['id'].'">'.Display::return_icon('edit.png', get_lang('Edit'), array(), ICON_SIZE_SMALL).'</a>';
+                        }
+
+                        $params['title'] .= $session_category['session_category']['name'];
+
+                        if (api_is_platform_admin()) {
+                            $params['link']   = api_get_path(WEB_CODE_PATH).'admin/session_category_edit.php?&id='.$session_category['session_category']['id'];
+                        }
+
+                        $session_category_start_date = $session_category['session_category']['date_start'];
+                        $session_category_end_date = $session_category['session_category']['date_end'];
+
+                        if (!empty($session_category_start_date) && $session_category_start_date != '0000-00-00' && !empty($session_category_end_date) && $session_category_end_date != '0000-00-00' ) {
+                            $params['subtitle'] = sprintf(get_lang('FromDateXToDateY'), $session_category['session_category']['date_start'], $session_category['session_category']['date_end']);
+                        } else {
+                            if (!empty($session_category_start_date) && $session_category_start_date != '0000-00-00') {
+                                 $params['subtitle'] = get_lang('From').' '.$session_category_start_date;
+                            }
+                            if (!empty($session_category_end_date) && $session_category_end_date != '0000-00-00') {
+                                $params['subtitle'] = get_lang('Until').' '.$session_category_end_date;
+                            }
+                        }
+                        $sessions_with_category .= CourseManager::course_item_parent(CourseManager::course_item_html($params, true), $html_sessions);
+                    }
+				}
+			}
+		}
+        return $sessions_with_category.$sessions_with_no_category.$courses_html.$special_courses;
+	}
+
+    /**
+     * Shows a welcome message when the user doesn't have any content in the course list
+     */
+    static function return_welcome_to_course_block($tpl) {
+        $count_courses = CourseManager::count_courses();
+        $tpl = $tpl->get_template('layout/welcome_to_course.tpl');
+
+        $course_catalog_url = api_get_path(WEB_CODE_PATH).'auth/courses.php';
+        $course_list_url = api_get_path(WEB_PATH).'user_portal.php';
+
+        $tpl->assign('course_catalog_url', $course_catalog_url);
+        $tpl->assign('course_list_url', $course_list_url);
+        $tpl->assign('course_catalog_link', Display::url(get_lang('here'), $course_catalog_url));
+        $tpl->assign('course_list_link', Display::url(get_lang('here'), $course_list_url));
+        $tpl->assign('count_courses', $count_courses);
+
+        return $tpl->fetch($tpl);
+    }
+
+    /*function run() {
+        $app = $this->app;
+        $app->get('/', function() use ($app) {
+            $data = $this->app['twig']->render($app['template_style'].'/'.$app['default_template']);
+            return new Response($data, 200, array('cache-control' => 's-maxage=3600, public'));
+        });
+        if ($app['debug'] == true) {
+            $this->app->run();
+        } else {
+            //Using http cache
+           $app['http_cache']->run();
+        }
+    }*/
+}

+ 740 - 141
main/inc/lib/template.lib.php

@@ -3,20 +3,17 @@
 /* For licensing terms, see /license.txt */
 /**
  *  @author Julio Montoya <gugli100@gmail.com>
- *  @todo better organization of the class, methods and variables 
- * 
+ *  @todo better organization of the class, methods and variables
+ *
  * */
+use \ChamiloSession as Session;
 
 require_once api_get_path(LIBRARY_PATH) . 'banner.lib.php';
 require_once api_get_path(LIBRARY_PATH) . 'symfony/Twig/Autoloader.php';
 
-/*use Assetic\Asset\AssetCollection;
-use Assetic\Asset\FileAsset;
-use Assetic\Asset\GlobAsset;*/
-
 class Template {
 
-    public $style = 'default'; //see the template folder 
+    public $style = 'default'; //see the template folder
     public $preview_theme = null;
     public $theme; // the chamilo theme public_admin, chamilo, chamilo_red, etc
     public $title = null;
@@ -30,23 +27,30 @@ class Template {
     public $user_is_logged_in = false;
     public $twig = null;
     public $jquery_ui_theme;
-    public $force_plugin_load = false;
+    public $load_plugins = false; /* Loads chamilo plugins */
+    public $force_plugin_load = true;
+    public $app;
 
-    /* Loads chamilo plugins */
-    var $load_plugins = false;
-    var $params = array();
+    function __construct($title = null, $app = null) {
 
-    function __construct($title = '', $show_header = true, $show_footer = true, $show_learnpath = false, $hide_global_chat = false, $load_plugins = true) {
-        //Page title
-        $this->title = $title;
-        $this->show_learnpath = $show_learnpath;
-        $this->hide_global_chat = $hide_global_chat;
-        $this->load_plugins = $load_plugins;
-            
-         // Current themes: cupertino, smoothness, ui-lightness. Find the themes folder in main/inc/lib/javascript/jquery-ui 
-        $this->jquery_ui_theme = 'smoothness'; 
+        if (empty($app)) {
+            global $app;
+            $this->app = $app;
+        } else {
+            //ugly fix just for now
+            $this->app = $app;
+        }
+
+        $this->app['template_style'] = 'default';
+        $this->app['default_layout'] = 'layout_1_col.tpl';
+
+        $show_header        = $app['template.show_header'];
+        $show_footer        = $app['template.show_footer'];
+        $show_learnpath     = $app['template.show_learnpath'];
+        $hide_global_chat   = $app['template.hide_global_chat'];
+        $load_plugins       = $app['template.load_plugins'];
 
-        //Twig settings        
+        //Twig settings
         Twig_Autoloader::register();
 
         $template_paths = array(
@@ -96,13 +100,25 @@ class Template {
         $this->twig->addFilter('icon', new Twig_Filter_Function('Template::get_icon_path'));
         $this->twig->addFilter('format_date', new Twig_Filter_Function('Template::format_date'));
 
+        $this->app['twig'] = $this->twig;
+
+
+        //Page title
+        $this->title        = $title;
+        $this->show_learnpath = $show_learnpath;
+        $this->hide_global_chat = $hide_global_chat;
+        $this->load_plugins = $load_plugins;
+
+         // Current themes: cupertino, smoothness, ui-lightness. Find the themes folder in main/inc/lib/javascript/jquery-ui
+        $this->jquery_ui_theme = 'smoothness';
+
         //Setting system variables
         $this->set_system_parameters();
 
-        //Setting user variables 
+        //Setting user variables
         $this->set_user_parameters();
 
-        //Setting course variables 
+        //Setting course variables
         $this->set_course_parameters();
 
         //header and footer are showed by default
@@ -134,8 +150,9 @@ class Template {
                 }
             }
         }
-    }    
-    
+
+    }
+
     public static function get_icon_path($image, $size = ICON_SIZE_SMALL) {
         return Display:: return_icon($image, '', array(), $size, false, true);
     }
@@ -143,12 +160,12 @@ class Template {
     public static function format_date($timestamp, $format = null) {
         return api_format_date($timestamp, $format);
     }
-        
+
     /**
      * Return the item's url key:
-     * 
+     *
      *      c_id=xx&id=xx
-     * 
+     *
      * @param object $item
      * @return string
      */
@@ -193,7 +210,6 @@ class Template {
      * Use template system to parse the actions menu
      * @todo finish it!
      * */
-
     function set_actions($actions) {
         $action_string = '';
         if (!empty($actions)) {
@@ -218,7 +234,6 @@ class Template {
     function display_two_col_template() {
         $tpl = $this->get_template('layout/layout_2_col.tpl');
         $this->display($tpl);
-        $this->show_page_loaded_info();
     }
 
     /**
@@ -237,8 +252,8 @@ class Template {
         $this->display($tpl);
     }
 
-    /** 	  
-     * Sets the footer visibility 
+    /**
+     * Sets the footer visibility
      * @param bool true if we show the footer
      */
     function set_footer($status) {
@@ -254,7 +269,7 @@ class Template {
         $this->show_header = $status;
         $this->assign('show_header', $status);
 
-        //Toolbar                
+        //Toolbar
         $show_admin_toolbar = api_get_setting('show_admin_toolbar');
         $show_toolbar = 0;
 
@@ -277,7 +292,7 @@ class Template {
         }
         $this->assign('show_toolbar', $show_toolbar);
 
-        //Only if course is available        
+        //Only if course is available
         $show_course_shortcut = null;
         $show_course_navigation_menu = null;
 
@@ -296,7 +311,7 @@ class Template {
     }
 
     function get_template($name) {
-        return $this->style . '/' . $name;
+        return $this->app['template_style'] . '/' . $name;
     }
 
     /** Set course parameters */
@@ -323,7 +338,7 @@ class Template {
             $user_info['messages_count'] = MessageManager::get_new_messages();
             $this->user_is_logged_in = true;
         }
-        //Setting the $_u array that could be use in any template 
+        //Setting the $_u array that could be use in any template
         $this->assign('_u', $user_info);
     }
 
@@ -358,7 +373,7 @@ class Template {
     function set_css_files() {
         global $disable_js_and_css_files;
         $css = array();
-        
+
         $this->theme = api_get_visual_theme();
 
         if (!empty($this->preview_theme)) {
@@ -367,16 +382,18 @@ class Template {
 
         //Base CSS
         $css[] = api_get_cdn_path(api_get_path(WEB_CSS_PATH).'base.css');
+        //Compressed version of default + all CSS files
+        //$css[] = api_get_cdn_path(api_get_path(WEB_PATH).'web/css/'.$this->theme.'/style.css');
 
         //Default theme CSS
         $css[] = api_get_cdn_path(api_get_path(WEB_CSS_PATH).$this->theme.'/default.css');
         $css[] = api_get_cdn_path(api_get_path(WEB_CSS_PATH).'bootstrap-responsive.css');
         $css[] = api_get_cdn_path(api_get_path(WEB_CSS_PATH).'responsive.css');
-        
+
         //Extra CSS files
         $css[] = api_get_path(WEB_LIBRARY_PATH) . 'javascript/thickbox.css';
         $css[] = api_get_path(WEB_LIBRARY_PATH) . 'javascript/chosen/chosen.css';
-            
+
         if ($this->show_learnpath) {
             $css[] = api_get_path(WEB_CSS_PATH) . $this->theme . '/learnpath.css';
             $css[] = api_get_path(WEB_CSS_PATH) . $this->theme . '/scorm.css';
@@ -385,66 +402,64 @@ class Template {
         if (api_is_global_chat_enabled()) {
             $css[] = api_get_path(WEB_LIBRARY_PATH) . 'javascript/chat/css/chat.css';
         }
-        
-        $css[] = api_get_path(WEB_LIBRARY_PATH).'javascript/jquery-ui/'.$this->jquery_ui_theme.'/jquery-ui-custom.css';
-        $css[] = api_get_path(WEB_LIBRARY_PATH).'javascript/jquery-ui/default.css';         
-               
+
+        //$css[] = api_get_path(WEB_LIBRARY_PATH).'javascript/jquery-ui/'.$this->jquery_ui_theme.'/jquery-ui-custom.css';
+        //$css[] = api_get_path(WEB_LIBRARY_PATH).'javascript/jquery-ui/default.css';
+
         $css_file_to_string = null;
         foreach ($css as $file) {
-            $css_file_to_string .= api_get_css($file);
-        }    
-        
+           $css_file_to_string .= api_get_css($file);
+        }
+
         // @todo move this somewhere else. Special fix when using tablets in order to see the text near icons
         if (SHOW_TEXT_NEAR_ICONS == true) {
             //hack in order to fix the actions buttons
-            $css_file_to_string .= '<style>                
+            $css_file_to_string .= '<style>
                 .td_actions a {
                     float:left;
                     width:100%;
-                }                
+                }
                 .forum_message_left a {
                     float:left;
                     width:100%;
                 }
                 </style>';
         }
-        
+
         $navigator_info = api_get_navigator();
         if ($navigator_info['name'] == 'Internet Explorer' && $navigator_info['version'] == '6') {
             $css_file_to_string .= 'img, div { behavior: url(' . api_get_path(WEB_LIBRARY_PATH) . 'javascript/iepngfix/iepngfix.htc) } ' . "\n";
         }
-        
+
         if (!$disable_js_and_css_files) {
             $this->assign('css_file_to_string', $css_file_to_string);
-            
+
             $style_print = api_get_css(api_get_cdn_path(api_get_path(WEB_CSS_PATH) . $this->theme . '/print.css'), 'print');
             $this->assign('css_style_print', $style_print);
         }
-        
+
         // Logo
-        $logo = return_logo($this->theme);
+        $logo = $this->return_logo($this->theme);
         $this->assign('logo', $logo);
     }
-    
+
     function set_js_files() {
         global $disable_js_and_css_files, $htmlHeadXtra;
-    
-        
-        //JS files        
+        //JS files
         $js_files = array(
-            'modernizr.js',
+          'modernizr.js',
             'jquery.min.js',
             'chosen/chosen.jquery.min.js',
-            'jquery-ui/'.$this->jquery_ui_theme.'/jquery-ui-custom.min.js',      
-            'thickbox.js',            
+            'jquery-ui/'.$this->jquery_ui_theme.'/jquery-ui-custom.min.js',
+            'thickbox.js',
             'bootstrap/bootstrap.js',
         );
-        
-        if (api_is_global_chat_enabled()) {           
+
+        if (api_is_global_chat_enabled()) {
             //Do not include the global chat in LP
             if ($this->show_learnpath == false && $this->show_footer == true && $this->hide_global_chat == false) {
                 $js_files[] = 'chat/js/chat.js';
-            }            
+            }
         }
 
         if (api_get_setting('accessibility_font_resize') == 'true') {
@@ -453,23 +468,25 @@ class Template {
 
         if (api_get_setting('include_asciimathml_script') == 'true') {
             $js_files[] = 'asciimath/ASCIIMathML.js';
-        }       
-        
+        }
+
         $js_file_to_string = null;
-        
+
         foreach ($js_files as $js_file) {
             $js_file_to_string .= api_get_js($js_file);
         }
-        
+
         //Loading email_editor js
         if (!api_is_anonymous() && api_get_setting('allow_email_editor') == 'true') {
-            $js_file_to_string .= $this->fetch('default/mail_editor/email_link.js.tpl');            
+            $js_file_to_string .= $this->fetch('default/mail_editor/email_link.js.tpl');
         }
-        
-        if (!$disable_js_and_css_files) {       
+
+        //$js_file_to_string = api_get_js_simple(api_get_path(WEB_PATH).'web/js/script.js').$js_file_to_string;
+
+        if (!$disable_js_and_css_files) {
             $this->assign('js_file_to_string', $js_file_to_string);
-            
-            $extra_headers = null;            
+
+            $extra_headers = null;
             if (isset($htmlHeadXtra) && $htmlHeadXtra) {
                 foreach ($htmlHeadXtra as & $this_html_head) {
                     $extra_headers .= $this_html_head . "\n";
@@ -482,25 +499,23 @@ class Template {
     /**
      * Set header parameters
      */
-    private function set_header_parameters() {        
-        global $httpHeadXtra, $_course, $interbreadcrumb, $language_file, $noPHP_SELF, $_configuration, $this_section;
-        $help = $this->help;
+    private function set_header_parameters() {
+        global $httpHeadXtra, $_course, $interbreadcrumb, $language_file, $_configuration, $this_section;
         $nameTools = $this->title;
-        $navigation = return_navigation_array();
+        $navigation = $this->return_navigation_array();
         $this->menu_navigation = $navigation['menu_navigation'];
 
         $this->assign('system_charset', api_get_system_encoding());
 
         if (isset($httpHeadXtra) && $httpHeadXtra) {
             foreach ($httpHeadXtra as & $thisHttpHead) {
-                header($thisHttpHead);
+                //header($thisHttpHead);
             }
         }
 
         $this->assign('online_button', Security::remove_XSS(Display::return_icon('online.png')));
         $this->assign('offline_button', Security::remove_XSS(Display::return_icon('offline.png')));
-
-        // Get language iso-code for this page - ignore errors				
+        // Get language iso-code for this page - ignore errors
         $this->assign('document_language', api_get_language_isocode());
 
         $course_title = $_course['name'];
@@ -516,7 +531,7 @@ class Template {
         if ($nameTools != '') {
             $title_list[] = $nameTools;
         }
-        
+
         $title_string = '';
         for ($i = 0; $i < count($title_list); $i++) {
             $title_string .=$title_list[$i];
@@ -528,12 +543,12 @@ class Template {
         }
 
         $this->assign('title_string', $title_string);
-               
+
         //Setting the theme and CSS files
         $this->set_css_files();
         $this->set_js_files();
-        
-        // Implementation of prefetch. 
+
+        // Implementation of prefetch.
         // See http://cdn.chamilo.org/main/img/online.png for details
         $prefetch = '';
         if (!empty($_configuration['cdn_enable'])) {
@@ -542,7 +557,7 @@ class Template {
                 $prefetch .= '<link rel="dns-prefetch" href="' . $host . '">';
             }
         }
-        
+
         $this->assign('prefetch', $prefetch);
         $this->assign('text_direction', api_get_text_direction());
         $this->assign('section_name', 'section-' . $this_section);
@@ -579,67 +594,43 @@ class Template {
 		        						<img src="' . api_get_path(WEB_IMG_PATH) . 'bug.large.png" style="vertical-align: middle;" alt="' . get_lang('ReportABug') . '" title="' . get_lang('ReportABug') . '"/></a>
 		    						  </li>';
         }
-
         $this->assign('bug_notification_link', $bug_notification_link);
 
-        $notification = return_notification_menu();
-        $this->assign('notification_menu', $notification);        
-        
+        $notification = $this->return_notification_menu();
+        $this->assign('notification_menu', $notification);
+
         //Preparing values for the menu
-        
+
         //Logout link
-        $this->assign('logout_link', api_get_path(WEB_PATH).'index.php?logout=logout&&uid='.api_get_user_id());        
-        
+        $this->assign('logout_link', api_get_path(WEB_PATH).'index.php?logout=logout&uid='.api_get_user_id());
+
         //Profile link
         if (api_get_setting('allow_social_tool') == 'true') {
-            $profile_url = api_get_path(WEB_CODE_PATH).'social/home.php';
-            $profile_link = Display::url(get_lang('Profile'), $profile_url);
+            $profile_link = '<a href="'.api_get_path(WEB_CODE_PATH).'social/home.php">'.get_lang('Profile').'</a>';
         } else {
-            $profile_url = api_get_path(WEB_CODE_PATH).'auth/profile.php';            
-            $profile_link = Display::url(get_lang('Profile'), $profile_url);
+            $profile_link = '<a href="'.api_get_path(WEB_CODE_PATH).'auth/profile.php">'.get_lang('Profile').'</a>';
         }
         $this->assign('profile_link', $profile_link);
-        $this->assign('profile_url', $profile_url);
-        
+
         //Message link
         $message_link = null;
         if (api_get_setting('allow_message_tool') == 'true') {
             $message_link = '<a href="'.api_get_path(WEB_CODE_PATH).'messages/inbox.php">'.get_lang('Inbox').'</a>';
         }
         $this->assign('message_link', $message_link);
-        
+
         $institution = api_get_setting('Institution');
         $portal_name = empty($institution) ? api_get_setting('siteName') : $institution;
-        
+
         $this->assign('portal_name', $portal_name);
+
         //Menu
-        $menu = return_menu();
+        $menu = $this->return_menu();
+
         $this->assign('menu', $menu);
-        
-        //Setting notifications
-        
-           
-        $count_unread_message = 0;
-        if (api_get_setting('allow_message_tool')=='true') {
-            // get count unread message and total invitations
-            $count_unread_message = MessageManager::get_number_of_messages(true);
-        }
 
-        $total_invitations = 0;
-        if (api_get_setting('allow_social_tool')=='true') {
-            $number_of_new_messages_of_friend   = SocialManager::get_message_number_invitation_by_user_id(api_get_user_id());
-            $group_pending_invitations = GroupPortalManager::get_groups_by_user(api_get_user_id(), GROUP_USER_PERMISSION_PENDING_INVITATION,false);
-            $group_pending_invitations = 0;
-            if (!empty($group_pending_invitations )) {
-                $group_pending_invitations = count($group_pending_invitations);
-            }
-            $total_invitations = intval($number_of_new_messages_of_friend) + $group_pending_invitations + intval($count_unread_message);
-        }        
-        $total_invitations = (!empty($total_invitations) ? Display::badge($total_invitations) : null);    
-                
-        $this->assign('user_notifications', $total_invitations);
-        //Breadcrumb        
-        $breadcrumb = return_breadcrumb($interbreadcrumb, $language_file, $nameTools);
+        //Breadcrumb
+        $breadcrumb = $this->return_breadcrumb($interbreadcrumb, $language_file, $nameTools);
         $this->assign('breadcrumb', $breadcrumb);
 
         //Extra content
@@ -648,10 +639,10 @@ class Template {
             $extra_header = trim(api_get_setting('header_extra_content'));
         }
         $this->assign('header_extra_content', $extra_header);
-        
+
         if ($this->show_header == 1) {
-            header('Content-Type: text/html; charset=' . api_get_system_encoding());
-            header('X-Powered-By: ' . $_configuration['software_name'] . ' ' . substr($_configuration['system_version'], 0, 1));
+            //header('Content-Type: text/html; charset=' . api_get_system_encoding());
+            //header('X-Powered-By: ' . $_configuration['software_name'] . ' ' . substr($_configuration['system_version'], 0, 1));
         }
     }
 
@@ -727,7 +718,7 @@ class Template {
                 $this->assign('teachers', $teacher_data);
             }
         }
-        /* $stats = '';	
+        /* $stats = '';
           $this->assign('execution_stats', $stats); */
     }
 
@@ -738,9 +729,7 @@ class Template {
 
     function show_footer_template() {
         $tpl = $this->get_template('layout/show_footer.tpl');
-        $this->show_page_loaded_info();
         $this->display($tpl);
-        
     }
 
     /* Sets the plugin content in a template variable */
@@ -757,26 +746,636 @@ class Template {
     }
 
     public function fetch($template = null) {
-        $template = $this->twig->loadTemplate($template);
-        return $template->render($this->params);
+        $template = $this->app['twig']->loadTemplate($template);
+        return $template->render(array());
     }
 
-    public function assign($tpl_var, $value = null) {
-        $this->params[$tpl_var] = $value;
+    public function assign($key, $value = null) {
+        $this->app['twig']->addGlobal($key, $value);
     }
 
     public function display($template) {
-        echo $this->twig->render($template, $this->params);
+        echo $this->app['twig']->render($template);
     }
-    
-    function show_page_loaded_info() {   
+
+    function show_page_loaded_info() {
         //@todo will be removed before a stable release
-        $mtime = microtime(); 
-        $mtime = explode(" ",$mtime); 
-        $mtime = $mtime[1] + $mtime[0]; 
+        $mtime = microtime();
+        $mtime = explode(" ",$mtime);
+        $mtime = $mtime[1] + $mtime[0];
         error_log('--------------------------------------------------------');
         error_log("Page loaded in:".($mtime-START));
         error_log("memory_get_usage: ".format_file_size(memory_get_usage(true)));
         error_log("memory_get_peak_usage: ".format_file_size(memory_get_peak_usage(true)));
     }
-}
+
+    function return_menu() {
+        $navigation         = $this->return_navigation_array();
+        $navigation         = $navigation['navigation'];
+
+        // Displaying the tabs
+
+        $lang = ''; //el for "Edit Language"
+        //$user_language_choice = Session::get('user_language_choice');
+        $user_language_choice = isset($_SESSION['user_language_choice']) ? $_SESSION['user_language_choice'] : null;
+        $user_info = api_get_user_id() ? api_get_user_info() : null;
+
+        if (!empty($user_language_choice)) {
+            $lang = $user_language_choice;
+        } elseif (!empty($user_info['language'])) {
+            $lang = $user_info['language'];
+        } else {
+            $lang = api_get_setting('platformLanguage');
+        }
+
+        //Preparing home folder for multiple urls
+
+        if (api_get_multiple_access_url()) {
+            $access_url_id = api_get_current_access_url_id();
+            if ($access_url_id != -1) {
+                $url_info = api_get_access_url($access_url_id);
+                $url = api_remove_trailing_slash(preg_replace('/https?:\/\//i', '', $url_info['url']));
+                $clean_url = replace_dangerous_char($url);
+                $clean_url = str_replace('/', '-', $clean_url);
+                $clean_url .= '/';
+                $homep     = api_get_path(SYS_PATH).'home/'.$clean_url; //homep for Home Path
+                //we create the new dir for the new sites
+                if (!is_dir($homep)) {
+                    mkdir($homep, api_get_permissions_for_new_directories());
+                }
+            }
+        } else {
+            $homep = api_get_path(SYS_PATH).'home/';
+        }
+
+        $ext      = '.html';
+        $menutabs = 'home_tabs';
+        $home_top = '';
+
+        if (is_file($homep.$menutabs.'_'.$lang.$ext) && is_readable($homep.$menutabs.'_'.$lang.$ext)) {
+            $home_top = @(string)file_get_contents($homep.$menutabs.'_'.$lang.$ext);
+        } elseif (is_file($homep.$menutabs.$lang.$ext) && is_readable($homep.$menutabs.$lang.$ext)) {
+            $home_top = @(string)file_get_contents($homep.$menutabs.$lang.$ext);
+        } else {
+            //$errorMsg = get_lang('HomePageFilesNotReadable');
+        }
+
+        $home_top = api_to_system_encoding($home_top, api_detect_encoding(strip_tags($home_top)));
+
+        $open = str_replace('{rel_path}',api_get_path(REL_PATH), $home_top);
+        $open = api_to_system_encoding($open, api_detect_encoding(strip_tags($open)));
+
+        $lis = '';
+
+        if (!empty($open)) {
+            if (strpos($open, 'show_menu') === false) {
+                if (api_is_anonymous()) {
+                    $navigation[SECTION_CAMPUS]  = null;
+                }
+            } else {
+                //$lis .= Display::tag('li', $open);
+                $lis .= $open;
+            }
+        }
+
+        if (count($navigation) > 0 || !empty($lis)) {
+            $pre_lis = '';
+            foreach ($navigation as $section => $navigation_info) {
+                if (isset($GLOBALS['this_section'])) {
+                    $current = $section == $GLOBALS['this_section'] ? ' id="current" class="active" ' : '';
+                } else {
+                    $current = '';
+                }
+                if (!empty($navigation_info['title'])) {
+                    $pre_lis .= '<li'.$current.' ><a  href="'.$navigation_info['url'].'" target="_top">'.$navigation_info['title'].'</a></li>';
+                }
+            }
+            $lis = $pre_lis.$lis;
+        }
+
+        $menu = null;
+        if (!empty($lis)) {
+             $menu .= $lis;
+        }
+        return $menu;
+    }
+
+    function return_navigation_links() {
+		$html = '';
+
+		// Deleting the myprofile link.
+		if (api_get_setting('allow_social_tool') == 'true') {
+			unset($this->menu_navigation['myprofile']);
+		}
+
+		// Main navigation section.
+		// Tabs that are deactivated are added here.
+		if (!empty($this->menu_navigation)) {
+			$content = '<ul class="nav nav-list">';
+			foreach ($this->menu_navigation as $section => $navigation_info) {
+				$current = $section == $GLOBALS['this_section'] ? ' id="current"' : '';
+				$content .= '<li'.$current.'>';
+				$content .= '<a href="'.$navigation_info['url'].'" target="_self">'.$navigation_info['title'].'</a>';
+				$content .= '</li>';
+			}
+			$content .= '</ul>';
+			$html = PageController::show_right_block(get_lang('MainNavigation'), $content, 'navigation_link_block');
+		}
+		return $html;
+	}
+
+    function render_layout($layout = null) {
+        if (empty($layout)) {
+            $layout = $this->app['default_layout'];
+        }
+        return $this->app['twig']->render($this->app['template_style'].'/layout/'.$layout);
+    }
+
+    function render_template($template) {
+        return $this->app['twig']->render($this->app['template_style'].'/'.$template);
+    }
+
+
+    /**
+     * Determines the possible tabs (=sections) that are available.
+     * This function is used when creating the tabs in the third header line and
+     * all the sections that do not appear there (as determined by the
+     * platform admin on the Dokeos configuration settings page)
+     * will appear in the right hand menu that appears on several other pages
+     * @return array containing all the possible tabs
+     * @author Patrick Cool <patrick.cool@UGent.be>, Ghent University
+     */
+    function get_tabs() {
+        global $_course;
+
+        $navigation = array();
+
+        // Campus Homepage
+        $navigation[SECTION_CAMPUS]['url'] = api_get_path(WEB_PATH).'index.php';
+        $navigation[SECTION_CAMPUS]['title'] = get_lang('CampusHomepage');
+
+        // My Courses
+
+        if(api_is_allowed_to_create_course()) {
+            // Link to my courses for teachers
+            $navigation['mycourses']['url'] = api_get_path(WEB_PATH).'user_portal.php?nosession=true';
+            $navigation['mycourses']['title'] = get_lang('MyCourses');
+        } else {
+            // Link to my courses for students
+            $navigation['mycourses']['url'] = api_get_path(WEB_PATH).'user_portal.php';
+            $navigation['mycourses']['title'] = get_lang('MyCourses');
+        }
+
+        // My Profile
+        $navigation['myprofile']['url'] = api_get_path(WEB_CODE_PATH).'auth/profile.php'.(!empty($_course['path']) ? '?coursePath='.$_course['path'].'&amp;courseCode='.$_course['official_code'] : '' );
+        $navigation['myprofile']['title'] = get_lang('ModifyProfile');
+
+        // Link to my agenda
+        $navigation['myagenda']['url'] = api_get_path(WEB_CODE_PATH).'calendar/agenda_js.php?type=personal';
+        $navigation['myagenda']['title'] = get_lang('MyAgenda');
+
+        // Gradebook
+        if (api_get_setting('gradebook_enable') == 'true') {
+            $navigation['mygradebook']['url'] = api_get_path(WEB_CODE_PATH).'gradebook/gradebook.php'.(!empty($_course['path']) ? '?coursePath='.$_course['path'].'&amp;courseCode='.$_course['official_code'] : '' );
+            $navigation['mygradebook']['title'] = get_lang('MyGradebook');
+        }
+
+        // Reporting
+        if (api_is_allowed_to_create_course() || api_is_drh() || api_is_session_admin()) {
+            // Link to my space
+            $navigation['session_my_space']['url'] = api_get_path(WEB_CODE_PATH).'mySpace/';
+            $navigation['session_my_space']['title'] = get_lang('MySpace');
+        } else {
+            // Link to my progress
+            $navigation['session_my_progress']['url'] = api_get_path(WEB_CODE_PATH).'auth/my_progress.php';
+            $navigation['session_my_progress']['title'] = get_lang('MyProgress');
+        }
+
+        // Social
+        if (api_get_setting('allow_social_tool')=='true') {
+            $navigation['social']['url'] = api_get_path(WEB_CODE_PATH).'social/home.php';
+
+            // get count unread message and total invitations
+            $count_unread_message = MessageManager::get_number_of_messages(true);
+
+            $number_of_new_messages_of_friend   = SocialManager::get_message_number_invitation_by_user_id(api_get_user_id());
+            $group_pending_invitations = GroupPortalManager::get_groups_by_user(api_get_user_id(), GROUP_USER_PERMISSION_PENDING_INVITATION,false);
+            $group_pending_invitations = 0;
+            if (!empty($group_pending_invitations )) {
+                $group_pending_invitations = count($group_pending_invitations);
+            }
+            $total_invitations = intval($number_of_new_messages_of_friend) + $group_pending_invitations + intval($count_unread_message);
+            $total_invitations = (!empty($total_invitations) ? Display::badge($total_invitations) :'');
+
+            $navigation['social']['title'] = get_lang('SocialNetwork'). $total_invitations;
+        }
+
+        // Dashboard
+        if (api_is_platform_admin() || api_is_drh() || api_is_session_admin()) {
+            $navigation['dashboard']['url'] = api_get_path(WEB_CODE_PATH).'dashboard/index.php';
+            $navigation['dashboard']['title'] = get_lang('Dashboard');
+        }
+
+        // Reports
+        /*
+        if (api_is_platform_admin() || api_is_drh() || api_is_session_admin()) {
+            $navigation['reports']['url'] = api_get_path(WEB_CODE_PATH).'reports/index.php';
+            $navigation['reports']['title'] = get_lang('Reports');
+        }*/
+
+        // Custom tabs
+        for ($i = 1; $i<=3; $i++)
+            if (api_get_setting('custom_tab_'.$i.'_name') && api_get_setting('custom_tab_'.$i.'_url')) {
+                $navigation['custom_tab_'.$i]['url'] = api_get_setting('custom_tab_'.$i.'_url');
+                $navigation['custom_tab_'.$i]['title'] = api_get_setting('custom_tab_'.$i.'_name');
+            }
+
+        // Platform administration
+        if (api_is_platform_admin(true)) {
+            $navigation['platform_admin']['url'] = api_get_path(WEB_CODE_PATH).'admin/';
+            $navigation['platform_admin']['title'] = get_lang('PlatformAdmin');
+        }
+        return $navigation;
+    }
+
+    function return_logo($theme) {
+        $_course = api_get_course_info();
+        $html = '';
+        $logo = api_get_path(SYS_CODE_PATH).'css/'.$theme.'/images/header-logo.png';
+
+        $site_name = api_get_setting('siteName');
+        if (file_exists($logo)) {
+            $site_name = api_get_setting('Institution').' - '.$site_name;
+            $html .= '<div id="logo">';
+                $image_url = api_get_path(WEB_CSS_PATH).$theme.'/images/header-logo.png';
+                $logo = Display::img($image_url, $site_name, array('title'=>$site_name));
+                $html .= Display::url($logo, api_get_path(WEB_PATH).'index.php');
+            $html .= '</div>';
+        } else {
+            $html .= '<a href="'.api_get_path(WEB_PATH).'index.php" target="_top">'.$site_name.'</a>';
+            $iurl  = api_get_setting('InstitutionUrl');
+            $iname = api_get_setting('Institution');
+
+            if (!empty($iname)) {
+                $html .= '-&nbsp;<a href="'.$iurl.'" target="_top">'.$iname.'</a>';
+            }
+            // External link section a.k.a Department - Department URL
+            if (isset($_course['extLink']) && $_course['extLink']['name'] != '') {
+                $html .= '<span class="extLinkSeparator"> - </span>';
+                if ($_course['extLink']['url'] != '') {
+                    $html .= '<a class="extLink" href="'.$_course['extLink']['url'].'" target="_top">';
+                    $html .= $_course['extLink']['name'];
+                    $html .= '</a>';
+                } else {
+                    $html .= $_course['extLink']['name'];
+                }
+            }
+        }
+
+       /* //  Course title section
+        if (!empty($_cid) and $_cid != -1 and isset($_course)) {
+            //Put the name of the course in the header
+            $html .= '<div id="my_courses">';
+            $html .= '</div>';
+        } elseif (isset($nameTools) && $language_file != 'course_home') {
+            //Put the name of the user-tools in the header
+            if (!isset($user_id)) {
+                //echo '<div id="my_courses"></div>';
+            } elseif (!$noPHP_SELF) {
+                $html .= '<div id="my_courses"><a href="'.api_get_self().'?'.api_get_cidreq(). '" target="_top">'.$nameTools.'</a></div>';
+            } else {
+                $html .= '<div id="my_courses">'.$nameTools.'</div>';
+            }
+        }*/
+        return $html;
+    }
+
+    function return_notification_menu() {
+
+        $_course    = api_get_course_info();
+        $course_id  = api_get_course_id();
+        $user_id    = api_get_user_id();
+
+        $html = '';
+
+        if ((api_get_setting('showonline', 'world') == 'true' AND !$user_id) OR (api_get_setting('showonline', 'users') == 'true' AND $user_id) OR (api_get_setting('showonline', 'course') == 'true' AND $user_id AND $course_id)) {
+            $number = who_is_online_count(api_get_setting('time_limit_whosonline'));
+
+            $number_online_in_course = 0;
+            if(!empty($_course['id'])) {
+                $number_online_in_course = who_is_online_in_this_course_count($user_id, api_get_setting('time_limit_whosonline'), $_course['id']);
+            }
+
+            // Display the who's online of the platform
+            if ($number) {
+                if ((api_get_setting('showonline', 'world') == 'true' AND !$user_id) OR (api_get_setting('showonline', 'users') == 'true' AND $user_id)) {
+                    $html .= '<li><a href="'.api_get_path(WEB_PATH).'whoisonline.php" target="_top" title="'.get_lang('UsersOnline').'" >'.
+                                Display::return_icon('user.png', get_lang('UsersOnline'), array(), ICON_SIZE_TINY).' '.$number.'</a></li>';
+                }
+            }
+
+            // Display the who's online for the course
+            if ($number_online_in_course) {
+                if (is_array($_course) AND api_get_setting('showonline', 'course') == 'true' AND isset($_course['sysCode'])) {
+                    $html .= '<li><a href="'.api_get_path(WEB_PATH).'whoisonline.php?cidReq='.$_course['sysCode'].'" target="_top">'.
+                            Display::return_icon('course.png', get_lang('UsersOnline').' '.get_lang('InThisCourse'), array(), ICON_SIZE_TINY).' '.$number_online_in_course.' </a></li>';
+                }
+            }
+
+            // Display the who's online for the session
+            if (isset($user_id) && api_get_session_id() != 0) {
+                if (api_is_allowed_to_edit()) {
+                    $html .= '<li><a href="'.api_get_path(WEB_PATH).'whoisonlinesession.php?session_id='.api_get_session_id().'&id_coach='.$user_id.'" >'.
+                        Display::return_icon('session.png', get_lang('UsersConnectedToMySessions'), array(), ICON_SIZE_TINY).' </a></li>';
+                }
+            }
+        }
+
+        if (api_get_setting('accessibility_font_resize') == 'true') {
+            $html .= '<li class="resize_font">';
+            $html .= '<span class="decrease_font" title="'.get_lang('DecreaseFontSize').'">A</span> <span class="reset_font" title="'.get_lang('ResetFontSize').'">A</span> <span class="increase_font" title="'.get_lang('IncreaseFontSize').'">A</span>';
+            $html .= '</li>';
+        }
+        return $html;
+    }
+
+    function return_navigation_array() {
+
+        $navigation         = array();
+        $menu_navigation    = array();
+        $possible_tabs      = $this->get_tabs();
+
+        // Campus Homepage
+        if (api_get_setting('show_tabs', 'campus_homepage') == 'true') {
+            $navigation[SECTION_CAMPUS] = $possible_tabs[SECTION_CAMPUS];
+        } else {
+            $menu_navigation[SECTION_CAMPUS] = $possible_tabs[SECTION_CAMPUS];
+        }
+
+        if (api_get_user_id() && !api_is_anonymous()) {
+
+            // My Courses
+            if (api_get_setting('show_tabs', 'my_courses') == 'true') {
+                $navigation['mycourses'] = $possible_tabs['mycourses'];
+            } else {
+                $menu_navigation['mycourses'] = $possible_tabs['mycourses'];
+            }
+
+            // My Profile
+            if (api_get_setting('show_tabs', 'my_profile') == 'true' && api_get_setting('allow_social_tool') != 'true') {
+                $navigation['myprofile'] = $possible_tabs['myprofile'];
+            } else {
+                $menu_navigation['myprofile'] = $possible_tabs['myprofile'];
+            }
+
+            // My Agenda
+            if (api_get_setting('show_tabs', 'my_agenda') == 'true') {
+                $navigation['myagenda'] = $possible_tabs['myagenda'];
+            } else {
+                $menu_navigation['myagenda'] = $possible_tabs['myagenda'];
+            }
+
+            // Gradebook
+            if (api_get_setting('gradebook_enable') == 'true') {
+                if (api_get_setting('show_tabs', 'my_gradebook') == 'true') {
+                    $navigation['mygradebook'] = $possible_tabs['mygradebook'];
+                } else{
+                    $menu_navigation['mygradebook'] = $possible_tabs['mygradebook'];
+                }
+            }
+
+            // Reporting
+            if (api_get_setting('show_tabs', 'reporting') == 'true') {
+                if (api_is_allowed_to_create_course() || api_is_drh() || api_is_session_admin()) {
+                    $navigation['session_my_space'] = $possible_tabs['session_my_space'];
+                } else {
+                    $navigation['session_my_space'] = $possible_tabs['session_my_progress'];
+                }
+            } else {
+                if (api_is_allowed_to_create_course() || api_is_drh() || api_is_session_admin()) {
+                    $menu_navigation['session_my_space'] = $possible_tabs['session_my_space'];
+                } else {
+                    $menu_navigation['session_my_space'] = $possible_tabs['session_my_progress'];
+                }
+            }
+
+            // Social Networking
+            if (api_get_setting('show_tabs', 'social') == 'true') {
+                if (api_get_setting('allow_social_tool') == 'true') {
+                    $navigation['social'] = $possible_tabs['social'];
+                }
+            } else{
+                $menu_navigation['social'] = isset($possible_tabs['social']) ? $possible_tabs['social'] : null;
+            }
+
+            // Dashboard
+            if (api_get_setting('show_tabs', 'dashboard') == 'true') {
+                if (api_is_platform_admin() || api_is_drh() || api_is_session_admin()) {
+                    $navigation['dashboard'] = $possible_tabs['dashboard'];
+                }
+            } else{
+                $menu_navigation['dashboard'] = isset($possible_tabs['dashboard']) ? $possible_tabs['dashboard'] : null;
+            }
+
+            // Administration
+            if (api_is_platform_admin(true)) {
+                if (api_get_setting('show_tabs', 'platform_administration') == 'true') {
+                    $navigation['platform_admin'] = $possible_tabs['platform_admin'];
+                } else {
+                    $menu_navigation['platform_admin'] = $possible_tabs['platform_admin'];
+                }
+            }
+
+            // Reports
+            if (!empty($possible_tabs['reports'])) {
+                if (api_get_setting('show_tabs', 'reports') == 'true') {
+                    if ((api_is_platform_admin() || api_is_drh() || api_is_session_admin()) && Rights::hasRight('show_tabs:reports')) {
+                        $navigation['reports'] = $possible_tabs['reports'];
+                    }
+                } else {
+                    $menu_navigation['reports'] = $possible_tabs['reports'];
+                }
+            }
+
+            // Custom tabs
+            for ($i=1;$i<=3;$i++)
+                if (api_get_setting('show_tabs', 'custom_tab_'.$i) == 'true') {
+                    $navigation['custom_tab_'.$i] = $possible_tabs['custom_tab_'.$i];
+                } else {
+                    if (isset($possible_tabs['custom_tab_'.$i])) {
+                        $menu_navigation['custom_tab_'.$i] = $possible_tabs['custom_tab_'.$i];
+                    }
+                }
+        }
+        $return = array('menu_navigation' => $menu_navigation, 'navigation' => $navigation, 'possible_tabs' => $possible_tabs);
+        return $return;
+    }
+
+
+    function return_breadcrumb($interbreadcrumb, $language_file, $nameTools) {
+
+        $session_id     = api_get_session_id();
+        $session_name   = api_get_session_name($session_id);
+        $_course        = api_get_course_info();
+        $user_id        = api_get_user_id();
+        $course_id      = api_get_course_id();
+
+
+        /*  Plugins for banner section */
+        $web_course_path = api_get_path(WEB_COURSE_PATH);
+
+        /* If the user is a coach he can see the users who are logged in its session */
+        $navigation = array();
+
+        // part 1: Course Homepage. If we are in a course then the first breadcrumb is a link to the course homepage
+        // hide_course_breadcrumb the parameter has been added to hide the name of the course, that appeared in the default $interbreadcrumb
+        $session_name = cut($session_name, MAX_LENGTH_BREADCRUMB);
+        $my_session_name = is_null($session_name) ? '' : '&nbsp;('.$session_name.')';
+
+        if (!empty($_course) && !isset($_GET['hide_course_breadcrumb'])) {
+
+            $navigation_item['url'] = $web_course_path . $_course['path'].'/index.php'.(!empty($session_id) ? '?id_session='.$session_id : '');
+            $course_title = cut($_course['name'], MAX_LENGTH_BREADCRUMB);
+
+            switch (api_get_setting('breadcrumbs_course_homepage')) {
+                case 'get_lang':
+                    $navigation_item['title'] = Display::img(api_get_path(WEB_CSS_PATH).'home.png', get_lang('CourseHomepageLink')).' '.get_lang('CourseHomepageLink');
+                    break;
+                case 'course_code':
+                    $navigation_item['title'] = Display::img(api_get_path(WEB_CSS_PATH).'home.png', $_course['official_code']).' '.$_course['official_code'];
+                    break;
+                case 'session_name_and_course_title':
+                    $navigation_item['title'] = Display::img(api_get_path(WEB_CSS_PATH).'home.png', $_course['name'].$my_session_name).' '.$course_title.$my_session_name;
+                    break;
+                default:
+                    if (api_get_session_id() != -1 ) {
+                        $navigation_item['title'] = Display::img(api_get_path(WEB_CSS_PATH).'home.png', $_course['name'].$my_session_name).' '.$course_title.$my_session_name;
+                    } else {
+                        $navigation_item['title'] = Display::img(api_get_path(WEB_CSS_PATH).'home.png', $_course['name']).' '.$course_title;
+                    }
+                    break;
+            }
+            /**
+             * @todo could be useful adding the My courses in the breadcrumb
+            $navigation_item_my_courses['title'] = get_lang('MyCourses');
+            $navigation_item_my_courses['url'] = api_get_path(WEB_PATH).'user_portal.php';
+            $navigation[] = $navigation_item_my_courses;
+            */
+            $navigation[] = $navigation_item;
+        }
+
+        // part 2: Interbreadcrumbs. If there is an array $interbreadcrumb defined then these have to appear before the last breadcrumb (which is the tool itself)
+        if (isset($interbreadcrumb) && is_array($interbreadcrumb)) {
+            foreach ($interbreadcrumb as $breadcrumb_step) {
+                if ($breadcrumb_step['url'] != '#') {
+                    $sep = (strrchr($breadcrumb_step['url'], '?') ? '&amp;' : '?');
+                    $navigation_item['url'] = $breadcrumb_step['url'].$sep.api_get_cidreq();
+                } else {
+                    $navigation_item['url'] = '#';
+                }
+                $navigation_item['title'] = $breadcrumb_step['name'];
+                // titles for shared folders
+                if ($breadcrumb_step['name'] == 'shared_folder') {
+                    $navigation_item['title'] = get_lang('UserFolders');
+                } elseif(strstr($breadcrumb_step['name'], 'shared_folder_session_')) {
+                    $navigation_item['title'] = get_lang('UserFolders');
+                } elseif(strstr($breadcrumb_step['name'], 'sf_user_')) {
+                    $userinfo = Database::get_user_info_from_id(substr($breadcrumb_step['name'], 8));
+                    $navigation_item['title'] = api_get_person_name($userinfo['firstname'], $userinfo['lastname']);
+                } elseif($breadcrumb_step['name'] == 'chat_files') {
+                    $navigation_item['title'] = get_lang('ChatFiles');
+                } elseif($breadcrumb_step['name'] == 'images') {
+                    $navigation_item['title'] = get_lang('Images');
+                } elseif($breadcrumb_step['name'] == 'video') {
+                    $navigation_item['title'] = get_lang('Video');
+                } elseif($breadcrumb_step['name'] == 'audio') {
+                    $navigation_item['title'] = get_lang('Audio');
+                } elseif($breadcrumb_step['name'] == 'flash') {
+                    $navigation_item['title'] = get_lang('Flash');
+                } elseif($breadcrumb_step['name'] == 'gallery') {
+                    $navigation_item['title'] = get_lang('Gallery');
+                }
+                //Fixes breadcrumb title now we applied the Security::remove_XSS and we cut the string depending of the MAX_LENGTH_BREADCRUMB value
+
+                $navigation_item['title'] = cut($navigation_item['title'], MAX_LENGTH_BREADCRUMB);
+                $navigation_item['title'] = Security::remove_XSS($navigation_item['title']);
+                $navigation[] = $navigation_item;
+            }
+        }
+
+
+        // part 3: The tool itself. If we are on the course homepage we do not want to display the title of the course because this
+        // is the same as the first part of the breadcrumbs (see part 1)
+        if (isset($nameTools) && $language_file != 'course_home') { // TODO: This condition $language_file != 'course_home' might bring surprises.
+            $navigation_item['url'] = '#';
+            $navigation_item['title'] = $nameTools;
+            $navigation[] = $navigation_item;
+        }
+
+        $final_navigation = array();
+        $counter = 0;
+
+        foreach ($navigation as $index => $navigation_info) {
+            if (!empty($navigation_info['title'])) {
+
+                if ($navigation_info['url'] == '#') {
+                    $final_navigation[$index] = $navigation_info['title'];
+                } else {
+                    $final_navigation[$index] = '<a href="'.$navigation_info['url'].'" class="" target="_top">'.$navigation_info['title'].'</a>';
+                }
+                $counter++;
+            }
+        }
+
+        $html = '';
+
+        /* Part 4 . Show the teacher view/student view button at the right of the breadcrumb */
+        $view_as_student_link = null;
+        if ($user_id && isset($course_id)) {
+            if ((api_is_course_admin() || api_is_platform_admin()) && api_get_setting('student_view_enabled') == 'true') {
+                $view_as_student_link = api_display_tool_view_option();
+            }
+        }
+
+        if (!empty($final_navigation)) {
+            $lis = '';
+            $i = 0;
+            //$home_link = Display::url(Display::img(api_get_path(WEB_CSS_PATH).'home.png', get_lang('Homepage'), array('align'=>'middle')), api_get_path(WEB_PATH), array('class'=>'home'));
+            //$lis.= Display::tag('li', Display::url(get_lang('Homepage').'<span class="divider">/</span>', api_get_path(WEB_PATH)));
+            $final_navigation_count = count($final_navigation);
+
+            if (!empty($final_navigation)) {
+                // $home_link.= '<span class="divider">/</span>';
+
+                if (!empty($home_link)) {
+                    $lis.= Display::tag('li', $home_link);
+                }
+
+                foreach ($final_navigation as $bread) {
+                    $bread_check = trim(strip_tags($bread));
+                    if (!empty($bread_check)) {
+                        if ($final_navigation_count-1 > $i) {
+                            $bread .= '<span class="divider">/</span>';
+                        }
+                        $lis.= Display::tag('li', $bread);
+                        $i++;
+                    }
+                }
+            } else {
+                if (!empty($home_link)) {
+                    $lis.= Display::tag('li', $home_link);
+                }
+            }
+
+            // View as student/teacher link
+            if (!empty($view_as_student_link)) {
+                $lis.= Display::tag('li', $view_as_student_link, array('id' => 'view_as_link','class' => 'pull-right'));
+            }
+
+            if (!empty($lis)) {
+                $html .= Display::tag('ul', $lis, array('class'=>'breadcrumb'));
+            }
+        }
+        return $html ;
+    }
+}

+ 218 - 217
main/inc/lib/userportal.lib.php

@@ -1,4 +1,4 @@
-<?php 
+<?php
 /* For licensing terms, see /license.txt */
 
 use \ChamiloSession as Session;
@@ -6,40 +6,41 @@ use \ChamiloSession as Session;
 class IndexManager {
 	var $tpl 	= false; //An instance of the template engine
 	var $name 	= '';
-	
+
 	var $home			= '';
-	var $default_home 	= 'home/';    
-	
-	function __construct($title) {					
-		$this->tpl = new Template($title);		
+	var $default_home 	= 'home/';
+
+	function __construct($title) {
+        global $app;
+		$this->tpl = new Template($title, $app);
 		$this->home     = api_get_home_path();
 		$this->user_id  = api_get_user_id();
 		$this->load_directories_preview = false;
-        
+
 		if (api_get_setting('show_documents_preview') == 'true') {
 			$this->load_directories_preview = true;
-		}		
-	}	
-	
+		}
+	}
+
 	function set_login_form() {
 		global $loginFailed;
-		
+
 		$login_form = '';
-	
+
 		if (!($this->user_id) || api_is_anonymous($this->user_id)) {
-	
+
 			// Only display if the user isn't logged in.
 			$this->tpl->assign('login_language_form', api_display_language_form(true));
 			$this->tpl->assign('login_form',  self::display_login_form());
-			
-			if ($loginFailed) {				
+
+			if ($loginFailed) {
 				$this->tpl->assign('login_failed',  self::handle_login_failed());
 			}
-	
+
 			if (api_get_setting('allow_lostpassword') == 'true' || api_get_setting('allow_registration') == 'true') {
 				$login_form .= '<ul class="nav nav-list">';
 				if (api_get_setting('allow_registration') != 'false') {
-					$login_form .= '<li><a href="main/auth/inscription.php">'.get_lang('Reg').'</a></li>';					
+					$login_form .= '<li><a href="main/auth/inscription.php">'.get_lang('Reg').'</a></li>';
 				}
 				if (api_get_setting('allow_lostpassword') == 'true') {
 					$login_form .= '<li><a href="main/auth/lostPassword.php">'.get_lang('LostPassword').'</a></li>';
@@ -49,8 +50,8 @@ class IndexManager {
 			$this->tpl->assign('login_options',  $login_form);
 		}
 	}
-	
-	
+
+
 	function return_exercise_block($personal_course_list) {
 		require_once api_get_path(SYS_CODE_PATH).'exercice/exercise.lib.php';
 		$exercise_list = array();
@@ -58,14 +59,14 @@ class IndexManager {
 			foreach($personal_course_list as  $course_item) {
 				$course_code 	= $course_item['c'];
 				$session_id 	= $course_item['id_session'];
-					
+
 				$exercises = get_exercises_to_be_taken($course_code, $session_id);
-	
+
 				foreach($exercises as $exercise_item) {
 					$exercise_item['course_code'] 	= $course_code;
 					$exercise_item['session_id'] 	= $session_id;
 					$exercise_item['tms'] 	= api_strtotime($exercise_item['end_time'], 'UTC');
-						
+
 					$exercise_list[] = $exercise_item;
 				}
 			}
@@ -78,16 +79,16 @@ class IndexManager {
 			}
 		}
 	}
-	
-	function return_announcements($show_slide = true) {	
+
+	function return_announcements($show_slide = true) {
 		// Display System announcements
 		$announcement = isset($_GET['announcement']) ? $_GET['announcement'] : null;
-		$announcement = intval($announcement);	
-        
+		$announcement = intval($announcement);
+
 		if (!api_is_anonymous() && $this->user_id) {
 			$visibility = api_is_allowed_to_create_course() ? SystemAnnouncementManager::VISIBLE_TEACHER : SystemAnnouncementManager::VISIBLE_STUDENT;
 			if ($show_slide) {
-				$announcements = SystemAnnouncementManager :: display_announcements_slider($visibility, $announcement);                
+				$announcements = SystemAnnouncementManager :: display_announcements_slider($visibility, $announcement);
 			} else {
 				$announcements = SystemAnnouncementManager :: display_all_announcements($visibility, $announcement);
 			}
@@ -99,15 +100,15 @@ class IndexManager {
 			}
 		}
 		return $announcements;
-	}	
-		
+	}
+
 	/**
-     * Alias for the online_logout() function	 
+     * Alias for the online_logout() function
 	 */
-	function logout() {        
+	function logout() {
         online_logout($this->user_id, true);
 	}
-	
+
 	/**
 	 * This function checks if there are courses that are open to the world in the platform course categories (=faculties)
 	 *
@@ -133,8 +134,8 @@ class IndexManager {
 		}
 		return false;
 	}
-	
-	
+
+
 	/**
 	 * Displays the right-hand menu for anonymous users:
 	 * login form, useful links, help section
@@ -143,24 +144,24 @@ class IndexManager {
 	 * @todo does $_plugins need to be global?
 	 */
 	function display_anonymous_right_menu() {
-		global $loginFailed, $_user;        
-		$display_add_course_link	= api_is_allowed_to_create_course() && ($_SESSION['studentview'] != 'studentenview');	
+		global $loginFailed, $_user;
+		$display_add_course_link	= api_is_allowed_to_create_course() && ($_SESSION['studentview'] != 'studentenview');
 		$current_user_id        	= api_get_user_id();
-	
-		echo self::set_login_form(false);				
-		echo self::return_teacher_link();		
-		echo self::return_notice();		
-	}	
-	
+
+		echo self::set_login_form(false);
+		echo self::return_teacher_link();
+		echo self::return_notice();
+	}
+
 	function return_teacher_link() {
 		$html = '';
 		if (!empty($this->user_id)) {
 			// tabs that are deactivated are added here
-		
+
 			$show_menu = false;
 			$show_create_link = false;
 			$show_course_link = false;
-		
+
 			if (api_is_platform_admin() || api_is_course_admin() || api_is_allowed_to_create_course()) {
 				$show_menu = true;
 				$show_course_link = true;
@@ -170,55 +171,55 @@ class IndexManager {
 					$show_course_link = true;
 				}
 			}
-		
+
 			if ($show_menu && ($show_create_link || $show_course_link )) {
 				$show_menu = true;
 			} else {
 				$show_menu = false;
 			}
-		}	
-		
+		}
+
 		// My Account section
-		
+
 		if ($show_menu) {
 			$html .= '<ul class="nav nav-list">';
-			if ($show_create_link) {			
+			if ($show_create_link) {
 				$html .= '<li><a href="main/create_course/add_course.php" class="add course">'.(api_get_setting('course_validation') == 'true' ? get_lang('CreateCourseRequest') : get_lang('CourseCreate')).'</a></li>';
 			}
-			
+
 			if ($show_course_link) {
 				if (!api_is_drh() && !api_is_session_admin()) {
-					$html .=  '<li><a href="main/auth/courses.php" class="list course">'.get_lang('CourseCatalog').'</a></li>';					
+					$html .=  '<li><a href="main/auth/courses.php" class="list course">'.get_lang('CourseCatalog').'</a></li>';
 				} else {
 					$html .= '<li><a href="main/dashboard/index.php">'.get_lang('Dashboard').'</a></li>';
 				}
-			}		
+			}
 			$html .= '</ul>';
-		}	
-		
+		}
+
 		if (!empty($html)) {
 			$html = self::show_right_block(get_lang('Courses'), $html, 'teacher_block');
 		}
 		return $html;
 	}
-	
+
 	/* Includes a created page */
-	function return_home_page() {	
+	function return_home_page() {
 
 		// Including the page for the news
 		$html = '';
-		
+
 		if (!empty($_GET['include']) && preg_match('/^[a-zA-Z0-9_-]*\.html$/', $_GET['include'])) {
 			$open = @(string)file_get_contents(api_get_path(SYS_PATH).$this->home.$_GET['include']);
-			$html = api_to_system_encoding($open, api_detect_encoding(strip_tags($open)));		 			
-		} else {		
+			$html = api_to_system_encoding($open, api_detect_encoding(strip_tags($open)));
+		} else {
 			if (!empty($_SESSION['user_language_choice'])) {
 				$user_selected_language = $_SESSION['user_language_choice'];
 			} elseif (!empty($_SESSION['_user']['language'])) {
 				$user_selected_language = $_SESSION['_user']['language'];
 			} else {
 				$user_selected_language = api_get_setting('platformLanguage');
-			}		
+			}
 			if (!file_exists($this->home.'home_news_'.$user_selected_language.'.html')) {
 				if (file_exists($this->home.'home_top.html')) {
 					$home_top_temp = file($this->home.'home_top.html');
@@ -237,22 +238,22 @@ class IndexManager {
 				$home_top_temp = get_lang('PortalHomepageDefaultIntroduction');
 			}
 			$open = str_replace('{rel_path}', api_get_path(REL_PATH), $home_top_temp);
-			$html = api_to_system_encoding($open, api_detect_encoding(strip_tags($open)));				
+			$html = api_to_system_encoding($open, api_detect_encoding(strip_tags($open)));
 		}
-		return $html;		
+		return $html;
 	}
-	
-	function return_notice() { 
+
+	function return_notice() {
 		$sys_path               = api_get_path(SYS_PATH);
 		$user_selected_language = api_get_interface_language();
-		
+
 		$html = '';
 		// Notice
 		$home_notice = @(string)file_get_contents($sys_path.$this->home.'home_notice_'.$user_selected_language.'.html');
 		if (empty($home_notice)) {
 			$home_notice = @(string)file_get_contents($sys_path.$this->home.'home_notice.html');
 		}
-		
+
 		if (!empty($home_notice)) {
 			$home_notice = api_to_system_encoding($home_notice, api_detect_encoding(strip_tags($home_notice)));
             $home_notice = Display::div($home_notice, array('class'  => 'homepage_notice'));
@@ -260,46 +261,46 @@ class IndexManager {
 		}
         return $html;
     }
-    
-    function return_help() { 
+
+    function return_help() {
         $user_selected_language = api_get_interface_language();
         $sys_path               = api_get_path(SYS_PATH);
         $platformLanguage       = api_get_setting('platformLanguage');
-        
+
 		// Help section.
 		/* Hide right menu "general" and other parts on anonymous right menu. */
-		
+
 		if (!isset($user_selected_language)) {
 			$user_selected_language = $platformLanguage;
 		}
-        
-        $html = null;		
+
+        $html = null;
 		$home_menu = @(string)file_get_contents($sys_path.$this->home.'home_menu_'.$user_selected_language.'.html');
 		if (!empty($home_menu)) {
 			$home_menu_content .= '<ul class="nav nav-list">';
 			$home_menu_content .= api_to_system_encoding($home_menu, api_detect_encoding(strip_tags($home_menu)));
 			$home_menu_content .= '</ul>';
 			$html .= self::show_right_block(get_lang('MenuGeneral'), $home_menu_content, 'help_block');
-		}        
+		}
 		return $html;
 	}
-	    
+
     function return_skills_links() {
         $html = '';
         if (api_get_setting('allow_skills_tool') == 'true') {
-            $content = '<ul class="nav nav-list">';      
-            
+            $content = '<ul class="nav nav-list">';
+
             $content .= Display::tag('li', Display::url(get_lang('MySkills'), api_get_path(WEB_CODE_PATH).'social/skills_wheel.php'));
-            
+
             if (api_get_setting('allow_hr_skills_management') == 'true' || api_is_platform_admin()) {
                 $content .= Display::tag('li', Display::url(get_lang('ManageSkills'), api_get_path(WEB_CODE_PATH).'admin/skills_wheel.php'));
             }
-            $content .= '</ul>';        
+            $content .= '</ul>';
             $html = self::show_right_block(get_lang("Skills"), $content, 'skill_block');
         }
         return $html;
     }
-	
+
 	/**
 	 * Reacts on a failed login:
 	 * Displays an explanation with a link to the registration form.
@@ -308,14 +309,14 @@ class IndexManager {
 	 */
 	function handle_login_failed() {
         $message = get_lang('InvalidId');
-        
-		if (!isset($_GET['error'])) {	
+
+		if (!isset($_GET['error'])) {
 			if (api_is_self_registration_allowed()) {
 				$message = get_lang('InvalidForSelfRegistration');
 			}
 		} else {
 			switch ($_GET['error']) {
-				case '':					
+				case '':
 					if (api_is_self_registration_allowed()) {
 						$message = get_lang('InvalidForSelfRegistration');
 					}
@@ -338,8 +339,8 @@ class IndexManager {
 			}
 		}
 		return Display::return_message($message, 'error');
-	}	
-	
+	}
+
 	/**
 	 * Display list of courses in a category.
 	 * (for anonymous users)
@@ -352,22 +353,22 @@ class IndexManager {
         $result = '';
 		$ctok = $_SESSION['sec_token'];
 		$stok = Security::get_token();
-	
+
 		// Initialization.
 		$user_identified = (api_get_user_id() > 0 && !api_is_anonymous());
 		$web_course_path = api_get_path(WEB_COURSE_PATH);
 		$category = Database::escape_string($_GET['category']);
 		$setting_show_also_closed_courses = api_get_setting('show_closed_courses') == 'true';
-	
+
 		// Database table definitions.
 		$main_course_table      = Database :: get_main_table(TABLE_MAIN_COURSE);
-		$main_category_table    = Database :: get_main_table(TABLE_MAIN_CATEGORY);		
-	
+		$main_category_table    = Database :: get_main_table(TABLE_MAIN_CATEGORY);
+
 		// Get list of courses in category $category.
 		$sql_get_course_list = "SELECT * FROM $main_course_table cours
 	                                WHERE category_code = '".Database::escape_string($_GET['category'])."'
 	                                ORDER BY title, UPPER(visual_code)";
-	
+
 		// Showing only the courses of the current access_url_id.
 		global $_configuration;
 		if ($_configuration['multiple_access_urls']) {
@@ -379,14 +380,14 @@ class IndexManager {
 	                    WHERE access_url_id = $url_access_id AND category_code = '".Database::escape_string($_GET['category'])."' ORDER BY title, UPPER(visual_code)";
 			}
 		}
-	
+
 		// Removed: AND cours.visibility='".COURSE_VISIBILITY_OPEN_WORLD."'
 		$sql_result_courses = Database::query($sql_get_course_list);
-	
+
 		while ($course_result = Database::fetch_array($sql_result_courses)) {
 			$course_list[] = $course_result;
 		}
-	
+
 		$platform_visible_courses = '';
 		// $setting_show_also_closed_courses
 		if ($user_identified) {
@@ -409,9 +410,9 @@ class IndexManager {
 	                LEFT JOIN $main_course_table t3 ON (t3.category_code=t1.code $platform_visible_courses)
 	                WHERE t1.parent_id ". (empty ($category) ? "IS NULL" : "='$category'")."
 	                GROUP BY t1.name,t1.code,t1.parent_id,t1.children_count ORDER BY t1.tree_pos, t1.name";
-	
-	
-		// Showing only the category of courses of the current access_url_id		
+
+
+		// Showing only the category of courses of the current access_url_id
 		if ($_configuration['multiple_access_urls']) {
 			$url_access_id = api_get_current_access_url_id();
 			if ($url_access_id != -1) {
@@ -427,14 +428,14 @@ class IndexManager {
 	                GROUP BY t1.name,t1.code,t1.parent_id,t1.children_count ORDER BY t1.tree_pos, t1.name";
 			}
 		}
-	
+
 		$resCats = Database::query($sqlGetSubCatList);
 		$thereIsSubCat = false;
 		if (Database::num_rows($resCats) > 0) {
 			$htmlListCat = Display::page_header(get_lang('CatList'));
             $htmlListCat .= '<ul>';
 			while ($catLine = Database::fetch_array($resCats)) {
-				if ($catLine['code'] != $category) {	
+				if ($catLine['code'] != $category) {
 					$category_has_open_courses = self::category_has_open_courses($catLine['code']);
 					if ($category_has_open_courses) {
 						// The category contains courses accessible to anonymous visitors.
@@ -488,14 +489,14 @@ class IndexManager {
 		$courses_list_string = '';
 		$courses_shown = 0;
 		if ($numrows > 0) {
-			
+
 			$courses_list_string .= Display::page_header(get_lang('CourseList'));
             $courses_list_string .= "<ul>";
-	
+
 			if (api_get_user_id()) {
 				$courses_of_user = self::get_courses_of_user(api_get_user_id());
 			}
-	
+
 			foreach ($course_list as $course) {
 				// $setting_show_also_closed_courses
 				if (!$setting_show_also_closed_courses) {
@@ -561,7 +562,7 @@ class IndexManager {
                     if (api_get_setting('show_different_course_language') == 'true' && $course['course_language'] != api_get_setting('platformLanguage')) {
 	                    $course_details[] = $course['course_language'];
 	                }
-                    
+
                     $courses_list_string .= implode(' - ', $course_details);
 					// We display a subscription link if:
 	                // 1. it is allowed to register for the course and if the course is not already in the courselist of the user and if the user is identiefied
@@ -589,9 +590,9 @@ class IndexManager {
 		if ($category != '') {
 			$result .=  '<p><a href="'.api_get_self().'"> ' . Display :: return_icon('back.png', get_lang('BackToHomePage')) . get_lang('BackToHomePage') . '</a></p>';
 		}
-        return $result; 
+        return $result;
 	}
-	
+
 	/**
 	* retrieves all the courses that the user has already subscribed to
 		* @author Patrick Cool <patrick.cool@UGent.be>, Ghent University, Belgium
@@ -619,25 +620,25 @@ class IndexManager {
 	        $courses[$row['k']] = array('db' => $row['db'], 'code' => $row['k'], 'visual_code' => $row['vc'], 'title' => $row['i'], 'directory' => $row['dir'], 'status' => $row['status'], 'tutor' => $row['t'], 'subscribe' => $row['subscr'], 'unsubscribe' => $row['unsubscr'], 'sort' => $row['sort'], 'user_course_category' => $row['user_course_cat']);
 	    }
 		return $courses;
-	}	
-	
+	}
+
     /**
      * @todo use the template system
      */
-	function show_right_block($title, $content, $id = null, $params = null) {        
-	    if (!empty($id)) {            
+	function show_right_block($title, $content, $id = null, $params = null) {
+	    if (!empty($id)) {
             $params['id'] = $id;
-        }        
+        }
         $params['class'] = 'well sidebar-nav';
-        $html = null;        
+        $html = null;
 		if (!empty($title)) {
 			$html.= '<h4>'.$title.'</h4>';
-		}        
+		}
 		$html.= $content;
         $html = Display::div($html, $params);
 		return $html;
 	}
-	
+
 	/**
 	 * Adds a form to let users login
 	 * @version 1.1
@@ -645,11 +646,11 @@ class IndexManager {
 	function display_login_form() {
 		$form = new FormValidator('formLogin', 'POST', null,  null, array('class'=>'form-vertical'));
         // 'placeholder'=>get_lang('UserName')
-        //'autocomplete'=>"off",        
-        
+        //'autocomplete'=>"off",
+
 		$form->addElement('text', 'login', get_lang('UserName'), array('class' => 'span2 autocapitalize_off', 'autofocus' => 'autofocus'));
 		$form->addElement('password', 'password', get_lang('Pass'), array('class' => 'span2'));
-		$form->addElement('style_submit_button','submitAuth', get_lang('LoginEnter'), array('class' => 'btn'));		
+		$form->addElement('style_submit_button','submitAuth', get_lang('LoginEnter'), array('class' => 'btn'));
 		$html = $form->return_form();
 		if (api_get_setting('openid_authentication') == 'true') {
 			include_once 'main/auth/openid/login.php';
@@ -657,22 +658,22 @@ class IndexManager {
 		}
 		return $html;
 	}
-	
+
 	function return_search_block() {
-		$html = '';		
+		$html = '';
 		if (api_get_setting('search_enabled') == 'true') {
 			$html .= '<div class="searchbox">';
-			$search_btn = get_lang('Search');			
+			$search_btn = get_lang('Search');
 			$search_content = '<br />
 		    	<form action="main/search/" method="post">
 		    	<input type="text" id="query" class="span2" name="query" value="" />
 		    	<button class="save" type="submit" name="submit" value="'.$search_btn.'" />'.$search_btn.' </button>
-		    	</form></div>';    
+		    	</form></div>';
 			$html .= self::show_right_block(get_lang('Search'), $search_content, 'search_block');
 		}
-		return $html;	
+		return $html;
 	}
-	
+
 	function return_classes_block() {
 		$html = '';
 		if (api_get_setting('show_groups_to_users') == 'true') {
@@ -693,11 +694,11 @@ class IndexManager {
 			if (!empty($classes)) {
 				$classes = Display::tag('ul', $classes, array('class'=>'nav nav-list'));
 				$html .= self::show_right_block(get_lang('Classes'), $classes, 'classes_block');
-			}		
+			}
 		}
 		return $html;
 	}
-	
+
 	function return_reservation_block() {
 		$html = '';
 		if (api_get_setting('allow_reservation') == 'true' && api_is_allowed_to_create_course()) {
@@ -708,54 +709,54 @@ class IndexManager {
 		}
 		return $html;
 	}
-    
-    function return_user_image_block() {		
-		$img_array = UserManager::get_user_picture_path_by_id(api_get_user_id(), 'web', true, true);		
-		$img_array = UserManager::get_picture_user(api_get_user_id(), $img_array['file'], 50, USER_IMAGE_SIZE_MEDIUM, ' width="90" height="90" ');		
+
+    function return_user_image_block() {
+		$img_array = UserManager::get_user_picture_path_by_id(api_get_user_id(), 'web', true, true);
+		$img_array = UserManager::get_picture_user(api_get_user_id(), $img_array['file'], 50, USER_IMAGE_SIZE_MEDIUM, ' width="90" height="90" ');
         if (api_get_setting('allow_social_tool') == 'true') {
             $profile_content .='<a style="text-align:center" href="'.api_get_path(WEB_PATH).'main/social/home.php"><img src="'.$img_array['file'].'"  '.$img_array['style'].' ></a>';
         } else {
             $profile_content .='<a style="text-align:center"  href="'.api_get_path(WEB_PATH).'main/auth/profile.php"><img title="'.get_lang('EditProfile').'" src="'.$img_array['file'].'" '.$img_array['style'].'></a>';
-        }		     
+        }
         $html = self::show_right_block(null, $profile_content, 'user_image_block', array('style' => 'text-align:center;'));
         return $html;
     }
-	
+
 	function return_profile_block() {
 		$html = '';
 		$user_id = api_get_user_id();
-        
+
 		if (empty($user_id)) {
-			return; 
+			return;
 		}
-	
-		$profile_content .= '<ul class="nav nav-list">'; 
-		
+
+		$profile_content .= '<ul class="nav nav-list">';
+
 		//  @todo Add a platform setting to add the user image.
 		if (api_get_setting('allow_message_tool') == 'true') {
 			require_once api_get_path(LIBRARY_PATH).'group_portal_manager.lib.php';
-		
+
 			// New messages.
 			$number_of_new_messages             = MessageManager::get_new_messages();
 			// New contact invitations.
 			$number_of_new_messages_of_friend   = SocialManager::get_message_number_invitation_by_user_id(api_get_user_id());
-		
+
 			// New group invitations sent by a moderator.
 			$group_pending_invitations = GroupPortalManager::get_groups_by_user(api_get_user_id(), GROUP_USER_PERMISSION_PENDING_INVITATION, false);
 			$group_pending_invitations = count($group_pending_invitations);
-		
+
 			$total_invitations = $number_of_new_messages_of_friend + $group_pending_invitations;
-            $cant_msg = Display::badge($number_of_new_messages);			         
-            
+            $cant_msg = Display::badge($number_of_new_messages);
+
 			$link = '';
 			if (api_get_setting('allow_social_tool') == 'true') {
 				$link = '?f=social';
 			}
 			$profile_content .= '<li><a href="'.api_get_path(WEB_PATH).'main/messages/inbox.php'.$link.'">'.get_lang('Inbox').$cant_msg.' </a></li>';
-			$profile_content .= '<li><a href="'.api_get_path(WEB_PATH).'main/messages/new_message.php'.$link.'">'.get_lang('Compose').' </a></li>';            
-		
-			if (api_get_setting('allow_social_tool') == 'true') {                				
-				$total_invitations = Display::badge($total_invitations);				                
+			$profile_content .= '<li><a href="'.api_get_path(WEB_PATH).'main/messages/new_message.php'.$link.'">'.get_lang('Compose').' </a></li>';
+
+			if (api_get_setting('allow_social_tool') == 'true') {
+				$total_invitations = Display::badge($total_invitations);
 				$profile_content .= '<li><a href="'.api_get_path(WEB_PATH).'main/social/invitations.php">'.get_lang('PendingInvitations').$total_invitations.'</a></li>';
 			}
         }
@@ -764,37 +765,37 @@ class IndexManager {
 		$html = self::show_right_block(get_lang('Profile'), $profile_content, 'profile_block');
 		return $html;
 	}
-	
+
 	function return_navigation_links() {
 		$html = '';
-		
+
 		// Deleting the myprofile link.
 		if (api_get_setting('allow_social_tool') == 'true') {
 			unset($this->tpl->menu_navigation['myprofile']);
 		}
-                
+
 		// Main navigation section.
 		// Tabs that are deactivated are added here.
-		if (!empty($this->tpl->menu_navigation)) {            
+		if (!empty($this->tpl->menu_navigation)) {
 			$content = '<ul class="nav nav-list">';
-			foreach ($this->tpl->menu_navigation as $section => $navigation_info) {                
+			foreach ($this->tpl->menu_navigation as $section => $navigation_info) {
 				$current = $section == $GLOBALS['this_section'] ? ' id="current"' : '';
 				$content .= '<li'.$current.'>';
 				$content .= '<a href="'.$navigation_info['url'].'" target="_self">'.$navigation_info['title'].'</a>';
 				$content .= '</li>';
 			}
-			$content .= '</ul>';            
+			$content .= '</ul>';
 			$html = self::show_right_block(get_lang('MainNavigation'), $content, 'navigation_link_block');
-		}        
+		}
 		return $html;
 	}
-	
+
 	function return_course_block() {
 		$html = '';
 
 		$show_create_link = false;
 		$show_course_link = false;
-				
+
 		if ((api_get_setting('allow_users_to_create_courses') == 'false' && !api_is_platform_admin()) || api_is_student()) {
             $display_add_course_link = false;
         } else {
@@ -804,95 +805,95 @@ class IndexManager {
 		if ($display_add_course_link) {
 			$show_create_link = true;
 		}
-		
+
 		if (api_is_platform_admin() || api_is_course_admin() || api_is_allowed_to_create_course()) {
 			$show_course_link = true;
 		} else {
-			if (api_get_setting('allow_students_to_browse_courses') == 'true') {		
+			if (api_get_setting('allow_students_to_browse_courses') == 'true') {
 				$show_course_link = true;
 			}
 		}
-		
-		// My account section		
+
+		// My account section
 		$my_account_content = '<ul class="nav nav-list">';
-        
+
 		if ($show_create_link) {
 			$my_account_content .= '<li><a href="main/create_course/add_course.php" class="add course">'.(api_get_setting('course_validation') == 'true' ? get_lang('CreateCourseRequest') : get_lang('CourseCreate')).'</a></li>';
 		}
-        
+
         //Sort courses
         $url = api_get_path(WEB_CODE_PATH).'auth/courses.php?action=sortmycourses';
         $my_account_content .= '<li>'.Display::url(get_lang('SortMyCourses'), $url, array('class' => 'sort course')).'</li>';
 
-        //Course management                
+        //Course management
 		if ($show_course_link) {
 			if (!api_is_drh()) {
-				$my_account_content .= '<li><a href="main/auth/courses.php" class="list course">'.get_lang('CourseCatalog').'</a></li>';	
-				
+				$my_account_content .= '<li><a href="main/auth/courses.php" class="list course">'.get_lang('CourseCatalog').'</a></li>';
+
                 if (isset($_GET['history']) && intval($_GET['history']) == 1) {
                     $my_account_content .= '<li><a href="user_portal.php">'.get_lang('DisplayTrainingList').'</a></li>';
                 } else {
                     $my_account_content .= '<li><a href="user_portal.php?history=1"  class="history course">'.get_lang('HistoryTrainingSessions').'</a></li>';
                 }
-				
+
 			} else {
 				$my_account_content .= '<li><a href="main/dashboard/index.php">'.get_lang('Dashboard').'</a></li>';
 			}
 		}
-        
+
 		$my_account_content .= '</ul>';
-		
+
 		if (!empty($my_account_content)) {
 			$html =  self::show_right_block(get_lang('Courses'), $my_account_content, 'course_block');
 		}
 		return $html;
 	}
-	
+
 	/**
 	 * The most important function here, prints the session and course list (user_portal.php)
-	 *  
+	 *
 	 * */
-	function return_courses_and_sessions($user_id) {		       
-        $session_categories = array();     
+	function return_courses_and_sessions($user_id) {
+        $session_categories = array();
         $load_history = (isset($_GET['history']) && intval($_GET['history']) == 1) ? true : false;
-		
+
 		if ($load_history) {
             //Load sessions in category in *history*
-			$session_categories = UserManager::get_sessions_by_category($user_id, true);			
+			$session_categories = UserManager::get_sessions_by_category($user_id, true);
 		} else {
             //Load sessions in category
 			$session_categories = UserManager::get_sessions_by_category($user_id, false);
-		}        
-        
-        $html = '';        
-        //Showing history title		
+		}
+
+        $html = '';
+        //Showing history title
 		if ($load_history) {
-			$html .= Display::page_subheader(get_lang('HistoryTrainingSession'));			
+			$html .= Display::page_subheader(get_lang('HistoryTrainingSession'));
 			if (empty($session_categories)) {
 				$html .=  get_lang('YouDoNotHaveAnySessionInItsHistory');
 			}
 		}
-        
+
         $courses_html = '';
         $special_courses = '';
-        
+
         // If we're not in the history view...
         if (!isset($_GET['history'])) {
             //Display special courses
-            $special_courses = CourseManager::display_special_courses($user_id, $this->load_directories_preview);                        
+            $special_courses = CourseManager::display_special_courses($user_id, $this->load_directories_preview);
             //Display courses
             $courses_html .= CourseManager::display_courses($user_id, $this->load_directories_preview);
         }
-        
+
         $sessions_with_category = '';
-        $sessions_with_no_category = '';        
-        
+        $sessions_with_no_category = '';
+
 		if (is_array($session_categories)) {
             foreach ($session_categories as $session_category) {
                 $session_category_id = $session_category['session_category']['id'];
                 // Sessions and courses that are not in a session category
                 if ($session_category_id == 0) {
-                    
+
                     // Independent sessions
                     if (isset($session_category['sessions'])) {
                         foreach ($session_category['sessions'] as $session) {
@@ -907,10 +908,10 @@ class IndexManager {
                             $html_courses_session = '';
                             $count_courses_session = 0;
 
-                            foreach ($session['courses'] as $course) {                                   
+                            foreach ($session['courses'] as $course) {
                                 //read only and accesible
                                 if (api_get_setting('hide_courses_in_sessions') == 'false') {
-                                    $html_courses_session .= CourseManager :: get_logged_user_course_html($course, $session_id, $this->load_directories_preview);									                                
+                                    $html_courses_session .= CourseManager :: get_logged_user_course_html($course, $session_id, $this->load_directories_preview);
                                 }
                                 $count_courses_session++;
                             }
@@ -930,9 +931,9 @@ class IndexManager {
                                 $params['title'] = $session_link;
 
                                 $moved_status = SessionManager::get_session_change_user_reason($session['moved_status']);
-                                $moved_status = isset($moved_status) && !empty($moved_status) ? ' ('.$moved_status.')' : null;                            
+                                $moved_status = isset($moved_status) && !empty($moved_status) ? ' ('.$moved_status.')' : null;
 
-                                $params['subtitle'] = isset($session['coach_info']) ? $session['coach_info']['complete_name'] : null.$moved_status;						
+                                $params['subtitle'] = isset($session['coach_info']) ? $session['coach_info']['complete_name'] : null.$moved_status;
                                 $params['dates'] = $session['date_message'];
 
                                 $params['right_actions'] = '';
@@ -948,18 +949,18 @@ class IndexManager {
                             }
                         }
                     }
-                    
-				} else {           
-					// All sessions included in					
+
+				} else {
+					// All sessions included in
                     $count_courses_session = 0;
-                    $html_sessions = '';                        
+                    $html_sessions = '';
                     foreach ($session_category['sessions'] as $session) {
-                        $session_id = $session['session_id'];                        
+                        $session_id = $session['session_id'];
                         // Don't show empty sessions.
                         if (count($session['courses']) < 1) {
                             continue;
                         }
-                        
+
                         $html_courses_session = '';
                         $count = 0;
                         foreach ($session['courses'] as $course) {
@@ -967,11 +968,11 @@ class IndexManager {
                                 $html_courses_session .= CourseManager :: get_logged_user_course_html($course, $session_id);
                             }
                             $count_courses_session++;
-                            $count++;                          
+                            $count++;
                         }
-                        
+
                         $params = array();
-                        if ($count > 0) {                                                                             
+                        if ($count > 0) {
                             $params['icon'] = Display::return_icon('window_list.png', $session['session_name'], array('id' => 'session_img_'.$session_id), ICON_SIZE_LARGE);
 
                             if (api_is_drh()) {
@@ -983,22 +984,22 @@ class IndexManager {
                             }
 
                             $params['title'] .=  $session_link;
-                            
+
                             $moved_status = SessionManager::get_session_change_user_reason($session['moved_status']);
-                            $moved_status = isset($moved_status) && !empty($moved_status) ? ' ('.$moved_status.')' : null;                            
-                                                        
-                            $params['subtitle'] = isset($session['coach_info']) ? $session['coach_info']['complete_name'] : null.$moved_status;						
+                            $moved_status = isset($moved_status) && !empty($moved_status) ? ' ('.$moved_status.')' : null;
+
+                            $params['subtitle'] = isset($session['coach_info']) ? $session['coach_info']['complete_name'] : null.$moved_status;
                             $params['dates'] = $session['date_message'];
 
                             if (api_is_platform_admin()) {
                                 $params['right_actions'] .=  '<a href="'.api_get_path(WEB_CODE_PATH).'admin/resume_session.php?id_session='.$session_id.'">'.Display::return_icon('edit.png', get_lang('Edit'), array('align' => 'absmiddle'), ICON_SIZE_SMALL).'</a>';
-                            }                                
-                            $html_sessions .= CourseManager::course_item_html($params, true).$html_courses_session;                         
+                            }
+                            $html_sessions .= CourseManager::course_item_html($params, true).$html_courses_session;
                         }
-                    }                    
-                    
+                    }
+
                     if ($count_courses_session > 0) {
-                        $params = array();				
+                        $params = array();
                         $params['icon'] = Display::return_icon('folder_blue.png', $session_category['session_category']['name'], array(), ICON_SIZE_LARGE);
 
                         if (api_is_platform_admin()) {
@@ -1010,48 +1011,48 @@ class IndexManager {
                         if (api_is_platform_admin()) {
                             $params['link']   = api_get_path(WEB_CODE_PATH).'admin/session_category_edit.php?&id='.$session_category['session_category']['id'];
                         }
-                        
+
                         $session_category_start_date = $session_category['session_category']['date_start'];
                         $session_category_end_date = $session_category['session_category']['date_end'];
-                        
+
                         if (!empty($session_category_start_date) && $session_category_start_date != '0000-00-00' && !empty($session_category_end_date) && $session_category_end_date != '0000-00-00' ) {
                             $params['subtitle'] = sprintf(get_lang('FromDateXToDateY'), $session_category['session_category']['date_start'], $session_category['session_category']['date_end']);
-                        } else {                            
+                        } else {
                             if (!empty($session_category_start_date) && $session_category_start_date != '0000-00-00') {
                                  $params['subtitle'] = get_lang('From').' '.$session_category_start_date;
                             }
                             if (!empty($session_category_end_date) && $session_category_end_date != '0000-00-00') {
                                 $params['subtitle'] = get_lang('Until').' '.$session_category_end_date;
                             }
-                        }               
+                        }
                         $sessions_with_category .= CourseManager::course_item_parent(CourseManager::course_item_html($params, true), $html_sessions);
-                    }					
+                    }
 				}
 			}
-		}        
+		}
         return $sessions_with_category.$sessions_with_no_category.$courses_html.$special_courses;
 	}
-    
-    /** 
-     * Shows a welcome message when the user doesn't have any content in the course list 
+
+    /**
+     * Shows a welcome message when the user doesn't have any content in the course list
      */
     function return_welcome_to_course_block() {
-        $count_courses = CourseManager::count_courses();        
+        $count_courses = CourseManager::count_courses();
         $tpl = $this->tpl->get_template('layout/welcome_to_course.tpl');
-        
+
         $course_catalog_url = api_get_path(WEB_CODE_PATH).'auth/courses.php';
         $course_list_url = api_get_path(WEB_PATH).'user_portal.php';
-                
+
         $this->tpl->assign('course_catalog_url', $course_catalog_url);
         $this->tpl->assign('course_list_url', $course_list_url);
         $this->tpl->assign('course_catalog_link', Display::url(get_lang('here'), $course_catalog_url));
         $this->tpl->assign('course_list_link', Display::url(get_lang('here'), $course_list_url));
         $this->tpl->assign('count_courses', $count_courses);
-  
+
         return $this->tpl->fetch($tpl);
     }
 
 	function return_hot_courses() {
-		return CourseManager::return_hot_courses();		
+		return CourseManager::return_hot_courses();
 	}
 }

+ 3 - 2
main/template/default/layout/main.tpl

@@ -1,8 +1,8 @@
 {% block header %}
-{% include "default/layout/main_header.tpl" %}    
+{% include "default/layout/main_header.tpl" %}
 {% endblock %}
 
-{% block body %}	
+{% block body %}
 	{% if show_sniff == 1 %}
 	 	{% include "default/layout/sniff.tpl" %}
 	{% endif %}
@@ -17,4 +17,5 @@
         </div> <!-- end of #wrapper section -->
     {% endif %}
 {% include "default/layout/main_footer.tpl" %}
+{{ xhprof }}
 {% endblock %}

+ 10 - 0
resources/config/dev.php

@@ -0,0 +1,10 @@
+<?php
+
+// include the prod configuration
+require __DIR__.'/prod.php';
+
+error_reporting(-1);
+
+// enable the debug mode
+$app['debug'] = true;
+

+ 68 - 0
resources/config/prod.php

@@ -0,0 +1,68 @@
+<?php
+
+$app['debug'] = false;
+$app['app.theme'] = api_get_visual_theme();
+$app['app.title'] = '';
+$app['jquery_ui_theme'] = 'smoothness';
+
+// Cache
+$app['cache.path'] = api_get_path(SYS_ARCHIVE_PATH);
+
+// Http cache
+$app['http_cache.cache_dir'] = $app['cache.path'].'http';
+
+// Doctrine ORM
+$app['db.orm.proxies_dir'] = $app['cache.path'].'proxies_dir';
+
+// Assetic
+$app['assetic.path_to_cache']   = $app['cache.path'] . DIRECTORY_SEPARATOR . 'assetic' ;
+$app['assetic.path_to_web']     = api_get_path(SYS_PATH) . 'web'; //Location where to dump all generated files
+$app['assetic.input.path_to_assets'] = $app['assetic.path_to_web'].$app['app.theme'];
+
+$css_path = api_get_path(SYS_PATH) . 'web/css/';
+
+$app['assetic.input.path_to_css'] = array(
+    $css_path.'bootstrap.css',
+    $css_path.'base.css',
+    $css_path.'base_chamilo.css',
+    $css_path.$app['app.theme'].'/default.css',
+    $css_path.'bootstrap-responsive.css',
+    $css_path.'responsive.css',
+//  api_get_path(LIBRARY_PATH).'javascript/thickbox.css',
+//  api_get_path(LIBRARY_PATH).'javascript/chosen/chosen.css',
+    $css_path.$app['app.theme'].'/learnpath.css',
+    $css_path.$app['app.theme'].'/scorm.css',
+    api_get_path(LIBRARY_PATH).'javascript/chat/css/chat.css',
+    api_get_path(LIBRARY_PATH).'javascript/jquery-ui/'.$app['jquery_ui_theme'].'/jquery-ui-custom.css',
+    api_get_path(LIBRARY_PATH).'javascript/jquery-ui/default.css',
+    //api_get_path(LIBRARY_PATH).'javascript/bxslider/bx_styles/bx_styles.css',
+);
+
+$app['assetic.output.path_to_css'] = 'css/'.$app['app.theme'].'/style.css';
+
+$app['assetic.input.path_to_js'] = array(
+    api_get_path(LIBRARY_PATH).'javascript/modernizr.js',
+    api_get_path(LIBRARY_PATH).'javascript/jquery.min.js',
+    //api_get_path(LIBRARY_PATH).'javascript/chosen/chosen.jquery.min.js',
+    api_get_path(LIBRARY_PATH).'javascript/jquery-ui/'.$app['jquery_ui_theme'].'/jquery-ui-custom.min.js',
+    //api_get_path(LIBRARY_PATH).'javascript/thickbox.js',
+    api_get_path(LIBRARY_PATH).'javascript/bootstrap/bootstrap.js',
+    //api_get_path(LIBRARY_PATH).'javascript/bxslider/jquery.bxSlider.min.js',
+);
+
+$app['assetic.output.path_to_js'] = 'js/script.js';
+$app['assetic.filter.yui_compressor.path'] = '/usr/share/yui-compressor/yui-compressor.jar';
+
+//Create directories?
+if (!is_dir($app['assetic.path_to_web'])) {
+    mkdir($app['assetic.path_to_web'], api_get_permissions_for_new_directories());
+}
+
+if (!is_dir($app['assetic.path_to_web'].'/css')) {
+    mkdir($app['assetic.path_to_web'].'/css', api_get_permissions_for_new_directories());
+}
+
+if (!is_dir($app['assetic.path_to_web'].'/js')) {
+    mkdir($app['assetic.path_to_web'].'/js', api_get_permissions_for_new_directories());
+}
+

+ 3 - 2
tests/xhprof/footer.php

@@ -4,8 +4,9 @@ if (extension_loaded('xhprof')) {
     $xhprof_data = xhprof_disable();
     $xhprof_runs = new XHProfRuns_Default();
     $run_id = $xhprof_runs->save_run($xhprof_data, $profiler_namespace);
- 
+
     // url to the XHProf UI libraries (change the host name and path)
     $profiler_url = sprintf('http://my.chamilo.net/tests/xhprof/xhprof_html/index.php?run=%s&source=%s', $run_id, $profiler_namespace);
-    echo '<a href="'. $profiler_url .'" target="_blank">Profiler output</a>';
+    $xhprof =  '<a href="'. $profiler_url .'" target="_blank">Profiler output</a>';
+    error_log($run_id);
 }

+ 333 - 141
user_portal.php

@@ -34,167 +34,359 @@ if (isset($_SESSION['this_section']))
 /* Included libraries */
 
 require_once './main/inc/global.inc.php';
-require_once api_get_path(LIBRARY_PATH).'userportal.lib.php';
 
 api_block_anonymous_users(); // Only users who are logged in can proceed.
 
-/* Constants and CONFIGURATION parameters */
+$nameTools = get_lang('MyCourses');
+$this_section = SECTION_COURSES;
+
 $load_dirs = api_get_setting('show_documents_preview');
 
-// Check if a user is enrolled only in one course for going directly to the course after the login.
-if (api_get_setting('go_to_course_after_login') == 'true') {
-    
-    // Get the courses list
-    $personal_course_list 	= UserManager::get_personal_session_course_list(api_get_user_id());
-    
-    $my_session_list = array();
-    $count_of_courses_no_sessions = 0;
-    $count_of_courses_with_sessions = 0;
-    
-    foreach ($personal_course_list as $course) {       
-        if (!empty($course['id_session'])) {
-            $my_session_list[$course['id_session']] = true;
-            $count_of_courses_with_sessions++;
-        } else {
-            $count_of_courses_no_sessions++;
+if ($load_dirs) {
+    $url 			= api_get_path(WEB_AJAX_PATH).'document.ajax.php?a=document_preview';
+    $folder_icon 	= api_get_path(WEB_IMG_PATH).'icons/22/folder.png';
+    $close_icon 	= api_get_path(WEB_IMG_PATH).'loading1.gif';
+
+    $htmlHeadXtra[] =  '<script>
+
+    $(document).ready(function() {
+        $(".document_preview_container").hide();
+        $(".document_preview").click(function() {
+            var my_id = this.id;
+            var course_id  = my_id.split("_")[2];
+            var session_id = my_id.split("_")[3];
+
+            //showing div
+            $(".document_preview_container").hide();
+
+            $("#document_result_" +course_id+"_" + session_id).show();
+
+            //Loading
+            var image = $("img", this);
+            image.attr("src", "'.$close_icon.'");
+
+            $.ajax({
+                url: "'.$url.'",
+                data: "course_id="+course_id+"&session_id="+session_id,
+                success: function(return_value) {
+                    image.attr("src", "'.$folder_icon.'");
+                    $("#document_result_" +course_id+"_" + session_id).html(return_value);
+
+                }
+            });
+
+        });
+    });
+    </script>';
+}
+
+use Silex\Application;
+use Symfony\Component\HttpFoundation\Response;
+
+class UserPortalController
+{
+    function indexAction(Application $app)
+    {
+        // Check if a user is enrolled only in one course for going directly to the course after the login.
+        if (api_get_setting('go_to_course_after_login') == 'true') {
+
+            // Get the courses list
+            $personal_course_list 	= UserManager::get_personal_session_course_list(api_get_user_id());
+
+            $my_session_list = array();
+            $count_of_courses_no_sessions = 0;
+            $count_of_courses_with_sessions = 0;
+
+            foreach ($personal_course_list as $course) {
+                if (!empty($course['id_session'])) {
+                    $my_session_list[$course['id_session']] = true;
+                    $count_of_courses_with_sessions++;
+                } else {
+                    $count_of_courses_no_sessions++;
+                }
+            }
+            $count_of_sessions = count($my_session_list);
+
+            if ($count_of_sessions == 1 && $count_of_courses_no_sessions == 0) {
+
+                $key              = array_keys($personal_course_list);
+                $course_info      = $personal_course_list[$key[0]];
+                $course_directory = $course_info['course_info']['path'];
+                $id_session       = isset($course_info['id_session']) ? $course_info['id_session'] : 0;
+
+                $url = api_get_path(WEB_CODE_PATH).'session/?session_id='.$id_session;
+
+                header('location:'.$url);
+                exit;
+            }
+
+            if (!isset($_SESSION['coursesAlreadyVisited']) && $count_of_sessions == 0 && $count_of_courses_no_sessions == 1) {
+                $key              = array_keys($personal_course_list);
+                $course_info      = $personal_course_list[$key[0]];
+                $course_directory = $course_info['course_info']['path'];
+                $id_session       = isset($course_info['id_session']) ? $course_info['id_session'] : 0;
+
+                $url = api_get_path(WEB_COURSE_PATH).$course_directory.'/?id_session='.$id_session;
+                header('location:'.$url);
+                exit;
+            }
+        }
+
+        /* Sniffing system */
+/*
+        //store posts to sessions
+        if ($_SESSION['sniff_navigator']!="checked") {
+            $_SESSION['sniff_navigator']=Security::remove_XSS($_POST['sniff_navigator']);
+            $_SESSION['sniff_screen_size_w']=Security::remove_XSS($_POST['sniff_navigator_screen_size_w']);
+            $_SESSION['sniff__screen_size_h']=Security::remove_XSS($_POST['sniff_navigator_screen_size_h']);
+            $_SESSION['sniff_type_mimetypes']=Security::remove_XSS($_POST['sniff_navigator_type_mimetypes']);
+            $_SESSION['sniff_suffixes_mimetypes']=Security::remove_XSS($_POST['sniff_navigator_suffixes_mimetypes']);
+            $_SESSION['sniff_list_plugins']=Security::remove_XSS($_POST['sniff_navigator_list_plugins']);
+            $_SESSION['sniff_check_some_activex']=Security::remove_XSS($_POST['sniff_navigator_check_some_activex']);
+            $_SESSION['sniff_check_some_plugins']=Security::remove_XSS($_POST['sniff_navigator_check_some_plugins']);
+            $_SESSION['sniff_java']=Security::remove_XSS($_POST['sniff_navigator_java']);
+            $_SESSION['sniff_java_sun_ver']=Security::remove_XSS($_POST['sniff_navigator_java_sun_ver']);
+        }*/
+
+        // Main courses and session list
+        $courses_and_sessions = PageController::return_courses_and_sessions(api_get_user_id());
+
+        //Show the chamilo mascot
+        if (empty($courses_and_sessions) && !isset($_GET['history'])) {
+            $app['template']->assign('welcome_to_course_block', self::return_welcome_to_course_block($app));
         }
+
+        $app['template']->assign('content', $courses_and_sessions);
+
+        /*
+        if (api_get_setting('allow_browser_sniffer') == 'true') {
+            if ($_SESSION['sniff_navigator']!="checked") {
+                $app['template']->assign('show_sniff', 	1);
+            } else {
+                $app['template']->assign('show_sniff', 	0);
+            }
+        }
+
+        //check for flash and message
+
+        $sniff_notification = '';
+        $some_activex=$_SESSION['sniff_check_some_activex'];
+        $some_plugins=$_SESSION['sniff_check_some_plugins'];
+
+        if(!empty($some_activex) || !empty($some_plugins)){
+            if (! preg_match("/flash_yes/", $some_activex) && ! preg_match("/flash_yes/", $some_plugins)) {
+                $sniff_notification = Display::return_message(get_lang('NoFlash'), 'warning', true);
+                //js verification - To annoying of redirecting every time the page
+                $app['template']->assign('sniff_notification',  $sniff_notification);
+            }
+        }*/
+
+        $app['template']->assign('profile_block', 				PageController::return_profile_block());
+        $app['template']->assign('user_image_block',            PageController::return_user_image_block());
+        $app['template']->assign('course_block',				PageController::return_course_block());
+        $app['template']->assign('navigation_course_links', 	$app['template']->return_navigation_links());
+        $app['template']->assign('reservation_block', 			PageController::return_reservation_block());
+        $app['template']->assign('search_block', 				PageController::return_search_block());
+        $app['template']->assign('classes_block', 				PageController::return_classes_block());
+        $app['template']->assign('skills_block',                PageController::return_skills_links());
+
+        // Deleting the session_id.
+        Session::erase('session_id');
+
+        $response = $app['template']->render_layout('layout_2_col.tpl');
+
+        //return new Response($response, 200, array('Cache-Control' => 's-maxage=3600, private'));
+        return new Response($response, 200, array());
     }
-    $count_of_sessions = count($my_session_list);    
 
-    if ($count_of_sessions == 1 && $count_of_courses_no_sessions == 0) {
-     
-        $key              = array_keys($personal_course_list);
-        $course_info      = $personal_course_list[$key[0]];
-        $course_directory = $course_info['course_info']['path'];
-        $id_session       = isset($course_info['id_session']) ? $course_info['id_session'] : 0;
+    function return_welcome_to_course_block(Application $app) {
+        $count_courses = CourseManager::count_courses();
+        $tpl = $app['template']->get_template('layout/welcome_to_course.tpl');
 
-        $url = api_get_path(WEB_CODE_PATH).'session/?session_id='.$id_session; 
+        $course_catalog_url = api_get_path(WEB_CODE_PATH).'auth/courses.php';
+        $course_list_url = api_get_path(WEB_PATH).'user_portal.php';
 
-        header('location:'.$url);            
-        exit;
+        $app['template']->assign('course_catalog_url', $course_catalog_url);
+        $app['template']->assign('course_list_url', $course_list_url);
+        $app['template']->assign('course_catalog_link', Display::url(get_lang('here'), $course_catalog_url));
+        $app['template']->assign('course_list_link', Display::url(get_lang('here'), $course_list_url));
+        $app['template']->assign('count_courses', $count_courses);
+
+        return $app['template']->fetch($tpl);
     }
-    
-    if (!isset($_SESSION['coursesAlreadyVisited']) && $count_of_sessions == 0 && $count_of_courses_no_sessions == 1) {
-        $key              = array_keys($personal_course_list);
-        $course_info      = $personal_course_list[$key[0]];
-        $course_directory = $course_info['course_info']['path'];
-        $id_session       = isset($course_info['id_session']) ? $course_info['id_session'] : 0;
-       
-        $url = api_get_path(WEB_COURSE_PATH).$course_directory.'/?id_session='.$id_session;
-        header('location:'.$url);            
-        exit;
-    } 
-}
-$nameTools = get_lang('MyCourses');
-$this_section = SECTION_COURSES;
 
-/*
-    Header
-    Include the HTTP, HTML headers plus the top banner.
-*/
-if ($load_dirs) {
-	$url 			= api_get_path(WEB_AJAX_PATH).'document.ajax.php?a=document_preview';
-	$folder_icon 	= api_get_path(WEB_IMG_PATH).'icons/22/folder.png';
-	$close_icon 	= api_get_path(WEB_IMG_PATH).'loading1.gif';
-	
-	$htmlHeadXtra[] =  '<script>
-	
-	$(document).ready(function() {    
-		$(".document_preview_container").hide();		
-		$(".document_preview").click(function() {
-			var my_id = this.id;
-			var course_id  = my_id.split("_")[2];
-			var session_id = my_id.split("_")[3];
-			
-			//showing div
-			$(".document_preview_container").hide();
-					
-			$("#document_result_" +course_id+"_" + session_id).show();	
-			
-			//Loading		
-			var image = $("img", this);
-			image.attr("src", "'.$close_icon.'");		
-					
-			$.ajax({
-				url: "'.$url.'",
-				data: "course_id="+course_id+"&session_id="+session_id,
-	            success: function(return_value) {
-	            	image.attr("src", "'.$folder_icon.'");
-	            	$("#document_result_" +course_id+"_" + session_id).html(return_value);
-	            	
-	            }
-	        });
-	        
-		});
-	});
-	</script>';
-}
 
-/* Sniffing system */
-
-//store posts to sessions
-if ($_SESSION['sniff_navigator']!="checked") {
-	$_SESSION['sniff_navigator']=Security::remove_XSS($_POST['sniff_navigator']);
-	$_SESSION['sniff_screen_size_w']=Security::remove_XSS($_POST['sniff_navigator_screen_size_w']);
-	$_SESSION['sniff__screen_size_h']=Security::remove_XSS($_POST['sniff_navigator_screen_size_h']);
-	$_SESSION['sniff_type_mimetypes']=Security::remove_XSS($_POST['sniff_navigator_type_mimetypes']);
-	$_SESSION['sniff_suffixes_mimetypes']=Security::remove_XSS($_POST['sniff_navigator_suffixes_mimetypes']);
-	$_SESSION['sniff_list_plugins']=Security::remove_XSS($_POST['sniff_navigator_list_plugins']);
-	$_SESSION['sniff_check_some_activex']=Security::remove_XSS($_POST['sniff_navigator_check_some_activex']);
-	$_SESSION['sniff_check_some_plugins']=Security::remove_XSS($_POST['sniff_navigator_check_some_plugins']);
-	$_SESSION['sniff_java']=Security::remove_XSS($_POST['sniff_navigator_java']);
-	$_SESSION['sniff_java_sun_ver']=Security::remove_XSS($_POST['sniff_navigator_java_sun_ver']);
-}
+    function check_last_login() {
+        /**
+         * @todo This piece of code should probably move to local.inc.php where the actual login procedure is handled.
+         * @todo Check if this code is used. I think this code is never executed because after clicking the submit button
+         *       the code does the stuff in local.inc.php and then redirects to index.php or user_portal.php depending
+         *       on api_get_setting('page_after_login').
+         */
 
-/* MAIN CODE */
+        if (!empty($_POST['submitAuth'])) {
+            // The user has been already authenticated, we are now to find the last login of the user.
+            if (!empty($this->user_id)) {
+                $track_login_table      = Database :: get_statistic_table(TABLE_STATISTIC_TRACK_E_LOGIN);
+                $sql_last_login = "SELECT login_date
+                                    FROM $track_login_table
+                                    WHERE login_user_id = '".$this->user_id."'
+                                    ORDER BY login_date DESC LIMIT 1";
+                $result_last_login = Database::query($sql_last_login);
+                if (!$result_last_login) {
+                    if (Database::num_rows($result_last_login) > 0) {
+                        $user_last_login_datetime = Database::fetch_array($result_last_login);
+                        $user_last_login_datetime = $user_last_login_datetime[0];
+                        Session::write('user_last_login_datetime', $user_last_login_datetime);
+                    }
+                }
+                Database::free_result($result_last_login);
 
-$controller = new IndexManager(get_lang('MyCourses'));
+                if (api_is_platform_admin()) {
+                    // decode all open event informations and fill the track_c_* tables
+                    include api_get_path(LIBRARY_PATH).'stats.lib.inc.php';
+                    decodeOpenInfos();
+                }
+            }
+            // End login -- if ($_POST['submitAuth'])
+        } else {
+            // Only if login form was not sent because if the form is sent the user was already on the page.
+            event_open();
+        }
+    }
 
-$user_id = api_get_user_id();
+	function set_login_form() {
+		global $loginFailed;
 
-// Main courses and session list
-$courses_and_sessions = $controller->return_courses_and_sessions($user_id);
+		$login_form = '';
 
-//Show the chamilo mascot
-if (empty($courses_and_sessions) && !isset($_GET['history'])) {
-    $controller->tpl->assign('welcome_to_course_block', $controller->return_welcome_to_course_block());
-}
+		if (!($this->user_id) || api_is_anonymous($this->user_id)) {
 
-$controller->tpl->assign('content', $courses_and_sessions);
- 
-if (api_get_setting('allow_browser_sniffer') == 'true') {
-	if ($_SESSION['sniff_navigator']!="checked") {
-		$controller->tpl->assign('show_sniff', 	1);
-	} else {
-		$controller->tpl->assign('show_sniff', 	0);
+			// Only display if the user isn't logged in.
+			$this->page->assign('login_language_form', api_display_language_form(true));
+			$this->page->assign('login_form',  self::display_login_form());
+
+			if ($loginFailed) {
+				$this->page->assign('login_failed',  self::handle_login_failed());
+			}
+
+			if (api_get_setting('allow_lostpassword') == 'true' || api_get_setting('allow_registration') == 'true') {
+				$login_form .= '<ul class="nav nav-list">';
+				if (api_get_setting('allow_registration') != 'false') {
+					$login_form .= '<li><a href="main/auth/inscription.php">'.get_lang('Reg').'</a></li>';
+				}
+				if (api_get_setting('allow_lostpassword') == 'true') {
+					$login_form .= '<li><a href="main/auth/lostPassword.php">'.get_lang('LostPassword').'</a></li>';
+				}
+				$login_form .= '</ul>';
+			}
+			$this->page->assign('login_options',  $login_form);
+		}
 	}
-}
 
-//check for flash and message
-$sniff_notification = '';
-$some_activex=$_SESSION['sniff_check_some_activex'];
-$some_plugins=$_SESSION['sniff_check_some_plugins'];
-
-if(!empty($some_activex) || !empty($some_plugins)){
-	if (! preg_match("/flash_yes/", $some_activex) && ! preg_match("/flash_yes/", $some_plugins)) {
-		$sniff_notification = Display::return_message(get_lang('NoFlash'), 'warning', true);
-		//js verification - To annoying of redirecting every time the page
-		$controller->tpl->assign('sniff_notification',  $sniff_notification);
-	}  
+	/**
+     * Alias for the online_logout() function
+	 */
+	function logout() {
+        online_logout($this->user_id, true);
+	}
+
+	/**
+	 * This function checks if there are courses that are open to the world in the platform course categories (=faculties)
+	 *
+	 * @param string $category
+	 * @return boolean
+	 */
+	function category_has_open_courses($category) {
+		$setting_show_also_closed_courses = api_get_setting('show_closed_courses') == 'true';
+		$main_course_table = Database :: get_main_table(TABLE_MAIN_COURSE);
+        $category = Database::escape_string($category);
+		$sql_query = "SELECT * FROM $main_course_table WHERE category_code='$category'";
+		$sql_result = Database::query($sql_query);
+		while ($course = Database::fetch_array($sql_result)) {
+			if (!$setting_show_also_closed_courses) {
+				if ((api_get_user_id() > 0 && $course['visibility'] == COURSE_VISIBILITY_OPEN_PLATFORM) || ($course['visibility'] == COURSE_VISIBILITY_OPEN_WORLD)) {
+					return true; //at least one open course
+				}
+			} else {
+				if (isset($course['visibility'])) {
+					return true; // At least one course (it does not matter weither it's open or not because $setting_show_also_closed_courses = true).
+				}
+			}
+		}
+		return false;
+	}
+
+	/**
+	 * Reacts on a failed login:
+	 * Displays an explanation with a link to the registration form.
+	 *
+	 * @version 1.0.1
+	 */
+	function handle_login_failed() {
+        $message = get_lang('InvalidId');
+
+		if (!isset($_GET['error'])) {
+			if (api_is_self_registration_allowed()) {
+				$message = get_lang('InvalidForSelfRegistration');
+			}
+		} else {
+			switch ($_GET['error']) {
+				case '':
+					if (api_is_self_registration_allowed()) {
+						$message = get_lang('InvalidForSelfRegistration');
+					}
+					break;
+				case 'account_expired':
+					$message = get_lang('AccountExpired');
+					break;
+				case 'account_inactive':
+					$message = get_lang('AccountInactive');
+					break;
+				case 'user_password_incorrect':
+					$message = get_lang('InvalidId');
+					break;
+				case 'access_url_inactive':
+					$message = get_lang('AccountURLInactive');
+					break;
+                case 'unrecognize_sso_origin':
+                    //$message = get_lang('SSOError');
+                    break;
+			}
+		}
+		return Display::return_message($message, 'error');
+	}
+
+	/**
+	* retrieves all the courses that the user has already subscribed to
+    * @author Patrick Cool <patrick.cool@UGent.be>, Ghent University, Belgium
+    * @param int $user_id: the id of the user
+    * @return array an array containing all the information of the courses of the given user
+    */
+	function get_courses_of_user($user_id) {
+		$table_course       = Database::get_main_table(TABLE_MAIN_COURSE);
+    	$table_course_user  = Database::get_main_table(TABLE_MAIN_COURSE_USER);
+		// Secondly we select the courses that are in a category (user_course_cat <> 0) and sort these according to the sort of the category
+		$user_id = intval($user_id);
+		$sql_select_courses = "SELECT course.code k, course.visual_code  vc, course.subscribe subscr, course.unsubscribe unsubscr,
+    		course.title i, course.tutor_name t, course.db_name db, course.directory dir, course_rel_user.status status,
+    		course_rel_user.sort sort, course_rel_user.user_course_cat user_course_cat
+    		FROM    $table_course       course,
+    		$table_course_user  course_rel_user
+    		WHERE course.code = course_rel_user.course_code
+    		AND   course_rel_user.user_id = '".$user_id."'
+                                    AND course_rel_user.relation_type<>".COURSE_RELATION_TYPE_RRHH."
+                                    ORDER BY course_rel_user.sort ASC";
+	    $result = Database::query($sql_select_courses);
+	    $courses = array();
+	    while ($row = Database::fetch_array($result)) {
+	        // We only need the database name of the course.
+	        $courses[$row['k']] = array('db' => $row['db'], 'code' => $row['k'], 'visual_code' => $row['vc'], 'title' => $row['i'], 'directory' => $row['dir'], 'status' => $row['status'], 'tutor' => $row['t'], 'subscribe' => $row['subscr'], 'unsubscribe' => $row['unsubscr'], 'sort' => $row['sort'], 'user_course_category' => $row['user_course_cat']);
+	    }
+		return $courses;
+	}
 }
 
-$controller->tpl->assign('profile_block', 				$controller->return_profile_block());
-$controller->tpl->assign('user_image_block',            $controller->return_user_image_block());
-$controller->tpl->assign('course_block',				$controller->return_course_block());
-$controller->tpl->assign('navigation_course_links', 	$controller->return_navigation_links());
-$controller->tpl->assign('reservation_block', 			$controller->return_reservation_block());
-$controller->tpl->assign('search_block', 				$controller->return_search_block());
-$controller->tpl->assign('classes_block', 				$controller->return_classes_block());
-
-//if (api_is_platform_admin() || api_is_drh()) {
-    $controller->tpl->assign('skills_block',            $controller->return_skills_links());
-//}
-$controller->tpl->display_two_col_template();
-
-// Deleting the session_id.
-Session::erase('session_id');
+$app->get('/', 'UserPortalController::indexAction');
+$app->run();
+//$app['http_cache']->run();

+ 1 - 1
vendor/autoload.php

@@ -4,4 +4,4 @@
 
 require_once __DIR__ . '/composer' . '/autoload_real.php';
 
-return ComposerAutoloaderInit::getLoader();
+return ComposerAutoloaderInit33af5fd183707f07bf76906a8439a661::getLoader();

+ 36 - 2
vendor/composer/autoload_classmap.php

@@ -47,6 +47,7 @@ return array(
     'AttendanceLink' => $baseDir . '/main/gradebook/lib/be/attendancelink.class.php',
     'Attribute_Translator' => $baseDir . '/main/inc/lib/phpdocx/pdf/include/attribute_translator.cls.php',
     'Auth' => $baseDir . '/main/inc/lib/fckeditor/editor/plugins/ajaxfilemanager/inc/class.auth.php',
+    'AutoLoader' => $baseDir . '/main/inc/lib/phpdocx/classes/AutoLoader.inc',
     'Autoload' => $baseDir . '/main/inc/lib/autoload.class.php',
     'AutoloadClassFinder' => $baseDir . '/main/inc/lib/autoload.class.php',
     'BaseFacebook' => $baseDir . '/main/auth/external_login/facebook-php-sdk/src/base_facebook.php',
@@ -103,6 +104,30 @@ return array(
     'CourseSession' => $baseDir . '/main/coursecopy/classes/CourseSession.class.php',
     'CoursesController' => $baseDir . '/main/auth/courses_controller.php',
     'Cpdf' => $baseDir . '/main/inc/lib/phpdocx/pdf/lib/class.pdf.php',
+    'CreateChartRels' => $baseDir . '/main/inc/lib/phpdocx/classes/CreateChartRels.inc',
+    'CreateDocx' => $baseDir . '/main/inc/lib/phpdocx/classes/CreateDocx.inc',
+    'CreateElement' => $baseDir . '/main/inc/lib/phpdocx/classes/CreateElement.inc',
+    'CreateExcelSharedStrings' => $baseDir . '/main/inc/lib/phpdocx/classes/CreateExcelSharedStrings.inc',
+    'CreateExcelSheet' => $baseDir . '/main/inc/lib/phpdocx/classes/CreateExcelSheet.inc',
+    'CreateExcelTable' => $baseDir . '/main/inc/lib/phpdocx/classes/CreateExcelTable.inc',
+    'CreateFontTable' => $baseDir . '/main/inc/lib/phpdocx/classes/CreateFontTable.inc',
+    'CreateFooter' => $baseDir . '/main/inc/lib/phpdocx/classes/CreateFooter.inc',
+    'CreateFootnote' => $baseDir . '/main/inc/lib/phpdocx/classes/CreateFootnote.inc',
+    'CreateGraphic' => $baseDir . '/main/inc/lib/phpdocx/classes/CreateGraphic.inc',
+    'CreateHeader' => $baseDir . '/main/inc/lib/phpdocx/classes/CreateHeader.inc',
+    'CreateImage' => $baseDir . '/main/inc/lib/phpdocx/classes/CreateImage.inc',
+    'CreateLink' => $baseDir . '/main/inc/lib/phpdocx/classes/CreateLink.inc',
+    'CreateList' => $baseDir . '/main/inc/lib/phpdocx/classes/CreateList.inc',
+    'CreatePage' => $baseDir . '/main/inc/lib/phpdocx/classes/CreatePage.inc',
+    'CreateSettings' => $baseDir . '/main/inc/lib/phpdocx/classes/CreateSettings.inc',
+    'CreateStyle' => $baseDir . '/main/inc/lib/phpdocx/classes/CreateStyle.inc',
+    'CreateStyleTable' => $baseDir . '/main/inc/lib/phpdocx/classes/CreateStyleTable.inc',
+    'CreateTable' => $baseDir . '/main/inc/lib/phpdocx/classes/CreateTable.inc',
+    'CreateTableContents' => $baseDir . '/main/inc/lib/phpdocx/classes/CreateTableContents.inc',
+    'CreateText' => $baseDir . '/main/inc/lib/phpdocx/classes/CreateText.inc',
+    'CreateTheme1' => $baseDir . '/main/inc/lib/phpdocx/classes/CreateTheme1.inc',
+    'CreateWebSettings' => $baseDir . '/main/inc/lib/phpdocx/classes/CreateWebSettings.inc',
+    'CreateXlsx' => $baseDir . '/main/inc/lib/phpdocx/classes/CreateXlsx.inc',
     'CsvObjectWriter' => $baseDir . '/main/inc/lib/system/io/csv_object_writer.class.php',
     'CsvReader' => $baseDir . '/main/inc/lib/system/io/csv_reader.class.php',
     'CsvWriter' => $baseDir . '/main/inc/lib/system/io/csv_writer.class.php',
@@ -1062,7 +1087,9 @@ return array(
     'LoggerRoot' => $baseDir . '/main/inc/lib/phpdocx/lib/log4php/LoggerRoot.php',
     'Login' => $baseDir . '/main/inc/lib/login.lib.php',
     'LoginRedirection' => $baseDir . '/main/inc/lib/login_redirection.class.php',
+    'MagpieRSS' => $baseDir . '/main/inc/lib/magpierss/rss_parse.inc',
     'Matching' => $baseDir . '/main/exercice/matching.class.php',
+    'MediaQuestion' => $baseDir . '/main/exercice/media_question.class.php',
     'MergeLibraryFSTools' => $baseDir . '/main/inc/lib/htmlpurifier/maintenance/generate-standalone.php',
     'MessageManager' => $baseDir . '/main/inc/lib/message.lib.php',
     'Model' => $baseDir . '/main/inc/lib/model.lib.php',
@@ -1109,6 +1136,7 @@ return array(
     'Null_Frame_Reflower' => $baseDir . '/main/inc/lib/phpdocx/pdf/include/null_frame_reflower.cls.php',
     'Null_Positioner' => $baseDir . '/main/inc/lib/phpdocx/pdf/include/null_positioner.cls.php',
     'OLE' => $baseDir . '/main/inc/lib/pear/OLE/OLE.php',
+    'OLERead' => $baseDir . '/main/inc/lib/pear/excelreader/OLERead.inc',
     'OLE_ChainedBlockStream' => $baseDir . '/main/inc/lib/pear/OLE/ChainedBlockStream.php',
     'OLE_PPS' => $baseDir . '/main/inc/lib/pear/OLE/PPS.php',
     'OLE_PPS_File' => $baseDir . '/main/inc/lib/pear/OLE/PPS/File.php',
@@ -1131,6 +1159,7 @@ return array(
     'PHP_Evaluator' => $baseDir . '/main/inc/lib/phpdocx/pdf/include/php_evaluator.cls.php',
     'POP3' => $baseDir . '/main/inc/lib/phpmailer/class.pop3.php',
     'Page' => $baseDir . '/main/inc/lib/page.class.php',
+    'PageController' => $baseDir . '/main/inc/lib/page.lib.php',
     'Page_Cache' => $baseDir . '/main/inc/lib/phpdocx/pdf/include/page_cache.cls.php',
     'Page_Frame_Decorator' => $baseDir . '/main/inc/lib/phpdocx/pdf/include/page_frame_decorator.cls.php',
     'Page_Frame_Reflower' => $baseDir . '/main/inc/lib/phpdocx/pdf/include/page_frame_reflower.cls.php',
@@ -1173,6 +1202,7 @@ return array(
     'QuickformForm' => $baseDir . '/main/inc/lib/pear/HTML/QuickForm/Renderer/Object.php',
     'Quiz' => $baseDir . '/main/coursecopy/classes/Quiz.class.php',
     'QuizQuestion' => $baseDir . '/main/coursecopy/classes/QuizQuestion.class.php',
+    'RSSCache' => $baseDir . '/main/inc/lib/magpierss/rss_cache.inc',
     'Redirect' => $baseDir . '/main/inc/lib/redirect.class.php',
     'Renderer' => $baseDir . '/main/inc/lib/phpdocx/pdf/include/renderer.cls.php',
     'Request' => $baseDir . '/main/inc/lib/system/web/request.class.php',
@@ -1206,6 +1236,7 @@ return array(
     'SessionFieldOption' => $baseDir . '/main/inc/lib/session_field_option.lib.php',
     'SessionFieldValue' => $baseDir . '/main/inc/lib/session_field_value.lib.php',
     'SessionHandler' => $baseDir . '/main/inc/lib/session_handler.class.php',
+    'SessionHandlerInterface' => $baseDir . '/vendor/symfony/http-foundation/Symfony/Component/HttpFoundation/Resources/stubs/SessionHandlerInterface.php',
     'SessionManager' => $baseDir . '/main/inc/lib/sessionmanager.lib.php',
     'SessionModel' => $baseDir . '/main/inc/lib/session_model.lib.php',
     'Shibboleth\\Admin' => $baseDir . '/main/auth/shibboleth/app/model/admin.class.php',
@@ -1239,6 +1270,7 @@ return array(
     'SkillRelSkill' => $baseDir . '/main/inc/lib/skill.lib.php',
     'SkillRelUser' => $baseDir . '/main/inc/lib/skill.lib.php',
     'SkillVisualizer' => $baseDir . '/main/inc/lib/skill.visualizer.lib.php',
+    'Snoopy' => $baseDir . '/main/inc/lib/magpierss/extlib/Snoopy.class.inc',
     'SocialManager' => $baseDir . '/main/inc/lib/social.lib.php',
     'SortableTable' => $baseDir . '/main/inc/lib/sortable_table.class.php',
     'SortableTableFromArray' => $baseDir . '/main/inc/lib/sortable_table.class.php',
@@ -1363,6 +1395,7 @@ return array(
     'TrackingCourseLog' => $baseDir . '/main/inc/lib/tracking.lib.php',
     'TrackingUserLog' => $baseDir . '/main/inc/lib/tracking.lib.php',
     'TrackingUserLogCSV' => $baseDir . '/main/inc/lib/tracking.lib.php',
+    'TransformDoc' => $baseDir . '/main/inc/lib/phpdocx/classes/TransformDoc.inc',
     'Twig_Autoloader' => $baseDir . '/main/inc/lib/symfony/Twig/Autoloader.php',
     'Twig_Compiler' => $baseDir . '/main/inc/lib/symfony/Twig/Compiler.php',
     'Twig_CompilerInterface' => $baseDir . '/main/inc/lib/symfony/Twig/CompilerInterface.php',
@@ -1581,12 +1614,13 @@ return array(
     'mPDF' => $baseDir . '/main/inc/lib/mpdf/mpdf.php',
     'manager' => $baseDir . '/main/inc/lib/fckeditor/editor/plugins/ajaxfilemanager/inc/class.manager.php',
     'net\\HttpChannel' => $baseDir . '/main/inc/lib/system/net/http_channel.class.php',
+    'null' => $baseDir . '/main/newscorm/lp_admin_view.php',
     'nusoap_base' => $baseDir . '/main/inc/lib/nusoap/nusoap.php',
     'nusoap_client' => $baseDir . '/main/inc/lib/nusoap/class.soapclient.php',
     'nusoap_client_mime' => $baseDir . '/main/inc/lib/nusoap/nusoapmime.php',
     'nusoap_fault' => $baseDir . '/main/inc/lib/nusoap/class.soap_fault.php',
     'nusoap_parser' => $baseDir . '/main/inc/lib/nusoap/class.soap_parser.php',
-    'nusoap_server' => $baseDir . '/main/inc/lib/nusoap/nusoap.php',
+    'nusoap_server' => $baseDir . '/main/inc/lib/nusoap/class.soap_server.php',
     'nusoap_server_mime' => $baseDir . '/main/inc/lib/nusoap/nusoapmime.php',
     'nusoap_wsdlcache' => $baseDir . '/main/inc/lib/nusoap/class.wsdlcache.php',
     'nusoap_xmlschema' => $baseDir . '/main/inc/lib/nusoap/class.xmlschema.php',
@@ -1619,7 +1653,7 @@ return array(
     'search_processor' => $baseDir . '/main/inc/lib/search/tool_processors/search_processor.class.php',
     'soap_fault' => $baseDir . '/main/inc/lib/nusoap/class.soap_fault.php',
     'soap_parser' => $baseDir . '/main/inc/lib/nusoap/class.soap_parser.php',
-    'soap_server' => $baseDir . '/main/inc/lib/nusoap/nusoap.php',
+    'soap_server' => $baseDir . '/main/inc/lib/nusoap/class.soap_server.php',
     'soap_transport_http' => $baseDir . '/main/inc/lib/nusoap/class.soap_transport_http.php',
     'soapclient' => $baseDir . '/main/inc/lib/nusoap/class.soapclient.php',
     'soapclientmime' => $baseDir . '/main/inc/lib/nusoap/nusoapmime.php',

+ 10 - 0
vendor/composer/autoload_namespaces.php

@@ -6,5 +6,15 @@ $vendorDir = dirname(__DIR__);
 $baseDir = dirname($vendorDir);
 
 return array(
+    'Twig_' => $vendorDir . '/twig/twig/lib/',
+    'Symfony\\Component\\Yaml' => $vendorDir . '/symfony/yaml/',
+    'Symfony\\Component\\Routing\\' => $vendorDir . '/symfony/routing/',
+    'Symfony\\Component\\HttpKernel\\' => $vendorDir . '/symfony/http-kernel/',
+    'Symfony\\Component\\HttpFoundation\\' => $vendorDir . '/symfony/http-foundation/',
+    'Symfony\\Component\\EventDispatcher\\' => $vendorDir . '/symfony/event-dispatcher/',
+    'Symfony\\Component\\Config' => $vendorDir . '/symfony/config/',
+    'Silex' => $vendorDir . '/silex/silex/src/',
+    'Pimple' => $vendorDir . '/pimple/pimple/lib/',
+    'Monolog' => $vendorDir . '/monolog/monolog/src/',
     'Chamilo' => $baseDir . '/src/',
 );

+ 11 - 3
vendor/composer/autoload_real.php

@@ -2,19 +2,27 @@
 
 // autoload_real.php generated by Composer
 
-require __DIR__ . '/ClassLoader.php';
-
-class ComposerAutoloaderInit
+class ComposerAutoloaderInit33af5fd183707f07bf76906a8439a661
 {
     private static $loader;
 
+    public static function loadClassLoader($class)
+    {
+        if ('Composer\Autoload\ClassLoader' === $class) {
+            require __DIR__ . '/ClassLoader.php';
+        }
+    }
+
     public static function getLoader()
     {
         if (null !== static::$loader) {
             return static::$loader;
         }
 
+        spl_autoload_register(array('ComposerAutoloaderInit33af5fd183707f07bf76906a8439a661', 'loadClassLoader'));
         static::$loader = $loader = new \Composer\Autoload\ClassLoader();
+        spl_autoload_unregister(array('ComposerAutoloaderInit33af5fd183707f07bf76906a8439a661', 'loadClassLoader'));
+
         $vendorDir = dirname(__DIR__);
         $baseDir = dirname($vendorDir);
 

+ 564 - 1
vendor/composer/installed.json

@@ -1,3 +1,566 @@
 [
-
+    {
+        "name": "symfony/event-dispatcher",
+        "version": "dev-master",
+        "version_normalized": "9999999-dev",
+        "target-dir": "Symfony/Component/EventDispatcher",
+        "source": {
+            "type": "git",
+            "url": "https://github.com/symfony/EventDispatcher",
+            "reference": "eb290a447c0af5bea0d3de5d95d498afd8c82f89"
+        },
+        "dist": {
+            "type": "zip",
+            "url": "https://github.com/symfony/EventDispatcher/archive/eb290a447c0af5bea0d3de5d95d498afd8c82f89.zip",
+            "reference": "eb290a447c0af5bea0d3de5d95d498afd8c82f89",
+            "shasum": ""
+        },
+        "require": {
+            "php": ">=5.3.3"
+        },
+        "require-dev": {
+            "symfony/dependency-injection": "2.2.*"
+        },
+        "suggest": {
+            "symfony/dependency-injection": "2.2.*",
+            "symfony/http-kernel": "2.2.*"
+        },
+        "time": "2012-11-13 14:08:04",
+        "type": "library",
+        "extra": {
+            "branch-alias": {
+                "dev-master": "2.2-dev"
+            }
+        },
+        "installation-source": "source",
+        "autoload": {
+            "psr-0": {
+                "Symfony\\Component\\EventDispatcher\\": ""
+            }
+        },
+        "notification-url": "https://packagist.org/downloads/",
+        "license": [
+            "MIT"
+        ],
+        "authors": [
+            {
+                "name": "Fabien Potencier",
+                "email": "fabien@symfony.com"
+            },
+            {
+                "name": "Symfony Community",
+                "homepage": "http://symfony.com/contributors"
+            }
+        ],
+        "description": "Symfony EventDispatcher Component",
+        "homepage": "http://symfony.com"
+    },
+    {
+        "name": "pimple/pimple",
+        "version": "dev-master",
+        "version_normalized": "9999999-dev",
+        "source": {
+            "type": "git",
+            "url": "git://github.com/fabpot/Pimple.git",
+            "reference": "86df0604a10c5faf20b466ae6a0b762cc6ed0a35"
+        },
+        "dist": {
+            "type": "zip",
+            "url": "https://github.com/fabpot/Pimple/archive/86df0604a10c5faf20b466ae6a0b762cc6ed0a35.zip",
+            "reference": "86df0604a10c5faf20b466ae6a0b762cc6ed0a35",
+            "shasum": ""
+        },
+        "require": {
+            "php": ">=5.3.0"
+        },
+        "time": "2012-11-11 08:32:34",
+        "type": "library",
+        "extra": {
+            "branch-alias": {
+                "dev-master": "1.0.x-dev"
+            }
+        },
+        "installation-source": "source",
+        "autoload": {
+            "psr-0": {
+                "Pimple": "lib/"
+            }
+        },
+        "notification-url": "https://packagist.org/downloads/",
+        "license": [
+            "MIT"
+        ],
+        "authors": [
+            {
+                "name": "Fabien Potencier",
+                "email": "fabien@symfony.com"
+            }
+        ],
+        "description": "Pimple is a simple Dependency Injection Container for PHP 5.3",
+        "homepage": "http://pimple.sensiolabs.org",
+        "keywords": [
+            "dependency injection",
+            "container"
+        ]
+    },
+    {
+        "name": "silex/silex",
+        "version": "dev-master",
+        "version_normalized": "9999999-dev",
+        "source": {
+            "type": "git",
+            "url": "git://github.com/fabpot/Silex.git",
+            "reference": "7e5862934aa831ededc9ca188a56816dc46e70b4"
+        },
+        "dist": {
+            "type": "zip",
+            "url": "https://github.com/fabpot/Silex/archive/7e5862934aa831ededc9ca188a56816dc46e70b4.zip",
+            "reference": "7e5862934aa831ededc9ca188a56816dc46e70b4",
+            "shasum": ""
+        },
+        "require": {
+            "php": ">=5.3.3",
+            "pimple/pimple": "1.*",
+            "symfony/event-dispatcher": ">=2.1,<2.3-dev",
+            "symfony/http-foundation": ">=2.1,<2.3-dev",
+            "symfony/http-kernel": ">=2.1,<2.3-dev",
+            "symfony/routing": ">=2.1,<2.3-dev"
+        },
+        "require-dev": {
+            "monolog/monolog": ">=1.0.0,<1.2-dev",
+            "twig/twig": ">=1.8.0,<2.0-dev",
+            "swiftmailer/swiftmailer": "4.2.*",
+            "doctrine/dbal": ">=2.2.0,<2.4.0-dev",
+            "symfony/security": ">=2.1,<2.3-dev",
+            "symfony/config": ">=2.1,<2.3-dev",
+            "symfony/locale": ">=2.1,<2.3-dev",
+            "symfony/form": ">=2.1,<2.3-dev",
+            "symfony/browser-kit": ">=2.1,<2.3-dev",
+            "symfony/css-selector": ">=2.1,<2.3-dev",
+            "symfony/finder": ">=2.1,<2.3-dev",
+            "symfony/monolog-bridge": ">=2.1,<2.3-dev",
+            "symfony/process": ">=2.1,<2.3-dev",
+            "symfony/translation": ">=2.1,<2.3-dev",
+            "symfony/twig-bridge": ">=2.1,<2.3-dev",
+            "symfony/validator": ">=2.1,<2.3-dev",
+            "symfony/serializer": ">=2.1,<2.3-dev"
+        },
+        "suggest": {
+            "symfony/browser-kit": ">=2.1,<2.3-dev",
+            "symfony/css-selector": ">=2.1,<2.3-dev",
+            "symfony/dom-crawler": ">=2.1,<2.3-dev"
+        },
+        "time": "2012-12-02 18:04:58",
+        "type": "library",
+        "extra": {
+            "branch-alias": {
+                "dev-master": "1.0.x-dev"
+            }
+        },
+        "installation-source": "source",
+        "autoload": {
+            "psr-0": {
+                "Silex": "src/"
+            }
+        },
+        "notification-url": "https://packagist.org/downloads/",
+        "license": [
+            "MIT"
+        ],
+        "authors": [
+            {
+                "name": "Fabien Potencier",
+                "email": "fabien@symfony.com"
+            },
+            {
+                "name": "Igor Wiedler",
+                "email": "igor@wiedler.ch",
+                "homepage": "http://wiedler.ch/igor/"
+            }
+        ],
+        "description": "The PHP micro-framework based on the Symfony2 Components",
+        "homepage": "http://silex.sensiolabs.org",
+        "keywords": [
+            "microframework"
+        ]
+    },
+    {
+        "name": "monolog/monolog",
+        "version": "dev-master",
+        "version_normalized": "9999999-dev",
+        "source": {
+            "type": "git",
+            "url": "https://github.com/Seldaek/monolog",
+            "reference": "546225bed27bea7d00b836e0f7d8954272e0cf42"
+        },
+        "dist": {
+            "type": "zip",
+            "url": "https://github.com/Seldaek/monolog/archive/546225bed27bea7d00b836e0f7d8954272e0cf42.zip",
+            "reference": "546225bed27bea7d00b836e0f7d8954272e0cf42",
+            "shasum": ""
+        },
+        "require": {
+            "php": ">=5.3.0"
+        },
+        "require-dev": {
+            "mlehner/gelf-php": "1.0.*"
+        },
+        "suggest": {
+            "mlehner/gelf-php": "Allow sending log messages to a GrayLog2 server",
+            "ext-amqp": "Allow sending log messages to an AMQP server (1.0+ required)",
+            "ext-mongo": "Allow sending log messages to a MongoDB server"
+        },
+        "time": "2012-12-04 11:59:29",
+        "type": "library",
+        "extra": {
+            "branch-alias": {
+                "dev-master": "1.3.x-dev"
+            }
+        },
+        "installation-source": "source",
+        "autoload": {
+            "psr-0": {
+                "Monolog": "src/"
+            }
+        },
+        "notification-url": "https://packagist.org/downloads/",
+        "license": [
+            "MIT"
+        ],
+        "authors": [
+            {
+                "name": "Jordi Boggiano",
+                "email": "j.boggiano@seld.be",
+                "homepage": "http://seld.be",
+                "role": "Developer"
+            }
+        ],
+        "description": "Logging for PHP 5.3",
+        "homepage": "http://github.com/Seldaek/monolog",
+        "keywords": [
+            "log",
+            "logging"
+        ]
+    },
+    {
+        "name": "twig/twig",
+        "version": "dev-master",
+        "version_normalized": "9999999-dev",
+        "source": {
+            "type": "git",
+            "url": "git://github.com/fabpot/Twig.git",
+            "reference": "de5aaf2c1d43baafde255a042f5c7cf6122ea3ce"
+        },
+        "dist": {
+            "type": "zip",
+            "url": "https://github.com/fabpot/Twig/archive/de5aaf2c1d43baafde255a042f5c7cf6122ea3ce.zip",
+            "reference": "de5aaf2c1d43baafde255a042f5c7cf6122ea3ce",
+            "shasum": ""
+        },
+        "require": {
+            "php": ">=5.2.4"
+        },
+        "time": "2012-12-10 14:12:12",
+        "type": "library",
+        "extra": {
+            "branch-alias": {
+                "dev-master": "1.12-dev"
+            }
+        },
+        "installation-source": "source",
+        "autoload": {
+            "psr-0": {
+                "Twig_": "lib/"
+            }
+        },
+        "notification-url": "https://packagist.org/downloads/",
+        "license": [
+            "BSD-3"
+        ],
+        "authors": [
+            {
+                "name": "Fabien Potencier",
+                "email": "fabien@symfony.com"
+            },
+            {
+                "name": "Armin Ronacher",
+                "email": "armin.ronacher@active-4.com"
+            }
+        ],
+        "description": "Twig, the flexible, fast, and secure template language for PHP",
+        "homepage": "http://twig.sensiolabs.org",
+        "keywords": [
+            "templating"
+        ]
+    },
+    {
+        "name": "symfony/routing",
+        "version": "dev-master",
+        "version_normalized": "9999999-dev",
+        "target-dir": "Symfony/Component/Routing",
+        "source": {
+            "type": "git",
+            "url": "https://github.com/symfony/Routing",
+            "reference": "d5ecbda302b4704e374cea1e733967897675ee2c"
+        },
+        "dist": {
+            "type": "zip",
+            "url": "https://github.com/symfony/Routing/archive/d5ecbda302b4704e374cea1e733967897675ee2c.zip",
+            "reference": "d5ecbda302b4704e374cea1e733967897675ee2c",
+            "shasum": ""
+        },
+        "require": {
+            "php": ">=5.3.3"
+        },
+        "require-dev": {
+            "doctrine/common": ">=2.2,<2.4-dev",
+            "symfony/config": "2.2.*",
+            "symfony/yaml": "2.2.*",
+            "symfony/http-kernel": "2.2.*"
+        },
+        "suggest": {
+            "doctrine/common": ">=2.2,<2.4-dev",
+            "symfony/config": "2.2.*",
+            "symfony/yaml": "2.2.*"
+        },
+        "time": "2012-12-07 21:24:45",
+        "type": "library",
+        "extra": {
+            "branch-alias": {
+                "dev-master": "2.2-dev"
+            }
+        },
+        "installation-source": "source",
+        "autoload": {
+            "psr-0": {
+                "Symfony\\Component\\Routing\\": ""
+            }
+        },
+        "notification-url": "https://packagist.org/downloads/",
+        "license": [
+            "MIT"
+        ],
+        "authors": [
+            {
+                "name": "Fabien Potencier",
+                "email": "fabien@symfony.com"
+            },
+            {
+                "name": "Symfony Community",
+                "homepage": "http://symfony.com/contributors"
+            }
+        ],
+        "description": "Symfony Routing Component",
+        "homepage": "http://symfony.com"
+    },
+    {
+        "name": "symfony/http-foundation",
+        "version": "dev-master",
+        "version_normalized": "9999999-dev",
+        "target-dir": "Symfony/Component/HttpFoundation",
+        "source": {
+            "type": "git",
+            "url": "https://github.com/symfony/HttpFoundation",
+            "reference": "0acee754b149537dd90ae1e97508e8767802811b"
+        },
+        "dist": {
+            "type": "zip",
+            "url": "https://github.com/symfony/HttpFoundation/archive/0acee754b149537dd90ae1e97508e8767802811b.zip",
+            "reference": "0acee754b149537dd90ae1e97508e8767802811b",
+            "shasum": ""
+        },
+        "require": {
+            "php": ">=5.3.3"
+        },
+        "time": "2012-12-07 09:33:24",
+        "type": "library",
+        "extra": {
+            "branch-alias": {
+                "dev-master": "2.2-dev"
+            }
+        },
+        "installation-source": "source",
+        "autoload": {
+            "psr-0": {
+                "Symfony\\Component\\HttpFoundation\\": ""
+            },
+            "classmap": [
+                "Symfony/Component/HttpFoundation/Resources/stubs"
+            ]
+        },
+        "notification-url": "https://packagist.org/downloads/",
+        "license": [
+            "MIT"
+        ],
+        "authors": [
+            {
+                "name": "Fabien Potencier",
+                "email": "fabien@symfony.com"
+            },
+            {
+                "name": "Symfony Community",
+                "homepage": "http://symfony.com/contributors"
+            }
+        ],
+        "description": "Symfony HttpFoundation Component",
+        "homepage": "http://symfony.com"
+    },
+    {
+        "name": "symfony/http-kernel",
+        "version": "dev-master",
+        "version_normalized": "9999999-dev",
+        "target-dir": "Symfony/Component/HttpKernel",
+        "source": {
+            "type": "git",
+            "url": "https://github.com/symfony/HttpKernel",
+            "reference": "323b8c877fdf1f47ce23ac5b882092dce0beeb9a"
+        },
+        "dist": {
+            "type": "zip",
+            "url": "https://github.com/symfony/HttpKernel/archive/323b8c877fdf1f47ce23ac5b882092dce0beeb9a.zip",
+            "reference": "323b8c877fdf1f47ce23ac5b882092dce0beeb9a",
+            "shasum": ""
+        },
+        "require": {
+            "php": ">=5.3.3",
+            "symfony/event-dispatcher": "2.2.*",
+            "symfony/http-foundation": "2.2.*"
+        },
+        "require-dev": {
+            "symfony/browser-kit": "2.2.*",
+            "symfony/class-loader": "2.2.*",
+            "symfony/config": "2.2.*",
+            "symfony/console": "2.2.*",
+            "symfony/dependency-injection": "2.2.*",
+            "symfony/finder": "2.2.*",
+            "symfony/process": "2.2.*",
+            "symfony/routing": "2.2.*",
+            "symfony/stopwatch": "2.2.*"
+        },
+        "suggest": {
+            "symfony/browser-kit": "2.2.*",
+            "symfony/class-loader": "2.2.*",
+            "symfony/config": "2.2.*",
+            "symfony/console": "2.2.*",
+            "symfony/dependency-injection": "2.2.*",
+            "symfony/finder": "2.2.*"
+        },
+        "time": "2012-12-07 10:04:59",
+        "type": "library",
+        "extra": {
+            "branch-alias": {
+                "dev-master": "2.2-dev"
+            }
+        },
+        "installation-source": "source",
+        "autoload": {
+            "psr-0": {
+                "Symfony\\Component\\HttpKernel\\": ""
+            }
+        },
+        "notification-url": "https://packagist.org/downloads/",
+        "license": [
+            "MIT"
+        ],
+        "authors": [
+            {
+                "name": "Fabien Potencier",
+                "email": "fabien@symfony.com"
+            },
+            {
+                "name": "Symfony Community",
+                "homepage": "http://symfony.com/contributors"
+            }
+        ],
+        "description": "Symfony HttpKernel Component",
+        "homepage": "http://symfony.com"
+    },
+    {
+        "name": "symfony/config",
+        "version": "2.1.x-dev",
+        "version_normalized": "2.1.9999999.9999999-dev",
+        "target-dir": "Symfony/Component/Config",
+        "source": {
+            "type": "git",
+            "url": "https://github.com/symfony/Config",
+            "reference": "160ce63c9e75a94b9da126967fcb6d15e4cb878e"
+        },
+        "dist": {
+            "type": "zip",
+            "url": "https://github.com/symfony/Config/archive/160ce63c9e75a94b9da126967fcb6d15e4cb878e.zip",
+            "reference": "160ce63c9e75a94b9da126967fcb6d15e4cb878e",
+            "shasum": ""
+        },
+        "require": {
+            "php": ">=5.3.3"
+        },
+        "time": "2012-12-06 10:00:55",
+        "type": "library",
+        "installation-source": "source",
+        "autoload": {
+            "psr-0": {
+                "Symfony\\Component\\Config": ""
+            }
+        },
+        "notification-url": "https://packagist.org/downloads/",
+        "license": [
+            "MIT"
+        ],
+        "authors": [
+            {
+                "name": "Fabien Potencier",
+                "email": "fabien@symfony.com"
+            },
+            {
+                "name": "Symfony Community",
+                "homepage": "http://symfony.com/contributors"
+            }
+        ],
+        "description": "Symfony Config Component",
+        "homepage": "http://symfony.com"
+    },
+    {
+        "name": "symfony/yaml",
+        "version": "2.1.x-dev",
+        "version_normalized": "2.1.9999999.9999999-dev",
+        "target-dir": "Symfony/Component/Yaml",
+        "source": {
+            "type": "git",
+            "url": "https://github.com/symfony/Yaml",
+            "reference": "4fdae9fa28b7abd1135afc5227a4e59af4b64e5a"
+        },
+        "dist": {
+            "type": "zip",
+            "url": "https://github.com/symfony/Yaml/archive/4fdae9fa28b7abd1135afc5227a4e59af4b64e5a.zip",
+            "reference": "4fdae9fa28b7abd1135afc5227a4e59af4b64e5a",
+            "shasum": ""
+        },
+        "require": {
+            "php": ">=5.3.3"
+        },
+        "time": "2012-12-06 10:00:55",
+        "type": "library",
+        "installation-source": "source",
+        "autoload": {
+            "psr-0": {
+                "Symfony\\Component\\Yaml": ""
+            }
+        },
+        "notification-url": "https://packagist.org/downloads/",
+        "license": [
+            "MIT"
+        ],
+        "authors": [
+            {
+                "name": "Fabien Potencier",
+                "email": "fabien@symfony.com"
+            },
+            {
+                "name": "Symfony Community",
+                "homepage": "http://symfony.com/contributors"
+            }
+        ],
+        "description": "Symfony Yaml Component",
+        "homepage": "http://symfony.com"
+    }
 ]

Some files were not shown because too many files changed in this diff