Procházet zdrojové kódy

Format code, remove comments

Julio Montoya před 9 roky
rodič
revize
80111b53fb
79 změnil soubory, kde provedl 1119 přidání a 1015 odebrání
  1. 0 2
      main/announcements/announcements.php
  2. 1 1
      main/announcements/download.php
  3. 1 1
      main/attendance/attendance_add.php
  4. 12 21
      main/attendance/attendance_controller.php
  5. 18 10
      main/attendance/attendance_edit.php
  6. 2 6
      main/attendance/attendance_list.php
  7. 13 32
      main/attendance/attendance_sheet.php
  8. 4 7
      main/attendance/index.php
  9. 10 19
      main/auth/cas/authcas.php
  10. 18 8
      main/auth/cas/cas_var.inc.php
  11. 8 3
      main/auth/cas/logincas.php
  12. 12 16
      main/auth/cas/logout.php
  13. 1 2
      main/auth/conditional_login/complete_phone_number.php
  14. 19 10
      main/auth/conditional_login/conditional_login.php
  15. 3 1
      main/auth/external_login/facebook.inc.php
  16. 4 1
      main/auth/external_login/login.ws.php
  17. 0 1
      main/auth/external_login/newUser.ldap.php
  18. 0 1
      main/auth/external_login/newUser.php
  19. 4 4
      main/auth/external_login/updateUser.php
  20. 6 3
      main/auth/gotocourse.php
  21. 2 1
      main/auth/ldap/authldap.php
  22. 1 1
      main/auth/ldap/ldap_var.inc.php
  23. 1 1
      main/auth/ldap/login.php
  24. 4 7
      main/auth/ldap/newUser.php
  25. 24 18
      main/auth/openid/login.php
  26. 2 2
      main/auth/openid/openid.lib.php
  27. 1 3
      main/auth/set_temp_password.php
  28. 1 1
      main/auth/sso/sso.Drupal.class.php
  29. 8 8
      main/auth/sso/sso.class.php
  30. 18 18
      main/auth/sso/sso_server_test.php
  31. 4 3
      main/auth/unsubscribe_account.php
  32. 76 76
      main/blog/blog_admin.php
  33. 6 1
      main/blog/download.php
  34. 1 1
      main/calendar/download.php
  35. 3 3
      main/course_description/course_description_controller.php
  36. 62 62
      main/course_home/2column.php
  37. 149 149
      main/course_home/3column.php
  38. 53 53
      main/course_home/vertical_activity.php
  39. 0 1
      main/course_info/download.php
  40. 0 3
      main/course_info/maintenance_coach.php
  41. 0 2
      main/course_info/start.php
  42. 18 3
      main/course_info/tools.php
  43. 0 3
      main/course_progress/thematic.php
  44. 20 3
      main/course_progress/thematic_plan.php
  45. 5 5
      main/coursecopy/copy_course.php
  46. 4 3
      main/dashboard/block.class.php
  47. 67 67
      main/dashboard/dashboard_controller.php
  48. 2 1
      main/dropbox/dropbox_functions.inc.php
  49. 1 1
      main/dropbox/dropbox_init.inc.php
  50. 0 2
      main/exercice/exercise.php
  51. 0 2
      main/exercice/exercise_admin.php
  52. 0 2
      main/exercice/question_pool.php
  53. 108 113
      main/forum/forumfunction.inc.php
  54. 0 1
      main/forum/forumsearch.php
  55. 8 5
      main/forum/iframe_thread.php
  56. 36 14
      main/forum/viewpost.php
  57. 1 1
      main/forum/viewthread_threaded.inc.php
  58. 8 1
      main/gradebook/gradebook_add_link.php
  59. 10 7
      main/gradebook/gradebook_showlog_eval.php
  60. 1 1
      main/gradebook/gradebook_statistics.php
  61. 0 2
      main/inc/email_editor.php
  62. 1 1
      main/inc/lib/api.lib.php
  63. 2 2
      main/inc/lib/auth.lib.php
  64. 26 16
      main/inc/lib/chat.lib.php
  65. 46 43
      main/inc/lib/course.lib.php
  66. 12 7
      main/inc/lib/course_category.lib.php
  67. 5 1
      main/inc/lib/course_description.lib.php
  68. 0 4
      main/inc/lib/course_home.lib.php
  69. 16 4
      main/inc/lib/course_request.lib.php
  70. 3 1
      main/inc/lib/custom_pages.class.php
  71. 0 1
      main/inc/lib/event_email_template.class.php
  72. 131 43
      main/inc/lib/fileDisplay.lib.php
  73. 9 9
      main/inc/lib/fileManage.lib.php
  74. 5 3
      main/inc/lib/grade_model.lib.php
  75. 7 5
      main/inc/lib/social.lib.php
  76. 0 1
      main/newscorm/lp_add.php
  77. 6 7
      main/reports/index.php
  78. 9 10
      main/reports/reports.php
  79. 0 57
      tests/main/forum/forumfunction.inc.test.php

+ 0 - 2
main/announcements/announcements.php

@@ -13,8 +13,6 @@
  * multiple functions
  * multiple functions
  */
  */
 
 
-// name of the language file that needs to be included
-
 // use anonymous mode when accessing this course tool
 // use anonymous mode when accessing this course tool
 $use_anonymous = true;
 $use_anonymous = true;
 
 

+ 1 - 1
main/announcements/download.php

@@ -69,7 +69,7 @@ if (Database::num_rows($result) > 0) {
     if (Security::check_abs_path($full_file_name,
     if (Security::check_abs_path($full_file_name,
         api_get_path(SYS_COURSE_PATH) . api_get_course_path() . '/upload/announcements/')
         api_get_path(SYS_COURSE_PATH) . api_get_course_path() . '/upload/announcements/')
     ) {
     ) {
-        DocumentManager::file_send_for_download($full_file_name,TRUE, $title);
+        DocumentManager::file_send_for_download($full_file_name, true, $title);
     }
     }
 }
 }
 exit;
 exit;

+ 1 - 1
main/attendance/attendance_add.php

@@ -28,7 +28,7 @@ $form = new FormValidator('attendance_add','POST','index.php?action=attendance_a
 $form->addElement('header', '', get_lang('CreateANewAttendance'));
 $form->addElement('header', '', get_lang('CreateANewAttendance'));
 $form->addElement('hidden', 'sec_token', $token);
 $form->addElement('hidden', 'sec_token', $token);
 
 
-$form->addText('title', get_lang('Title'), true, array('size'=>'50'));
+$form->addText('title', get_lang('Title'), true);
 $form->applyFilter('title','html_filter');
 $form->applyFilter('title','html_filter');
 $form->addHtmlEditor(
 $form->addHtmlEditor(
     'description',
     'description',

+ 12 - 21
main/attendance/attendance_controller.php

@@ -10,6 +10,7 @@
  *
  *
  * @author Christian Fasanando <christian1827@gmail.com>
  * @author Christian Fasanando <christian1827@gmail.com>
  * @author Julio Montoya <gugli100@gmail.com> lot of bugfixes + improvements
  * @author Julio Montoya <gugli100@gmail.com> lot of bugfixes + improvements
+ *
  * @package chamilo.attendance
  * @package chamilo.attendance
  */
  */
 class AttendanceController
 class AttendanceController
@@ -31,7 +32,6 @@ class AttendanceController
      */
      */
     public function attendance_list($history = false, $messages = array())
     public function attendance_list($history = false, $messages = array())
     {
     {
-        $attendance = new Attendance();
         $data = array();
         $data = array();
 
 
         // render to the view
         // render to the view
@@ -71,7 +71,6 @@ class AttendanceController
                 if (isset($_SESSION['gradebook'])) {
                 if (isset($_SESSION['gradebook'])) {
                     $param_gradebook = '&gradebook='.Security::remove_XSS($_SESSION['gradebook']);
                     $param_gradebook = '&gradebook='.Security::remove_XSS($_SESSION['gradebook']);
                 }
                 }
-                //header('location:index.php?action=attendance_sheet_list&attendance_id='.$last_id.'&'.api_get_cidreq().$param_gradebook);
                 header('location:index.php?action=calendar_add&attendance_id='.$last_id.'&'.api_get_cidreq().$param_gradebook);
                 header('location:index.php?action=calendar_add&attendance_id='.$last_id.'&'.api_get_cidreq().$param_gradebook);
                 exit;
                 exit;
             } else {
             } else {
@@ -117,14 +116,9 @@ class AttendanceController
                     ) {
                     ) {
                         $link_to_gradebook = true;
                         $link_to_gradebook = true;
                     }
                     }
-                    $last_id = $attendance->attendance_edit($attendance_id,$link_to_gradebook);
+                    $attendance->attendance_edit($attendance_id,$link_to_gradebook);
                     Security::clear_token();
                     Security::clear_token();
-
-                    $param_gradebook = '';
-                    if (isset($_SESSION['gradebook'])) {
-                        $param_gradebook = '&gradebook='.Security::remove_XSS($_SESSION['gradebook']);
-                    }
-                    header('location:index.php?action=attendance_list&'.api_get_cidreq().$param_gradebook);
+                    header('location:index.php?action=attendance_list&'.api_get_cidreq());
                     exit;
                     exit;
                 }
                 }
             } else {
             } else {
@@ -181,7 +175,7 @@ class AttendanceController
     /**
     /**
      * It's used for make attendance visible
      * It's used for make attendance visible
      * render to attendance_list view
      * render to attendance_list view
-     * @param int	attendance id
+     * @param int	$attendanceId
      */
      */
     public function attendanceSetVisible($attendanceId)
     public function attendanceSetVisible($attendanceId)
     {
     {
@@ -199,7 +193,7 @@ class AttendanceController
     /**
     /**
      * It's used for make attendance invisible
      * It's used for make attendance invisible
      * render to attendance_list view
      * render to attendance_list view
-     * @param int	attendance id
+     * @param int	$attendanceId
      */
      */
     public function attendanceSetInvisible($attendanceId)
     public function attendanceSetInvisible($attendanceId)
     {
     {
@@ -216,7 +210,7 @@ class AttendanceController
 
 
     /**
     /**
      * Restores an attendance entry and fallback to attendances rendering
      * Restores an attendance entry and fallback to attendances rendering
-     * @param int	attendance id
+     * @param int	$attendanceId
      */
      */
     public function attendance_restore($attendance_id)
     public function attendance_restore($attendance_id)
     {
     {
@@ -256,16 +250,15 @@ class AttendanceController
     public function export($id, $type = 'pdf')
     public function export($id, $type = 'pdf')
     {
     {
         $attendance = new Attendance();
         $attendance = new Attendance();
-        $attendance_id = intval($attendance_id);
     }
     }
 
 
     /**
     /**
      * It's used for controlling attendance sheet (list, add),
      * It's used for controlling attendance sheet (list, add),
      * render to attendance_sheet view
      * render to attendance_sheet view
      * @param string $action
      * @param string $action
-     * @param int  $attendance_id
-     * @param int  $student_id
-     * @param bool $edit
+     * @param int    $attendance_id
+     * @param int    $student_id
+     * @param bool   $edit
      */
      */
     public function attendance_sheet($action, $attendance_id, $student_id = 0, $edit = true)
     public function attendance_sheet($action, $attendance_id, $student_id = 0, $edit = true)
     {
     {
@@ -434,10 +427,10 @@ class AttendanceController
                 }
                 }
             }
             }
         } else if ($action == 'calendar_delete') {
         } else if ($action == 'calendar_delete') {
-            $affected_rows = $attendance->attendance_calendar_delete($calendar_id, $attendance_id);
+            $attendance->attendance_calendar_delete($calendar_id, $attendance_id);
             $action = 'calendar_list';
             $action = 'calendar_list';
         } else if ($action == 'calendar_all_delete') {
         } else if ($action == 'calendar_all_delete') {
-            $affected_rows = $attendance->attendance_calendar_delete(0, $attendance_id, true);
+            $attendance->attendance_calendar_delete(0, $attendance_id, true);
             $action = 'calendar_list';
             $action = 'calendar_list';
         }
         }
 
 
@@ -528,8 +521,6 @@ class AttendanceController
                 api_format_date($class_day['date_time'], TIME_NO_SEC_FORMAT);
                 api_format_date($class_day['date_time'], TIME_NO_SEC_FORMAT);
         }
         }
         $data_table[] = $head_table;
         $data_table[] = $head_table;
-        $dataClass = array();
-        $max_dates_per_page = 10;
         $data_attendant_calendar = $data_array['attendant_calendar'];
         $data_attendant_calendar = $data_array['attendant_calendar'];
         $data_users_presence = $data_array['users_presence'];
         $data_users_presence = $data_array['users_presence'];
         $count = 1;
         $count = 1;
@@ -647,7 +638,7 @@ class AttendanceController
                 $startDate = api_get_utc_datetime($values['range_start']);
                 $startDate = api_get_utc_datetime($values['range_start']);
                 $endDate = api_get_utc_datetime($values['range_end']);
                 $endDate = api_get_utc_datetime($values['range_end']);
             }
             }
-            $formToDisplay = $form->return_form();
+            $formToDisplay = $form->returnForm();
         } else {
         } else {
            if (!empty($sessionId)) {
            if (!empty($sessionId)) {
                $sessionInfo = api_get_session_info($sessionId);
                $sessionInfo = api_get_session_info($sessionId);

+ 18 - 10
main/attendance/attendance_edit.php

@@ -15,25 +15,34 @@ if (isset($error)) {
     Display::display_error_message(get_lang('FormHasErrorsPleaseComplete'),false);
     Display::display_error_message(get_lang('FormHasErrorsPleaseComplete'),false);
 }
 }
 
 
-$param_gradebook = '';
-if (isset($_SESSION['gradebook'])) {
-    $param_gradebook = '&gradebook='.Security::remove_XSS($_SESSION['gradebook']);
-}
-
 if (!isset($error)) {
 if (!isset($error)) {
     $token = Security::get_token();
     $token = Security::get_token();
 }
 }
 
 
 $attendance_weight = floatval($attendance_weight);
 $attendance_weight = floatval($attendance_weight);
 // display form
 // display form
-$form = new FormValidator('attendance_edit','POST','index.php?action=attendance_edit&'.api_get_cidreq().'&attendance_id='.$attendance_id.$param_gradebook);
+$form = new FormValidator(
+    'attendance_edit',
+    'POST',
+    'index.php?action=attendance_edit&'.api_get_cidreq().'&attendance_id='.$attendance_id
+);
 $form->addElement('header', '', get_lang('Edit'));
 $form->addElement('header', '', get_lang('Edit'));
-$form->addElement('hidden', 'sec_token',$token);
+$form->addElement('hidden', 'sec_token', $token);
 $form->addElement('hidden', 'attendance_id', $attendance_id);
 $form->addElement('hidden', 'attendance_id', $attendance_id);
 
 
-$form->addText('title', get_lang('Title'), true, array('size'=>'50'));
+$form->addText('title', get_lang('Title'), true);
 $form->applyFilter('title','html_filter');
 $form->applyFilter('title','html_filter');
-$form->addHtmlEditor('description', get_lang('Description'), false, false, array('ToolbarSet' => 'TrainingDescription', 'Width' => '100%', 'Height' => '200'));
+$form->addHtmlEditor(
+    'description',
+    get_lang('Description'),
+    false,
+    false,
+    array(
+        'ToolbarSet' => 'TrainingDescription',
+        'Width' => '100%',
+        'Height' => '200',
+    )
+);
 
 
 // Adavanced Parameters
 // Adavanced Parameters
 
 
@@ -55,7 +64,6 @@ if (Gradebook::is_active()) {
     $form->addElement('text', 'attendance_weight', get_lang('QualifyWeight'),'value="0.00" Style="width:40px" onfocus="javascript: this.select();"');
     $form->addElement('text', 'attendance_weight', get_lang('QualifyWeight'),'value="0.00" Style="width:40px" onfocus="javascript: this.select();"');
     $form->applyFilter('attendance_weight', 'html_filter');
     $form->applyFilter('attendance_weight', 'html_filter');
     $form->addElement('html','</div>');
     $form->addElement('html','</div>');
-
     $form->addElement('html','</div>');
     $form->addElement('html','</div>');
 }
 }
 $form->addButtonUpdate(get_lang('Save'));
 $form->addButtonUpdate(get_lang('Save'));

+ 2 - 6
main/attendance/attendance_list.php

@@ -11,12 +11,8 @@
 api_protect_course_script(true);
 api_protect_course_script(true);
 
 
 if (api_is_allowed_to_edit(null, true)) {
 if (api_is_allowed_to_edit(null, true)) {
-    $param_gradebook = '';
-    if (isset($_SESSION['gradebook'])) {
-        $param_gradebook = '&gradebook='.Security::remove_XSS($_SESSION['gradebook']);
-    }
     echo '<div class="actions">';
     echo '<div class="actions">';
-    echo '<a href="index.php?'.api_get_cidreq().$param_gradebook.'&action=attendance_add">'.
+    echo '<a href="index.php?'.api_get_cidreq().'&action=attendance_add">'.
         Display::return_icon('new_attendance_list.png', get_lang('CreateANewAttendance'),'',ICON_SIZE_MEDIUM).'</a>';
         Display::return_icon('new_attendance_list.png', get_lang('CreateANewAttendance'),'',ICON_SIZE_MEDIUM).'</a>';
     echo '</div>';
     echo '</div>';
 }
 }
@@ -36,7 +32,7 @@ $table = new SortableTable(
 );
 );
 $table->set_additional_parameters($parameters);
 $table->set_additional_parameters($parameters);
 $table->set_header(0, '', false, array('style'=>'width:20px;'));
 $table->set_header(0, '', false, array('style'=>'width:20px;'));
-$table->set_header(1, get_lang('Name'), true );
+$table->set_header(1, get_lang('Name'), true);
 $table->set_header(2, get_lang('Description'), true);
 $table->set_header(2, get_lang('Description'), true);
 $table->set_header(3, get_lang('CountDoneAttendance'), true, array('style'=>'width:90px;'));
 $table->set_header(3, get_lang('CountDoneAttendance'), true, array('style'=>'width:90px;'));
 
 

+ 13 - 32
main/attendance/attendance_sheet.php

@@ -20,33 +20,16 @@ if (api_is_allowed_to_edit(null, true) ||
     api_is_coach(api_get_session_id(), api_get_course_int_id()) ||
     api_is_coach(api_get_session_id(), api_get_course_int_id()) ||
     $isDrhOfCourse
     $isDrhOfCourse
 ) {
 ) {
-    $param_gradebook = '';
-    if (isset($_SESSION['gradebook'])) {
-        $param_gradebook = '&gradebook='.$_SESSION['gradebook'];
-    }
-
     $groupId = isset($_REQUEST['group_id']) ? intval($_REQUEST['group_id']) : null;
     $groupId = isset($_REQUEST['group_id']) ? intval($_REQUEST['group_id']) : null;
-
-    /* $form = new FormValidator(
-        'filter',
-        'post',
-        'index.php?action=attendance_sheet_list&' . api_get_cidreq() . $param_gradebook . '&attendance_id=' . $attendance_id,
-        null,
-        array(),
-        FormValidator::LAYOUT_INLINE
-    );
-    */
-     
-    
     $form = new FormValidator(
     $form = new FormValidator(
             'filter',
             'filter',
             'post',
             'post',
-            'index.php?action=attendance_sheet_list&' . api_get_cidreq() . $param_gradebook . '&attendance_id=' . $attendance_id,
+            'index.php?action=attendance_sheet_list&' . api_get_cidreq().'&attendance_id=' . $attendance_id,
             null,
             null,
             array(),
             array(),
             'inline'
             'inline'
         );
         );
-    
+
     $values = array(
     $values = array(
         'all' => get_lang('All'),
         'all' => get_lang('All'),
         'today' => get_lang('Today'),
         'today' => get_lang('Today'),
@@ -83,14 +66,14 @@ if (api_is_allowed_to_edit(null, true) ||
     if (!$exists_attendance_today) {
     if (!$exists_attendance_today) {
         Display::display_warning_message(get_lang('ThereIsNoClassScheduledTodayTryPickingAnotherDay'));
         Display::display_warning_message(get_lang('ThereIsNoClassScheduledTodayTryPickingAnotherDay'));
     }
     }
-    
+
     $form->addSelect(
     $form->addSelect(
-            'filter',
-            get_lang('Filter'),
-            $values,
-            ['id' => 'filter_id', 'onchange' => 'submit();']
+        'filter',
+        get_lang('Filter'),
+        $values,
+        ['id' => 'filter_id', 'onchange' => 'submit();']
     );
     );
-    
+
     //$form->addElement('select', 'filter', get_lang('Filter'), $values, array('id' => 'filter_id'));
     //$form->addElement('select', 'filter', get_lang('Filter'), $values, array('id' => 'filter_id'));
 
 
     $groupList = GroupManager::get_group_list(null, null, 1);
     $groupList = GroupManager::get_group_list(null, null, 1);
@@ -103,8 +86,6 @@ if (api_is_allowed_to_edit(null, true) ||
         $form->addSelect('group_id', get_lang('Group'), $groupIdList);
         $form->addSelect('group_id', get_lang('Group'), $groupIdList);
     }
     }
 
 
-    //$form->addButtonFilter(get_lang('Filter'));
-
     if (isset($_REQUEST['filter'])) {
     if (isset($_REQUEST['filter'])) {
         if (in_array($_REQUEST['filter'], array_keys($values))) {
         if (in_array($_REQUEST['filter'], array_keys($values))) {
             $default_filter = $_REQUEST['filter'];
             $default_filter = $_REQUEST['filter'];
@@ -124,7 +105,7 @@ if (api_is_allowed_to_edit(null, true) ||
     );
     );
 
 
     if (!$is_locked_attendance || api_is_platform_admin()) {
     if (!$is_locked_attendance || api_is_platform_admin()) {
-        
+
         $actionsLeft = '<a style="float:left;" href="index.php?'.api_get_cidreq().'&action=calendar_list&attendance_id='.$attendance_id.$param_gradebook.'">'.
         $actionsLeft = '<a style="float:left;" href="index.php?'.api_get_cidreq().'&action=calendar_list&attendance_id='.$attendance_id.$param_gradebook.'">'.
             Display::return_icon('attendance_calendar.png',get_lang('AttendanceCalendar'),'',ICON_SIZE_MEDIUM).'</a>';
             Display::return_icon('attendance_calendar.png',get_lang('AttendanceCalendar'),'',ICON_SIZE_MEDIUM).'</a>';
         $actionsLeft .= '<a id="pdf_export" style="float:left;"  href="index.php?'.api_get_cidreq().'&action=attendance_sheet_export_to_pdf&attendance_id='.$attendance_id.$param_gradebook.'&filter='.$default_filter.'&group_id='.$groupId.'">'.
         $actionsLeft .= '<a id="pdf_export" style="float:left;"  href="index.php?'.api_get_cidreq().'&action=attendance_sheet_export_to_pdf&attendance_id='.$attendance_id.$param_gradebook.'&filter='.$default_filter.'&group_id='.$groupId.'">'.
@@ -132,7 +113,7 @@ if (api_is_allowed_to_edit(null, true) ||
         //if (count($users_in_course) > 0) {
         //if (count($users_in_course) > 0) {
         $actionsRight = $form->returnForm();
         $actionsRight = $form->returnForm();
         //}
         //}
-        
+
         $toolbar = Display::toolbarAction('toolbar-attendance', array(0 => $actionsLeft, 1 => $actionsRight), 2 , false);
         $toolbar = Display::toolbarAction('toolbar-attendance', array(0 => $actionsLeft, 1 => $actionsRight), 2 , false);
         echo $toolbar;
         echo $toolbar;
     }
     }
@@ -371,7 +352,7 @@ if (api_is_allowed_to_edit(null, true) ||
 
 
                             echo '<td style="'.$style_td.'" class="checkboxes_col_'.$calendar['id'].'">';
                             echo '<td style="'.$style_td.'" class="checkboxes_col_'.$calendar['id'].'">';
                             echo '<div class="check">';
                             echo '<div class="check">';
-                           
+
                             if (api_is_allowed_to_edit(null, true)) {
                             if (api_is_allowed_to_edit(null, true)) {
                                 if (!$is_locked_attendance || api_is_platform_admin()) {
                                 if (!$is_locked_attendance || api_is_platform_admin()) {
                                     echo '<input type="checkbox" name="check_presence['.$calendar['id'].'][]" value="'.$user['user_id'].'" '.$disabled.' '.$checked.' />';
                                     echo '<input type="checkbox" name="check_presence['.$calendar['id'].'][]" value="'.$user['user_id'].'" '.$disabled.' '.$checked.' />';
@@ -392,7 +373,7 @@ if (api_is_allowed_to_edit(null, true) ||
                                         break;
                                         break;
                                 }
                                 }
                             }
                             }
-                            
+
                             echo '</div>';
                             echo '</div>';
                             echo '</td>';
                             echo '</td>';
                         }
                         }
@@ -413,7 +394,7 @@ if (api_is_allowed_to_edit(null, true) ||
                 echo '</tbody></table>';
                 echo '</tbody></table>';
                 echo '</div></div>';
                 echo '</div></div>';
                 ?>
                 ?>
-               
+
                 <div class="row">
                 <div class="row">
                     <div class="col-md-12">
                     <div class="col-md-12">
                 <?php if (!$is_locked_attendance || api_is_platform_admin()) {
                 <?php if (!$is_locked_attendance || api_is_platform_admin()) {

+ 4 - 7
main/attendance/index.php

@@ -176,10 +176,7 @@ if (!empty($_GET['gradebook']) && $_GET['gradebook'] == 'view') {
     unset($_SESSION['gradebook']);
     unset($_SESSION['gradebook']);
     $gradebook = '';
     $gradebook = '';
 }
 }
-$param_gradebook = '';
-if (isset($_SESSION['gradebook'])) {
-    $param_gradebook = '&gradebook='.$gradebook;
-}
+
 $student_param = '';
 $student_param = '';
 $student_id = null;
 $student_id = null;
 if (api_is_drh() && isset($_GET['student_id'])) {
 if (api_is_drh() && isset($_GET['student_id'])) {
@@ -194,7 +191,7 @@ if (api_is_drh() && isset($_GET['student_id'])) {
 if (!empty($gradebook)) {
 if (!empty($gradebook)) {
     $interbreadcrumb[] = array('url' => api_get_path(WEB_CODE_PATH).'gradebook/index.php', 'name' => get_lang('ToolGradebook'));
     $interbreadcrumb[] = array('url' => api_get_path(WEB_CODE_PATH).'gradebook/index.php', 'name' => get_lang('ToolGradebook'));
 }
 }
-$interbreadcrumb[] = array('url' => 'index.php?'.api_get_cidreq().'&action=attendance_list'.$param_gradebook.$student_param, 'name' => get_lang('ToolAttendance'));
+$interbreadcrumb[] = array('url' => 'index.php?'.api_get_cidreq().'&action=attendance_list&'.$student_param, 'name' => get_lang('ToolAttendance'));
 if ($action == 'attendance_add') {
 if ($action == 'attendance_add') {
     $interbreadcrumb[] = array('url' => '#', 'name' => get_lang('CreateANewAttendance'));
     $interbreadcrumb[] = array('url' => '#', 'name' => get_lang('CreateANewAttendance'));
 }
 }
@@ -205,11 +202,11 @@ if ($action == 'attendance_sheet_list' || $action == 'attendance_sheet_add') {
     $interbreadcrumb[] = array('url' => '#', 'name' => $attendance_data['name']);
     $interbreadcrumb[] = array('url' => '#', 'name' => $attendance_data['name']);
 }
 }
 if ($action == 'calendar_list' || $action == 'calendar_edit' || $action == 'calendar_delete' || $action == 'calendar_all_delete') {
 if ($action == 'calendar_list' || $action == 'calendar_edit' || $action == 'calendar_delete' || $action == 'calendar_all_delete') {
-    $interbreadcrumb[] = array('url' => 'index.php?'.api_get_cidreq().'&action=attendance_sheet_list&attendance_id='.$attendance_id.$param_gradebook, 'name' => $attendance_data['name']);
+    $interbreadcrumb[] = array('url' => 'index.php?'.api_get_cidreq().'&action=attendance_sheet_list&attendance_id='.$attendance_id, 'name' => $attendance_data['name']);
     $interbreadcrumb[] = array('url' => '#', 'name' => get_lang('AttendanceCalendar'));
     $interbreadcrumb[] = array('url' => '#', 'name' => get_lang('AttendanceCalendar'));
 }
 }
 if ($action == 'calendar_add') {
 if ($action == 'calendar_add') {
-    $interbreadcrumb[] = array('url' => 'index.php?'.api_get_cidreq().'&action=attendance_sheet_list&attendance_id='.$attendance_id.$param_gradebook, 'name' => $attendance_data['name']);
+    $interbreadcrumb[] = array('url' => 'index.php?'.api_get_cidreq().'&action=attendance_sheet_list&attendance_id='.$attendance_id, 'name' => $attendance_data['name']);
     $interbreadcrumb[] = array('url' => '#', 'name' => get_lang('AddDateAndTime'));
     $interbreadcrumb[] = array('url' => '#', 'name' => get_lang('AddDateAndTime'));
 }
 }
 
 

+ 10 - 19
main/auth/cas/authcas.php

@@ -5,11 +5,9 @@
 * Gets all the info via the ldap module (ldap has to work)
 * Gets all the info via the ldap module (ldap has to work)
 
 
 */
 */
-require_once(api_get_path(SYS_PATH).'main/auth/cas/cas_var.inc.php');
-require_once(api_get_path(SYS_PATH).'main/auth/external_login/ldap.inc.php');
-require_once(api_get_path(SYS_PATH).'main/auth/external_login/functions.inc.php');
-
-
+require_once api_get_path(SYS_PATH).'main/auth/cas/cas_var.inc.php';
+require_once api_get_path(SYS_PATH).'main/auth/external_login/ldap.inc.php';
+require_once api_get_path(SYS_PATH).'main/auth/external_login/functions.inc.php';
 
 
 /**
 /**
 * @return true if cas is configured
 * @return true if cas is configured
@@ -21,6 +19,7 @@ function cas_configured() {
     if (!empty($cas_auth_ver) && !empty($cas_auth_server) && !empty($cas_auth_port)) {
     if (!empty($cas_auth_ver) && !empty($cas_auth_server) && !empty($cas_auth_port)) {
         $res = true;
         $res = true;
     }
     }
+
     return $res;
     return $res;
 }
 }
 
 
@@ -41,9 +40,7 @@ function cas_is_authenticated()
         return;
         return;
     }
     }
 
 
-
-	if (!is_object($PHPCAS_CLIENT) )
-	{
+	if (!is_object($PHPCAS_CLIENT)) {
 		phpCAS::client($cas_auth_ver,$cas_auth_server,$cas_auth_port,$cas_auth_uri);
 		phpCAS::client($cas_auth_ver,$cas_auth_server,$cas_auth_port,$cas_auth_uri);
 		phpCAS::setNoCasServerValidation();
 		phpCAS::setNoCasServerValidation();
 	}
 	}
@@ -152,9 +149,7 @@ function cas_is_authenticated()
 //			}
 //			}
 //		}
 //		}
 		return $login;
 		return $login;
-	}
-	else
-	{
+    } else {
 		return false;
 		return false;
 	}
 	}
 }
 }
@@ -184,23 +179,19 @@ function cas_logout($uinfo=null, $location=null)
     phpCAS::logoutWithRedirectService($location);
     phpCAS::logoutWithRedirectService($location);
 }
 }
 
 
-
-
 /*
 /*
  * Return the direct URL to a course code with CAS login
  * Return the direct URL to a course code with CAS login
  */
  */
-function get_cas_direct_URL($in_course_code) {
+function get_cas_direct_URL($in_course_code)
+{
     return api_get_path(WEB_PATH).'main/auth/cas/logincas.php?firstpage='.$in_course_code;
     return api_get_path(WEB_PATH).'main/auth/cas/logincas.php?firstpage='.$in_course_code;
 }
 }
 
 
-
-function getCASLogoHTML() {
+function getCASLogoHTML()
+{
     $out_res = "";
     $out_res = "";
     if (api_get_setting("casLogoURL") != "") {
     if (api_get_setting("casLogoURL") != "") {
         $out_res = "<img src='".api_get_setting("casLogoURL")."' alt='CAS Logo' />";
         $out_res = "<img src='".api_get_setting("casLogoURL")."' alt='CAS Logo' />";
     }
     }
     return $out_res;
     return $out_res;
 }
 }
-
-
-?>

+ 18 - 8
main/auth/cas/cas_var.inc.php

@@ -1,21 +1,31 @@
 <?php
 <?php
+
 /* This file contains all the configuration variable for the cas module
 /* This file contains all the configuration variable for the cas module
  * In the future, these will be in the database
  * In the future, these will be in the database
 */
 */
-require_once('lib/CAS.php');
+require_once 'lib/CAS.php';
 
 
-global $cas_auth_ver, $cas_auth_server, $cas_auth_port, $cas_auth_uri; 
+global $cas_auth_ver, $cas_auth_server, $cas_auth_port, $cas_auth_uri;
 
 
 $cas_auth_server = api_get_setting('cas_server');
 $cas_auth_server = api_get_setting('cas_server');
 $cas_auth_uri = api_get_setting('cas_server_uri');
 $cas_auth_uri = api_get_setting('cas_server_uri');
 $cas_auth_port = intval(api_get_setting('cas_port'));
 $cas_auth_port = intval(api_get_setting('cas_port'));
 switch (api_get_setting('cas_protocol')) {
 switch (api_get_setting('cas_protocol')) {
-    case 'CAS1': $cas_auth_ver = CAS_VERSION_1_0; break;
-    case 'CAS2': $cas_auth_ver = CAS_VERSION_2_0; break;
-    case 'SAML': $cas_auth_ver = SAML_VERSION_1_1; break;
-    default : $cas_auth_ver = CAS_VERSION_2_0; break;
+    case 'CAS1':
+        $cas_auth_ver = CAS_VERSION_1_0;
+        break;
+    case 'CAS2':
+        $cas_auth_ver = CAS_VERSION_2_0;
+        break;
+    case 'SAML':
+        $cas_auth_ver = SAML_VERSION_1_1;
+        break;
+    default :
+        $cas_auth_ver = CAS_VERSION_2_0;
+        break;
 }
 }
 
 
 $cas_auth_uri = api_get_setting('cas_server_uri');
 $cas_auth_uri = api_get_setting('cas_server_uri');
-if ( ! is_string($cas_auth_uri)) $cas_auth_uri = ''; 
-?>
+if (!is_string($cas_auth_uri)) {
+    $cas_auth_uri = '';
+}

+ 8 - 3
main/auth/cas/logincas.php

@@ -25,8 +25,8 @@ We go to page api_not_allowed :
 > You are not allowed to see this page.
 > You are not allowed to see this page.
 > Sorry, you are not allowed to access this page, or maybe your connection has expired.
 > Sorry, you are not allowed to access this page, or maybe your connection has expired.
 > Please click your browser's \"Back\" button or follow the link below to return to the previous page
 > Please click your browser's \"Back\" button or follow the link below to return to the previous page
-If we click on the link to go to homepage, some datas are entered in $_SESSION and if we enter our CAS loggin, we go to api_not_allowad_page again
-and again
+If we click on the link to go to homepage, some datas are entered in $_SESSION and if we enter our CAS login,
+we go to api_not_allowad_page again and again
 As a result, if we are not logged on, we have to destroy the session variables, before calling CAS page
 As a result, if we are not logged on, we have to destroy the session variables, before calling CAS page
 */
 */
 if (api_is_anonymous()) {
 if (api_is_anonymous()) {
@@ -40,7 +40,12 @@ if (cas_configured()) {
         setcookie("GotoCourse", $firstpage);
         setcookie("GotoCourse", $firstpage);
     }
     }
     if (!is_object($PHPCAS_CLIENT) ) {
     if (!is_object($PHPCAS_CLIENT) ) {
-        phpCAS::client($cas_auth_ver,$cas_auth_server,$cas_auth_port,$cas_auth_uri);
+        phpCAS::client(
+            $cas_auth_ver,
+            $cas_auth_server,
+            $cas_auth_port,
+            $cas_auth_uri
+        );
         phpCAS::setNoCasServerValidation();
         phpCAS::setNoCasServerValidation();
     }
     }
     phpCAS::forceAuthentication();
     phpCAS::forceAuthentication();

+ 12 - 16
main/auth/cas/logout.php

@@ -1,17 +1,13 @@
 <?php
 <?php
-    /* For licensing terms, see /license.txt */
-    /*
-    Call this file to disconnect from CAS session.
-    logoutWithUrl() not used because with CAS v3 you cannot redirect your logout to a specific URL
-    because of security reason.
-    */
-    require('../..//inc/global.inc.php');
-    require_once('authcas.php');
-
-
-    global $cas_auth_ver, $cas_auth_server, $cas_auth_port, $cas_auth_uri;
-
-	phpCAS::client($cas_auth_ver,$cas_auth_server,$cas_auth_port,$cas_auth_uri);
-    phpCAS::logout();
-
-?>
+/* For licensing terms, see /license.txt */
+/*
+Call this file to disconnect from CAS session.
+logoutWithUrl() not used because with CAS v3 you cannot redirect your logout to a specific URL
+because of security reason.
+*/
+require '../..//inc/global.inc.php';
+require_once('authcas.php');
+global $cas_auth_ver, $cas_auth_server, $cas_auth_port, $cas_auth_uri;
+
+phpCAS::client($cas_auth_ver,$cas_auth_server,$cas_auth_port,$cas_auth_uri);
+phpCAS::logout();

+ 1 - 2
main/auth/conditional_login/complete_phone_number.php

@@ -45,7 +45,6 @@ if (isset($_POST['submit'])){
         ''
         ''
     );
     );
     if ($updated) {
     if ($updated) {
-    ConditionalLogin::login();
+        ConditionalLogin::login();
     }
     }
 }
 }
-?>

+ 19 - 10
main/auth/conditional_login/conditional_login.php

@@ -16,17 +16,21 @@
 $login_conditions = array();
 $login_conditions = array();
 
 
 //"Term and conditions" condition
 //"Term and conditions" condition
-array_push($login_conditions, array(
-    'conditional_function'    => 'check_platform_legal_conditions',
-    'url'                     => api_get_path(WEB_CODE_PATH).'auth/inscription.php'
-));
+array_push(
+    $login_conditions,
+    array(
+        'conditional_function' => 'check_platform_legal_conditions',
+        'url' => api_get_path(WEB_CODE_PATH).'auth/inscription.php',
+    )
+);
 
 
 //array_push($login_conditions, array(
 //array_push($login_conditions, array(
 //  'conditional_function' => 'dc_check_phone_number',
 //  'conditional_function' => 'dc_check_phone_number',
 //  'url' => api_get_path(WEB_PATH).'main/auth/conditional_login/complete_phone_number.php'
 //  'url' => api_get_path(WEB_PATH).'main/auth/conditional_login/complete_phone_number.php'
 //));
 //));
 
 
-function dc_check_phone_number($user){
+function dc_check_phone_number($user)
+{
     $uInfo = api_get_user_info($user['user_id']);
     $uInfo = api_get_user_info($user['user_id']);
     if (empty($uInfo['phone'])) {
     if (empty($uInfo['phone'])) {
         return false;
         return false;
@@ -41,22 +45,27 @@ function dc_check_phone_number($user){
  * @param array $user
  * @param array $user
  * @return boolean true if user pass, false otherwise
  * @return boolean true if user pass, false otherwise
  */
  */
-function check_platform_legal_conditions($user) {
+function check_platform_legal_conditions($user)
+{
     if (api_get_setting('allow_terms_conditions') == 'true') {
     if (api_get_setting('allow_terms_conditions') == 'true') {
         $term_and_condition_status = api_check_term_condition($user['user_id']);
         $term_and_condition_status = api_check_term_condition($user['user_id']);
         // @todo not sure why we need the login password and update_term_status
         // @todo not sure why we need the login password and update_term_status
         if ($term_and_condition_status == false) {
         if ($term_and_condition_status == false) {
-            $_SESSION['term_and_condition'] = array('user_id'           => $user['user_id'],
-                                                    //'login'             => $user['username'],
-                                                    //'password'          => $user['password'],
-                                                    //'update_term_status' => true,
+            $_SESSION['term_and_condition'] = array(
+                'user_id' => $user['user_id'],
+                //'login'             => $user['username'],
+                //'password'          => $user['password'],
+                //'update_term_status' => true,
             );
             );
+
             return false;
             return false;
         } else {
         } else {
             unset($_SESSION['term_and_condition']);
             unset($_SESSION['term_and_condition']);
+
             return true;
             return true;
         }
         }
     } else {
     } else {
+
         //No validation user can pass
         //No validation user can pass
         return true;
         return true;
     }
     }

+ 3 - 1
main/auth/external_login/facebook.inc.php

@@ -120,6 +120,7 @@ function facebookGetLoginUrl()
     $loginUrl =   $helper->getLoginUrl(
     $loginUrl =   $helper->getLoginUrl(
         array('scope' => 'email')
         array('scope' => 'email')
     );
     );
+
     return $loginUrl;
     return $loginUrl;
 }
 }
 
 
@@ -151,6 +152,7 @@ function facebookPluginGetLanguage($language = 'en_US')
         $result = Database::fetch_array($sqlResult);
         $result = Database::fetch_array($sqlResult);
         return $result['english_name'];
         return $result['english_name'];
     }
     }
+
     return false;
     return false;
-} 
+}
 
 

+ 4 - 1
main/auth/external_login/login.ws.php

@@ -1,4 +1,6 @@
-<?php /* For licensing terms, see /license.txt */
+<?php
+/* For licensing terms, see /license.txt */
+
 // External login module : WS (for Web Services)
 // External login module : WS (for Web Services)
 /**
 /**
  *
  *
@@ -92,6 +94,7 @@ function loginWSAuthenticate($username, $password, $wsUrl) {
         }
         }
         return 0;
         return 0;
     }
     }
+
     return $response->validateUserResult;
     return $response->validateUserResult;
 }
 }
 
 

+ 0 - 1
main/auth/external_login/newUser.ldap.php

@@ -62,7 +62,6 @@ if ($ldap_user !== false) {
         }
         }
         Event::event_login($chamilo_uid);
         Event::event_login($chamilo_uid);
     }
     }
-
 } else {
 } else {
     $loginFailed = true;
     $loginFailed = true;
     $uidReset = false;
     $uidReset = false;

+ 0 - 1
main/auth/external_login/newUser.php

@@ -52,4 +52,3 @@ if ($user !== false && ($chamilo_uid = external_add_user($user)) !== false) {
     unset($_user['user_id']);
     unset($_user['user_id']);
     $uidReset = false;
     $uidReset = false;
 }
 }
-?>

+ 4 - 4
main/auth/external_login/updateUser.php

@@ -2,8 +2,8 @@
 
 
 //Script loaded by local.inc.php providing update user information of type external_logininfo.
 //Script loaded by local.inc.php providing update user information of type external_logininfo.
 /*
 /*
-  This script must not exit.
- */
+This script must not exit.
+*/
 
 
 use ChamiloSession as Session;
 use ChamiloSession as Session;
 
 
@@ -32,10 +32,10 @@ if ($new_user !== false) { //User can login
     $_user['uidReset'] = true;
     $_user['uidReset'] = true;
     $uidReset = true;
     $uidReset = true;
     Session::write('_user', $_user);
     Session::write('_user', $_user);
-} else { //User cannot login
+} else {
+    //User cannot login
     $loginFailed = true;
     $loginFailed = true;
     Session::erase('_uid');
     Session::erase('_uid');
     header('Location: ' . api_get_path(WEB_PATH) . 'index.php?loginFailed=1&error=user_password_incorrect');
     header('Location: ' . api_get_path(WEB_PATH) . 'index.php?loginFailed=1&error=user_password_incorrect');
     exit;
     exit;
 }
 }
-?>

+ 6 - 3
main/auth/gotocourse.php

@@ -1,8 +1,10 @@
 <?php
 <?php
+/* For licensing terms, see /license.txt */
+
 /**
 /**
- * For licensing terms, see /license.txt
  *
  *
- * Allow the user to login to a course after reaching a course URL (e.g. http://chamilo.chamilo.org/courses/MYCOURSE/?id_session=0 )
+ * Allow the user to login to a course after reaching a course URL
+ * (e.g. http://chamilo.chamilo.org/courses/MYCOURSE/?id_session=0 )
  * See https://support.chamilo.org/issues/6768
  * See https://support.chamilo.org/issues/6768
  *
  *
  * Author : hubert.borderiou@grenet.fr
  * Author : hubert.borderiou@grenet.fr
@@ -50,5 +52,6 @@ if (isset($_GET['firstpage'])) {
 
 
 } else {
 } else {
     api_delete_firstpage_parameter();
     api_delete_firstpage_parameter();
-    Header('Location: '.api_get_path(WEB_PATH).'index.php');
+    header('Location: '.api_get_path(WEB_PATH).'index.php');
+    exit;
 }
 }

+ 2 - 1
main/auth/ldap/authldap.php

@@ -24,7 +24,8 @@
     ---------------
     ---------------
     This historial has been discontinued. Please use the Mercurial logs for more
     This historial has been discontinued. Please use the Mercurial logs for more
     3.2 - updated to allow for specific term search for teachers identification
     3.2 - updated to allow for specific term search for teachers identification
-    3.1 - updated code to use database settings, to respect coding conventions as much as possible (camel-case removed) and to allow for non-anonymous login
+    3.1 - updated code to use database settings, to respect coding conventions
+ *        as much as possible (camel-case removed) and to allow for non-anonymous login
     3.0    - updated to use ldap_var.inc.php instead of ldap_var.inc (deprecated)
     3.0    - updated to use ldap_var.inc.php instead of ldap_var.inc (deprecated)
         (November 2003)
         (November 2003)
     2.9    - further changes for new login procedure
     2.9    - further changes for new login procedure

+ 1 - 1
main/auth/ldap/ldap_var.inc.php

@@ -1,4 +1,4 @@
-<?php // $Id: ldap_var.inc.php 14966 2008-04-20 23:03:11Z yannoo $
+<?php
 /* For licensing terms, see /license.txt */
 /* For licensing terms, see /license.txt */
 /**
 /**
 *	LDAP settings
 *	LDAP settings

+ 1 - 1
main/auth/ldap/login.php

@@ -1,4 +1,4 @@
-<?php // $Id: login.php 22201 2009-07-17 19:57:03Z cfasanando $
+<?php
 /* For licensing terms, see /license.txt */
 /* For licensing terms, see /license.txt */
 /**
 /**
 *	Users trying to login, who already exist in the Chamilo database
 *	Users trying to login, who already exist in the Chamilo database

+ 4 - 7
main/auth/ldap/newUser.php

@@ -1,8 +1,8 @@
-<?php # $Id: newUser.php 14965 2008-04-20 23:01:17Z yannoo $
+<?php
 /* For licensing terms, see /license.txt */
 /* For licensing terms, see /license.txt */
 /**
 /**
 * Users trying to login, who do not yet exist in the Chamilo database,
 * Users trying to login, who do not yet exist in the Chamilo database,
-* can be added by this script which tries to retrieve ldap information 
+* can be added by this script which tries to retrieve ldap information
 * about them.
 * about them.
 * @author Roan Embrechts
 * @author Roan Embrechts
 * @package chamilo.auth.ldap
 * @package chamilo.auth.ldap
@@ -29,12 +29,9 @@ if ($ldap_login_success)
 	*/
 	*/
 	$info_array = ldap_find_user_info($login);
 	$info_array = ldap_find_user_info($login);
 	ldap_put_user_info_locally($login, $info_array);
 	ldap_put_user_info_locally($login, $info_array);
-}
-else
-{
-	//error_log('Could not find '.$login.' on LDAP server',0);
+} else {
+    //error_log('Could not find '.$login.' on LDAP server',0);
 	$loginFailed = true;
 	$loginFailed = true;
 	unset($_user['user_id']);
 	unset($_user['user_id']);
 	$uidReset = false;
 	$uidReset = false;
 }
 }
-?>

+ 24 - 18
main/auth/openid/login.php

@@ -18,19 +18,19 @@ require_once api_get_path(CONFIGURATION_PATH) . 'auth.conf.php';
 require_once 'openid.lib.php';
 require_once 'openid.lib.php';
 require_once 'xrds.lib.php';
 require_once 'xrds.lib.php';
 
 
-function openid_form() {
-    //get_lang('OpenIdAuthentication')
-
-    $form = new FormValidator('openid_login', 'post', null, null, array('class' => 'form-vertical form_login'));
+function openid_form()
+{
+    $form = new FormValidator(
+        'openid_login',
+        'post',
+        null,
+        null,
+        array('class' => 'form-vertical form_login')
+    );
     $form -> addElement('text', 'openid_url', array(get_lang('OpenIDURL'), Display::url(get_lang('OpenIDWhatIs'), 'main/auth/openid/whatis.php')), array('class' => 'openid_input'));
     $form -> addElement('text', 'openid_url', array(get_lang('OpenIDURL'), Display::url(get_lang('OpenIDWhatIs'), 'main/auth/openid/whatis.php')), array('class' => 'openid_input'));
     $form -> addElement('button', 'submit', get_lang('Login'));
     $form -> addElement('button', 'submit', get_lang('Login'));
+
     return $form->return_form();
     return $form->return_form();
-    /*
-      return '<label for="openid_url">'.get_lang('OpenIDURL').' <a href="main/auth/openid/whatis.php" title="'.get_lang('OpenIDWhatIs').'">'.Display::return_icon('info3.gif',get_lang('Info')).'</a></label>
-      <input type="text" id="openid_url" name="openid_url" style="background: url(main/img/openid_small_logo.png) no-repeat; background-color: #fff; background-position: 0 50%; padding-left:18px;" value="http://"></input>
-     * <input type="submit" name="openid_login" value="'.get_lang('Enter').'" /><br /><br /></form></div>';
-     * 
-     */
 }
 }
 
 
 /**
 /**
@@ -46,7 +46,7 @@ function openid_form() {
 function openid_begin($claimed_id, $return_to = '', $form_values = array()) {
 function openid_begin($claimed_id, $return_to = '', $form_values = array()) {
 
 
     $claimed_id = _openid_normalize($claimed_id);
     $claimed_id = _openid_normalize($claimed_id);
-    $services = openid_discovery($claimed_id);    
+    $services = openid_discovery($claimed_id);
     if (count($services) == 0) {
     if (count($services) == 0) {
         echo 'Sorry, that is not a valid OpenID. Please ensure you have spelled your ID correctly.';
         echo 'Sorry, that is not a valid OpenID. Please ensure you have spelled your ID correctly.';
         return;
         return;
@@ -64,14 +64,14 @@ function openid_begin($claimed_id, $return_to = '', $form_values = array()) {
     $assoc_handle = '';
     $assoc_handle = '';
     if (function_exists('bcadd')) {
     if (function_exists('bcadd')) {
         $assoc_handle = openid_association($op_endpoint);
         $assoc_handle = openid_association($op_endpoint);
-    }    
+    }
     // Now that there is an association created, move on
     // Now that there is an association created, move on
     // to request authentication from the IdP
     // to request authentication from the IdP
     $identity = (!empty($services[0]['delegate'])) ? $services[0]['delegate'] : $claimed_id;
     $identity = (!empty($services[0]['delegate'])) ? $services[0]['delegate'] : $claimed_id;
     if (isset($services[0]['types']) && is_array($services[0]['types']) && in_array(OPENID_NS_2_0 . '/server', $services[0]['types'])) {
     if (isset($services[0]['types']) && is_array($services[0]['types']) && in_array(OPENID_NS_2_0 . '/server', $services[0]['types'])) {
         $identity = 'http://openid.net/identifier_select/2.0';
         $identity = 'http://openid.net/identifier_select/2.0';
     }
     }
-    $authn_request = openid_authentication_request($claimed_id, $identity, $return_to, $assoc_handle, $services[0]['version']);    
+    $authn_request = openid_authentication_request($claimed_id, $identity, $return_to, $assoc_handle, $services[0]['version']);
     if ($services[0]['version'] == 2) {
     if ($services[0]['version'] == 2) {
         echo openid_redirect($op_endpoint, $authn_request);
         echo openid_redirect($op_endpoint, $authn_request);
     } else {
     } else {
@@ -108,6 +108,7 @@ function openid_complete($response) {
             }
             }
         }
         }
     }
     }
+
     return $response;
     return $response;
 }
 }
 
 
@@ -119,8 +120,8 @@ function openid_complete($response) {
  * @return Array of services discovered (including OpenID version, endpoint
  * @return Array of services discovered (including OpenID version, endpoint
  * URI, etc).
  * URI, etc).
  */
  */
-function openid_discovery($claimed_id) {
-
+function openid_discovery($claimed_id)
+{
     $services = array();
     $services = array();
 
 
     $xrds_url = $claimed_id;
     $xrds_url = $claimed_id;
@@ -175,6 +176,7 @@ function openid_discovery($claimed_id) {
             }
             }
         }
         }
     }
     }
+
     return $services;
     return $services;
 }
 }
 
 
@@ -186,14 +188,17 @@ function openid_discovery($claimed_id) {
  * @return $assoc_handle The association handle.
  * @return $assoc_handle The association handle.
  */
  */
 function openid_association($op_endpoint) {
 function openid_association($op_endpoint) {
-    //@todo Remove Old Associations:  
+    //@todo Remove Old Associations:
     $openid_association = Database::get_main_table(TABLE_MAIN_OPENID_ASSOCIATION);
     $openid_association = Database::get_main_table(TABLE_MAIN_OPENID_ASSOCIATION);
-    $sql = "DELETE FROM $openid_association WHERE created + expires_in < '" . api_get_utc_datetime() . "'";
+    $sql = "DELETE FROM $openid_association
+            WHERE created + expires_in < '" . api_get_utc_datetime() . "'";
     Database::query($sql);
     Database::query($sql);
 
 
     // Check to see if we have an association for this IdP already
     // Check to see if we have an association for this IdP already
     $op_endpoint = Database::escape_string($op_endpoint);
     $op_endpoint = Database::escape_string($op_endpoint);
-    $sql = "SELECT assoc_handle FROM $openid_association WHERE idp_endpoint_uri = '$op_endpoint'";
+    $sql = "SELECT assoc_handle
+            FROM $openid_association
+            WHERE idp_endpoint_uri = '$op_endpoint'";
     $assoc_handle = Database::query($sql);
     $assoc_handle = Database::query($sql);
     if (Database::num_rows($assoc_handle) <= 1) {
     if (Database::num_rows($assoc_handle) <= 1) {
         $mod = OPENID_DH_DEFAULT_MOD;
         $mod = OPENID_DH_DEFAULT_MOD;
@@ -248,6 +253,7 @@ function openid_association_request($public) {
         $cpub = _openid_dh_long_to_base64($public);
         $cpub = _openid_dh_long_to_base64($public);
         $request['openid.dh_consumer_public'] = $cpub;
         $request['openid.dh_consumer_public'] = $cpub;
     }
     }
+
     return $request;
     return $request;
 }
 }
 
 

+ 2 - 2
main/auth/openid/openid.lib.php

@@ -1,6 +1,6 @@
 <?php
 <?php
-
 /* For licensing terms, see /license.txt */
 /* For licensing terms, see /license.txt */
+
 /**
 /**
  * OpenID utility functions. Taken from Drupal 6 code (from dries)
  * OpenID utility functions. Taken from Drupal 6 code (from dries)
  * @package chamilo.auth.openid
  * @package chamilo.auth.openid
@@ -48,7 +48,7 @@ function openid_redirect($url, $message) {
     $output .= '<form method="post" action="' . $url . '" id="openid-redirect-form">';
     $output .= '<form method="post" action="' . $url . '" id="openid-redirect-form">';
     foreach ($message as $key => $value) {
     foreach ($message as $key => $value) {
         $output .='<input type="hidden" name="' . $key . '" value="' . $value . '">';
         $output .='<input type="hidden" name="' . $key . '" value="' . $value . '">';
-    }    
+    }
     $output .= '<noscript><input type="submit" name="submit" value="' . get_lang('Send') . '"/></noscript>';
     $output .= '<noscript><input type="submit" name="submit" value="' . get_lang('Send') . '"/></noscript>';
     $output .= '</form>';
     $output .= '</form>';
     $output .= '<script type="text/javascript">document.getElementById("openid-redirect-form").submit();</script>';
     $output .= '<script type="text/javascript">document.getElementById("openid-redirect-form").submit();</script>';

+ 1 - 3
main/auth/set_temp_password.php

@@ -5,9 +5,7 @@
  * protected by password. If the password matches the course password, we
  * protected by password. If the password matches the course password, we
  * store the fact that user can access it during its session
  * store the fact that user can access it during its session
  */
  */
-/**
- * Initializing context
- */
+
 use ChamiloSession as Session;
 use ChamiloSession as Session;
 
 
 $cidReset = true;
 $cidReset = true;

+ 1 - 1
main/auth/sso/sso.Drupal.class.php

@@ -1,8 +1,8 @@
 <?php
 <?php
+/* For licensing terms, see /license.txt */
 
 
 use ChamiloSession as Session;
 use ChamiloSession as Session;
 
 
-/* For licensing terms, see /license.txt */
 /**
 /**
  * This file contains the necessary elements to implement a Single Sign On
  * This file contains the necessary elements to implement a Single Sign On
  * mechanism with an external Drupal application (on which the Chamilo module
  * mechanism with an external Drupal application (on which the Chamilo module

+ 8 - 8
main/auth/sso/sso.class.php

@@ -1,8 +1,8 @@
 <?php
 <?php
+/* For licensing terms, see /license.txt */
 
 
 use ChamiloSession as Session;
 use ChamiloSession as Session;
 
 
-/* For licensing terms, see /license.txt */
 /**
 /**
  * This file contains the necessary elements to implement a Single Sign On
  * This file contains the necessary elements to implement a Single Sign On
  * mechanism with an arbitrary external web application (given some light
  * mechanism with an arbitrary external web application (given some light
@@ -15,7 +15,8 @@ use ChamiloSession as Session;
 /**
 /**
  * The SSO class allows for management or remote Single Sign On resources
  * The SSO class allows for management or remote Single Sign On resources
  */
  */
-class sso {
+class sso
+{
     public $protocol; //    'http://',
     public $protocol; //    'http://',
     public $domain; //    'localhost/project/drupal5',
     public $domain; //    'localhost/project/drupal5',
     public $auth_uri; //    '/?q=user',
     public $auth_uri; //    '/?q=user',
@@ -36,16 +37,16 @@ class sso {
         $this->protocol   = api_get_setting('sso_authentication_protocol');
         $this->protocol   = api_get_setting('sso_authentication_protocol');
         // There can be multiple domains, so make sure to take only the first
         // There can be multiple domains, so make sure to take only the first
         // This might be later extended with a decision process
         // This might be later extended with a decision process
-        $domains          = split(',',api_get_setting('sso_authentication_domain'));
-        $this->domain     = trim($domains[0]);
-        $this->auth_uri   = api_get_setting('sso_authentication_auth_uri');
+        $domains = explode(',', api_get_setting('sso_authentication_domain'));
+        $this->domain = trim($domains[0]);
+        $this->auth_uri = api_get_setting('sso_authentication_auth_uri');
         $this->deauth_uri = api_get_setting('sso_authentication_unauth_uri');
         $this->deauth_uri = api_get_setting('sso_authentication_unauth_uri');
         //cut the string to avoid recursive URL construction in case of failure
         //cut the string to avoid recursive URL construction in case of failure
-        $this->referer    = $this->protocol.$_SERVER['HTTP_HOST'].substr($_SERVER['REQUEST_URI'],0,strpos($_SERVER['REQUEST_URI'],'sso'));
+        $this->referer = $this->protocol.$_SERVER['HTTP_HOST'].substr($_SERVER['REQUEST_URI'],0,strpos($_SERVER['REQUEST_URI'],'sso'));
         $this->deauth_url = $this->protocol.$this->domain.$this->deauth_uri;
         $this->deauth_url = $this->protocol.$this->domain.$this->deauth_uri;
         $this->master_url = $this->protocol.$this->domain.$this->auth_uri;
         $this->master_url = $this->protocol.$this->domain.$this->auth_uri;
         $this->referrer_uri = base64_encode($_SERVER['REQUEST_URI']);
         $this->referrer_uri = base64_encode($_SERVER['REQUEST_URI']);
-        $this->target     = api_get_path(WEB_PATH);
+        $this->target = api_get_path(WEB_PATH);
     }
     }
 
 
     /**
     /**
@@ -290,5 +291,4 @@ class sso {
 
 
         return api_get_path(WEB_CODE_PATH) . 'auth/profile.php';
         return api_get_path(WEB_CODE_PATH) . 'auth/profile.php';
     }
     }
-
 }
 }

+ 18 - 18
main/auth/sso/sso_server_test.php

@@ -1,25 +1,25 @@
 <?php
 <?php
-/* 
+/*
   SSO sample
   SSO sample
-  
+
   This is the "server" of my institution/university authentification "code"
   This is the "server" of my institution/university authentification "code"
-  
+
   1. Active all the SSO option in your Chamilo installation: main/admin/settings.php?category=Security
   1. Active all the SSO option in your Chamilo installation: main/admin/settings.php?category=Security
   2. Make sure this script is located in the index page of the server you fill in the "Domain of the Single Sign On server" Chamilo setting
   2. Make sure this script is located in the index page of the server you fill in the "Domain of the Single Sign On server" Chamilo setting
      For example this script must be located in example.com/index.php if you set the "Domain of the Single Sign On server" = example.com
      For example this script must be located in example.com/index.php if you set the "Domain of the Single Sign On server" = example.com
-  3. Create a user in chamilo and in your external system with login = "joe" and password = "doe"  
-  4. Remember this is just a sample! Check the chamilo drupal extension for more information: 
+  3. Create a user in chamilo and in your external system with login = "joe" and password = "doe"
+  4. Remember this is just a sample! Check the chamilo drupal extension for more information:
      http://drupal.org/node/817682
      http://drupal.org/node/817682
-  5. When activating the settings in step 1, the principal Chamilo file main/inc/local.inc.php will load the class main/auth/sso.class.php library 
+  5. When activating the settings in step 1, the principal Chamilo file main/inc/local.inc.php will load the class main/auth/sso.class.php library
  *   that will redirect to this field with some parameters.
  *   that will redirect to this field with some parameters.
- * 
+ *
 */
 */
 
 
 
 
 exit; //Uncomment this to execute the page
 exit; //Uncomment this to execute the page
 
 
 
 
-//After you located this file in you new domain and you set the settings in step 2, 
+//After you located this file in you new domain and you set the settings in step 2,
 //this page will be loaded when entering to the Chamilo site if the SSO option was set in step 1.
 //this page will be loaded when entering to the Chamilo site if the SSO option was set in step 1.
 
 
 //Getting the chamilo server
 //Getting the chamilo server
@@ -32,19 +32,19 @@ if (isset($_SESSION['my_server_user_session'])) {
 }
 }
 
 
 //Login process
 //Login process
-      
+
 if (isset($_POST['user']) && isset($_POST['password'])) {
 if (isset($_POST['user']) && isset($_POST['password'])) {
-    
+
     //1. Your Server validations
     //1. Your Server validations
     $validate = validate_user($_POST['user'], $_POST['password']);
     $validate = validate_user($_POST['user'], $_POST['password']);
-    
+
     if ($validate) {
     if ($validate) {
-    
+
         /* 2.Get the chamilo username and password from your system or from webservices */
         /* 2.Get the chamilo username and password from your system or from webservices */
-        
+
         $account['username'] = 'jbrion525';             //username in Chamilo
         $account['username'] = 'jbrion525';             //username in Chamilo
         $account['password'] = sha1(sha1('jbrion525')); //encrypted password with assuming that the first encrypted method is sha1 in chamilo
         $account['password'] = sha1(sha1('jbrion525')); //encrypted password with assuming that the first encrypted method is sha1 in chamilo
-        
+
         $master_auth_uri = $my_chamilo_server.'/?q=user';
         $master_auth_uri = $my_chamilo_server.'/?q=user';
 
 
         // Creating an array cookie that will be sent to Chamilo
         // Creating an array cookie that will be sent to Chamilo
@@ -61,10 +61,10 @@ if (isset($_POST['user']) && isset($_POST['password'])) {
         $url = chamilo_sso_protocol() . $master_auth_uri;
         $url = chamilo_sso_protocol() . $master_auth_uri;
         $params = 'sso_referer='. urlencode($url) .'&sso_cookie='. urlencode($cookie);
         $params = 'sso_referer='. urlencode($url) .'&sso_cookie='. urlencode($cookie);
         $final_url = filter_xss($_GET['sso_referer']) .'?'. $params;
         $final_url = filter_xss($_GET['sso_referer']) .'?'. $params;
-        
-        //If your user exists redirect to chamilo and set the account in a session to check it later        
+
+        //If your user exists redirect to chamilo and set the account in a session to check it later
         $_SESSION['my_server_user_session'] = $account;
         $_SESSION['my_server_user_session'] = $account;
-        
+
         //3. After validating the user in the server and getting and setting the user data of chamilo in the sso_cookie variable:
         //3. After validating the user in the server and getting and setting the user data of chamilo in the sso_cookie variable:
         // Redirect to this URL
         // Redirect to this URL
         header('Location: '.$final_url);
         header('Location: '.$final_url);
@@ -97,4 +97,4 @@ function chamilo_sso_protocol() {
         Pass <input name="password" />
         Pass <input name="password" />
         <input type="submit" value="Login">
         <input type="submit" value="Login">
     </form>
     </form>
-</html>
+</html>

+ 4 - 3
main/auth/unsubscribe_account.php

@@ -1,5 +1,6 @@
 <?php
 <?php
 /* For licensing terms, see /license.txt */
 /* For licensing terms, see /license.txt */
+
 require_once '../inc/global.inc.php';
 require_once '../inc/global.inc.php';
 
 
 if (api_get_setting('platform_unsubscribe_allowed') != 'true') {
 if (api_get_setting('platform_unsubscribe_allowed') != 'true') {
@@ -14,15 +15,15 @@ $form = new FormValidator('user_add');
 $form->addElement('button', 'submit', get_lang('Unsubscribe'), array('onclick' => "javascript:if(!confirm('".addslashes(api_htmlentities(get_lang("UnsubscribeFromPlatformConfirm")))."')) return false;"));
 $form->addElement('button', 'submit', get_lang('Unsubscribe'), array('onclick' => "javascript:if(!confirm('".addslashes(api_htmlentities(get_lang("UnsubscribeFromPlatformConfirm")))."')) return false;"));
 $content = $form->return_form();
 $content = $form->return_form();
 
 
-if ($form->validate()) {    
+if ($form->validate()) {
     $user_info = api_get_user_info();
     $user_info = api_get_user_info();
-    $result = UserManager::delete_user($user_info['user_id']);    
+    $result = UserManager::delete_user($user_info['user_id']);
     if ($result) {
     if ($result) {
         $message = Display::return_message(sprintf(get_lang('UnsubscribeFromPlatformSuccess', $user_info['username'])));
         $message = Display::return_message(sprintf(get_lang('UnsubscribeFromPlatformSuccess', $user_info['username'])));
         $content = null;
         $content = null;
         online_logout($user_info['user_id'], false);
         online_logout($user_info['user_id'], false);
         api_not_allowed(true, $message);
         api_not_allowed(true, $message);
-    }    
+    }
 }
 }
 
 
 $tpl = new Template($tool_name);
 $tpl = new Template($tool_name);

+ 76 - 76
main/blog/blog_admin.php

@@ -20,91 +20,91 @@ api_protect_course_script(true);
 
 
 //	 ONLY USERS REGISTERED IN THE COURSE
 //	 ONLY USERS REGISTERED IN THE COURSE
 if ((!$is_allowed_in_course || !$is_courseMember) && !api_is_allowed_to_edit()) {
 if ((!$is_allowed_in_course || !$is_courseMember) && !api_is_allowed_to_edit()) {
-	api_not_allowed(true);//print headers/footers
+    api_not_allowed(true);//print headers/footers
 }
 }
 
 
 if (api_is_allowed_to_edit()) {
 if (api_is_allowed_to_edit()) {
-	$nameTools = get_lang("blog_management");
+    $nameTools = get_lang("blog_management");
 
 
-	// showing the header if we are not in the learning path, if we are in
-	// the learning path, we do not include the banner so we have to explicitly
-	// include the stylesheet, which is normally done in the header
-	if ($_GET['origin'] != 'learnpath') {
-		$interbreadcrumb[]= array ('url' => 'blog_admin.php?','name' => $nameTools);
-		$my_url='';
-		if (isset($_GET['action']) && $_GET['action']=='add') {
-			$current_section=get_lang('AddBlog');
-			$my_url='action=add';
-		} elseif (isset($_GET['action']) && $_GET['action']=='edit') {
-			$current_section=get_lang('EditBlog');
-			$my_url='action=edit&amp;blog_id='.Security::remove_XSS($_GET['blog_id']);
-		}
-		Display::display_header('');
-	}
-	echo '<div class="actions">';
-	echo "<a href='".api_get_self()."?".api_get_cidreq()."&action=add'>",
-		Display::return_icon('new_blog.png',get_lang('AddBlog'),'',ICON_SIZE_MEDIUM)."</a>";
-	echo '</div>';
+    // showing the header if we are not in the learning path, if we are in
+    // the learning path, we do not include the banner so we have to explicitly
+    // include the stylesheet, which is normally done in the header
+    if ($_GET['origin'] != 'learnpath') {
+        $interbreadcrumb[]= array ('url' => 'blog_admin.php?','name' => $nameTools);
+        $my_url='';
+        if (isset($_GET['action']) && $_GET['action']=='add') {
+            $current_section=get_lang('AddBlog');
+            $my_url='action=add';
+        } elseif (isset($_GET['action']) && $_GET['action']=='edit') {
+            $current_section=get_lang('EditBlog');
+            $my_url='action=edit&amp;blog_id='.Security::remove_XSS($_GET['blog_id']);
+        }
+        Display::display_header('');
+    }
+    echo '<div class="actions">';
+    echo "<a href='".api_get_self()."?".api_get_cidreq()."&action=add'>",
+        Display::return_icon('new_blog.png',get_lang('AddBlog'),'',ICON_SIZE_MEDIUM)."</a>";
+    echo '</div>';
 
 
-	if (!empty($_POST['new_blog_submit']) AND !empty($_POST['blog_name'])) {
-		if (isset($_POST['blog_name']))  {
-			Blog::create_blog($_POST['blog_name'], $_POST['blog_subtitle']);
-			Display::display_confirmation_message(get_lang('BlogStored'));
-		}
-	}
-	if (!empty($_POST['edit_blog_submit']) AND !empty($_POST['blog_name'])) {
-		if (strlen(trim($_POST['blog_name']))>0) {
-			Blog::edit_blog($_POST['blog_id'], $_POST['blog_name'], $_POST['blog_subtitle']);
-			Display::display_confirmation_message(get_lang('BlogEdited'));
-		}
-	}
-	if (isset($_GET['action']) && $_GET['action'] == 'visibility') {
-		Blog::change_blog_visibility(intval($_GET['blog_id']));
-		Display::display_confirmation_message(get_lang('VisibilityChanged'));
-	}
-	if (isset($_GET['action']) && $_GET['action'] == 'delete') {
-		Blog::delete_blog(intval($_GET['blog_id']));
-		Display::display_confirmation_message(get_lang('BlogDeleted'));
-	}
+    if (!empty($_POST['new_blog_submit']) AND !empty($_POST['blog_name'])) {
+        if (isset($_POST['blog_name']))  {
+            Blog::create_blog($_POST['blog_name'], $_POST['blog_subtitle']);
+            Display::display_confirmation_message(get_lang('BlogStored'));
+        }
+    }
+    if (!empty($_POST['edit_blog_submit']) AND !empty($_POST['blog_name'])) {
+        if (strlen(trim($_POST['blog_name']))>0) {
+            Blog::edit_blog($_POST['blog_id'], $_POST['blog_name'], $_POST['blog_subtitle']);
+            Display::display_confirmation_message(get_lang('BlogEdited'));
+        }
+    }
+    if (isset($_GET['action']) && $_GET['action'] == 'visibility') {
+        Blog::change_blog_visibility(intval($_GET['blog_id']));
+        Display::display_confirmation_message(get_lang('VisibilityChanged'));
+    }
+    if (isset($_GET['action']) && $_GET['action'] == 'delete') {
+        Blog::delete_blog(intval($_GET['blog_id']));
+        Display::display_confirmation_message(get_lang('BlogDeleted'));
+    }
 
 
-	/*
-		DISPLAY
-	*/
-	//api_display_tool_title($nameTools);
-	//api_introductionsection(TOOL_BLOG);
-	if (isset($_GET['action']) && $_GET['action'] == 'add') {
-		// we show the form if
-		// 1. no post data
-		// 2. there is post data and one of the required form elements is empty
-		if (!$_POST OR (!empty($_POST) AND (empty($_POST['new_blog_submit']) OR empty($_POST['blog_name'])))) {
-			// if there is post data there is certainly an error in the form
-			/*if ($_POST){
-				Display::display_error_message(get_lang('FormHasErrorsPleaseComplete'));
-			}*/
-			/*if (strlen($_POST['blog_name'])==0) {
-				if (count($_POST)>0) {
-					Display::display_error_message(get_lang('FormHasErrorsPleaseComplete'));
-				}
-			}*/
-			Blog::display_new_blog_form();
-		}
-	}
+    /*
+        DISPLAY
+    */
+    //api_display_tool_title($nameTools);
+    //api_introductionsection(TOOL_BLOG);
+    if (isset($_GET['action']) && $_GET['action'] == 'add') {
+        // we show the form if
+        // 1. no post data
+        // 2. there is post data and one of the required form elements is empty
+        if (!$_POST OR (!empty($_POST) AND (empty($_POST['new_blog_submit']) OR empty($_POST['blog_name'])))) {
+            // if there is post data there is certainly an error in the form
+            /*if ($_POST){
+                Display::display_error_message(get_lang('FormHasErrorsPleaseComplete'));
+            }*/
+            /*if (strlen($_POST['blog_name'])==0) {
+                if (count($_POST)>0) {
+                    Display::display_error_message(get_lang('FormHasErrorsPleaseComplete'));
+                }
+            }*/
+            Blog::display_new_blog_form();
+        }
+    }
 
 
-	if (isset($_GET['action']) && $_GET['action'] == 'edit') {
-		// we show the form if
-		// 1. no post data
-		// 2. there is post data and one of the three form elements is empty
-		if (!$_POST OR (!empty($_POST) AND (empty($_POST['edit_blog_submit']) OR empty($_POST['blog_name']) ))) {
-			// if there is post data there is certainly an error in the form
-			if ($_POST) {
-				Display::display_error_message(get_lang('FormHasErrorsPleaseComplete'));
-			}
+    if (isset($_GET['action']) && $_GET['action'] == 'edit') {
+        // we show the form if
+        // 1. no post data
+        // 2. there is post data and one of the three form elements is empty
+        if (!$_POST OR (!empty($_POST) AND (empty($_POST['edit_blog_submit']) OR empty($_POST['blog_name']) ))) {
+            // if there is post data there is certainly an error in the form
+            if ($_POST) {
+                Display::display_error_message(get_lang('FormHasErrorsPleaseComplete'));
+            }
             Blog::display_edit_blog_form(intval($_GET['blog_id']));
             Blog::display_edit_blog_form(intval($_GET['blog_id']));
-		}
-	}
-	Blog::display_blog_list();
+        }
+    }
+    Blog::display_blog_list();
 } else {
 } else {
-	api_not_allowed(true);
+    api_not_allowed(true);
 }
 }
 
 
 // Display the footer
 // Display the footer

+ 6 - 1
main/blog/download.php

@@ -45,6 +45,7 @@ if (is_dir($full_file_name)) {
 	$document_explorer = api_get_path(WEB_COURSE_PATH).api_get_course_path(); // home course path
 	$document_explorer = api_get_path(WEB_COURSE_PATH).api_get_course_path(); // home course path
 	//redirect
 	//redirect
 	header('Location: '.$document_explorer);
 	header('Location: '.$document_explorer);
+    exit;
 }
 }
 
 
 $tbl_blogs_attachment 	= Database::get_course_table(TABLE_BLOGS_ATTACHMENT);
 $tbl_blogs_attachment 	= Database::get_course_table(TABLE_BLOGS_ATTACHMENT);
@@ -59,7 +60,11 @@ $result = Database::query($sql);
 if (Database::num_rows($result) > 0) {
 if (Database::num_rows($result) > 0) {
     $row = Database::fetch_array($result);
     $row = Database::fetch_array($result);
     if (Security::check_abs_path($full_file_name, api_get_path(SYS_COURSE_PATH).api_get_course_path().'/upload/blog/')) {
     if (Security::check_abs_path($full_file_name, api_get_path(SYS_COURSE_PATH).api_get_course_path().'/upload/blog/')) {
-        DocumentManager::file_send_for_download($full_file_name, TRUE, $row['filename']);
+        DocumentManager::file_send_for_download(
+            $full_file_name,
+            true,
+            $row['filename']
+        );
     }
     }
 }
 }
 exit;
 exit;

+ 1 - 1
main/calendar/download.php

@@ -82,7 +82,7 @@ if (Database::num_rows($result)) {
         $full_file_name,
         $full_file_name,
         api_get_path(SYS_COURSE_PATH).$course_info['path'].'/upload/calendar/')
         api_get_path(SYS_COURSE_PATH).$course_info['path'].'/upload/calendar/')
     ) {
     ) {
-        DocumentManager::file_send_for_download($full_file_name,TRUE, $title);
+        DocumentManager::file_send_for_download($full_file_name, true, $title);
     }
     }
 }
 }
 
 

+ 3 - 3
main/course_description/course_description_controller.php

@@ -104,9 +104,9 @@ class CourseDescriptionController
 
 
                     if (!empty($thematic_advance)) {
                     if (!empty($thematic_advance)) {
                         $course_description->set_id($id);
                         $course_description->set_id($id);
-                        $affected_rows = $course_description->update();
+                        $course_description->update();
                     } else {
                     } else {
-                        $affected_rows = $course_description->insert();
+                        $course_description->insert();
                     }
                     }
                     Security::clear_token();
                     Security::clear_token();
 
 
@@ -203,7 +203,7 @@ class CourseDescriptionController
                         $course_description->set_description_type($description_type);
                         $course_description->set_description_type($description_type);
                         $course_description->set_title($title);
                         $course_description->set_title($title);
                         $course_description->set_content($content);
                         $course_description->set_content($content);
-                        $affected_rows = $course_description->insert(api_get_course_int_id());
+                        $course_description->insert(api_get_course_int_id());
                     }
                     }
                     Security::clear_token();
                     Security::clear_token();
 
 

+ 62 - 62
main/course_home/2column.php

@@ -19,62 +19,62 @@ $id = isset($_GET['id']) ? intval($_GET['id']) : null;
 $course_id = api_get_course_int_id();
 $course_id = api_get_course_int_id();
 
 
 if (api_is_allowed_to_edit(null, true)) {
 if (api_is_allowed_to_edit(null, true)) {
-	/*  Processing request */
-	/*	Modify home page */
-	/*
-	 * Display message to confirm that a tool must be hidden from the list of available tools (visibility 0,1->2)
-	 */
-
-	if ($_GET['remove']) {
-		$msgDestroy = get_lang('DelLk').'<br />';
-		$msgDestroy .= '<a href="'.api_get_self().'">'.get_lang('No').'</a>&nbsp;|&nbsp;';
-		$msgDestroy .= '<a href="'.api_get_self().'?destroy=yes&amp;id='.$id.'">'.get_lang('Yes').'</a>';
-		$show_message .= Display :: return_message($msgDestroy, 'confirmation',false);
-	}
-
-	/*
-	 * Process hiding a tools from available tools.
-	 * visibility=2 are only view  by Dokeos Administrator (visibility 0,1->2)
-	 */
-
-	elseif ($_GET['destroy']) {
-		Database::query("UPDATE $tool_table SET visibility='2' WHERE c_id = $course_id AND id='".$id."'");
-	}
-
-  	/*	HIDE */
-
-	elseif ($_GET['hide']) { // visibility 1 -> 0
-		Database::query("UPDATE $tool_table SET visibility=0 WHERE c_id = $course_id AND id='".$id."'");
-		$show_message .= Display::return_message(get_lang('ToolIsNowHidden'), 'confirmation');
-	}
+    /*  Processing request */
+    /*	Modify home page */
+    /*
+     * Display message to confirm that a tool must be hidden from the list of available tools (visibility 0,1->2)
+     */
+
+    if ($_GET['remove']) {
+        $msgDestroy = get_lang('DelLk').'<br />';
+        $msgDestroy .= '<a href="'.api_get_self().'">'.get_lang('No').'</a>&nbsp;|&nbsp;';
+        $msgDestroy .= '<a href="'.api_get_self().'?destroy=yes&amp;id='.$id.'">'.get_lang('Yes').'</a>';
+        $show_message .= Display :: return_message($msgDestroy, 'confirmation',false);
+    }
+
+    /*
+     * Process hiding a tools from available tools.
+     * visibility=2 are only view  by Dokeos Administrator (visibility 0,1->2)
+     */
+
+    elseif ($_GET['destroy']) {
+        Database::query("UPDATE $tool_table SET visibility='2' WHERE c_id = $course_id AND id='".$id."'");
+    }
+
+    /*	HIDE */
+
+    elseif ($_GET['hide']) { // visibility 1 -> 0
+        Database::query("UPDATE $tool_table SET visibility=0 WHERE c_id = $course_id AND id='".$id."'");
+        $show_message .= Display::return_message(get_lang('ToolIsNowHidden'), 'confirmation');
+    }
 
 
     /*	REACTIVATE */
     /*	REACTIVATE */
 
 
-	elseif ($_GET["restore"]) { // visibility 0,2 -> 1
-		Database::query("UPDATE $tool_table SET visibility=1  WHERE c_id = $course_id AND id='".$id."'");
-		$show_message .= Display::return_message(get_lang('ToolIsNowVisible'), 'confirmation');
-	}
+    elseif ($_GET["restore"]) { // visibility 0,2 -> 1
+        Database::query("UPDATE $tool_table SET visibility=1  WHERE c_id = $course_id AND id='".$id."'");
+        $show_message .= Display::return_message(get_lang('ToolIsNowVisible'), 'confirmation');
+    }
 }
 }
 
 
 // Work with data post askable by admin of course
 // Work with data post askable by admin of course
 
 
 // Work with data post askable by admin of course
 // Work with data post askable by admin of course
 if (api_is_platform_admin()) {
 if (api_is_platform_admin()) {
-	// Show message to confirm that a tool it to be hidden from available tools
-	// visibility 0,1->2
-	if (!empty($_GET['askDelete'])) {
+    // Show message to confirm that a tool it to be hidden from available tools
+    // visibility 0,1->2
+    if (!empty($_GET['askDelete'])) {
         $content .='<div id="toolhide">'.get_lang('DelLk').'<br />&nbsp;&nbsp;&nbsp;
         $content .='<div id="toolhide">'.get_lang('DelLk').'<br />&nbsp;&nbsp;&nbsp;
             <a href="'.api_get_self().'">'.get_lang('No').'</a>&nbsp;|&nbsp;
             <a href="'.api_get_self().'">'.get_lang('No').'</a>&nbsp;|&nbsp;
             <a href="'.api_get_self().'?delete=yes&id='.intval($_GET['id']).'">'.get_lang('Yes').'</a>
             <a href="'.api_get_self().'?delete=yes&id='.intval($_GET['id']).'">'.get_lang('Yes').'</a>
         </div>';
         </div>';
-	} elseif (isset($_GET['delete']) && $_GET['delete']) {
+    } elseif (isset($_GET['delete']) && $_GET['delete']) {
         /*
         /*
         * Process hiding a tools from available tools.
         * Process hiding a tools from available tools.
         */
         */
-		//where $id is set?
-		$id = intval($id);
-		Database::query("DELETE FROM $tool_table WHERE c_id = $course_id AND id='$id' AND added_tool=1");
-	}
+        //where $id is set?
+        $id = intval($id);
+        Database::query("DELETE FROM $tool_table WHERE c_id = $course_id AND id='$id' AND added_tool=1");
+    }
 }
 }
 
 
 /*	TOOLS VISIBLE FOR EVERYBODY */
 /*	TOOLS VISIBLE FOR EVERYBODY */
@@ -89,36 +89,36 @@ $content .= '</div>';
 
 
 // Start of tools for CourseAdmins (teachers/tutors)
 // Start of tools for CourseAdmins (teachers/tutors)
 if (api_is_allowed_to_edit(null, true) && !api_is_coach()) {
 if (api_is_allowed_to_edit(null, true) && !api_is_coach()) {
-	$content .= "<div class=\"courseadminview\">";
-	$content .= "<span class=\"viewcaption\">";
-	$content .= get_lang('CourseAdminOnly');
-	$content .= "</span>";
-	$content .= "<table width=\"100%\">";
+    $content .= "<div class=\"courseadminview\">";
+    $content .= "<span class=\"viewcaption\">";
+    $content .= get_lang('CourseAdminOnly');
+    $content .= "</span>";
+    $content .= "<table width=\"100%\">";
 
 
-	$content .= CourseHome::show_tool_2column(TOOL_COURSE_ADMIN);
+    $content .= CourseHome::show_tool_2column(TOOL_COURSE_ADMIN);
 
 
-	/*	INACTIVE TOOLS - HIDDEN (GREY) LINKS */
+    /*	INACTIVE TOOLS - HIDDEN (GREY) LINKS */
 
 
-	$content .=	"<tr><td colspan=\"4\"><hr style='color:\"#4171B5\"' noshade=\"noshade\" size=\"1\" /></td></tr>\n".
-			"<tr>\n".
-			"<td colspan=\"4\">\n".
-			"<div style=\"margin-bottom: 10px;\"><font color=\"#808080\">\n".get_lang('InLnk')."</font></div>".
-			"</td>\n".
-			"</tr>";
+    $content .=	"<tr><td colspan=\"4\"><hr style='color:\"#4171B5\"' noshade=\"noshade\" size=\"1\" /></td></tr>\n".
+            "<tr>\n".
+            "<td colspan=\"4\">\n".
+            "<div style=\"margin-bottom: 10px;\"><font color=\"#808080\">\n".get_lang('InLnk')."</font></div>".
+            "</td>\n".
+            "</tr>";
 
 
-	$content .= CourseHome::show_tool_2column(TOOL_PUBLIC_BUT_HIDDEN);
+    $content .= CourseHome::show_tool_2column(TOOL_PUBLIC_BUT_HIDDEN);
 
 
-	$content .=	"</table>";
-	$content .=	"</div> ";
+    $content .=	"</table>";
+    $content .=	"</div> ";
 }
 }
 
 
 /*	Tools for platform admin only */
 /*	Tools for platform admin only */
 
 
 if (api_is_platform_admin() && api_is_allowed_to_edit(null, true) && !api_is_coach()) {
 if (api_is_platform_admin() && api_is_allowed_to_edit(null, true) && !api_is_coach()) {
-	$content .='<div class="platformadminview">
-	<span class="viewcaption">'.get_lang('PlatformAdminOnly').'</span>
-	<table width="100%">
-		'.CourseHome::show_tool_2column(TOOL_PLATFORM_ADMIN).'
-	</table>
-	</div>';
+    $content .='<div class="platformadminview">
+    <span class="viewcaption">'.get_lang('PlatformAdminOnly').'</span>
+    <table width="100%">
+        '.CourseHome::show_tool_2column(TOOL_PLATFORM_ADMIN).'
+    </table>
+    </div>';
 }
 }

+ 149 - 149
main/course_home/3column.php

@@ -21,64 +21,64 @@ $course_id = api_get_course_int_id();
 
 
 // WORK with data post askable by admin of course
 // WORK with data post askable by admin of course
 if (api_is_allowed_to_edit(null, true)) {
 if (api_is_allowed_to_edit(null, true)) {
-	/*  Processing request */
-	/*	MODIFY HOME PAGE */
-	/*
-	 * Edit visibility of tools
-	 *
-	 *     visibility = 1 - everybody
-	 *     visibility = 0 - prof and admin
-	 *     visibility = 2 - admin
-	 *
-	 * Who can change visibility ?
-	 *
-	 *     admin = 0 - prof and admin
-	 *     admin = 1 - admin
-	 *
-	 * Show message to confirm that a tools must be hide from aivailable tools
-	 *
-	 *     visibility 0,1->2 - $remove
-	 *
-	 * Process hiding a tools from aivailable tools.
-	 *
-	 *     visibility=2                         are only view  by Dokeos
-	 * Administrator visibility 0,1->2 - $destroy
-	 *
-	 *     visibility 1 -> 0 - $hide / $restore
-	 */
-
-	/*
-	 * Diplay message to confirm that a tools must be hide from aivailable tools
-	 * (visibility 0,1->2)
-	 */
-
-	if ($remove) {
-		$sql = "SELECT * FROM $TBL_ACCUEIL WHERE c_id = $course_id AND id=$id";
-		$result = Database::query($sql);
-		$tool = Database::fetch_array($result);
-		$tool_name = @htmlspecialchars($tool['name'] != '' ? $tool['name'] : $tool['link'], ENT_QUOTES, api_get_system_encoding());
-		if ($tool['img'] != 'external.gif') {
-			$tool['link'] = api_get_path(WEB_CODE_PATH).$tool['link'];
-		}
-		$tool['image'] = api_get_path(WEB_IMG_PATH).$tool['image'];
-
-		echo "<br /><br /><br />\n";
-		echo "<table class=\"message\" width=\"70%\" align=\"center\">\n",
-			"<tr><td width=\"7%\" align=\"center\">\n",
-			"<a href=\"".$tool['link']."\">".Display::return_icon($tool['image'], get_lang('Delete')), "</a></td>\n",
-			"<td width=\"28%\" height=\"45\"><small>\n",
-			"<a href=\"".$tool['link']."\">".$tool_name."</a></small></td>\n";
-		echo "<td align=\"center\">\n",
-			"<font color=\"#ff0000\">",
-			"&nbsp;&nbsp;&nbsp;",
-			"<strong>", get_lang('DelLk'), "</strong>",
-			"<br />&nbsp;&nbsp;&nbsp;\n",
-			"<a href=\"".api_get_self()."\">", get_lang('No'), "</a>\n",
-			"&nbsp;|&nbsp;\n",
-			"<a href=\"".api_get_self()."?destroy=yes&amp;id=$id\">", get_lang('Yes'), "</a>\n",
-			"</font></td></tr>\n",
-			"</table>\n";
-		echo "<br /><br /><br />\n";
+    /*  Processing request */
+    /*	MODIFY HOME PAGE */
+    /*
+     * Edit visibility of tools
+     *
+     *     visibility = 1 - everybody
+     *     visibility = 0 - prof and admin
+     *     visibility = 2 - admin
+     *
+     * Who can change visibility ?
+     *
+     *     admin = 0 - prof and admin
+     *     admin = 1 - admin
+     *
+     * Show message to confirm that a tools must be hide from aivailable tools
+     *
+     *     visibility 0,1->2 - $remove
+     *
+     * Process hiding a tools from aivailable tools.
+     *
+     *     visibility=2                         are only view  by Dokeos
+     * Administrator visibility 0,1->2 - $destroy
+     *
+     *     visibility 1 -> 0 - $hide / $restore
+     */
+
+    /*
+     * Diplay message to confirm that a tools must be hide from aivailable tools
+     * (visibility 0,1->2)
+     */
+
+    if ($remove) {
+        $sql = "SELECT * FROM $TBL_ACCUEIL WHERE c_id = $course_id AND id=$id";
+        $result = Database::query($sql);
+        $tool = Database::fetch_array($result);
+        $tool_name = @htmlspecialchars($tool['name'] != '' ? $tool['name'] : $tool['link'], ENT_QUOTES, api_get_system_encoding());
+        if ($tool['img'] != 'external.gif') {
+            $tool['link'] = api_get_path(WEB_CODE_PATH).$tool['link'];
+        }
+        $tool['image'] = api_get_path(WEB_IMG_PATH).$tool['image'];
+
+        echo "<br /><br /><br />\n";
+        echo "<table class=\"message\" width=\"70%\" align=\"center\">\n",
+            "<tr><td width=\"7%\" align=\"center\">\n",
+            "<a href=\"".$tool['link']."\">".Display::return_icon($tool['image'], get_lang('Delete')), "</a></td>\n",
+            "<td width=\"28%\" height=\"45\"><small>\n",
+            "<a href=\"".$tool['link']."\">".$tool_name."</a></small></td>\n";
+        echo "<td align=\"center\">\n",
+            "<font color=\"#ff0000\">",
+            "&nbsp;&nbsp;&nbsp;",
+            "<strong>", get_lang('DelLk'), "</strong>",
+            "<br />&nbsp;&nbsp;&nbsp;\n",
+            "<a href=\"".api_get_self()."\">", get_lang('No'), "</a>\n",
+            "&nbsp;|&nbsp;\n",
+            "<a href=\"".api_get_self()."?destroy=yes&amp;id=$id\">", get_lang('Yes'), "</a>\n",
+            "</font></td></tr>\n",
+            "</table>\n";
+        echo "<br /><br /><br />\n";
 
 
 } // if remove
 } // if remove
 
 
@@ -88,104 +88,104 @@ if (api_is_allowed_to_edit(null, true)) {
  */
  */
 
 
 elseif ($destroy) {
 elseif ($destroy) {
-	Database::query("UPDATE $TBL_ACCUEIL SET visibility='2' WHERE c_id = $course_id AND id = $id");
+    Database::query("UPDATE $TBL_ACCUEIL SET visibility='2' WHERE c_id = $course_id AND id = $id");
 }
 }
 
 
 /* HIDE */
 /* HIDE */
 
 
 elseif ($hide) { // visibility 1 -> 0
 elseif ($hide) { // visibility 1 -> 0
-	Database::query("UPDATE $TBL_ACCUEIL SET visibility=0 WHERE c_id = $course_id AND id=$id");
-	$show_message .= Display::return_message(get_lang('ToolIsNowHidden'), 'confirmation');
+    Database::query("UPDATE $TBL_ACCUEIL SET visibility=0 WHERE c_id = $course_id AND id=$id");
+    $show_message .= Display::return_message(get_lang('ToolIsNowHidden'), 'confirmation');
 }
 }
 
 
 /*	REACTIVATE */
 /*	REACTIVATE */
 
 
 elseif ($restore) { // visibility 0,2 -> 1
 elseif ($restore) { // visibility 0,2 -> 1
-	Database::query("UPDATE $TBL_ACCUEIL SET visibility=1  WHERE c_id = $course_id AND id=$id");
-	$show_message .= Display::return_message(get_lang('ToolIsNowVisible'), 'confirmation');
+    Database::query("UPDATE $TBL_ACCUEIL SET visibility=1  WHERE c_id = $course_id AND id=$id");
+    $show_message .= Display::return_message(get_lang('ToolIsNowVisible'), 'confirmation');
 }
 }
 /*
 /*
  * Editing "apparance" of  a tools  on the course Home Page.
  * Editing "apparance" of  a tools  on the course Home Page.
  */
  */
 elseif (isset($update) && $update) {
 elseif (isset($update) && $update) {
-	$result 	= Database::query("SELECT * FROM $TBL_ACCUEIL WHERE c_id = $course_id AND id=$id");
-	$tool		= Database::fetch_array($result);
-	$racine		= api_get_path(SYS_PATH).'/'.$currentCourseID.'/images/';
-	$chemin		= $racine;
-	$name		= $tool[1];
-	$image		= $tool[3];
-
-	$content .= "<tr>\n".
-		"<td colspan=\"4\">\n".
-		"<table>\n".
-		"<tr>\n".
-		"<td>\n".
-		"<form method=\"post\" action=\"".api_get_self()."\">\n".
-		"<input type=\"hidden\" name=\"id\" value=\"$id\">\n".
-		"Image : ".Display::return_icon($image)."\n".
-		"</td>\n".
-		"<td>\n".
-		"<select name=\"image\">\n".
-		"<option selected>". $image. "</option>\n";
-
-	if ($dir = @opendir($chemin)) {
-		while ($file = readdir($dir)) {
-			if ($file == '..' || $file == '.') {
-				unset($file);
-			}
-			$content .= "<option>". $file. "</option>\n";
-		}
-		closedir($dir);
-	}
-
-	$content .= "</select>\n".
-		"</td>\n".
-		"</tr>\n".
-		"<tr>\n".
-		"<td>". get_lang('NameOfTheLink'). " : </td>\n".
-		"<td><input type=\"text\" name=\"name\" value=\"". $name. "\"></td>\n".
-		"</tr>\n".
-		"<tr>\n".
-		"<td>Lien :</td>\n".
-		"<td><input type=\"text\" name=\"link\" value=\"". $link. "\"></td>\n".
-		"</tr>\n".
-		"<tr>\n".
-		"<td colspan=\"2\"><input type=\"submit\" name=\"submit\" value=\"". get_lang('Ok'). "\"></td>\n".
-		"</tr>\n".
-		"</form>\n".
-		"</table>\n".
-		"</td>\n".
-		"</tr>\n";
-	}
+    $result 	= Database::query("SELECT * FROM $TBL_ACCUEIL WHERE c_id = $course_id AND id=$id");
+    $tool		= Database::fetch_array($result);
+    $racine		= api_get_path(SYS_PATH).'/'.$currentCourseID.'/images/';
+    $chemin		= $racine;
+    $name		= $tool[1];
+    $image		= $tool[3];
+
+    $content .= "<tr>\n".
+        "<td colspan=\"4\">\n".
+        "<table>\n".
+        "<tr>\n".
+        "<td>\n".
+        "<form method=\"post\" action=\"".api_get_self()."\">\n".
+        "<input type=\"hidden\" name=\"id\" value=\"$id\">\n".
+        "Image : ".Display::return_icon($image)."\n".
+        "</td>\n".
+        "<td>\n".
+        "<select name=\"image\">\n".
+        "<option selected>". $image. "</option>\n";
+
+    if ($dir = @opendir($chemin)) {
+        while ($file = readdir($dir)) {
+            if ($file == '..' || $file == '.') {
+                unset($file);
+            }
+            $content .= "<option>". $file. "</option>\n";
+        }
+        closedir($dir);
+    }
+
+    $content .= "</select>\n".
+        "</td>\n".
+        "</tr>\n".
+        "<tr>\n".
+        "<td>". get_lang('NameOfTheLink'). " : </td>\n".
+        "<td><input type=\"text\" name=\"name\" value=\"". $name. "\"></td>\n".
+        "</tr>\n".
+        "<tr>\n".
+        "<td>Lien :</td>\n".
+        "<td><input type=\"text\" name=\"link\" value=\"". $link. "\"></td>\n".
+        "</tr>\n".
+        "<tr>\n".
+        "<td colspan=\"2\"><input type=\"submit\" name=\"submit\" value=\"". get_lang('Ok'). "\"></td>\n".
+        "</tr>\n".
+        "</form>\n".
+        "</table>\n".
+        "</td>\n".
+        "</tr>\n";
+    }
 }
 }
 
 
 
 
 // Work with data post askable by admin of  course
 // Work with data post askable by admin of  course
 
 
 if (api_is_platform_admin() && api_is_allowed_to_edit(null, true) && !api_is_coach()) {
 if (api_is_platform_admin() && api_is_allowed_to_edit(null, true) && !api_is_coach()) {
-	// Show message to confirm that a tools must be hide  from aivailable tools
-	// visibility 0,1->2
-	if ($askDelete) {
-		$content .= "<table align=\"center\"><tr><td colspan=\"4\">
+    // Show message to confirm that a tools must be hide  from aivailable tools
+    // visibility 0,1->2
+    if ($askDelete) {
+        $content .= "<table align=\"center\"><tr><td colspan=\"4\">
             <br /><br /><font color=\"#ff0000\">&nbsp;&nbsp;&nbsp;<strong>".get_lang('DelLk')."</strong>
             <br /><br /><font color=\"#ff0000\">&nbsp;&nbsp;&nbsp;<strong>".get_lang('DelLk')."</strong>
-			<br />&nbsp;&nbsp;&nbsp;
-			<a href=\"".api_get_self()."\">".get_lang('No')."</a>
-			&nbsp;|&nbsp;
-			<a href=\"".api_get_self()."?delete=yes&amp;id=$id\">".get_lang('Yes')."</a>
-			</font>
-			<br /><br /><br />
-			</td>
-			</tr>
-			</table>\n";
-	} // if remove
-
-	/*
-	 * Process hiding a tools from aivailable tools.
-	 * visibility=2 are only viewed by Dokeos Administrator visibility 0,1->2
-	 */
-	elseif (isset($delete) && $delete) {
-		Database::query("DELETE FROM $TBL_ACCUEIL WHERE c_id = $course_id AND id = $id AND added_tool=1");
-	}
+            <br />&nbsp;&nbsp;&nbsp;
+            <a href=\"".api_get_self()."\">".get_lang('No')."</a>
+            &nbsp;|&nbsp;
+            <a href=\"".api_get_self()."?delete=yes&amp;id=$id\">".get_lang('Yes')."</a>
+            </font>
+            <br /><br /><br />
+            </td>
+            </tr>
+            </table>\n";
+    } // if remove
+
+    /*
+     * Process hiding a tools from aivailable tools.
+     * visibility=2 are only viewed by Dokeos Administrator visibility 0,1->2
+     */
+    elseif (isset($delete) && $delete) {
+        Database::query("DELETE FROM $TBL_ACCUEIL WHERE c_id = $course_id AND id = $id AND added_tool=1");
+    }
 }
 }
 
 
 $content .= "<table class=\"item\" align=\"center\" border=\"0\" width=\"95%\">\n";
 $content .= "<table class=\"item\" align=\"center\" border=\"0\" width=\"95%\">\n";
@@ -204,25 +204,25 @@ $content .= "</td>\n</tr>\n";
 /*	PROF ONLY VIEW */
 /*	PROF ONLY VIEW */
 
 
 if (api_is_allowed_to_edit(null, true) && !api_is_coach()) {
 if (api_is_allowed_to_edit(null, true) && !api_is_coach()) {
-	$content .= "<tr><td colspan=\"6\"><hr noshade size=\"1\" /></td></tr>\n".
-		"<tr><td colspan=\"6\"><font color=\"#F66105\">\n".get_lang('CourseAdminOnly')."</font>
-		</td></tr>\n";
-	$content .= "<tr>\n<td colspan=\"6\">";
-	$content .=CourseHome::show_tool_3column('courseAdmin');
-	$content .= "</td>\n</tr>\n";
+    $content .= "<tr><td colspan=\"6\"><hr noshade size=\"1\" /></td></tr>\n".
+        "<tr><td colspan=\"6\"><font color=\"#F66105\">\n".get_lang('CourseAdminOnly')."</font>
+        </td></tr>\n";
+    $content .= "<tr>\n<td colspan=\"6\">";
+    $content .=CourseHome::show_tool_3column('courseAdmin');
+    $content .= "</td>\n</tr>\n";
 }
 }
 
 
 /*	TOOLS FOR PLATFORM ADMIN ONLY */
 /*	TOOLS FOR PLATFORM ADMIN ONLY */
 if (api_is_platform_admin() && api_is_allowed_to_edit(null, true) && !api_is_coach()) {
 if (api_is_platform_admin() && api_is_allowed_to_edit(null, true) && !api_is_coach()) {
-	$content .=  "<tr>"."<td colspan=\"6\">".
-		"<hr noshade size=\"1\" />".
-		"</td>"."</tr>\n".
-		"<tr>\n"."<td colspan=\"6\">\n".
-		"<font color=\"#F66105\" >". get_lang('PlatformAdminOnly'). "</font>\n".
-		"</td>\n"."</tr>\n";
-	$content .=  "<tr>\n<td colspan=\"6\">";
-	$content .= CourseHome::show_tool_3column('platformAdmin');
-	$content .=  "</td>\n</tr>\n";
+    $content .=  "<tr>"."<td colspan=\"6\">".
+        "<hr noshade size=\"1\" />".
+        "</td>"."</tr>\n".
+        "<tr>\n"."<td colspan=\"6\">\n".
+        "<font color=\"#F66105\" >". get_lang('PlatformAdminOnly'). "</font>\n".
+        "</td>\n"."</tr>\n";
+    $content .=  "<tr>\n<td colspan=\"6\">";
+    $content .= CourseHome::show_tool_3column('platformAdmin');
+    $content .=  "</td>\n</tr>\n";
 }
 }
 
 
 $content .=  "</table>\n";
 $content .=  "</table>\n";

+ 53 - 53
main/course_home/vertical_activity.php

@@ -19,43 +19,43 @@ $course_id = api_get_course_int_id();
 $session_id = api_get_session_id();
 $session_id = api_get_session_id();
 
 
 if (api_is_allowed_to_edit(null, true)) {
 if (api_is_allowed_to_edit(null, true)) {
-	// HIDE
-	if (!empty($_GET['hide'])) { // visibility 1 -> 0
-		$sql = "UPDATE $tool_table SET visibility=0 WHERE c_id = $course_id AND id='".$id."'";
-		Database::query($sql);
-		$show_message = Display::return_message(get_lang('ToolIsNowHidden'), 'confirmation');
-	} elseif (!empty($_GET['restore'])) {
-		// visibility 0,2 -> 1
-		// REACTIVATE
-		$sql = "UPDATE $tool_table SET visibility=1  WHERE c_id = $course_id AND id='".$id."'";
-		Database::query($sql);
-		$show_message = Display::return_message(get_lang('ToolIsNowVisible'), 'confirmation');
-	}
+    // HIDE
+    if (!empty($_GET['hide'])) { // visibility 1 -> 0
+        $sql = "UPDATE $tool_table SET visibility=0 WHERE c_id = $course_id AND id='".$id."'";
+        Database::query($sql);
+        $show_message = Display::return_message(get_lang('ToolIsNowHidden'), 'confirmation');
+    } elseif (!empty($_GET['restore'])) {
+        // visibility 0,2 -> 1
+        // REACTIVATE
+        $sql = "UPDATE $tool_table SET visibility=1  WHERE c_id = $course_id AND id='".$id."'";
+        Database::query($sql);
+        $show_message = Display::return_message(get_lang('ToolIsNowVisible'), 'confirmation');
+    }
 }
 }
 
 
 // Work with data post askable by admin of course
 // Work with data post askable by admin of course
 if (api_is_platform_admin()) {
 if (api_is_platform_admin()) {
-	// Show message to confirm that a tool it to be hidden from available tools
-	// visibility 0,1->2
-	if (!empty($_GET['askDelete'])) {
+    // Show message to confirm that a tool it to be hidden from available tools
+    // visibility 0,1->2
+    if (!empty($_GET['askDelete'])) {
         $content .='<div id="toolhide">'.get_lang('DelLk').'<br />&nbsp;&nbsp;&nbsp;
         $content .='<div id="toolhide">'.get_lang('DelLk').'<br />&nbsp;&nbsp;&nbsp;
             <a href="'.api_get_self().'">'.get_lang('No').'</a>&nbsp;|&nbsp;
             <a href="'.api_get_self().'">'.get_lang('No').'</a>&nbsp;|&nbsp;
             <a href="'.api_get_self().'?delete=yes&id='.$id.'">'.get_lang('Yes').'</a>
             <a href="'.api_get_self().'?delete=yes&id='.$id.'">'.get_lang('Yes').'</a>
         </div>';
         </div>';
-	} elseif (isset($_GET['delete']) && $_GET['delete']) {
+    } elseif (isset($_GET['delete']) && $_GET['delete']) {
         /*
         /*
         * Process hiding a tools from available tools.
         * Process hiding a tools from available tools.
         */
         */
-		//where $id is set?
-		$id = intval($id);
-		Database::query("DELETE FROM $tool_table WHERE c_id = $course_id AND id='$id' AND added_tool=1");
-	}
+        //where $id is set?
+        $id = intval($id);
+        Database::query("DELETE FROM $tool_table WHERE c_id = $course_id AND id='$id' AND added_tool=1");
+    }
 }
 }
 
 
 //	COURSE ADMIN ONLY VIEW
 //	COURSE ADMIN ONLY VIEW
 
 
 // Start of tools for CourseAdmins (teachers/tutors)
 // Start of tools for CourseAdmins (teachers/tutors)
-if (api_is_allowed_to_edit(null, true) && !api_is_coach()) {   
+if (api_is_allowed_to_edit(null, true) && !api_is_coach()) {
     $content .=  '<div class="courseadminview" style="border:0px; margin-top: 0px;padding:5px;">
     $content .=  '<div class="courseadminview" style="border:0px; margin-top: 0px;padding:5px;">
     <div class="normal-message" id="id_normal_message" style="display:none">';
     <div class="normal-message" id="id_normal_message" style="display:none">';
         $content .=  '<img src="'.api_get_path(WEB_PATH).'main/inc/lib/javascript/indicator.gif"/>&nbsp;&nbsp;';
         $content .=  '<img src="'.api_get_path(WEB_PATH).'main/inc/lib/javascript/indicator.gif"/>&nbsp;&nbsp;';
@@ -87,48 +87,48 @@ if (api_is_allowed_to_edit(null, true) && !api_is_coach()) {
     $content .= '</div>';
     $content .= '</div>';
 
 
 } elseif (api_is_coach()) {
 } elseif (api_is_coach()) {
-	if (api_get_setting('show_session_data') == 'true' && $session_id > 0) {
+    if (api_get_setting('show_session_data') == 'true' && $session_id > 0) {
         $content .= '<div class="courseadminview-activity-3col"><span class="viewcaption">'.get_lang('SessionData').'</span>
         $content .= '<div class="courseadminview-activity-3col"><span class="viewcaption">'.get_lang('SessionData').'</span>
-			<table width="100%">';
-				$content .= CourseHome::show_session_data($session_id);
+            <table width="100%">';
+                $content .= CourseHome::show_session_data($session_id);
              $content .=  '</table></div>';
              $content .=  '</table></div>';
-	}
+    }
 
 
     $content .=  '<div class="Authoringview">';
     $content .=  '<div class="Authoringview">';
-				$my_list = CourseHome::get_tools_category(TOOL_STUDENT_VIEW);
-				$content .= CourseHome::show_tools_category($my_list);
+                $my_list = CourseHome::get_tools_category(TOOL_STUDENT_VIEW);
+                $content .= CourseHome::show_tools_category($my_list);
     $content .= '</div>';
     $content .= '</div>';
     //	TOOLS AUTHORING
     //	TOOLS AUTHORING
 
 
 } else {
 } else {
-	$my_list = CourseHome::get_tools_category(TOOL_STUDENT_VIEW);
-	if (count($my_list) > 0) {
+    $my_list = CourseHome::get_tools_category(TOOL_STUDENT_VIEW);
+    if (count($my_list) > 0) {
         $content .= '<div class="course-student-view-activity-3col">';
         $content .= '<div class="course-student-view-activity-3col">';
-		//ordering by get_lang name
-		$order_tool_list = array();
-		foreach($my_list as $key=>$new_tool) {
-			$tool_name = CourseHome::translate_tool_name($new_tool);
-			$order_tool_list [$key]= $tool_name;
-		}		
-		natsort($order_tool_list);		
-		$my_temp_tool_array = array();
-		foreach($order_tool_list as $key=>$new_tool) {
-			$my_temp_tool_array[] = $my_list[$key];
-		}
-		$my_list = $my_temp_tool_array;
+        //ordering by get_lang name
+        $order_tool_list = array();
+        foreach($my_list as $key=>$new_tool) {
+            $tool_name = CourseHome::translate_tool_name($new_tool);
+            $order_tool_list [$key]= $tool_name;
+        }
+        natsort($order_tool_list);
+        $my_temp_tool_array = array();
+        foreach($order_tool_list as $key=>$new_tool) {
+            $my_temp_tool_array[] = $my_list[$key];
+        }
+        $my_list = $my_temp_tool_array;
 
 
-		$i = 0;
-		foreach($my_list as $new_tool) {
-			if ($i >= 10) {
-				$my_list2[] = $new_tool;
-			} else {
-				$my_list1[] = $new_tool;
-			}
-			$i++;
-		}
-		$content .=CourseHome::show_tools_category($my_list1);
-		$content .=CourseHome::show_tools_category($my_list2);
+        $i = 0;
+        foreach($my_list as $new_tool) {
+            if ($i >= 10) {
+                $my_list2[] = $new_tool;
+            } else {
+                $my_list1[] = $new_tool;
+            }
+            $i++;
+        }
+        $content .=CourseHome::show_tools_category($my_list1);
+        $content .=CourseHome::show_tools_category($my_list2);
         $content .= '</div>';
         $content .= '</div>';
-	}
+    }
 }
 }
 $content .= '</div>';
 $content .= '</div>';

+ 0 - 1
main/course_info/download.php

@@ -6,7 +6,6 @@
  * @package chamilo.course_info
  * @package chamilo.course_info
  */
  */
 
 
-//session_cache_limiter('public');
 require_once '../inc/global.inc.php';
 require_once '../inc/global.inc.php';
 $this_section = SECTION_COURSES;
 $this_section = SECTION_COURSES;
 
 

+ 0 - 3
main/course_info/maintenance_coach.php

@@ -6,9 +6,6 @@
  * @author Angel Fernando Quiroz Campos <angel.quiroz@beeznest.com>
  * @author Angel Fernando Quiroz Campos <angel.quiroz@beeznest.com>
  * @package chamilo.course_info
  * @package chamilo.course_info
  */
  */
-/**
- * Code
- */
 
 
 require_once '../inc/global.inc.php';
 require_once '../inc/global.inc.php';
 
 

+ 0 - 2
main/course_info/start.php

@@ -1,8 +1,6 @@
 <?php
 <?php
 /* For licensing terms, see /license.txt */
 /* For licensing terms, see /license.txt */
 
 
-use \ChamiloSession as Session;
-
 require_once '../inc/global.inc.php';
 require_once '../inc/global.inc.php';
 
 
 api_protect_course_script(true);
 api_protect_course_script(true);

+ 18 - 3
main/course_info/tools.php

@@ -50,9 +50,24 @@ switch ($action) {
         $allowed_picture_types = array ('jpg', 'jpeg', 'png');
         $allowed_picture_types = array ('jpg', 'jpeg', 'png');
         $form->addElement('file', 'icon', get_lang('CustomIcon'));
         $form->addElement('file', 'icon', get_lang('CustomIcon'));
         $form->addRule('icon', get_lang('OnlyImagesAllowed').' ('.implode(',', $allowed_picture_types).')', 'filetype', $allowed_picture_types);
         $form->addRule('icon', get_lang('OnlyImagesAllowed').' ('.implode(',', $allowed_picture_types).')', 'filetype', $allowed_picture_types);
-        $form->addElement('select', 'target', get_lang('Target'), array('_self' => '_self', '_blank' => '_blank'));
-        $form->addElement('select', 'visibility', get_lang('Visibility'), array(1 => get_lang('Visible'), 0 => get_lang('Invisible')));
-        $form->addElement('textarea', 'description', get_lang('Description'),array ('rows' => '3', 'cols' => '40'));
+        $form->addElement(
+            'select',
+            'target',
+            get_lang('Target'),
+            array('_self' => '_self', '_blank' => '_blank')
+        );
+        $form->addElement(
+            'select',
+            'visibility',
+            get_lang('Visibility'),
+            array(1 => get_lang('Visible'), 0 => get_lang('Invisible'))
+        );
+        $form->addElement(
+            'textarea',
+            'description',
+            get_lang('Description'),
+            array('rows' => '3', 'cols' => '40')
+        );
         $form->addButtonUpdate(get_lang('Update'));
         $form->addButtonUpdate(get_lang('Update'));
         $form->addHtml('</div>');
         $form->addHtml('</div>');
         $form->addHtml('<div class="col-md-5">');
         $form->addHtml('<div class="col-md-5">');

+ 0 - 3
main/course_progress/thematic.php

@@ -209,11 +209,8 @@ if ($action == 'thematic_list') {
                     }
                     }
 
 
                     $thematic_advance_item =  isset($thematic_advance_div[$thematic['id']][$thematic_advance['id']]) ? $thematic_advance_div[$thematic['id']][$thematic_advance['id']] : null;
                     $thematic_advance_item =  isset($thematic_advance_div[$thematic['id']][$thematic_advance['id']]) ? $thematic_advance_div[$thematic['id']][$thematic_advance['id']] : null;
-
                     echo Display::div($thematic_advance_item, array('id'=>'thematic_advance_'.$thematic_advance['id']));
                     echo Display::div($thematic_advance_item, array('id'=>'thematic_advance_'.$thematic_advance['id']));
-
                     echo $edit_link;
                     echo $edit_link;
-
                     echo '</td>';
                     echo '</td>';
 
 
                     //if (api_is_allowed_to_edit(null, true) && api_get_session_id() == $thematic['session_id']) {
                     //if (api_is_allowed_to_edit(null, true) && api_get_session_id() == $thematic['session_id']) {

+ 20 - 3
main/course_progress/thematic_plan.php

@@ -85,8 +85,14 @@ if ($action == 'thematic_plan_list') {
     }
     }
 
 
     // display form
     // display form
-    $form = new FormValidator('thematic_plan_add','POST','index.php?action=thematic_plan_edit&thematic_id='.$thematic_id.'&'.api_get_cidreq().$param_gradebook,'','style="width: 100%;"');
-    //$form->addElement('header', '', $header_form);
+    $form = new FormValidator(
+        'thematic_plan_add',
+        'POST',
+        'index.php?action=thematic_plan_edit&thematic_id='.$thematic_id.'&'.api_get_cidreq(
+        ).$param_gradebook,
+        '',
+        'style="width: 100%;"'
+    );
     $form->addElement('hidden', 'action', $action);
     $form->addElement('hidden', 'action', $action);
     $form->addElement('hidden', 'thematic_plan_token', $token);
     $form->addElement('hidden', 'thematic_plan_token', $token);
 
 
@@ -98,7 +104,18 @@ if ($action == 'thematic_plan_list') {
     }
     }
 
 
     $form->addText('title', get_lang('Title'), true, array('size'=>'50'));
     $form->addText('title', get_lang('Title'), true, array('size'=>'50'));
-    $form->addHtmlEditor('description', get_lang('Description'), false, false, array('ToolbarStartExpanded'=>'false', 'ToolbarSet' => 'TrainingDescription', 'Width' => '80%', 'Height' => '150'));
+    $form->addHtmlEditor(
+        'description',
+        get_lang('Description'),
+        false,
+        false,
+        array(
+            'ToolbarStartExpanded' => 'false',
+            'ToolbarSet' => 'TrainingDescription',
+            'Width' => '80%',
+            'Height' => '150',
+        )
+    );
     $form->addButtonSave(get_lang('Save'));
     $form->addButtonSave(get_lang('Save'));
 
 
     if ($description_type < ADD_THEMATIC_PLAN) {
     if ($description_type < ADD_THEMATIC_PLAN) {

+ 5 - 5
main/coursecopy/copy_course.php

@@ -3,9 +3,6 @@
 /**
 /**
  * @package chamilo.backup
  * @package chamilo.backup
  */
  */
-/**
- * Code
- */
 
 
 // Setting the global file that gets the general configuration, the databases, the languages, ...
 // Setting the global file that gets the general configuration, the databases, the languages, ...
 require_once '../inc/global.inc.php';
 require_once '../inc/global.inc.php';
@@ -65,7 +62,10 @@ if (Security::check_token('post') && (
     $cr = new CourseRestorer($course);
     $cr = new CourseRestorer($course);
     $cr->set_file_option($_POST['same_file_name_option']);
     $cr->set_file_option($_POST['same_file_name_option']);
     $cr->restore($_POST['destination_course']);
     $cr->restore($_POST['destination_course']);
-    Display::display_normal_message(get_lang('CopyFinished').': <a href="'.api_get_course_url($_POST['destination_course']).'">'.$_POST['destination_course'].'</a>', false);
+    Display::display_normal_message(
+        get_lang('CopyFinished').': <a href="'.api_get_course_url($_POST['destination_course']).'">'.$_POST['destination_course'].'</a>',
+        false
+    );
 } elseif (Security::check_token('post') && (
 } elseif (Security::check_token('post') && (
         isset ($_POST['copy_option']) &&
         isset ($_POST['copy_option']) &&
         $_POST['copy_option'] == 'select_items'
         $_POST['copy_option'] == 'select_items'
@@ -78,7 +78,7 @@ if (Security::check_token('post') && (
     $course = $cb->build();
     $course = $cb->build();
     $hiddenFields = array();
     $hiddenFields = array();
     $hiddenFields['same_file_name_option'] = $_POST['same_file_name_option'];
     $hiddenFields['same_file_name_option'] = $_POST['same_file_name_option'];
-    $hiddenFields['destination_course']    = $_POST['destination_course'];
+    $hiddenFields['destination_course'] = $_POST['destination_course'];
     // Add token to Course select form
     // Add token to Course select form
     $hiddenFields['sec_token'] = Security::get_token();
     $hiddenFields['sec_token'] = Security::get_token();
     CourseSelectForm::display_form($course, $hiddenFields, true);
     CourseSelectForm::display_form($course, $hiddenFields, true);

+ 4 - 3
main/dashboard/block.class.php

@@ -2,6 +2,7 @@
 /* For licensing terms, see /license.txt */
 /* For licensing terms, see /license.txt */
 
 
 /**
 /**
+ * Class Block
  * This file contains class used parent class for blocks plugins
  * This file contains class used parent class for blocks plugins
  * Parent class for controller Blocks from dashboard plugin
  * Parent class for controller Blocks from dashboard plugin
  * @author Christian Fasanando <christian1827@gmail.com>
  * @author Christian Fasanando <christian1827@gmail.com>
@@ -9,9 +10,9 @@
  */
  */
 class Block
 class Block
 {
 {
-	/**
-	 * Contructor
-	 */
+    /**
+     * Constructor
+     */
     public function __construct()
     public function __construct()
     {
     {
 
 

+ 67 - 67
main/dashboard/dashboard_controller.php

@@ -11,77 +11,77 @@
  */
  */
 class DashboardController
 class DashboardController
 {
 {
- 	private $toolname;
-	private $view;
-	private $user_id;
-
-	/**
-	 * Constructor
-	 */
-	public function __construct()
-	{
-		$this->user_id = api_get_user_id();
-		$this->toolname = 'dashboard';
-		$this->view = new View($this->toolname);
-	}
-
-	/**
-	 * Display blocks from dashboard plugin paths
-	 * @param string message (optional)
-	 * render to dashboard.php view
-	 */
-	public function display($msg = false)
-	{
-		$data = array();
-		$user_id = $this->user_id;
+    private $toolname;
+    private $view;
+    private $user_id;
+
+    /**
+     * Constructor
+     */
+    public function __construct()
+    {
+        $this->user_id = api_get_user_id();
+        $this->toolname = 'dashboard';
+        $this->view = new View($this->toolname);
+    }
+
+    /**
+     * Display blocks from dashboard plugin paths
+     * @param string message (optional)
+     * render to dashboard.php view
+     */
+    public function display($msg = false)
+    {
+        $data = array();
+        $user_id = $this->user_id;
 
 
-		$block_data_without_plugin = DashboardManager::get_block_data_without_plugin();
-		$dashboard_blocks = DashboardManager::get_enabled_dashboard_blocks();
-		$user_block_data  = DashboardManager::get_user_block_data($user_id);
-		$user_blocks_id = array_keys($user_block_data);
+        $block_data_without_plugin = DashboardManager::get_block_data_without_plugin();
+        $dashboard_blocks = DashboardManager::get_enabled_dashboard_blocks();
+        $user_block_data  = DashboardManager::get_user_block_data($user_id);
+        $user_blocks_id = array_keys($user_block_data);
 
 
         $data_block = null;
         $data_block = null;
 
 
-		if (!empty($dashboard_blocks)) {
-			foreach ($dashboard_blocks as $block) {
-
-				// display only user blocks
-				if (!in_array($block['id'], $user_blocks_id)) continue;
-
-				$path = $block['path'];
-				$controller_class = $block['controller'];
-				$filename_controller = $path.'.class.php';
-				$dashboard_plugin_path = api_get_path(SYS_PLUGIN_PATH).'dashboard/'.$path.'/';
-				require_once $dashboard_plugin_path.$filename_controller;
-				if (class_exists($controller_class)) {
-    				$obj = new $controller_class($user_id);
-
-    				// check if user is allowed to see the block
-    				if (method_exists($obj, 'is_block_visible_for_user')) {
-    					$is_block_visible_for_user = $obj->is_block_visible_for_user($user_id);
-    					if (!$is_block_visible_for_user) continue;
-    				}
-
-    				$data_block[$path] = $obj->get_block();
-    				// set user block column
-    				$data_block[$path]['column'] = $user_block_data[$block['id']]['column'];
-				}
-			}
-
-			$data['blocks'] = $data_block;
-			$data['dashboard_view'] = 'blocks';
-		}
-
-		if ($msg) {
-			$data['msg'] = $msg;
-		}
-
-		// render to the view
-		$this->view->set_data($data);
-		$this->view->set_layout('layout');
-		$this->view->set_template('dashboard');
-		$this->view->render();
-	}
+        if (!empty($dashboard_blocks)) {
+            foreach ($dashboard_blocks as $block) {
+
+                // display only user blocks
+                if (!in_array($block['id'], $user_blocks_id)) continue;
+
+                $path = $block['path'];
+                $controller_class = $block['controller'];
+                $filename_controller = $path.'.class.php';
+                $dashboard_plugin_path = api_get_path(SYS_PLUGIN_PATH).'dashboard/'.$path.'/';
+                require_once $dashboard_plugin_path.$filename_controller;
+                if (class_exists($controller_class)) {
+                    $obj = new $controller_class($user_id);
+
+                    // check if user is allowed to see the block
+                    if (method_exists($obj, 'is_block_visible_for_user')) {
+                        $is_block_visible_for_user = $obj->is_block_visible_for_user($user_id);
+                        if (!$is_block_visible_for_user) continue;
+                    }
+
+                    $data_block[$path] = $obj->get_block();
+                    // set user block column
+                    $data_block[$path]['column'] = $user_block_data[$block['id']]['column'];
+                }
+            }
+
+            $data['blocks'] = $data_block;
+            $data['dashboard_view'] = 'blocks';
+        }
+
+        if ($msg) {
+            $data['msg'] = $msg;
+        }
+
+        // render to the view
+        $this->view->set_data($data);
+        $this->view->set_layout('layout');
+        $this->view->set_template('dashboard');
+        $this->view->render();
+    }
 
 
 	/**
 	/**
 	 * This method allow store user blocks from dashboard manager
 	 * This method allow store user blocks from dashboard manager

+ 2 - 1
main/dropbox/dropbox_functions.inc.php

@@ -356,7 +356,8 @@ function get_dropbox_category($id)
 /**
 /**
 * This functions stores a new dropboxcategory
 * This functions stores a new dropboxcategory
 *
 *
-* @var  it might not seem very elegant if you create a category in sent and in received with the same name that you get two entries in the
+* @var  it might not seem very elegant if you create a category in sent
+ * and in received with the same name that you get two entries in the
 *       dropbox_category table but it is the easiest solution. You get
 *       dropbox_category table but it is the easiest solution. You get
 *       cat_name | received | sent | user_id
 *       cat_name | received | sent | user_id
 *       test     |    1     |   0  |    237
 *       test     |    1     |   0  |    237

+ 1 - 1
main/dropbox/dropbox_init.inc.php

@@ -341,7 +341,7 @@ if ($view == 'received') {
 	}
 	}
 }
 }
 
 
-if ($view == 'sent' OR empty($view)) {
+if ($view == 'sent' || empty($view)) {
 	$interbreadcrumb[] = array('url' => '../dropbox/index.php', 'name' => get_lang('Dropbox', ''));
 	$interbreadcrumb[] = array('url' => '../dropbox/index.php', 'name' => get_lang('Dropbox', ''));
 	$nameTools = get_lang('SentFiles');
 	$nameTools = get_lang('SentFiles');
 
 

+ 0 - 2
main/exercice/exercise.php

@@ -11,8 +11,6 @@
  * Modified by hubert.borderiou (question category)
  * Modified by hubert.borderiou (question category)
  */
  */
 
 
-// name of the language file that needs to be included
-
 use \ChamiloSession as Session;
 use \ChamiloSession as Session;
 
 
 // including the global library
 // including the global library

+ 0 - 2
main/exercice/exercise_admin.php

@@ -8,8 +8,6 @@
 * @author Olivier Brouckaert, Julio Montoya
 * @author Olivier Brouckaert, Julio Montoya
 */
 */
 
 
-// name of the language file that needs to be included
-
 use \ChamiloSession as Session;
 use \ChamiloSession as Session;
 
 
 require_once '../inc/global.inc.php';
 require_once '../inc/global.inc.php';

+ 0 - 2
main/exercice/question_pool.php

@@ -11,8 +11,6 @@
 *   @author Modify by hubert borderiou 2011-10-21 Question's category
 *   @author Modify by hubert borderiou 2011-10-21 Question's category
 */
 */
 
 
-// name of the language file that needs to be included
-
 use ChamiloSession as Session;
 use ChamiloSession as Session;
 
 
 require_once '../inc/global.inc.php';
 require_once '../inc/global.inc.php';

+ 108 - 113
main/forum/forumfunction.inc.php

@@ -162,7 +162,12 @@ function handle_forum_and_forumcategories($lp_id = null)
 
 
         for ($i = 0; $i < count($list_threads); $i++) {
         for ($i = 0; $i < count($list_threads); $i++) {
             deleteForumCategoryThread('thread', $list_threads[$i]['thread_id']);
             deleteForumCategoryThread('thread', $list_threads[$i]['thread_id']);
-            $link_info = GradebookUtils::is_resource_in_course_gradebook(api_get_course_id(), 5, intval($list_threads[$i]['thread_id']), api_get_session_id());
+            $link_info = GradebookUtils::is_resource_in_course_gradebook(
+                api_get_course_id(),
+                5,
+                intval($list_threads[$i]['thread_id']),
+                api_get_session_id()
+            );
             if ($link_info !== false) {
             if ($link_info !== false) {
                 GradebookUtils::remove_resource_from_course_gradebook($link_info['id']);
                 GradebookUtils::remove_resource_from_course_gradebook($link_info['id']);
             }
             }
@@ -570,7 +575,7 @@ function store_forumcategory($values, $courseInfo = array(), $showMessage = true
             'cat_title' => $clean_cat_title,
             'cat_title' => $clean_cat_title,
             'cat_comment' => $values['forum_category_comment'],
             'cat_comment' => $values['forum_category_comment'],
             'cat_order' => $new_max,
             'cat_order' => $new_max,
-            'session_id' => $session_id
+            'session_id' => $session_id,
         ];
         ];
         $last_id = Database::insert($table_categories, $params);
         $last_id = Database::insert($table_categories, $params);
 
 
@@ -642,8 +647,6 @@ function store_forum($values, $courseInfo = array(), $returnId = false)
         $new_max = $row['sort_max'] + 1;
         $new_max = $row['sort_max'] + 1;
     }
     }
 
 
-    $clean_title = Database::escape_string($values['forum_title']);
-
     // Forum images
     // Forum images
     $image_moved = false;
     $image_moved = false;
     if (!empty($_FILES['picture']['name'])) {
     if (!empty($_FILES['picture']['name'])) {
@@ -657,7 +660,7 @@ function store_forum($values, $courseInfo = array(), $returnId = false)
     if (!empty($_POST['remove_picture'])) {
     if (!empty($_POST['remove_picture'])) {
         delete_forum_image($values['forum_id']);
         delete_forum_image($values['forum_id']);
     }
     }
-
+    $new_file_name = '';
     if (isset($upload_ok)) {
     if (isset($upload_ok)) {
         if ($has_attachment) {
         if ($has_attachment) {
             $course_dir = $courseInfo['path'].'/upload/forum/images';
             $course_dir = $courseInfo['path'].'/upload/forum/images';
@@ -952,7 +955,8 @@ function delete_post($post_id)
  * This can be done by sorting the posts that have the field thread_id=$thread_id and sort them by post_date
  * This can be done by sorting the posts that have the field thread_id=$thread_id and sort them by post_date
  *
  *
  * @param $thread_id the id of the thread we want to know the last post of.
  * @param $thread_id the id of the thread we want to know the last post of.
- * @return an array or bool if there is a last post found, false if there is no post entry linked to that thread => thread will be deleted
+ * @return an array or bool if there is a last post found, false if there is
+ * no post entry linked to that thread => thread will be deleted
  *
  *
  * @author Patrick Cool <patrick.cool@UGent.be>, Ghent University
  * @author Patrick Cool <patrick.cool@UGent.be>, Ghent University
  * @version february 2006, dokeos 1.8
  * @version february 2006, dokeos 1.8
@@ -974,21 +978,6 @@ function check_if_last_post_of_thread($thread_id)
     }
     }
 }
 }
 
 
-/**
- * This function takes care of the display of the visibility icon
- *
- * @param $content what is it that we want to make (in)visible: forum category, forum, thread, post
- * @param $id the id of the content we want to make invisible
- * @param $current_visibility_status what is the current status of the visibility (0 = invisible, 1 = visible)
- * @return void string HTML
- *
- * @author Patrick Cool <patrick.cool@UGent.be>, Ghent University
- * @version february 2006, dokeos 1.8
- */
-function display_visible_invisible_icon($content, $id, $current_visibility_status, $additional_url_parameters = '')
-{
-    echo return_visible_invisible_icon($content, $id, $current_visibility_status, $additional_url_parameters);
-}
 /**
 /**
  * @param $content what is it that we want to make (in)visible: forum category, forum, thread, post
  * @param $content what is it that we want to make (in)visible: forum category, forum, thread, post
  * @param $id the id of the content we want to make invisible
  * @param $id the id of the content we want to make invisible
@@ -1006,7 +995,8 @@ function return_visible_invisible_icon($content, $id, $current_visibility_status
                 $html .= $key . '=' . $value . '&';
                 $html .= $key . '=' . $value . '&';
             }
             }
         }
         }
-       $html.='action=invisible&content='.$content.'&id='.$id.'">'.Display::return_icon('visible.png', get_lang('MakeInvisible'), array(), ICON_SIZE_SMALL).'</a>';
+       $html.='action=invisible&content='.$content.'&id='.$id.'">'.
+           Display::return_icon('visible.png', get_lang('MakeInvisible'), array(), ICON_SIZE_SMALL).'</a>';
     }
     }
     if ($current_visibility_status == '0') {
     if ($current_visibility_status == '0') {
         $html .= '<a href="' . api_get_self() . '?' . api_get_cidreq() . '&';
         $html .= '<a href="' . api_get_self() . '?' . api_get_cidreq() . '&';
@@ -1015,26 +1005,12 @@ function return_visible_invisible_icon($content, $id, $current_visibility_status
                 $html .= $key . '=' . $value . '&';
                 $html .= $key . '=' . $value . '&';
             }
             }
         }
         }
-       $html .= 'action=visible&content=' . $content . '&id=' . $id . '">' . Display::return_icon('invisible.png', get_lang('MakeVisible'), array(), ICON_SIZE_SMALL) . '</a>';
+       $html .= 'action=visible&content=' . $content . '&id=' . $id . '">' .
+           Display::return_icon('invisible.png', get_lang('MakeVisible'), array(), ICON_SIZE_SMALL) . '</a>';
     }
     }
     return $html;
     return $html;
 }
 }
 
 
-/**
- * This function takes care of the display of the lock icon
- *
- * @param $content what is it that we want to (un)lock: forum category, forum, thread, post
- * @param $id the id of the content we want to (un)lock
- * @param $current_visibility_status what is the current status of the visibility (0 = invisible, 1 = visible)
- * @return void display the lock HTML.
- *
- * @author Patrick Cool <patrick.cool@UGent.be>, Ghent University
- * @version february 2006, dokeos 1.8
- */
-function display_lock_unlock_icon($content, $id, $current_lock_status, $additional_url_parameters = '')
-{
-    echo return_lock_unlock_icon($content, $id, $current_lock_status, $additional_url_parameters);
-}
 function return_lock_unlock_icon($content, $id, $current_lock_status, $additional_url_parameters = '')
 function return_lock_unlock_icon($content, $id, $current_lock_status, $additional_url_parameters = '')
 {
 {
     $html = '';
     $html = '';
@@ -1054,7 +1030,8 @@ function return_lock_unlock_icon($content, $id, $current_lock_status, $additiona
                 $html .= $key . '=' . $value . '&';
                 $html .= $key . '=' . $value . '&';
             }
             }
         }
         }
-        $html.= 'action=unlock&content='.$content.'&id='.$id.'">'.Display::return_icon('lock.png', get_lang('Unlock'), array(), ICON_SIZE_SMALL).'</a>';
+        $html.= 'action=unlock&content='.$content.'&id='.$id.'">'.
+            Display::return_icon('lock.png', get_lang('Unlock'), array(), ICON_SIZE_SMALL).'</a>';
     }
     }
     if ($current_lock_status == '0') {
     if ($current_lock_status == '0') {
         $html .= '<a href="'.api_get_self().'?'.api_get_cidreq().'&';
         $html .= '<a href="'.api_get_self().'?'.api_get_cidreq().'&';
@@ -1063,7 +1040,8 @@ function return_lock_unlock_icon($content, $id, $current_lock_status, $additiona
                 $html .= $key . '=' . $value . '&';
                 $html .= $key . '=' . $value . '&';
             }
             }
         }
         }
-        $html .= 'action=lock&content=' . $content . '&id=' . $id . '">' . Display::return_icon('unlock.png', get_lang('Lock'), array(), ICON_SIZE_SMALL) . '</a>';
+        $html .= 'action=lock&content=' . $content . '&id=' . $id . '">' .
+            Display::return_icon('unlock.png', get_lang('Lock'), array(), ICON_SIZE_SMALL) . '</a>';
     }
     }
     return $html;
     return $html;
 }
 }
@@ -1073,18 +1051,12 @@ function return_lock_unlock_icon($content, $id, $current_lock_status, $additiona
  *
  *
  * @param $content what is it that we want to make (in)visible: forum category, forum, thread, post
  * @param $content what is it that we want to make (in)visible: forum category, forum, thread, post
  * @param $id is the id of the item we want to display the icons for
  * @param $id is the id of the item we want to display the icons for
- * @param $list is an array of all the items. All items in this list should have an up and down icon except for the first (no up icon) and the last (no down icon)
+ * @param $list is an array of all the items. All items in this list should have
+ * an up and down icon except for the first (no up icon) and the last (no down icon)
  *          The key of this $list array is the id of the item.
  *          The key of this $list array is the id of the item.
  *
  *
  * @return void HTML
  * @return void HTML
- *
- * @author Patrick Cool <patrick.cool@UGent.be>, Ghent University
- * @version february 2006, dokeos 1.8
- */
-function display_up_down_icon($content, $id, $list)
-{
-    echo return_up_down_icon($content, $id, $list);
-}
+ **/
 function return_up_down_icon($content, $id, $list)
 function return_up_down_icon($content, $id, $list)
 {
 {
     $id = strval(intval($id));
     $id = strval(intval($id));
@@ -1140,7 +1112,7 @@ function change_visibility($content, $id, $target_visibility)
     $constants = array(
     $constants = array(
         'forumcategory' => TOOL_FORUM_CATEGORY,
         'forumcategory' => TOOL_FORUM_CATEGORY,
         'forum' => TOOL_FORUM,
         'forum' => TOOL_FORUM,
-        'thread' => TOOL_FORUM_THREAD
+        'thread' => TOOL_FORUM_THREAD,
     );
     );
     api_item_property_update(
     api_item_property_update(
         $_course,
         $_course,
@@ -1283,7 +1255,6 @@ function move_up_down($content, $direction, $id)
                 forum_category='" . Database::escape_string($forum_category) . "'
                 forum_category='" . Database::escape_string($forum_category) . "'
             ORDER BY forum_order $sort_direction";
             ORDER BY forum_order $sort_direction";
     }
     }
-    // echo $sql.'<br />';
     // Finding the items that need to be switched.
     // Finding the items that need to be switched.
     $result = Database::query($sql);
     $result = Database::query($sql);
     $found = false;
     $found = false;
@@ -1305,12 +1276,13 @@ function move_up_down($content, $direction, $id)
     // We do an extra check if we do not have illegal values. If your remove this if statment you will
     // We do an extra check if we do not have illegal values. If your remove this if statment you will
     // be able to mess with the sorting by refreshing the page over and over again.
     // be able to mess with the sorting by refreshing the page over and over again.
     if ($this_sort != '' && $next_sort != '' && $next_id != '' && $this_id != '') {
     if ($this_sort != '' && $next_sort != '' && $next_id != '' && $this_id != '') {
-        $sql_update1 = "UPDATE $table SET $sort_column='".Database::escape_string($this_sort)."'
-                        WHERE c_id = $course_id AND $id_column='".Database::escape_string($next_id)."'";
-        $sql_update2 = "UPDATE $table SET $sort_column='".Database::escape_string($next_sort)."'
-                        WHERE c_id = $course_id AND $id_column='".Database::escape_string($this_id)."'";
-        Database::query($sql_update1);
-        Database::query($sql_update2);
+        $sql = "UPDATE $table SET $sort_column='".Database::escape_string($this_sort)."'
+                WHERE c_id = $course_id AND $id_column='".Database::escape_string($next_id)."'";
+        Database::query($sql);
+
+        $sql = "UPDATE $table SET $sort_column='".Database::escape_string($next_sort)."'
+                WHERE c_id = $course_id AND $id_column='".Database::escape_string($this_id)."'";
+        Database::query($sql);
     }
     }
 
 
     return get_lang(ucfirst($content).'Moved');
     return get_lang(ucfirst($content).'Moved');
@@ -1332,6 +1304,7 @@ function class_visible_invisible($current_visibility_status)
         return 'class="invisible"';
         return 'class="invisible"';
     }
     }
 }
 }
+
 function return_visible_invisible($current_visibility_status)
 function return_visible_invisible($current_visibility_status)
 {
 {
     $current_visibility_status = intval($current_visibility_status);
     $current_visibility_status = intval($current_visibility_status);
@@ -1775,7 +1748,17 @@ function get_last_post_information($forum_id, $show_invisibles = false, $course_
     $table_item_property = Database :: get_course_table(TABLE_ITEM_PROPERTY);
     $table_item_property = Database :: get_course_table(TABLE_ITEM_PROPERTY);
     $table_users = Database :: get_main_table(TABLE_MAIN_USER);
     $table_users = Database :: get_main_table(TABLE_MAIN_USER);
 
 
-    $sql = "SELECT post.post_id, post.forum_id, post.poster_id, post.poster_name, post.post_date, users.lastname, users.firstname, post.visible, thread_properties.visibility AS thread_visibility, forum_properties.visibility AS forum_visibility
+    $sql = "SELECT
+                post.post_id,
+                post.forum_id,
+                post.poster_id,
+                post.poster_name,
+                post.post_date,
+                users.lastname,
+                users.firstname,
+                post.visible,
+                thread_properties.visibility AS thread_visibility,
+                forum_properties.visibility AS forum_visibility
             FROM
             FROM
                 $table_posts post,
                 $table_posts post,
                 $table_users users,
                 $table_users users,
@@ -1946,7 +1929,7 @@ function getPosts($threadId, $orderDirection = 'ASC', $recursive = false, $postI
     $posts = $qb->getQuery()->getResult();
     $posts = $qb->getQuery()->getResult();
 
 
     $depth++;
     $depth++;
-
+    /** @var \Chamilo\CourseBundle\Entity\CForumPost $post */
     foreach ($posts as $post) {
     foreach ($posts as $post) {
         $user = $em->find('ChamiloUserBundle:User', $post->getPosterId());
         $user = $em->find('ChamiloUserBundle:User', $post->getPosterId());
 
 
@@ -1993,7 +1976,8 @@ function getPosts($threadId, $orderDirection = 'ASC', $recursive = false, $postI
 /**
 /**
  * This function retrieves all the information of a post
  * This function retrieves all the information of a post
  *
  *
- * @param int $forum_id integer that indicates the forum
+ * @param int $post_id integer that indicates the forum
+ *
  * @return array returns
  * @return array returns
  *
  *
  * @author Patrick Cool <patrick.cool@UGent.be>, Ghent University
  * @author Patrick Cool <patrick.cool@UGent.be>, Ghent University
@@ -2019,7 +2003,8 @@ function get_post_information($post_id)
 /**
 /**
  * This function retrieves all the information of a thread
  * This function retrieves all the information of a thread
  *
  *
- * @param $forum_id integer that indicates the forum
+ * @param $thread_id integer that indicates the forum
+ *
  * @return array returns
  * @return array returns
  *
  *
  * @author Patrick Cool <patrick.cool@UGent.be>, Ghent University
  * @author Patrick Cool <patrick.cool@UGent.be>, Ghent University
@@ -2062,9 +2047,6 @@ function get_thread_users_details($thread_id)
     $t_course_user = Database :: get_main_table(TABLE_MAIN_COURSE_USER);
     $t_course_user = Database :: get_main_table(TABLE_MAIN_COURSE_USER);
     $t_session_rel_user = Database :: get_main_table(TABLE_MAIN_SESSION_COURSE_USER);
     $t_session_rel_user = Database :: get_main_table(TABLE_MAIN_SESSION_COURSE_USER);
 
 
-    $course_code = api_get_course_id();
-    $course_code = Database::escape_string($course_code);
-
     $course_id = api_get_course_int_id();
     $course_id = api_get_course_int_id();
 
 
     $is_western_name_order = api_is_western_name_order();
     $is_western_name_order = api_is_western_name_order();
@@ -2279,7 +2261,8 @@ function get_forum_information($forum_id, $courseId = 0)
 /**
 /**
  * This function retrieves all the information of a given forumcategory id
  * This function retrieves all the information of a given forumcategory id
  *
  *
- * @param $forum_id integer that indicates the forum
+ * @param $cat_id integer that indicates the forum
+ *
  * @return array returns if there are category or bool returns if there aren't category
  * @return array returns if there are category or bool returns if there aren't category
  * @author Patrick Cool <patrick.cool@UGent.be>, Ghent University
  * @author Patrick Cool <patrick.cool@UGent.be>, Ghent University
  * @version february 2006, dokeos 1.8
  * @version february 2006, dokeos 1.8
@@ -2307,7 +2290,7 @@ function get_forumcategory_information($cat_id)
 /**
 /**
  * This function counts the number of forums inside a given category
  * This function counts the number of forums inside a given category
  *
  *
- * @param $cat_id the id of the forum category
+ * @param int $cat_id the id of the forum category
  * @todo an additional parameter that takes the visibility into account. For instance $countinvisible=0 would return the number
  * @todo an additional parameter that takes the visibility into account. For instance $countinvisible=0 would return the number
  *      of visible forums, $countinvisible=1 would return the number of visible and invisible forums
  *      of visible forums, $countinvisible=1 would return the number of visible and invisible forums
  * @return int the number of forums inside the given category
  * @return int the number of forums inside the given category
@@ -2387,7 +2370,7 @@ function store_thread($current_forum, $values, $courseInfo = array(), $showMessa
                 'thread_qualify_max' => isset($values['numeric_calification']) ? $values['numeric_calification'] : '',
                 'thread_qualify_max' => isset($values['numeric_calification']) ? $values['numeric_calification'] : '',
                 'thread_weight' => isset($values['weight_calification']) ? $values['weight_calification'] : '',
                 'thread_weight' => isset($values['weight_calification']) ? $values['weight_calification'] : '',
                 'thread_peer_qualify' => isset($values['thread_peer_qualify']) ? $values['thread_peer_qualify'] : '',
                 'thread_peer_qualify' => isset($values['thread_peer_qualify']) ? $values['thread_peer_qualify'] : '',
-                'session_id' => api_get_session_id()
+                'session_id' => api_get_session_id(),
             ]
             ]
         );
         );
 
 
@@ -2740,7 +2723,8 @@ function show_add_post_form($current_forum, $forum_setting, $action = '', $id =
     // we can add this as default to the textarea.
     // we can add this as default to the textarea.
 
 
     if (($action == 'quote' || $action == 'replymessage') && isset($my_post)) {
     if (($action == 'quote' || $action == 'replymessage') && isset($my_post)) {
-        // We also need to put the parent_id of the post in a hidden form when we are quoting or replying to a message (<> reply to a thread !!!)
+        // We also need to put the parent_id of the post in a hidden form when
+        // we are quoting or replying to a message (<> reply to a thread !!!)
         $form->addElement('hidden', 'post_parent_id', intval($my_post));
         $form->addElement('hidden', 'post_parent_id', intval($my_post));
 
 
         // If we are replying or are quoting then we display a default title.
         // If we are replying or are quoting then we display a default title.
@@ -3111,7 +3095,7 @@ function store_reply($current_forum, $values)
                 'post_date' => $post_date,
                 'post_date' => $post_date,
                 'post_notification' => isset($values['post_notification']) ? $values['post_notification'] : null,
                 'post_notification' => isset($values['post_notification']) ? $values['post_notification'] : null,
                 'post_parent_id' => isset($values['post_parent_id']) ? $values['post_parent_id'] : null,
                 'post_parent_id' => isset($values['post_parent_id']) ? $values['post_parent_id'] : null,
-                'visible' => $visible
+                'visible' => $visible,
             ]
             ]
         );
         );
         if ($new_post_id) {
         if ($new_post_id) {
@@ -3126,7 +3110,7 @@ function store_reply($current_forum, $values)
                     editAttachedFile(
                     editAttachedFile(
                         array(
                         array(
                             'comment' => $_POST['file_comments'][$key],
                             'comment' => $_POST['file_comments'][$key],
-                            'post_id' => $new_post_id
+                            'post_id' => $new_post_id,
                         ),
                         ),
                         $id
                         $id
                     );
                     );
@@ -3221,12 +3205,12 @@ function show_edit_post_form($forum_setting, $current_post, $current_thread, $cu
         api_is_allowed_to_edit(null, true) ? array(
         api_is_allowed_to_edit(null, true) ? array(
             'ToolbarSet' => 'Forum',
             'ToolbarSet' => 'Forum',
             'Width' => '100%',
             'Width' => '100%',
-            'Height' => '400'
+            'Height' => '400',
         ) : array(
         ) : array(
             'ToolbarSet' => 'ForumStudent',
             'ToolbarSet' => 'ForumStudent',
             'Width' => '100%',
             'Width' => '100%',
             'Height' => '400',
             'Height' => '400',
-            'UserStatus' => 'student'
+            'UserStatus' => 'student',
         )
         )
     );
     );
     $form->addRule('post_text', get_lang('ThisFieldIsRequired'), 'required');
     $form->addRule('post_text', get_lang('ThisFieldIsRequired'), 'required');
@@ -3416,7 +3400,7 @@ function store_edit_post($values)
             'thread_title_qualify' => $values['calification_notebook_title'],
             'thread_title_qualify' => $values['calification_notebook_title'],
             'thread_qualify_max' => $values['numeric_calification'],
             'thread_qualify_max' => $values['numeric_calification'],
             'thread_weight' => $values['weight_calification'],
             'thread_weight' => $values['weight_calification'],
-            'thread_peer_qualify' => $values['thread_peer_qualify']
+            'thread_peer_qualify' => $values['thread_peer_qualify'],
         ];
         ];
         $where = ['c_id = ? AND thread_id = ?' => [$course_id, $values['thread_id']]];
         $where = ['c_id = ? AND thread_id = ?' => [$course_id, $values['thread_id']]];
 
 
@@ -3427,7 +3411,7 @@ function store_edit_post($values)
     $params = [
     $params = [
         'post_title' => $values['post_title'],
         'post_title' => $values['post_title'],
         'post_text' => $values['post_text'],
         'post_text' => $values['post_text'],
-        'post_notification' => isset($values['post_notification']) ? $values['post_notification'] : ''
+        'post_notification' => isset($values['post_notification']) ? $values['post_notification'] : '',
     ];
     ];
     $where = ['c_id = ? AND post_id = ?' => [$course_id, $values['post_id']]];
     $where = ['c_id = ? AND post_id = ?' => [$course_id, $values['post_id']]];
 
 
@@ -4509,7 +4493,7 @@ function add_forum_attachment_file($file_comment, $last_id)
                 'comment' => $safe_file_comment,
                 'comment' => $safe_file_comment,
                 'path' => $safe_new_file_name,
                 'path' => $safe_new_file_name,
                 'post_id' => $last_id,
                 'post_id' => $last_id,
-                'size' => intval($attachment['size'])
+                'size' => intval($attachment['size']),
             ]
             ]
         );
         );
 
 
@@ -4525,9 +4509,9 @@ function add_forum_attachment_file($file_comment, $last_id)
 
 
 /**
 /**
  * This function edits an attachment file into a forum
  * This function edits an attachment file into a forum
- * @param string  a comment about file
- * @param int Post Id
- * @param int attachment file Id
+ * @param string $file_comment  a comment about file
+ * @param int $post_id
+ * @param int $id_attach attachment file Id
  * @return void
  * @return void
  */
  */
 function edit_forum_attachment_file($file_comment, $post_id, $id_attach)
 function edit_forum_attachment_file($file_comment, $post_id, $id_attach)
@@ -4596,7 +4580,7 @@ function edit_forum_attachment_file($file_comment, $post_id, $id_attach)
 
 
 /**
 /**
  * Show a list with all the attachments according to the post's id
  * Show a list with all the attachments according to the post's id
- * @param the post's id
+ * @param int $post_id
  * @return array with the post info
  * @return array with the post info
  * @author Julio Montoya Dokeos
  * @author Julio Montoya Dokeos
  * @version avril 2008, dokeos 1.8.5
  * @version avril 2008, dokeos 1.8.5
@@ -4625,8 +4609,8 @@ function getAllAttachment($postId)
     $columns = array('iid', 'path', 'filename', 'comment');
     $columns = array('iid', 'path', 'filename', 'comment');
     $conditions = array(
     $conditions = array(
         'where' => array(
         'where' => array(
-            'c_id = ? AND post_id = ?' => array($courseId, $postId)
-        )
+            'c_id = ? AND post_id = ?' => array($courseId, $postId),
+        ),
     );
     );
     $array = Database::select(
     $array = Database::select(
         $columns,
         $columns,
@@ -4856,7 +4840,7 @@ function set_notification($content, $id, $add_only = false)
     if ($total <= 0) {
     if ($total <= 0) {
         $sql = "INSERT INTO $table_notification (c_id, $database_field, user_id)
         $sql = "INSERT INTO $table_notification (c_id, $database_field, user_id)
                 VALUES (".$course_id.", '".Database::escape_string($id)."','".intval($_user['user_id'])."')";
                 VALUES (".$course_id.", '".Database::escape_string($id)."','".intval($_user['user_id'])."')";
-        $result = Database::query($sql);
+        Database::query($sql);
         Session::erase('forum_notification');
         Session::erase('forum_notification');
         get_notifications_of_user(0, true);
         get_notifications_of_user(0, true);
 
 
@@ -5022,7 +5006,7 @@ function get_notifications_of_user($user_id = 0, $force = false)
 
 
 /**
 /**
  * This function counts the number of post inside a thread
  * This function counts the number of post inside a thread
- * @param   int Thread ID
+ * @param   int $thread_id
  * @return  int the number of post inside a thread
  * @return  int the number of post inside a thread
  * @author Jhon Hinojosa <jhon.hinojosa@dokeos.com>,
  * @author Jhon Hinojosa <jhon.hinojosa@dokeos.com>,
  * @version octubre 2008, dokeos 1.8
  * @version octubre 2008, dokeos 1.8
@@ -5043,8 +5027,9 @@ function count_number_of_post_in_thread($thread_id)
 
 
 /**
 /**
  * This function counts the number of post inside a thread user
  * This function counts the number of post inside a thread user
- * @param   int thread ID
- * @param   int user ID
+ * @param   int $thread_id
+ * @param   int $user_id
+ *
  * @return  int the number of post inside a thread user
  * @return  int the number of post inside a thread user
  */
  */
 function count_number_of_post_for_user_thread($thread_id, $user_id)
 function count_number_of_post_for_user_thread($thread_id, $user_id)
@@ -5067,7 +5052,8 @@ function count_number_of_post_for_user_thread($thread_id, $user_id)
 
 
 /**
 /**
  * This function counts the number of user register in course
  * This function counts the number of user register in course
- * @param   int Course ID
+ * @param   int $course_id Course ID
+ *
  * @return  int the number of user register in course
  * @return  int the number of user register in course
  * @author Jhon Hinojosa <jhon.hinojosa@dokeos.com>,
  * @author Jhon Hinojosa <jhon.hinojosa@dokeos.com>,
  * @version octubre 2008, dokeos 1.8
  * @version octubre 2008, dokeos 1.8
@@ -5105,9 +5091,10 @@ function get_statistical_information($thread_id, $user_id, $course_id)
 
 
 /**
 /**
  * This function return the posts inside a thread from a given user
  * This function return the posts inside a thread from a given user
- * @param   course code
- * @param   int Thread ID
- * @param   int User ID
+ * @param   string $course_code
+ * @param   int $thread_id
+ * @param   int $user_id
+ *
  * @return  int the number of post inside a thread
  * @return  int the number of post inside a thread
  * @author Jhon Hinojosa <jhon.hinojosa@dokeos.com>,
  * @author Jhon Hinojosa <jhon.hinojosa@dokeos.com>,
  * @version octubre 2008, dokeos 1.8
  * @version octubre 2008, dokeos 1.8
@@ -5177,8 +5164,9 @@ function get_name_thread_by_id($thread_id)
 
 
 /**
 /**
  * This function gets all the post written by an user
  * This function gets all the post written by an user
- * @param int user id
- * @param string db course name
+ * @param int $user_id
+ * @param string $course_code
+ *
  * @return string
  * @return string
  */
  */
 function get_all_post_from_user($user_id, $course_code)
 function get_all_post_from_user($user_id, $course_code)
@@ -5245,10 +5233,11 @@ function get_all_post_from_user($user_id, $course_code)
 }
 }
 
 
 /**
 /**
- * @param string
- * @param int
- * @param int
- * @param int
+ * @param string $course_code
+ * @param int $thread_id
+ * @param int $user_id
+ * @param int $limit
+ *
  * @return array
  * @return array
  */
  */
 function get_thread_user_post_limit($course_code, $thread_id, $user_id, $limit = 10)
 function get_thread_user_post_limit($course_code, $thread_id, $user_id, $limit = 10)
@@ -5278,10 +5267,10 @@ function get_thread_user_post_limit($course_code, $thread_id, $user_id, $limit =
 }
 }
 
 
 /**
 /**
- * @param string
- * @param int
- * @param int
- * @param int
+ * @param string $user_id
+ * @param int $courseId
+ * @param int $sessionId
+ *
  * @return array
  * @return array
  */
  */
 function getForumCreatedByUser($user_id, $courseId, $sessionId)
 function getForumCreatedByUser($user_id, $courseId, $sessionId)
@@ -5308,7 +5297,7 @@ function getForumCreatedByUser($user_id, $courseId, $sessionId)
             $forumList[] = array(
             $forumList[] = array(
                 $forumInfo['forum_title'],
                 $forumInfo['forum_title'],
                 api_get_local_time($forum['insert_date']),
                 api_get_local_time($forum['insert_date']),
-                api_get_local_time($forum['lastedit_date'])
+                api_get_local_time($forum['lastedit_date']),
             );
             );
         }
         }
     }
     }
@@ -5446,7 +5435,8 @@ function getAttachmentAjaxForm($forumId, $threadId, $postId)
 
 
 /**
 /**
  * Return a table where the attachments will be set
  * Return a table where the attachments will be set
- * @param null $postId Forum Post ID
+ * @param int $postId Forum Post ID
+ *
  * @return string The Forum Attachments Ajax Table
  * @return string The Forum Attachments Ajax Table
  */
  */
 function getAttachmentsAjaxTable($postId = null)
 function getAttachmentsAjaxTable($postId = null)
@@ -5514,11 +5504,12 @@ function getAttachmentsAjaxTable($postId = null)
 /**
 /**
  * Return an array of prepared attachment data to build forum attachment table
  * Return an array of prepared attachment data to build forum attachment table
  * Also, save this array into $_SESSION to do available the attachment data
  * Also, save this array into $_SESSION to do available the attachment data
- * @param $forumId
- * @param $threadId
- * @param null $postId
- * @param null $attachId
- * @param null $courseId
+ * @param int $forumId
+ * @param int $threadId
+ * @param int $postId
+ * @param int $attachId
+ * @param int $courseId
+ *
  * @return array
  * @return array
  */
  */
 function getAttachedFiles($forumId, $threadId, $postId = null, $attachId = null, $courseId = null)
 function getAttachedFiles($forumId, $threadId, $postId = null, $attachId = null, $courseId = null)
@@ -5595,12 +5586,13 @@ function getAttachedFiles($forumId, $threadId, $postId = null, $attachId = null,
 /**
 /**
  * Clear forum attachment data stored in $_SESSION,
  * Clear forum attachment data stored in $_SESSION,
  * If is not defined post, it will clear all forum attachment data from course
  * If is not defined post, it will clear all forum attachment data from course
- * @param null $postId -1 : Clear all attachments from course stored in $_SESSION
+ * @param int $postId -1 : Clear all attachments from course stored in $_SESSION
  *                      0 : Clear attachments from course, except from temporal post "0"
  *                      0 : Clear attachments from course, except from temporal post "0"
  *                          but without delete them from file system and database
  *                          but without delete them from file system and database
  *                     Other values : Clear attachments from course except specified post
  *                     Other values : Clear attachments from course except specified post
  *                          and delete them from file system and database
  *                          and delete them from file system and database
- * @param null $courseId : Course ID, if it is null, will use api_get_course_int_id()
+ * @param int $courseId : Course ID, if it is null, will use api_get_course_int_id()
+ *
  * @return array
  * @return array
  */
  */
 function clearAttachedFiles($postId = null, $courseId = null) {
 function clearAttachedFiles($postId = null, $courseId = null) {
@@ -5643,12 +5635,14 @@ function clearAttachedFiles($postId = null, $courseId = null) {
 
 
 /**
 /**
  * Returns an array of forum attachment ids into a course and forum post
  * Returns an array of forum attachment ids into a course and forum post
- * @param $postId
- * @param null $courseId
+ * @param int $postId
+ * @param int $courseId
+ *
  * @return array
  * @return array
  */
  */
-function getAttachmentIdsByPostId($postId, $courseId = null) {
-    // Init variables
+function getAttachmentIdsByPostId($postId, $courseId = null)
+{
+
     $array = array();
     $array = array();
     $courseId = intval($courseId);
     $courseId = intval($courseId);
     $postId = intval($postId);
     $postId = intval($postId);
@@ -5658,7 +5652,8 @@ function getAttachmentIdsByPostId($postId, $courseId = null) {
     }
     }
     if ($courseId > 0) {
     if ($courseId > 0) {
         $forumAttachmentTable = Database::get_course_table(TABLE_FORUM_ATTACHMENT);
         $forumAttachmentTable = Database::get_course_table(TABLE_FORUM_ATTACHMENT);
-        $sql = "SELECT id FROM $forumAttachmentTable WHERE c_id = $courseId AND post_id = $postId";
+        $sql = "SELECT id FROM $forumAttachmentTable
+                WHERE c_id = $courseId AND post_id = $postId";
         $result = Database::query($sql);
         $result = Database::query($sql);
         if ($result !== false && Database::num_rows($result) > 0) {
         if ($result !== false && Database::num_rows($result) > 0) {
             while ($row = Database::fetch_array($result,'ASSOC')) {
             while ($row = Database::fetch_array($result,'ASSOC')) {

+ 0 - 1
main/forum/forumsearch.php

@@ -69,7 +69,6 @@ if ($origin == 'group') {
     $interbreadcrumb[] = array('url' => 'forumsearch.php?'.api_get_cidreq(),'name' => get_lang('ForumSearch'));
     $interbreadcrumb[] = array('url' => 'forumsearch.php?'.api_get_cidreq(),'name' => get_lang('ForumSearch'));
 } else {
 } else {
     $interbreadcrumb[] = array('url' => 'index.php?'.api_get_cidreq(), 'name' => $nameTools);
     $interbreadcrumb[] = array('url' => 'index.php?'.api_get_cidreq(), 'name' => $nameTools);
-    //$interbreadcrumb[] = array('url' => 'forumsearch.php', 'name' => );
     $nameTools = get_lang('ForumSearch');
     $nameTools = get_lang('ForumSearch');
 }
 }
 
 

+ 8 - 5
main/forum/iframe_thread.php

@@ -22,8 +22,6 @@
  */
  */
 require_once '../inc/global.inc.php';
 require_once '../inc/global.inc.php';
 
 
-/* ACCESS RIGHTS */
-
 // A notice for unauthorized people.
 // A notice for unauthorized people.
 api_protect_course_script(true);
 api_protect_course_script(true);
 $nameTools = get_lang('ToolForum');
 $nameTools = get_lang('ToolForum');
@@ -42,9 +40,14 @@ require_once 'forumfunction.inc.php';
 // We are getting all the information about the current forum and forum category.
 // We are getting all the information about the current forum and forum category.
 // Note pcool: I tried to use only one sql statement (and function) for this,
 // Note pcool: I tried to use only one sql statement (and function) for this,
 // but the problem is that the visibility of the forum AND forum cateogory are stored in the item_property table.
 // but the problem is that the visibility of the forum AND forum cateogory are stored in the item_property table.
-$current_thread=get_thread_information($_GET['thread']); // Note: this has to be validated that it is an existing thread.
-$current_forum=get_forum_information($current_thread['forum_id']); // Note: this has to be validated that it is an existing forum.
-$current_forum_category = get_forumcategory_information($current_forum['forum_category']);
+$current_thread = get_thread_information(
+    $_GET['thread']
+); // Note: this has to be validated that it is an existing thread.
+$current_forum = get_forum_information($current_thread['forum_id']);
+// Note: this has to be validated that it is an existing forum.
+$current_forum_category = get_forumcategory_information(
+    $current_forum['forum_category']
+);
 
 
 /* Is the user allowed here? */
 /* Is the user allowed here? */
 
 

+ 36 - 14
main/forum/viewpost.php

@@ -59,9 +59,18 @@ if (!empty($gradebook) && $gradebook == 'view') {
 if ($origin == 'learnpath') {
 if ($origin == 'learnpath') {
     Display::display_reduced_header();
     Display::display_reduced_header();
 } else {
 } else {
-    $interbreadcrumb[] = array('url' => 'index.php?gradebook='.$gradebook.'&search='.Security::remove_XSS(urlencode($_GET['search'])), 'name' => $nameTools);
-    $interbreadcrumb[] = array('url' => 'viewforumcategory.php?forumcategory='.$current_forum_category['cat_id'].'&search='.Security::remove_XSS(urlencode($_GET['search'])), 'name' => prepare4display($current_forum_category['cat_title']));
-    $interbreadcrumb[] = array('url' => 'viewforum.php?forum='.Security::remove_XSS($_GET['forum']).'&origin='.$origin.'&search='.Security::remove_XSS(urlencode($_GET['search'])), 'name' => prepare4display($current_forum['forum_title']));
+    $interbreadcrumb[] = array(
+        'url' => 'index.php?'.api_get_cidreq().'&search='.Security::remove_XSS(urlencode($_GET['search'])),
+        'name' => $nameTools,
+    );
+    $interbreadcrumb[] = array(
+        'url' => 'viewforumcategory.php?'.api_get_cidreq().'&forumcategory='.$current_forum_category['cat_id'].'&search='.Security::remove_XSS(urlencode($_GET['search'])),
+        'name' => prepare4display($current_forum_category['cat_title']),
+    );
+    $interbreadcrumb[] = array(
+        'url' => 'viewforum.php?'.api_get_cidreq().'&forum='.Security::remove_XSS($_GET['forum']).'&origin='.$origin.'&search='.Security::remove_XSS(urlencode($_GET['search'])),
+        'name' => prepare4display($current_forum['forum_title']),
+    );
 
 
     // the last element of the breadcrumb navigation is already set in interbreadcrumb, so give empty string
     // the last element of the breadcrumb navigation is already set in interbreadcrumb, so give empty string
     Display :: display_header('');
     Display :: display_header('');
@@ -72,7 +81,9 @@ if ($origin == 'learnpath') {
 
 
 // if the user is not a course administrator and the forum is hidden
 // if the user is not a course administrator and the forum is hidden
 // then the user is not allowed here.
 // then the user is not allowed here.
-if (!api_is_allowed_to_edit(false, true) AND ($current_forum['visibility'] == 0 OR $current_thread['visibility'] == 0)) {
+if (!api_is_allowed_to_edit(false, true) &&
+    ($current_forum['visibility'] == 0 || $current_thread['visibility'] == 0)
+) {
     $forum_allow = forum_not_allowed_here();
     $forum_allow = forum_not_allowed_here();
     if ($forum_allow === false) {
     if ($forum_allow === false) {
         exit;
         exit;
@@ -81,10 +92,15 @@ if (!api_is_allowed_to_edit(false, true) AND ($current_forum['visibility'] == 0
 
 
 /* Actions */
 /* Actions */
 
 
-if ($_GET['action'] == 'delete' && isset($_GET['content']) && isset($_GET['id']) && api_is_allowed_to_edit(false, true)) {
+if ($_GET['action'] == 'delete' &&
+    isset($_GET['content']) &&
+    isset($_GET['id']) && api_is_allowed_to_edit(false, true)
+) {
     $message = delete_post($_GET['id']);
     $message = delete_post($_GET['id']);
 }
 }
-if (($_GET['action'] == 'invisible' || $_GET['action'] == 'visible') && isset($_GET['id']) && api_is_allowed_to_edit(false, true)) {
+if (($_GET['action'] == 'invisible' || $_GET['action'] == 'visible') &&
+    isset($_GET['id']) && api_is_allowed_to_edit(false, true)
+) {
     $message = approve_post($_GET['id'], $_GET['action']);
     $message = approve_post($_GET['id'], $_GET['action']);
 }
 }
 if ($_GET['action'] == 'move' && isset($_GET['post'])) {
 if ($_GET['action'] == 'move' && isset($_GET['post'])) {
@@ -105,23 +121,29 @@ if ($message != 'PostDeletedSpecial') {
     /* Action Links */
     /* Action Links */
 
 
     echo '<div style="float:right;">';
     echo '<div style="float:right;">';
-    $my_url = '<a href="viewthread.php?'.api_get_cidreq().'&gidReq='.Security::remove_XSS($_GET['gidReq']).'&forum='.Security::remove_XSS($_GET['forum']).'&thread='.Security::remove_XSS($_GET['thread']).'&origin='.$origin.'&gradebook='.$gradebook.'&search='.Security::remove_XSS(urlencode($_GET['search']));
+    $my_url = '<a href="viewthread.php?'.api_get_cidreq().'&forum='.Security::remove_XSS($_GET['forum']).'&thread='.Security::remove_XSS($_GET['thread']).'&origin='.$origin.'&gradebook='.$gradebook.'&search='.Security::remove_XSS(urlencode($_GET['search']));
     echo $my_url.'&view=flat&origin='.$origin.'">'.get_lang('FlatView').'</a> | ';
     echo $my_url.'&view=flat&origin='.$origin.'">'.get_lang('FlatView').'</a> | ';
     echo $my_url.'&view=threaded&origin='.$origin.'">'.get_lang('ThreadedView').'</a> | ';
     echo $my_url.'&view=threaded&origin='.$origin.'">'.get_lang('ThreadedView').'</a> | ';
     echo $my_url.'&view=nested&origin='.$origin.'">'.get_lang('NestedView').'</a>';
     echo $my_url.'&view=nested&origin='.$origin.'">'.get_lang('NestedView').'</a>';
     $my_url = null;
     $my_url = null;
     echo '</div>';
     echo '</div>';
-    // The reply to thread link should only appear when the forum_category is not locked AND the forum is not locked AND the thread is not locked.
+    // The reply to thread link should only appear when the forum_category is
+    // not locked AND the forum is not locked AND the thread is not locked.
     // If one of the three levels is locked then the link should not be displayed.
     // If one of the three levels is locked then the link should not be displayed.
-    if (($current_forum_category && $current_forum_category['locked'] == 0) AND $current_forum['locked'] == 0 AND $current_thread['locked'] == 0 OR api_is_allowed_to_edit(false, true)) {
+    if (($current_forum_category && $current_forum_category['locked'] == 0) &&
+        $current_forum['locked'] == 0 && $current_thread['locked'] == 0 || api_is_allowed_to_edit(false, true)
+    ) {
         // The link should only appear when the user is logged in or when anonymous posts are allowed.
         // The link should only appear when the user is logged in or when anonymous posts are allowed.
-        if ($_user['user_id'] OR ($current_forum['allow_anonymous'] == 1 AND !$_user['user_id'])) {
+        if ($_user['user_id'] || ($current_forum['allow_anonymous'] == 1 && !$_user['user_id'])) {
             // reply link
             // reply link
-            echo '<a href="reply.php?'.api_get_cidreq().'&gidReq='.Security::remove_XSS($_GET['gidReq']).'&forum='.Security::remove_XSS($_GET['forum']).'&thread='.Security::remove_XSS($_GET['thread']).'&action=replythread&origin='.$origin.'">'.get_lang('ReplyToThread').'</a>';
+            echo '<a href="reply.php?'.api_get_cidreq().'&forum='.Security::remove_XSS($_GET['forum']).'&thread='.Security::remove_XSS($_GET['thread']).'&action=replythread&origin='.$origin.'">'.get_lang('ReplyToThread').'</a>';
 
 
             // new thread link
             // new thread link
-            if (api_is_allowed_to_edit(false, true) OR ($current_forum['allow_new_threads'] == 1 AND isset($_user['user_id'])) OR ($current_forum['allow_new_threads'] == 1 AND !isset($_user['user_id']) AND $current_forum['allow_anonymous'] == 1)) {
-                if ($current_forum['locked'] <> 1 AND $current_forum['locked'] <> 1) {
+            if (api_is_allowed_to_edit(false, true) ||
+                ($current_forum['allow_new_threads'] == 1 && isset($_user['user_id'])) ||
+                ($current_forum['allow_new_threads'] == 1 && !isset($_user['user_id']) && $current_forum['allow_anonymous'] == 1)
+            ) {
+                if ($current_forum['locked'] <> 1 && $current_forum['locked'] <> 1) {
                     echo '&nbsp;&nbsp;';
                     echo '&nbsp;&nbsp;';
                     /*echo '<a href="newthread.php?'.api_get_cidreq().'&forum='.Security::remove_XSS($_GET['forum']).$origin_string.'">'.Display::return_icon('new_thread.png','','',ICON_SIZE_MEDIUM).'</a>';*/
                     /*echo '<a href="newthread.php?'.api_get_cidreq().'&forum='.Security::remove_XSS($_GET['forum']).$origin_string.'">'.Display::return_icon('new_thread.png','','',ICON_SIZE_MEDIUM).'</a>';*/
                 } else {
                 } else {
@@ -141,7 +163,7 @@ if ($message != 'PostDeletedSpecial') {
         $viewmode = $_SESSION['view'];
         $viewmode = $_SESSION['view'];
     }
     }
 
 
-    $viewmode_whitelist=array('flat', 'threaded', 'nested');
+    $viewmode_whitelist = array('flat', 'threaded', 'nested');
     if (isset($_GET['view']) && in_array($_GET['view'], $viewmode_whitelist)) {
     if (isset($_GET['view']) && in_array($_GET['view'], $viewmode_whitelist)) {
         $viewmode = Database::escape_string($_GET['view']);
         $viewmode = Database::escape_string($_GET['view']);
         $_SESSION['view'] = $viewmode;
         $_SESSION['view'] = $viewmode;

+ 1 - 1
main/forum/viewthread_threaded.inc.php

@@ -296,7 +296,7 @@ if (
             )."</a>";
             )."</a>";
     }
     }
 
 
-    display_visible_invisible_icon(
+    echo return_visible_invisible_icon(
         'post',
         'post',
         $rows[$display_post_id]['post_id'],
         $rows[$display_post_id]['post_id'],
         $rows[$display_post_id]['visible'],
         $rows[$display_post_id]['visible'],

+ 8 - 1
main/gradebook/gradebook_add_link.php

@@ -23,7 +23,14 @@ $session_id = api_get_session_id();
 $typeSelected = isset($_GET['typeselected']) ? intval($_GET['typeselected']) : null;
 $typeSelected = isset($_GET['typeselected']) ? intval($_GET['typeselected']) : null;
 
 
 if ($session_id == 0) {
 if ($session_id == 0) {
-    $all_categories = Category::load(null, null, api_get_course_id(), null, null, $session_id);
+    $all_categories = Category::load(
+        null,
+        null,
+        api_get_course_id(),
+        null,
+        null,
+        $session_id
+    );
 } else {
 } else {
     $all_categories = Category::load_session_categories(null, $session_id);
     $all_categories = Category::load_session_categories(null, $session_id);
 }
 }

+ 10 - 7
main/gradebook/gradebook_showlog_eval.php

@@ -27,16 +27,19 @@ Display :: display_header('');
 echo Display::page_header(get_lang('GradebookQualifyLog'));
 echo Display::page_header(get_lang('GradebookQualifyLog'));
 
 
 $t_linkeval_log = Database :: get_main_table(TABLE_MAIN_GRADEBOOK_LINKEVAL_LOG);
 $t_linkeval_log = Database :: get_main_table(TABLE_MAIN_GRADEBOOK_LINKEVAL_LOG);
-$t_user=	 Database :: get_main_table(TABLE_MAIN_USER);
+$t_user = Database :: get_main_table(TABLE_MAIN_USER);
 $visible_log=Security::remove_XSS($_GET['visiblelog']);
 $visible_log=Security::remove_XSS($_GET['visiblelog']);
 
 
 $evaledit = Evaluation :: load($visible_log);
 $evaledit = Evaluation :: load($visible_log);
-$sql="SELECT le.name,le.description,le.weight,le.visible,le.type,le.created_at,us.username FROM ".$t_linkeval_log." le INNER JOIN ".$t_user." us
-      ON le.user_id_log=us.user_id where id_linkeval_log=".$evaledit[0]->get_id()." and type='evaluation';";
-$result=Database::query($sql);
-$list_info=array();
-while ($row=Database::fetch_row($result)) {
-    $list_info[]=$row;
+$sql = "SELECT le.name,le.description,le.weight,le.visible,le.type,le.created_at,us.username
+        FROM ".$t_linkeval_log." le
+        INNER JOIN ".$t_user." us
+        ON le.user_id_log=us.user_id
+        WHERE id_linkeval_log=".$evaledit[0]->get_id()." AND type='evaluation';";
+$result = Database::query($sql);
+$list_info = array();
+while ($row = Database::fetch_row($result)) {
+    $list_info[] = $row;
 }
 }
 
 
 foreach($list_info as $key => $info_log) {
 foreach($list_info as $key => $info_log) {

+ 1 - 1
main/gradebook/gradebook_statistics.php

@@ -61,7 +61,7 @@ if (!$displayscore->is_custom() || empty($displays)) {
     // find the region with the most scores, this is 100% of the bar
     // find the region with the most scores, this is 100% of the bar
 
 
     $highest_ratio = 0;
     $highest_ratio = 0;
-    foreach($keys as $key) {
+    foreach ($keys as $key) {
         if ($nr_items[$key] > $highest_ratio) {
         if ($nr_items[$key] > $highest_ratio) {
             $highest_ratio = $nr_items[$key];
             $highest_ratio = $nr_items[$key];
         }
         }

+ 0 - 2
main/inc/email_editor.php

@@ -10,8 +10,6 @@
  * @author Julio Montoya <gugli100@gmail.com> Updating form with formvalidator
  * @author Julio Montoya <gugli100@gmail.com> Updating form with formvalidator
  */
  */
 
 
-// name of the language file that needs to be included
-
 use ChamiloSession as Session;
 use ChamiloSession as Session;
 
 
 require_once '../inc/global.inc.php';
 require_once '../inc/global.inc.php';

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

@@ -5690,13 +5690,13 @@ function api_is_element_in_the_session($tool, $element_id, $session_id = null) {
     return false;
     return false;
 }
 }
 
 
-
 /**
 /**
  * Replaces "forbidden" characters in a filename string.
  * Replaces "forbidden" characters in a filename string.
  *
  *
  * @param string $filename
  * @param string $filename
  * @param int $length
  * @param int $length
  * @param bool $file_name
  * @param bool $file_name
+ *
  * @return string
  * @return string
  */
  */
 function api_replace_dangerous_char($filename)
 function api_replace_dangerous_char($filename)

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

@@ -638,6 +638,7 @@ class Auth
             $form->addElement('text', 'course_registration_code');
             $form->addElement('text', 'course_registration_code');
             $form->addButton(get_lang('SubmitRegistrationCode'));
             $form->addButton(get_lang('SubmitRegistrationCode'));
             $content = $form->returnForm();
             $content = $form->returnForm();
+
             return array('message' => $message, 'content' => $content);
             return array('message' => $message, 'content' => $content);
         }
         }
     }
     }
@@ -655,7 +656,7 @@ class Auth
 
 
         $_sessions = $qb->select('s')
         $_sessions = $qb->select('s')
             ->from('ChamiloCoreBundle:Session', 's');
             ->from('ChamiloCoreBundle:Session', 's');
-        
+
         if (!empty($limit)) {
         if (!empty($limit)) {
             $_sessions->setFirstResult($limit['start'])
             $_sessions->setFirstResult($limit['start'])
                 ->setMaxResults($limit['length']);
                 ->setMaxResults($limit['length']);
@@ -806,5 +807,4 @@ SQL;
 
 
         return $sessionsToBrowse;
         return $sessionsToBrowse;
     }
     }
-
 }
 }

+ 26 - 16
main/inc/lib/chat.lib.php

@@ -28,13 +28,20 @@ class Chat extends Model
      */
      */
     function get_user_status()
     function get_user_status()
     {
     {
-        $status = UserManager::get_extra_user_data_by_field(api_get_user_id(), 'user_chat_status', false, true);
+        $status = UserManager::get_extra_user_data_by_field(
+            api_get_user_id(),
+            'user_chat_status',
+            false,
+            true
+        );
+
         return $status['user_chat_status'];
         return $status['user_chat_status'];
     }
     }
 
 
     /**
     /**
     * Set user chat status
     * Set user chat status
     * @param int 0 if disconnected, 1 if connected
     * @param int 0 if disconnected, 1 if connected
+     *
     * @return void
     * @return void
     */
     */
     public function setUserStatus($status)
     public function setUserStatus($status)
@@ -68,13 +75,10 @@ class Chat extends Model
     public function heartbeat()
     public function heartbeat()
     {
     {
         $to_user_id = api_get_user_id();
         $to_user_id = api_get_user_id();
-        $minutes = 60;
-        $now = time() - $minutes * 60;
-        $now = api_get_utc_datetime($now);
 
 
-        //OR  sent > '$now'
         $sql = "SELECT * FROM ".$this->table."
         $sql = "SELECT * FROM ".$this->table."
-                WHERE to_user = '".intval($to_user_id)."' AND ( recd  = 0 ) ORDER BY id ASC";
+                WHERE to_user = '".intval($to_user_id)."' AND ( recd  = 0 )
+                ORDER BY id ASC";
         $result = Database::query($sql);
         $result = Database::query($sql);
 
 
         $chat_list = array();
         $chat_list = array();
@@ -132,7 +136,8 @@ class Chat extends Model
             }
             }
         }
         }
 
 
-        $sql = "UPDATE ".$this->table." SET recd = 1 WHERE to_user = '".$to_user_id."' AND recd = 0";
+        $sql = "UPDATE ".$this->table." SET recd = 1
+                WHERE to_user = '".$to_user_id."' AND recd = 0";
         Database::query($sql);
         Database::query($sql);
 
 
         if ($items != '') {
         if ($items != '') {
@@ -141,18 +146,18 @@ class Chat extends Model
         echo json_encode(array('items' => $items));
         echo json_encode(array('items' => $items));
     }
     }
 
 
-    /*
-     * Returns an array of messages inside a chat session with a specific user
-     * @param int The ID of the user with whom the current user is chatting
-     * @return array Messages list
-     */
-
+    /**
+    * Returns an array of messages inside a chat session with a specific user
+    * @param int The ID of the user with whom the current user is chatting
+    * @return array Messages list
+    */
     public function box_session($user_id)
     public function box_session($user_id)
     {
     {
         $items = array();
         $items = array();
         if (isset($_SESSION['chatHistory'][$user_id])) {
         if (isset($_SESSION['chatHistory'][$user_id])) {
             $items = $_SESSION['chatHistory'][$user_id];
             $items = $_SESSION['chatHistory'][$user_id];
         }
         }
+
         return $items;
         return $items;
     }
     }
 
 
@@ -184,7 +189,10 @@ class Chat extends Model
         $sanitize =  true
         $sanitize =  true
     )
     )
     {
     {
-        $user_friend_relation = SocialManager::get_relation_between_contacts($from_user_id, $to_user_id);
+        $user_friend_relation = SocialManager::get_relation_between_contacts(
+            $from_user_id,
+            $to_user_id
+        );
         if ($user_friend_relation == USER_RELATION_TYPE_FRIEND) {
         if ($user_friend_relation == USER_RELATION_TYPE_FRIEND) {
 
 
             $user_info = api_get_user_info($to_user_id, true);
             $user_info = api_get_user_info($to_user_id, true);
@@ -197,7 +205,7 @@ class Chat extends Model
             } else {
             } else {
                 $messagesan = $message;
                 $messagesan = $message;
             }
             }
-            
+
             error_log(print_r($sanitize) . '----' . $messagesan);
             error_log(print_r($sanitize) . '----' . $messagesan);
 
 
             if (!isset($_SESSION['chatHistory'][$to_user_id])) {
             if (!isset($_SESSION['chatHistory'][$to_user_id])) {
@@ -250,7 +258,8 @@ class Chat extends Model
 
 
     /**
     /**
      * Filter chat messages to avoid XSS or other JS
      * Filter chat messages to avoid XSS or other JS
-     * @param string Unfiltered message
+     * @param string $text Unfiltered message
+     *
      * @return string Filterd mssage
      * @return string Filterd mssage
      */
      */
     public function sanitize($text)
     public function sanitize($text)
@@ -259,6 +268,7 @@ class Chat extends Model
         $text = str_replace("\n\r", "\n", $text);
         $text = str_replace("\n\r", "\n", $text);
         $text = str_replace("\r\n", "\n", $text);
         $text = str_replace("\r\n", "\n", $text);
         $text = str_replace("\n", "<br>", $text);
         $text = str_replace("\n", "<br>", $text);
+
         return $text;
         return $text;
     }
     }
 
 

+ 46 - 43
main/inc/lib/course.lib.php

@@ -332,8 +332,8 @@ class CourseManager
     {
     {
 
 
         $result = Database::fetch_array(
         $result = Database::fetch_array(
-            Database::query(
-                "SELECT * FROM " . Database::get_main_table(TABLE_MAIN_COURSE_USER) . "
+            Database::query("
+                SELECT * FROM " . Database::get_main_table(TABLE_MAIN_COURSE_USER) . "
                 WHERE
                 WHERE
                     c_id  = '" . intval($courseId). "' AND
                     c_id  = '" . intval($courseId). "' AND
                     user_id = " . intval($userId)
                     user_id = " . intval($userId)
@@ -347,6 +347,7 @@ class CourseManager
      * @param int  $userId
      * @param int  $userId
      * @param int  $courseId
      * @param int  $courseId
      * @param bool $isTutor
      * @param bool $isTutor
+     *
      * @return bool
      * @return bool
      */
      */
     public static function updateUserCourseTutor($userId, $courseId, $isTutor)
     public static function updateUserCourseTutor($userId, $courseId, $isTutor)
@@ -373,14 +374,18 @@ class CourseManager
     /**
     /**
      * @param int $user_id
      * @param int $user_id
      * @param string $course_code
      * @param string $course_code
+     *
      * @return mixed
      * @return mixed
      */
      */
     public static function get_tutor_in_course_status($user_id, $course_code)
     public static function get_tutor_in_course_status($user_id, $course_code)
     {
     {
         $result = Database::fetch_array(
         $result = Database::fetch_array(
-            Database::query(
-                "SELECT is_tutor FROM " . Database::get_main_table(TABLE_MAIN_COURSE_USER) . "
-                WHERE course_code = '" . Database::escape_string($course_code) . "' AND user_id = " . intval($user_id)
+            Database::query("
+                SELECT is_tutor
+                FROM " . Database::get_main_table(TABLE_MAIN_COURSE_USER) . "
+                WHERE
+                    course_code = '" . Database::escape_string($course_code) . "' AND
+                    user_id = " . intval($user_id)
             )
             )
         );
         );
 
 
@@ -812,9 +817,11 @@ class CourseManager
     public static function course_code_exists($wanted_course_code)
     public static function course_code_exists($wanted_course_code)
     {
     {
         $wanted_course_code = Database::escape_string($wanted_course_code);
         $wanted_course_code = Database::escape_string($wanted_course_code);
-        $sql = "SELECT COUNT(*) as number FROM " . Database::get_main_table(TABLE_MAIN_COURSE) . "
+        $sql = "SELECT COUNT(*) as number
+                FROM " . Database::get_main_table(TABLE_MAIN_COURSE) . "
                 WHERE code = '$wanted_course_code' OR visual_code = '$wanted_course_code'";
                 WHERE code = '$wanted_course_code' OR visual_code = '$wanted_course_code'";
         $result = Database::fetch_array(Database::query($sql));
         $result = Database::fetch_array(Database::query($sql));
+
         return $result['number'] > 0;
         return $result['number'] > 0;
     }
     }
 
 
@@ -1232,7 +1239,8 @@ class CourseManager
             }
             }
         }
         }
 
 
-        // if the $order_by does not contain 'ORDER BY' we have to check if it is a valid field that can be sorted on
+        // if the $order_by does not contain 'ORDER BY'
+        // we have to check if it is a valid field that can be sorted on
         if (!strstr($order_by, 'ORDER BY')) {
         if (!strstr($order_by, 'ORDER BY')) {
             if (!empty($order_by)) {
             if (!empty($order_by)) {
                 $order_by = 'ORDER BY ' . $order_by;
                 $order_by = 'ORDER BY ' . $order_by;
@@ -1625,7 +1633,8 @@ class CourseManager
 
 
         $multiple_access_url = api_get_multiple_access_url();
         $multiple_access_url = api_get_multiple_access_url();
         if ($multiple_access_url) {
         if ($multiple_access_url) {
-            $sql .= ' LEFT JOIN ' . Database::get_main_table(TABLE_MAIN_ACCESS_URL_REL_USER) . '  au ON (au.user_id = user.user_id) ';
+            $sql .= ' LEFT JOIN ' . Database::get_main_table(TABLE_MAIN_ACCESS_URL_REL_USER) . '  au
+                      ON (au.user_id = user.user_id) ';
         }
         }
 
 
         $sql .= ' WHERE ' . implode(' OR ', $where);
         $sql .= ' WHERE ' . implode(' OR ', $where);
@@ -1711,7 +1720,6 @@ class CourseManager
         $includeInvitedUsers = true,
         $includeInvitedUsers = true,
         $groupId = 0
         $groupId = 0
     ) {
     ) {
-
         $userTable = Database::get_main_table(TABLE_MAIN_USER);
         $userTable = Database::get_main_table(TABLE_MAIN_USER);
         $session_id = intval($session_id);
         $session_id = intval($session_id);
         $course_code = Database::escape_string($course_code);
         $course_code = Database::escape_string($course_code);
@@ -1722,7 +1730,8 @@ class CourseManager
         if ($session_id == 0) {
         if ($session_id == 0) {
             if (empty($groupId)) {
             if (empty($groupId)) {
                 // students directly subscribed to the course
                 // students directly subscribed to the course
-                $sql = "SELECT * FROM ".Database::get_main_table(TABLE_MAIN_COURSE_USER)." cu
+                $sql = "SELECT *
+                        FROM ".Database::get_main_table(TABLE_MAIN_COURSE_USER)." cu
                         INNER JOIN $userTable u
                         INNER JOIN $userTable u
                         ON cu.user_id = u.user_id
                         ON cu.user_id = u.user_id
                         WHERE c_id = '$courseId' AND cu.status = ".STUDENT;
                         WHERE c_id = '$courseId' AND cu.status = ".STUDENT;
@@ -1756,7 +1765,8 @@ class CourseManager
                 $joinSession = "INNER JOIN " . Database::get_main_table(TABLE_MAIN_SESSION) . " s";
                 $joinSession = "INNER JOIN " . Database::get_main_table(TABLE_MAIN_SESSION) . " s";
             }
             }
 
 
-            $sql_query = "SELECT * FROM " . Database::get_main_table(TABLE_MAIN_SESSION_COURSE_USER) . " scu
+            $sql_query = "SELECT *
+                          FROM " . Database::get_main_table(TABLE_MAIN_SESSION_COURSE_USER) . " scu
                           $joinSession
                           $joinSession
                           INNER JOIN $userTable u ON scu.user_id = u.user_id
                           INNER JOIN $userTable u ON scu.user_id = u.user_id
                           WHERE scu.c_id = '$courseId' AND scu.status <> 2";
                           WHERE scu.c_id = '$courseId' AND scu.status <> 2";
@@ -1864,6 +1874,7 @@ class CourseManager
      * This function returns information about coachs from a course in session
      * This function returns information about coachs from a course in session
      * @param int $session_id
      * @param int $session_id
      * @param int $courseId
      * @param int $courseId
+     *
      * @return array    - array containing user_id, lastname, firstname, username
      * @return array    - array containing user_id, lastname, firstname, username
      *
      *
      */
      */
@@ -2066,7 +2077,8 @@ class CourseManager
             return;
             return;
         }
         }
 
 
-        $sql = "SELECT * FROM $table_course WHERE code = '" . $codeFiltered . "'";
+        $sql = "SELECT * FROM $table_course
+                WHERE code = '" . $codeFiltered . "'";
         $res = Database::query($sql);
         $res = Database::query($sql);
         $course = Database::fetch_array($res);
         $course = Database::fetch_array($res);
         $courseId = $course['id'];
         $courseId = $course['id'];
@@ -2087,7 +2099,6 @@ class CourseManager
             $course_tables = AddCourse::get_course_tables();
             $course_tables = AddCourse::get_course_tables();
 
 
             // Cleaning group categories
             // Cleaning group categories
-
             $groupCategories = GroupManager::get_categories($course['code']);
             $groupCategories = GroupManager::get_categories($course['code']);
 
 
             if (!empty($groupCategories)) {
             if (!empty($groupCategories)) {
@@ -2118,9 +2129,6 @@ class CourseManager
                 rename($course_dir, $archive_dir);
                 rename($course_dir, $archive_dir);
             }
             }
 
 
-            // Unsubscribe all classes from the course
-            /*$sql = "DELETE FROM $table_course_class WHERE course_code='".$code."'";
-            Database::query($sql);*/
             // Unsubscribe all users from the course
             // Unsubscribe all users from the course
             $sql = "DELETE FROM $table_course_user WHERE c_id='" . $courseId . "'";
             $sql = "DELETE FROM $table_course_user WHERE c_id='" . $courseId . "'";
             Database::query($sql);
             Database::query($sql);
@@ -2326,10 +2334,13 @@ class CourseManager
     public static function course_exists($course_code, $accept_virtual = false)
     public static function course_exists($course_code, $accept_virtual = false)
     {
     {
         if ($accept_virtual === true) {
         if ($accept_virtual === true) {
-            $sql = 'SELECT 1 FROM ' . Database::get_main_table(TABLE_MAIN_COURSE) . ' WHERE code="' . Database::escape_string($course_code) . '" OR visual_code="' . Database::escape_string($course_code) . '"';
+            $sql = 'SELECT 1 FROM ' . Database::get_main_table(TABLE_MAIN_COURSE) . '
+                    WHERE code="' . Database::escape_string($course_code) . '" OR visual_code="' . Database::escape_string($course_code) . '"';
         } else {
         } else {
-            $sql = 'SELECT 1 FROM ' . Database::get_main_table(TABLE_MAIN_COURSE) . ' WHERE code="' . Database::escape_string($course_code) . '"';
+            $sql = 'SELECT 1 FROM ' . Database::get_main_table(TABLE_MAIN_COURSE) . '
+                    WHERE code="' . Database::escape_string($course_code) . '"';
         }
         }
+
         return Database::num_rows(Database::query($sql));
         return Database::num_rows(Database::query($sql));
     }
     }
 
 
@@ -2559,6 +2570,7 @@ class CourseManager
             return false;
             return false;
         }
         }
         $row = Database::fetch_array($res);
         $row = Database::fetch_array($res);
+
         return $row['code'];
         return $row['code'];
     }
     }
 
 
@@ -3107,6 +3119,7 @@ class CourseManager
             $medium->resize(100, 85, 0, false);
             $medium->resize(100, 85, 0, false);
             $medium->send_image($store_path . '/course-pic85x85.png', -1, 'png');
             $medium->send_image($store_path . '/course-pic85x85.png', -1, 'png');
         }
         }
+
         return $result;
         return $result;
     }
     }
 
 
@@ -4052,6 +4065,7 @@ class CourseManager
                 }
                 }
             }
             }
         }
         }
+
         return false;
         return false;
     }
     }
 
 
@@ -4070,7 +4084,9 @@ class CourseManager
             $wanted_code = CourseManager::generate_course_code($wanted_code);
             $wanted_code = CourseManager::generate_course_code($wanted_code);
             $table = Database::get_main_table(TABLE_MAIN_COURSE);
             $table = Database::get_main_table(TABLE_MAIN_COURSE);
             $wanted_code = Database::escape_string($wanted_code);
             $wanted_code = Database::escape_string($wanted_code);
-            $sql = "SELECT count(*) as count FROM $table WHERE code LIKE '$wanted_code%'";
+            $sql = "SELECT count(*) as count
+                    FROM $table
+                    WHERE code LIKE '$wanted_code%'";
             $result = Database::query($sql);
             $result = Database::query($sql);
             if (Database::num_rows($result) > 0) {
             if (Database::num_rows($result) > 0) {
                 $row = Database::fetch_array($result);
                 $row = Database::fetch_array($result);
@@ -4081,6 +4097,7 @@ class CourseManager
                     return $wanted_code;
                     return $wanted_code;
                 }
                 }
             }
             }
+
             return false;
             return false;
         }
         }
 
 
@@ -4458,8 +4475,6 @@ class CourseManager
      */
      */
     public static function return_hot_courses($days = 30, $limit = 5)
     public static function return_hot_courses($days = 30, $limit = 5)
     {
     {
-        global $_configuration;
-
         if (api_is_invitee()) {
         if (api_is_invitee()) {
             return array();
             return array();
         }
         }
@@ -4485,15 +4500,6 @@ class CourseManager
         $table_course = Database::get_main_table(TABLE_MAIN_COURSE);
         $table_course = Database::get_main_table(TABLE_MAIN_COURSE);
         $table_course_url = Database::get_main_table(TABLE_MAIN_ACCESS_URL_REL_COURSE);
         $table_course_url = Database::get_main_table(TABLE_MAIN_ACCESS_URL_REL_COURSE);
 
 
-        //@todo all dates in the tracking_course_access, last_access are in the DB time (NOW) not UTC
-        /*
-        $today                    = api_get_utc_datetime();
-        $today_diff                = time() -intval($days)*24*60*60;
-        $today_diff                = api_get_utc_datetime($today_diff);
-         * */
-
-        //WHERE login_course_date <= '$today' AND login_course_date >= '$today_diff'
-
         //$table_course_access table uses the now() and interval ...
         //$table_course_access table uses the now() and interval ...
         $now = api_get_utc_datetime(time());
         $now = api_get_utc_datetime(time());
         $sql = "SELECT COUNT(course_access_id) course_count, a.c_id, visibility
         $sql = "SELECT COUNT(course_access_id) course_count, a.c_id, visibility
@@ -4679,7 +4685,6 @@ class CourseManager
      */
      */
     public static function countAvailableCourses($accessUrlId = null)
     public static function countAvailableCourses($accessUrlId = null)
     {
     {
-        global $_configuration;
         $tableCourse = Database::get_main_table(TABLE_MAIN_COURSE);
         $tableCourse = Database::get_main_table(TABLE_MAIN_COURSE);
         $tableCourseRelAccessUrl = Database::get_main_table(TABLE_MAIN_ACCESS_URL_REL_COURSE);
         $tableCourseRelAccessUrl = Database::get_main_table(TABLE_MAIN_ACCESS_URL_REL_COURSE);
         $specialCourseList = self::get_special_course_list();
         $specialCourseList = self::get_special_course_list();
@@ -5089,12 +5094,12 @@ class CourseManager
         $forum = Database::get_course_table(TABLE_FORUM);
         $forum = Database::get_course_table(TABLE_FORUM);
         if ($getAllSessions) {
         if ($getAllSessions) {
             $sql = "SELECT count(*) as count
             $sql = "SELECT count(*) as count
-            FROM $forum f
-            where f.c_id = %s";
+                    FROM $forum f
+                    WHERE f.c_id = %s";
         } else {
         } else {
             $sql = "SELECT count(*) as count
             $sql = "SELECT count(*) as count
-            FROM $forum f
-            where f.c_id = %s and f.session_id = %s";
+                    FROM $forum f
+                    WHERE f.c_id = %s and f.session_id = %s";
         }
         }
 
 
         $sql = sprintf($sql, intval($courseId), intval($sessionId));
         $sql = sprintf($sql, intval($courseId), intval($sessionId));
@@ -5471,12 +5476,12 @@ class CourseManager
         }
         }
 
 
         $sql = "SELECT DISTINCT(c.id), c.title
         $sql = "SELECT DISTINCT(c.id), c.title
-            FROM $courseTable c
-            INNER JOIN $courseUserTable cru ON c.id = cru.c_id
-            WHERE (
-                cru.user_id IN (" . implode(', ', $userIdList) . ")
-                AND cru.relation_type = 0
-            )";
+                FROM $courseTable c
+                INNER JOIN $courseUserTable cru ON c.id = cru.c_id
+                WHERE (
+                    cru.user_id IN (" . implode(', ', $userIdList) . ")
+                    AND cru.relation_type = 0
+                )";
 
 
         if (api_is_multiple_url_enabled()) {
         if (api_is_multiple_url_enabled()) {
             $courseAccessUrlTable = Database::get_main_table(TABLE_MAIN_ACCESS_URL_REL_COURSE);
             $courseAccessUrlTable = Database::get_main_table(TABLE_MAIN_ACCESS_URL_REL_COURSE);
@@ -5703,6 +5708,4 @@ class CourseManager
 
 
         return $params;
         return $params;
     }
     }
-
-
 }
 }

+ 12 - 7
main/inc/lib/course_category.lib.php

@@ -29,6 +29,7 @@ function getCategoryById($categoryId)
     if (Database::num_rows($result)) {
     if (Database::num_rows($result)) {
         return Database::fetch_array($result, 'ASSOC');
         return Database::fetch_array($result, 'ASSOC');
     }
     }
+
     return array();
     return array();
 }
 }
 
 
@@ -46,6 +47,7 @@ function getCategory($category)
     if (Database::num_rows($result)) {
     if (Database::num_rows($result)) {
         return Database::fetch_array($result, 'ASSOC');
         return Database::fetch_array($result, 'ASSOC');
     }
     }
+
     return array();
     return array();
 }
 }
 
 
@@ -107,7 +109,6 @@ function getCategories($category)
     return $categories;
     return $categories;
 }
 }
 
 
-
 /**
 /**
  * @param string $code
  * @param string $code
  * @param string $name
  * @param string $name
@@ -246,6 +247,7 @@ function editNode($code, $name, $canHaveCourses, $old_code)
     $sql = "UPDATE $tbl_course SET category_code = '$code'
     $sql = "UPDATE $tbl_course SET category_code = '$code'
             WHERE category_code = '$old_code' ";
             WHERE category_code = '$old_code' ";
     Database::query($sql);
     Database::query($sql);
+
     return true;
     return true;
 }
 }
 
 
@@ -326,6 +328,7 @@ function courseCategoryChildrenCount($categoryId)
     }
     }
     $sql = "UPDATE $tbl_category SET children_count = $count WHERE id = $categoryId";
     $sql = "UPDATE $tbl_category SET children_count = $count WHERE id = $categoryId";
     Database::query($sql);
     Database::query($sql);
+
     return $count + 1;
     return $count + 1;
 }
 }
 
 
@@ -373,6 +376,7 @@ function getParents($categoryCode)
         $subChildren = getParents($parent['code']);
         $subChildren = getParents($parent['code']);
         $children = array_merge($children, $subChildren);
         $children = array_merge($children, $subChildren);
     }
     }
+
     return $children;
     return $children;
 }
 }
 
 
@@ -394,11 +398,13 @@ function getParentsToString($categoryCode)
 
 
         return $categoriesInString;
         return $categoriesInString;
     }
     }
+
     return null;
     return null;
 }
 }
 
 
 /**
 /**
  * @param string $categorySource
  * @param string $categorySource
+ *
  * @return string
  * @return string
  */
  */
 function listCategories($categorySource)
 function listCategories($categorySource)
@@ -462,12 +468,14 @@ function listCategories($categorySource)
 function getCategoriesToDisplayInHomePage()
 function getCategoriesToDisplayInHomePage()
 {
 {
     $tbl_category = Database::get_main_table(TABLE_MAIN_CATEGORY);
     $tbl_category = Database::get_main_table(TABLE_MAIN_CATEGORY);
-    $sql = "SELECT name FROM $tbl_category WHERE parent_id IS NULL ORDER BY tree_pos";
+    $sql = "SELECT name FROM $tbl_category
+            WHERE parent_id IS NULL ORDER BY tree_pos";
     return Database::store_result(Database::query($sql));
     return Database::store_result(Database::query($sql));
 }
 }
 
 
 /**
 /**
  * @param int $id
  * @param int $id
+ *
  * @return bool
  * @return bool
  */
  */
 function addToUrl($id)
 function addToUrl($id)
@@ -578,7 +586,6 @@ function browseCourseCategories()
  */
  */
 function countCoursesInCategory($category_code="", $searchTerm = '')
 function countCoursesInCategory($category_code="", $searchTerm = '')
 {
 {
-    global $_configuration;
     $tbl_course = Database::get_main_table(TABLE_MAIN_COURSE);
     $tbl_course = Database::get_main_table(TABLE_MAIN_COURSE);
     $categoryCode = Database::escape_string($category_code);
     $categoryCode = Database::escape_string($category_code);
     $searchTerm = Database::escape_string($searchTerm);
     $searchTerm = Database::escape_string($searchTerm);
@@ -656,7 +663,6 @@ function countCoursesInCategory($category_code="", $searchTerm = '')
  */
  */
 function browseCoursesInCategory($category_code, $random_value = null, $limit = array())
 function browseCoursesInCategory($category_code, $random_value = null, $limit = array())
 {
 {
-    global $_configuration;
     $tbl_course = Database::get_main_table(TABLE_MAIN_COURSE);
     $tbl_course = Database::get_main_table(TABLE_MAIN_COURSE);
 
 
     $specialCourseList = CourseManager::get_special_course_list();
     $specialCourseList = CourseManager::get_special_course_list();
@@ -858,7 +864,8 @@ function getCourseCategoryNotInList($list)
     $list = array_map('intval', $list);
     $list = array_map('intval', $list);
     $listToString = implode("','", $list);
     $listToString = implode("','", $list);
 
 
-    $sql = "SELECT * FROM $table WHERE id NOT IN ('$listToString') AND (parent_id IS NULL) ";
+    $sql = "SELECT * FROM $table
+            WHERE id NOT IN ('$listToString') AND (parent_id IS NULL) ";
     $result = Database::query($sql);
     $result = Database::query($sql);
     return Database::store_result($result, 'ASSOC');
     return Database::store_result($result, 'ASSOC');
 }
 }
@@ -1110,8 +1117,6 @@ function getPageNumberItem($pageNumber, $pageLength, $liAttributes = array(), $c
  */
  */
 function getCourseCatalogNameTools($action)
 function getCourseCatalogNameTools($action)
 {
 {
-
-
     $nameTools = get_lang('SortMyCourses');
     $nameTools = get_lang('SortMyCourses');
     if (empty($action)) {
     if (empty($action)) {
         return $nameTools; //should never happen
         return $nameTools; //should never happen

+ 5 - 1
main/inc/lib/course_description.lib.php

@@ -353,6 +353,7 @@ class CourseDescription
         $rs = Database::query($sql);
         $rs = Database::query($sql);
         $row = Database::fetch_array($rs);
         $row = Database::fetch_array($rs);
         $description_id = $row['id'];
         $description_id = $row['id'];
+
         return $description_id;
         return $description_id;
     }
     }
 
 
@@ -370,8 +371,8 @@ class CourseDescription
         $default_description_titles[5] = get_lang('CourseMaterial');
         $default_description_titles[5] = get_lang('CourseMaterial');
         $default_description_titles[6] = get_lang('HumanAndTechnicalResources');
         $default_description_titles[6] = get_lang('HumanAndTechnicalResources');
         $default_description_titles[7] = get_lang('Assessment');
         $default_description_titles[7] = get_lang('Assessment');
-
         $default_description_titles[8] = get_lang('Other');
         $default_description_titles[8] = get_lang('Other');
+
         return $default_description_titles;
         return $default_description_titles;
     }
     }
 
 
@@ -390,6 +391,7 @@ class CourseDescription
         $default_description_title_editable[6] = true;
         $default_description_title_editable[6] = true;
         $default_description_title_editable[7] = true;
         $default_description_title_editable[7] = true;
         //$default_description_title_editable[8] = true;
         //$default_description_title_editable[8] = true;
+
         return $default_description_title_editable;
         return $default_description_title_editable;
     }
     }
 
 
@@ -409,6 +411,7 @@ class CourseDescription
         $default_description_icon[7] = 'assessment.png';
         $default_description_icon[7] = 'assessment.png';
         //$default_description_icon[8]= 'porcent.png';
         //$default_description_icon[8]= 'porcent.png';
         $default_description_icon[8] = 'wizard.png';
         $default_description_icon[8] = 'wizard.png';
+
         return $default_description_icon;
         return $default_description_icon;
     }
     }
 
 
@@ -427,6 +430,7 @@ class CourseDescription
         $question[6] = get_lang('HumanAndTechnicalResourcesQuestions');
         $question[6] = get_lang('HumanAndTechnicalResourcesQuestions');
         $question[7] = get_lang('AssessmentQuestions');
         $question[7] = get_lang('AssessmentQuestions');
         //$question[8]= get_lang('ThematicAdvanceQuestions');
         //$question[8]= get_lang('ThematicAdvanceQuestions');
+
         return $question;
         return $question;
     }
     }
 
 

+ 0 - 4
main/inc/lib/course_home.lib.php

@@ -299,10 +299,6 @@ class CourseHome
             foreach ($all_tools_list as & $tool) {
             foreach ($all_tools_list as & $tool) {
 
 
                 if ($tool['image'] == 'scormbuilder.gif') {
                 if ($tool['image'] == 'scormbuilder.gif') {
-                    // display links to lp only for current session
-                    /* if (api_get_session_id() != $tool['session_id']) {
-                      continue;
-                      } */
                     // check if the published learnpath is visible for student
                     // check if the published learnpath is visible for student
                     $published_lp_id = self::get_published_lp_id_from_link($tool['link']);
                     $published_lp_id = self::get_published_lp_id_from_link($tool['link']);
 
 

+ 16 - 4
main/inc/lib/course_request.lib.php

@@ -51,7 +51,7 @@ class CourseRequestManager
      * @param string $objetives
      * @param string $objetives
      * @param string $target_audience
      * @param string $target_audience
      * @param int/string $user_id
      * @param int/string $user_id
-     * @return int/bool                 The database id of the newly created course request or FALSE on failure.
+     * @return int/bool The database id of the newly created course request or FALSE on failure.
      */
      */
     public static function create_course_request(
     public static function create_course_request(
         $wanted_code,
         $wanted_code,
@@ -240,7 +240,7 @@ class CourseRequestManager
      * @param string $objetives
      * @param string $objetives
      * @param string $target_audience
      * @param string $target_audience
      * @param int/string $user_id
      * @param int/string $user_id
-     * @return bool                     Returns TRUE on success or FALSE on failure.
+     * @return bool Returns TRUE on success or FALSE on failure.
      */
      */
     public static function update_course_request(
     public static function update_course_request(
         $id,
         $id,
@@ -299,7 +299,13 @@ class CourseRequestManager
         if ($user_id != $course_request_info['code']) {
         if ($user_id != $course_request_info['code']) {
             $user_info = api_get_user_info($user_id);
             $user_info = api_get_user_info($user_id);
             if (is_array($user_info)) {
             if (is_array($user_info)) {
-                $tutor_name = api_get_person_name($user_info['firstname'], $user_info['lastname'], null, null, $course_language);
+                $tutor_name = api_get_person_name(
+                    $user_info['firstname'],
+                    $user_info['lastname'],
+                    null,
+                    null,
+                    $course_language
+                );
             } else {
             } else {
                 $user_id = $course_request_info['code'];
                 $user_id = $course_request_info['code'];
             }
             }
@@ -308,7 +314,13 @@ class CourseRequestManager
         if ($course_language != $course_request_info['course_language']) {
         if ($course_language != $course_request_info['course_language']) {
             $user_info = api_get_user_info($user_id);
             $user_info = api_get_user_info($user_id);
             if (is_array($user_info)) {
             if (is_array($user_info)) {
-                $tutor_name = api_get_person_name($user_info['firstname'], $user_info['lastname'], null, null, $course_language);
+                $tutor_name = api_get_person_name(
+                    $user_info['firstname'],
+                    $user_info['lastname'],
+                    null,
+                    null,
+                    $course_language
+                );
             }
             }
         }
         }
 
 

+ 3 - 1
main/inc/lib/custom_pages.class.php

@@ -30,6 +30,7 @@ class CustomPages
      * Returns the path to a custom page.
      * Returns the path to a custom page.
      *
      *
      * @param string $name
      * @param string $name
+     *
      * @return string
      * @return string
      */
      */
     public static function path($name = '')
     public static function path($name = '')
@@ -61,7 +62,8 @@ class CustomPages
     /**
     /**
      * Does not look like this function is being used is being used
      * Does not look like this function is being used is being used
      *
      *
-     * @param type $url_id
+     * @param int $url_id
+     *
      * @return string
      * @return string
      */
      */
     public static function getURLImages($url_id = null)
     public static function getURLImages($url_id = null)

+ 0 - 1
main/inc/lib/event_email_template.class.php

@@ -70,7 +70,6 @@ class EventEmailTemplate extends Model
         $form->addElement('header', $header);
         $form->addElement('header', $header);
         $id = isset($_GET['id']) ? intval($_GET['id']) : '';
         $id = isset($_GET['id']) ? intval($_GET['id']) : '';
         $form->addElement('hidden', 'id', $id);
         $form->addElement('hidden', 'id', $id);
-
         $form->addElement('text', 'name', get_lang('Name'), array('size' => '70'));
         $form->addElement('text', 'name', get_lang('Name'), array('size' => '70'));
         $form->addHtmlEditor(
         $form->addHtmlEditor(
             'description',
             'description',

+ 131 - 43
main/inc/lib/fileDisplay.lib.php

@@ -22,59 +22,146 @@ function choose_image($file_name)
 
 
     /* TABLES INITIALISATION */
     /* TABLES INITIALISATION */
     if (!$type || !$image) {
     if (!$type || !$image) {
-        $type['word'      ] = array('doc', 'dot',  'rtf', 'mcw',  'wps', 'psw', 'docm', 'docx', 'dotm',  'dotx');
-        $type['web'       ] = array('htm', 'html', 'htx', 'xml',  'xsl',  'php', 'xhtml');
-        $type['image'     ] = array('gif', 'jpg',  'png', 'bmp',  'jpeg', 'tif', 'tiff');
-        $type['image_vect'] = array('svg','svgz');
-        $type['audio'     ] = array('wav', 'mid',  'mp2', 'mp3',  'midi', 'sib', 'amr', 'kar', 'oga','au','wma');
-		$type['video'     ] = array('mp4', 'mov',  'rm',  'pls',  'mpg',  'mpeg', 'm2v', 'm4v', 'flv', 'f4v', 'avi', 'wmv', 'asf', '3gp','ogv','ogg','ogx','webm');
-        $type['excel'     ] = array('xls', 'xlt',  'xls', 'xlt', 'pxl', 'xlsx', 'xlsm', 'xlam', 'xlsb', 'xltm', 'xltx');
-        $type['compressed'] = array('zip', 'tar',  'rar', 'gz');
-        $type['code'      ] = array('js',  'cpp',  'c',   'java', 'phps', 'jsp', 'asp', 'aspx', 'cfm');
-        $type['acrobat'   ] = array('pdf');
-        $type['powerpoint'] = array('ppt', 'pps', 'pptm', 'pptx', 'potm', 'potx', 'ppam', 'ppsm', 'ppsx');
-        $type['flash'     ] = array('fla', 'swf');
-        $type['text'      ] = array('txt','log');
-        $type['oo_writer' ] = array('odt', 'ott', 'sxw', 'stw');
-        $type['oo_calc'   ] = array('ods', 'ots', 'sxc', 'stc');
+        $type['word'] = array(
+            'doc',
+            'dot',
+            'rtf',
+            'mcw',
+            'wps',
+            'psw',
+            'docm',
+            'docx',
+            'dotm',
+            'dotx',
+        );
+        $type['web'] = array(
+            'htm',
+            'html',
+            'htx',
+            'xml',
+            'xsl',
+            'php',
+            'xhtml',
+        );
+        $type['image'] = array(
+            'gif',
+            'jpg',
+            'png',
+            'bmp',
+            'jpeg',
+            'tif',
+            'tiff',
+        );
+        $type['image_vect'] = array('svg', 'svgz');
+        $type['audio'] = array(
+            'wav',
+            'mid',
+            'mp2',
+            'mp3',
+            'midi',
+            'sib',
+            'amr',
+            'kar',
+            'oga',
+            'au',
+            'wma',
+        );
+        $type['video'] = array(
+            'mp4',
+            'mov',
+            'rm',
+            'pls',
+            'mpg',
+            'mpeg',
+            'm2v',
+            'm4v',
+            'flv',
+            'f4v',
+            'avi',
+            'wmv',
+            'asf',
+            '3gp',
+            'ogv',
+            'ogg',
+            'ogx',
+            'webm',
+        );
+        $type['excel'] = array(
+            'xls',
+            'xlt',
+            'xls',
+            'xlt',
+            'pxl',
+            'xlsx',
+            'xlsm',
+            'xlam',
+            'xlsb',
+            'xltm',
+            'xltx',
+        );
+        $type['compressed'] = array('zip', 'tar', 'rar', 'gz');
+        $type['code'] = array(
+            'js',
+            'cpp',
+            'c',
+            'java',
+            'phps',
+            'jsp',
+            'asp',
+            'aspx',
+            'cfm',
+        );
+        $type['acrobat'] = array('pdf');
+        $type['powerpoint'] = array(
+            'ppt',
+            'pps',
+            'pptm',
+            'pptx',
+            'potm',
+            'potx',
+            'ppam',
+            'ppsm',
+            'ppsx',
+        );
+        $type['flash'] = array('fla', 'swf');
+        $type['text'] = array('txt', 'log');
+        $type['oo_writer'] = array('odt', 'ott', 'sxw', 'stw');
+        $type['oo_calc'] = array('ods', 'ots', 'sxc', 'stc');
         $type['oo_impress'] = array('odp', 'otp', 'sxi', 'sti');
         $type['oo_impress'] = array('odp', 'otp', 'sxi', 'sti');
-        $type['oo_draw'   ] = array('odg', 'otg', 'sxd', 'std');
-        $type['epub'      ] = array('epub');
-		$type['java'      ] = array('class','jar');
-		$type['freemind'  ] = array('mm');
-
-        $image['word'      ] = 'word.gif';
-        $image['web'       ] = 'file_html.gif';
-        $image['image'     ] = 'file_image.gif';
+        $type['oo_draw'] = array('odg', 'otg', 'sxd', 'std');
+        $type['epub'] = array('epub');
+        $type['java'] = array('class', 'jar');
+        $type['freemind'] = array('mm');
+
+        $image['word'] = 'word.gif';
+        $image['web'] = 'file_html.gif';
+        $image['image'] = 'file_image.gif';
         $image['image_vect'] = 'file_svg.png';
         $image['image_vect'] = 'file_svg.png';
-        $image['audio'     ] = 'file_sound.gif';
-        $image['video'     ] = 'film.gif';
-        $image['excel'     ] = 'excel.gif';
+        $image['audio'] = 'file_sound.gif';
+        $image['video'] = 'film.gif';
+        $image['excel'] = 'excel.gif';
         $image['compressed'] = 'file_zip.gif';
         $image['compressed'] = 'file_zip.gif';
-        $image['code'      ] = 'icons/22/mime_code.png';
-        $image['acrobat'   ] = 'file_pdf.gif';
+        $image['code'] = 'icons/22/mime_code.png';
+        $image['acrobat'] = 'file_pdf.gif';
         $image['powerpoint'] = 'powerpoint.gif';
         $image['powerpoint'] = 'powerpoint.gif';
-        $image['flash'     ] = 'file_flash.gif';
-        $image['text'      ] = 'icons/22/mime_text.png';
-        $image['oo_writer' ] = 'file_oo_writer.gif';
-        $image['oo_calc'   ] = 'file_oo_calc.gif';
+        $image['flash'] = 'file_flash.gif';
+        $image['text'] = 'icons/22/mime_text.png';
+        $image['oo_writer'] = 'file_oo_writer.gif';
+        $image['oo_calc'] = 'file_oo_calc.gif';
         $image['oo_impress'] = 'file_oo_impress.gif';
         $image['oo_impress'] = 'file_oo_impress.gif';
-        $image['oo_draw'   ] = 'file_oo_draw.gif';
-        $image['epub'      ] = 'file_epub.gif';
-		$image['java'      ] = 'file_java.png';
-		$image['freemind'  ] = 'file_freemind.png';
+        $image['oo_draw'] = 'file_oo_draw.gif';
+        $image['epub'] = 'file_epub.gif';
+        $image['java'] = 'file_java.png';
+        $image['freemind'] = 'file_freemind.png';
     }
     }
 
 
-    /* FUNCTION CORE */
     $extension = array();
     $extension = array();
     if (!is_array($file_name)) {
     if (!is_array($file_name)) {
         if (preg_match('/\.([[:alnum:]]+)(\?|$)/', $file_name, $extension)) {
         if (preg_match('/\.([[:alnum:]]+)(\?|$)/', $file_name, $extension)) {
             $extension[1] = strtolower($extension[1]);
             $extension[1] = strtolower($extension[1]);
 
 
-            foreach ($type as $generic_type => $extension_list)
-            {
-                if (in_array($extension[1], $extension_list))
-                {
+            foreach ($type as $generic_type => $extension_list) {
+                if (in_array($extension[1], $extension_list)) {
                     return $image[$generic_type];
                     return $image[$generic_type];
                 }
                 }
             }
             }
@@ -185,8 +272,8 @@ function folder_size($dir_name)
 function get_total_folder_size($path, $can_see_invisible = false)
 function get_total_folder_size($path, $can_see_invisible = false)
 {
 {
     $table_itemproperty = Database::get_course_table(TABLE_ITEM_PROPERTY);
     $table_itemproperty = Database::get_course_table(TABLE_ITEM_PROPERTY);
-    $table_document 	= Database::get_course_table(TABLE_DOCUMENT);
-    $tool_document 		= TOOL_DOCUMENT;
+    $table_document = Database::get_course_table(TABLE_DOCUMENT);
+    $tool_document = TOOL_DOCUMENT;
 
 
     $course_id = api_get_course_int_id();
     $course_id = api_get_course_int_id();
     $session_id = api_get_session_id();
     $session_id = api_get_session_id();
@@ -216,6 +303,7 @@ function get_total_folder_size($path, $can_see_invisible = false)
     $result = Database::query($sql);
     $result = Database::query($sql);
     if ($result && Database::num_rows($result) != 0) {
     if ($result && Database::num_rows($result) != 0) {
         $row = Database::fetch_row($result);
         $row = Database::fetch_row($result);
+
         return $row[0] == null ? 0 : $row[0];
         return $row[0] == null ? 0 : $row[0];
     } else {
     } else {
         return 0;
         return 0;

+ 9 - 9
main/inc/lib/fileManage.lib.php

@@ -158,7 +158,6 @@ function folder_is_empty($in_folder)
     return $folder_is_empty;
     return $folder_is_empty;
 }
 }
 
 
-
 /**
 /**
  * Renames a file or a directory
  * Renames a file or a directory
  *
  *
@@ -345,7 +344,6 @@ function dirsize($root, $recursive = true) {
 */
 */
 class FileManager
 class FileManager
 {
 {
-
 	/**
 	/**
 		Returns a list of all directories, except the base dir,
 		Returns a list of all directories, except the base dir,
 		of the current course. This function uses recursion.
 		of the current course. This function uses recursion.
@@ -355,8 +353,8 @@ class FileManager
 		@author Roan Embrechts
 		@author Roan Embrechts
 		@version 1.0.1
 		@version 1.0.1
 	*/
 	*/
-	function list_all_directories($path) {
-
+	function list_all_directories($path)
+    {
 		$result_array = array();
 		$result_array = array();
 		if (is_dir($path)) {
 		if (is_dir($path)) {
 			$save_dir = getcwd();
 			$save_dir = getcwd();
@@ -393,8 +391,8 @@ class FileManager
 		@author Roan Embrechts
 		@author Roan Embrechts
 		@version 1.0
 		@version 1.0
 	*/
 	*/
-	function list_all_files($dir_array) {
-
+	function list_all_files($dir_array)
+    {
 		$element_array = array();
 		$element_array = array();
 		if (is_dir($dir_array)) {
 		if (is_dir($dir_array)) {
 
 
@@ -403,7 +401,8 @@ class FileManager
 				chdir($directory);
 				chdir($directory);
 				$handle = opendir($directory);
 				$handle = opendir($directory);
 			   	while ($element = readdir($handle)) {
 			   	while ($element = readdir($handle)) {
-					if ($element == '.' || $element == '..' || $element == '.htaccess') continue; // Skip the current and parent directories
+					if ($element == '.' || $element == '..' || $element == '.htaccess') continue;
+                    // Skip the current and parent directories
 					if (!is_dir($element)) {
 					if (!is_dir($element)) {
 						$element_array[] = $directory.'/'.$element;
 						$element_array[] = $directory.'/'.$element;
 					}
 					}
@@ -413,6 +412,7 @@ class FileManager
 				chdir($save_dir);
 				chdir($save_dir);
 			}
 			}
 		}
 		}
+
 		return $element_array;
 		return $element_array;
 	}
 	}
 
 
@@ -421,7 +421,8 @@ class FileManager
 		Function kept for compatibility with older PHP versions.
 		Function kept for compatibility with older PHP versions.
 		Function is binary safe (is needed on Windows)
 		Function is binary safe (is needed on Windows)
 	*/
 	*/
-	function compat_load_file($file_name) {
+	function compat_load_file($file_name)
+    {
 		$buffer = '';
 		$buffer = '';
 		if (file_exists($file_name)) {
 		if (file_exists($file_name)) {
 			$fp = fopen($file_name, 'rb');
 			$fp = fopen($file_name, 'rb');
@@ -461,7 +462,6 @@ class FileManager
 		}
 		}
 
 
 		$full_file_name = $upload_path.'/'.$filename;
 		$full_file_name = $upload_path.'/'.$filename;
-		//$upload_path = str_replace("//", '/', $upload_path);
 		$full_file_name = str_replace("//", '/', $full_file_name);
 		$full_file_name = str_replace("//", '/', $full_file_name);
 
 
 		$sql_query = "SELECT count(*) as number_existing FROM $glued_table WHERE path='$full_file_name'";
 		$sql_query = "SELECT count(*) as number_existing FROM $glued_table WHERE path='$full_file_name'";

+ 5 - 3
main/inc/lib/grade_model.lib.php

@@ -62,9 +62,10 @@ class GradeModel extends Model
     /**
     /**
      * Returns a Form validator Obj
      * Returns a Form validator Obj
      * @todo the form should be auto generated
      * @todo the form should be auto generated
-     * @param   string  url
-     * @param   string  action add, edit
-     * @return  obj     form validator obj
+     * @param   string  $url
+     * @param   string  $action add, edit
+     *
+     * @return  FormValidator form validator obj
      */
      */
     public function return_form($url, $action)
     public function return_form($url, $action)
     {
     {
@@ -189,6 +190,7 @@ class GradeModel extends Model
 
 
         // Setting the rules
         // Setting the rules
         $form->addRule('name', get_lang('ThisFieldIsRequired'), 'required');
         $form->addRule('name', get_lang('ThisFieldIsRequired'), 'required');
+
 		return $form;
 		return $form;
     }
     }
 
 

+ 7 - 5
main/inc/lib/social.lib.php

@@ -477,9 +477,8 @@ class SocialManager extends UserManager
 
 
             }
             }
         } else {
         } else {
-                $imageCourse = Display::return_icon('course.png', get_lang('Course'), array('class' => 'img-default'));
+            $imageCourse = Display::return_icon('course.png', get_lang('Course'), array('class' => 'img-default'));
         }
         }
-        //$imageCourse = Display::return_icon('course.png', get_lang('Course'));
 
 
         //display course entry
         //display course entry
         if (api_get_setting('course_images_in_courses_list') === 'true') {
         if (api_get_setting('course_images_in_courses_list') === 'true') {
@@ -502,7 +501,6 @@ class SocialManager extends UserManager
 
 
 
 
         $session = '';
         $session = '';
-        $active = false;
         if (!empty($my_course['session_name']) && !empty($my_course['id_session'])) {
         if (!empty($my_course['session_name']) && !empty($my_course['id_session'])) {
 
 
             // Request for the name of the general coach
             // Request for the name of the general coach
@@ -522,7 +520,6 @@ class SocialManager extends UserManager
                 if (api_get_setting('show_session_coach') === 'true') {
                 if (api_get_setting('show_session_coach') === 'true') {
                     $session['coach'] = get_lang('GeneralCoach').': '.api_get_person_name($sessioncoach['firstname'], $sessioncoach['lastname']);
                     $session['coach'] = get_lang('GeneralCoach').': '.api_get_person_name($sessioncoach['firstname'], $sessioncoach['lastname']);
                 }
                 }
-                $active = true;
             } else {
             } else {
                 $session ['dates'] = ' - '.get_lang('From').' '.$my_course['access_start_date'].' '.get_lang('To').' '.$my_course['access_end_date'];
                 $session ['dates'] = ' - '.get_lang('From').' '.$my_course['access_start_date'].' '.get_lang('To').' '.$my_course['access_end_date'];
                 if (api_get_setting('show_session_coach') === 'true') {
                 if (api_get_setting('show_session_coach') === 'true') {
@@ -531,7 +528,12 @@ class SocialManager extends UserManager
             }
             }
         }
         }
         $my_course['id_session'] = isset($my_course['id_session']) ? $my_course['id_session'] : 0;
         $my_course['id_session'] = isset($my_course['id_session']) ? $my_course['id_session'] : 0;
-        $output = array($my_course['user_course_cat'], $result, $my_course['id_session'], $session);
+        $output = array(
+            $my_course['user_course_cat'],
+            $result,
+            $my_course['id_session'],
+            $session,
+        );
 
 
         return $output;
         return $output;
     }
     }

+ 0 - 1
main/newscorm/lp_add.php

@@ -22,7 +22,6 @@ require 'learnpath_functions.inc.php';
 //include '../resourcelinker/resourcelinker.inc.php';
 //include '../resourcelinker/resourcelinker.inc.php';
 require 'resourcelinker.inc.php';
 require 'resourcelinker.inc.php';
 // Rewrite the language file, sadly overwritten by resourcelinker.inc.php.
 // Rewrite the language file, sadly overwritten by resourcelinker.inc.php.
-// Name of the language file that needs to be included.
 /* Header and action code */
 /* Header and action code */
 
 
 $currentstyle = api_get_setting('stylesheets');
 $currentstyle = api_get_setting('stylesheets');

+ 6 - 7
main/reports/index.php

@@ -7,10 +7,9 @@
 * @package chamilo.reports
 * @package chamilo.reports
 */
 */
 exit;
 exit;
-// name of the language file that needs to be included
 $cidReset = true;
 $cidReset = true;
 
 
-// including files 
+// including files
 require_once '../inc/global.inc.php';
 require_once '../inc/global.inc.php';
 require_once 'reports.lib.php';
 require_once 'reports.lib.php';
 
 
@@ -46,7 +45,7 @@ $htmlHeadXtra[] = '    <style type="text/css">
 				margin-right : 1em;
 				margin-right : 1em;
 				text-align: right;
 				text-align: right;
 			}
 			}
-			
+
 			#data {
 			#data {
 				font-size : 0.7em;
 				font-size : 0.7em;
 			}
 			}
@@ -93,7 +92,7 @@ $htmlHeadXtra[] = '    <style type="text/css">
 			.navigation_button {
 			.navigation_button {
 				width : 70px;
 				width : 70px;
 			}
 			}
-			
+
 			#data {
 			#data {
 				overflow : auto;
 				overflow : auto;
 				display: none;
 				display: none;
@@ -164,7 +163,7 @@ foreach ($reports_template as $key => $value) {
     </div>
     </div>
     <div id="wizardShowButton">
     <div id="wizardShowButton">
         <?php echo get_lang('ShowWizard'); ?>
         <?php echo get_lang('ShowWizard'); ?>
-    </div>		
+    </div>
     <p id="data"></p>
     <p id="data"></p>
 </div>
 </div>
 <div id="result" class="result">
 <div id="result" class="result">
@@ -182,7 +181,7 @@ foreach ($reports_template as $key => $value) {
 					$("#wizardContent").show();
 					$("#wizardContent").show();
 					$("#wizardShowButton").hide();
 					$("#wizardShowButton").hide();
 				});
 				});
-				$("#reportsBuilderWizardForm").formwizard({ 
+				$("#reportsBuilderWizardForm").formwizard({
 				 	formPluginEnabled: true,
 				 	formPluginEnabled: true,
 				 	validationEnabled: true,
 				 	validationEnabled: true,
 				 	focusFirstInput : true,
 				 	focusFirstInput : true,
@@ -195,7 +194,7 @@ foreach ($reports_template as $key => $value) {
 						},
 						},
 						beforeSubmit: function(data){$("#data").html("data sent to the server: " + $.param(data));},
 						beforeSubmit: function(data){$("#data").html("data sent to the server: " + $.param(data));},
 						resetForm: false
 						resetForm: false
-				 	}	
+				 	}
 				 }
 				 }
 				);
 				);
   		});
   		});

+ 9 - 10
main/reports/reports.php

@@ -8,10 +8,9 @@
 * @package chamilo.reports
 * @package chamilo.reports
 */
 */
 exit;
 exit;
-// name of the language file that needs to be included
 $cidReset = true;
 $cidReset = true;
 
 
-// including files 
+// including files
 require_once '../inc/global.inc.php';
 require_once '../inc/global.inc.php';
 require_once 'reports.lib.php';
 require_once 'reports.lib.php';
 require_once 'multiquery.lib.php';
 require_once 'multiquery.lib.php';
@@ -103,7 +102,7 @@ if (is_array($reports_template[$_REQUEST['type']])) {
 		die(var_export($query, true));
 		die(var_export($query, true));
 
 
 	$result = multiquery_query($query);
 	$result = multiquery_query($query);
-	
+
 
 
 	// check number of result
 	// check number of result
 	$numberOfResult = multiquery_num_rows($result);
 	$numberOfResult = multiquery_num_rows($result);
@@ -148,7 +147,7 @@ if ($_REQUEST['format'] == 'html' || $_REQUEST['format'] == 'directlink') {
 
 
 	// counting fields
 	// counting fields
 	$nfields = multiquery_num_fields($result);
 	$nfields = multiquery_num_fields($result);
-	$columns = array();	
+	$columns = array();
 	$columns_islink = array();
 	$columns_islink = array();
 	echo '<thead><tr>';
 	echo '<thead><tr>';
 	for ($i=0; $i < $nfields; $i++)	{
 	for ($i=0; $i < $nfields; $i++)	{
@@ -156,7 +155,7 @@ if ($_REQUEST['format'] == 'html' || $_REQUEST['format'] == 'directlink') {
 		if (substr($columns[$i], -5, 5) != '_link') {
 		if (substr($columns[$i], -5, 5) != '_link') {
 			$column_islink[$i] = false;
 			$column_islink[$i] = false;
 			echo '<th>'.$columns[$i].'</th>';
 			echo '<th>'.$columns[$i].'</th>';
-		} else 
+		} else
 			$columns_islink[$i] = true;
 			$columns_islink[$i] = true;
 	}
 	}
 
 
@@ -175,10 +174,10 @@ if ($_REQUEST['format'] == 'html' || $_REQUEST['format'] == 'directlink') {
 			if (!$columns_islink[$i]){ // ignore links
 			if (!$columns_islink[$i]){ // ignore links
 				if ($columns_link[$i] != '') // link is defined
 				if ($columns_link[$i] != '') // link is defined
 					if (substr($columns_link[$i],0,10) == 'javascript') {
 					if (substr($columns_link[$i],0,10) == 'javascript') {
-						echo '<td><a href="#" onclick="'.$row[$columns_link[$i]].'">'.$row[$i].'</a></td>'; 
+						echo '<td><a href="#" onclick="'.$row[$columns_link[$i]].'">'.$row[$i].'</a></td>';
 					}
 					}
 					else {
 					else {
-						echo '<td><a href="'.$row[$columns_link[$i]].'">'.$row[$i].'</a></td>'; 
+						echo '<td><a href="'.$row[$columns_link[$i]].'">'.$row[$i].'</a></td>';
 					}
 					}
 				else
 				else
 					echo '<td>'.$row[$i].'</td>';
 					echo '<td>'.$row[$i].'</td>';
@@ -196,18 +195,18 @@ if ($_REQUEST['format'] == 'html' || $_REQUEST['format'] == 'directlink') {
 		</div>';
 		</div>';
 
 
 		Display::display_footer();
 		Display::display_footer();
-		
+
 	}
 	}
 } else if ($_REQUEST['format'] == 'csv') {
 } else if ($_REQUEST['format'] == 'csv') {
 	$nfields = multiquery_num_fields($result);
 	$nfields = multiquery_num_fields($result);
-	$columns = array();	
+	$columns = array();
 	$columns_islink = array();
 	$columns_islink = array();
 	for ($i=0; $i < $nfields; $i++)	{
 	for ($i=0; $i < $nfields; $i++)	{
 		$columns[$i] = multiquery_field_name($result, $i);
 		$columns[$i] = multiquery_field_name($result, $i);
 		if (substr($columns[$i], -5, 5) != '_link') {
 		if (substr($columns[$i], -5, 5) != '_link') {
 			$column_islink[$i] = false;
 			$column_islink[$i] = false;
 			echo csv_escaping($columns[$i]).',';
 			echo csv_escaping($columns[$i]).',';
-		} else 
+		} else
 			$columns_islink[$i] = true;
 			$columns_islink[$i] = true;
 	}
 	}
 
 

+ 0 - 57
tests/main/forum/forumfunction.inc.test.php

@@ -202,44 +202,6 @@ class TestForumFunction extends UnitTestCase {
 		 //var_dump($res);
 		 //var_dump($res);
 	 }
 	 }
 
 
-	 /**
-	* This function takes care of the display of the lock icon
-	* @param $content what is it that we want to (un)lock: forum category, forum, thread, post
-	* @param $id the id of the content we want to (un)lock
-	* @param $current_visibility_status what is the current status of the visibility (0 = invisible, 1 = visible)
-	* @return void display the lock HTML.
-	*/
-
-	 function testdisplay_lock_unlock_icon() {
-		 $content = 'testterm';
-		 $id = 1;
-		 $current_lock_status = 0;
-		 ob_start();
-		 $res = display_lock_unlock_icon($content, $id, $current_lock_status, $additional_url_parameters='');
-		 ob_end_clean();
-		 $this->assertTrue(is_null($res));
-		 //var_dump($res);
-	 }
-
-	 /**
-	* This function takes care of the display of the up and down icon
-	* @param $content what is it that we want to make (in)visible: forum category, forum, thread, post
-	* @param $id is the id of the item we want to display the icons for
-	* @param $list is an array of all the items. All items in this list should have an up and down icon except for the first (no up icon) and the last (no down icon)
-	* 		 The key of this $list array is the id of the item.
-	* @return void HTML
-	*/
-
-	public function testdisplay_up_down_icon() {
-		 $content = 'testcontent';
-		 $id = 1;
-		 $list = array('test');
-		 ob_start();
-		 $res = display_up_down_icon($content, $id, $list);
-		 ob_end_clean();
-		 $this->assertTrue(is_null($res));
-		 //var_dump($res);
-	 }
 
 
 	 /**
 	 /**
 	* This function displays the user image from the profile, with a link to the user's details.
 	* This function displays the user image from the profile, with a link to the user's details.
@@ -270,25 +232,6 @@ class TestForumFunction extends UnitTestCase {
 		 //var_dump($res);
 		 //var_dump($res);
 	 }
 	 }
 
 
-	/**
-	* This function takes care of the display of the visibility icon
-	* @param $content what is it that we want to make (in)visible: forum category, forum, thread, post
-	* @param $id the id of the content we want to make invisible
-	* @param $current_visibility_status what is the current status of the visibility (0 = invisible, 1 = visible)
-	* @return void string HTML
-	*/
-
-	public function testdisplay_visible_invisible_icon() {
-		 $content = 'testcontent';
-		 $current_visibility_status = 0;
-		 $id = 1;
-		 ob_start();
-		 $res = display_visible_invisible_icon($content, $id, $current_visibility_status, $additional_url_parameters='');
-		 ob_end_clean();
-		 $this->assertTrue(is_null($res));
-		 //var_dump($res);
-	 }
-
 	 /**
 	 /**
 	 * This function edit a attachment file into forum
 	 * This function edit a attachment file into forum
 	 * @param string  a comment about file
 	 * @param string  a comment about file