From 531e7e2c34d0126d8766ecc4f5a0f9e7f2c3006f Mon Sep 17 00:00:00 2001 From: Julio Montoya Date: Thu, 31 Jul 2014 16:18:32 +0200 Subject: [PATCH 1/3] Minor - adding commented 'allow_lp_return_link' conf see d942e8e92804ab4b7577cb5a7b143144ec605ed7 --- main/install/configuration.dist.php | 2 ++ 1 file changed, 2 insertions(+) diff --git a/main/install/configuration.dist.php b/main/install/configuration.dist.php index 75641bf53d..2cf6bdf3b7 100755 --- a/main/install/configuration.dist.php +++ b/main/install/configuration.dist.php @@ -194,3 +194,5 @@ $_configuration['system_stable'] = NEW_VERSION_STABLE; //$_configuration['save_user_last_login'] = true; // Allow course tutors in sessions to add existing students to their session //$_configuration['allow_tutors_to_assign_students_to_session'] = 'false'; +// Allow select the return link in the LP view +//$_configuration['allow_lp_return_link'] = 'false'; From ba3000da556af59eb2e90c971d54b5a9455aa3d8 Mon Sep 17 00:00:00 2001 From: Julio Montoya Date: Thu, 31 Jul 2014 16:20:52 +0200 Subject: [PATCH 2/3] Minor - Adding comments, removing white spaces, fixing PHP warnings. --- main/admin/access_url_add_courses_to_url.php | 1 + main/admin/add_many_session_to_category.php | 86 ++++++------- main/admin/add_sessions_to_usergroup.php | 8 +- main/admin/archive_cleanup.php | 2 +- main/admin/course_list.php | 6 +- main/admin/dashboard_add_courses_to_user.php | 1 - main/admin/group_list.php | 2 +- main/admin/inactive_user_list.php | 11 +- main/admin/languages.php | 29 +---- main/admin/promotions.php | 66 +++++----- main/admin/session_category_add.php | 4 +- main/admin/session_category_edit.php | 5 +- main/admin/session_category_list.php | 25 ++-- main/admin/session_user_import.php | 4 +- main/admin/settings.lib.php | 13 +- main/admin/settings.php | 4 +- main/admin/sub_language.class.php | 2 +- main/admin/system_announcements.php | 2 +- main/admin/user_add.php | 8 +- main/admin/user_edit.php | 46 +++---- main/admin/user_export.php | 2 +- main/admin/user_information.php | 5 - main/admin/user_move_stats.php | 6 +- main/admin/usergroups.php | 6 +- .../classes/CourseBuilder.class.php | 1 - main/coursecopy/classes/Event.class.php | 8 +- main/coursecopy/classes/Resource.class.php | 20 +-- main/coursecopy/copy_course.php | 2 +- main/coursecopy/create_backup.php | 4 +- main/create_course/add_course.php | 19 ++- main/cron/img/list_used_img.php | 2 +- main/document/create_audio.php | 114 ++++++++---------- main/document/document.inc.php | 6 +- main/newscorm/lp_view.php | 2 + 34 files changed, 237 insertions(+), 285 deletions(-) diff --git a/main/admin/access_url_add_courses_to_url.php b/main/admin/access_url_add_courses_to_url.php index 0234b68301..bfc4cf3628 100755 --- a/main/admin/access_url_add_courses_to_url.php +++ b/main/admin/access_url_add_courses_to_url.php @@ -17,6 +17,7 @@ require_once api_get_path(LIBRARY_PATH).'urlmanager.lib.php'; $this_section=SECTION_PLATFORM_ADMIN; api_protect_global_admin_script(); + if (!api_get_multiple_access_url()) { header('Location: index.php'); exit; diff --git a/main/admin/add_many_session_to_category.php b/main/admin/add_many_session_to_category.php index e710894ace..d4291b32ce 100755 --- a/main/admin/add_many_session_to_category.php +++ b/main/admin/add_many_session_to_category.php @@ -86,54 +86,52 @@ function remove_item(origin) } '; -$formSent=0; -$errorMsg = $firstLetterCourse = $firstLetterSession=''; -$CourseList=$SessionList=array(); -$courses=$sessions=array(); -$Categoryid = intval($_POST['CategorySessionId']); - -if ($_POST['formSent']) { - $formSent=$_POST['formSent']; - $SessionCategoryList = $_POST['SessionCategoryList']; - - if($Categoryid != 0 && count($SessionCategoryList)>0 ){ - $session_id = join(',', $SessionCategoryList); - $sql = "UPDATE $tbl_session SET session_category_id = $Categoryid WHERE id in ($session_id) "; - Database::query($sql); - //header('Location: session_list.php?id_category='.$Categoryid); - header('Location: add_many_session_to_category.php?id_category='.$Categoryid.'&msg=ok'); - exit; - } else { - header('Location: add_many_session_to_category.php?msg=error'); - exit; - } +$formSent = 0; +$errorMsg = $firstLetterCourse = $firstLetterSession = ''; +$CourseList = $SessionList = array(); +$courses = $sessions = array(); +$Categoryid = isset($_POST['CategorySessionId']) ? intval($_POST['CategorySessionId']) : null; + +if (isset($_POST['formSent']) && $_POST['formSent']) { + $formSent = $_POST['formSent']; + $SessionCategoryList = $_POST['SessionCategoryList']; + + if ($Categoryid != 0 && count($SessionCategoryList) > 0) { + $session_id = join(',', $SessionCategoryList); + $sql = "UPDATE $tbl_session SET session_category_id = $Categoryid WHERE id in ($session_id) "; + Database::query($sql); + header('Location: add_many_session_to_category.php?id_category=' . $Categoryid . '&msg=ok'); + exit; + } else { + header('Location: add_many_session_to_category.php?msg=error'); + exit; + } } if (isset($_GET['id_category'])) { - $Categoryid = intval($_GET['id_category']); + $Categoryid = intval($_GET['id_category']); } -if(isset($_GET['msg']) && $_GET['msg']=='error'){ - $errorMsg = get_lang('MsgErrorSessionCategory'); +if (isset($_GET['msg']) && $_GET['msg'] == 'error') { + $errorMsg = get_lang('MsgErrorSessionCategory'); } -if(isset($_GET['msg']) && $_GET['msg']=='ok'){ - $OkMsg = get_lang('SessionCategoryUpdate'); +if (isset($_GET['msg']) && $_GET['msg'] == 'ok') { + $OkMsg = get_lang('SessionCategoryUpdate'); } - +$page = isset($_GET['page']) ? Security::remove_XSS($_GET['page']) : null; // display the dokeos header Display::display_header($tool_name); - -$where =''; +$where = ''; $rows_category_session = array(); -if((isset($_POST['CategorySessionId']) && $_POST['formSent'] == 0) || isset($_GET['id_category']) ) { - - $where = 'WHERE session_category_id !='.$Categoryid; - $sql = 'SELECT id, name FROM '.$tbl_session .' WHERE session_category_id ='.$Categoryid.' ORDER BY name'; - $result=Database::query($sql); - $rows_category_session = Database::store_result($result); +if ((isset($_POST['CategorySessionId']) && $_POST['formSent'] == 0) || isset($_GET['id_category'])) { + + $where = 'WHERE session_category_id !=' . $Categoryid; + $sql = 'SELECT id, name FROM ' . $tbl_session . ' WHERE session_category_id =' . $Categoryid . ' ORDER BY name'; + $result = Database::query($sql); + $rows_category_session = Database::store_result($result); } $rows_session_category = SessionManager::get_all_session_category(); @@ -153,13 +151,17 @@ if (api_get_multiple_access_url()) { $result=Database::query($sql); $rows_session = Database::store_result($result); ?> -
> - '.$tool_name.''; ?> - -?page=" style="margin:0px;"> + ' . $tool_name . ''; ?> + + "$needle%")); } - $i=0; + $i=0; if ($type=='single') { /* while ($user = Database :: fetch_array($rs)) { @@ -164,9 +164,9 @@ function search_sessions($needle,$type) { $xajax_response -> addAssign('ajax_list_users_single','innerHTML',api_utf8_encode($return));*/ } else { $return .= ''; while ($row = Database::fetch_array($result_select)) { - - if (in_array($row['isocode'], array('ca', 'en', 'es', 'hi', 'it', 'pt'))){ - + if (in_array($row['isocode'], array('ca', 'en', 'es', 'hi', 'it', 'pt'))) { if (api_get_setting('platformLanguage')==$row['english_name']){ echo ''; - } - else{ + } else { echo ''; } } @@ -335,8 +331,8 @@ $(document).ready(function(){ echo '
'; echo ''; - echo '

'; + echo ''; + echo '

'; echo ''; echo '
'; echo '
'; @@ -356,7 +352,8 @@ Display :: display_footer(); * @author Juan Carlos Raña Trabado * @version january 2011, chamilo 1.8.8 */ -function downloadMP3_google($filepath, $dir) { +function downloadMP3_google($filepath, $dir) +{ $location='create_audio.php?'.api_get_cidreq().'&id='.Security::remove_XSS($_POST['document_id']).'&dt2a=google'; //security @@ -468,9 +465,6 @@ function downloadMP3_pediaphon($filepath, $dir){ } $documentPath = $filepath.'/'.$audio_filename; - - - //prev for a fine unicode, borrowed from main api TODO:clean // Safe replacements for some non-letter characters (whitout blank spaces) @@ -486,49 +480,47 @@ function downloadMP3_pediaphon($filepath, $dir){ // Replacing remaining dangerous non-letter characters. $clean_text = str_replace($search, $replace, $filename); - //adding the file + //adding the file - - if ($clean_lang=='de'){ - $url_pediaphon='http://www.pediaphon.org/~bischoff/radiopedia/sprich_multivoice.cgi'; - $find_t2v = '/http\:\/\/www\.pediaphon\.org\/\~bischoff\/radiopedia\/mp3\/(.*)\.mp3\"/'; - } - else{ - $url_pediaphon='http://www.pediaphon.org/~bischoff/radiopedia/sprich_multivoice_'.$clean_lang.'.cgi';//en, es, fr - $find_t2v = '/http\:\/\/www\.pediaphon\.org\/\~bischoff\/radiopedia\/mp3\/'.$clean_lang.'\/(.*)\.mp3\"/'; - } + if ($clean_lang=='de') { + $url_pediaphon='http://www.pediaphon.org/~bischoff/radiopedia/sprich_multivoice.cgi'; + $find_t2v = '/http\:\/\/www\.pediaphon\.org\/\~bischoff\/radiopedia\/mp3\/(.*)\.mp3\"/'; + } else { + $url_pediaphon='http://www.pediaphon.org/~bischoff/radiopedia/sprich_multivoice_'.$clean_lang.'.cgi';//en, es, fr + $find_t2v = '/http\:\/\/www\.pediaphon\.org\/\~bischoff\/radiopedia\/mp3\/'.$clean_lang.'\/(.*)\.mp3\"/'; + } - $data="stimme=".$clean_voices."&inputtext=".$clean_text."&speed=".$clean_speed."&go=speak"; - $opts = array('http' => - array( - 'method' => 'POST', - 'header' =>"Content-Type: application/x-www-form-urlencoded\r\n", - "Content-Length: " . strlen($data) . "\r\n", - 'content' => $data - ) - ); - $context = stream_context_create($opts); - // Download the whole HTML page - $previous_returntext2voice = file_get_contents($url_pediaphon,false,$context); - - //extract the audio file path - $search_source=preg_match($find_t2v, $previous_returntext2voice, $hits); - $souce_end=substr($hits[0], 0,-1); - //download file - $returntext2voice = file_get_contents($souce_end); - //save file - $f = @file_put_contents($documentPath, $returntext2voice); - if ($f === false && !empty($php_errormsg)) { - error_log($php_errormsg); - } - //add document to database - $current_session_id = api_get_session_id(); - $groupId = $_SESSION['_gid']; - $file_size = filesize($documentPath); - $relativeUrlPath=$dir; - $doc_id = add_document($_course, $relativeUrlPath.$audio_filename, 'file', filesize($documentPath), $audio_title); - api_item_property_update($_course, TOOL_DOCUMENT, $doc_id, 'DocumentAdded', $_user['user_id'], $groupId, null, null, null, $current_session_id); - Display::display_confirmation_message(get_lang('DocumentCreated')); + $data="stimme=".$clean_voices."&inputtext=".$clean_text."&speed=".$clean_speed."&go=speak"; + $opts = array('http' => + array( + 'method' => 'POST', + 'header' =>"Content-Type: application/x-www-form-urlencoded\r\n", + "Content-Length: " . strlen($data) . "\r\n", + 'content' => $data + ) + ); + $context = stream_context_create($opts); + // Download the whole HTML page + $previous_returntext2voice = file_get_contents($url_pediaphon,false,$context); + + //extract the audio file path + $search_source=preg_match($find_t2v, $previous_returntext2voice, $hits); + $souce_end=substr($hits[0], 0,-1); + //download file + $returntext2voice = file_get_contents($souce_end); + //save file + $f = @file_put_contents($documentPath, $returntext2voice); + if ($f === false && !empty($php_errormsg)) { + error_log($php_errormsg); + } + //add document to database + $current_session_id = api_get_session_id(); + $groupId = $_SESSION['_gid']; + $file_size = filesize($documentPath); + $relativeUrlPath=$dir; + $doc_id = add_document($_course, $relativeUrlPath.$audio_filename, 'file', filesize($documentPath), $audio_title); + api_item_property_update($_course, TOOL_DOCUMENT, $doc_id, 'DocumentAdded', $_user['user_id'], $groupId, null, null, null, $current_session_id); + Display::display_confirmation_message(get_lang('DocumentCreated')); //return to location echo ''; } diff --git a/main/document/document.inc.php b/main/document/document.inc.php index 073e995419..4826dc6598 100755 --- a/main/document/document.inc.php +++ b/main/document/document.inc.php @@ -1,5 +1,4 @@ Date: Thu, 31 Jul 2014 12:02:27 -0500 Subject: [PATCH 3/3] Install just allowed plugins in the course - refs #7222 --- main/inc/lib/plugin.lib.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/main/inc/lib/plugin.lib.php b/main/inc/lib/plugin.lib.php index e75099e0a8..93e4326ce7 100755 --- a/main/inc/lib/plugin.lib.php +++ b/main/inc/lib/plugin.lib.php @@ -482,7 +482,7 @@ class AppPlugin if (file_exists($plugin_path)) { require $plugin_path; - if (isset($plugin_info) && isset($plugin_info['plugin_class'])) { + if (isset($plugin_info) && isset($plugin_info['plugin_class']) && $obj->isCoursePlugin) { $obj->course_install($courseId); } }