Browse Source

Removing "class" functions + converting events.lib.inc.php into a class

Julio Montoya 10 years ago
parent
commit
4fc32e485b

+ 0 - 47
main/admin/class_add.php

@@ -1,47 +0,0 @@
-<?php
-/* For licensing terms, see /license.txt */
-/**
-*	@package chamilo.admin
-*/
-/**
- * Code
- */
-// Language files that should be included.
-$language_file = 'admin';
-
-// Resetting the course id.
-$cidReset = true;
-
-// Including some necessary dokeos files.
-require_once '../inc/global.inc.php';
-
-// Setting the section (for the tabs).
-$this_section = SECTION_PLATFORM_ADMIN;
-
-// Access restrictions.
-api_protect_admin_script();
-
-// Setting breadcrumbs.
-$interbreadcrumb[] = array('url' => 'index.php', 'name' => get_lang('PlatformAdmin'));
-$interbreadcrumb[] = array ('url' => 'class_list.php', 'name' => get_lang('Classes'));
-
-// Setting the name of the tool.
-$tool_name = get_lang("AddClasses");
-
-$form = new FormValidator('add_class');
-$form->add_textfield('name', get_lang('ClassName'));
-$form->addElement('style_submit_button', 'submit', get_lang('Ok'), 'class="add"');
-if ($form->validate()) {
-    $values = $form->exportValues();
-    ClassManager::create_class($values['name']);
-    header('Location: class_list.php');
-}
-
-// Displaying the header.
-Display :: display_header($tool_name);
-
-// Displaying the form.
-$form->display();
-
-// Displaying the footer.
-Display :: display_footer();

+ 0 - 52
main/admin/class_edit.php

@@ -1,52 +0,0 @@
-<?php
-/* For licensing terms, see /license.txt */
-/**
-*	@package chamilo.admin
-*/
-/**
- * Code
- */
-// Language files that should be included.
-$language_file = 'admin';
-
-// Resetting the course id.
-$cidReset = true;
-
-// Including some necessary dokeos files.
-require_once '../inc/global.inc.php';
-require_once api_get_path(LIBRARY_PATH).'classmanager.lib.php';
-
-// Setting the section (for the tabs).
-$this_section = SECTION_PLATFORM_ADMIN;
-
-// Access restrictions.
-api_protect_admin_script();
-
-// Setting breadcrumbs.
-$interbreadcrumb[] = array ('url' => 'index.php', 'name' => get_lang('PlatformAdmin'));
-$interbreadcrumb[] = array ('url' => 'class_list.php', 'name' => get_lang('AdminClasses'));
-
-
-// Setting the name of the tool.
-$tool_name = get_lang('AddClasses');
-
-$tool_name = get_lang('ModifyClassInfo');
-$class_id = intval($_GET['idclass']);
-$class = ClassManager :: get_class_info($class_id);
-$form = new FormValidator('edit_class', 'post', 'class_edit.php?idclass='.$class_id);
-$form->add_textfield('name',get_lang('ClassName'));
-$form->addElement('style_submit_button', 'submit', get_lang('Ok'), 'class="add"');
-$form->setDefaults(array('name'=>$class['name']));
-if($form->validate())
-{
-    $values = $form->exportValues();
-    ClassManager :: set_name($values['name'], $class_id);
-    header('Location: class_list.php');
-}
-
-Display :: display_header($tool_name);
-//api_display_tool_title($tool_name);
-$form->display();
-
-// Displaying the footer.
-Display :: display_footer();

+ 0 - 116
main/admin/class_import.php

@@ -1,116 +0,0 @@
-<?php
-/* For licensing terms, see /license.txt */
-/**
-*	@package chamilo.admin
-*/
-/**
- * Code
-*   This     tool allows platform admins to add classes by uploading a CSV file
-* @todo Add some langvars to DLTT
-*/
-
-/**
- * Validates imported data.
- */
-function validate_data($classes) {
-    $errors = array();
-    foreach ($classes as $index => $class) {
-        // 1. Check wheter ClassName is available.
-        if (!isset($class['ClassName']) || strlen(trim($class['ClassName'])) == 0) {
-            $class['line'] = $index + 2;
-            $class['error'] = get_lang('MissingClassName');
-            $errors[] = $class;
-        }
-        // 2. Check whether class doesn't exist yet.
-        else {
-            if (ClassManager::class_name_exists($class['ClassName'])) {
-                $class['line'] = $index + 2;
-                $class['error'] = get_lang('ClassNameExists').' <strong>'.$class['ClassName'].'</strong>';
-                $errors[] = $class;
-            }
-        }
-    }
-    return $errors;
-}
-
-/**
- * Save imported class data to database
- */
-function save_data($classes) {
-    $number_of_added_classes = 0;
-    foreach ($classes as $index => $class) {
-        if (ClassManager::create_class($class['ClassName'])) {
-            $number_of_added_classes++;
-        }
-    }
-    return $number_of_added_classes;
-}
-
-// Language files that should be included.
-$language_file = array ('admin', 'registration');
-
-// Resetting the course id.
-$cidReset = true;
-
-// Including some necessary dokeos files.
-include '../inc/global.inc.php';
-
-// Setting the section (for the tabs).
-$this_section = SECTION_PLATFORM_ADMIN;
-
-// Access restrictions.
-api_protect_admin_script();
-
-// setting breadcrumbs
-$interbreadcrumb[] = array ('url' => 'index.php', 'name' => get_lang('PlatformAdmin'));
-$interbreadcrumb[] = array ('url' => 'class_list.php', 'name' => get_lang('Classes'));
-
-// Database Table Definitions
-
-// Setting the name of the tool.
-$tool_name = get_lang('ImportClassListCSV');
-
-// Displaying the header.
-Display :: display_header($tool_name);
-//api_display_tool_title($tool_name);
-
-set_time_limit(0);
-
-$form = new FormValidator('import_classes');
-$form->addElement('file', 'import_file', get_lang('ImportCSVFileLocation'));
-$form->addElement('style_submit_button', 'submit', get_lang('Import'), 'class="save"');
-
-if ($form->validate()) {
-    $classes = Import::csv_to_array($_FILES['import_file']['tmp_name']);
-    $errors = validate_data($classes);
-    if (count($errors) == 0) {
-        $number_of_added_classes = save_data($classes);
-        Display::display_normal_message($number_of_added_classes.' '.get_lang('ClassesCreated'));
-    } else {
-        $error_message = get_lang('ErrorsWhenImportingFile');
-        $error_message .= '<ul>';
-        foreach ($errors as $index => $error_class) {
-            $error_message .= '<li>'.$error_class['error'].' ('.get_lang('Line').' '.$error_class['line'].')';
-            $error_message .= '</li>';
-        }
-        $error_message .= '</ul>';
-        $error_message .= get_lang('NoClassesHaveBeenCreated');
-        Display :: display_error_message($error_message);
-    }
-}
-
-$form->display();
-?>
-<p><?php echo get_lang('CSVMustLookLike').' ('.get_lang('MandatoryFields').')'; ?> :</p>
-
- <pre>
-  <b>ClassName</b>
-  <b>1A</b>
-  <b>1B</b>
-  <b>2A group 1</b>
-  <b>2A group 2</b>
- </pre>
-<?php
-
-// Displaying the footer.
-Display :: display_footer();

+ 0 - 104
main/admin/class_information.php

@@ -1,104 +0,0 @@
-<?php
-/* For licensing terms, see /license.txt */
-/**
-*	@package chamilo.admin
-*/
-/**
- * Code
-*	@author	 Bart Mollet
-*/
-
-// Language files that should be included.
-$language_file = 'admin';
-
-$cidReset = true;
-
-require_once '../inc/global.inc.php';
-$this_section = SECTION_PLATFORM_ADMIN;
-
-api_protect_admin_script();
-
-require_once api_get_path(LIBRARY_PATH).'classmanager.lib.php';
-
-if (!isset($_GET['id'])) {
-    api_not_allowed();
-}
-
-$interbreadcrumb[] = array ('url' => 'index.php', 'name' => get_lang('PlatformAdmin'));
-$interbreadcrumb[] = array ('url' => 'class_list.php', 'name' => get_lang('AdminClasses'));
-
-$class_id = $_GET['id'];
-$class = ClassManager::get_class_info($class_id);
-
-$tool_name = $class['name'];
-Display::display_header($tool_name);
-//api_display_tool_title($tool_name);
-
-/**
- * Show all users subscribed in this class.
- */
-echo '<h4>'.get_lang('Users').'</h4>';
-$users = ClassManager::get_users($class_id);
-if (count($users) > 0) {
-    $is_western_name_order = api_is_western_name_order();
-    $table_header[] = array (get_lang('OfficialCode'), true);
-    if ($is_western_name_order) {
-        $table_header[] = array (get_lang('FirstName'), true);
-        $table_header[] = array (get_lang('LastName'), true);
-    } else {
-        $table_header[] = array (get_lang('LastName'), true);
-        $table_header[] = array (get_lang('FirstName'), true);
-    }
-    $table_header[] = array (get_lang('Email'), true);
-    $table_header[] = array (get_lang('Status'), true);
-    $table_header[] = array ('', false);
-    $data = array();
-    foreach($users as $index => $user) {
-        $username = api_htmlentities(sprintf(get_lang('LoginX'), $user['username']), ENT_QUOTES);
-        $row = array ();
-        $row[] = $user['official_code'];
-        if ($is_western_name_order) {
-            $row[] = $user['firstname'];
-            $row[] = "<span title='$username'>".$user['lastname']."</span>";
-        } else {
-            $row[] = "<span title='$username'>".$user['lastname']."</span>";
-            $row[] = $user['firstname'];
-        }
-        $row[] = Display :: encrypted_mailto_link($user['email'], $user['email']);
-        $row[] = $user['status'] == 5 ? get_lang('Student') : get_lang('Teacher');
-        $row[] = '<a href="user_information.php?user_id='.$user['user_id'].'">'.Display::return_icon('synthese_view.gif', get_lang('Info')).'</a>';
-        $data[] = $row;
-    }
-    Display::display_sortable_table($table_header,$data,array(),array(),array('id'=>$_GET['id']));
-} else {
-    echo get_lang('NoUsersInClass');
-}
-
-/**
- * Show all courses in which this class is subscribed.
- */
-$courses = ClassManager::get_courses($class_id);
-if (count($courses) > 0) {
-    $header[] = array (get_lang('Code'), true);
-    $header[] = array (get_lang('Title'), true);
-    $header[] = array ('', false);
-    $data = array ();
-    foreach( $courses as $index => $course) {
-        $row = array ();
-        $row[] = $course['visual_code'];
-        $row[] = $course['title'];
-        $row[] = '<a href="course_information.php?code='.$course['code'].'">'.Display::return_icon('info_small.gif', get_lang('Delete')).'</a>'.
-                    '<a href="'.api_get_path(WEB_COURSE_PATH).$course['directory'].'">'.Display::return_icon('course_home.gif', get_lang('CourseHome')).'</a>' .
-                    '<a href="course_edit.php?course_code='.$course['code'].'">'.Display::return_icon('edit.gif', get_lang('Edit')).'</a>';
-        $data[] = $row;
-    }
-    echo '<p><b>'.get_lang('Courses').'</b></p>';
-    echo '<blockquote>';
-    Display :: display_sortable_table($header, $data, array (), array (), array('id'=>$_GET['id']));
-    echo '</blockquote>';
-} else {
-    echo '<p>'.get_lang('NoCoursesForThisClass').'</p>';
-}
-
-// Displaying the footer.
-Display::display_footer();

+ 0 - 130
main/admin/class_list.php

@@ -1,130 +0,0 @@
-<?php
-/* For licensing terms, see /license.txt */
-/**
-*	@package chamilo.admin
-*/
-/**
- * Code
- */
-$language_file = 'admin';
-
-$cidReset = true;
-require '../inc/global.inc.php';
-
-$this_section = SECTION_PLATFORM_ADMIN;
-api_protect_admin_script();
-
-/**
- * Gets the total number of classes.
- */
-function get_number_of_classes() {
-    $tbl_class = Database :: get_main_table(TABLE_MAIN_CLASS);
-    $sql = "SELECT COUNT(*) AS number_of_classes FROM $tbl_class";
-    if (isset ($_GET['keyword'])) {
-        $sql .= " WHERE (name LIKE '%".Database::escape_string(trim($_GET['keyword']))."%')";
-    }
-    $res = Database::query($sql);
-    $obj = Database::fetch_object($res);
-    return $obj->number_of_classes;
-}
-
-/**
- * Gets the information about some classes.
- * @param int $from
- * @param int $number_of_items
- * @param string $direction
- */
-function get_class_data($from, $number_of_items, $column, $direction) {
-    $tbl_class_user = Database::get_main_table(TABLE_MAIN_CLASS_USER);
-    $tbl_class = Database :: get_main_table(TABLE_MAIN_CLASS);
-    $from 				= Database::escape_string($from);
-    $number_of_items 	= Database::escape_string($number_of_items);
-    $column 			= Database::escape_string($column);
-    $direction 			= Database::escape_string($direction);
-
-    $sql = "SELECT 	id AS col0, name AS col1, COUNT(user_id) AS col2, id AS col3
-        FROM $tbl_class
-            LEFT JOIN $tbl_class_user ON id=class_id ";
-    if (isset ($_GET['keyword'])) {
-        $sql .= " WHERE (name LIKE '%".Database::escape_string(trim($_GET['keyword']))."%')";
-    }
-    $sql .= " GROUP BY id,name ORDER BY col$column $direction LIMIT $from,$number_of_items";
-    $res = Database::query($sql);
-    $classes = array ();
-    while ($class = Database::fetch_row($res)) {
-        $classes[] = $class;
-    }
-    return $classes;
-}
-
-/**
- * Filter for sortable table to display edit icons for class
- */
-function modify_filter($class_id) {
-    $class_id = Security::remove_XSS($class_id);
-    $result = '<a href="class_information.php?id='.$class_id.'">'.Display::return_icon('synthese_view.gif', get_lang('Info')).'</a>';
-    $result .= ' <a href="class_edit.php?idclass='.$class_id.'">'.Display::return_icon('edit.png', get_lang('Edit')).'</a>';
-    $result .= ' <a href="subscribe_user2class.php?idclass='.$class_id.'">'.Display::return_icon('add_multiple_users.gif', get_lang('AddUsersToAClass')).'</a>';
-    $result .= ' <a href="class_list.php?action=delete_class&amp;class_id='.$class_id.'" onclick="javascript: if(!confirm('."'".addslashes(get_lang("ConfirmYourChoice"))."'".')) return false;">'.Display::return_icon('delete.png', get_lang('Delete')).'</a>';
-    return $result;
-}
-
-$tool_name = get_lang('ClassList');
-$interbreadcrumb[] = array ('url' => 'index.php', 'name' => get_lang('PlatformAdmin'));
-
-if (isset($_POST['action'])) {
-    switch ($_POST['action']) {
-        // Delete selected classes
-        case 'delete_classes' :
-            $classes = $_POST['class'];
-            if (count($classes) > 0) {
-                foreach ($classes as $index => $class_id) {
-                    ClassManager :: delete_class($class_id);
-                }
-                $message = Display :: return_message(get_lang('ClassesDeleted'));
-            }
-            break;
-    }
-}
-
-if (isset($_GET['action'])) {
-    switch ($_GET['action']) {
-        case 'delete_class':
-            ClassManager :: delete_class($_GET['class_id']);
-            $message = Display :: return_message(get_lang('ClassDeleted'));
-            break;
-        case 'show_message':
-            $message = Display :: return_message(Security::remove_XSS(stripslashes($_GET['message'])));
-            break;
-    }
-}
-
-// Create a search-box
-$form = new FormValidator('search_simple', 'get', '', '', null, false);
-$renderer =& $form->defaultRenderer();
-$renderer->setElementTemplate('<span>{element}</span> ');
-$form->addElement('text', 'keyword', get_lang('keyword'));
-$form->addElement('button', 'submit', get_lang('Search'));
-$content .= $form->return_form();
-
-// Create the sortable table with class information
-$table = new SortableTable('classes', 'get_number_of_classes', 'get_class_data', 1);
-$table->set_additional_parameters(array('keyword' => $_GET['keyword']));
-$table->set_header(0, '', false);
-$table->set_header(1, get_lang('ClassName'));
-$table->set_header(2, get_lang('NumberOfUsers'));
-$table->set_header(3, '', false);
-$table->set_column_filter(3, 'modify_filter');
-$table->set_form_actions(array ('delete_classes' => get_lang('DeleteSelectedClasses')), 'class');
-
-$content .= $table->return_table();
-
-$actions .= Display::url(Display::return_icon('add.png', get_lang('Add'), array(), ICON_SIZE_MEDIUM), 'class_add.php');
-$actions .= Display::url(Display::return_icon('import_csv.png', get_lang('AddUsersToAClass'), array(), ICON_SIZE_MEDIUM), 'class_user_import.php');
-$actions .= Display::url(Display::return_icon('import_csv.png', get_lang('ImportClassListCSV'), array(), ICON_SIZE_MEDIUM), 'class_import.php');
-
-//$app['title'] = $tool_name;
-
-echo $message;
-echo $actions;
-echo $content;

+ 0 - 192
main/admin/class_user_import.php

@@ -1,192 +0,0 @@
-<?php
-/* For licensing terms, see /license.txt */
-/**
-*	@package chamilo.admin
-*/
-/**
- * Code
-* This tool allows platform admins to update class-user relations by uploading
-* a CSVfile
-*/
-
-/**
- * Validates imported data.
- */
-function validate_data($user_classes) {
-    global $purification_option_for_usernames;
-    $errors = array ();
-    $classcodes = array ();
-
-    if (!isset($_POST['subscribe']) && !isset($_POST['subscribe']))  {
-          $user_class['error'] = get_lang('SelectAnAction');
-          $errors[] = $user_class;
-          return $errors;
-    }
-    foreach ($user_classes as $index => $user_class) {
-        $user_class['line'] = $index + 1;
-        // 1. Check whether mandatory fields are set.
-        $mandatory_fields = array ('UserName', 'ClassName');
-
-        foreach ($mandatory_fields as $key => $field) {
-            if (!isset ($user_class[$field]) || strlen($user_class[$field]) == 0) {
-                $user_class['error'] = get_lang($field.'Mandatory');
-                $errors[] = $user_class;
-            }
-        }
-
-        // 2. Check whether classcode exists.
-        if (isset ($user_class['ClassName']) && strlen($user_class['ClassName']) != 0) {
-            // 2.1 Check whether code has been allready used in this CVS-file.
-            if (!isset ($classcodes[$user_class['ClassName']])) {
-                // 2.1.1 Check whether code exists in DB.
-                $class_table = Database :: get_main_table(TABLE_MAIN_CLASS);
-                $sql = "SELECT * FROM $class_table WHERE name = '".Database::escape_string($user_class['ClassName'])."'";
-                $res = Database::query($sql);
-                if (Database::num_rows($res) == 0) {
-                    $user_class['error'] = get_lang('CodeDoesNotExists').': '.$user_class['ClassName'];
-                    $errors[] = $user_class;
-                } else {
-                    $classcodes[$user_class['CourseCode']] = 1;
-                }
-            }
-        }
-        // 3. Check username, first, check whether it is empty.
-        if (!UserManager::is_username_empty($user_class['UserName'])) {
-            // 3.1. Check whether username is too long.
-            if (UserManager::is_username_too_long($user_class['UserName'])) {
-                $user_class['error'] = get_lang('UserNameTooLong').': '.$user_class['UserName'];
-                $errors[] = $user_class;
-            }
-            $username = UserManager::purify_username($user_class['UserName'], $purification_option_for_usernames);
-            // 3.2. Check whether username exists.
-            if (UserManager::is_username_available($username)) {
-                $user_class['error'] = get_lang('UnknownUser').': '.$username;
-                $errors[] = $user_class;
-            }
-        }
-    }
-    return $errors;
-}
-
-/**
- * Saves imported data.
- */
-function save_data($users_classes) {
-
-    global $purification_option_for_usernames;
-
-    // Table definitions.
-    $user_table 		= Database :: get_main_table(TABLE_MAIN_USER);
-    $class_user_table 	= Database :: get_main_table(TABLE_MAIN_CLASS_USER);
-    $class_table 		= Database :: get_main_table(TABLE_MAIN_CLASS);
-
-    // Data parsing: purification + conversion (UserName, ClassName) --> (user_is, class_id)
-    $csv_data = array ();
-    foreach ($users_classes as $index => $user_class) {
-
-        $sql1 = "SELECT user_id FROM $user_table WHERE username = '".Database::escape_string(UserManager::purify_username($user_class['UserName'], $purification_option_for_usernames))."'";
-        $res1 = Database::query($sql1);
-        $obj1 = Database::fetch_object($res1);
-        $sql2 = "SELECT id FROM $class_table WHERE name = '".Database::escape_string(trim($user_class['ClassName']))."'";
-        $res2 = Database::query($sql2);
-        $obj2 = Database::fetch_object($res2);
-        if ($obj1 && $obj2) {
-            $csv_data[$obj1->user_id][$obj2->id] = 1;
-        }
-    }
-
-    // Logic for processing the request (data + UI options).
-    $db_subscriptions = array();
-    foreach ($csv_data as $user_id => $csv_subscriptions) {
-        $sql = "SELECT class_id FROM $class_user_table cu WHERE cu.user_id = $user_id";
-        $res = Database::query($sql);
-        while ($obj = Database::fetch_object($res)) {
-            $db_subscriptions[$obj->class_id] = 1;
-        }
-        $to_subscribe   = array_diff(array_keys($csv_subscriptions), array_keys($db_subscriptions));
-        $to_unsubscribe = array_diff(array_keys($db_subscriptions), array_keys($csv_subscriptions));
-
-        // Subscriptions for new classes.
-        if ($_POST['subscribe']) {
-            foreach ($to_subscribe as $class_id) {
-                ClassManager::add_user($user_id, $class_id);
-            }
-        }
-        // Unsubscription from previous classes.
-        if ($_POST['unsubscribe']) {
-            foreach ($to_unsubscribe as $class_id) {
-                ClassManager::unsubscribe_user($user_id, $class_id);
-            }
-        }
-    }
-}
-
-/**
- * Reads a CSV-file.
- * @param string $file Path to the CSV-file
- * @return array All course-information read from the file
- */
-function parse_csv_data($file) {
-    $courses = Import::csv_to_array($file);
-    return $courses;
-}
-
-$language_file = array('admin', 'registration');
-$cidReset = true;
-
-require_once '../inc/global.inc.php';
-
-$this_section = SECTION_PLATFORM_ADMIN;
-api_protect_admin_script(true);
-
-require_once api_get_path(LIBRARY_PATH).'import.lib.php';
-
-$tool_name = get_lang('AddUsersToAClass').' CSV';
-
-$interbreadcrumb[] = array ('url' => 'index.php', 'name' => get_lang('PlatformAdmin'));
-$interbreadcrumb[] = array ('url' => 'class_list.php', 'name' => get_lang('Classes'));
-
-// Set this option to true to enforce strict purification for usenames.
-$purification_option_for_usernames = false;
-
-set_time_limit(0);
-
-$form = new FormValidator('class_user_import');
-$form->addElement('file', 'import_file', get_lang('ImportFileLocation'));
-$form->addElement('checkbox', 'subscribe', get_lang('Action'), get_lang('SubscribeUserIfNotAllreadySubscribed'));
-$form->addElement('checkbox', 'unsubscribe', '', get_lang('UnsubscribeUserIfSubscriptionIsNotInFile'));
-$form->addElement('style_submit_button', 'submit', get_lang('Import'), 'class="save"');
-
-if ($form->validate()) {
-    $users_classes = parse_csv_data($_FILES['import_file']['tmp_name']);
-
-    $errors = validate_data($users_classes);
-    if (count($errors) == 0) {
-        save_data($users_classes);
-        header('Location: class_list.php?action=show_message&message='.urlencode(get_lang('FileImported')));
-        exit();
-    }
-}
-
-Display :: display_header($tool_name);
-api_display_tool_title($tool_name);
-
-if (count($errors) != 0) {
-    $error_message = "\n";
-    foreach ($errors as $index => $error_class_user) {
-        $error_message .= get_lang('Line').' '.$error_class_user['line'].': '.$error_class_user['error'].'</b>';
-        $error_message .= "<br />";
-    }
-    $error_message .= "\n";
-    Display :: display_error_message($error_message, false);
-}
-$form->display();
-?>
-<p><?php echo get_lang('CSVMustLookLike').' ('.get_lang('MandatoryFields').')'; ?> :</p>
-<pre>
-<b>UserName</b>;<b>ClassName</b>
-jdoe;class01
-adam;class01
-</pre>
-<?php
-Display :: display_footer();

+ 4 - 4
main/admin/configure_homepage.php

@@ -181,7 +181,7 @@ if (!empty($action)) {
                 if (EventsMail::check_if_using_class('portal_homepage_edited')) {
                     EventsDispatcher::events('portal_homepage_edited', array('about_user' => api_get_user_id()));
                 }
-                event_system(
+                Event::addEvent(
                     LOG_HOMEPAGE_CHANGED,
                     'edit_top',
                     Text::cut(strip_tags($home_top), 254),
@@ -221,7 +221,7 @@ if (!empty($action)) {
                     fputs($fp, "<b>$notice_title</b><br />\n$notice_text");
                     fclose($fp);
                 }
-                event_system(
+                Event::addEvent(
                     LOG_HOMEPAGE_CHANGED,
                     'edit_notice',
                     Text::cut(strip_tags($notice_title), 254),
@@ -274,7 +274,7 @@ if (!empty($action)) {
                         }
                     }
                 }
-                event_system(
+                Event::addEvent(
                     LOG_HOMEPAGE_CHANGED,
                     'edit_news',
                     strip_tags(Text::cut($home_news, 254)),
@@ -422,7 +422,7 @@ if (!empty($action)) {
                         fclose($fp);
                     }
                 }
-                event_system(
+                Event::addEvent(
                     LOG_HOMEPAGE_CHANGED,
                     $action,
                     Text::cut($link_name.':'.$link_url, 254),

+ 1 - 2
main/admin/course_add.php

@@ -11,7 +11,6 @@
 $language_file = array('admin', 'create_course');
 
 $cidReset = true;
-require_once '../inc/global.inc.php';
 $this_section = SECTION_PLATFORM_ADMIN;
 
 api_protect_admin_script();
@@ -150,4 +149,4 @@ if ($form->validate()) {
 // Display the form.
 $content = $form->return_form();
 
-echo $content;
+echo $content;

+ 30 - 21
main/admin/course_edit.php

@@ -7,7 +7,6 @@
 // name of the language file that needs to be included
 $language_file = 'admin';
 $cidReset = true;
-require_once '../inc/global.inc.php';
 $this_section = SECTION_PLATFORM_ADMIN;
 
 api_protect_admin_script();
@@ -33,8 +32,13 @@ if (empty($course)) {
 // Get course teachers
 $table_course_user = Database :: get_main_table(TABLE_MAIN_COURSE_USER);
 $order_clause = api_sort_by_first_name() ? ' ORDER BY firstname, lastname' : ' ORDER BY lastname, firstname';
-$sql = "SELECT user.user_id,lastname,firstname FROM $table_user as user,$table_course_user as course_user
-WHERE course_user.status='1' AND course_user.user_id=user.user_id AND course_user.c_id ='".$course['real_id']."'".$order_clause;
+$sql = "SELECT user.user_id,lastname,firstname
+    FROM $table_user as user,$table_course_user as course_user
+    WHERE
+        course_user.status='1' AND
+        course_user.user_id=user.user_id AND
+        course_user.c_id ='".$course['real_id']."'".
+    $order_clause;
 $res = Database::query($sql);
 $course_teachers = array();
 while ($obj = Database::fetch_object($res)) {
@@ -42,34 +46,39 @@ while ($obj = Database::fetch_object($res)) {
 }
 
 // Get all possible teachers without the course teachers
-if (api_is_multiple_url_enabled()) {
-	$access_url_rel_user_table= Database :: get_main_table(TABLE_MAIN_ACCESS_URL_REL_USER);
-	$sql = "SELECT u.user_id,lastname,firstname FROM $table_user as u
-			INNER JOIN $access_url_rel_user_table url_rel_user
-			ON (u.user_id=url_rel_user.user_id) WHERE url_rel_user.access_url_id=".api_get_current_access_url_id()." AND status = 1 or status = 2 ".$order_clause;
-} else {
-	$sql = "SELECT user_id,lastname,firstname FROM $table_user WHERE status = 1 or status = 2 ".$order_clause;
-}
-
-$res = Database::query($sql);
+/*$sql = "SELECT u.user_id,lastname,firstname
+        FROM $table_user as u
+        INNER JOIN $access_url_rel_user_table url_rel_user
+        ON (u.user_id=url_rel_user.user_id)
+        WHERE
+            url_rel_user.access_url_id=".api_get_current_access_url_id()." AND
+            status = 1 or status = 2 ".$order_clause;*/
+/** @var Doctrine\ORM\EntityManager $em */
+/*$em = $this->getDoctrine()->getManager();
+$userManager = $em->getRepository('ApplicationSonataUserBundle:User');
+var_dump($userManager->getTeachers());*/
+//$userManager->get
+
+
+$teachersInPlatform = CourseManager::get_teacher_list_from_course_code($course['real_id']);
 $teachers = array();
 
 $platform_teachers[0] = '-- '.get_lang('NoManager').' --';
-while ($obj = Database::fetch_object($res)) {
-
-	if (!array_key_exists($obj->user_id,$course_teachers)) {
-		$teachers[$obj->user_id] = api_get_person_name($obj->firstname, $obj->lastname);
+foreach ($teachersInPlatform as $teacher) {
+    $teacherId = $teacher['user_id'];
+	if (!array_key_exists($teacherId, $course_teachers)) {
+		$teachers[$teacherId] = api_get_person_name($teacher['firstname'], $teacher['lastname']);
 	}
 
-	if (isset($course['tutor_name']) && isset($course_teachers[$obj->user_id]) && $course['tutor_name']== $course_teachers[$obj->user_id]) {
-		$course['tutor_name']=$obj->user_id;
+	if (isset($course['tutor_name']) && isset($course_teachers[$teacherId]) && $course['tutor_name'] == $course_teachers[$teacherId]) {
+		$course['tutor_name'] = $teacherId;
 	}
 	//We add in the array platform teachers
-	$platform_teachers[$obj->user_id] = api_get_person_name($obj->firstname, $obj->lastname);
+	$platform_teachers[$teacherId] = api_get_person_name($teacher['firstname'], $teacher['lastname']);
 }
 
 //Case where there is no teacher in the course
-if (count($course_teachers)==0) {
+if (count($course_teachers) ==0 ) {
 	$sql='SELECT tutor_name FROM '.$course_table.' WHERE code="'.$course_code.'"';
 	$res = Database::query($sql);
 	$tutor_name=Database::result($res,0,0);

+ 5 - 5
main/admin/settings.lib.php

@@ -24,7 +24,7 @@ function handle_regions()
         $user_id = api_get_user_id();
         $category = $_GET['category'];
         api_set_setting_last_update();
-        event_system(LOG_CONFIGURATION_SETTINGS_CHANGE, LOG_CONFIGURATION_SETTINGS_CATEGORY, $category, api_get_utc_datetime(), $user_id);
+        Event::addEvent(LOG_CONFIGURATION_SETTINGS_CHANGE, LOG_CONFIGURATION_SETTINGS_CATEGORY, $category, api_get_utc_datetime(), $user_id);
         Display :: display_confirmation_message(get_lang('SettingsStored'));
     }
 
@@ -111,7 +111,7 @@ function handle_plugins()
         // Add event to the system log.
         $user_id = api_get_user_id();
         $category = $_GET['category'];
-        event_system(LOG_CONFIGURATION_SETTINGS_CHANGE, LOG_CONFIGURATION_SETTINGS_CATEGORY, $category, api_get_utc_datetime(), $user_id);
+        Event::addEvent(LOG_CONFIGURATION_SETTINGS_CHANGE, LOG_CONFIGURATION_SETTINGS_CATEGORY, $category, api_get_utc_datetime(), $user_id);
         Display :: display_confirmation_message(get_lang('SettingsStored'));
     }
 
@@ -246,7 +246,7 @@ function handle_stylesheets()
             $user_id = api_get_user_id();
             $category = $_GET['category'];
 
-            event_system(LOG_CONFIGURATION_SETTINGS_CHANGE, LOG_CONFIGURATION_SETTINGS_CATEGORY, $category, api_get_utc_datetime(), $user_id);
+            Event::addEvent(LOG_CONFIGURATION_SETTINGS_CHANGE, LOG_CONFIGURATION_SETTINGS_CATEGORY, $category, api_get_utc_datetime(), $user_id);
 
             if ($result) {
                 Display::display_confirmation_message(get_lang('StylesheetAdded'));
@@ -724,7 +724,7 @@ function handle_templates()
         // Add event to the system log.
         $user_id = api_get_user_id();
         $category = $_GET['category'];
-        event_system(LOG_CONFIGURATION_SETTINGS_CHANGE, LOG_CONFIGURATION_SETTINGS_CATEGORY, $category, api_get_utc_datetime(), $user_id);
+        Event::addEvent(LOG_CONFIGURATION_SETTINGS_CHANGE, LOG_CONFIGURATION_SETTINGS_CATEGORY, $category, api_get_utc_datetime(), $user_id);
 
     } else {
         if ($action == 'delete' && is_numeric($_GET['id'])) {
@@ -733,7 +733,7 @@ function handle_templates()
             // Add event to the system log
             $user_id = api_get_user_id();
             $category = $_GET['category'];
-            event_system(LOG_CONFIGURATION_SETTINGS_CHANGE, LOG_CONFIGURATION_SETTINGS_CATEGORY, $category, api_get_utc_datetime(), $user_id);
+            Event::addEvent(LOG_CONFIGURATION_SETTINGS_CHANGE, LOG_CONFIGURATION_SETTINGS_CATEGORY, $category, api_get_utc_datetime(), $user_id);
         }
         display_templates();
     }

+ 3 - 3
main/admin/settings.php

@@ -336,7 +336,7 @@ if (!empty($_GET['category']) && !in_array($_GET['category'], array('Plugins', '
         // Add event configuration settings category to the system log.
         $user_id = api_get_user_id();
         $category = $_GET['category'];
-        event_system(
+        Event::addEvent(
             LOG_CONFIGURATION_SETTINGS_CHANGE,
             LOG_CONFIGURATION_SETTINGS_CATEGORY,
             $category,
@@ -352,7 +352,7 @@ if (!empty($_GET['category']) && !in_array($_GET['category'], array('Plugins', '
                 if (in_array($key, $settings_to_avoid)) {
                     continue;
                 }
-                event_system(
+                Event::addEvent(
                     LOG_CONFIGURATION_SETTINGS_CHANGE,
                     LOG_CONFIGURATION_SETTINGS_VARIABLE,
                     $variable,
@@ -502,7 +502,7 @@ if (!empty($_GET['category'])) {
                     // add event to system log
                     $user_id = api_get_user_id();
                     $category = $_GET['category'];
-                    event_system(
+                    Event::addEvent(
                         LOG_CONFIGURATION_SETTINGS_CHANGE,
                         LOG_CONFIGURATION_SETTINGS_CATEGORY,
                         $category,

+ 5 - 5
main/admin/sub_language.class.php

@@ -4,7 +4,7 @@
 
 /**
  * SubLanguageManager class definition file
- * @package chamilo.admin.sublanguage 
+ * @package chamilo.admin.sublanguage
  * @todo clean this lib and move to main/inc/lib
  */
 class SubLanguageManager {
@@ -255,9 +255,9 @@ class SubLanguageManager {
             return false;
         }
     }
-    
+
     public static function check_if_language_is_used($language_id) {
-        $language_info = self::get_all_information_of_language($language_id);        
+        $language_info = self::get_all_information_of_language($language_id);
         $user_table = Database :: get_main_table(TABLE_MAIN_USER);
         $sql = 'SELECT count(*) AS count FROM ' . $user_table . ' WHERE language ="' . Database::escape_string($language_info['english_name']).'"';
         $rs = Database::query($sql);
@@ -325,7 +325,7 @@ class SubLanguageManager {
         $lang = Database::fetch_array($result);
         $sql_update_2 = "UPDATE " . $tbl_settings_current . " SET selected_value='" . $lang['english_name'] . "' WHERE variable='platformLanguage'";
         $result_2 = Database::query($sql_update_2);
-        event_system(LOG_PLATFORM_LANGUAGE_CHANGE, LOG_PLATFORM_LANGUAGE, $lang['english_name']);
+        Event::addEvent(LOG_PLATFORM_LANGUAGE_CHANGE, LOG_PLATFORM_LANGUAGE, $lang['english_name']);
         return $result_2 !== false;
     }
 
@@ -363,4 +363,4 @@ class SubLanguageManager {
         return $row['dokeos_folder'];
     }
 
-}
+}

+ 4 - 3
main/inc/lib/api.lib.php

@@ -1572,8 +1572,8 @@ function api_format_course_array($course_data) {
     $_course['directory'    ]         = $course_data['directory'      ];
 
     //@todo should be deprecated
-    $_course['dbName'       ]         = $course_data['db_name'        ]; // Use as key in db list.
-    $_course['db_name'      ]         = $course_data['db_name'         ];
+    //$_course['dbName'       ]         = $course_data['db_name'        ]; // Use as key in db list.
+    //$_course['db_name'      ]         = $course_data['db_name'         ];
     //$_course['dbNameGlu'    ]         = $_configuration['table_prefix'] . $course_data['db_name'] . $_configuration['db_glue']; // Use in all queries.
 
     $_course['titular'      ]         = $course_data['tutor_name'     ];
@@ -2957,7 +2957,7 @@ function api_is_anonymous($user_id = null, $db_check = false) {
 
     $_user = Session::read('_user');
 
-    if (!isset($_user) || $_user['user_id'] == 0) {
+    if (!isset($_user) || (isset($_user['user_id']) && $_user['user_id'] == 0)) {
         // In some cases, api_set_anonymous doesn't seem to be triggered in local.inc.php. Make sure it is.
         // Occurs in agenda for admin links - YW
         /*global $use_anonymous;
@@ -6683,6 +6683,7 @@ function api_get_user_language()
 
     if (!api_is_anonymous()) {
         $userInfo = api_get_user_info();
+        //var_dump($userInfo);exit;
         if (isset($userInfo['language'])) {
             $user_language = $userInfo['language'];
         }

+ 0 - 227
main/inc/lib/classmanager.lib.php

@@ -1,227 +0,0 @@
-<?php
-/* For licensing terms, see /license.txt */
-/**
-* This is the class library for this application.
-* @package	 chamilo.library
-*/
-/**
- * Code
- */
-class ClassManager
-{
-	/**
-	 * Get class information
-	 * note: This function can't be named get_class() because that's a standard
-	 * php-function.
-	 */
-	function get_class_info($class_id) {
-        $class_id = intval($class_id);
-		$table_class = Database :: get_main_table(TABLE_MAIN_CLASS);
-		$sql = "SELECT * FROM $table_class WHERE id='".$class_id."'";
-		$res = Database::query($sql);
-		return Database::fetch_array($res, 'ASSOC');
-	}
-	/**
-	 * Change the name of a class
-	 * @param string $name The new name
-	 * @param int $class_id The class id
-	 */
-	function set_name($name, $class_id) {
-        $class_id = intval($class_id);
-		$table_class = Database :: get_main_table(TABLE_MAIN_CLASS);
-		$sql = "UPDATE $table_class SET name='".Database::escape_string($name)."' WHERE id='".$class_id."'";
-		$res = Database::query($sql);
-	}
-	/**
-	 * Create a class
-	 * @param string $name
-	 */
-	function create_class($name) {
-		$table_class = Database :: get_main_table(TABLE_MAIN_CLASS);
-		$sql = "INSERT INTO $table_class SET name='".Database::escape_string($name)."'";
-		$result = Database::query($sql);
-		return Database::affected_rows($result) == 1;
-	}
-	/**
-	 * Check if a classname is allready in use
-	 * @param string $name
-	 */
-	function class_name_exists($name) {
-		$table_class = Database :: get_main_table(TABLE_MAIN_CLASS);
-		$sql = "SELECT * FROM $table_class WHERE name='".Database::escape_string($name)."'";
-		$res = Database::query($sql);
-		return Database::num_rows($res) != 0;
-	}
-	/**
-	 * Delete a class
-	 * @param int $class_id
-	 * @todo Add option to unsubscribe class-members from the courses where the
-	 * class was subscibed to
-	 */
-	function delete_class($class_id) {
-        $class_id = intval($class_id);
-		$table_class = Database :: get_main_table(TABLE_MAIN_CLASS);
-		$table_class_course = Database :: get_main_table(TABLE_MAIN_COURSE_CLASS);
-		$table_class_user = Database :: get_main_table(TABLE_MAIN_CLASS_USER);
-		$sql = "DELETE FROM $table_class_user WHERE class_id = '".$class_id."'";
-		Database::query($sql);
-		$sql = "DELETE FROM $table_class_course WHERE class_id = '".$class_id."'";
-		Database::query($sql);
-		$sql = "DELETE FROM $table_class WHERE id = '".$class_id."'";
-		Database::query($sql);
-	}
-	/**
-	 * Get all users from a class
-	 * @param int $class_id
-	 * @return array
-	 */
-	function get_users($class_id) {
-        $class_id = intval($class_id);
-		$table_class_user = Database :: get_main_table(TABLE_MAIN_CLASS_USER);
-		$table_user = Database :: get_main_table(TABLE_MAIN_USER);
-		$sql = "SELECT * FROM $table_class_user cu, $table_user u WHERE cu.class_id = '".$class_id."' AND cu.user_id = u.user_id";
-		$res = Database::query($sql);
-		$users = array ();
-		while ($user = Database::fetch_array($res, 'ASSOC')) {
-			$users[] = $user;
-		}
-		return $users;
-	}
-	/**
-	 * Add a user to a class. If the class is subscribed to a course, the new
-	 * user will also be subscribed to that course.
-	 * @param int $user_id The user id
-	 * @param int $class_id The class id
-	 */
-	function add_user($user_id, $class_id) {
-		$table_class_user = Database :: get_main_table(TABLE_MAIN_CLASS_USER);
-        $user_id  = intval($user_id);
-        $class_id = intval($class_id);
-		$sql = "INSERT IGNORE INTO $table_class_user SET user_id = '".$user_id."', class_id='".$class_id."'";
-		Database::query($sql);
-		$courses = ClassManager :: get_courses($class_id);
-		foreach ($courses as $index => $course) {
-			CourseManager :: subscribe_user($user_id, $course['course_code']);
-		}
-	}
-	/**
-	 * Unsubscribe a user from a class. If the class is also subscribed in a
-	 * course, the user will be unsubscribed from that course
-	 * @param int $user_id The user id
-	 * @param int $class_id The class id
-	 */
-	function unsubscribe_user($user_id, $class_id) {
-        $class_id = intval($class_id);
-        $user_id  = intval($user_id);
-
-		$table_class_user = Database :: get_main_table(TABLE_MAIN_CLASS_USER);
-		$table_course_class = Database :: get_main_table(TABLE_MAIN_COURSE_CLASS);
-		$courses = ClassManager :: get_courses($class_id);
-		if (count($courses) != 0) {
-			$course_codes = array ();
-			foreach ($courses as $index => $course) {
-				$course_codes[] = $course['course_code'];
-				$sql = "SELECT DISTINCT user_id FROM $table_class_user t1, $table_course_class t2 WHERE t1.class_id=t2.class_id AND course_code = '".$course['course_code']."' AND user_id = $user_id AND t2.class_id<>'$class_id'";
-				$res = Database::query($sql);
-				if (Database::num_rows($res) == 0 && CourseManager :: get_user_in_course_status($user_id, $course['course_code']) == STUDENT)
-				{
-					CourseManager :: unsubscribe_user($user_id, $course['course_code']);
-				}
-			}
-		}
-		$sql = "DELETE FROM $table_class_user WHERE user_id='".$user_id."' AND class_id = '".$class_id."'";
-		Database::query($sql);
-	}
-	/**
-	 * Get all courses in which a class is subscribed
-	 * @param int $class_id
-	 * @return array
-	 */
-	function get_courses($class_id) {
-        $class_id = intval($class_id);
-		$table_class_course = Database :: get_main_table(TABLE_MAIN_COURSE_CLASS);
-		$table_course = Database :: get_main_table(TABLE_MAIN_COURSE);
-		$sql = "SELECT * FROM $table_class_course cc, $table_course c WHERE cc.class_id = '".$class_id."' AND cc.course_code = c.code";
-		$res = Database::query($sql);
-		$courses = array ();
-		while ($course = Database::fetch_array($res, 'ASSOC')) {
-			$courses[] = $course;
-		}
-		return $courses;
-	}
-	/**
-	 * Subscribe all members of a class to a course
-	 * @param  int $class_id The class id
-	 * @param string $course_code The course code
-     * @deprecated
-	 */
-	function subscribe_to_course($class_id, $course_code) {
-		$tbl_course_class = Database :: get_main_table(TABLE_MAIN_COURSE_CLASS);
-		$tbl_class_user = Database :: get_main_table(TABLE_MAIN_CLASS_USER);
-		$sql = "INSERT IGNORE INTO $tbl_course_class SET course_code = '".Database::escape_string($course_code)."', class_id = '".Database::escape_string($class_id)."'";
-		Database::query($sql);
-		$sql = "SELECT user_id FROM $tbl_class_user WHERE class_id = '".Database::escape_string($class_id)."'";
-		$res = Database::query($sql);
-		while ($user = Database::fetch_object($res)) {
-			CourseManager :: subscribe_user($user->user_id, $course_code);
-		}
-	}
-	/**
-	 * Unsubscribe a class from a course.
-	 * Only students are unsubscribed. If a user is member of 2 classes which
-	 * are both subscribed to the course, the user stays in the course.
-	 * @param int $class_id The class id
-	 * @param string $course_code The course code
-	 */
-	function unsubscribe_from_course($class_id, $course_code)
-	{
-		$tbl_course_class = Database :: get_main_table(TABLE_MAIN_COURSE_CLASS);
-		$tbl_class_user = Database :: get_main_table(TABLE_MAIN_CLASS_USER);
-		$sql = "SELECT cu.user_id,COUNT(cc.class_id) FROM $tbl_course_class cc, $tbl_class_user cu WHERE  cc.class_id = cu.class_id AND cc.course_code = '".Database::escape_string($course_code)."' GROUP BY cu.user_id HAVING COUNT(cc.class_id) = 1";
-		$single_class_users = Database::query($sql);
-		while ($single_class_user = Database::fetch_object($single_class_users))
-		{
-			$sql = "SELECT * FROM $tbl_class_user WHERE class_id = '".Database::escape_string($class_id)."' AND user_id = '".Database::escape_string($single_class_user->user_id)."'";
-			$res = Database::query($sql);
-			if (Database::num_rows($res) > 0)
-			{
-				if (CourseManager :: get_user_in_course_status($single_class_user->user_id, $course_code) == STUDENT)
-				{
-					CourseManager :: unsubscribe_user($single_class_user->user_id, $course_code);
-				}
-			}
-		}
-		$sql = "DELETE FROM $tbl_course_class WHERE course_code = '".Database::escape_string($course_code)."' AND class_id = '".Database::escape_string($class_id)."'";
-		Database::query($sql);
-	}
-
-	/**
-	 * Get the class-id
-	 * @param string $name The class name
-	 * @return int the ID of the class
-	 */
-	function get_class_id($name) {
-        $name = Database::escape_string($name);
-		$table_class = Database :: get_main_table(TABLE_MAIN_CLASS);
-		$sql = "SELECT * FROM $table_class WHERE name='".$name."'";
-		$res = Database::query($sql);
-		$obj = Database::fetch_object($res);
-		return $obj->id;
-	}
-	/**
-	 * Get all classes subscribed in a course
-	 * @param string $course_code
-	 * @return array An array with all classes (keys: 'id','code','name')
-	 */
-	function get_classes_in_course($course_code) {
-		$table_class = Database :: get_main_table(TABLE_MAIN_CLASS);
-		$table_course_class = Database :: get_main_table(TABLE_MAIN_COURSE_CLASS);
-		$sql = "SELECT cl.* FROM $table_class cl, $table_course_class cc WHERE cc.course_code = '".Database::escape_string($course_code)."' AND cc.class_id = cl.id";
-		$res = Database::query($sql);
-		$classes = array ();
-		while ($class = Database::fetch_array($res, 'ASSOC')) {
-			$classes[] = $class;
-		}
-		return $classes;
-	}
-}

+ 16 - 16
main/inc/lib/course.lib.php

@@ -2917,9 +2917,8 @@ class CourseManager
      * @param null $maxPerPage
      * @return null|string
      */
-    static function displayCourses($user_id, $filter, $load_dirs, $getCount, $start = null, $maxPerPage = null)
+    public static function displayCourses($user_id, $filter, $load_dirs, $getCount, $start = null, $maxPerPage = null)
     {
-
         // Table definitions
         $TABLECOURS                     = Database :: get_main_table(TABLE_MAIN_COURSE);
         $TABLECOURSUSER                 = Database :: get_main_table(TABLE_MAIN_COURSE_USER);
@@ -2935,16 +2934,17 @@ class CourseManager
             //$without_special_courses = ' AND course.code NOT IN ("'.implode('","',$special_course_list).'")';
         }
 
-        $select = " SELECT DISTINCT course.id,
-                course.title,
-                course.code,
-                course.subscribe subscr,
-                course.unsubscribe unsubscr,
-                course_rel_user.status status,
-                course_rel_user.sort sort,
-                course_rel_user.user_course_cat user_course_cat,
-                course.id as real_id
-                ";
+        $select = " SELECT DISTINCT
+                    course.id,
+                    course.title,
+                    course.code,
+                    course.subscribe subscr,
+                    course.unsubscribe unsubscr,
+                    course_rel_user.status status,
+                    course_rel_user.sort sort,
+                    course_rel_user.user_course_cat user_course_cat,
+                    course.id as real_id
+        ";
 
         $from = "$TABLECOURS course, $TABLECOURSUSER  course_rel_user, $TABLE_ACCESS_URL_REL_COURSE url ";
 
@@ -2982,7 +2982,6 @@ class CourseManager
             $row = Database::fetch_array($result);
             return $row['total'];
         }
-
         $result = Database::query($sql);
 
         $html = null;
@@ -2991,7 +2990,6 @@ class CourseManager
         // Browse through all courses.
         while ($course = Database::fetch_array($result)) {
             $course_info = api_get_course_info($course['code']);
-            //$course['id_session'] = null;
             $course_info['id_session'] = null;
             $course_info['status'] = $course['status'];
 
@@ -3037,16 +3035,18 @@ class CourseManager
                 }
             }
 
-            $course_title = $course_info['title'];
+            //$course_title = $course_info['title'];
 
             $course_title_url = '';
             if ($course_info['visibility'] != COURSE_VISIBILITY_CLOSED || $course['status'] == COURSEMANAGER) {
-                $course_title_url = api_get_path(WEB_COURSE_PATH).$course_info['path'].'/index.php?id_session=0';
+                //$course_title_url = api_get_path(WEB_COURSE_PATH).$course_info['path'].'/index.php?id_session=0';
+                $course_title_url = api_get_path(WEB_COURSE_PATH).$course_info['code'].'/index.php?id_session=0';
                 $course_title = Display::url($course_info['title'], $course_title_url);
             } else {
                 $course_title = $course_info['title']." ".Display::tag('span',get_lang('CourseClosed'), array('class'=>'item_closed'));
             }
 
+
             // Start displaying the course block itself
             if (api_get_setting('display_coursecode_in_courselist') == 'true') {
                 $course_title .= ' ('.$course_info['visual_code'].') ';

+ 1 - 20
main/inc/lib/database.constants.inc.php

@@ -21,11 +21,8 @@ define('DB_COURSE_PREFIX', 'c_');
 // Main database tables
 define('TABLE_MAIN_COURSE',                 'course');
 define('TABLE_MAIN_USER',                   'user');
-define('TABLE_MAIN_CLASS',                  'class');
 define('TABLE_MAIN_ADMIN',                  'admin');
-define('TABLE_MAIN_COURSE_CLASS',           'course_rel_class');
 define('TABLE_MAIN_COURSE_USER',            'course_rel_user');
-define('TABLE_MAIN_CLASS_USER',             'class_user');
 define('TABLE_MAIN_CATEGORY',               'course_category');
 define('TABLE_MAIN_COURSE_MODULE',          'course_module');
 define('TABLE_MAIN_SYSTEM_ANNOUNCEMENTS',   'sys_announcement');
@@ -44,7 +41,6 @@ define('TABLE_MAIN_SHARED_SURVEY_QUESTION', 'shared_survey_question');
 define('TABLE_MAIN_SHARED_SURVEY_QUESTION_OPTION', 'shared_survey_question_option');
 define('TABLE_MAIN_TEMPLATES',              'templates');
 define('TABLE_MAIN_SYSTEM_TEMPLATE',        'system_template');
-define('TABLE_MAIN_OPENID_ASSOCIATION',     'openid_association');
 define('TABLE_MAIN_COURSE_REQUEST',         'course_request');
 
 // Gradebook
@@ -67,7 +63,6 @@ define('TABLE_MAIN_USER_FIELD_VALUES',  'user_field_values');
 define('TABLE_MAIN_TAG',                'tag');
 define('TABLE_MAIN_USER_REL_TAG',       'user_rel_tag');
 
-
 // Search engine
 define('TABLE_MAIN_SPECIFIC_FIELD',         'specific_field');
 define('TABLE_MAIN_SPECIFIC_FIELD_VALUES',  'specific_field_values');
@@ -82,13 +77,6 @@ define('TABLE_MAIN_ACCESS_URL_REL_SESSION', 'access_url_rel_session');
 // Global calendar
 define('TABLE_MAIN_SYSTEM_CALENDAR', 'sys_calendar');
 
-// Reservation System
-define('TABLE_MAIN_RESERVATION_ITEM',           'reservation_item');
-define('TABLE_MAIN_RESERVATION_RESERVATION',    'reservation_main');
-define('TABLE_MAIN_RESERVATION_SUBSCRIBTION',   'reservation_subscription');
-define('TABLE_MAIN_RESERVATION_CATEGORY',       'reservation_category');
-define('TABLE_MAIN_RESERVATION_ITEM_RIGHTS',    'reservation_item_rights');
-
 // Social networking
 define('TABLE_MAIN_USER_REL_USER', 'user_rel_user');
 define('TABLE_MAIN_USER_FRIEND_RELATION_TYPE', 'user_friend_relation_type');
@@ -109,7 +97,6 @@ define('TABLE_MAIN_QUESTION_FIELD',          'question_field');
 define('TABLE_MAIN_QUESTION_FIELD_OPTIONS',  'question_field_options');
 define('TABLE_MAIN_QUESTION_FIELD_VALUES',   'question_field_values');
 
-
 // Message
 define('TABLE_MAIN_MESSAGE', 'message');
 
@@ -212,7 +199,6 @@ define('TABLE_LP_ITEM_VIEW', 'lp_item_view');
 define('TABLE_LP_IV_INTERACTION', 'lp_iv_interaction'); // IV = Item View
 define('TABLE_LP_IV_OBJECTIVE', 'lp_iv_objective'); // IV = Item View
 
-// Smartblogs (Kevin Van Den Haute::kevin@develop-it.be)
 // Permission tables
 define('TABLE_PERMISSION_USER', 'permission_user');
 define('TABLE_PERMISSION_TASK', 'permission_task');
@@ -222,6 +208,7 @@ define('TABLE_ROLE', 'role');
 define('TABLE_ROLE_PERMISSION', 'role_permissions');
 define('TABLE_ROLE_USER', 'role_user');
 define('TABLE_ROLE_GROUP', 'role_group');
+
 // Blog tables
 define('TABLE_BLOGS', 'blog');
 define('TABLE_BLOGS_POSTS', 'blog_post');
@@ -232,11 +219,6 @@ define('TABLE_BLOGS_TASKS_REL_USER', 'blog_task_rel_user');
 define('TABLE_BLOGS_RATING', 'blog_rating');
 define('TABLE_BLOGS_ATTACHMENT', 'blog_attachment');
 define('TABLE_BLOGS_TASKS_PERMISSIONS', 'permission_task');
-//end of Smartblogs
-
-// User information tables
-define('TABLE_USER_INFO',           'userinfo_def');
-define('TABLE_USER_INFO_CONTENT',   'userinfo_content');
 
 // Course settings table
 define('TABLE_COURSE_SETTING', 'course_setting');
@@ -298,7 +280,6 @@ define('TABLE_THEMATIC_ADVANCE','thematic_advance');
 //User groups
 //Needed for migration
 define('TABLE_MAIN_GROUP',              'groups');
-
 /*
 define('TABLE_MAIN_USER_REL_GROUP',     'group_rel_user');
 define('TABLE_MAIN_GROUP_REL_TAG',      'group_rel_tag');

+ 0 - 1
main/inc/lib/events.lib.inc.php

@@ -13,7 +13,6 @@
  * @package chamilo.library
  */
 use Application\Sonata\UserBundle\Entity\User;
-use ChamiloLMS\CoreBundle\Entity\Role;
 
 class Event
 {