Format code, remove comments

1.10.x
Julio Montoya 10 years ago
parent 471cd47e93
commit 80111b53fb
  1. 2
      main/announcements/announcements.php
  2. 2
      main/announcements/download.php
  3. 2
      main/attendance/attendance_add.php
  4. 27
      main/attendance/attendance_controller.php
  5. 28
      main/attendance/attendance_edit.php
  6. 8
      main/attendance/attendance_list.php
  7. 21
      main/attendance/attendance_sheet.php
  8. 11
      main/attendance/index.php
  9. 29
      main/auth/cas/authcas.php
  10. 24
      main/auth/cas/cas_var.inc.php
  11. 11
      main/auth/cas/logincas.php
  12. 28
      main/auth/cas/logout.php
  13. 1
      main/auth/conditional_login/complete_phone_number.php
  14. 21
      main/auth/conditional_login/conditional_login.php
  15. 2
      main/auth/external_login/facebook.inc.php
  16. 5
      main/auth/external_login/login.ws.php
  17. 1
      main/auth/external_login/newUser.ldap.php
  18. 1
      main/auth/external_login/newUser.php
  19. 8
      main/auth/external_login/updateUser.php
  20. 9
      main/auth/gotocourse.php
  21. 3
      main/auth/ldap/authldap.php
  22. 2
      main/auth/ldap/ldap_var.inc.php
  23. 2
      main/auth/ldap/login.php
  24. 7
      main/auth/ldap/newUser.php
  25. 34
      main/auth/openid/login.php
  26. 2
      main/auth/openid/openid.lib.php
  27. 4
      main/auth/set_temp_password.php
  28. 2
      main/auth/sso/sso.Drupal.class.php
  29. 8
      main/auth/sso/sso.class.php
  30. 1
      main/auth/unsubscribe_account.php
  31. 7
      main/blog/download.php
  32. 2
      main/calendar/download.php
  33. 6
      main/course_description/course_description_controller.php
  34. 1
      main/course_info/download.php
  35. 3
      main/course_info/maintenance_coach.php
  36. 2
      main/course_info/start.php
  37. 21
      main/course_info/tools.php
  38. 3
      main/course_progress/thematic.php
  39. 23
      main/course_progress/thematic_plan.php
  40. 8
      main/coursecopy/copy_course.php
  41. 3
      main/dashboard/block.class.php
  42. 3
      main/dropbox/dropbox_functions.inc.php
  43. 2
      main/dropbox/dropbox_init.inc.php
  44. 2
      main/exercice/exercise.php
  45. 2
      main/exercice/exercise_admin.php
  46. 2
      main/exercice/question_pool.php
  47. 217
      main/forum/forumfunction.inc.php
  48. 1
      main/forum/forumsearch.php
  49. 13
      main/forum/iframe_thread.php
  50. 50
      main/forum/viewpost.php
  51. 2
      main/forum/viewthread_threaded.inc.php
  52. 9
      main/gradebook/gradebook_add_link.php
  53. 17
      main/gradebook/gradebook_showlog_eval.php
  54. 2
      main/gradebook/gradebook_statistics.php
  55. 2
      main/inc/email_editor.php
  56. 2
      main/inc/lib/api.lib.php
  57. 2
      main/inc/lib/auth.lib.php
  58. 32
      main/inc/lib/chat.lib.php
  59. 73
      main/inc/lib/course.lib.php
  60. 19
      main/inc/lib/course_category.lib.php
  61. 6
      main/inc/lib/course_description.lib.php
  62. 4
      main/inc/lib/course_home.lib.php
  63. 16
      main/inc/lib/course_request.lib.php
  64. 4
      main/inc/lib/custom_pages.class.php
  65. 1
      main/inc/lib/event_email_template.class.php
  66. 168
      main/inc/lib/fileDisplay.lib.php
  67. 18
      main/inc/lib/fileManage.lib.php
  68. 8
      main/inc/lib/grade_model.lib.php
  69. 10
      main/inc/lib/social.lib.php
  70. 1
      main/newscorm/lp_add.php
  71. 1
      main/reports/index.php
  72. 1
      main/reports/reports.php
  73. 57
      tests/main/forum/forumfunction.inc.test.php

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

@ -69,7 +69,7 @@ if (Database::num_rows($result) > 0) {
if (Security::check_abs_path($full_file_name,
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;

@ -28,7 +28,7 @@ $form = new FormValidator('attendance_add','POST','index.php?action=attendance_a
$form->addElement('header', '', get_lang('CreateANewAttendance'));
$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->addHtmlEditor(
'description',

@ -10,6 +10,7 @@
*
* @author Christian Fasanando <christian1827@gmail.com>
* @author Julio Montoya <gugli100@gmail.com> lot of bugfixes + improvements
*
* @package chamilo.attendance
*/
class AttendanceController
@ -31,7 +32,6 @@ class AttendanceController
*/
public function attendance_list($history = false, $messages = array())
{
$attendance = new Attendance();
$data = array();
// render to the view
@ -71,7 +71,6 @@ class AttendanceController
if (isset($_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);
exit;
} else {
@ -117,14 +116,9 @@ class AttendanceController
) {
$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();
$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;
}
} else {
@ -181,7 +175,7 @@ class AttendanceController
/**
* It's used for make attendance visible
* render to attendance_list view
* @param int attendance id
* @param int $attendanceId
*/
public function attendanceSetVisible($attendanceId)
{
@ -199,7 +193,7 @@ class AttendanceController
/**
* It's used for make attendance invisible
* render to attendance_list view
* @param int attendance id
* @param int $attendanceId
*/
public function attendanceSetInvisible($attendanceId)
{
@ -216,7 +210,7 @@ class AttendanceController
/**
* Restores an attendance entry and fallback to attendances rendering
* @param int attendance id
* @param int $attendanceId
*/
public function attendance_restore($attendance_id)
{
@ -256,7 +250,6 @@ class AttendanceController
public function export($id, $type = 'pdf')
{
$attendance = new Attendance();
$attendance_id = intval($attendance_id);
}
/**
@ -434,10 +427,10 @@ class AttendanceController
}
}
} 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';
} 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';
}
@ -528,8 +521,6 @@ class AttendanceController
api_format_date($class_day['date_time'], TIME_NO_SEC_FORMAT);
}
$data_table[] = $head_table;
$dataClass = array();
$max_dates_per_page = 10;
$data_attendant_calendar = $data_array['attendant_calendar'];
$data_users_presence = $data_array['users_presence'];
$count = 1;
@ -647,7 +638,7 @@ class AttendanceController
$startDate = api_get_utc_datetime($values['range_start']);
$endDate = api_get_utc_datetime($values['range_end']);
}
$formToDisplay = $form->return_form();
$formToDisplay = $form->returnForm();
} else {
if (!empty($sessionId)) {
$sessionInfo = api_get_session_info($sessionId);

@ -15,25 +15,34 @@ if (isset($error)) {
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)) {
$token = Security::get_token();
}
$attendance_weight = floatval($attendance_weight);
// 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('hidden', 'sec_token',$token);
$form->addElement('hidden', 'sec_token', $token);
$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->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
@ -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->applyFilter('attendance_weight', 'html_filter');
$form->addElement('html','</div>');
$form->addElement('html','</div>');
}
$form->addButtonUpdate(get_lang('Save'));

@ -11,12 +11,8 @@
api_protect_course_script(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 '<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>';
echo '</div>';
}
@ -36,7 +32,7 @@ $table = new SortableTable(
);
$table->set_additional_parameters($parameters);
$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(3, get_lang('CountDoneAttendance'), true, array('style'=>'width:90px;'));

@ -20,28 +20,11 @@ if (api_is_allowed_to_edit(null, true) ||
api_is_coach(api_get_session_id(), api_get_course_int_id()) ||
$isDrhOfCourse
) {
$param_gradebook = '';
if (isset($_SESSION['gradebook'])) {
$param_gradebook = '&gradebook='.$_SESSION['gradebook'];
}
$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(
'filter',
'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,
array(),
'inline'
@ -103,8 +86,6 @@ if (api_is_allowed_to_edit(null, true) ||
$form->addSelect('group_id', get_lang('Group'), $groupIdList);
}
//$form->addButtonFilter(get_lang('Filter'));
if (isset($_REQUEST['filter'])) {
if (in_array($_REQUEST['filter'], array_keys($values))) {
$default_filter = $_REQUEST['filter'];

@ -176,10 +176,7 @@ if (!empty($_GET['gradebook']) && $_GET['gradebook'] == 'view') {
unset($_SESSION['gradebook']);
$gradebook = '';
}
$param_gradebook = '';
if (isset($_SESSION['gradebook'])) {
$param_gradebook = '&gradebook='.$gradebook;
}
$student_param = '';
$student_id = null;
if (api_is_drh() && isset($_GET['student_id'])) {
@ -194,7 +191,7 @@ if (api_is_drh() && isset($_GET['student_id'])) {
if (!empty($gradebook)) {
$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') {
$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']);
}
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'));
}
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'));
}

@ -5,11 +5,9 @@
* 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
@ -21,6 +19,7 @@ function cas_configured() {
if (!empty($cas_auth_ver) && !empty($cas_auth_server) && !empty($cas_auth_port)) {
$res = true;
}
return $res;
}
@ -41,9 +40,7 @@ function cas_is_authenticated()
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::setNoCasServerValidation();
}
@ -152,9 +149,7 @@ function cas_is_authenticated()
// }
// }
return $login;
}
else
{
} else {
return false;
}
}
@ -184,23 +179,19 @@ function cas_logout($uinfo=null, $location=null)
phpCAS::logoutWithRedirectService($location);
}
/*
* 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;
}
function getCASLogoHTML() {
function getCASLogoHTML()
{
$out_res = "";
if (api_get_setting("casLogoURL") != "") {
$out_res = "<img src='".api_get_setting("casLogoURL")."' alt='CAS Logo' />";
}
return $out_res;
}
?>

@ -1,8 +1,9 @@
<?php
/* This file contains all the configuration variable for the cas module
* 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;
@ -10,12 +11,21 @@ $cas_auth_server = api_get_setting('cas_server');
$cas_auth_uri = api_get_setting('cas_server_uri');
$cas_auth_port = intval(api_get_setting('cas_port'));
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');
if ( ! is_string($cas_auth_uri)) $cas_auth_uri = '';
?>
if (!is_string($cas_auth_uri)) {
$cas_auth_uri = '';
}

@ -25,8 +25,8 @@ We go to page api_not_allowed :
> You are not allowed to see this page.
> 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
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
*/
if (api_is_anonymous()) {
@ -40,7 +40,12 @@ if (cas_configured()) {
setcookie("GotoCourse", $firstpage);
}
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::forceAuthentication();

@ -1,17 +1,13 @@
<?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();

@ -48,4 +48,3 @@ if (isset($_POST['submit'])){
ConditionalLogin::login();
}
}
?>

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

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

@ -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)
/**
*
@ -92,6 +94,7 @@ function loginWSAuthenticate($username, $password, $wsUrl) {
}
return 0;
}
return $response->validateUserResult;
}

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

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

@ -2,8 +2,8 @@
//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;
@ -32,10 +32,10 @@ if ($new_user !== false) { //User can login
$_user['uidReset'] = true;
$uidReset = true;
Session::write('_user', $_user);
} else { //User cannot login
} else {
//User cannot login
$loginFailed = true;
Session::erase('_uid');
header('Location: ' . api_get_path(WEB_PATH) . 'index.php?loginFailed=1&error=user_password_incorrect');
exit;
}
?>

@ -1,8 +1,10 @@
<?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
*
* Author : hubert.borderiou@grenet.fr
@ -50,5 +52,6 @@ if (isset($_GET['firstpage'])) {
} else {
api_delete_firstpage_parameter();
Header('Location: '.api_get_path(WEB_PATH).'index.php');
header('Location: '.api_get_path(WEB_PATH).'index.php');
exit;
}

@ -24,7 +24,8 @@
---------------
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.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)
(November 2003)
2.9 - further changes for new login procedure

@ -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 */
/**
* LDAP settings

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

@ -1,4 +1,4 @@
<?php # $Id: newUser.php 14965 2008-04-20 23:01:17Z yannoo $
<?php
/* For licensing terms, see /license.txt */
/**
* Users trying to login, who do not yet exist in the Chamilo database,
@ -29,12 +29,9 @@ if ($ldap_login_success)
*/
$info_array = ldap_find_user_info($login);
ldap_put_user_info_locally($login, $info_array);
}
else
{
} else {
//error_log('Could not find '.$login.' on LDAP server',0);
$loginFailed = true;
unset($_user['user_id']);
$uidReset = false;
}
?>

@ -18,19 +18,19 @@ require_once api_get_path(CONFIGURATION_PATH) . 'auth.conf.php';
require_once 'openid.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('button', 'submit', get_lang('Login'));
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>';
*
*/
}
/**
@ -108,6 +108,7 @@ function openid_complete($response) {
}
}
}
return $response;
}
@ -119,8 +120,8 @@ function openid_complete($response) {
* @return Array of services discovered (including OpenID version, endpoint
* URI, etc).
*/
function openid_discovery($claimed_id) {
function openid_discovery($claimed_id)
{
$services = array();
$xrds_url = $claimed_id;
@ -175,6 +176,7 @@ function openid_discovery($claimed_id) {
}
}
}
return $services;
}
@ -188,12 +190,15 @@ function openid_discovery($claimed_id) {
function openid_association($op_endpoint) {
//@todo Remove Old Associations:
$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);
// Check to see if we have an association for this IdP already
$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);
if (Database::num_rows($assoc_handle) <= 1) {
$mod = OPENID_DH_DEFAULT_MOD;
@ -248,6 +253,7 @@ function openid_association_request($public) {
$cpub = _openid_dh_long_to_base64($public);
$request['openid.dh_consumer_public'] = $cpub;
}
return $request;
}

@ -1,6 +1,6 @@
<?php
/* For licensing terms, see /license.txt */
/**
* OpenID utility functions. Taken from Drupal 6 code (from dries)
* @package chamilo.auth.openid

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

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

@ -1,8 +1,8 @@
<?php
/* For licensing terms, see /license.txt */
use ChamiloSession as Session;
/* For licensing terms, see /license.txt */
/**
* This file contains the necessary elements to implement a Single Sign On
* 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
*/
class sso {
class sso
{
public $protocol; // 'http://',
public $domain; // 'localhost/project/drupal5',
public $auth_uri; // '/?q=user',
@ -36,7 +37,7 @@ class sso {
$this->protocol = api_get_setting('sso_authentication_protocol');
// There can be multiple domains, so make sure to take only the first
// This might be later extended with a decision process
$domains = split(',',api_get_setting('sso_authentication_domain'));
$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');
@ -290,5 +291,4 @@ class sso {
return api_get_path(WEB_CODE_PATH) . 'auth/profile.php';
}
}

@ -1,5 +1,6 @@
<?php
/* For licensing terms, see /license.txt */
require_once '../inc/global.inc.php';
if (api_get_setting('platform_unsubscribe_allowed') != 'true') {

@ -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
//redirect
header('Location: '.$document_explorer);
exit;
}
$tbl_blogs_attachment = Database::get_course_table(TABLE_BLOGS_ATTACHMENT);
@ -59,7 +60,11 @@ $result = Database::query($sql);
if (Database::num_rows($result) > 0) {
$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/')) {
DocumentManager::file_send_for_download($full_file_name, TRUE, $row['filename']);
DocumentManager::file_send_for_download(
$full_file_name,
true,
$row['filename']
);
}
}
exit;

@ -82,7 +82,7 @@ if (Database::num_rows($result)) {
$full_file_name,
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);
}
}

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

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

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

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

@ -50,9 +50,24 @@ switch ($action) {
$allowed_picture_types = array ('jpg', 'jpeg', 'png');
$form->addElement('file', 'icon', get_lang('CustomIcon'));
$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->addHtml('</div>');
$form->addHtml('<div class="col-md-5">');

@ -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;
echo Display::div($thematic_advance_item, array('id'=>'thematic_advance_'.$thematic_advance['id']));
echo $edit_link;
echo '</td>';
//if (api_is_allowed_to_edit(null, true) && api_get_session_id() == $thematic['session_id']) {

@ -85,8 +85,14 @@ if ($action == 'thematic_plan_list') {
}
// 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', 'thematic_plan_token', $token);
@ -98,7 +104,18 @@ if ($action == 'thematic_plan_list') {
}
$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'));
if ($description_type < ADD_THEMATIC_PLAN) {

@ -3,9 +3,6 @@
/**
* @package chamilo.backup
*/
/**
* Code
*/
// Setting the global file that gets the general configuration, the databases, the languages, ...
require_once '../inc/global.inc.php';
@ -65,7 +62,10 @@ if (Security::check_token('post') && (
$cr = new CourseRestorer($course);
$cr->set_file_option($_POST['same_file_name_option']);
$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') && (
isset ($_POST['copy_option']) &&
$_POST['copy_option'] == 'select_items'

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

@ -356,7 +356,8 @@ function get_dropbox_category($id)
/**
* 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
* cat_name | received | sent | user_id
* test | 1 | 0 | 237

@ -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', ''));
$nameTools = get_lang('SentFiles');

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

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

@ -11,8 +11,6 @@
* @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;
require_once '../inc/global.inc.php';

@ -162,7 +162,12 @@ function handle_forum_and_forumcategories($lp_id = null)
for ($i = 0; $i < count($list_threads); $i++) {
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) {
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_comment' => $values['forum_category_comment'],
'cat_order' => $new_max,
'session_id' => $session_id
'session_id' => $session_id,
];
$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;
}
$clean_title = Database::escape_string($values['forum_title']);
// Forum images
$image_moved = false;
if (!empty($_FILES['picture']['name'])) {
@ -657,7 +660,7 @@ function store_forum($values, $courseInfo = array(), $returnId = false)
if (!empty($_POST['remove_picture'])) {
delete_forum_image($values['forum_id']);
}
$new_file_name = '';
if (isset($upload_ok)) {
if ($has_attachment) {
$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
*
* @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
* @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 $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.='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') {
$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 .= '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;
}
/**
* 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 = '')
{
$html = '';
@ -1054,7 +1030,8 @@ function return_lock_unlock_icon($content, $id, $current_lock_status, $additiona
$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') {
$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 .= '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;
}
@ -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 $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.
*
* @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)
{
$id = strval(intval($id));
@ -1140,7 +1112,7 @@ function change_visibility($content, $id, $target_visibility)
$constants = array(
'forumcategory' => TOOL_FORUM_CATEGORY,
'forum' => TOOL_FORUM,
'thread' => TOOL_FORUM_THREAD
'thread' => TOOL_FORUM_THREAD,
);
api_item_property_update(
$_course,
@ -1283,7 +1255,6 @@ function move_up_down($content, $direction, $id)
forum_category='" . Database::escape_string($forum_category) . "'
ORDER BY forum_order $sort_direction";
}
// echo $sql.'<br />';
// Finding the items that need to be switched.
$result = Database::query($sql);
$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
// be able to mess with the sorting by refreshing the page over and over again.
if ($this_sort != '' && $next_sort != '' && $next_id != '' && $this_id != '') {
$sql_update1 = "UPDATE $table SET $sort_column='".Database::escape_string($this_sort)."'
$sql = "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)."'
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_update1);
Database::query($sql_update2);
Database::query($sql);
}
return get_lang(ucfirst($content).'Moved');
@ -1332,6 +1304,7 @@ function class_visible_invisible($current_visibility_status)
return 'class="invisible"';
}
}
function return_visible_invisible($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_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
$table_posts post,
$table_users users,
@ -1946,7 +1929,7 @@ function getPosts($threadId, $orderDirection = 'ASC', $recursive = false, $postI
$posts = $qb->getQuery()->getResult();
$depth++;
/** @var \Chamilo\CourseBundle\Entity\CForumPost $post */
foreach ($posts as $post) {
$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
*
* @param int $forum_id integer that indicates the forum
* @param int $post_id integer that indicates the forum
*
* @return array returns
*
* @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
*
* @param $forum_id integer that indicates the forum
* @param $thread_id integer that indicates the forum
*
* @return array returns
*
* @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_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();
$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
*
* @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
* @author Patrick Cool <patrick.cool@UGent.be>, Ghent University
* @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
*
* @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
* of visible forums, $countinvisible=1 would return the number of visible and invisible forums
* @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_weight' => isset($values['weight_calification']) ? $values['weight_calification'] : '',
'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.
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));
// 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_notification' => isset($values['post_notification']) ? $values['post_notification'] : null,
'post_parent_id' => isset($values['post_parent_id']) ? $values['post_parent_id'] : null,
'visible' => $visible
'visible' => $visible,
]
);
if ($new_post_id) {
@ -3126,7 +3110,7 @@ function store_reply($current_forum, $values)
editAttachedFile(
array(
'comment' => $_POST['file_comments'][$key],
'post_id' => $new_post_id
'post_id' => $new_post_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(
'ToolbarSet' => 'Forum',
'Width' => '100%',
'Height' => '400'
'Height' => '400',
) : array(
'ToolbarSet' => 'ForumStudent',
'Width' => '100%',
'Height' => '400',
'UserStatus' => 'student'
'UserStatus' => 'student',
)
);
$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_qualify_max' => $values['numeric_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']]];
@ -3427,7 +3411,7 @@ function store_edit_post($values)
$params = [
'post_title' => $values['post_title'],
'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']]];
@ -4509,7 +4493,7 @@ function add_forum_attachment_file($file_comment, $last_id)
'comment' => $safe_file_comment,
'path' => $safe_new_file_name,
'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
* @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
*/
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
* @param the post's id
* @param int $post_id
* @return array with the post info
* @author Julio Montoya Dokeos
* @version avril 2008, dokeos 1.8.5
@ -4625,8 +4609,8 @@ function getAllAttachment($postId)
$columns = array('iid', 'path', 'filename', 'comment');
$conditions = array(
'where' => array(
'c_id = ? AND post_id = ?' => array($courseId, $postId)
)
'c_id = ? AND post_id = ?' => array($courseId, $postId),
),
);
$array = Database::select(
$columns,
@ -4856,7 +4840,7 @@ function set_notification($content, $id, $add_only = false)
if ($total <= 0) {
$sql = "INSERT INTO $table_notification (c_id, $database_field, user_id)
VALUES (".$course_id.", '".Database::escape_string($id)."','".intval($_user['user_id'])."')";
$result = Database::query($sql);
Database::query($sql);
Session::erase('forum_notification');
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
* @param int Thread ID
* @param int $thread_id
* @return int the number of post inside a thread
* @author Jhon Hinojosa <jhon.hinojosa@dokeos.com>,
* @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
* @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
*/
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
* @param int Course ID
* @param int $course_id Course ID
*
* @return int the number of user register in course
* @author Jhon Hinojosa <jhon.hinojosa@dokeos.com>,
* @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
* @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
* @author Jhon Hinojosa <jhon.hinojosa@dokeos.com>,
* @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
* @param int user id
* @param string db course name
* @param int $user_id
* @param string $course_code
*
* @return string
*/
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
*/
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
*/
function getForumCreatedByUser($user_id, $courseId, $sessionId)
@ -5308,7 +5297,7 @@ function getForumCreatedByUser($user_id, $courseId, $sessionId)
$forumList[] = array(
$forumInfo['forum_title'],
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
* @param null $postId Forum Post ID
* @param int $postId Forum Post ID
*
* @return string The Forum Attachments Ajax Table
*/
function getAttachmentsAjaxTable($postId = null)
@ -5514,11 +5504,12 @@ function getAttachmentsAjaxTable($postId = null)
/**
* Return an array of prepared attachment data to build forum attachment table
* 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
*/
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,
* 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"
* but without delete them from file system and database
* Other values : Clear attachments from course except specified post
* 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
*/
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
* @param $postId
* @param null $courseId
* @param int $postId
* @param int $courseId
*
* @return array
*/
function getAttachmentIdsByPostId($postId, $courseId = null) {
// Init variables
function getAttachmentIdsByPostId($postId, $courseId = null)
{
$array = array();
$courseId = intval($courseId);
$postId = intval($postId);
@ -5658,7 +5652,8 @@ function getAttachmentIdsByPostId($postId, $courseId = null) {
}
if ($courseId > 0) {
$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);
if ($result !== false && Database::num_rows($result) > 0) {
while ($row = Database::fetch_array($result,'ASSOC')) {

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

@ -22,8 +22,6 @@
*/
require_once '../inc/global.inc.php';
/* ACCESS RIGHTS */
// A notice for unauthorized people.
api_protect_course_script(true);
$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.
// 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.
$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? */

@ -59,9 +59,18 @@ if (!empty($gradebook) && $gradebook == 'view') {
if ($origin == 'learnpath') {
Display::display_reduced_header();
} 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
Display :: display_header('');
@ -72,7 +81,9 @@ if ($origin == 'learnpath') {
// if the user is not a course administrator and the forum is hidden
// 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();
if ($forum_allow === false) {
exit;
@ -81,10 +92,15 @@ if (!api_is_allowed_to_edit(false, true) AND ($current_forum['visibility'] == 0
/* 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']);
}
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']);
}
if ($_GET['action'] == 'move' && isset($_GET['post'])) {
@ -105,23 +121,29 @@ if ($message != 'PostDeletedSpecial') {
/* Action Links */
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=threaded&origin='.$origin.'">'.get_lang('ThreadedView').'</a> | ';
echo $my_url.'&view=nested&origin='.$origin.'">'.get_lang('NestedView').'</a>';
$my_url = null;
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 (($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.
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
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
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 '<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 {
@ -141,7 +163,7 @@ if ($message != 'PostDeletedSpecial') {
$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)) {
$viewmode = Database::escape_string($_GET['view']);
$_SESSION['view'] = $viewmode;

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

@ -23,7 +23,14 @@ $session_id = api_get_session_id();
$typeSelected = isset($_GET['typeselected']) ? intval($_GET['typeselected']) : null;
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 {
$all_categories = Category::load_session_categories(null, $session_id);
}

@ -27,16 +27,19 @@ Display :: display_header('');
echo Display::page_header(get_lang('GradebookQualifyLog'));
$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']);
$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) {

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

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

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

@ -638,6 +638,7 @@ class Auth
$form->addElement('text', 'course_registration_code');
$form->addButton(get_lang('SubmitRegistrationCode'));
$content = $form->returnForm();
return array('message' => $message, 'content' => $content);
}
}
@ -806,5 +807,4 @@ SQL;
return $sessionsToBrowse;
}
}

@ -28,13 +28,20 @@ class Chat extends Model
*/
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'];
}
/**
* Set user chat status
* @param int 0 if disconnected, 1 if connected
*
* @return void
*/
public function setUserStatus($status)
@ -68,13 +75,10 @@ class Chat extends Model
public function heartbeat()
{
$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."
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);
$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);
if ($items != '') {
@ -141,18 +146,18 @@ class Chat extends Model
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
*/
public function box_session($user_id)
{
$items = array();
if (isset($_SESSION['chatHistory'][$user_id])) {
$items = $_SESSION['chatHistory'][$user_id];
}
return $items;
}
@ -184,7 +189,10 @@ class Chat extends Model
$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) {
$user_info = api_get_user_info($to_user_id, true);
@ -250,7 +258,8 @@ class Chat extends Model
/**
* Filter chat messages to avoid XSS or other JS
* @param string Unfiltered message
* @param string $text Unfiltered message
*
* @return string Filterd mssage
*/
public function sanitize($text)
@ -259,6 +268,7 @@ class Chat extends Model
$text = str_replace("\n\r", "\n", $text);
$text = str_replace("\r\n", "\n", $text);
$text = str_replace("\n", "<br>", $text);
return $text;
}

@ -332,8 +332,8 @@ class CourseManager
{
$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
c_id = '" . intval($courseId). "' AND
user_id = " . intval($userId)
@ -347,6 +347,7 @@ class CourseManager
* @param int $userId
* @param int $courseId
* @param bool $isTutor
*
* @return bool
*/
public static function updateUserCourseTutor($userId, $courseId, $isTutor)
@ -373,14 +374,18 @@ class CourseManager
/**
* @param int $user_id
* @param string $course_code
*
* @return mixed
*/
public static function get_tutor_in_course_status($user_id, $course_code)
{
$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)
{
$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'";
$result = Database::fetch_array(Database::query($sql));
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 (!empty($order_by)) {
$order_by = 'ORDER BY ' . $order_by;
@ -1625,7 +1633,8 @@ class CourseManager
$multiple_access_url = api_get_multiple_access_url();
if ($multiple_access_url) {
$sql .= ' LEFT JOIN ' . Database::get_main_table(TABLE_MAIN_ACCESS_URL_REL_USER) . ' au ON (au.user_id = user.user_id) ';
$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);
@ -1711,7 +1720,6 @@ class CourseManager
$includeInvitedUsers = true,
$groupId = 0
) {
$userTable = Database::get_main_table(TABLE_MAIN_USER);
$session_id = intval($session_id);
$course_code = Database::escape_string($course_code);
@ -1722,7 +1730,8 @@ class CourseManager
if ($session_id == 0) {
if (empty($groupId)) {
// 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
ON cu.user_id = u.user_id
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";
}
$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
INNER JOIN $userTable u ON scu.user_id = u.user_id
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
* @param int $session_id
* @param int $courseId
*
* @return array - array containing user_id, lastname, firstname, username
*
*/
@ -2066,7 +2077,8 @@ class CourseManager
return;
}
$sql = "SELECT * FROM $table_course WHERE code = '" . $codeFiltered . "'";
$sql = "SELECT * FROM $table_course
WHERE code = '" . $codeFiltered . "'";
$res = Database::query($sql);
$course = Database::fetch_array($res);
$courseId = $course['id'];
@ -2087,7 +2099,6 @@ class CourseManager
$course_tables = AddCourse::get_course_tables();
// Cleaning group categories
$groupCategories = GroupManager::get_categories($course['code']);
if (!empty($groupCategories)) {
@ -2118,9 +2129,6 @@ class CourseManager
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
$sql = "DELETE FROM $table_course_user WHERE c_id='" . $courseId . "'";
Database::query($sql);
@ -2326,10 +2334,13 @@ class CourseManager
public static function course_exists($course_code, $accept_virtual = false)
{
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 {
$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));
}
@ -2559,6 +2570,7 @@ class CourseManager
return false;
}
$row = Database::fetch_array($res);
return $row['code'];
}
@ -3107,6 +3119,7 @@ class CourseManager
$medium->resize(100, 85, 0, false);
$medium->send_image($store_path . '/course-pic85x85.png', -1, 'png');
}
return $result;
}
@ -4052,6 +4065,7 @@ class CourseManager
}
}
}
return false;
}
@ -4070,7 +4084,9 @@ class CourseManager
$wanted_code = CourseManager::generate_course_code($wanted_code);
$table = Database::get_main_table(TABLE_MAIN_COURSE);
$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);
if (Database::num_rows($result) > 0) {
$row = Database::fetch_array($result);
@ -4081,6 +4097,7 @@ class CourseManager
return $wanted_code;
}
}
return false;
}
@ -4458,8 +4475,6 @@ class CourseManager
*/
public static function return_hot_courses($days = 30, $limit = 5)
{
global $_configuration;
if (api_is_invitee()) {
return array();
}
@ -4485,15 +4500,6 @@ class CourseManager
$table_course = Database::get_main_table(TABLE_MAIN_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 ...
$now = api_get_utc_datetime(time());
$sql = "SELECT COUNT(course_access_id) course_count, a.c_id, visibility
@ -4679,7 +4685,6 @@ class CourseManager
*/
public static function countAvailableCourses($accessUrlId = null)
{
global $_configuration;
$tableCourse = Database::get_main_table(TABLE_MAIN_COURSE);
$tableCourseRelAccessUrl = Database::get_main_table(TABLE_MAIN_ACCESS_URL_REL_COURSE);
$specialCourseList = self::get_special_course_list();
@ -5090,11 +5095,11 @@ class CourseManager
if ($getAllSessions) {
$sql = "SELECT count(*) as count
FROM $forum f
where f.c_id = %s";
WHERE f.c_id = %s";
} else {
$sql = "SELECT count(*) as count
FROM $forum f
where f.c_id = %s and f.session_id = %s";
WHERE f.c_id = %s and f.session_id = %s";
}
$sql = sprintf($sql, intval($courseId), intval($sessionId));
@ -5703,6 +5708,4 @@ class CourseManager
return $params;
}
}

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

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

@ -299,10 +299,6 @@ class CourseHome
foreach ($all_tools_list as & $tool) {
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
$published_lp_id = self::get_published_lp_id_from_link($tool['link']);

@ -299,7 +299,13 @@ class CourseRequestManager
if ($user_id != $course_request_info['code']) {
$user_info = api_get_user_info($user_id);
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 {
$user_id = $course_request_info['code'];
}
@ -308,7 +314,13 @@ class CourseRequestManager
if ($course_language != $course_request_info['course_language']) {
$user_info = api_get_user_info($user_id);
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
);
}
}

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

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

@ -22,59 +22,146 @@ function choose_image($file_name)
/* TABLES INITIALISATION */
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['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['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_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['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['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['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_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();
if (!is_array($file_name)) {
if (preg_match('/\.([[:alnum:]]+)(\?|$)/', $file_name, $extension)) {
$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];
}
}
@ -216,6 +303,7 @@ function get_total_folder_size($path, $can_see_invisible = false)
$result = Database::query($sql);
if ($result && Database::num_rows($result) != 0) {
$row = Database::fetch_row($result);
return $row[0] == null ? 0 : $row[0];
} else {
return 0;

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

@ -62,9 +62,10 @@ class GradeModel extends Model
/**
* Returns a Form validator Obj
* @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)
{
@ -189,6 +190,7 @@ class GradeModel extends Model
// Setting the rules
$form->addRule('name', get_lang('ThisFieldIsRequired'), 'required');
return $form;
}

@ -479,7 +479,6 @@ class SocialManager extends UserManager
} else {
$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
if (api_get_setting('course_images_in_courses_list') === 'true') {
@ -502,7 +501,6 @@ class SocialManager extends UserManager
$session = '';
$active = false;
if (!empty($my_course['session_name']) && !empty($my_course['id_session'])) {
// Request for the name of the general coach
@ -522,7 +520,6 @@ class SocialManager extends UserManager
if (api_get_setting('show_session_coach') === 'true') {
$session['coach'] = get_lang('GeneralCoach').': '.api_get_person_name($sessioncoach['firstname'], $sessioncoach['lastname']);
}
$active = true;
} else {
$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') {
@ -531,7 +528,12 @@ class SocialManager extends UserManager
}
}
$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;
}

@ -22,7 +22,6 @@ require 'learnpath_functions.inc.php';
//include '../resourcelinker/resourcelinker.inc.php';
require '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 */
$currentstyle = api_get_setting('stylesheets');

@ -7,7 +7,6 @@
* @package chamilo.reports
*/
exit;
// name of the language file that needs to be included
$cidReset = true;
// including files

@ -8,7 +8,6 @@
* @package chamilo.reports
*/
exit;
// name of the language file that needs to be included
$cidReset = true;
// including files

@ -202,44 +202,6 @@ class TestForumFunction extends UnitTestCase {
//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.
@ -270,25 +232,6 @@ class TestForumFunction extends UnitTestCase {
//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
* @param string a comment about file

Loading…
Cancel
Save