From 534792cd82edf285c5225d4347e3ab5ad3a41a62 Mon Sep 17 00:00:00 2001 From: skodak Date: Sun, 1 Jun 2008 15:52:12 +0000 Subject: [PATCH] MDL-14679 removed all instances of get_records_select_menu() --- .../glossary_random/block_glossary_random.php | 4 ++-- lib/dmllib.php | 4 ++++ lib/dmllib_todo.php | 19 ------------------- lib/questionlib.php | 4 +++- mod/feedback/lib.php | 13 +++++++------ mod/scorm/locallib.php | 4 ++-- question/category_class.php | 3 ++- question/contextmove.php | 5 ++--- 8 files changed, 22 insertions(+), 34 deletions(-) diff --git a/blocks/glossary_random/block_glossary_random.php b/blocks/glossary_random/block_glossary_random.php index 855ae7df57..6fa57e51a2 100644 --- a/blocks/glossary_random/block_glossary_random.php +++ b/blocks/glossary_random/block_glossary_random.php @@ -109,7 +109,7 @@ class block_glossary_random extends block_base { } function instance_config_print() { - global $CFG; + global $CFG, $DB; if (!isset($this->config)) { // ... teacher has not yet configured the block, let's put some default values here to explain things @@ -123,7 +123,7 @@ class block_glossary_random extends block_base { } // select glossaries to put in dropdown box ... - $glossaries = get_records_select_menu('glossary', 'course='.$this->course->id,'name','id,name'); + $glossaries = $DB->get_records_menu('glossary', array('course'=>$this->course->id),'name','id,name'); //format menu texts to avoid html and to filter multilang values if(!empty($glossaries)) { diff --git a/lib/dmllib.php b/lib/dmllib.php index 85f684315a..50d56bf73f 100644 --- a/lib/dmllib.php +++ b/lib/dmllib.php @@ -431,3 +431,7 @@ function get_recordset_list($table, $field='', $values='', $sort='', $fields='*' function get_records_menu($table, $field='', $value='', $sort='', $fields='*', $limitfrom='', $limitnum='') { error('get_records_menu() removed'); } + +function get_records_select_menu($table, $select='', $sort='', $fields='*', $limitfrom='', $limitnum='') { + error('get_records_select_menu() removed'); +} diff --git a/lib/dmllib_todo.php b/lib/dmllib_todo.php index 65866c2be0..888df948a3 100644 --- a/lib/dmllib_todo.php +++ b/lib/dmllib_todo.php @@ -664,25 +664,6 @@ function records_to_menu($records, $field1, $field2) { } } -/** - * Get the first two columns from a number of records as an associative array. - * - * Arguments as for @see function get_recordset_select. - * Return value as for @see function get_records_menu. - * - * @param string $table The database table to be checked against. - * @param string $select A fragment of SQL to be used in a where clause in the SQL call. - * @param string $sort Sort order (optional) - a valid SQL order parameter - * @param string $fields A comma separated list of fields to be returned from the chosen table. - * @param int $limitfrom return a subset of records, starting at this point (optional, required if $limitnum is set). - * @param int $limitnum return a subset comprising this many records (optional, required if $limitfrom is set). - * @return mixed an associative array, or false if no records were found or an error occured. - */ -function get_records_select_menu($table, $select='', $sort='', $fields='*', $limitfrom='', $limitnum='') { - $rs = get_recordset_select($table, $select, $sort, $fields, $limitfrom, $limitnum); - return recordset_to_menu($rs); -} - /** * Get the first two columns from a number of records as an associative array. * diff --git a/lib/questionlib.php b/lib/questionlib.php index 008d28e9f3..6b6d03dbde 100644 --- a/lib/questionlib.php +++ b/lib/questionlib.php @@ -556,6 +556,8 @@ function question_delete_course($course, $feedback=true) { * @return boolean */ function question_delete_course_category($category, $newcategory, $feedback=true) { + global $DB; + $context = get_context_instance(CONTEXT_COURSECAT, $category->id); if (empty($newcategory)) { $feedbackdata = array(); // To store feedback to be showed at the end of the process @@ -578,7 +580,7 @@ function question_delete_course_category($category, $newcategory, $feedback=true // still in use somehow, even though quizzes in courses in this category will // already have been deteted. This could happen, for example, if questions are // added to a course, and then that course is moved to another category (MDL-14802). - $questionids = get_records_select_menu('question', 'category = ' . $category->id, '', 'id,1'); + $questionids = $DB->get_records_menu('question', array('category'=>$category->id), '', 'id,1'); if (!empty($questionids)) { if (!$rescueqcategory = question_save_from_deletion(implode(',', array_keys($questionids)), get_parent_contextid($context), print_context_name($context), $rescueqcategory)) { diff --git a/mod/feedback/lib.php b/mod/feedback/lib.php index 72f4d87254..80f5b8a4c9 100644 --- a/mod/feedback/lib.php +++ b/mod/feedback/lib.php @@ -1029,7 +1029,9 @@ function feedback_create_pagebreak($feedbackid) { * @return array all ordered pagebreak positions */ function feedback_get_all_break_positions($feedbackid) { - if(!$allbreaks = get_records_select_menu('feedback_item', "typ = 'pagebreak' AND feedback = ".$feedbackid, 'position', 'id, position')) return false; + global $DB; + + if(!$allbreaks = $DB->get_records_menu('feedback_item', array('typ'=>'pagebreak', 'feedback'=>$feedbackid), 'position', 'id, position')) return false; return array_values($allbreaks); } @@ -1359,16 +1361,15 @@ function feedback_get_group_values($item, $groupid = false, $courseid = false){ * @return boolean true if the feedback already is submitted otherwise false */ function feedback_is_already_submitted($feedbackid, $courseid = false) { - global $USER; + global $USER, $DB; - $select = 'userid = '.$USER->id.' AND feedback = '.$feedbackid; - if(!$trackings = get_records_select_menu('feedback_tracking', $select, '', 'id, completed')) { + if (!$trackings = $DB->get_records_menu('feedback_tracking', array('userid'=>$USER->id, 'feedback'=>$feedbackid), '', 'id, completed')) { return false; } if($courseid) { - $select = 'completed IN ('.implode(',',$trackings).') AND course_id = '.$courseid; - if(!$values = get_records_select('feedback_value', $select)) { + $select = 'completed IN ('.implode(',',$trackings).') AND course_id = ?'; + if(!$values = $DB->get_records_select('feedback_value', $select, array($courseid))) { return false; } } diff --git a/mod/scorm/locallib.php b/mod/scorm/locallib.php index bb368b3e1c..f9ae7fd56e 100755 --- a/mod/scorm/locallib.php +++ b/mod/scorm/locallib.php @@ -485,7 +485,7 @@ function scorm_course_format_display($user,$course) { } function scorm_view_display ($user, $scorm, $action, $cm, $boxwidth='') { - global $CFG; + global $CFG, $DB; if ($scorm->updatefreq == UPDATE_EVERYTIME){ require_once($CFG->dirroot.'/mod/scorm/lib.php'); @@ -503,7 +503,7 @@ function scorm_view_display ($user, $scorm, $action, $cm, $boxwidth='') { if (empty($organization)) { $organization = $scorm->launch; } - if ($orgs = get_records_select_menu('scorm_scoes',"scorm='$scorm->id' AND organization='' AND launch=''",'id','id,title')) { + if ($orgs = $DB->get_records_select_menu('scorm_scoes', array('scorm'=>$scorm->id, 'organization'=>'', 'launch'=>''), 'id', 'id,title')) { if (count($orgs) > 1) { ?>
diff --git a/question/category_class.php b/question/category_class.php index ca3c513faa..9a91402857 100644 --- a/question/category_class.php +++ b/question/category_class.php @@ -352,7 +352,8 @@ class question_category_object { } function move_questions($oldcat, $newcat){ - $questionids = get_records_select_menu('question', "category = $oldcat AND (parent = 0 OR parent = id)", '', 'id,1'); + global $DB; + $questionids = $DB->get_records_select_menu('question', "category = ? AND (parent = 0 OR parent = id)", array($oldcat), '', 'id,1'); if (!question_move_questions_to_category(implode(',', array_keys($questionids)), $newcat)) { print_error('errormovingquestions', 'question', $returnurl, $ids); } diff --git a/question/contextmove.php b/question/contextmove.php index d4fede6b3f..4b6f165afb 100644 --- a/question/contextmove.php +++ b/question/contextmove.php @@ -154,9 +154,8 @@ } //adjust sortorder before we make the cat a peer of it's new peers - $peers = get_records_select_menu('question_categories', "contextid = {$toparent->contextid} AND ". - "parent = {$toparent->id}", "sortorder ASC", - "id, id"); + $peers = $DB->get_records_select_menu('question_categories', "contextid = ? AND parent = ?", array($toparent->contextid, $toparent->id), + "sortorder ASC", "id, id"); $peers = array_keys($peers); if ($totop){ array_unshift($peers, $cattomove->id); -- 2.39.5