diff --git a/main/admin/access_url_check_user_session.php b/main/admin/access_url_check_user_session.php index 098af8ff31..84d3afa222 100755 --- a/main/admin/access_url_check_user_session.php +++ b/main/admin/access_url_check_user_session.php @@ -56,7 +56,6 @@ $order_clause = api_sort_by_first_name() ? ' ORDER BY firstname, lastname' : ' O $session_list = SessionManager::get_sessions_list(); - $html = ''; $show_users_with_problems = isset($_REQUEST['show_users_with_problems']) && $_REQUEST['show_users_with_problems'] == 1 ? true : false; if ($show_users_with_problems) { diff --git a/main/admin/access_url_edit.php b/main/admin/access_url_edit.php index 167e666a8f..2a81157bd6 100755 --- a/main/admin/access_url_edit.php +++ b/main/admin/access_url_edit.php @@ -159,3 +159,5 @@ $form->addElement('file','url_image_3','URL Image 3 (PNG)'); // Submit button $form->addElement('style_submit_button', 'submit', $submit_name, 'class="add"'); $form->display(); + +Display::display_footer(); diff --git a/main/admin/add_sessions_to_promotion.php b/main/admin/add_sessions_to_promotion.php index 08767bf443..e34fca2aee 100755 --- a/main/admin/add_sessions_to_promotion.php +++ b/main/admin/add_sessions_to_promotion.php @@ -93,7 +93,7 @@ if (isset($_POST['form_sent']) && $_POST['form_sent']) { } $promotion_data = $promotion->get($id); -$session_list = SessionManager::get_sessions_list(array(), array('name')); +$session_list = SessionManager::get_sessions_list(array(), array('name')); $session_not_in_promotion = $session_in_promotion= array(); if (!empty($session_list)) { @@ -126,17 +126,19 @@ function search_sessions($needle, $type) $needle = Database::escape_string($needle); $needle = api_convert_encoding($needle, $charset, 'utf-8'); - $session_list = SessionManager::get_sessions_list(array('s.name LIKE' => "$needle%")); + $session_list = SessionManager::get_sessions_list( + array('s.name' => array('operator' => 'LIKE', 'value' => "$needle%")) + ); $return .= ''; $xajax_response -> addAssign('ajax_list_multiple','innerHTML',api_utf8_encode($return)); - } + return $xajax_response; } $xajax->processRequests(); diff --git a/main/admin/add_sessions_to_usergroup.php b/main/admin/add_sessions_to_usergroup.php index 9edf901597..627ee5f39a 100755 --- a/main/admin/add_sessions_to_usergroup.php +++ b/main/admin/add_sessions_to_usergroup.php @@ -98,7 +98,7 @@ if (isset($_POST['form_sent']) && $_POST['form_sent']) { $elements_posted = array(); } if ($form_sent == 1) { - //added a parameter to send emails when registering a user + //added a parameter to send emails when registering a user $usergroup->subscribe_sessions_to_usergroup($id, $elements_posted); header('Location: usergroups.php'); exit; @@ -145,9 +145,13 @@ function search_sessions($needle,$type) { $order_clause. ' LIMIT 11';*/ } else if ($type == 'searchbox') { - $session_list = SessionManager::get_sessions_list(array('s.name LIKE' => "%$needle%")); + $session_list = SessionManager::get_sessions_list( + array('s.name' => array('operator' => 'LIKE', 'value' => "%$needle%")) + ); } else { - $session_list = SessionManager::get_sessions_list(array('s.name LIKE' => "$needle%")); + $session_list = SessionManager::get_sessions_list( + array('s.name' => array('operator' => 'LIKE', 'value' => "$needle%")) + ); } $i=0; if ($type=='single') { @@ -189,13 +193,10 @@ if ($add_type == 'multiple') { } echo '
'; -echo ''.Display::return_icon('back.png',get_lang('Back'),'',ICON_SIZE_MEDIUM).''; +echo ''.Display::return_icon('back.png',get_lang('Back'),'',ICON_SIZE_MEDIUM).''; echo ' '.Display::return_icon('div_show.gif',get_lang('Show'),array('style'=>'vertical-align:middle')).' '.get_lang('AdvancedSearch').''; echo '
'; - -?> - -'. get_lang('SearchSessions'); ?> : +echo '
> @@ -262,8 +263,8 @@ if(!empty($errorMsg)) {
-
@@ -313,9 +314,7 @@ if(!empty($errorMsg)) { '; -$form_sent=0; -$errorMsg=$firstLetterUser=$firstLetterSession=''; -$UserList=$SessionList=array(); -$sessions=array(); -$noPHP_SELF=true; +$form_sent = 0; +$errorMsg = $firstLetterUser = $firstLetterSession = ''; +$UserList = $SessionList = array(); +$sessions = array(); +$noPHP_SELF = true; if (isset($_POST['form_sent']) && $_POST['form_sent']) { $form_sent = $_POST['form_sent']; @@ -330,7 +332,8 @@ if ($ajax_search) { $sql = "SELECT user_id, lastname, firstname, username, id_session, official_code FROM $tbl_user u INNER JOIN $tbl_session_rel_user - ON $tbl_session_rel_user.id_user = u.user_id AND $tbl_session_rel_user.relation_type<>".SESSION_RELATION_TYPE_RRHH." + ON $tbl_session_rel_user.id_user = u.user_id AND + $tbl_session_rel_user.relation_type<>".SESSION_RELATION_TYPE_RRHH." AND $tbl_session_rel_user.id_session = ".intval($id_session)." WHERE u.status<>".DRH." AND u.status<>6 $order_clause"; @@ -342,7 +345,8 @@ if ($ajax_search) { $sql="SELECT u.user_id, lastname, firstname, username, id_session, official_code FROM $tbl_user u INNER JOIN $tbl_session_rel_user - ON $tbl_session_rel_user.id_user = u.user_id AND $tbl_session_rel_user.relation_type<>".SESSION_RELATION_TYPE_RRHH." + ON $tbl_session_rel_user.id_user = u.user_id AND + $tbl_session_rel_user.relation_type<>".SESSION_RELATION_TYPE_RRHH." AND $tbl_session_rel_user.id_session = ".intval($id_session)." INNER JOIN $tbl_user_rel_access_url url_user ON (url_user.user_id=u.user_id) WHERE access_url_id = $access_url_id AND u.status<>".DRH." AND u.status<>6 @@ -438,8 +442,8 @@ if ($ajax_search) { } } - $result = Database::query($sql); - $users = Database::store_result($result,'ASSOC'); + $result = Database::query($sql); + $users = Database::store_result($result,'ASSOC'); foreach ($users as $uid => $user) { if ($user['id_session'] != $id_session) { $nosessionUsersList[$user['user_id']] = array( diff --git a/main/admin/course_list.php b/main/admin/course_list.php index 1d199d4e7a..ad8da98b35 100755 --- a/main/admin/course_list.php +++ b/main/admin/course_list.php @@ -23,36 +23,56 @@ $sessionId = isset($_GET['session_id']) ? $_GET['session_id'] : null; /** * Get the number of courses which will be displayed */ -function get_number_of_courses() { +function get_number_of_courses() +{ $course_table = Database :: get_main_table(TABLE_MAIN_COURSE); $sql = "SELECT COUNT(code) AS total_number_of_items FROM $course_table"; - if ((api_is_platform_admin() || api_is_session_admin()) && api_is_multiple_url_enabled() && api_get_current_access_url_id() != -1) { + if ((api_is_platform_admin() || api_is_session_admin()) && + api_is_multiple_url_enabled() && api_get_current_access_url_id() != -1 + ) { $access_url_rel_course_table = Database :: get_main_table(TABLE_MAIN_ACCESS_URL_REL_COURSE); $sql.= " INNER JOIN $access_url_rel_course_table url_rel_course ON (code=url_rel_course.course_code)"; } if (isset ($_GET['keyword'])) { - $keyword = Database::escape_string($_GET['keyword']); - $sql .= " WHERE (title LIKE '%".$keyword."%' OR code LIKE '%".$keyword."%' OR visual_code LIKE '%".$keyword."%')"; - } elseif (isset ($_GET['keyword_code'])) { - $keyword_code = Database::escape_string($_GET['keyword_code']); - $keyword_title = Database::escape_string($_GET['keyword_title']); - $keyword_category = Database::escape_string($_GET['keyword_category']); - $keyword_language = Database::escape_string($_GET['keyword_language']); - $keyword_visibility = Database::escape_string($_GET['keyword_visibility']); + $keyword = Database::escape_string("%".$_GET['keyword']."%"); + $sql .= " WHERE ( + title LIKE '".$keyword."' OR + code LIKE '".$keyword."' OR + visual_code LIKE '".$keyword."' + ) + "; + } elseif (isset($_GET['keyword_code'])) { + $keyword_code = Database::escape_string("%".$_GET['keyword_code']."%"); + $keyword_title = Database::escape_string("%".$_GET['keyword_title']."%"); + $keyword_category = Database::escape_string("%".$_GET['keyword_category']."%"); + $keyword_language = Database::escape_string("%".$_GET['keyword_language']."%"); + $keyword_visibility = Database::escape_string("%".$_GET['keyword_visibility']."%"); $keyword_subscribe = Database::escape_string($_GET['keyword_subscribe']); $keyword_unsubscribe = Database::escape_string($_GET['keyword_unsubscribe']); - $sql .= " WHERE (code LIKE '%".$keyword_code."%' OR visual_code LIKE '%".$keyword_code."%') AND title LIKE '%".$keyword_title."%' AND category_code LIKE '%".$keyword_category."%' AND course_language LIKE '%".$keyword_language."%' AND visibility LIKE '%".$keyword_visibility."%' AND subscribe LIKE '".$keyword_subscribe."'AND unsubscribe LIKE '".$keyword_unsubscribe."'"; + + $sql .= " WHERE + (code LIKE '".$keyword_code."' OR visual_code LIKE '".$keyword_code."') AND + title LIKE '".$keyword_title."' AND + category_code LIKE '".$keyword_category."' AND + course_language LIKE '".$keyword_language."' AND + visibility LIKE '".$keyword_visibility."' AND + subscribe LIKE '".$keyword_subscribe."' AND + unsubscribe LIKE '".$keyword_unsubscribe."' + "; } // adding the filter to see the user's only of the current access_url - if ((api_is_platform_admin() || api_is_session_admin()) && api_is_multiple_url_enabled() && api_get_current_access_url_id() != -1) { + if ((api_is_platform_admin() || api_is_session_admin()) && + api_is_multiple_url_enabled() && api_get_current_access_url_id() != -1 + ) { $sql.= " AND url_rel_course.access_url_id=".api_get_current_access_url_id(); } $res = Database::query($sql); $obj = Database::fetch_object($res); + return $obj->total_number_of_items; } @@ -62,9 +82,11 @@ function get_number_of_courses() { * @param int $number_of_items * @param int $column * @param string $direction + * * @return array */ -function get_course_data($from, $number_of_items, $column, $direction) { +function get_course_data($from, $number_of_items, $column, $direction) +{ $course_table = Database::get_main_table(TABLE_MAIN_COURSE); $sql = "SELECT code AS col0, @@ -80,35 +102,52 @@ function get_course_data($from, $number_of_items, $column, $direction) { visual_code FROM $course_table"; - if ((api_is_platform_admin() || api_is_session_admin()) && api_is_multiple_url_enabled() && api_get_current_access_url_id() != -1) { + if ((api_is_platform_admin() || api_is_session_admin()) && + api_is_multiple_url_enabled() && api_get_current_access_url_id() != -1 + ) { $access_url_rel_course_table = Database :: get_main_table(TABLE_MAIN_ACCESS_URL_REL_COURSE); $sql.= " INNER JOIN $access_url_rel_course_table url_rel_course ON (code=url_rel_course.course_code)"; } if (isset ($_GET['keyword'])) { - $keyword = Database::escape_string(trim($_GET['keyword'])); - $sql .= " WHERE (title LIKE '%".$keyword."%' OR code LIKE '%".$keyword."%' OR visual_code LIKE '%".$keyword."%' ) "; - } elseif (isset ($_GET['keyword_code'])) { - $keyword_code = Database::escape_string($_GET['keyword_code']); - $keyword_title = Database::escape_string($_GET['keyword_title']); - $keyword_category = Database::escape_string($_GET['keyword_category']); - $keyword_language = Database::escape_string($_GET['keyword_language']); - $keyword_visibility = Database::escape_string($_GET['keyword_visibility']); - $keyword_subscribe = Database::escape_string($_GET['keyword_subscribe']); - $keyword_unsubscribe = Database::escape_string($_GET['keyword_unsubscribe']); - $sql .= " WHERE (code LIKE '%".$keyword_code."%' OR visual_code LIKE '%".$keyword_code."%') AND title LIKE '%".$keyword_title."%' AND category_code LIKE '%".$keyword_category."%' AND course_language LIKE '%".$keyword_language."%' AND visibility LIKE '%".$keyword_visibility."%' AND subscribe LIKE '".$keyword_subscribe."'AND unsubscribe LIKE '".$keyword_unsubscribe."'"; + $keyword = Database::escape_string("%".trim($_GET['keyword'])."%"); + $sql .= " WHERE ( + title LIKE '".$keyword."' OR + code LIKE '".$keyword."' OR + visual_code LIKE '".$keyword."' + ) + "; + } elseif (isset($_GET['keyword_code'])) { + $keyword_code = Database::escape_string("%".$_GET['keyword_code']."%"); + $keyword_title = Database::escape_string("%".$_GET['keyword_title']."%"); + $keyword_category = Database::escape_string("%".$_GET['keyword_category']."%"); + $keyword_language = Database::escape_string("%".$_GET['keyword_language']."%"); + $keyword_visibility = Database::escape_string("%".$_GET['keyword_visibility']."%"); + $keyword_subscribe = Database::escape_string($_GET['keyword_subscribe']); + $keyword_unsubscribe = Database::escape_string($_GET['keyword_unsubscribe']); + + $sql .= " WHERE + (code LIKE '".$keyword_code."' OR visual_code LIKE '".$keyword_code."') AND + title LIKE '".$keyword_title."' AND + category_code LIKE '".$keyword_category."' AND + course_language LIKE '".$keyword_language."' AND + visibility LIKE '".$keyword_visibility."' AND + subscribe LIKE '".$keyword_subscribe."' AND + unsubscribe LIKE '".$keyword_unsubscribe."'"; } // Adding the filter to see the user's only of the current access_url. - if ((api_is_platform_admin() || api_is_session_admin()) && api_is_multiple_url_enabled() && api_get_current_access_url_id() != -1) { + if ((api_is_platform_admin() || api_is_session_admin()) && + api_is_multiple_url_enabled() && api_get_current_access_url_id() != -1 + ) { $sql.= " AND url_rel_course.access_url_id=".api_get_current_access_url_id(); } $sql .= " ORDER BY col$column $direction "; - $sql .= " LIMIT $from,$number_of_items"; + $sql .= " LIMIT $from, $number_of_items"; $res = Database::query($sql); - $courses = array (); + $courses = array(); while ($course = Database::fetch_array($res)) { // Place colour icons in front of courses. $show_visual_code = $course['visual_code'] != $course[2] ? Display::label($course['visual_code'], 'info') : null; @@ -118,6 +157,7 @@ function get_course_data($from, $number_of_items, $column, $direction) { $course_rem = array($course[0], $course[1], $course[2], $course[3], $course[4], $course[5], $course[6], $course[7]); $courses[] = $course_rem; } + return $courses; } diff --git a/main/admin/course_request_accepted.php b/main/admin/course_request_accepted.php index 506233006f..7e79905581 100755 --- a/main/admin/course_request_accepted.php +++ b/main/admin/course_request_accepted.php @@ -92,8 +92,9 @@ function get_number_of_requests() { /** * Get course data to display */ -function get_request_data($from, $number_of_items, $column, $direction) { - $keyword = Database::escape_string(trim($_GET['keyword'])); +function get_request_data($from, $number_of_items, $column, $direction) +{ + $keyword = isset($_GET['keyword']) ? Database::escape_string(trim($_GET['keyword'])) : null; $course_request_table = Database :: get_main_table(TABLE_MAIN_COURSE_REQUEST); $sql = "SELECT id AS col0, diff --git a/main/admin/dashboard_add_courses_to_user.php b/main/admin/dashboard_add_courses_to_user.php index 2629de17ac..0bd50f4f1a 100755 --- a/main/admin/dashboard_add_courses_to_user.php +++ b/main/admin/dashboard_add_courses_to_user.php @@ -59,16 +59,17 @@ if (!api_is_platform_admin()) { api_not_allowed(true); } -function search_courses($needle,$type) +function search_courses($needle, $type) { - global $_configuration, $tbl_course, $tbl_course_rel_user, $tbl_course_rel_access_url,$user_id; + global $_configuration, $tbl_course, $tbl_course_rel_access_url,$user_id; $xajax_response = new XajaxResponse(); $return = ''; - if(!empty($needle) && !empty($type)) { + if (!empty($needle) && !empty($type)) { // xajax send utf8 datas... datas in db can be non-utf8 datas $charset = api_get_system_encoding(); $needle = api_convert_encoding($needle, $charset, 'utf-8'); + $needle = Database::escape_string($needle); $assigned_courses_to_hrm = CourseManager::get_courses_followed_by_drh($user_id); $assigned_courses_code = array_keys($assigned_courses_to_hrm); @@ -190,9 +191,10 @@ if (count($assigned_courses_code) > 0) { } $needle = '%'; +$firstLetter = null; if (isset($_POST['firstLetterCourse'])) { - $needle = Database::escape_string($_POST['firstLetterCourse']); - $needle = "$needle%"; + $firstLetter = $_POST['firstLetterCourse']; + $needle = Database::escape_string($firstLetter.'%'); } if (api_is_multiple_url_enabled()) { @@ -249,7 +251,7 @@ if(!empty($msg)) { diff --git a/main/admin/dashboard_add_sessions_to_user.php b/main/admin/dashboard_add_sessions_to_user.php index 296c6dfea3..0bae98dffa 100755 --- a/main/admin/dashboard_add_sessions_to_user.php +++ b/main/admin/dashboard_add_sessions_to_user.php @@ -59,7 +59,7 @@ if (!api_is_platform_admin() && !api_is_session_admin()) { api_not_allowed(true); } -function search_sessions($needle,$type) +function search_sessions($needle, $type) { global $_configuration, $tbl_session_rel_access_url, $tbl_session, $user_id; @@ -69,6 +69,7 @@ function search_sessions($needle,$type) // xajax send utf8 datas... datas in db can be non-utf8 datas $charset = api_get_system_encoding(); $needle = api_convert_encoding($needle, $charset, 'utf-8'); + $needle = Database::escape_string($needle); $assigned_sessions_to_hrm = SessionManager::get_sessions_followed_by_drh($user_id); $assigned_sessions_id = array_keys($assigned_sessions_to_hrm); @@ -93,6 +94,7 @@ function search_sessions($needle,$type) $return .= ''; $xajax_response->addAssign('ajax_list_sessions_multiple','innerHTML',api_utf8_encode($return)); } + return $xajax_response; } @@ -192,8 +194,7 @@ if (count($assigned_sessions_id) > 0) { $needle = '%'; if (!empty($firstLetterSession)) { - $needle = Database::escape_string($firstLetterSession); - $needle = "$needle%"; + $needle = Database::escape_string($firstLetterSession.'%'); } if (api_is_multiple_url_enabled()) { @@ -222,7 +223,8 @@ $result = Database::query($sql); :   - + + - + : '; $select_destination .= ''; diff --git a/main/document/slideshow.php b/main/document/slideshow.php index 8c7ed1853a..37e3309e66 100755 --- a/main/document/slideshow.php +++ b/main/document/slideshow.php @@ -48,6 +48,7 @@ if (isset($_SESSION['image_files_only'])) { } // Calculating the current slide, next slide, previous slide and the number of slides +$slide = null; if ($slide_id != 'all') { $slide = $slide_id ? $slide_id : 0; $previous_slide = $slide - 1; @@ -64,9 +65,11 @@ function MM_openBrWindow(theURL,winName,features) { //v2.0 '; // Back forward buttons diff --git a/main/document/upload.php b/main/document/upload.php index 9fac9327b1..6433eb96bd 100755 --- a/main/document/upload.php +++ b/main/document/upload.php @@ -284,7 +284,7 @@ if (api_get_setting('search_enabled') == 'true') { $form->addElement('radio', 'if_exists', get_lang('UplWhatIfFileExists'), get_lang('UplDoNothing'), 'nothing'); $form->addElement('radio', 'if_exists', '', get_lang('UplOverwriteLong'), 'overwrite'); -$form->addElement('radio', 'if_exists', '', get_lang('UplRenameLong'), 'rename', array('checked="checked"')); +$form->addElement('radio', 'if_exists', '', get_lang('UplRenameLong'), 'rename'); // Close the java script and avoid the footer up $form->addElement('html', '
'); @@ -292,7 +292,17 @@ $form->addElement('html', ''); $form->addElement('style_submit_button', 'submitDocument', get_lang('SendDocument'), 'class="upload"'); $form->add_real_progress_bar('DocumentUpload', 'file'); -$defaults = array('index_document' => 'checked="checked"'); +$fileExistsOption = api_get_configuration_value('document_if_file_exists_option'); + +$defaultFileExistsOption = 'rename'; +if (!empty($fileExistsOption)) { + $defaultFileExistsOption = $fileExistsOption; +} + +$defaults = array( + 'index_document' => 'checked="checked"', + 'if_exists' => $defaultFileExistsOption +); $form->setDefaults($defaults); diff --git a/main/dropbox/index.php b/main/dropbox/index.php index 68aef7f876..a17d3e5284 100755 --- a/main/dropbox/index.php +++ b/main/dropbox/index.php @@ -5,7 +5,7 @@ require_once 'dropbox_init.inc.php'; // get the last time the user accessed the tool -if ($_SESSION[$_course['id']]['last_access'][TOOL_DROPBOX] == '') { +if (isset($_SESSION[$_course['id']]) && $_SESSION[$_course['id']]['last_access'][TOOL_DROPBOX] == '') { $last_access = get_last_tool_access(TOOL_DROPBOX); $_SESSION[$_course['id']]['last_access'][TOOL_DROPBOX] = $last_access; } else { @@ -181,9 +181,11 @@ if (isset($_GET['error']) AND !empty($_GET['error'])) { Display :: display_normal_message(get_lang($_GET['error'])); } +$dropbox_data_sent = array(); +$movelist = array(); +$dropbox_data_recieved = array(); if ($action != 'add') { - // Getting all the categories in the dropbox for the given user $dropbox_categories = get_dropbox_categories(); // Greating the arrays with the categories for the received files and for the sent files diff --git a/main/exercice/exercice.php b/main/exercice/exercice.php index 6e01b60196..adb7485bfb 100755 --- a/main/exercice/exercice.php +++ b/main/exercice/exercice.php @@ -405,7 +405,9 @@ if (Database :: num_rows($result_total)) { //get HotPotatoes files (active and inactive) if ($is_allowedToEdit) { $sql = "SELECT * FROM $TBL_DOCUMENT - WHERE c_id = $courseId AND path LIKE '".Database :: escape_string($uploadPath)."/%/%'"; + WHERE + c_id = $courseId AND + path LIKE '".Database :: escape_string($uploadPath.'/%/%')."'"; $res = Database::query($sql); $hp_count = Database :: num_rows($res); } else { @@ -413,7 +415,7 @@ if ($is_allowedToEdit) { WHERE d.id = ip.ref AND ip.tool = '".TOOL_DOCUMENT."' AND - d.path LIKE '".Database :: escape_string($uploadPath)."/%/%' AND + d.path LIKE '".Database :: escape_string($uploadPath.'/%/%')."' AND ip.visibility ='1' AND d.c_id = ".$courseId." AND ip.c_id = ".$courseId; @@ -920,7 +922,7 @@ if ($is_allowedToEdit) { d.id = ip.ref AND ip.tool = '".TOOL_DOCUMENT."' AND (d.path LIKE '%htm%') AND - d.path LIKE '".Database :: escape_string($uploadPath)."/%/%' + d.path LIKE '".Database :: escape_string($uploadPath.'/%/%')."' LIMIT ".$from.",".$limit; // only .htm or .html files listed } else { $sql = "SELECT d.path as path, d.comment as comment, ip.visibility as visibility @@ -931,7 +933,7 @@ if ($is_allowedToEdit) { d.id = ip.ref AND ip.tool = '".TOOL_DOCUMENT."' AND (d.path LIKE '%htm%') AND - d.path LIKE '".Database :: escape_string($uploadPath)."/%/%' AND + d.path LIKE '".Database :: escape_string($uploadPath.'/%/%')."' AND ip.visibility='1' LIMIT ".$from.",".$limit; } diff --git a/main/exercice/exercise.lib.php b/main/exercice/exercise.lib.php index 9a0b73250f..6d36767778 100755 --- a/main/exercice/exercise.lib.php +++ b/main/exercice/exercise.lib.php @@ -1379,7 +1379,9 @@ function get_exam_results_data( $teacher_id_list[] = $teacher['user_id']; } - //Simple exercises + $list_info = array(); + + // Simple exercises if (empty($hotpotatoe_where)) { $column = !empty($column) ? Database::escape_string($column) : null; $from = intval($from); @@ -1407,7 +1409,7 @@ function get_exam_results_data( $lp_list_obj = new learnpathList(api_get_user_id()); $lp_list = $lp_list_obj->get_flat_list(); - $list_info = array(); + if (is_array($results)) { $users_array_id = array(); diff --git a/main/exercice/exercise_show.php b/main/exercice/exercise_show.php index d5ff900ba4..a9cd087e99 100755 --- a/main/exercice/exercise_show.php +++ b/main/exercice/exercise_show.php @@ -72,6 +72,7 @@ if (api_is_course_session_coach( } } +$maxEditors = isset($_configuration['exercise_max_fckeditors_in_page']) ? $_configuration['exercise_max_fckeditors_in_page'] : 0; $is_allowedToEdit = api_is_allowed_to_edit(null, true) || $is_courseTutor || api_is_session_admin() || api_is_drh(); //Getting results from the exe_id. This variable also contain all the information about the exercise @@ -128,6 +129,8 @@ if ($origin != 'learnpath') { } ?> '; diff --git a/main/newscorm/learnpath.class.php b/main/newscorm/learnpath.class.php index eabb2d45f2..f66bce6415 100755 --- a/main/newscorm/learnpath.class.php +++ b/main/newscorm/learnpath.class.php @@ -4,8 +4,8 @@ use \ChamiloSession as Session; /** - * This class defines the parent attributes and methods for Chamilo learnpaths and SCORM - * learnpaths. It is used by the scorm class. + * This class defines the parent attributes and methods for Chamilo learnpaths + * and SCORM learnpaths. It is used by the scorm class. * * @package chamilo.learnpath * @author Yannick Warnier @@ -457,7 +457,6 @@ class learnpath $parent = intval($parent); $previous = intval($previous); - $type = Database::escape_string($type); $id = intval($id); $max_time_allowed = Database::escape_string(htmlentities($max_time_allowed)); if (empty ($max_time_allowed)) { @@ -515,7 +514,7 @@ class learnpath $new_item_id = -1; $id = Database::escape_string($id); - + $typeCleaned = Database::escape_string($type); if ($type == 'quiz') { $sql = 'SELECT SUM(ponderation) FROM ' . Database :: get_course_table(TABLE_QUIZ_QUESTION) . ' as quiz_question @@ -555,7 +554,7 @@ class learnpath ") VALUES ( $course_id , ".$this->get_id() . ", ". - "'" . $type . "', ". + "'" . $typeCleaned . "', ". "'', ". "'" . $title . "', ". "'" . $description . "', ". @@ -587,7 +586,7 @@ class learnpath ") VALUES (". $course_id. ",". $this->get_id() . ",". - "'" . $type . "',". + "'" . $typeCleaned . "',". "'',". "'" . $title . "',". "'" . $description . "',". @@ -760,13 +759,13 @@ class learnpath $publicated_on = api_get_utc_datetime(); } } else { - $publicated_on = Database::escape_string(api_get_utc_datetime($publicated_on)); + $publicated_on = Database::escape_string(api_get_utc_datetime($publicated_on)); } if ($expired_on == '0000-00-00 00:00:00' || empty($expired_on)) { $expired_on = ''; } else { - $expired_on = Database::escape_string(api_get_utc_datetime($expired_on)); + $expired_on = Database::escape_string(api_get_utc_datetime($expired_on)); } while (Database :: num_rows($res_name)) { @@ -967,7 +966,7 @@ class learnpath } */ } - $this->ordered_items = array (); + $this->ordered_items = array(); $this->index = 0; unset ($this->lp_id); //unset other stuff @@ -1465,7 +1464,6 @@ class learnpath } $prerequisite_id = Database::escape_string($prerequisite_id); - $tbl_lp_item = Database :: get_course_table(TABLE_LP_ITEM); if (!is_numeric($mastery_score) || $mastery_score < 0) { @@ -1674,7 +1672,7 @@ class learnpath if ($this->debug > 0) { error_log('New LP - In learnpath::get_current_item_id()', 0); } - if (!empty ($this->current)) { + if (!empty($this->current)) { $current = $this->current; } if ($this->debug > 2) { @@ -1814,7 +1812,7 @@ class learnpath /** * Gets the information about an item in a format usable as JavaScript to update * the JS API by just printing this content into the section of the message frame - * @param integer Item ID + * @param int $item_id * @return string */ public function get_js_info($item_id = '') @@ -1824,7 +1822,7 @@ class learnpath } $info = ''; - $item_id = Database::escape_string($item_id); + $item_id = intval($item_id); if (!empty($item_id) && is_object($this->items[$item_id])) { //if item is defined, return values from DB @@ -3294,9 +3292,9 @@ class learnpath /** * Gets a link to the resource from the present location, depending on item ID. - * @param string Type of link expected - * @param integer Learnpath item ID - * @return string Link to the lp_item resource + * @param string $type Type of link expected + * @param integer $item_id Learnpath item ID + * @return string $provided_toc Link to the lp_item resource */ public function get_link($type = 'http', $item_id = null, $provided_toc = false) { @@ -3326,7 +3324,7 @@ class learnpath $lp_table = Database::get_course_table(TABLE_LP_MAIN); $lp_item_table = Database::get_course_table(TABLE_LP_ITEM); $lp_item_view_table = Database::get_course_table(TABLE_LP_ITEM_VIEW); - $item_id = Database::escape_string($item_id); + $item_id = intval($item_id); $sql = "SELECT l.lp_type as ltype, l.path as lpath, li.item_type as litype, li.path as lipath, li.parameters as liparams FROM $lp_table l @@ -3366,7 +3364,6 @@ class learnpath // Now go through the specific cases to get the end of the path // @todo Use constants instead of int values. - switch ($lp_type) { case 1 : if ($lp_item_type == 'dokeos_chapter') { @@ -3425,13 +3422,13 @@ class learnpath } if ($type_quiz) { - $lp_item_id = Database::escape_string($lp_item_id); - $lp_view_id = Database::escape_string($lp_view_id); + $lp_item_id = intval($lp_item_id); + $lp_view_id = intval($lp_view_id); $sql = "SELECT count(*) FROM $lp_item_view_table WHERE c_id = $course_id AND - lp_item_id='" . (int) $lp_item_id . "' AND - lp_view_id ='" . (int) $lp_view_id . "' AND + lp_item_id='" . $lp_item_id . "' AND + lp_view_id ='" . $lp_view_id . "' AND status='completed'"; $result = Database::query($sql); $row_count = Database :: fetch_row($result); @@ -4114,7 +4111,7 @@ class learnpath { $course_id = api_get_course_int_id(); $tbl_lp = Database :: get_course_table(TABLE_LP_MAIN); - $lp_id = Database::escape_string($lp_id); + $lp_id = intval($lp_id); $sql = "SELECT * FROM $tbl_lp where c_id = ".$course_id." AND id=$lp_id"; $result = Database::query($sql); if (Database::num_rows($result)) { @@ -4341,7 +4338,7 @@ class learnpath /** * Sets the current item ID (checks if valid and authorized first) - * @param integer New item ID. If not given or not authorized, defaults to current + * @param integer $item_id New item ID. If not given or not authorized, defaults to current */ public function set_current_item($item_id = null) { @@ -4358,7 +4355,7 @@ class learnpath error_log('New LP - New current item given is ' . $item_id . '...', 0); } if (is_numeric($item_id)) { - $item_id = Database::escape_string($item_id); + $item_id = intval($item_id); // TODO: Check in database here. $this->last = $this->current; $this->current = $item_id; @@ -4442,11 +4439,11 @@ class learnpath } if (empty ($name)) return false; - $this->maker = Database::escape_string($name); + $this->maker = $name; $lp_table = Database :: get_course_table(TABLE_LP_MAIN); $course_id = api_get_course_int_id(); $lp_id = $this->get_id(); - $sql = "UPDATE $lp_table SET content_maker = '" . $this->maker . "' + $sql = "UPDATE $lp_table SET content_maker = '" . Database::escape_string($this->maker) . "' WHERE c_id = ".$course_id." AND id = '$lp_id'"; if ($this->debug > 2) { error_log('New LP - lp updated with new content_maker : ' . $this->maker, 0); @@ -4468,11 +4465,11 @@ class learnpath if (empty($name)) { return false; } - $this->name = Database::escape_string($name); + $this->name = $name; $lp_table = Database :: get_course_table(TABLE_LP_MAIN); $lp_id = $this->get_id(); $course_id = api_get_course_int_id(); - $sql = "UPDATE $lp_table SET name = '" . $this->name . "' + $sql = "UPDATE $lp_table SET name = '" . Database::escape_string($this->name). "' WHERE c_id = ".$course_id." AND id = '$lp_id'"; if ($this->debug > 2) { error_log('New LP - lp updated with new name : ' . $this->name, 0); @@ -4582,10 +4579,10 @@ class learnpath if ($this->debug > 0) { error_log('New LP - In learnpath::set_theme()', 0); } - $this->theme = Database::escape_string($name); + $this->theme = $name; $lp_table = Database :: get_course_table(TABLE_LP_MAIN); $lp_id = $this->get_id(); - $sql = "UPDATE $lp_table SET theme = '" . $this->theme . "' + $sql = "UPDATE $lp_table SET theme = '" . Database::escape_string($this->theme). "' WHERE c_id = ".$course_id." AND id = '$lp_id'"; if ($this->debug > 2) { error_log('New LP - lp updated with new theme : ' . $this->theme, 0); @@ -4606,10 +4603,11 @@ class learnpath error_log('New LP - In learnpath::set_preview_image()', 0); } - $this->preview_image = Database::escape_string($name); + $this->preview_image = $name; $lp_table = Database :: get_course_table(TABLE_LP_MAIN); $lp_id = $this->get_id(); - $sql = "UPDATE $lp_table SET preview_image = '" . $this->preview_image . "' + $sql = "UPDATE $lp_table SET + preview_image = '" . Database::escape_string($this->preview_image). "' WHERE c_id = ".$course_id." AND id = '$lp_id'"; if ($this->debug > 2) { error_log('New LP - lp updated with new preview image : ' . $this->preview_image, 0); @@ -4628,10 +4626,10 @@ class learnpath if ($this->debug > 0) { error_log('New LP - In learnpath::set_author()', 0); } - $this->author = Database::escape_string($name); + $this->author = $name; $lp_table = Database :: get_course_table(TABLE_LP_MAIN); $lp_id = $this->get_id(); - $sql = "UPDATE $lp_table SET author = '" . $this->author . "' + $sql = "UPDATE $lp_table SET author = '" . Database::escape_string($name). "' WHERE c_id = ".$course_id." AND id = '$lp_id'"; if ($this->debug > 2) { error_log('New LP - lp updated with new preview author : ' . $this->author, 0); @@ -4704,10 +4702,11 @@ class learnpath if (empty ($name)) return false; - $this->proximity = Database::escape_string($name); + $this->proximity = $name; $lp_table = Database :: get_course_table(TABLE_LP_MAIN); $lp_id = $this->get_id(); - $sql = "UPDATE $lp_table SET content_local = '" . $this->proximity . "' + $sql = "UPDATE $lp_table SET + content_local = '" . Database::escape_string($name) . "' WHERE c_id = ".$course_id." AND id = '$lp_id'"; if ($this->debug > 2) { error_log('New LP - lp updated with new proximity : ' . $this->proximity, 0); @@ -4756,7 +4755,7 @@ class learnpath /** * Sets and saves the expired_on date - * @param string Optional string giving the new author of this learnpath + * @param string $expired_on Optional string giving the new author of this learnpath * @return bool Returns true if author's name is not empty */ public function set_expired_on($expired_on) @@ -4767,13 +4766,14 @@ class learnpath } if (!empty($expired_on)) { - $this->expired_on = Database::escape_string(api_get_utc_datetime($expired_on)); + $this->expired_on = api_get_utc_datetime($expired_on); } else { $this->expired_on = ''; } $lp_table = Database :: get_course_table(TABLE_LP_MAIN); $lp_id = $this->get_id(); - $sql = "UPDATE $lp_table SET expired_on = '" . $this->expired_on . "' + $sql = "UPDATE $lp_table SET + expired_on = '" . Database::escape_string($this->expired_on) . "' WHERE c_id = ".$course_id." AND id = '$lp_id'"; if ($this->debug > 2) { error_log('New LP - lp updated with new expired_on : ' . $this->expired_on, 0); @@ -4784,7 +4784,7 @@ class learnpath /** * Sets and saves the publicated_on date - * @param string Optional string giving the new author of this learnpath + * @param string $publicated_on Optional string giving the new author of this learnpath * @return bool Returns true if author's name is not empty */ public function set_publicated_on($publicated_on) @@ -4794,13 +4794,14 @@ class learnpath error_log('New LP - In learnpath::set_expired_on()', 0); } if (!empty($publicated_on)) { - $this->publicated_on = Database::escape_string(api_get_utc_datetime($publicated_on)); + $this->publicated_on = api_get_utc_datetime($publicated_on); } else { $this->publicated_on = ''; } $lp_table = Database :: get_course_table(TABLE_LP_MAIN); $lp_id = $this->get_id(); - $sql = "UPDATE $lp_table SET publicated_on = '" . $this->publicated_on . "' + $sql = "UPDATE $lp_table SET + publicated_on = '" . Database::escape_string($this->publicated_on) . "' WHERE c_id = ".$course_id." AND id = '$lp_id'"; if ($this->debug > 2) { error_log('New LP - lp updated with new publicated_on : ' . $this->publicated_on, 0); @@ -4811,7 +4812,6 @@ class learnpath /** * Sets and saves the expired_on date - * @param string Optional string giving the new author of this learnpath * @return bool Returns true if author's name is not empty */ public function set_modified_on() @@ -4837,7 +4837,8 @@ class learnpath * @param string Error message. If empty, reinits the error string * @return void */ - public function set_error_msg($error = '') { + public function set_error_msg($error = '') + { if ($this->debug > 0) { error_log('New LP - In learnpath::set_error_msg()', 0); } @@ -4849,9 +4850,10 @@ class learnpath } /** - * Launches the current item if not 'sco' (starts timer and make sure there is a record ready in the DB) - * @param boolean Whether to allow a new attempt or not - * @return boolean True + * Launches the current item if not 'sco' + * (starts timer and make sure there is a record ready in the DB) + * @param boolean $allow_new_attempt Whether to allow a new attempt or not + * @return boolean */ public function start_current_item($allow_new_attempt = false) { @@ -4865,7 +4867,6 @@ class learnpath ($type == 1 && $item_type != TOOL_QUIZ && $item_type != TOOL_HOTPOTATOES) ) { $this->items[$this->current]->open($allow_new_attempt); - $this->autocomplete_parents($this->current); $prereq_check = $this->prerequisites_match($this->current); $this->items[$this->current]->save(false, $prereq_check); @@ -5710,17 +5711,28 @@ class learnpath $return .= "\tm.add(" . $menu . ", -1, '" . addslashes(Security::remove_XSS(($this->name))) . "');\n"; $tbl_lp_item = Database :: get_course_table(TABLE_LP_ITEM); - $sql = " SELECT id, title, description, item_type, path, parent_item_id, previous_item_id, next_item_id, max_score, min_score, mastery_score, display_order + $sql = " SELECT + id, + title, + description, + item_type, + path, + parent_item_id, + previous_item_id, + next_item_id, + max_score, + min_score, + mastery_score, + display_order FROM $tbl_lp_item - WHERE c_id = ".$course_id." AND lp_id = " . Database::escape_string($this->lp_id); + WHERE c_id = ".$course_id." AND lp_id = " . intval($this->lp_id); $result = Database::query($sql); $arrLP = array (); while ($row = Database :: fetch_array($result)) { $row['title'] = Security :: remove_XSS($row['title']); $row['description'] = Security :: remove_XSS($row['description']); - - $arrLP[] = array ( + $arrLP[] = array( 'id' => $row['id'], 'item_type' => $row['item_type'], 'title' => $row['title'], @@ -6007,9 +6019,10 @@ class learnpath fputs($fp, $content); fclose($fp); - $sql_update = "UPDATE " . $table_doc ." SET title='".Database::escape_string($_POST['title'])."' - WHERE c_id = ".$course_id." AND id = " . $document_id; - Database::query($sql_update); + $sql = "UPDATE " . $table_doc ." SET + title='".Database::escape_string($_POST['title'])."' + WHERE c_id = ".$course_id." AND id = " . $document_id; + Database::query($sql); } } } @@ -6026,9 +6039,8 @@ class learnpath $return = ''; if (is_numeric($item_id)) { $tbl_lp_item = Database :: get_course_table(TABLE_LP_ITEM); - $tbl_doc = Database :: get_course_table(TABLE_DOCUMENT); $sql = "SELECT lp.* FROM " . $tbl_lp_item . " as lp - WHERE c_id = ".$course_id." AND lp.id = " . Database::escape_string($item_id); + WHERE c_id = ".$course_id." AND lp.id = " . intval($item_id); $result = Database::query($sql); while ($row = Database :: fetch_array($result,'ASSOC')) { $_SESSION['parent_item_id'] = ($row['item_type'] == 'dokeos_chapter' || $row['item_type'] == 'dokeos_module' || $row['item_type'] == 'dir') ? $item_id : 0; @@ -6057,11 +6069,12 @@ class learnpath } break; case TOOL_DOCUMENT: - $tbl_doc = Database :: get_course_table(TABLE_DOCUMENT); - $sql_doc = "SELECT path FROM " . $tbl_doc . " WHERE c_id = ".$course_id." AND id = " . Database::escape_string($row['path']); - $result = Database::query($sql_doc); - $path_file = Database::result($result, 0, 0); - $path_parts = pathinfo($path_file); + $tbl_doc = Database :: get_course_table(TABLE_DOCUMENT); + $sql_doc = "SELECT path FROM " . $tbl_doc . " + WHERE c_id = ".$course_id." AND id = " . Database::escape_string($row['path']); + $result = Database::query($sql_doc); + $path_file = Database::result($result, 0, 0); + $path_parts = pathinfo($path_file); // TODO: Correct the following naive comparisons, also, htm extension is missing. if (in_array($path_parts['extension'], array( 'html', @@ -6095,7 +6108,8 @@ class learnpath $return = ''; if (is_numeric($item_id)) { $tbl_lp_item = Database :: get_course_table(TABLE_LP_ITEM); - $sql = "SELECT * FROM $tbl_lp_item WHERE c_id = ".$course_id." AND id = " . Database::escape_string($item_id); + $sql = "SELECT * FROM $tbl_lp_item + WHERE c_id = ".$course_id." AND id = " . intval($item_id); $res = Database::query($sql); $row = Database::fetch_array($res); @@ -6116,9 +6130,10 @@ class learnpath $sql_step = " SELECT lp.*, doc.path as dir FROM " . $tbl_lp_item . " as lp LEFT JOIN " . $tbl_doc . " as doc ON doc.id = lp.path - WHERE lp.c_id = $course_id AND - doc.c_id = $course_id AND - lp.id = " . Database::escape_string($item_id); + WHERE + lp.c_id = $course_id AND + doc.c_id = $course_id AND + lp.id = " . intval($item_id); $res_step = Database::query($sql_step); $row_step = Database :: fetch_array($res_step); $return .= $this->display_manipulate($item_id, $row['item_type']); @@ -6128,7 +6143,8 @@ class learnpath $link_id = (string) $row['path']; if (ctype_digit($link_id)) { $tbl_link = Database :: get_course_table(TABLE_LINK); - $sql_select = 'SELECT url FROM ' . $tbl_link . ' WHERE c_id = '.$course_id.' AND id = ' . Database::escape_string($link_id); + $sql_select = 'SELECT url FROM ' . $tbl_link . ' + WHERE c_id = '.$course_id.' AND id = ' . intval($link_id); $res_link = Database::query($sql_select); $row_link = Database :: fetch_array($res_link); if (is_array($row_link)) { @@ -7792,9 +7808,7 @@ class learnpath WHERE c_id = ".$course_id." AND lp_id = " . $this->lp_id; $result = Database::query($sql); - - $arrLP = array (); - + $arrLP = array(); while ($row = Database :: fetch_array($result)) { $arrLP[] = array ( 'id' => $row['id'], diff --git a/main/newscorm/lp_ajax_switch_item.php b/main/newscorm/lp_ajax_switch_item.php index 371cbefad8..2b6a932065 100755 --- a/main/newscorm/lp_ajax_switch_item.php +++ b/main/newscorm/lp_ajax_switch_item.php @@ -232,7 +232,8 @@ function switch_item_details($lp_id, $user_id, $view_id, $current_item, $next_it if ($debug > 1) { error_log('Prereq_match() returned '.htmlentities($mylp->error), 0); } - $_SESSION['scorm_item_id'] = $new_item_id; // Save the new item ID for the exercise tool to use. + // Save the new item ID for the exercise tool to use. + $_SESSION['scorm_item_id'] = $new_item_id; $_SESSION['lpobject'] = serialize($mylp); return $return; } diff --git a/main/newscorm/lp_ajax_switch_item_toc.php b/main/newscorm/lp_ajax_switch_item_toc.php index 7593d7798e..8267243118 100755 --- a/main/newscorm/lp_ajax_switch_item_toc.php +++ b/main/newscorm/lp_ajax_switch_item_toc.php @@ -167,4 +167,11 @@ function switch_item_toc($lp_id, $user_id, $view_id, $current_item, $next_item) $_SESSION['lpobject'] = serialize($mylp); return $return; } -echo switch_item_toc($_POST['lid'], $_POST['uid'], $_POST['vid'], $_POST['iid'], $_POST['next']); + +echo switch_item_toc( + $_POST['lid'], + $_POST['uid'], + $_POST['vid'], + $_POST['iid'], + $_POST['next'] +); diff --git a/main/newscorm/lp_controller.php b/main/newscorm/lp_controller.php index f305658ee8..3c7f836610 100755 --- a/main/newscorm/lp_controller.php +++ b/main/newscorm/lp_controller.php @@ -1060,8 +1060,11 @@ switch ($action) { break; case 'content': if ($debug > 0) error_log('New LP - content action triggered', 0); - if ($debug > 0) error_log('New LP - Item id is '.$_GET['item_id'], 0); - if (!$lp_found) { error_log('New LP - No learnpath given for content', 0); require 'lp_list.php'; } + if ($debug > 0) error_log('New LP - Item id is '.intval($_GET['item_id']), 0); + if (!$lp_found) { + error_log('New LP - No learnpath given for content', 0); + require 'lp_list.php'; + } else { $_SESSION['oLP']->save_last(); $_SESSION['oLP']->set_current_item($_GET['item_id']); diff --git a/main/reservation/rsys.php b/main/reservation/rsys.php index 5472906e60..44b551473b 100755 --- a/main/reservation/rsys.php +++ b/main/reservation/rsys.php @@ -1,14 +1,18 @@ '; } - if ($lijn2[5] == 0) { - $tabel[$count][5] = ''; - } else { - $tabel[$count][5] = ''; - } - $controle = true; - } - } - if (!$controle) { - $tabel[$count][2] = ''; - $tabel[$count][3] = ''; - $tabel[$count][4] = ''; - $tabel[$count][5] = ''; - } - $tabel[$count][6] = $itemid."-".$lijn[0]; + if ($lijn2[5] == 0) { + $tabel[$count][5] = ''; + } else { + $tabel[$count][5] = ''; + } + $controle = true; + } + } + if (!$controle) { + $tabel[$count][2] = ''; + $tabel[$count][3] = ''; + $tabel[$count][4] = ''; + $tabel[$count][5] = ''; + } + $tabel[$count][6] = $itemid."-".$lijn[0]; } } return $tabel; @@ -927,7 +931,7 @@ class Rsys { */ function get_table_reservations($from, $per_page, $column, $direction) { $sql = "SELECT DISTINCT r.id AS col0, i.name AS col1, DATE_FORMAT(r.start_at,'%Y-%m-%d %H:%i') AS col2, DATE_FORMAT(r.end_at,'%Y-%m-%d %H:%i') AS col3," . - "DATE_FORMAT(r.subscribe_from,'%Y-%m-%d %k:%i') AS col4, DATE_FORMAT(r.subscribe_until,'%Y-%m-%d %k:%i') AS col5,IF(timepicker <> 0, '".get_lang('TimePicker')."',CONCAT(r.subscribers,'/',r.max_users)) AS col6, r.notes AS col7, r.id as col8 + "DATE_FORMAT(r.subscribe_from,'%Y-%m-%d %k:%i') AS col4, DATE_FORMAT(r.subscribe_until,'%Y-%m-%d %k:%i') AS col5,IF(timepicker <> 0, '".get_lang('TimePicker')."',CONCAT(r.subscribers,'/',r.max_users)) AS col6, r.notes AS col7, r.id as col8 FROM ".Rsys :: getTable('reservation')." r INNER JOIN ".Rsys :: getTable('item')." i ON r.item_id=i.id LEFT JOIN ".Rsys :: getTable('item_rights')." ir ON ir.item_id=i.id @@ -1005,10 +1009,10 @@ class Rsys { LEFT JOIN ".Database :: get_main_table(TABLE_MAIN_CLASS)." c ON ir.class_id=c.id AND ir.item_id = r.item_id LEFT JOIN ".Database :: get_main_table(TABLE_MAIN_CLASS_USER)." cu ON cu.class_id = c.id WHERE ((ir.m_reservation=1 AND cu.user_id='".api_get_user_id()."') OR i.creator='".api_get_user_id()."' OR 1=". (api_is_platform_admin() ? 1 : 0).')'; - if (isset ($_GET['keyword'])) { - $keyword = Database::escape_string(trim($_GET['keyword'])); - $sql .= " AND (i.name LIKE '%".$keyword."%' OR i.description LIKE '%".$keyword."%' OR r.notes LIKE '%".$keyword."%')"; - } + if (isset ($_GET['keyword'])) { + $keyword = Database::escape_string(trim($_GET['keyword'])); + $sql .= " AND (i.name LIKE '%".$keyword."%' OR i.description LIKE '%".$keyword."%' OR r.notes LIKE '%".$keyword."%')"; + } return Database::result(Database::query($sql), 0, 0); } @@ -1033,7 +1037,7 @@ class Rsys { return 2; } if ($start_at < (date( 'Y-m-d H:i:s',time()))) - return 3; + return 3; if (($stamp_start_date != $stamp_end_date) && $timepicker == '1') { return 4; @@ -1192,10 +1196,10 @@ class Rsys { WHERE ((ir.m_reservation=1 AND cu.user_id='".api_get_user_id()."') OR i2.creator='".api_get_user_id()."' OR 1=". (api_is_platform_admin() ? 1 : 0)."))"; - if (isset ($_GET['keyword'])) { - $keyword = Database::escape_string(trim($_GET['keyword'])); - $sql .= " AND (i1.name LIKE '%".$keyword."%' or r1.start_at LIKE '%".$keyword."%' or r1.end_at LIKE '%".$keyword."%' or u.lastname LIKE '%".$keyword."%' or u.firstname LIKE '%".$keyword."%' or s.start_at LIKE '%".$keyword."%' or s.end_at LIKE '%".$keyword."%')"; - } + if (isset ($_GET['keyword'])) { + $keyword = Database::escape_string(trim($_GET['keyword'])); + $sql .= " AND (i1.name LIKE '%".$keyword."%' or r1.start_at LIKE '%".$keyword."%' or r1.end_at LIKE '%".$keyword."%' or u.lastname LIKE '%".$keyword."%' or u.firstname LIKE '%".$keyword."%' or s.start_at LIKE '%".$keyword."%' or s.end_at LIKE '%".$keyword."%')"; + } return Database::result(Database::query($sql), 0, 0); } @@ -1228,10 +1232,10 @@ class Rsys { WHERE ((ir.m_reservation=1 AND cu.user_id='".api_get_user_id()."') OR i2.creator='".api_get_user_id()."' OR 1=". (api_is_platform_admin() ? 1 : 0)."))"; - if (isset ($_GET['keyword'])) { - $keyword = Database::escape_string(trim($_GET['keyword'])); - $sql .= " AND (i1.name LIKE '%".$keyword."%' or c.name LIKE '%".$keyword."%' or r1.start_at LIKE '%".$keyword."%' or r1.end_at LIKE '%".$keyword."%' or u.lastname LIKE '%".$keyword."%' or u.firstname LIKE '%".$keyword."%' or s.start_at LIKE '%".$keyword."%' or s.end_at LIKE '%".$keyword."%')"; - } + if (isset ($_GET['keyword'])) { + $keyword = Database::escape_string(trim($_GET['keyword'])); + $sql .= " AND (i1.name LIKE '%".$keyword."%' or c.name LIKE '%".$keyword."%' or r1.start_at LIKE '%".$keyword."%' or r1.end_at LIKE '%".$keyword."%' or u.lastname LIKE '%".$keyword."%' or u.firstname LIKE '%".$keyword."%' or s.start_at LIKE '%".$keyword."%' or s.end_at LIKE '%".$keyword."%')"; + } $sql .= " ORDER BY col".$column." ".$direction." LIMIT ".$from.",".$per_page; /*$result = Database::query($sql); while ($array = Database::fetch_array($result, 'NUM')) diff --git a/main/social/group_topics.php b/main/social/group_topics.php index 7e7e6c87cd..fd2ca973c3 100755 --- a/main/social/group_topics.php +++ b/main/social/group_topics.php @@ -1,5 +1,6 @@ diff --git a/main/social/groups.php b/main/social/groups.php index 322a6370a2..20610891fb 100755 --- a/main/social/groups.php +++ b/main/social/groups.php @@ -1,5 +1,6 @@ @@ -47,9 +48,7 @@ function remove_image_form(id_elem1) { if (filepaths.childNodes.length < 3) { var link_attach = document.getElementById("link-more-attach"); if (link_attach) { - link_attach.innerHTML=\'' . get_lang( - 'AddOneMoreFile' - ) . '\'; + link_attach.innerHTML=\'' . get_lang('AddOneMoreFile') . '\'; } } } @@ -67,10 +66,7 @@ function add_image_form() { filepaths.appendChild(elem1); id_elem1 = "filepath_"+counter_image; id_elem1 = "\'"+id_elem1+"\'"; - document.getElementById("filepath_"+counter_image).innerHTML = " "; - + document.getElementById("filepath_"+counter_image).innerHTML = " "; if (filepaths.childNodes.length == 3) { var link_attach = document.getElementById("link-more-attach"); if (link_attach) { @@ -92,34 +88,33 @@ jQuery(document).ready(function() { $("#tab_browse").bind("tabsselect", function(event, ui) { window.location.href=ui.tab; }); + $("#tabs").tabs(); $("#tab_browse").tabs(); - var valor = "' . $anchor . '"; $(".head").click(function() { - $(this).next().next().slideToggle("fast"); - image_clicked = $("#" + this.id + " img").attr("src"); - image_clicked_info = image_clicked.split("/"); - image_real_clicked = image_clicked_info[image_clicked_info.length-1]; - image_path = image_clicked.split("img"); - current_path = image_path[0]+"img/"; - if (image_real_clicked == "div_show.gif") { - current_path = current_path+"div_hide.gif"; - $("#" + this.id + " img").attr("src", current_path); - } else { - current_path = current_path+"div_show.gif"; - $("#" + this.id + " img").attr("src", current_path) - } - return false; - }).next().next().hide(); + $(this).next().next().slideToggle("fast"); + image_clicked = $("#" + this.id + " img").attr("src"); + image_clicked_info = image_clicked.split("/"); + image_real_clicked = image_clicked_info[image_clicked_info.length-1]; + image_path = image_clicked.split("img"); + current_path = image_path[0]+"img/"; + if (image_real_clicked == "div_show.gif") { + current_path = current_path+"div_hide.gif"; + $("#" + this.id + " img").attr("src", current_path); + } else { + current_path = current_path+"div_show.gif"; + $("#" + this.id + " img").attr("src", current_path) + } + return false; + }).next().next().hide(); // anchor for current topic if (valor) { $("#"+valor).show(); window.location = document.URL+"#"+valor; } - }); '; diff --git a/main/social/message_for_group_form.inc.php b/main/social/message_for_group_form.inc.php index aad98fd704..1531461564 100755 --- a/main/social/message_for_group_form.inc.php +++ b/main/social/message_for_group_form.inc.php @@ -4,9 +4,7 @@ * Form for group message * @package chamilo.social */ -/** - * Initialization - */ + $language_file = array('registration', 'messages', 'userInfo', 'admin'); $cidReset = true; require_once '../inc/global.inc.php'; @@ -36,19 +34,15 @@ if (isset($_REQUEST['user_friend'])) { } $group_id = intval($_GET['group_id']); +$message_id = isset($_GET['message_id']) ? intval($_GET['message_id']) : null; -$message_id = intval($_GET['message_id']); $actions = array( 'add_message_group', 'edit_message_group', 'reply_message_group' ); -$allowed_action = (isset($_GET['action']) && in_array( - $_GET['action'], - $actions - )) ? Security::remove_XSS($_GET['action']) : ''; - +$allowed_action = (isset($_GET['action']) && in_array($_GET['action'], $actions)) ? Security::remove_XSS($_GET['action']) : ''; $to_group = ''; $subject = ''; $message = ''; @@ -75,24 +69,15 @@ if (!empty($group_id) && $allowed_action) { } } -$page_item = !empty($_GET['topics_page_nr']) ? intval( - $_GET['topics_page_nr'] -) : 1; -$param_item_page = isset($_GET['items_page_nr']) && isset($_GET['topic_id']) ? ('&items_' . intval( - $_GET['topic_id'] - ) . '_page_nr=' . (!empty($_GET['topics_page_nr']) ? intval( - $_GET['topics_page_nr'] - ) : 1)) : ''; +$page_item = !empty($_GET['topics_page_nr']) ? intval($_GET['topics_page_nr']) : 1; +$param_item_page = isset($_GET['items_page_nr']) && isset($_GET['topic_id']) ? ('&items_' . intval($_GET['topic_id']) . '_page_nr=' . (!empty($_GET['topics_page_nr']) ? intval($_GET['topics_page_nr']) : 1)) : ''; $param_item_page .= '&topic_id=' . intval($_GET['topic_id']); -$page_topic = !empty($_GET['topics_page_nr']) ? intval( - $_GET['topics_page_nr'] -) : 1; +$page_topic = !empty($_GET['topics_page_nr']) ? intval($_GET['topics_page_nr']) : 1; +$anchor = isset($_GET['anchor_topic']) ? Security::remove_XSS($_GET['anchor_topic']) : null; ?>
diff --git a/main/social/search.php b/main/social/search.php index dfdf366198..5f83164ccf 100755 --- a/main/social/search.php +++ b/main/social/search.php @@ -4,12 +4,11 @@ * @package chamilo.social * @author Julio Montoya */ -/** - * Initialization - */ + // name of the language file that needs to be included $language_file = array('registration', 'admin', 'userInfo'); -$cidReset = true; +$cidReset = true; + require_once '../inc/global.inc.php'; require_once api_get_path(LIBRARY_PATH).'group_portal_manager.lib.php'; require_once api_get_path(LIBRARY_PATH).'magpierss/rss_fetch.inc'; @@ -136,26 +135,30 @@ $this_section = SECTION_SOCIAL; $tool_name = get_lang('Search'); $interbreadcrumb[] = array('url' => 'profile.php', 'name' => get_lang('SocialNetwork')); -$query = isset($_GET['q']) ? Database::escape_string($_GET['q']) : null; +$query = isset($_GET['q']) ? Security::remove_XSS($_GET['q']): null; $query_search_type = isset($_GET['search_type']) && in_array($_GET['search_type'], array('0','1','2')) ? $_GET['search_type'] : null; $extra_fields = UserManager::get_extra_filtrable_fields(); $query_vars = array('q' => $query, 'search_type' => $query_search_type); -foreach ($extra_fields as $extra_field) { - $field_name = 'field_'.$extra_field['variable']; - if (isset($_GET[$field_name]) && $_GET[$field_name]!='0') { - $query_vars[$field_name]=$_GET[$field_name]; +if (!empty($extra_fields)) { + foreach ($extra_fields as $extra_field) { + $field_name = 'field_' . $extra_field['variable']; + if (isset($_GET[$field_name]) && $_GET[$field_name] != '0') { + $query_vars[$field_name] = $_GET[$field_name]; + } } } $social_avatar_block = SocialManager::show_social_avatar_block('search'); $social_menu_block = SocialManager::show_social_menu('search'); - $social_right_content = '
'.UserManager::get_search_form($query).'
'; +$groups = array(); +$totalGroups = array(); + // I'm searching something if ($query != '' || ($query_vars['search_type']=='1' && count($query_vars)>2) ) { $itemPerPage = 9; - + if ($_GET['search_type']=='0' || $_GET['search_type']=='1') { $page = isset($_GET['users_page_nr']) ? intval($_GET['users_page_nr']) : 1; $totalUsers = UserManager::get_all_user_tags($_GET['q'], 0, 0, $itemPerPage, true); @@ -169,7 +172,6 @@ if ($query != '' || ($query_vars['search_type']=='1' && count($query_vars)>2) ) $pageGroup = isset($_GET['groups_page_nr']) ? intval($_GET['groups_page_nr']) : 1; // Groups $fromGroups = intval(($pageGroup - 1) * $itemPerPage); - $totalGroups = GroupPortalManager::get_all_group_tags($_GET['q'], 0, $itemPerPage, true); $groups = GroupPortalManager::get_all_group_tags($_GET['q'], $fromGroups, $itemPerPage); } @@ -216,9 +218,7 @@ if ($query != '' || ($query_vars['search_type']=='1' && count($query_vars)>2) ) } $tag = isset($user['tag']) ? '

'.$user['tag'] : null; - $user_info['complete_name'] = Display::url($status_icon.$user_info['complete_name'], $url); - $invitations = $user['tag'].$send_inv.$send_msg; $results .= '
  • diff --git a/main/survey/survey.lib.php b/main/survey/survey.lib.php index 963e836043..40efc3ee81 100755 --- a/main/survey/survey.lib.php +++ b/main/survey/survey.lib.php @@ -872,6 +872,7 @@ class survey_manager $sql = "SELECT * FROM $table_survey_question_option WHERE c_id = $course_id AND survey_id='".Database::escape_string($survey_id)."'"; $result = Database::query($sql); + $return = array(); while ($row = Database::fetch_array($result, 'ASSOC')) { $return[$row['question_id']]['answers'][] = $row['option_text']; } @@ -2631,7 +2632,7 @@ class SurveyUtil * @author Patrick Cool , Ghent University * @version February 2007 */ - static function handle_reporting_actions($survey_data, $people_filled) + public static function handle_reporting_actions($survey_data, $people_filled) { $action = isset($_GET['action']) ? $_GET['action'] : null; @@ -2639,7 +2640,8 @@ class SurveyUtil $temp_questions_data = survey_manager::get_questions($_GET['survey_id']); // Sorting like they should be displayed and removing the non-answer question types (comment and pagebreak) - $my_temp_questions_data=($temp_questions_data==null) ? array() : $temp_questions_data; + $my_temp_questions_data = ($temp_questions_data==null) ? array() : $temp_questions_data; + $questions_data = array(); foreach ($my_temp_questions_data as $key => & $value) { if ($value['type'] != 'comment' && $value['type'] != 'pagebreak') { $questions_data[$value['sort']] = $value; @@ -2892,6 +2894,7 @@ class SurveyUtil } $currentQuestion = isset($_GET['question']) ? $_GET['question'] : 0; + $question = array(); echo '
    '; echo ''. @@ -2938,7 +2941,7 @@ class SurveyUtil } } - echo $question['survey_question']; + echo isset($question['survey_question']) ? $question['survey_question'] : null; if ($question['type'] == 'score') { /** @todo This function should return the options as this is needed further in the code */ diff --git a/main/survey/survey_list.php b/main/survey/survey_list.php index 350f543fa7..cadefddf22 100755 --- a/main/survey/survey_list.php +++ b/main/survey/survey_list.php @@ -38,6 +38,7 @@ event_access_tool(TOOL_SURVEY); * of the code) */ +$courseInfo = api_get_course_info(); $isDrhOfCourse = CourseManager::isUserSubscribedInCourseAsDrh( api_get_user_id(), $courseInfo diff --git a/main/template/default/auth/courses_categories.php b/main/template/default/auth/courses_categories.php index 98cbdf64a8..019fb947c0 100755 --- a/main/template/default/auth/courses_categories.php +++ b/main/template/default/auth/courses_categories.php @@ -7,7 +7,7 @@ * @package chamilo.auth */ -if (Security::remove_XSS($_REQUEST['action']) !== 'subscribe') { +if (isset($_REQUEST['action']) && Security::remove_XSS($_REQUEST['action']) !== 'subscribe') { $stok = Security::get_token(); } else { $stok = $_SESSION['sec_token']; @@ -33,6 +33,8 @@ if ($showSessions && isset($_POST['date'])) { } $userInfo = api_get_user_info(); +$code = isset($code) ? $code : null; + ?>