Merge branch 'MDL-75667-master' of https://github.com/farhan6318/moodle

This commit is contained in:
Paul Holden 2022-12-16 13:44:56 +00:00
commit 2f29c6fa5e
4 changed files with 27 additions and 8 deletions

View File

@ -74,9 +74,15 @@
/// Get and sort the existing blocks
if (!$blocks = $DB->get_records('block', array(), 'name ASC')) {
throw new \moodle_exception('noblocks', 'error'); // Should never happen.
}
$sql = "SELECT b.* , COUNT(DISTINCT binst.id) as totalcount, COUNT(DISTINCT bcinst.id) as courseviewcount
FROM {block} b
LEFT JOIN {block_instances} binst ON binst.blockname = b.name
LEFT JOIN {block_instances} bcinst ON bcinst.blockname = b.name AND bcinst.pagetypepattern = 'course-view-*'
GROUP BY b.id, binst.blockname, bcinst.blockname
ORDER BY b.name ASC";
if (!$blocks = $DB->get_records_sql($sql)) {
throw new \moodle_exception('noblocks', 'error'); // Should never happen.
}
$incompatible = array();
@ -154,9 +160,8 @@
// MDL-11167, blocks can be placed on mymoodle, or the blogs page
// and it should not show up on course search page
$totalcount = $DB->count_records('block_instances', array('blockname'=>$blockname));
$count = $DB->count_records('block_instances', array('blockname'=>$blockname, 'pagetypepattern'=>'course-view-*'));
$totalcount = $blocks[$blockid]->totalcount;
$count = $blocks[$blockid]->courseviewcount;
if ($count>0) {
$blocklist = "<a href=\"{$CFG->wwwroot}/course/search.php?blocklist=$blockid&amp;sesskey=".sesskey()."\" ";
$blocklist .= "title=\"$strshowblockcourse\" >$totalcount</a>";

View File

@ -1,5 +1,5 @@
<?xml version="1.0" encoding="UTF-8" ?>
<XMLDB PATH="lib/db" VERSION="20221017" COMMENT="XMLDB file for core Moodle tables"
<XMLDB PATH="lib/db" VERSION="20221216" COMMENT="XMLDB file for core Moodle tables"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:noNamespaceSchemaLocation="../../lib/xmldb/xmldb.xsd"
>
@ -2747,6 +2747,7 @@
<INDEXES>
<INDEX NAME="parentcontextid-showinsubcontexts-pagetypepattern-subpagepattern" UNIQUE="false" FIELDS="parentcontextid, showinsubcontexts, pagetypepattern, subpagepattern"/>
<INDEX NAME="timemodified" UNIQUE="false" FIELDS="timemodified"/>
<INDEX NAME="blocknameindex" UNIQUE="false" FIELDS="blockname"/>
</INDEXES>
</TABLE>
<TABLE NAME="block_positions" COMMENT="Stores the position of a sticky block_instance on a another page than the one where it was added.">

View File

@ -3051,5 +3051,18 @@ privatefiles,moodle|/user/files.php';
upgrade_main_savepoint(true, 2022120900.01);
}
if ($oldversion < 2022121600.01) {
// Define index blocknameindex (not unique) to be added to block_instances.
$table = new xmldb_table('block_instances');
$index = new xmldb_index('blocknameindex', XMLDB_INDEX_NOTUNIQUE, ['blockname']);
// Conditionally launch add index blocknameindex.
if (!$dbman->index_exists($table, $index)) {
$dbman->add_index($table, $index);
}
// Main savepoint reached.
upgrade_main_savepoint(true, 2022121600.01);
}
return true;
}

View File

@ -29,7 +29,7 @@
defined('MOODLE_INTERNAL') || die();
$version = 2022121600.00; // YYYYMMDD = weekly release date of this DEV branch.
$version = 2022121600.01; // YYYYMMDD = weekly release date of this DEV branch.
// RR = release increments - 00 in DEV branches.
// .XX = incremental changes.
$release = '4.2dev (Build: 20221216)'; // Human-friendly version name