mirror of
https://github.com/moodle/moodle.git
synced 2025-04-16 05:54:19 +02:00
navigation MDL-21177 Removed erroneous DB queries from module extension calls
This commit is contained in:
parent
d193b8729b
commit
56115eea49
@ -927,9 +927,8 @@ function choice_supports($feature) {
|
||||
}
|
||||
|
||||
function choice_extend_settings_navigation($settings, $module) {
|
||||
global $PAGE, $USER, $OUTPUT, $CFG, $DB;
|
||||
global $PAGE, $OUTPUT, $CFG;
|
||||
|
||||
$choice = $DB->get_record('choice', array('id'=>$PAGE->cm->instance));
|
||||
$choicenavkey = $settings->add(get_string('choiceadministration', 'choice'));
|
||||
$choicenav = $settings->get($choicenavkey);
|
||||
$choicenav->forceopen = true;
|
||||
@ -940,6 +939,9 @@ function choice_extend_settings_navigation($settings, $module) {
|
||||
if ($groupmode) {
|
||||
groups_get_activity_group($PAGE->cm, true);
|
||||
}
|
||||
// We only actually need the choice id here
|
||||
$choice = new stdClass;
|
||||
$choice->id = $PAGE->cm->instance;
|
||||
$allresponses = choice_get_response_data($choice, $PAGE->cm, $groupmode); // Big function, approx 6 SQL calls per user
|
||||
|
||||
$responsecount =0;
|
||||
|
@ -2860,9 +2860,12 @@ function data_extend_navigation($navigation, $course, $module, $cm) {
|
||||
}
|
||||
|
||||
function data_extend_settings_navigation($settings, $module) {
|
||||
global $PAGE, $USER, $OUTPUT, $CFG, $DB;
|
||||
global $PAGE, $OUTPUT, $CFG;
|
||||
|
||||
// We only actually need the id here for functions
|
||||
$data = new stdClass;
|
||||
$data->id = $PAGE->cm->instance;
|
||||
|
||||
$data = $DB->get_record('data', array('id'=>$PAGE->cm->instance));
|
||||
$datanavkey = $settings->add(get_string('dataadministration', 'data'));
|
||||
$datanav = $settings->get($datanavkey);
|
||||
$datanav->forceopen = true;
|
||||
|
@ -337,10 +337,8 @@ function folder_extend_navigation($navigation, $course, $module, $cm) {
|
||||
* @param stdClass $module
|
||||
*/
|
||||
function folder_extend_settings_navigation($settings, $module) {
|
||||
global $PAGE, $CFG, $DB;
|
||||
global $PAGE, $CFG;
|
||||
|
||||
// Load the folder instance from the database
|
||||
$folder = $DB->get_record('folder', array('id'=>$PAGE->cm->instance));
|
||||
// Add a folder node to the settings navigation.
|
||||
$foldernavkey = $settings->add(get_string('folderadministration', 'folder'));
|
||||
$foldernav = $settings->get($foldernavkey);
|
||||
|
@ -2684,12 +2684,11 @@ function glossary_extend_navigation($navigation, $course, $module, $cm) {
|
||||
}
|
||||
|
||||
function glossary_extend_settings_navigation($settings, $module) {
|
||||
global $PAGE, $DB, $CFG, $USER;
|
||||
global $PAGE, $DB, $CFG;
|
||||
|
||||
$mode = optional_param('mode', '', PARAM_ALPHA);
|
||||
$hook = optional_param('hook', 'ALL', PARAM_CLEAN);
|
||||
|
||||
$glossary = $DB->get_record('glossary', array('id'=>$PAGE->cm->instance));
|
||||
$glossarynavkey = $settings->add(get_string('glossaryadministration', 'glossary'));
|
||||
$glossarynav = $settings->get($glossarynavkey);
|
||||
$glossarynav->forceopen = true;
|
||||
@ -2702,7 +2701,7 @@ function glossary_extend_settings_navigation($settings, $module) {
|
||||
$glossarynav->add(get_string('exportentries', 'glossary'), new moodle_url($CFG->wwwroot.'/mod/glossary/export.php', array('id'=>$PAGE->cm->id, 'mode'=>$mode, 'hook'=>$hook)));
|
||||
}
|
||||
|
||||
if (has_capability('mod/glossary:approve', $PAGE->cm->context) && ($hiddenentries = $DB->count_records('glossary_entries', array('glossaryid'=>$glossary->id, 'approved'=>0)))) {
|
||||
if (has_capability('mod/glossary:approve', $PAGE->cm->context) && ($hiddenentries = $DB->count_records('glossary_entries', array('glossaryid'=>$PAGE->cm->instance, 'approved'=>0)))) {
|
||||
$glossarynav->add(get_string('waitingapproval', 'glossary'), new moodle_url($CFG->wwwroot.'/mod/glossary/view.php', array('id'=>$PAGE->cm->id, 'mode'=>'approval')));
|
||||
}
|
||||
|
||||
|
@ -404,10 +404,8 @@ function imscp_extend_navigation($navigation, $course, $module, $cm) {
|
||||
* @param stdClass $module
|
||||
*/
|
||||
function imscp_extend_settings_navigation($settings, $module) {
|
||||
global $PAGE, $CFG, $DB;
|
||||
global $PAGE, $CFG;
|
||||
|
||||
// Load the imscp instance from the database
|
||||
$imscp = $DB->get_record('imscp', array('id'=>$PAGE->cm->instance));
|
||||
// Add a imscp node to the settings navigation.
|
||||
$imscpnavkey = $settings->add(get_string('imscpadministration', 'imscp'));
|
||||
$imscpnav = $settings->get($imscpnavkey);
|
||||
|
@ -799,9 +799,8 @@ function lesson_extend_navigation($navigation, $course, $module, $cm) {
|
||||
* @param stdClass $module
|
||||
*/
|
||||
function lesson_extend_settings_navigation($settings, $module) {
|
||||
global $PAGE, $CFG, $DB, $USER, $OUTPUT;
|
||||
global $PAGE, $CFG, $USER, $OUTPUT;
|
||||
|
||||
$lesson = $DB->get_record('lesson', array('id'=>$PAGE->cm->instance));
|
||||
$lessonnavkey = $settings->add(get_string('lessonadministration', 'lesson'));
|
||||
$lessonnav = $settings->get($lessonnavkey);
|
||||
$lessonnav->forceopen = true;
|
||||
|
@ -410,10 +410,8 @@ function page_extend_navigation($navigation, $course, $module, $cm) {
|
||||
* @param stdClass $module
|
||||
*/
|
||||
function page_extend_settings_navigation($settings, $module) {
|
||||
global $PAGE, $CFG, $DB;
|
||||
global $PAGE, $CFG;
|
||||
|
||||
// Load the page instance from the database
|
||||
$page = $DB->get_record('page', array('id'=>$PAGE->cm->instance));
|
||||
// Add a page node to the settings navigation.
|
||||
$pagenavkey = $settings->add(get_string('pageadministration', 'page'));
|
||||
$pagenav = $settings->get($pagenavkey);
|
||||
|
@ -1453,9 +1453,8 @@ function quiz_extend_navigation($navigation, $course, $module, $cm) {
|
||||
* @param stdClass $module
|
||||
*/
|
||||
function quiz_extend_settings_navigation($settings, $module) {
|
||||
global $PAGE, $CFG, $DB, $USER, $OUTPUT;
|
||||
global $PAGE, $CFG, $OUTPUT;
|
||||
|
||||
$quiz = $DB->get_record('quiz', array('id'=>$PAGE->cm->instance));
|
||||
$quiznavkey = $settings->add(get_string('quizadministration', 'quiz'));
|
||||
$quiznav = $settings->get($quiznavkey);
|
||||
$quiznav->forceopen = true;
|
||||
@ -1465,13 +1464,13 @@ function quiz_extend_settings_navigation($settings, $module) {
|
||||
$quiznav->add(get_string('info', 'quiz'), $url, navigation_node::TYPE_SETTING, null, null, $OUTPUT->pix_url('i/info'));
|
||||
}
|
||||
if (has_capability('mod/quiz:viewreports', $PAGE->cm->context)) {
|
||||
$url = new moodle_url($CFG->wwwroot.'/mod/quiz/report.php', array('q'=>$quiz->id));
|
||||
$url = new moodle_url($CFG->wwwroot.'/mod/quiz/report.php', array('q'=>$PAGE->cm->instance));
|
||||
$reportkey = $quiznav->add(get_string('results', 'quiz'), $url, navigation_node::TYPE_SETTING, null, null, $OUTPUT->pix_url('i/report'));
|
||||
|
||||
require_once($CFG->dirroot.'/mod/quiz/report/reportlib.php');
|
||||
$reportlist = quiz_report_list($PAGE->cm->context);
|
||||
foreach ($reportlist as $report) {
|
||||
$url = new moodle_url($CFG->wwwroot.'/mod/quiz/report.php', array('q'=>$quiz->id, 'mode'=>$report));
|
||||
$url = new moodle_url($CFG->wwwroot.'/mod/quiz/report.php', array('q'=>$PAGE->cm->instance, 'mode'=>$report));
|
||||
$quiznav->get($reportkey)->add(get_string($report, 'quiz_'.$report), $url, navigation_node::TYPE_SETTING, null, null, $OUTPUT->pix_url('i/item'));
|
||||
}
|
||||
}
|
||||
|
@ -969,10 +969,8 @@ function scorm_extend_navigation($navigation, $course, $module, $cm) {
|
||||
* @param stdClass $module
|
||||
*/
|
||||
function scorm_extend_settings_navigation($settings, $module) {
|
||||
global $PAGE, $CFG, $DB;
|
||||
global $PAGE, $CFG;
|
||||
|
||||
// Load the scorm instance from the database
|
||||
$scorm = $DB->get_record('scorm', array('id'=>$PAGE->cm->instance));
|
||||
// Add a scorm node to the settings navigation.
|
||||
$scormnavkey = $settings->add(get_string('scormadministration', 'scorm'));
|
||||
$scormnav = $settings->get($scormnavkey);
|
||||
|
@ -822,9 +822,8 @@ function survey_extend_navigation($navigation, $course, $module, $cm) {
|
||||
* @param stdClass $module
|
||||
*/
|
||||
function survey_extend_settings_navigation($settings, $module) {
|
||||
global $PAGE, $CFG, $DB, $USER, $OUTPUT;
|
||||
global $PAGE, $CFG, $OUTPUT;
|
||||
|
||||
$survey = $DB->get_record('quiz', array('id'=>$PAGE->cm->instance));
|
||||
$surveynavkey = $settings->add(get_string('surveyadministration', 'survey'));
|
||||
$surveynav = $settings->get($surveynavkey);
|
||||
$surveynav->forceopen = true;
|
||||
|
@ -316,10 +316,8 @@ function url_extend_navigation($navigation, $course, $module, $cm) {
|
||||
* @param stdClass $module
|
||||
*/
|
||||
function url_extend_settings_navigation($settings, $module) {
|
||||
global $PAGE, $CFG, $DB;
|
||||
global $PAGE, $CFG;
|
||||
|
||||
// Load the url instance from the database
|
||||
$url = $DB->get_record('url', array('id'=>$PAGE->cm->instance));
|
||||
// Add a url node to the settings navigation.
|
||||
$urlnavkey = $settings->add(get_string('urladministration', 'url'));
|
||||
$urlnav = $settings->get($urlnavkey);
|
||||
|
Loading…
x
Reference in New Issue
Block a user