From 0024c660980157e1706f44ffafcf9c5f001ada76 Mon Sep 17 00:00:00 2001 From: Julio Montoya Date: Tue, 27 Jul 2010 17:44:07 +0200 Subject: [PATCH 1/5] Improving sql query performance --- main/newscorm/learnpath.class.php | 31 ++++++++++++++++--------------- 1 file changed, 16 insertions(+), 15 deletions(-) diff --git a/main/newscorm/learnpath.class.php b/main/newscorm/learnpath.class.php index beaf85eade..65b1357684 100755 --- a/main/newscorm/learnpath.class.php +++ b/main/newscorm/learnpath.class.php @@ -2406,7 +2406,7 @@ class learnpath { */ function get_iv_objectives_array($lp_iv_id = 0) { - global $charset; + global $chatset; $list = array (); $table = Database :: get_course_table(TABLE_LP_IV_OBJECTIVE); @@ -4512,7 +4512,8 @@ 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 * FROM " . $tbl_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 + FROM " . $tbl_lp_item . " WHERE lp_id = " . Database :: escape_string($this->lp_id); $result = Database::query($sql); $arrLP = array (); @@ -4520,20 +4521,20 @@ class learnpath { while ($row = Database :: fetch_array($result)) { $row['title'] = Security :: remove_XSS(api_convert_encoding($row['title'], $platform_charset, $this->encoding)); $row['description'] = Security :: remove_XSS(api_convert_encoding($row['description'], $platform_charset, $this->encoding)); - //$row['title'] = Security :: remove_XSS($row['title']); + $arrLP[] = array ( - 'id' => $row['id'], - 'item_type' => $row['item_type'], - 'title' => $row['title'], - 'path' => $row['path'], - 'description' => $row['description'], - 'parent_item_id' => $row['parent_item_id'], - 'previous_item_id' => $row['previous_item_id'], - 'next_item_id' => $row['next_item_id'], - 'max_score' => $row['max_score'], - 'min_score' => $row['min_score'], - 'mastery_score' => $row['mastery_score'], - 'display_order' => $row['display_order'] + 'id' => $row['id'], + 'item_type' => $row['item_type'], + 'title' => $row['title'], + 'path' => $row['path'], + 'description' => $row['description'], + 'parent_item_id' => $row['parent_item_id'], + 'previous_item_id' => $row['previous_item_id'], + 'next_item_id' => $row['next_item_id'], + 'max_score' => $row['max_score'], + 'min_score' => $row['min_score'], + 'mastery_score' => $row['mastery_score'], + 'display_order' => $row['display_order'] ); } From 2ae17d4ab870c968e017eb92bfb6b1a1dd70bf99 Mon Sep 17 00:00:00 2001 From: christian1827 Date: Tue, 27 Jul 2010 10:46:13 -0500 Subject: [PATCH 2/5] Fixed Images lost with SCORM export - partial CT#1039 --- main/newscorm/learnpath.class.php | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/main/newscorm/learnpath.class.php b/main/newscorm/learnpath.class.php index beaf85eade..3584804096 100755 --- a/main/newscorm/learnpath.class.php +++ b/main/newscorm/learnpath.class.php @@ -7578,7 +7578,7 @@ class learnpath { foreach($this->items as $index => $item){ if(!in_array($item->type , array(TOOL_QUIZ, TOOL_FORUM, TOOL_THREAD, TOOL_LINK, TOOL_STUDENTPUBLICATION))) { - //get included documents from this item + //get included documents from this item if($item->type=='sco') $inc_docs = $item->get_resources_from_source(null,api_get_path(SYS_COURSE_PATH).api_get_course_path().'/'.'scorm/'.$this->path.'/'.$item->get_path()); else @@ -7592,7 +7592,7 @@ class learnpath { //give a child element to the <item> element $my_title = $xmldoc->createElement('title',htmlspecialchars($item->get_title(), ENT_QUOTES, $this->encoding)); $my_item->appendChild($my_title); - //give a child element <adlcp:prerequisites> to the <item> element + //give a child element <adlcp:prerequisites> to the <item> element $my_prereqs = $xmldoc->createElement('adlcp:prerequisites',$this->get_scorm_prereq_string($my_item_id)); $my_prereqs->setAttribute('type','aicc_script'); $my_item->appendChild($my_prereqs); @@ -7603,7 +7603,7 @@ class learnpath { //give a child element <adlcp:datafromlms> to the <item> element - not yet supported //$xmldoc->createElement('adlcp:datafromlms',''); //give a child element <adlcp:masteryscore> to the <item> element - $my_masteryscore = $xmldoc->createElement('adlcp:masteryscore',$item->get_mastery_score()); + $my_masteryscore = $xmldoc->createElement('adlcp:masteryscore',$item->get_mastery_score()); $my_item->appendChild($my_masteryscore); @@ -8056,7 +8056,7 @@ class learnpath { } break; case 'abs': //absolute path from DocumentRoot. Save file and leave path as is in the zip - $current_dir = dirname($current_course_path.'/'.$item->get_file_path()).'/'; + $current_dir = dirname($current_course_path.'/'.$item->get_file_path()).'/'; $file_path = realpath($doc_info[0]); $my_dep_file->setAttribute('href',$file_path); $my_dep->setAttribute('xml:base',''); @@ -8092,7 +8092,7 @@ class learnpath { } break; case 'rel': //path relative to the current document. Save xml:base as current document's directory and save file in zip as subdir.file_path - if(substr($doc_info[0],0,2)=='..') + if(substr($doc_info[0],0,2)=='..') { //relative path going up $current_dir = dirname($current_course_path.'/'.$item->get_file_path()).'/'; $file_path = realpath($current_dir.$doc_info[0]); @@ -8107,7 +8107,7 @@ class learnpath { //file path is courses/DOKEOS/document/.... $info_file_path=explode('/',$file_path); if ($info_file_path[0]=='courses') {//add character "/" in file path - $file_path_dest='/'.$file_path; + $file_path_dest='document/'.$file_path; } //error_log('Reduced path: '.$file_path,0); @@ -8121,7 +8121,7 @@ class learnpath { $zip_files[] = $my_sub_dir.'/'.$doc_info[0]; $my_dep_file->setAttribute('href',$doc_info[0]); $my_dep->setAttribute('xml:base',$my_xml_sub_dir); - } + } break; default: From 623aebd3f66180660d3ce0865384595cead488c5 Mon Sep 17 00:00:00 2001 From: Julio Montoya <gugli100@gmail.com> Date: Tue, 27 Jul 2010 17:57:54 +0200 Subject: [PATCH 3/5] htmlpurifier calls changed to static see CT#1450 --- main/inc/lib/security.lib.php | 18 ++++++++++-------- 1 file changed, 10 insertions(+), 8 deletions(-) diff --git a/main/inc/lib/security.lib.php b/main/inc/lib/security.lib.php index 0059e35a5d..7d867f5922 100755 --- a/main/inc/lib/security.lib.php +++ b/main/inc/lib/security.lib.php @@ -230,12 +230,14 @@ class Security { * @return mixed Filtered string or array */ public static function remove_XSS ($var,$user_status=ANONYMOUS) { - $purifier = new HTMLPurifier(null,$user_status); - if (is_array($var)) { - return $purifier->purifyArray($var); - } else { - return $purifier->purify($var); - } - + static $purifier = array(); + if (!isset($purifier[$user_status])) { + $purifier[$user_status] = new HTMLPurifier(null, $user_status); + } + if (is_array($var)) { + return $purifier[$user_status]->purifyArray($var); + } else { + return $purifier[$user_status]->purify($var); + } } -} +} \ No newline at end of file From 2ec3aceb7fae6d4f5b5be7c5ef83ebe9380050cd Mon Sep 17 00:00:00 2001 From: Julio Montoya <gugli100@gmail.com> Date: Tue, 27 Jul 2010 18:37:53 +0200 Subject: [PATCH 4/5] Fixing double form bug when moving a forum item in a LP (bis) --- main/newscorm/learnpath.class.php | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/main/newscorm/learnpath.class.php b/main/newscorm/learnpath.class.php index f2dfff4cdc..81b3394df0 100755 --- a/main/newscorm/learnpath.class.php +++ b/main/newscorm/learnpath.class.php @@ -6974,12 +6974,14 @@ class learnpath { $return .= $this->display_manipulate($item_id, $row['item_type']); $return .= $this->display_student_publication_form('move', $item_id, $row); break; - case TOOL_FORUM : + case TOOL_FORUM : $return .= $this->display_manipulate($item_id, $row['item_type']); $return .= $this->display_forum_form('move', $item_id, $row); + break; case TOOL_THREAD : $return .= $this->display_manipulate($item_id, $row['item_type']); $return .= $this->display_forum_form('move', $item_id, $row); + break; } } From ac01dd05af02929c4114ec6e2fffd9e935ced090 Mon Sep 17 00:00:00 2001 From: Ivan Tcholakov <ivantcholakov@gmail.com> Date: Tue, 27 Jul 2010 19:38:28 +0300 Subject: [PATCH 5/5] $chatset ----> $charset --- main/newscorm/learnpath.class.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/main/newscorm/learnpath.class.php b/main/newscorm/learnpath.class.php index f2dfff4cdc..707c264241 100755 --- a/main/newscorm/learnpath.class.php +++ b/main/newscorm/learnpath.class.php @@ -2406,7 +2406,7 @@ class learnpath { */ function get_iv_objectives_array($lp_iv_id = 0) { - global $chatset; + global $charset; $list = array (); $table = Database :: get_course_table(TABLE_LP_IV_OBJECTIVE);