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

skala
Julio Montoya 13 years ago
parent 7c1b1ee2aa
commit c3c338cf39
  1. 2
      .hgignore
  2. 17
      composer.json
  3. 567
      composer.lock
  4. 308
      index.php
  5. 43
      main/calendar/agenda_js.php
  6. 208
      main/inc/global.inc.php
  7. 347
      main/inc/lib/course.lib.php
  8. 37
      main/inc/lib/group_portal_manager.lib.php
  9. 95
      main/inc/lib/main_api.lib.php
  10. 910
      main/inc/lib/page.lib.php
  11. 881
      main/inc/lib/template.lib.php
  12. 435
      main/inc/lib/userportal.lib.php
  13. 5
      main/template/default/layout/main.tpl
  14. 10
      resources/config/dev.php
  15. 68
      resources/config/prod.php
  16. 5
      tests/xhprof/footer.php
  17. 474
      user_portal.php
  18. 2
      vendor/autoload.php
  19. 38
      vendor/composer/autoload_classmap.php
  20. 10
      vendor/composer/autoload_namespaces.php
  21. 14
      vendor/composer/autoload_real.php
  22. 565
      vendor/composer/installed.json

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

@ -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
composer.lock generated

@ -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": [
]
}

@ -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();

@ -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);

@ -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;
}

@ -41,7 +41,7 @@
CourseManager::has_virtual_courses_from_code($real_course_code, $user_id)
CourseManager::get_target_of_linked_course($virtual_course_code)
TITLE AND CODE FUNCTIONS
TITLE AND CODE FUNCTIONS
CourseManager::create_combined_name($user_is_registered_in_real_course, $real_course_name, $virtual_course_list)
CourseManager::create_combined_code($user_is_registered_in_real_course, $real_course_code, $virtual_course_list)
@ -75,7 +75,7 @@ class CourseManager {
CONST COURSE_FIELD_TYPE_CHECKBOX = 10;
var $columns = array();
/**
* Creates a course
* @param array with the columns in the main.course table
@ -83,20 +83,20 @@ class CourseManager {
*/
static function create_course($params) {
global $_configuration;
// Check portal limits
$access_url_id = 1;
if (api_get_multiple_access_url()) {
$access_url_id = api_get_current_access_url_id();
}
if (is_array($_configuration[$access_url_id]) && isset($_configuration[$access_url_id]['hosting_limit_courses']) && $_configuration[$access_url_id]['hosting_limit_courses'] > 0) {
$num = self::count_courses();
if ($num >= $_configuration[$access_url_id]['hosting_limit_courses']) {
return api_set_failure('PortalCoursesLimitReached');
}
}
if (empty($params['title'])) {
return false;
}
@ -125,25 +125,25 @@ class CourseManager {
$course_info = api_get_course_info_by_id($course_id);
if (!empty($course_info)) {
self::prepare_course_repository($course_info['directory'], $course_info['code']);
self::prepare_course_repository($course_info['directory'], $course_info['code']);
self::fill_db_course($course_id, $course_info['directory'], $course_info['course_language'], $params['exemplary_content']);
//Create an empty gradebook
//Create an empty gradebook
if (isset($params['create_gradebook_evaluation']) && $params['create_gradebook_evaluation'] == true) {
require_once api_get_path(SYS_CODE_PATH).'gradebook/lib/gradebook_functions.inc.php';
$category_id = create_default_course_gradebook($course_info['code']);
if ($category_id && isset($params['gradebook_params'])) {
$eval = new Evaluation();
$eval->set_name($params['gradebook_params']['name']);
$eval->set_name($params['gradebook_params']['name']);
$eval->set_user_id($params['gradebook_params']['user_id']);
$eval->set_course_code($course_info['code']);
$eval->set_category_id($category_id);
$eval->set_weight($params['gradebook_params']['weight']);
$eval->set_weight($params['gradebook_params']['weight']);
$eval->set_max($params['gradebook_params']['max']);
$eval->set_visible(0);
$eval->add();
$eval->add();
}
}
}
if (api_get_setting('gradebook_enable_grade_model') == 'true') {
//Create gradebook_category for the new course and add a gradebook model for the course
if (isset($params['gradebook_model_id']) && !empty($params['gradebook_model_id']) && $params['gradebook_model_id'] != '-1') {
@ -151,12 +151,12 @@ class CourseManager {
create_default_course_gradebook($course_info['code'], $params['gradebook_model_id']);
}
}
//Saving extra course fields
$field_value = new ExtraFieldValue('course');
$params['course_code'] = $course_info['code'];
$params['course_code'] = $course_info['code'];
$field_value->save_field_values($params);
return $course_info;
}
} else {
@ -170,17 +170,17 @@ class CourseManager {
}
return false;
}
static function update($params) {
$course_user_table = Database::get_main_table(TABLE_MAIN_COURSE_USER);
$course_table = Database::get_main_table(TABLE_MAIN_COURSE);
$course_code = $params['code'];
$visual_code = $params['visual_code'];
$field_value = new ExtraFieldValue('course');
$params['course_code'] = $course_code;
$field_value->save_field_values($params);
$field_value = new ExtraFieldValue('course');
$params['course_code'] = $course_code;
$field_value->save_field_values($params);
/*$tutor_id = $params['tutor_name'];
$tutor_name=$platform_teachers[$tutor_id];*/
@ -202,12 +202,12 @@ class CourseManager {
if (!stristr($department_url, 'http://')) {
$department_url = 'http://'.$department_url;
}
//tutor_name='".Database::escape_string($tutor_name)."',
$sql = "UPDATE $course_table SET
course_language='".Database::escape_string($course_language)."',
title='".Database::escape_string($title)."',
category_code='".Database::escape_string($category_code)."',
category_code='".Database::escape_string($category_code)."',
visual_code='".Database::escape_string($visual_code)."',
department_name='".Database::escape_string($department_name)."',
department_url='".Database::escape_string($department_url)."',
@ -247,10 +247,10 @@ class CourseManager {
Database::query($sql);
}
}
//user_id = '".$tutor_id . "',
$sql = "INSERT IGNORE INTO ".$course_user_table . " SET
course_code = '".Database::escape_string($course_code). "',
course_code = '".Database::escape_string($course_code). "',
status = '1',
role = '',
tutor_id='0',
@ -841,7 +841,7 @@ class CourseManager {
foreach ($students_in_course as $user_item) {
if ($user_item['moved_to'] == 0) {
$students_in_courses[$user_item['user_id']] = $user_item['user_id'];
}
}
}
}
}
@ -1243,14 +1243,14 @@ class CourseManager {
* @param integer $session_id the id of the session
* @param string $limit the LIMIT statement of the sql statement
* @param string $order_by the field to order the users by. Valid values are 'lastname', 'firstname', 'username', 'email', 'official_code' OR a part of a SQL statement that starts with ORDER BY ...
* @param int if using the session_id: 0 or 2 (student, coach), if using session_id = 0 STUDENT or COURSEMANAGER
* @param int if using the session_id: 0 or 2 (student, coach), if using session_id = 0 STUDENT or COURSEMANAGER
* @return array
*/
public static function get_user_list_from_course_code($course_code, $session_id = 0, $limit = null, $order_by =null, $filter_by_status = null, $keyword = null) {
$session_id = intval($session_id);
$course_code = Database::escape_string($course_code);
$keyword = Database::escape_string($keyword);
$where = array();
$where = array();
// if the $order_by does not contain 'ORDER BY' we have to check if it is a valid field that can be sorted on
if (!strstr($order_by,'ORDER BY')) {
@ -1260,59 +1260,59 @@ class CourseManager {
$order_by = '';
}
}
$filter_by_status_condition = null;
if (!empty($session_id)) {
$sql = 'SELECT DISTINCT user.user_id, session_course_user.status as status_session, user.* ';
$sql .= ' FROM '.Database::get_main_table(TABLE_MAIN_USER).' as user ';
$sql .= ' LEFT JOIN '.Database::get_main_table(TABLE_MAIN_SESSION_COURSE_USER).' as session_course_user
$sql .= ' FROM '.Database::get_main_table(TABLE_MAIN_USER).' as user ';
$sql .= ' LEFT JOIN '.Database::get_main_table(TABLE_MAIN_SESSION_COURSE_USER).' as session_course_user
ON user.user_id = session_course_user.id_user
AND session_course_user.course_code="'.$course_code.'"
AND session_course_user.id_session = '.$session_id.'
INNER JOIN '.Database::get_main_table(TABLE_MAIN_SESSION_USER).' as su
ON ( su.id_session = session_course_user.id_session AND
user.user_id = su.id_user AND
AND session_course_user.id_session = '.$session_id.'
INNER JOIN '.Database::get_main_table(TABLE_MAIN_SESSION_USER).' as su
ON ( su.id_session = session_course_user.id_session AND
user.user_id = su.id_user AND
su.moved_to = 0 AND
su.moved_status <> '.SessionManager::SESSION_CHANGE_USER_REASON_ENROLLMENT_ANNULATION.'
) ';
$where[] = ' AND session_course_user.course_code IS NOT NULL ';
// 2 = coach
// 0 = student
if (isset($filter_by_status)) {
// 0 = student
if (isset($filter_by_status)) {
$filter_by_status = intval($filter_by_status);
$filter_by_status_condition = " AND session_course_user.status = $filter_by_status AND ";
$filter_by_status_condition = " AND session_course_user.status = $filter_by_status AND ";
}
} else {
} else {
$sql = 'SELECT DISTINCT course_rel_user.status as status_rel, user.user_id, course_rel_user.role, course_rel_user.tutor_id, user.* ';
$sql .= ' FROM '.Database::get_main_table(TABLE_MAIN_USER).' as user ';
$sql .= ' FROM '.Database::get_main_table(TABLE_MAIN_USER).' as user ';
$sql .= ' LEFT JOIN '.Database::get_main_table(TABLE_MAIN_COURSE_USER).' as course_rel_user
ON user.user_id = course_rel_user.user_id AND course_rel_user.relation_type<>'.COURSE_RELATION_TYPE_RRHH.'
AND course_rel_user.course_code="'.$course_code.'"';
$where[] = ' AND course_rel_user.course_code IS NOT NULL ';
if (isset($filter_by_status) && $filter_by_status != '') {
$filter_by_status = intval($filter_by_status);
$filter_by_status_condition = " AND course_rel_user.status = $filter_by_status AND ";
}
}
$multiple_access_url = api_get_multiple_access_url();
if ($multiple_access_url) {
$sql .= ' LEFT JOIN '.Database::get_main_table(TABLE_MAIN_ACCESS_URL_REL_USER).' au ON (au.user_id = user.user_id) ';
}
$keyword_condition = null;
if (!empty($keyword)) {
$where_keyword = array();
$where_keyword[] = "firstname LIKE '%$keyword%'";
$where_keyword[] = "lastname LIKE '%$keyword%'";
$where_keyword[] = "username LIKE '%$keyword%'";
$where_keyword[] = "official_code LIKE '%$keyword%'";
$where_keyword[] = "official_code LIKE '%$keyword%'";
$keyword_condition = ' AND ('.implode(' OR ', $where_keyword).') ';
}
$where_condition = null;
if (!empty($where)) {
$where_condition = implode(' OR ', $where);
@ -1324,18 +1324,18 @@ class CourseManager {
$current_access_url_id = api_get_current_access_url_id();
$sql .= " AND (access_url_id = $current_access_url_id ) ";
}
$sql .= ' '.$order_by;
if (!empty($keyword)) {
$sql .= ' '.$limit;
}
$rs = Database::query($sql);
$users = array();
if (Database::num_rows($rs)) {
while ($user = Database::fetch_array($rs)) {
while ($user = Database::fetch_array($rs)) {
$user_info = $user;
$user_info['status'] = $user['status'];
@ -1361,7 +1361,7 @@ class CourseManager {
* @param int $session_id
* @return int
*/
public static function get_users_count_in_course($course_code, $session_id = 0) {
public static function get_users_count_in_course($course_code, $session_id = 0) {
$session_id = intval($session_id);
$course_code = Database::escape_string($course_code);
@ -1371,10 +1371,10 @@ class CourseManager {
$sql .= ' LEFT JOIN '.Database::get_main_table(TABLE_MAIN_SESSION_COURSE_USER).' as session_course_user
ON user.user_id = session_course_user.id_user
AND session_course_user.course_code = "'.$course_code.'"
AND session_course_user.id_session = '.$session_id.'
INNER JOIN '.Database::get_main_table(TABLE_MAIN_SESSION_USER).' as su
ON ( su.id_session = session_course_user.id_session AND
user.user_id = su.id_user AND
AND session_course_user.id_session = '.$session_id.'
INNER JOIN '.Database::get_main_table(TABLE_MAIN_SESSION_USER).' as su
ON ( su.id_session = session_course_user.id_session AND
user.user_id = su.id_user AND
su.moved_to = 0 AND
su.moved_status <> '.SessionManager::SESSION_CHANGE_USER_REASON_ENROLLMENT_ANNULATION.'
)';
@ -1398,7 +1398,7 @@ class CourseManager {
$current_access_url_id = api_get_current_access_url_id();
$sql .= " AND (access_url_id = $current_access_url_id ) ";
}
$rs = Database::query($sql);
$rs = Database::query($sql);
$count = 0;
if (Database::num_rows($rs)) {
$user = Database::fetch_array($rs);
@ -1436,7 +1436,7 @@ class CourseManager {
}
// We get the session coach.
$rs = Database::query('SELECT id_coach FROM '.Database::get_main_table(TABLE_MAIN_SESSION).' WHERE id="'.$session_id.'"');
$rs = Database::query('SELECT id_coach FROM '.Database::get_main_table(TABLE_MAIN_SESSION).' WHERE id="'.$session_id.'"');
$session_id_coach = Database::result($rs, 0, 'id_coach');
$user_info = Database::get_user_info_from_id($session_id_coach);
$user_info['status'] = $user['status'];
@ -1475,7 +1475,7 @@ class CourseManager {
// students subscribed to the course through a session
if ($with_session) {
$sql_query = "SELECT * FROM ".Database::get_main_table(TABLE_MAIN_SESSION_COURSE_USER)."
$sql_query = "SELECT * FROM ".Database::get_main_table(TABLE_MAIN_SESSION_COURSE_USER)."
WHERE course_code = '$course_code' AND status <> 2";
if ($session_id != 0) {
$sql_query .= ' AND id_session = '.$session_id;
@ -1497,11 +1497,11 @@ class CourseManager {
*/
public static function get_teacher_list_from_course_code($course_code) {
$course_code = Database::escape_string($course_code);
$teachers = array();
$sql = "SELECT DISTINCT u.user_id, u.lastname, u.firstname, u.email, u.username, u.status
FROM ".Database::get_main_table(TABLE_MAIN_COURSE_USER)." cu INNER JOIN ".Database::get_main_table(TABLE_MAIN_USER)." u
$teachers = array();
$sql = "SELECT DISTINCT u.user_id, u.lastname, u.firstname, u.email, u.username, u.status
FROM ".Database::get_main_table(TABLE_MAIN_COURSE_USER)." cu INNER JOIN ".Database::get_main_table(TABLE_MAIN_USER)." u
ON (cu.user_id = u.user_id)
WHERE cu.course_code = '$course_code' AND
WHERE cu.course_code = '$course_code' AND
cu.status = 1 ";
$rs = Database::query($sql);
while ($teacher = Database::fetch_array($rs)) {
@ -1555,7 +1555,7 @@ class CourseManager {
$tbl_session_course_user = Database :: get_main_table(TABLE_MAIN_SESSION_COURSE_USER);
$coaches = array();
$sql = "SELECT DISTINCT u.user_id, u.lastname, u.firstname, u.username
$sql = "SELECT DISTINCT u.user_id, u.lastname, u.firstname, u.username
FROM $tbl_user u, $tbl_session_course_user scu
WHERE u.user_id = scu.id_user AND scu.id_session = '$session_id' AND scu.course_code = '$course_code' AND scu.status = 2";
$rs = Database::query($sql);
@ -1682,15 +1682,15 @@ class CourseManager {
$course_id = $course_info['real_id'];
$group_list = array();
$session_id != 0 ? $session_condition = ' WHERE g.session_id IN(1,'.intval($session_id).')' : $session_condition = ' WHERE g.session_id = 0';
$sql = "SELECT g.id, g.name
FROM ".Database::get_course_table(TABLE_GROUP)." AS g
INNER JOIN ".Database::get_course_table(TABLE_GROUP_USER)." gu
ON (g.id = gu.group_id AND g.c_id = $course_id AND gu.c_id = $course_id)
$session_condition
$session_condition
ORDER BY g.name";
$result = Database::query($sql);
while ($group_data = Database::fetch_array($result)) {
$group_data['userNb'] = GroupManager::number_of_students($group_data['id'], $course_id);
$group_list[$group_data['id']] = $group_data;
@ -1796,7 +1796,7 @@ class CourseManager {
* that real course.
* @todo Remove globals
*/
public static function delete_course($code) {
public static function delete_course($code) {
$table_course = Database::get_main_table(TABLE_MAIN_COURSE);
$table_course_user = Database::get_main_table(TABLE_MAIN_COURSE_USER);
@ -1821,7 +1821,7 @@ class CourseManager {
$table_stats_uploads = Database::get_statistic_table(TABLE_STATISTIC_TRACK_E_UPLOADS);
$code = Database::escape_string($code);
// Unsubscribe all classes from the course
$sql = "DELETE FROM $table_course_class WHERE course_code='".$code."'";
Database::query($sql);
@ -2809,7 +2809,7 @@ class CourseManager {
$course_image = $store_path.'/course-pic.png'; // image name for courses
$course_medium_image = $store_path.'/course-pic85x85.png';
//$extension = strtolower(substr(strrchr($filename, '.'), 1));
if (file_exists($course_image)) {
@unlink($course_image);
}
@ -2842,7 +2842,7 @@ class CourseManager {
*/
public static function course_item_html($params, $is_sub_content = false) {
$html = '';
$class = "well";
$class = "well course-box";
if ($is_sub_content) {
$class = "course_item";
}
@ -2850,7 +2850,7 @@ class CourseManager {
$html .= '<div class="row">';
$html .= '<div class="span7">';
$html .= ' <div class="row">';
$html .= '<div class="span1">';
$html .= '<div class="span1 course-box-thumbnail-box">';
if (!empty($params['link'])) {
$html .= '<a class="thumbnail" href="'.$params['link'].'">';
$html .= $params['icon'];
@ -2860,33 +2860,29 @@ class CourseManager {
$html .= $params['icon'];
$html .= '</div>';
}
$html .= '</div>';
$notifications = isset($params['notifications']) ? $params['notifications'] : null;
$html .= '<div class="span6">';
$html .='<h3>'.$params['title'].$params['notifications'].'</h3> ';
$html .='<h3>'.$params['title'].$notifications.'</h3> ';
if (!empty($params['subtitle'])) {
$html .= '<small>'.$params['subtitle'].'</small>';
}
if (!empty($params['dates'])) {
if (!empty($params['subtitle'])) {
$html .= " | ";
}
$html .= '<small>'.$params['dates'].'</small>';
}
if (!empty($params['teachers'])) {
$html .= '<h5>'.Display::return_icon('teacher.png', get_lang('Teacher'), array(), ICON_SIZE_TINY).$params['teachers'].'</h5>';
}
if (!empty($params['coaches'])) {
$html .= '<h5>'.Display::return_icon('teacher.png', get_lang('Coach'), array(), ICON_SIZE_TINY).$params['coaches'].'</h5>';
}
}
$html .= '</div>';
$html .= '</div>';
$html .= '</div>';
$html .= '<div class="span1 pull-right">'.$params['right_actions'].'</div>';
$params['right_actions'] = isset($params['right_actions']) ? $params['right_actions'] : null;
$html .= '<div class="span1 pull-right course-box-actions">'.$params['right_actions'].'</div>';
$html .= '</div>';
$html .= '</div>';
return $html;
@ -2912,7 +2908,7 @@ class CourseManager {
$tbl_course_user = Database::get_main_table(TABLE_MAIN_COURSE_USER);
$special_course_list = self::get_special_course_list();
$html = null;
$with_special_courses = $without_special_courses = '';
if (!empty($special_course_list)) {
$with_special_courses = ' course.code IN ("'.implode('","',$special_course_list).'")';
@ -2928,7 +2924,7 @@ class CourseManager {
$rs_special_course = Database::query($sql);
$number_of_courses = Database::num_rows($rs_special_course);
$key = 0;
$html = '';
if ($number_of_courses > 0) {
@ -2949,7 +2945,7 @@ class CourseManager {
$params['icon'] = Display::return_icon('blackboard.png', $course_info['title'], array(), ICON_SIZE_LARGE);
$params['right_actions'] = '';
$params['right_actions'] = '';
if (api_is_platform_admin()) {
if ($load_dirs) {
$params['right_actions'] .= '<a id="document_preview_'.$course['real_id'].'_0" class="document_preview" href="javascript:void(0);">'.Display::return_icon('folder.png', get_lang('Documents'), array('align' => 'absmiddle'),ICON_SIZE_SMALL).'</a>';
@ -2963,9 +2959,9 @@ class CourseManager {
}
} else {
if ($course_info['visibility'] != COURSE_VISIBILITY_CLOSED) {
if ($load_dirs) {
if ($load_dirs) {
$params['right_actions'] .= '<a id="document_preview_'.$course['real_id'].'_0" class="document_preview" href="javascript:void(0);">'.Display::return_icon('folder.png', get_lang('Documents'), array('align' => 'absmiddle'),ICON_SIZE_SMALL).'</a>';
$params['right_actions'] .= Display::div('', array('id' => 'document_result_'.$course['real_id'].'_0', 'class'=>'document_preview_container'));
$params['right_actions'] .= Display::div('', array('id' => 'document_result_'.$course['real_id'].'_0', 'class'=>'document_preview_container'));
}
}
}
@ -2987,11 +2983,11 @@ class CourseManager {
$params['title'] = $course_title;
$params['link'] = api_get_path(WEB_COURSE_PATH).$course_info['path'].'/?id_session=0&amp;autoreg=1';
if ($course_info['visibility'] != COURSE_VISIBILITY_CLOSED) {
$params['notifications'] = $show_notification;
}
$html .= self::course_item_html($params, false);
$key++;
}
@ -3013,6 +3009,7 @@ class CourseManager {
if (empty($user_id)) {
$user_id = api_get_user_id();
}
$html = null;
// Step 1: We get all the categories of the user
$tucc = Database::get_user_personal_table(TABLE_USER_COURSE_CATEGORY);
@ -3025,9 +3022,9 @@ class CourseManager {
$params['title'] = $row['title'];
$html .= self::course_item_parent(self::course_item_html($params, true), self :: display_courses_in_category($row['id'], $load_dirs));
}
// Step 2: We display the course without a user category.
$html .= self :: display_courses_in_category(0, $load_dirs);
$html .= self :: display_courses_in_category(0, $load_dirs);
return $html;
}
@ -3048,7 +3045,7 @@ class CourseManager {
// Get course list auto-register
$special_course_list = self::get_special_course_list();
$without_special_courses = '';
if (!empty($special_course_list)) {
$without_special_courses = ' AND course.code NOT IN ("'.implode('","',$special_course_list).'")';
@ -3069,11 +3066,11 @@ class CourseManager {
}
// Use user's classification for courses (if any).
$sql .= " ORDER BY course_rel_user.user_course_cat, course_rel_user.sort ASC";
$result = Database::query($sql);
$result = Database::query($sql);
$status_icon = '';
$html = '';
$course_list = array();
// Browse through all courses.
@ -3082,7 +3079,7 @@ class CourseManager {
//$course['id_session'] = null;
$course_info['id_session'] = null;
$course_info['status'] = $course['status'];
//In order to avoid doubles
if (in_array($course_info['real_id'], $course_list)) {
continue;
@ -3124,7 +3121,7 @@ class CourseManager {
}
}
}
$course_title = $course_info['title'];
$course_title_url = '';
@ -3147,7 +3144,7 @@ class CourseManager {
$params['icon'] = $status_icon;
$params['title'] = $course_title;
$params['teachers'] = $teachers;
if ($course_info['visibility'] != COURSE_VISIBILITY_CLOSED) {
$params['notifications'] = $show_notification;
}
@ -3156,7 +3153,7 @@ class CourseManager {
if (empty($user_category_id)) {
$is_subcontent = false;
}
$html .= self::course_item_html($params, $is_subcontent);
$html .= self::course_item_html($params, $is_subcontent);
}
return $html;
}
@ -3220,20 +3217,20 @@ class CourseManager {
* @todo move code for what's new icons to a separate function to clear things up
* @todo add a parameter user_id so that it is possible to show the courselist of other users (=generalisation). This will prevent having to write a new function for this.
*/
public static function get_logged_user_course_html($course, $session_id = 0, $load_dirs = false) {
$course_info = api_get_course_info($course['code']);
public static function get_logged_user_course_html($course, $session_id = 0, $load_dirs = false) {
$course_info = api_get_course_info($course['code']);
$course_info['id_session'] = $session_id;
// Display course entry.
// Show a link to the course, unless the course is closed and user is not course admin.
$session_url = '';
$session_title = $course_info['name'];
if ($course_info['visibility'] != COURSE_VISIBILITY_CLOSED || $course_info['user_status_in_course'] == COURSEMANAGER) {
$session_title = $course_info['name'];
if ($course_info['visibility'] != COURSE_VISIBILITY_CLOSED || $course_info['user_status_in_course'] == COURSEMANAGER) {
//if ($course_info['user_status_in_course'] == COURSEMANAGER) {
$session_url = api_get_path(WEB_COURSE_PATH).$course_info['path'].'/?id_session='.$course_info['id_session'];
$session_title = '<a href="'.api_get_path(WEB_COURSE_PATH).$course_info['path'].'/?id_session='.$course_info['id_session'].'">'.$course_info['name'].'</a>';
//}
//}
} else {
$session_title = $course_info['name'].' '.Display::tag('span',get_lang('CourseClosed'), array('class'=>'item_closed'));
}
@ -3243,10 +3240,10 @@ class CourseManager {
$params['icon'] = Display::return_icon('blackboard_blue.png', $course_info['name'], array(), ICON_SIZE_LARGE);
$params['link'] = $session_url;
$params['title'] = $session_title;
$params['right_actions'] = '';
if ($course_info['visibility'] != COURSE_VISIBILITY_CLOSED) {
if ($load_dirs) {
$params['right_actions'] .= '<a id="document_preview_'.$course_info['real_id'].'_'.$course_info['id_session'].'" class="document_preview" href="javascript:void(0);">'.
@ -3259,11 +3256,11 @@ class CourseManager {
$session_title .= ' ('.$course_info['visual_code'].') ';
}
if (api_get_setting('display_teacher_in_courselist') == 'true') {
if (api_get_setting('display_teacher_in_courselist') == 'true') {
$teacher_list = CourseManager::get_teacher_list_from_course_code_to_string($course_info['code'], self::USER_SEPARATOR, true);
$course_coachs = CourseManager::get_coachs_from_course_to_string($course_info['id_session'], $course['code'], self::USER_SEPARATOR, true);
$course_coachs = CourseManager::get_coachs_from_course_to_string($course_info['id_session'], $course['code'], self::USER_SEPARATOR, true);
$params['teachers'] = $teacher_list;
$params['coaches'] = $course_coachs;
$params['coaches'] = $course_coachs;
}
$session_title .= isset($course['special_course']) ? ' '.Display::return_icon('klipper.png', get_lang('CourseAutoRegister')) : '';
@ -3463,7 +3460,7 @@ class CourseManager {
$params = array(
'c_id' => $course_id,
'session_id' => $session_id,
'url_id' => $url_id
'url_id' => $url_id
);
$result = Database::select('c_id, accesses, total_score, users', $table_course_ranking, array('where' => array('c_id = ? AND session_id = ? AND url_id = ?' => $params)), 'first');
@ -3502,7 +3499,7 @@ class CourseManager {
public static function update_course_ranking($course_id = null, $session_id = null, $url_id = null, $points_to_add = null, $add_access = true, $add_user = true) {
//Course catalog stats modifications see #4191
$table_course_ranking = Database::get_main_table(TABLE_STATISTIC_TRACK_COURSE_RANKING);
$course_id = empty($course_id) ? api_get_course_int_id() : intval($course_id);
$session_id = !isset($session_id) ? api_get_session_id() : intval($session_id);
$url_id = empty($url_id) ? api_get_current_access_url_id() : intval($url_id);
@ -3510,7 +3507,7 @@ class CourseManager {
$params = array(
'c_id' => $course_id,
'session_id' => $session_id,
'url_id' => $url_id
'url_id' => $url_id
);
$result = Database::select('id, accesses, total_score, users', $table_course_ranking, array('where' => array('c_id = ? AND session_id = ? AND url_id = ?' => $params)), 'first');
@ -3643,22 +3640,22 @@ class CourseManager {
public static function return_hot_courses($days = 30, $limit = 5) {
global $_configuration;
$limit = intval($limit);
//Getting my courses
$my_course_list = CourseManager::get_courses_list_by_user_id(api_get_user_id());
$my_course_code_list = array();
foreach ($my_course_list as $course) {
$my_course_code_list[$course['real_id']] = $course['real_id'];
}
if (api_is_drh()) {
$courses = CourseManager::get_courses_followed_by_drh(api_get_user_id());
foreach ($courses as $course) {
$my_course_code_list[$course['real_id']] = $course['real_id'];
}
}
}
$table_course_access = Database::get_main_table(TABLE_STATISTIC_TRACK_E_COURSE_ACCESS);
$table_course = Database::get_main_table(TABLE_MAIN_COURSE);
$table_course_url = Database::get_main_table(TABLE_MAIN_ACCESS_URL_REL_COURSE);
@ -3676,7 +3673,7 @@ class CourseManager {
$sql = "SELECT COUNT(course_access_id) course_count, a.course_code, visibility ".
"FROM $table_course c INNER JOIN $table_course_access a ".
" ON (c.code = a.course_code) INNER JOIN $table_course_url u ON u.course_code = a.course_code ".
" ON (c.code = a.course_code) INNER JOIN $table_course_url u ON u.course_code = a.course_code ".
" WHERE u.access_url_id = ".$_configuration['access_url']." AND".
" login_course_date <= now() AND ".
" login_course_date > DATE_SUB(now(), INTERVAL $days DAY) AND".
@ -3688,36 +3685,36 @@ class CourseManager {
$result = Database::query($sql);
$courses = array();
if (Database::num_rows($result)) {
$courses = Database::store_result($result, 'ASSOC');
$courses = self::process_hot_course_item($courses, $my_course_code_list);
$courses = Database::store_result($result, 'ASSOC');
$courses = self::process_hot_course_item($courses, $my_course_code_list);
}
return $courses;
}
public static function process_hot_course_item($courses, $my_course_code_list = array()) {
$ajax_url = api_get_path(WEB_AJAX_PATH).'course.ajax.php?a=add_course_vote';
foreach ($courses as &$my_course) {
$course_info = api_get_course_info($my_course['course_code']);
$course_info = api_get_course_info($my_course['course_code']);
$my_course['extra_info'] = $course_info;
$my_course['extra_info']['go_to_course_button'] = '';
$my_course['extra_info']['register_button'] = '';
$access_link = self::get_access_link_by_user(api_get_user_id(), $course_info, $my_course_code_list);
//Course visibility
//Course visibility
if ($access_link && in_array('register', $access_link)) {
$stok = Security::get_token();
$my_course['extra_info']['register_button'] = Display::url(get_lang('Subscribe'), api_get_path(WEB_COURSE_PATH).$course_info['path'].'/index.php?action=subscribe&amp;sec_token='.$stok, array('class' => 'btn btn-primary'));
}
if ($access_link && in_array('enter', $access_link)) {
$my_course['extra_info']['go_to_course_button'] = Display::url(get_lang('GoToCourse'), api_get_path(WEB_COURSE_PATH).$course_info['path'].'/index.php', array('class' => 'btn btn-primary'));
$my_course['extra_info']['go_to_course_button'] = Display::url(get_lang('GoToCourse'), api_get_path(WEB_COURSE_PATH).$course_info['path'].'/index.php', array('class' => 'btn btn-primary'));
}
//Description
$my_course['extra_info']['description_button'] = '';
if ($course_info['visibility'] == COURSE_VISIBILITY_OPEN_WORLD || in_array($course_info['real_id'], $my_course_code_list) ) {
$my_course['extra_info']['description_button'] = Display::url(get_lang('Description'), api_get_path(WEB_AJAX_PATH).'course_home.ajax.php?a=show_course_information&code='.$course_info['code'], array('class' => 'ajax btn'));
$my_course['extra_info']['description_button'] = Display::url(get_lang('Description'), api_get_path(WEB_AJAX_PATH).'course_home.ajax.php?a=show_course_information&code='.$course_info['code'], array('class' => 'ajax btn'));
}
$my_course['extra_info']['teachers'] = CourseManager::get_teacher_list_from_course_code_to_string($course_info['code']);
@ -3779,8 +3776,8 @@ class CourseManager {
$res = Database::query($sql);
$row = Database::fetch_row($res);
return $row[0];
}
}
/**
* Return a link to go to the course, validating the visibility of the
* course and the user status
@ -3793,43 +3790,43 @@ class CourseManager {
if (empty($uid) or empty($course)) { return false; }
if (empty($user_courses)) {
// get the array of courses to which the user is subscribed
$user_courses = CourseManager::get_courses_list_by_user_id($uid);
$user_courses = CourseManager::get_courses_list_by_user_id($uid);
foreach ($user_courses as $k => $v) {
$user_courses[$k] = $v['real_id'];
}
}
}
if (!isset($course['real_id']) && empty($course['real_id'])) {
$course = api_get_course_info($course['code']);
}
$is_admin = api_is_platform_admin_by_id($uid);
$options = array();
// Register button
if (!api_is_anonymous($uid) &&
!$is_admin &&
if (!api_is_anonymous($uid) &&
!$is_admin &&
(
($course['visibility'] == COURSE_VISIBILITY_OPEN_WORLD || $course['visibility'] == COURSE_VISIBILITY_OPEN_PLATFORM) ||
($course['visibility'] == COURSE_VISIBILITY_OPEN_WORLD || $course['visibility'] == COURSE_VISIBILITY_OPEN_PLATFORM) ||
$course['visibility'] == COURSE_VISIBILITY_REGISTERED && $course['subscribe'] == SUBSCRIBE_ALLOWED
) &&
) &&
$course['subscribe'] == SUBSCRIBE_ALLOWED &&
(!in_array($course['real_id'], $user_courses) || empty($user_courses))
) {
$options[]= 'register';
}
// Go To Course button (only if admin, if course public or if student already subscribed)
if ($is_admin ||
if ($is_admin ||
$course['visibility'] == COURSE_VISIBILITY_OPEN_WORLD && empty($course['registration_code']) ||
(api_user_is_login($uid) && $course['visibility'] == COURSE_VISIBILITY_OPEN_PLATFORM && empty($course['registration_code']) ) ||
(in_array($course['real_id'], $user_courses) && $course['visibility'] != COURSE_VISIBILITY_CLOSED)
(api_user_is_login($uid) && $course['visibility'] == COURSE_VISIBILITY_OPEN_PLATFORM && empty($course['registration_code']) ) ||
(in_array($course['real_id'], $user_courses) && $course['visibility'] != COURSE_VISIBILITY_CLOSED)
) {
$options[]= 'enter';
}
return $options;
return $options;
}
// TODO: Such a function might be useful in other places too. It might be moved in the CourseManager class.
// Also, the function might be upgraded for avoiding code duplications.
static function generate_course_code($course_title, $encoding = null) {
@ -3838,7 +3835,7 @@ class CourseManager {
}
return substr(preg_replace('/[^A-Z0-9]/', '', strtoupper(api_transliterate($course_title, 'X', $encoding))), 0, CourseManager::MAX_COURSE_LENGTH_CODE);
}
/**
* Defines the four needed keys to create a course based on several parameters.
@ -3906,7 +3903,7 @@ class CourseManager {
return $keys;
}
/**
* Initializes a file repository for a newly created course.
*/
@ -3915,18 +3912,18 @@ class CourseManager {
$perm = api_get_permissions_for_new_directories();
$perm_file = api_get_permissions_for_new_files();
$htmlpage = "<!DOCTYPE html>\n<html lang=\"en\">\n <head>\n <meta charset=\"utf-8\">\n <title>Not authorized</title>\n </head>\n <body>\n </body>\n</html>";
$cp = api_get_path(SYS_COURSE_PATH).$course_repository;
$cp = api_get_path(SYS_COURSE_PATH).$course_repository;
//Creating document folder
mkdir($cp, $perm);
mkdir($cp, $perm);
mkdir($cp . '/document', $perm);
$cpt = $cp.'/document/index.html';
$cpt = $cp.'/document/index.html';
$fd = fopen($cpt, 'w');
fwrite($fd, $htmlpage);
fclose($fd);
/*
@chmod($cpt, $perm_file);
@chmod($cpt, $perm_file);
@copy($cpt, $cp . '/document/index.html');
mkdir($cp . '/document/images', $perm);
@copy($cpt, $cp . '/document/images/index.html');
@ -3947,7 +3944,7 @@ class CourseManager {
$fd = fopen($cpt, 'w');
fwrite($fd, $htmlpage);
fclose($fd);
@chmod($cpt, $perm_file);
@chmod($cpt, $perm_file);
mkdir($cp . '/group', $perm);
@copy($cpt, $cp . '/group/index.html');
mkdir($cp . '/page', $perm);
@ -4009,7 +4006,7 @@ class CourseManager {
@chmod($cp . '/index.php',$perm_file);
return 0;
}
static function get_course_tables() {
$tables = array();
@ -4320,7 +4317,7 @@ class CourseManager {
}
return $default_document_array;
}
/**
* Fills the course database with some required content and example content.
@ -4329,7 +4326,7 @@ class CourseManager {
static function fill_db_course($course_id, $course_repository, $language, $fill_with_exemplary_content = null) {
if (is_null($fill_with_exemplary_content)) {
$fill_with_exemplary_content = api_get_setting('example_material_course_creation') != 'false';
}
}
$course_id = intval($course_id);
if (empty($course_id)) {
@ -4476,7 +4473,7 @@ class CourseManager {
if ($fill_with_exemplary_content) {
Database::query("INSERT INTO $TABLETOOLDOCUMENT (c_id,path,title,filetype,size) VALUES ($course_id,'/images','".get_lang('Images')."','folder','0')");
$example_doc_id = Database :: insert_id();
$example_doc_id = Database :: insert_id();
Database::query("INSERT INTO $TABLEITEMPROPERTY (c_id, tool,insert_user_id,insert_date,lastedit_date,ref,lastedit_type,lastedit_user_id,to_group_id,to_user_id,visibility) VALUES ($course_id,'document',1,NOW(),NOW(),$example_doc_id,'DocumentAdded',1,0,NULL,0)");
Database::query("INSERT INTO $TABLETOOLDOCUMENT (c_id, path,title,filetype,size) VALUES ($course_id,'/images/gallery','".get_lang('DefaultCourseImages')."','folder','0')");
@ -4492,7 +4489,7 @@ class CourseManager {
Database::query("INSERT INTO $TABLEITEMPROPERTY (c_id, tool,insert_user_id,insert_date,lastedit_date,ref,lastedit_type,lastedit_user_id,to_group_id,to_user_id,visibility) VALUES ($course_id,'document',1,NOW(),NOW(),$example_doc_id,'DocumentAdded',1,0,NULL,0)");
Database::query("INSERT INTO $TABLETOOLDOCUMENT (c_id, path,title,filetype,size) VALUES ($course_id,'/video','".get_lang('Video')."','folder','0')");
$example_doc_id = Database :: insert_id();
$example_doc_id = Database :: insert_id();
Database::query("INSERT INTO $TABLEITEMPROPERTY (c_id, tool,insert_user_id,insert_date,lastedit_date,ref,lastedit_type,lastedit_user_id,to_group_id,to_user_id,visibility) VALUES ($course_id,'document',1,NOW(),NOW(),$example_doc_id,'DocumentAdded',1,0,NULL,0)");
Database::query("INSERT INTO $TABLETOOLDOCUMENT (c_id, path,title,filetype,size) VALUES ($course_id,'/certificates','".get_lang('Certificates')."','folder','0')");
@ -4512,11 +4509,11 @@ class CourseManager {
$default_course_path = api_get_path(SYS_CODE_PATH).'default_course_document/';
$default_document_array = array();
foreach ($folders_to_copy_from_default_course as $folder) {
foreach ($folders_to_copy_from_default_course as $folder) {
$default_course_folder_path = $default_course_path.$folder.'/';
$files = browse_folders($default_course_folder_path, array(), $folder);
$sorted_array = sort_pictures($files, 'dir');
$sorted_array = array_merge($sorted_array, sort_pictures($files, 'file'));
$sorted_array = array_merge($sorted_array, sort_pictures($files, 'file'));
$default_document_array[$folder] = $sorted_array;
}
@ -4530,16 +4527,16 @@ class CourseManager {
foreach ($default_document_array as $media_type => $array_media) {
$path_documents = "/$media_type/";
//hack until feature #5242 is implemented
//hack until feature #5242 is implemented
if ($media_type == 'images') {
$media_type = 'images/gallery';
$images_folder = $sys_course_path.$course_repository."/document/images/";
if (!is_dir($images_folder)) {
//Creating index.html
//Creating index.html
mkdir($images_folder, $perm);
$fd = fopen($images_folder.'index.html', 'w');
fwrite($fd, $htmlpage);
fwrite($fd, $htmlpage);
@chmod($images_folder.'index.html', $perm_file);
}
}
@ -4550,10 +4547,10 @@ class CourseManager {
//echo 'try '.$course_documents_folder; echo '<br />';
if (!is_dir($course_documents_folder)) {
//Creating index.html
//Creating index.html
mkdir($course_documents_folder, $perm);
$fd = fopen($course_documents_folder.'index.html', 'w');
fwrite($fd, $htmlpage);
fwrite($fd, $htmlpage);
@chmod($course_documents_folder.'index.html', $perm_file);
}
@ -4568,7 +4565,7 @@ class CourseManager {
//Creating index.html (for light protection)
$index_html = $course_documents_folder.$value['dir'].'/index.html';
$fd = fopen($index_html, 'w');
fwrite($fd, $htmlpage);
fwrite($fd, $htmlpage);
@chmod($index_html, $perm_file);
//Inserting folder in the DB
@ -4576,13 +4573,13 @@ class CourseManager {
$temp = explode('/', $folder_path);
$title = $temp[count($temp)-1];
//hack until feature #5242 is implemented
//hack until feature #5242 is implemented
if ($title == 'gallery') {
$title = get_lang('DefaultCourseImages');
}
if ($media_type == 'images/gallery') {
$folder_path = 'gallery/'.$folder_path;
$folder_path = 'gallery/'.$folder_path;
}
Database::query("INSERT INTO $TABLETOOLDOCUMENT (c_id, path,title,filetype,size) VALUES ($course_id,'$path_documents".$folder_path."','".$title."','folder','0')");
@ -4595,14 +4592,14 @@ class CourseManager {
if (!file_exists($course_documents_folder.$value['file'])) {
//Copying file
copy($default_course_path.$value['file'], $course_documents_folder.$value['file']);
chmod($course_documents_folder.$value['file'], $perm_file);
chmod($course_documents_folder.$value['file'], $perm_file);
//echo $default_course_path.$value['file']; echo ' - '; echo $course_documents_folder.$value['file']; echo '<br />';
$temp = explode('/', $value['file']);
$file_size = filesize($course_documents_folder.$value['file']);
//hack until feature #5242 is implemented
//hack until feature #5242 is implemented
if ($media_type == 'images/gallery') {
$value["file"] = 'gallery/'.$value["file"];
$value["file"] = 'gallery/'.$value["file"];
}
//Inserting file in the DB
@ -4682,7 +4679,7 @@ class CourseManager {
$html=Database::escape_string('<table width="100%" border="0" cellpadding="0" cellspacing="0"><tr><td width="110" valign="top" align="left"><img src="'.api_get_path(WEB_CODE_PATH).'default_course_document/images/mr_dokeos/thinking.jpg"></td><td valign="top" align="left">'.get_lang('Antique').'</td></tr></table>');
Database::query('INSERT INTO '.$TABLEQUIZ .
Database::query('INSERT INTO '.$TABLEQUIZ .
' (c_id, title, description, type, random, random_answers, active, results_disabled ) ' .
' VALUES ('.$course_id.', "'.lang2db(get_lang('ExerciceEx')) . '",' .
' "'.$html.'", "1", "0", "0", "1", "0")');
@ -4764,7 +4761,7 @@ class CourseManager {
$department_name = isset($params['department_name']) ? $params['department_name'] : null;
$department_url = isset($params['department_url']) ? $params['department_url'] : null;
$disk_quota = isset($params['disk_quota']) ? $params['disk_quota'] : null;
if (!isset($params['visibility'])) {
$default_course_visibility = api_get_setting('courses_default_creation_visibility');
if (isset($default_course_visibility)) {
@ -4777,7 +4774,7 @@ class CourseManager {
}
$subscribe = isset($params['subscribe']) ? intval($params['subscribe']) : ($visibility == COURSE_VISIBILITY_OPEN_PLATFORM ? 1 : 0);
$unsubscribe = isset($params['unsubscribe']) ? intval($params['unsubscribe']) : 0;
$expiration_date = isset($params['expiration_date']) ? $params['expiration_date'] : null;
$expiration_date = isset($params['expiration_date']) ? $params['expiration_date'] : null;
$teachers = isset($params['teachers']) ? $params['teachers'] : null;
$status = isset($params['status']) ? $params['status'] : null;
@ -4899,7 +4896,7 @@ class CourseManager {
}
}
// Adding the course to an URL
// Adding the course to an URL
if (api_is_multiple_url_enabled()) {
$url_id = 1;
if (api_get_current_access_url_id() != -1) {
@ -4936,7 +4933,7 @@ class CourseManager {
return $course_id;
}
/**
* Extract properties of the files from a ZIP package, write them to disk and

@ -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;
}
}

@ -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;
}

@ -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();
}
}*/
}

File diff suppressed because it is too large Load Diff

@ -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();
}
}

@ -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 %}

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

@ -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());
}

@ -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);
}

@ -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();

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

@ -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',

@ -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/',
);

@ -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);

@ -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"
}
]

Loading…
Cancel
Save