Alex Aragón 6 gadi atpakaļ
vecāks
revīzija
cb33b2e8e6
39 mainītis faili ar 376 papildinājumiem un 305 dzēšanām
  1. 1 1
      main/coursecopy/copy_course_session.php
  2. 1 1
      main/coursecopy/copy_course_session_selected.php
  3. 0 1
      main/document/create_audio.php
  4. 1 2
      main/document/create_document.php
  5. 1 0
      main/exercise/exercise_show.php
  6. 3 5
      main/exercise/hotspot.class.php
  7. 1 0
      main/exercise/hotspot_actionscript.as.php
  8. 2 3
      main/exercise/hotspot_actionscript_admin.as.php
  9. 1 0
      main/exercise/hotspot_answers.as.php
  10. 0 3
      main/exercise/question_list_admin.inc.php
  11. 1 1
      main/forum/viewthread.php
  12. 3 8
      main/inc/lib/api.lib.php
  13. 1 0
      main/inc/lib/course.lib.php
  14. 0 2
      main/inc/lib/exercise.lib.php
  15. 2 2
      main/inc/lib/extra_field.lib.php
  16. 1 1
      main/inc/lib/message.lib.php
  17. 72 87
      main/inc/lib/myspace.lib.php
  18. 1 0
      main/inc/lib/online.inc.php
  19. 1 2
      main/inc/lib/pdf.lib.php
  20. 12 13
      main/inc/lib/sessionmanager.lib.php
  21. 6 1
      main/inc/lib/social.lib.php
  22. 11 11
      main/inc/lib/sortable_table.class.php
  23. 2 1
      main/inc/lib/system_announcements.lib.php
  24. 11 7
      main/inc/lib/template.lib.php
  25. 2 2
      main/inc/lib/urlmanager.lib.php
  26. 1 0
      main/inc/lib/usermanager.lib.php
  27. 4 0
      main/lp/learnpath.class.php
  28. 12 71
      main/lp/lp_controller.php
  29. 9 11
      main/lp/lp_list.php
  30. 3 3
      main/mySpace/admin_view.php
  31. 10 10
      main/social/group_view.php
  32. 2 0
      main/social/personal_data.php
  33. 1 1
      main/template/default/learnpath/list.tpl
  34. 1 1
      main/tracking/exams.php
  35. 1 1
      main/upload/upload.document.php
  36. 135 0
      src/Chamilo/CoreBundle/Component/Editor/CkEditor/Toolbar/IntroductionSection.php
  37. 0 16
      src/Chamilo/ThemeBundle/Resources/views/Layout/base-layout.html.twig
  38. 47 29
      tests/behat/features/bootstrap/FeatureContext.php
  39. 13 8
      tests/behat/features/toolLp.feature

+ 1 - 1
main/coursecopy/copy_course_session.php

@@ -9,7 +9,7 @@ use ChamiloSession as Session;
 /**
  * Copy resources from one course in a session to another one.
  *
- * @author Christian Fasanando <christian.fasanando@dokeos.com>
+ * @author Christian Fasanando
  * @author Julio Montoya <gugli100@gmail.com> Lots of bug fixes/improvements
  *
  * @package chamilo.backup

+ 1 - 1
main/coursecopy/copy_course_session_selected.php

@@ -9,7 +9,7 @@ use ChamiloSession as Session;
 /**
  * Copy resources from one course in a session to another one.
  *
- * @author Christian Fasanando <christian.fasanando@dokeos.com>
+ * @author Christian Fasanando
  * @author Julio Montoya <gugli100@gmail.com> Lots of bug fixes/improvements
  * @author Angel Fernando Quiroz Campos <angel.quiroz@beeznest.com> Code conventions
  *

+ 0 - 1
main/document/create_audio.php

@@ -113,7 +113,6 @@ if (!($is_allowed_to_edit || $groupRights ||
     api_not_allowed(true);
 }
 
-/*	Header */
 Event::event_access_tool(TOOL_DOCUMENT);
 
 $display_dir = $dir;

+ 1 - 2
main/document/create_document.php

@@ -63,10 +63,9 @@ if (isset($_REQUEST['certificate']) && $_REQUEST['certificate'] == 'true') {
     $is_certificate_mode = true;
 }
 
+$nameTools = get_lang('CreateDocument');
 if ($is_certificate_mode) {
     $nameTools = get_lang('CreateCertificate');
-} else {
-    $nameTools = get_lang('CreateDocument');
 }
 
 /* Constants and variables */

+ 1 - 0
main/exercise/exercise_show.php

@@ -1210,3 +1210,4 @@ unset($questionList);
 
 Session::erase('exerciseResult');
 unset($exerciseResult);
+Session::erase('calculatedAnswerId');

+ 3 - 5
main/exercise/hotspot.class.php

@@ -77,17 +77,15 @@ class HotSpot extends Question
      */
     public function processCreation($form, $exercise)
     {
-        $file_info = $form->getSubmitValue('imageUpload');
+        $fileInfo = $form->getSubmitValue('imageUpload');
         parent::processCreation($form, $exercise);
 
-        if (!empty($file_info['tmp_name'])) {
-            $result = $this->uploadPicture($file_info['tmp_name']);
+        if (!empty($fileInfo['tmp_name'])) {
+            $result = $this->uploadPicture($fileInfo);
             if ($result) {
                 $this->save($exercise);
 
                 return true;
-            } else {
-                return false;
             }
         }
 

+ 1 - 0
main/exercise/hotspot_actionscript.as.php

@@ -18,6 +18,7 @@ require_once __DIR__.'/../inc/global.inc.php';
 
 api_protect_course_script(true);
 
+$_course = api_get_course_info();
 require api_get_path(LIBRARY_PATH).'geometry.lib.php';
 
 // set vars

+ 2 - 3
main/exercise/hotspot_actionscript_admin.as.php

@@ -21,10 +21,9 @@ if (!$isAllowedToEdit) {
     exit;
 }
 
-// set vars
-$questionId = intval($_GET['modifyAnswers']);
-$objQuestion = Question::read($questionId);
 $_course = api_get_course_info();
+$questionId = isset($_GET['modifyAnswers']) ? (int) $_GET['modifyAnswers'] : 0;
+$objQuestion = Question::read($questionId);
 $documentPath = api_get_path(SYS_COURSE_PATH).$_course['path'].'/document';
 $picturePath = $documentPath.'/images';
 $pictureName = $objQuestion->getPictureFilename();

+ 1 - 0
main/exercise/hotspot_answers.as.php

@@ -15,6 +15,7 @@ require_once __DIR__.'/../inc/global.inc.php';
 
 api_protect_course_script();
 
+$_course = api_get_course_info();
 $questionId = isset($_GET['modifyAnswers']) ? (int) $_GET['modifyAnswers'] : 0;
 $exerciseId = isset($_GET['exerciseId']) ? (int) $_GET['exerciseId'] : 0;
 $exeId = isset($_GET['exeId']) ? (int) $_GET['exeId'] : 0;

+ 0 - 3
main/exercise/question_list_admin.inc.php

@@ -151,9 +151,6 @@ $ajax_url = api_get_path(WEB_AJAX_PATH).'exercise.ajax.php?'.api_get_cidreq().'&
 //we filter the type of questions we can add
 Question::displayTypeMenu($objExercise);
 
-// Re sets the question list
-//$objExercise->setQuestionList();
-
 echo '<div id="message"></div>';
 $token = Security::get_token();
 //deletes a session when using don't know question type (ugly fix)

+ 1 - 1
main/forum/viewthread.php

@@ -634,7 +634,7 @@ foreach ($posts as $post) {
         'Aw:',
     ];
     $replace = '<span>'.Display::returnFontAwesomeIcon('mail-reply').'</span>';
-    $post['post_title'] = str_replace($search, $replace, $post['post_title']);
+    $post['post_title'] = str_replace($search, $replace, Security::remove_XSS($post['post_title']));
 
     // The post title
     $titlePost = Display::tag('h3', $post['post_title'], ['class' => 'forum_post_title']);

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

@@ -7553,8 +7553,6 @@ function api_user_is_login($user_id = null)
  */
 function api_get_real_ip()
 {
-    // Guess the IP if behind a reverse proxy
-    global $debug;
     $ip = trim($_SERVER['REMOTE_ADDR']);
     if (!empty($_SERVER['HTTP_X_FORWARDED_FOR'])) {
         if (preg_match('/,/', $_SERVER['HTTP_X_FORWARDED_FOR'])) {
@@ -7564,9 +7562,6 @@ function api_get_real_ip()
         }
         $ip = trim($ip1);
     }
-    if (!empty($debug)) {
-        error_log('Real IP: '.$ip);
-    }
 
     return $ip;
 }
@@ -8358,11 +8353,11 @@ function api_is_allowed_in_course()
  * Set the cookie to go directly to the course code $in_firstpage
  * after login.
  *
- * @param string $in_firstpage is the course code of the course to go
+ * @param string $value is the course code of the course to go
  */
-function api_set_firstpage_parameter($in_firstpage)
+function api_set_firstpage_parameter($value)
 {
-    setcookie('GotoCourse', $in_firstpage);
+    setcookie('GotoCourse', $value);
 }
 
 /**

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

@@ -4270,6 +4270,7 @@ class CourseManager
             if (Skill::isAllowed($user_id, false)) {
                 $em = Database::getManager();
                 $objUser = api_get_user_entity($user_id);
+                /** @var Course $objCourse */
                 $objCourse = $em->find('ChamiloCoreBundle:Course', $course['real_id']);
                 $objSession = $em->find('ChamiloCoreBundle:Session', $session_id);
 

+ 0 - 2
main/inc/lib/exercise.lib.php

@@ -3721,8 +3721,6 @@ EOT;
                 }
             }
             //We asumme that all exe_weighting
-            //$avg_score = show_score( $avg_score / count($user_results) , $result['exe_weighting']);
-            //$avg_score = ($avg_score / count($user_results));
             if (!empty($user_count)) {
                 $avg_score = float_format($avg_score / $user_count, 1) * 100;
             } else {

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

@@ -1977,7 +1977,7 @@ class ExtraField extends Model
         $header = get_lang('Add');
         $defaults = [];
 
-        if ($action == 'edit') {
+        if ($action === 'edit') {
             $header = get_lang('Modify');
             // Setting the defaults
             $defaults = $this->get($id, false);
@@ -1985,7 +1985,7 @@ class ExtraField extends Model
 
         $form->addElement('header', $header);
 
-        if ($action == 'edit') {
+        if ($action === 'edit') {
             $translateUrl = api_get_path(WEB_CODE_PATH).'extrafield/translate.php?'
                 .http_build_query(['extra_field' => $id]);
             $translateButton = Display::toolbarButton(get_lang('TranslateThisTerm'), $translateUrl, 'language', 'link');

+ 1 - 1
main/inc/lib/message.lib.php

@@ -470,7 +470,7 @@ class MessageManager
             return false;
         } elseif ($totalFileSize > intval(api_get_setting('message_max_upload_filesize'))) {
             $warning = sprintf(
-                get_lang("FilesSizeExceedsX"),
+                get_lang('FilesSizeExceedsX'),
                 format_file_size(api_get_setting('message_max_upload_filesize'))
             );
 

+ 72 - 87
main/inc/lib/myspace.lib.php

@@ -63,8 +63,8 @@ class MySpace
      */
     public static function getTopMenu()
     {
-        $menu_items = [];
-        $menu_items[] = Display::url(
+        $menuItems = [];
+        $menuItems[] = Display::url(
             Display::return_icon(
                 'statistics.png',
                 get_lang('MyStats'),
@@ -73,7 +73,7 @@ class MySpace
             ),
             api_get_path(WEB_CODE_PATH)."auth/my_progress.php"
         );
-        $menu_items[] = Display::url(
+        $menuItems[] = Display::url(
             Display::return_icon(
                 'teacher.png',
                 get_lang('TeacherInterface'),
@@ -82,7 +82,7 @@ class MySpace
             ),
             api_get_path(WEB_CODE_PATH).'mySpace/?view=teacher'
         );
-        $menu_items[] = Display::url(
+        $menuItems[] = Display::url(
             Display::return_icon(
                 'star_na.png',
                 get_lang('AdminInterface'),
@@ -91,12 +91,12 @@ class MySpace
             ),
             '#'
         );
-        $menu_items[] = Display::url(
+        $menuItems[] = Display::url(
             Display::return_icon('quiz.png', get_lang('ExamTracking'), [], 32),
             api_get_path(WEB_CODE_PATH).'tracking/exams.php'
         );
         $menu = '';
-        foreach ($menu_items as $item) {
+        foreach ($menuItems as $item) {
             $menu .= $item;
         }
         $menu .= '<br />';
@@ -207,13 +207,15 @@ class MySpace
         }
 
         // protect data
-        $user_id = intval($user_id);
-        $session_id = intval($session_id);
+        $user_id = (int) $user_id;
+        $session_id = (int) $session_id;
         $new_course_list = [];
         foreach ($course_list as $course_item) {
             $courseInfo = api_get_course_info($course_item['code']);
-            $courseId = $courseInfo['real_id'];
-            $new_course_list[] = '"'.$courseId.'"';
+            if ($courseInfo) {
+                $courseId = $courseInfo['real_id'];
+                $new_course_list[] = '"'.$courseId.'"';
+            }
         }
         $course_list = implode(', ', $new_course_list);
 
@@ -259,11 +261,13 @@ class MySpace
         // database table definition
         $tbl_course_user = Database::get_main_table(TABLE_MAIN_COURSE_USER);
 
+        $user_id = (int) $user_id;
+
         // getting all the courses of the user
         $sql = "SELECT * FROM $tbl_course_user
                 WHERE
-                    user_id = '".intval($user_id)."' AND
-                    relation_type<>".COURSE_RELATION_TYPE_RRHH." ";
+                    user_id = '".$user_id."' AND
+                    relation_type <> ".COURSE_RELATION_TYPE_RRHH;
         $result = Database::query($sql);
         while ($row = Database::fetch_array($result)) {
             $courseInfo = api_get_course_info_by_id($row['c_id']);
@@ -311,20 +315,24 @@ class MySpace
     /**
      * Creates a small table in the last column of the table with the user overview.
      *
-     * @param int   $user_id    the id of the user
+     * @param int $user_id the id of the user
      *
      * @return array List course
      */
-
     public static function returnCourseTracking($user_id)
     {
+        $user_id = (int) $user_id;
+
+        if (empty($user_id)) {
+            return [];
+        }
 
         $tbl_course_user = Database::get_main_table(TABLE_MAIN_COURSE_USER);
         // getting all the courses of the user
         $sql = "SELECT * FROM $tbl_course_user
                 WHERE
-                    user_id = '" . intval($user_id) . "' AND
-                    relation_type<>" . COURSE_RELATION_TYPE_RRHH . " ";
+                    user_id = $user_id AND
+                    relation_type <> ".COURSE_RELATION_TYPE_RRHH;
         $result = Database::query($sql);
 
         $list = [];
@@ -345,8 +353,13 @@ class MySpace
                 $avg_score = '-';
             }
 
-            // student exercises results (obtained score, maximum score, number of exercises answered, score percentage)
-            $exercises_results = self::exercises_results($user_id, $courseCode);
+            // Student exercises results (obtained score, maximum score, number of exercises answered, score percentage)
+            $exercisesResults = self::exercises_results($user_id, $courseCode);
+
+            $resultToString = '';
+            if (!is_null($exercisesResults['percentage'])) {
+                $resultToString = $exercisesResults['score_obtained'].'/'.$exercisesResults['score_possible'].' ( '.$exercisesResults['percentage'].'% )';
+            }
 
             $item = [
                 'code' => $courseInfo['code'],
@@ -360,9 +373,9 @@ class MySpace
                 'student_score' => $avg_score,
                 'student_message' => Tracking::count_student_messages($user_id, $courseCode),
                 'student_assignments' => Tracking::count_student_assignments($user_id, $courseCode),
-                'student_exercises' => (is_null($exercises_results['percentage']) ? '' : $exercises_results['score_obtained'] . '/' . $exercises_results['score_possible'] . ' ( ' . $exercises_results['percentage'] . '% )'),
-                'questions_answered' => $exercises_results['questions_answered'],
-                'last_connection' => Tracking::get_last_connection_date_on_the_course($user_id, $courseInfo)
+                'student_exercises' => $resultToString,
+                'questions_answered' => $exercisesResults['questions_answered'],
+                'last_connection' => Tracking::get_last_connection_date_on_the_course($user_id, $courseInfo),
             ];
             $list[] = $item;
         }
@@ -381,10 +394,8 @@ class MySpace
      *
      * @since April 2019
      */
-
     public static function returnTrackingUserOverviewFilter($user_id)
     {
-
         $tpl = new Template('', false, false, false, false, false, false);
         $userInfo = api_get_user_info($user_id);
 
@@ -395,7 +406,7 @@ class MySpace
             'complete_name' => $userInfo['complete_name'],
             'username' => $userInfo['username'],
             'course' => self::returnCourseTracking($user_id),
-            'avatar' => $avatar
+            'avatar' => $avatar,
         ];
 
         $tpl->assign('item', $user);
@@ -403,7 +414,6 @@ class MySpace
         $content = $tpl->fetch($templateName);
 
         return $content;
-
     }
 
     /**
@@ -421,7 +431,7 @@ class MySpace
     {
         self::display_user_overview_export_options();
 
-        $addparams = ['view' => 'admin', 'display' => 'user'];
+        $params = ['view' => 'admin', 'display' => 'user'];
         $table = new SortableTable(
             'tracking_user_overview',
             ['MySpace', 'get_number_of_users_tracking_overview'],
@@ -430,10 +440,10 @@ class MySpace
             20,
             'ASC',
             null, [
-                'class' => 'table table-transparent'
+                'class' => 'table table-transparent',
             ]
         );
-        $table->additional_parameters = $addparams;
+        $table->additional_parameters = $params;
 
         $table->set_column_filter(0, ['MySpace', 'returnTrackingUserOverviewFilter']);
         $tableContent = $table->return_table();
@@ -1043,14 +1053,14 @@ class MySpace
         $t_head .= '<th style="padding:0;border-bottom:0"><span>'.cut(get_lang('TotalExercisesAnswered'), 6, true).'</span></th>';
         $t_head .= '<th style="padding:0;border-bottom:0;border-right:0;"><span>'.get_lang('LatestLogin').'</span></th>';
         $t_head .= '</tr></table>';
-        $addparams = ['view' => 'admin', 'display' => 'courseoverview'];
+        $params = ['view' => 'admin', 'display' => 'courseoverview'];
         $table = new SortableTable(
             'tracking_session_overview',
             ['MySpace', 'get_total_number_courses'],
             ['MySpace', 'get_course_data_tracking_overview'],
             1
         );
-        $table->additional_parameters = $addparams;
+        $table->additional_parameters = $params;
 
         $table->set_header(0, '', false, null, ['style' => 'display: none']);
         $table->set_header(1, get_lang('Course'), true, ['style' => 'font-size:8pt'], ['style' => 'font-size:8pt']);
@@ -1461,14 +1471,14 @@ class MySpace
         $head .= '<th style="padding:0;border-bottom:0;border-right:0;"><span>'.get_lang('LatestLogin').'</span></th>';
         $head .= '</tr></table>';
 
-        $addparams = ['view' => 'admin', 'display' => 'sessionoverview'];
+        $params = ['view' => 'admin', 'display' => 'sessionoverview'];
         $table = new SortableTable(
             'tracking_session_overview',
             ['MySpace', 'get_total_number_sessions'],
             ['MySpace', 'get_session_data_tracking_overview'],
             1
         );
-        $table->additional_parameters = $addparams;
+        $table->additional_parameters = $params;
 
         $table->set_header(0, '', false, null, ['style' => 'display: none']);
         $table->set_header(
@@ -1690,21 +1700,19 @@ class MySpace
         $tbl_user = Database::get_main_table(TABLE_MAIN_USER);
 
         // the values of the sortable table
+        $from = 0;
         if ($_GET['tracking_session_overview_page_nr']) {
             $from = $_GET['tracking_session_overview_page_nr'];
-        } else {
-            $from = 0;
         }
+
+        $orderby = 0;
         if ($_GET['tracking_session_overview_column']) {
             $orderby = $_GET['tracking_session_overview_column'];
-        } else {
-            $orderby = 0;
         }
 
+        $direction = 'ASC';
         if ($_GET['tracking_session_overview_direction']) {
             $direction = $_GET['tracking_session_overview_direction'];
-        } else {
-            $direction = 'ASC';
         }
 
         $session_data = self::get_session_data_tracking_overview($from, 1000, $orderby, $direction);
@@ -1881,6 +1889,7 @@ class MySpace
      *
      * @param int    $user_id     the id of the user
      * @param string $course_code the course code
+     * @param int    $session_id
      *
      * @return array
      *
@@ -1890,15 +1899,20 @@ class MySpace
      *
      * @since November 2008
      */
-    public static function exercises_results($user_id, $course_code, $session_id = false)
+    public static function exercises_results($user_id, $course_code, $session_id = 0)
     {
+        $user_id = (int) $user_id;
         $courseId = api_get_course_int_id($course_code);
-        $sql = 'SELECT exe_result, exe_weighting
-                FROM '.Database::get_main_table(TABLE_STATISTIC_TRACK_E_EXERCISES)."
+        $table = Database::get_main_table(TABLE_STATISTIC_TRACK_E_EXERCISES);
+
+        $sql = "SELECT exe_result, exe_weighting
+                FROM $table
                 WHERE 
-                    c_id = ' . $courseId . ' AND 
-                    exe_user_id = '".intval($user_id)."'";
-        if ($session_id !== false) {
+                    c_id = $courseId AND 
+                    exe_user_id = $user_id";
+
+        $session_id = (int) $session_id;
+        if (!empty($session_id)) {
             $sql .= " AND session_id = '".$session_id."' ";
         }
         $result = Database::query($sql);
@@ -1911,10 +1925,9 @@ class MySpace
             $questions_answered++;
         }
 
+        $percentage = null;
         if ($score_possible != 0) {
             $percentage = round(($score_obtained / $score_possible * 100), 2);
-        } else {
-            $percentage = null;
         }
 
         return [
@@ -1980,8 +1993,8 @@ class MySpace
         }
         $csv_row[] = get_lang('LoginName');
         $csv_row[] = get_lang('CourseCode');
-        // the additional user defined fields (only those that were selected to be exported)
 
+        // the additional user defined fields (only those that were selected to be exported)
         $fields = UserManager::get_extra_fields(0, 50, 5, 'ASC');
 
         $additionalExportFields = Session::read('additional_export_fields');
@@ -2213,20 +2226,7 @@ class MySpace
         switch ($column) {
             case '0':
                 $column = $isWestern ? 'firstname' : 'lastname';
-                //$column = 'official_code';
-                break;
-            /*case '1':
-                $column = $isWestern ? 'firstname' : 'lastname';
-                break;
-            case '2':
-                $column = $isWestern ? 'lastname' : 'firstname';
-                break;
-            case '3':
-                $column = 'username';
                 break;
-            case '4':
-                $column = 'username';
-                break;*/
         }
 
         $order = [
@@ -2235,15 +2235,9 @@ class MySpace
         $userList = UserManager::get_user_list([], $order, $from, $numberItems);
         $return = [];
         foreach ($userList as $user) {
-            //$firstPosition = $user['lastname'];
-            //$secondPosition = $user['firstname'];
-            /*if ($isWestern) {
-                $firstPosition = $user['firstname'];
-                $secondPosition = $user['lastname'];
-            }*/
             $return[] = [
                 '0' => $user['user_id'],
-                'col0' => $user['user_id']
+                'col0' => $user['user_id'],
             ];
         }
 
@@ -2267,9 +2261,9 @@ class MySpace
     public static function get_user_overview_export_extra_fields($user_id)
     {
         // include the user manager
-        $extra_data = UserManager::get_extra_user_data($user_id, true);
+        $data = UserManager::get_extra_user_data($user_id, true);
 
-        return $extra_data;
+        return $data;
     }
 
     /**
@@ -2298,9 +2292,7 @@ class MySpace
                 }
                 $desired_username = UserManager::create_username(
                     $firstname,
-                    $lastname,
-                    $language,
-                    $encoding
+                    $lastname
                 );
                 if (UserManager::is_username_available($desired_username.$sufix)) {
                     break;
@@ -2360,10 +2352,10 @@ class MySpace
     {
         $table_user = Database::get_main_table(TABLE_MAIN_USER);
         $tbl_session_rel_course_rel_user = Database::get_main_table(TABLE_MAIN_SESSION_COURSE_USER);
-        $id_session = intval($id_session);
+        $id_session = (int) $id_session;
         $username = Database::escape_string($username);
         foreach ($course_list as $courseId) {
-            $courseId = intval($courseId);
+            $courseId = (int) $courseId;
             $sql = " SELECT u.user_id FROM $tbl_session_rel_course_rel_user rel
                      INNER JOIN $table_user u
                      ON (rel.user_id = u.user_id)
@@ -2452,9 +2444,8 @@ class MySpace
     public static function get_user_creator($users)
     {
         $errors = [];
+        $table_user = Database::get_main_table(TABLE_MAIN_USER);
         foreach ($users as $index => $user) {
-            // database table definition
-            $table_user = Database::get_main_table(TABLE_MAIN_USER);
             $username = Database::escape_string($user['UserName']);
             $sql = "SELECT creator_id FROM $table_user WHERE username='$username' ";
 
@@ -2568,24 +2559,20 @@ class MySpace
         $users = $new_users;
 
         // Inserting users.
-        $super_list = [];
         foreach ($course_list as $enreg_course) {
             $nbr_users = 0;
             $new_users = [];
             $enreg_course = Database::escape_string($enreg_course);
             foreach ($users as $index => $user) {
-                $userid = intval($user['id']);
+                $userid = (int) $user['id'];
                 $sql = "INSERT IGNORE INTO $tbl_session_rel_course_rel_user(session_id, c_id, user_id)
                         VALUES('$id_session','$enreg_course','$userid')";
-                $course_session = ['course' => $enreg_course, 'added' => 1];
-
                 $result = Database::query($sql);
                 if (Database::affected_rows($result)) {
                     $nbr_users++;
                 }
                 $new_users[] = $user;
             }
-            $super_list[] = $new_users;
 
             //update the nbr_users field
             $sql_select = "SELECT COUNT(user_id) as nbUsers FROM $tbl_session_rel_course_rel_user
@@ -2615,7 +2602,6 @@ class MySpace
         // Sending emails.
         $addedto = '';
         if ($sendMail) {
-            $i = 0;
             foreach ($users as $index => $user) {
                 $emailsubject = '['.api_get_setting('siteName').'] '.get_lang('YourReg').' '.api_get_setting('siteName');
                 $emailbody = get_lang('Dear').' '.
@@ -2655,7 +2641,6 @@ class MySpace
                 $registered_users .= UserManager::getUserProfileLink($userInfo).' - '.$addedto.'<br />';
             }
         } else {
-            $i = 0;
             foreach ($users as $index => $user) {
                 $userInfo = api_get_user_info($user['id']);
                 if (($user['added_at_platform'] == 1 && $user['added_at_session'] == 1) || $user['added_at_session'] == 1) {
@@ -3052,7 +3037,7 @@ class MySpace
         $user_id = (int) $user_id;
         $connections = [];
         if (!empty($course_info)) {
-            $courseId = intval($course_info['real_id']);
+            $courseId = (int) $course_info['real_id'];
             $end_date = add_day_to($end_date);
             $sessionCondition = api_get_session_condition($sessionId);
             $sql = "SELECT login_course_date, logout_course_date
@@ -3132,8 +3117,8 @@ function get_stats($user_id, $course_info, $sessionId, $start_date = null, $end_
 function add_day_to($end_date)
 {
     $foo_date = strtotime($end_date);
-    $foo_date = strtotime(" +1 day", $foo_date);
-    $foo_date = date("Y-m-d", $foo_date);
+    $foo_date = strtotime(' +1 day', $foo_date);
+    $foo_date = date('Y-m-d', $foo_date);
 
     return $foo_date;
 }
@@ -3155,7 +3140,7 @@ function convert_to_array($sql_result)
             api_time_to_hms($data['logout'] - $data['login']).'</tr></td>'."\n";
     }
     $result_to_print .= '</table>';
-    $result_to_print = ["result" => $result_to_print];
+    $result_to_print = ['result' => $result_to_print];
 
     return $result_to_print;
 }

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

@@ -173,6 +173,7 @@ function online_logout($user_id = null, $logout_redirect = false)
         }
     }
 
+    api_delete_firstpage_parameter();
     Session::erase('last_id');
     CourseChatUtils::exitChat($user_id);
     session_regenerate_id();

+ 1 - 2
main/inc/lib/pdf.lib.php

@@ -83,9 +83,8 @@ class PDF
      * Export the given HTML to PDF, using a global template.
      *
      * @uses \export/table_pdf.tpl
-
      *
-     * @param $content
+     * @param string     $content
      * @param bool|false $saveToFile
      * @param bool|false $returnHtml
      * @param bool       $addDefaultCss (bootstrap/default/base.css)

+ 12 - 13
main/inc/lib/sessionmanager.lib.php

@@ -103,9 +103,9 @@ class SessionManager
         ];
 
         foreach ($variables as $value) {
-            $result[$value."_to_local_time"] = null;
+            $result[$value.'_to_local_time'] = null;
             if (!empty($result[$value])) {
-                $result[$value."_to_local_time"] = api_get_local_time($result[$value]);
+                $result[$value.'_to_local_time'] = api_get_local_time($result[$value]);
             }
         }
 
@@ -182,8 +182,8 @@ class SessionManager
         }
 
         $name = Database::escape_string(trim($name));
-        $sessionCategoryId = intval($sessionCategoryId);
-        $visibility = intval($visibility);
+        $sessionCategoryId = (int) $sessionCategoryId;
+        $visibility = (int) $visibility;
         $tbl_session = Database::get_main_table(TABLE_MAIN_SESSION);
 
         $startDate = Database::escape_string($startDate);
@@ -238,7 +238,7 @@ class SessionManager
                     'session_admin_id' => $sessionAdminId,
                     'visibility' => $visibility,
                     'description' => $description,
-                    'show_description' => intval($showDescription),
+                    'show_description' => $showDescription,
                     'send_subscription_notification' => (int) $sendSubscriptionNotification,
                 ];
 
@@ -270,8 +270,7 @@ class SessionManager
                 }
 
                 $session_id = Database::insert($tbl_session, $values);
-
-                $duration = intval($duration);
+                $duration = (int) $duration;
 
                 if (!empty($duration)) {
                     $sql = "UPDATE $tbl_session SET
@@ -1551,9 +1550,9 @@ class SessionManager
         $sessionAdminId = 0,
         $sendSubscriptionNotification = false
     ) {
-        $coachId = intval($coachId);
-        $sessionCategoryId = intval($sessionCategoryId);
-        $visibility = intval($visibility);
+        $coachId = (int) $coachId;
+        $sessionCategoryId = (int) $sessionCategoryId;
+        $visibility = (int) $visibility;
         $tbl_session = Database::get_main_table(TABLE_MAIN_SESSION);
 
         if (empty($name)) {
@@ -3395,8 +3394,8 @@ class SessionManager
         // Definition of variables
         $userId = (int) $userId;
 
-        $sessionId = !empty($sessionId) ? intval($sessionId) : api_get_session_id();
-        $courseId = !empty($courseId) ? intval($courseId) : api_get_course_id();
+        $sessionId = !empty($sessionId) ? (int) $sessionId : api_get_session_id();
+        $courseId = !empty($courseId) ? (int) $courseId : api_get_course_id();
 
         if (empty($sessionId) || empty($courseId) || empty($userId)) {
             return false;
@@ -7753,7 +7752,7 @@ SQL;
         $form->addElement('html', '<div id="advanced_params_options" style="display:none">');
 
         if (empty($sessionId)) {
-            $sessions = SessionManager::formatSessionsAdminForGrid();
+            $sessions = self::formatSessionsAdminForGrid();
             $sessionList = [];
             $sessionList[] = '';
             foreach ($sessions as $session) {

+ 6 - 1
main/inc/lib/social.lib.php

@@ -409,12 +409,14 @@ class SocialManager extends UserManager
      * @author isaac flores paz
      *
      * @param int $userId
+     * @param int $limit
      *
      * @return array
      */
-    public static function get_list_invitation_of_friends_by_user_id($userId)
+    public static function get_list_invitation_of_friends_by_user_id($userId, $limit = 0)
     {
         $userId = (int) $userId;
+        $limit = (int) $limit;
 
         if (empty($userId)) {
             return [];
@@ -426,6 +428,9 @@ class SocialManager extends UserManager
                 WHERE
                     user_receiver_id = '.$userId.' AND
                     msg_status = '.MESSAGE_STATUS_INVITATION_PENDING;
+        if ($limit != null && $limit > 0) {
+            $sql .= ' LIMIT '.$limit;
+        }
         $res = Database::query($sql);
         $list = [];
         while ($row = Database::fetch_array($res, 'ASSOC')) {

+ 11 - 11
main/inc/lib/sortable_table.class.php

@@ -104,19 +104,19 @@ class SortableTable extends HTML_Table
     /**
      * Create a new SortableTable.
      *
-     * @param string $table_name A name for the table (default = 'table')
+     * @param string $table_name                A name for the table (default = 'table')
      * @param string $get_total_number_function A user defined function to get
      *                                          the total number of items in the table
-     * @param string $get_data_function A function to get the data to display on
+     * @param string $get_data_function         A function to get the data to display on
      *                                          the current page
-     * @param int $default_column The default column on which the data should be
+     * @param int    $default_column            The default column on which the data should be
      *                                          sorted
-     * @param int $default_items_per_page The default number of items to show
+     * @param int    $default_items_per_page    The default number of items to show
      *                                          on one page
-     * @param string $default_order_direction The default order direction;
+     * @param string $default_order_direction   The default order direction;
      *                                          either the constant 'ASC' or 'DESC'
      * @param string $table_id
-     * @param array $parameters         They are custom attributes of the table
+     * @param array  $parameters                They are custom attributes of the table
      */
     public function __construct(
         $table_name = 'table',
@@ -131,7 +131,7 @@ class SortableTable extends HTML_Table
         if (empty($table_id)) {
             $table_id = $table_name.uniqid();
         }
-        if(isset($parameters) && empty($parameters)){
+        if (isset($parameters) && empty($parameters)) {
             $parameters = ['class' => 'table table-bordered data_table', 'id' => $table_id];
         }
 
@@ -142,9 +142,9 @@ class SortableTable extends HTML_Table
         $this->param_prefix = $table_name.'_';
 
         $this->page_nr = Session::read($this->param_prefix.'page_nr', 1);
-        $this->page_nr = isset($_GET[$this->param_prefix.'page_nr']) ? intval($_GET[$this->param_prefix.'page_nr']) : $this->page_nr;
+        $this->page_nr = isset($_GET[$this->param_prefix.'page_nr']) ? (int) $_GET[$this->param_prefix.'page_nr'] : $this->page_nr;
         $this->column = Session::read($this->param_prefix.'column', $default_column);
-        $this->column = isset($_GET[$this->param_prefix.'column']) ? intval($_GET[$this->param_prefix.'column']) : $this->column;
+        $this->column = isset($_GET[$this->param_prefix.'column']) ? (int) $_GET[$this->param_prefix.'column'] : $this->column;
 
         $defaultRow = api_get_configuration_value('table_default_row');
         if (!empty($defaultRow)) {
@@ -174,9 +174,9 @@ class SortableTable extends HTML_Table
             if (!in_array($my_get_direction, ['ASC', 'DESC'])) {
                 $this->direction = 'ASC';
             } else {
-                if ($my_get_direction == 'ASC') {
+                if ($my_get_direction === 'ASC') {
                     $this->direction = 'ASC';
-                } elseif ($my_get_direction == 'DESC') {
+                } elseif ($my_get_direction === 'DESC') {
                     $this->direction = 'DESC';
                 }
             }

+ 2 - 1
main/inc/lib/system_announcements.lib.php

@@ -900,11 +900,12 @@ class SystemAnnouncementManager
         $selectedUserLanguage = Database::escape_string(api_get_interface_language());
         $announcementTable = Database::get_main_table(TABLE_MAIN_SYSTEM_ANNOUNCEMENTS);
         $now = api_get_utc_datetime();
+        $announcementId = (int) $announcementId;
 
         $whereConditions = [
             "(lang = ? OR lang IS NULL OR lang = '') " => $selectedUserLanguage,
             "AND (? >= date_start AND ? <= date_end) " => [$now, $now],
-            "AND id = ? " => intval($announcementId),
+            "AND id = ? " => $announcementId,
         ];
 
         $condition = self::getVisibilityCondition($visibility);

+ 11 - 7
main/inc/lib/template.lib.php

@@ -1304,13 +1304,17 @@ class Template
             if (!empty($courseInfo)) {
                 $courseParams = api_get_cidreq();
             }
-            $url = api_get_path(WEB_CODE_PATH).
-                'ticket/tickets.php?project_id='.$defaultProjectId.'&'.$courseParams;
-            $rightFloatMenu .= '<div class="help">
-                <a href="'.$url.'" target="_blank">
-                    '.$iconTicket.'
-                </a>
-            </div>';
+            $url = api_get_path(WEB_CODE_PATH).'ticket/tickets.php?project_id='.$defaultProjectId.'&'.$courseParams;
+
+            $allow = TicketManager::userIsAllowInProject(api_get_user_info(), $defaultProjectId);
+
+            if ($allow) {
+                $rightFloatMenu .= '<div class="help">
+                    <a href="'.$url.'" target="_blank">
+                        '.$iconTicket.'
+                    </a>
+                </div>';
+            }
         }
 
         $this->assign('bug_notification', $rightFloatMenu);

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

@@ -280,14 +280,14 @@ class UrlManager
      */
     public static function getCountUrlRelCourse($courseId)
     {
-        $courseId = intval($courseId);
+        $courseId = (int) $courseId;
         $tableUrlRelCourse = Database::get_main_table(TABLE_MAIN_ACCESS_URL_REL_COURSE);
         $sql = "SELECT *
                 FROM $tableUrlRelCourse
                 WHERE c_id = '$courseId'";
         $res = Database::query($sql);
 
-        return Database::num_rows($res);
+        return (int) Database::num_rows($res);
     }
 
     /**

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

@@ -683,6 +683,7 @@ class UserManager
      * @param int $user_id The user id
      *
      * @return bool true if user can be deleted
+     *
      * @assert (null) === false
      * @assert (-1) === false
      * @assert ('abc') === false

+ 4 - 0
main/lp/learnpath.class.php

@@ -12653,7 +12653,11 @@ EOD;
             $sql = "DELETE FROM $tbl_tool
                     WHERE c_id = ".$courseId." AND (link LIKE '$link%' AND image='lp_category.gif')";
             Database::query($sql);
+
+            return true;
         }
+
+        return false;
     }
 
     /**

+ 12 - 71
main/lp/lp_controller.php

@@ -18,11 +18,10 @@ use ChamiloSession as Session;
 $use_anonymous = true;
 $debug = 0;
 
-if ($debug) {
-    error_log('Entering lp_controller.php. Checking if LP exist in current session');
-}
-
 require_once __DIR__.'/../inc/global.inc.php';
+
+api_protect_course_script(true);
+
 $current_course_tool = TOOL_LEARNPATH;
 $_course = api_get_course_info();
 
@@ -56,18 +55,7 @@ $htmlHeadXtra[] = '
     /*
     Script to manipulate Learning Path items with Drag and drop
      */
-    var newOrderData = "";
-    var lptree_debug = "";  // for debug
-    var lp_id_list = "";    // for debug
-
-    // uncomment for some debug display utility
-    /*
-    $(function() {
-        buildLPtree_debug($("#lp_item_list"), 0, 0);
-        alert(lp_id_list+"\n\n"+lptree_debug);
-    });
-    */
-
+    var newOrderData = "";    
     function buildLPtree(in_elem, in_parent_id) {
         var item_tag = in_elem.get(0).tagName;
         var item_id =  in_elem.attr("id");
@@ -83,26 +71,6 @@ $htmlHeadXtra[] = '
         });
     }
 
-    // same than buildLPtree with some text display for debug in string lptree_debug
-    function buildLPtree_debug(in_elem, in_lvl, in_parent_id) {
-        var item_tag = in_elem.get(0).tagName;
-        var item_id =  in_elem.attr("id");
-        var parent_id = item_id;
-
-        if (item_tag == "LI" && item_id != undefined) {
-            for (i=0; i < 4 * in_lvl; i++) {
-                lptree_debug += " ";
-            }
-            lptree_debug += " Lvl="+(in_lvl - 1)/2+" ("+item_tag+" "+item_id+" Fils de="+in_parent_id+") \n";
-            // in_parent_id de la forme UL_x
-            lp_id_list += item_id+"|"+get_UL_integer_id(in_parent_id)+"^";
-        }
-
-        in_elem.children().each(function () {
-            buildLPtree_debug($(this), in_lvl + 1, parent_id);
-        });
-    }
-
     // return the interge part of an UL id
     // (0 for lp_item_list)
     function get_UL_integer_id(in_ul_id) {
@@ -185,7 +153,6 @@ $htmlHeadXtra[] = '
 </script>';
 
 $session_id = api_get_session_id();
-api_protect_course_script(true);
 
 $lpfound = false;
 $myrefresh = 0;
@@ -258,9 +225,6 @@ if (!$lp_found || (!empty($_REQUEST['lp_id']) && $_SESSION['oLP']->get_id() != $
     }
     // Regenerate a new lp object? Not always as some pages don't need the object (like upload?)
     if (!empty($_REQUEST['lp_id']) || !empty($myrefresh_id)) {
-        if ($debug > 0) {
-            error_log(' lp_id is defined');
-        }
         // Select the lp in the database and check which type it is (scorm/chamilo/aicc) to generate the
         // right object.
         if (!empty($_REQUEST['lp_id'])) {
@@ -298,32 +262,24 @@ if (!$lp_found || (!empty($_REQUEST['lp_id']) && $_SESSION['oLP']->get_id() != $
                         $oLP = new learnpath(api_get_course_id(), $lpIid, api_get_user_id());
                         if ($oLP !== false) {
                             $lp_found = true;
-                        } else {
-                            error_log($oLP->error);
                         }
                         break;
                     case 2:
                         $oLP = new scorm(api_get_course_id(), $lpIid, api_get_user_id());
                         if ($oLP !== false) {
                             $lp_found = true;
-                        } else {
-                            error_log($oLP->error);
                         }
                         break;
                     case 3:
                         $oLP = new aicc(api_get_course_id(), $lpIid, api_get_user_id());
                         if ($oLP !== false) {
                             $lp_found = true;
-                        } else {
-                            error_log($oLP->error);
                         }
                         break;
                     default:
                         $oLP = new learnpath(api_get_course_id(), $lpIid, api_get_user_id());
                         if ($oLP !== false) {
                             $lp_found = true;
-                        } else {
-                            error_log($oLP->error);
                         }
                         break;
                 }
@@ -344,34 +300,16 @@ if (!$lp_found || (!empty($_REQUEST['lp_id']) && $_SESSION['oLP']->get_id() != $
 }
 
 if ($debug > 0) {
-    error_log('Passed oLP creation check', 0);
+    error_log('Passed oLP creation check');
 }
 
 $is_allowed_to_edit = api_is_allowed_to_edit(false, true, false, false);
 
 if (isset($_SESSION['oLP'])) {
-    $_SESSION['oLP']->update_queue = [];
     // Reinitialises array used by javascript to update items in the TOC.
+    $_SESSION['oLP']->update_queue = [];
 }
 
-/*$studentView = api_is_student_view_active();
-if ($studentView) {
-    if (isset($_REQUEST['action']) && !in_array($_REQUEST['action'], ['list', 'view', 'view_category'])) {
-        if (!empty($_REQUEST['lp_id'])) {
-            $_REQUEST['action'] = 'view';
-        } elseif ($_REQUEST['action'] == 'view_category') {
-            $_REQUEST['action'] = 'view_category';
-        } else {
-            $_REQUEST['action'] = 'list';
-        }
-    }
-} else {
-    if ($is_allowed_to_edit) {
-        if (isset($_REQUEST['action']) && $_REQUEST['action'] == 'view' && !isset($_REQUEST['exeId'])) {
-            $_REQUEST['action'] = 'build';
-        }
-    }
-}*/
 
 $action = !empty($_REQUEST['action']) ? $_REQUEST['action'] : '';
 
@@ -660,8 +598,10 @@ switch ($action) {
             api_not_allowed(true);
         }
         if (isset($_REQUEST['id'])) {
-            learnpath::deleteCategory($_REQUEST['id']);
-            Display::addFlash(Display::return_message(get_lang('Deleted')));
+            $result = learnpath::deleteCategory($_REQUEST['id']);
+            if ($result) {
+                Display::addFlash(Display::return_message(get_lang('Deleted')));
+            }
         }
         require 'lp_list.php';
         break;
@@ -1197,7 +1137,8 @@ switch ($action) {
             exit;
         }
         break;
-    case 'add_sub_item': // Add an item inside a dir/chapter.
+    case 'add_sub_item':
+        // Add an item inside a dir/chapter.
         // @todo check if this is @deprecated
         if (!$is_allowed_to_edit) {
             api_not_allowed(true);

+ 9 - 11
main/lp/lp_list.php

@@ -16,11 +16,14 @@ use ChamiloSession as Session;
 $this_section = SECTION_COURSES;
 //@todo who turns on $lp_controller_touched?
 if (empty($lp_controller_touched) || $lp_controller_touched != 1) {
-    header('location: lp_controller.php?action=list');
+    header('Location: lp_controller.php?action=list&'.api_get_cidreq());
     exit;
 }
 
 require_once __DIR__.'/../inc/global.inc.php';
+
+api_protect_course_script();
+
 $courseDir = api_get_course_path().'/scorm';
 $baseWordDir = $courseDir;
 
@@ -28,8 +31,7 @@ $baseWordDir = $courseDir;
  * Display initialisation and security checks.
  */
 // Extra javascript functions for in html head:
-$htmlHeadXtra[]
-    = "<script>
+$htmlHeadXtra[] = "<script>
 function confirmation(name) {
     if (confirm(\" ".trim(get_lang('AreYouSureToDeleteJS'))." \"+name+\"?\")) {
         return true;
@@ -40,7 +42,6 @@ function confirmation(name) {
 </script>";
 $nameTools = get_lang('LearningPaths');
 Event::event_access_tool(TOOL_LEARNPATH);
-api_protect_course_script();
 
 /**
  * Display.
@@ -51,6 +52,8 @@ if (api_get_setting('search_enabled') === 'true') {
     search_widget_prepare($htmlHeadXtra);
 }
 $sessionId = api_get_session_id();
+$is_allowed_to_edit = api_is_allowed_to_edit(null, true);
+$courseInfo = api_get_course_info();
 
 $subscriptionSettings = learnpath::getSubscriptionSettings();
 
@@ -67,11 +70,8 @@ $introduction = Display::return_introduction_section(
     ]
 );
 
-$is_allowed_to_edit = api_is_allowed_to_edit(null, true);
-$courseInfo = api_get_course_info();
 $message = '';
 $actions = '';
-
 if ($is_allowed_to_edit) {
     $actionLeft = '';
     $actionLeft .= Display::url(
@@ -806,11 +806,9 @@ foreach ($categories as $item) {
                             'delete.png',
                             get_lang('LearnpathDeleteLearnpath')
                         ),
-                        'lp_controller.php?'.api_get_cidreq()
-                        ."&action=delete&lp_id=$id",
+                        'lp_controller.php?'.api_get_cidreq()."&action=delete&lp_id=$id",
                         [
-                            'onclick' => "javascript: return confirmation('"
-                                .addslashes($name)."');",
+                            'onclick' => "javascript: return confirmation('".addslashes($name)."');",
                         ]
                     );
                 } else {

+ 3 - 3
main/mySpace/admin_view.php

@@ -23,13 +23,13 @@ if (!$allowToTrack) {
 }
 
 if ($exportCSV) {
-    if ($display == 'user') {
+    if ($display === 'user') {
         MySpace::export_tracking_user_overview();
         exit;
-    } elseif ($display == 'session') {
+    } elseif ($display === 'session') {
         MySpace::export_tracking_session_overview();
         exit;
-    } elseif ($display == 'course') {
+    } elseif ($display === 'course') {
         MySpace::export_tracking_course_overview();
         exit;
     }

+ 10 - 10
main/social/group_view.php

@@ -109,9 +109,9 @@ $role = 0;
 $usergroup = new UserGroup();
 
 if ($group_id != 0) {
-    $group_info = $usergroup->get($group_id);
-    $group_info['name'] = Security::remove_XSS($group_info['name']);
-    $group_info['description'] = Security::remove_XSS($group_info['description']);
+    $groupInfo = $usergroup->get($group_id);
+    $groupInfo['name'] = Security::remove_XSS($groupInfo['name']);
+    $groupInfo['description'] = Security::remove_XSS($groupInfo['description']);
 
     $interbreadcrumb[] = ['url' => '#', 'name' => $group_info['name']];
 
@@ -119,7 +119,7 @@ if ($group_id != 0) {
         $user_leaved = intval($_GET['u']);
         // I can "leave me myself"
         if (api_get_user_id() == $user_leaved) {
-            if (UserGroup::canLeave($group_info)) {
+            if (UserGroup::canLeave($groupInfo)) {
                 $usergroup->delete_user_rel_group($user_leaved, $group_id);
                 Display::addFlash(
                     Display::return_message(get_lang('UserIsNotSubscribedToThisGroup'), 'confirmation', false)
@@ -133,7 +133,7 @@ if ($group_id != 0) {
         // we add a user only if is a open group
         $user_join = intval($_GET['u']);
         if (api_get_user_id() == $user_join && !empty($group_id)) {
-            if ($group_info['visibility'] == GROUP_PERMISSION_OPEN) {
+            if ($groupInfo['visibility'] == GROUP_PERMISSION_OPEN) {
                 $usergroup->add_user_to_group($user_join, $group_id);
                 Display::addFlash(
                     Display::return_message(get_lang('UserIsSubscribedToThisGroup'), 'confirmation', false)
@@ -155,9 +155,9 @@ $create_thread_link = '';
 $social_right_content = null;
 $socialForum = '';
 
-$group_info = $usergroup->get($group_id);
-$group_info['name'] = Security::remove_XSS($group_info['name']);
-$group_info['description'] = Security::remove_XSS($group_info['description']);
+$groupInfo = $usergroup->get($group_id);
+$groupInfo['name'] = Security::remove_XSS($groupInfo['name']);
+$groupInfo['description'] = Security::remove_XSS($groupInfo['description']);
 
 //Loading group information
 if (isset($_GET['status']) && $_GET['status'] == 'sent') {
@@ -167,13 +167,13 @@ if (isset($_GET['status']) && $_GET['status'] == 'sent') {
 $is_group_member = $usergroup->is_group_member($group_id);
 $role = $usergroup->get_user_group_role(api_get_user_id(), $group_id);
 
-if (!$is_group_member && $group_info['visibility'] == GROUP_PERMISSION_CLOSED) {
+if (!$is_group_member && $groupInfo['visibility'] == GROUP_PERMISSION_CLOSED) {
     if ($role == GROUP_USER_PERMISSION_PENDING_INVITATION_SENT_BY_USER) {
         $social_right_content .= Display::return_message(get_lang('YouAlreadySentAnInvitation'));
     }
 }
 
-if ($is_group_member || $group_info['visibility'] == GROUP_PERMISSION_OPEN) {
+if ($is_group_member || $groupInfo['visibility'] == GROUP_PERMISSION_OPEN) {
     if (!$is_group_member) {
         if (!in_array(
             $role,

+ 2 - 0
main/social/personal_data.php

@@ -10,6 +10,8 @@ $cidReset = true;
 
 require_once __DIR__.'/../inc/global.inc.php';
 
+api_set_more_memory_and_time_limits();
+
 api_block_anonymous_users();
 
 if (api_get_configuration_value('disable_gdpr')) {

+ 1 - 1
main/template/default/learnpath/list.tpl

@@ -22,7 +22,7 @@
                 {% if categories|length > 1 and lp_data.category.id %}
                     {% if is_allowed_to_edit %}
                         <h3 class="page-header">
-                            {{ lp_data.category.getName() }}
+                            {{ lp_data.category.getName() | trim }}
 
                             {% if lp_data.category.getId() > 0 %}
                                 {% if not _c.session_id %}

+ 1 - 1
main/tracking/exams.php

@@ -12,7 +12,7 @@ $toolTable = Database::get_course_table(TABLE_TOOL_LIST);
 $quizTable = Database::get_course_table(TABLE_QUIZ_TEST);
 
 $this_section = SECTION_TRACKING;
-$is_allowedToTrack = $is_courseAdmin || api_is_platform_admin(true) || $is_session_general_coach;
+$is_allowedToTrack = api_is_course_admin() || api_is_platform_admin(true) || $is_session_general_coach;
 
 if (!$is_allowedToTrack) {
     api_not_allowed(true);

+ 1 - 1
main/upload/upload.document.php

@@ -36,7 +36,7 @@ if (!DocumentManager::get_document_id($_course, $path)) {
 $nameTools = get_lang('UplUploadDocument');
 $interbreadcrumb[] = [
     "url" => api_get_path(WEB_CODE_PATH)."document/document.php?curdirpath=".urlencode($path).'&'.api_get_cidreq(),
-    "name" => $langDocuments,
+    "name" => get_lang('Documents'),
 ];
 Display::display_header($nameTools, "Doc");
 //show the title

+ 135 - 0
src/Chamilo/CoreBundle/Component/Editor/CkEditor/Toolbar/IntroductionSection.php

@@ -0,0 +1,135 @@
+<?php
+/* For licensing terms, see /license.txt */
+
+namespace Chamilo\CoreBundle\Component\Editor\CkEditor\Toolbar;
+
+/**
+ * Documents toolbar configuration.
+ *
+ * @package Chamilo\CoreBundle\Component\Editor\CkEditor\Toolbar
+ */
+class IntroductionSection extends Basic
+{
+    public $plugins = [];
+
+    /**
+     * Get the toolbar config.
+     *
+     * @return array
+     */
+    public function getConfig()
+    {
+        $config = [];
+
+        if (api_get_setting('more_buttons_maximized_mode') !== 'true') {
+            $config['toolbar'] = $this->getNormalToolbar();
+        } else {
+            $config['toolbar_minToolbar'] = $this->getMinimizedToolbar();
+        }
+
+        $config['extraPlugins'] = $this->getPluginsToString();
+        $config['fullPage'] = true;
+
+        return $config;
+    }
+
+    /**
+     * @return array
+     */
+    public function getConditionalPlugins()
+    {
+        $plugins = [];
+
+        if (api_get_setting('show_glossary_in_documents') === 'ismanual') {
+            $plugins[] = 'glossary';
+        }
+
+        return $plugins;
+    }
+
+    /**
+     * Get the default toolbar configuration when the setting more_buttons_maximized_mode is false.
+     *
+     * @return array
+     */
+    protected function getNormalToolbar()
+    {
+        return [
+            ['Maximize', 'PasteFromWord', '-', 'Undo', 'Redo'],
+            ['Link', 'Unlink', 'Anchor', 'inserthtml', 'Glossary'],
+            [
+                'Image',
+                'Video',
+                'Flash',
+                'Oembed',
+                'Youtube',
+                'Audio',
+                'Asciimath',
+                'Asciisvg',
+            ],
+            ['Table', 'SpecialChar'],
+            [
+                'Outdent',
+                'Indent',
+                '-',
+                'TextColor',
+                'BGColor',
+                '-',
+                'NumberedList',
+                'BulletedList',
+                '-',
+                api_get_configuration_value('translate_html') ? 'Language' : '',
+                api_get_setting('allow_spellcheck') === 'true' ? 'Scayt' : '',
+            ],
+            '/',
+            ['Styles', 'Format', 'Font', 'FontSize'],
+            ['Bold', 'Italic', 'Underline'],
+            ['JustifyLeft', 'JustifyCenter', 'JustifyRight'],
+            api_get_setting('enabled_wiris') === 'true' ? ['ckeditor_wiris_formulaEditor', 'ckeditor_wiris_CAS'] : [''],
+            ['Source'],
+        ];
+    }
+
+    /**
+     * Get the toolbar configuration when CKEditor is minimized.
+     *
+     * @return array
+     */
+    protected function getMinimizedToolbar()
+    {
+        return [
+            $this->getNewPageBlock(),
+            ['Undo', 'Redo'],
+            [
+                'Link',
+                'Image',
+                'Video',
+                'Flash',
+                'Youtube',
+                'Audio',
+                'Table',
+                'Asciimath',
+                'Asciisvg',
+            ],
+            ['BulletedList', 'NumberedList', 'HorizontalRule'],
+            ['JustifyLeft', 'JustifyCenter', 'JustifyBlock'],
+            ['Styles',
+                'Format',
+                'Font',
+                'FontSize',
+                'Bold',
+                'Italic',
+                'Underline',
+                'TextColor',
+                'BGColor',
+            ],
+            [
+                'Language',
+                'ShowBlocks',
+                'Source',
+            ],
+            api_get_setting('enabled_wiris') === 'true' ? ['ckeditor_wiris_formulaEditor', 'ckeditor_wiris_CAS'] : [''],
+            ['Toolbarswitch'],
+        ];
+    }
+}

+ 0 - 16
src/Chamilo/ThemeBundle/Resources/views/Layout/base-layout.html.twig

@@ -110,22 +110,6 @@
 {% block chamilo_wrap %}
 <div id="page-wrap">
     <!-- page section -->
-    {# Bug and help notifications #}
-    {#{% block help_notifications %}#}
-    {#<ul id="navigation" class="notification-panel">#}
-    {#{{ help_content }}#}
-    {#{{ bug_notification_link }}#}
-    {#</ul>#}
-    {#{% endblock %}#}
-
-    {# topbar #}
-    {% block topbar %}
-        {#{% include "@template_style/layout/topbar.html.twig" %}#}
-        {#{% if show_toolbar == 1 %}#}
-            {#<div class="clear-header"></div>#}
-        {#{% endif %}#}
-    {% endblock %}
-
     <header>
         <div class="extra-header">
             {{ header_extra_content }}

+ 47 - 29
tests/behat/features/bootstrap/FeatureContext.php

@@ -95,7 +95,7 @@ class FeatureContext extends MinkContext
     public function courseExists($argument)
     {
         $this->iAmAPlatformAdministrator();
-        $this->visit('/main/admin/course_list.php?keyword=' . $argument);
+        $this->visit('/main/admin/course_list.php?keyword='.$argument);
         $this->assertPageContainsText($argument);
     }
 
@@ -105,7 +105,7 @@ class FeatureContext extends MinkContext
     public function courseIsDeleted($argument)
     {
         $this->iAmAPlatformAdministrator();
-        $this->visit('/main/admin/course_list.php?keyword=' . $argument);
+        $this->visit('/main/admin/course_list.php?keyword='.$argument);
         $this->clickLink('Delete');
     }
 
@@ -142,10 +142,14 @@ class FeatureContext extends MinkContext
     {
         $this->visit('/index.php?logout=logout');
         $this->iAmOnHomepage();
-        $this->fillFields(new TableNode([
-            ['login', $username],
-            ['password', $username]
-        ]));
+        $this->fillFields(
+            new TableNode(
+                [
+                    ['login', $username],
+                    ['password', $username],
+                ]
+            )
+        );
         $this->pressButton('submitAuth');
     }
 
@@ -158,16 +162,22 @@ class FeatureContext extends MinkContext
         $friendId = $friendId;
         $friendUsername = $friendUsername;
 
-        $sendInvitationURL = '/main/inc/ajax/message.ajax.php?' . http_build_query([
-            'a' => 'send_invitation',
-            'user_id' => $friendId,
-            'content' => 'Add me'
-        ]);
-        $acceptInvitationURL = '/main/inc/ajax/social.ajax.php?' . http_build_query([
-            'a' => 'add_friend',
-            'friend_id' => $adminId,
-            'is_my_friend' => 'friend'
-        ]);
+        $sendInvitationURL = '/main/inc/ajax/message.ajax.php?'.
+            http_build_query(
+                [
+                    'a' => 'send_invitation',
+                    'user_id' => $friendId,
+                    'content' => 'Add me',
+                ]
+            );
+        $acceptInvitationURL = '/main/inc/ajax/social.ajax.php?'.
+            http_build_query(
+                [
+                    'a' => 'add_friend',
+                    'friend_id' => $adminId,
+                    'is_my_friend' => 'friend',
+                ]
+            );
 
         $this->iAmAPlatformAdministrator();
         $this->visit($sendInvitationURL);
@@ -182,13 +192,17 @@ class FeatureContext extends MinkContext
     public function iHaveAPublicPasswordProtectedCourse($code, $password)
     {
         $this->visit('/main/admin/course_add.php');
-        $this->fillFields(new TableNode([
-            ['title', 'Password Protected'],
-            ['visual_code', $code],
-            ['visibility', 3]
-        ]));
+        $this->fillFields(
+            new TableNode(
+                [
+                    ['title', 'Password Protected'],
+                    ['visual_code', $code],
+                    ['visibility', 3],
+                ]
+            )
+        );
         $this->pressButton('submit');
-        $this->visit('/main/course_info/infocours.php?cidReq=' . $code);
+        $this->visit('/main/course_info/infocours.php?cidReq='.$code);
         $this->assertPageContainsText('Course registration password');
         $this->fillField('course_registration_password', $password);
         $this->pressButton('submit_save');
@@ -209,7 +223,7 @@ class FeatureContext extends MinkContext
      */
     public function iInviteAFriendToASocialGroup($friendId, $groupId)
     {
-        $this->visit('/main/social/group_invitation.php?id=' . $groupId);
+        $this->visit('/main/social/group_invitation.php?id='.$groupId);
         $this->fillField('invitation[]', $friendId);
         $this->pressButton('submit');
     }
@@ -248,7 +262,7 @@ class FeatureContext extends MinkContext
      */
     public function iAmOnSocialGroupMembersPageWithId($groupId)
     {
-        $this->visit('/main/social/group_view.php?id=' . $groupId);
+        $this->visit('/main/social/group_view.php?id='.$groupId);
     }
 
     /**
@@ -256,11 +270,15 @@ class FeatureContext extends MinkContext
      */
     public function iTryDeleteAFriendFromSocialGroup($friendId, $groupId)
     {
-        $this->visit('/main/social/group_members.php?' . http_build_query([
-            'id' => $groupId,
-            'u' => $friendId,
-            'action' => 'delete'
-        ]));
+        $this->visit(
+            '/main/social/group_members.php?'.http_build_query(
+                [
+                    'id' => $groupId,
+                    'u' => $friendId,
+                    'action' => 'delete',
+                ]
+            )
+        );
     }
 
     /**

+ 13 - 8
tests/behat/features/toolLp.feature

@@ -49,13 +49,6 @@ Feature: LP tool
     And I should see "Document 1"
     And I should see "Exercise 1"
 
-  Scenario: Delete a LP category
-    Given I am on "/main/lp/lp_controller.php?cidReq=TEMP&action=list&isStudentView=false"
-    And wait for the page to be loaded
-    Then I should see "LP category 1"
-    And I follow "Delete"
-    Then I should not see "LP category 1"
-
 #  Scenario: Check the PDF export in LP list if hide SCORM PDF link is false
 #    Given I am on "/main/admin/settings.php?category=Course"
 #    And I check the "hide_scorm_pdf_link" radio button with "false" value
@@ -70,8 +63,20 @@ Feature: LP tool
 #    And I am on "/main/lp/lp_controller.php?cidReq=TEMP&action=list&isStudentView=true"
 #    Then I should not see an icon with title "Export to PDF"
 
+  Scenario: LP exists and LP category exists
+    Given I am on course "TEMP" homepage
+    And I am on "/main/lp/lp_controller.php?cidReq=TEMP"
+    Then I should see "LP 1"
+    And I should see "LP category 1"
+
   Scenario: Delete a LP
-    Given I am on "/main/lp/lp_controller.php?cidReq=TEMP&action=list"
+    Given I am on "/main/lp/lp_controller.php?cidReq=TEMP"
     And I follow "Delete"
     And I confirm the popup
     Then I should not see "LP 1"
+
+  Scenario: Delete a LP category
+    Given I am on "/main/lp/lp_controller.php?cidReq=TEMP"
+    Then I should see "LP category 1"
+    And I follow "Delete"
+    Then I should see "Deleted"