Skip to content

Commit

Permalink
Merge branch 'MDL-73342-master' of https://github.com/sarjona/moodle
Browse files Browse the repository at this point in the history
  • Loading branch information
rezaies committed Jan 18, 2022
2 parents 68a711b + 749c678 commit 945058b
Show file tree
Hide file tree
Showing 20 changed files with 261 additions and 21 deletions.
20 changes: 8 additions & 12 deletions adminpresets/classes/helper.php
Original file line number Diff line number Diff line change
Expand Up @@ -204,10 +204,10 @@ public static function create_default_presets(): void {
static::add_plugin($presetid, 'availability', 'grouping', false);
static::add_plugin($presetid, 'availability', 'profile', false);

// Blocks: Disable Activities, Blog menu, Blog tags, Comments, Course completion status, Course/site summary, Courses,
// Flickr, Global search, Latest badges, Learning plans, Logged in user, Login, Main menu, Mentees, Network servers,
// Private files, Recent blog entries, RSS feeds, Search forums, Section links,Self completion, Social activities,
// Tags, YouTube.
// Blocks: Hide Activities, Blog menu, Blog tags, Comments, Course completion status, Courses, Flickr,
// Global search, Latest badges, Learning plans, Logged in user, Login, Main menu, Mentees, Network servers, Private files,
// Recent blog entries, Search forums, Section links, Social activities,Tags, YouTube.
// Hidden by default: Course/site summary, RSS feeds, Self completion, Feedback.
static::add_plugin($presetid, 'block', 'activity_modules', false);
static::add_plugin($presetid, 'block', 'blog_menu', false);
static::add_plugin($presetid, 'block', 'blog_tags', false);
Expand Down Expand Up @@ -316,16 +316,15 @@ public static function create_default_presets(): void {
static::add_plugin($presetid, 'availability', 'grouping', true);
static::add_plugin($presetid, 'availability', 'profile', true);

// Blocks: Enable Activities, Blog menu, Blog tags, Comments, Course completion status, Course/site summary, Courses,
// Flickr, Global search, Latest badges, Learning plans, Logged in user, Login, Main menu, Mentees, Network servers,
// Private files, Recent blog entries, RSS feeds, Search forums, Section links,Self completion, Social activities,
// Tags, YouTube.
// Blocks: Enable Activities, Blog menu, Blog tags, Comments, Course completion status, Courses, Flickr,
// Global search, Latest badges, Learning plans, Logged in user, Login, Main menu, Mentees, Network servers, Private files,
// Recent blog entries, Search forums, Section links, Social activities,Tags, YouTube.
// Hidden by default: Course/site summary, RSS feeds, Self completion, Feedback.
static::add_plugin($presetid, 'block', 'activity_modules', true);
static::add_plugin($presetid, 'block', 'blog_menu', true);
static::add_plugin($presetid, 'block', 'blog_tags', true);
static::add_plugin($presetid, 'block', 'comments', true);
static::add_plugin($presetid, 'block', 'completionstatus', true);
static::add_plugin($presetid, 'block', 'course_summary', true);
static::add_plugin($presetid, 'block', 'course_list', true);
static::add_plugin($presetid, 'block', 'tag_flickr', true);
static::add_plugin($presetid, 'block', 'globalsearch', true);
Expand All @@ -338,13 +337,10 @@ public static function create_default_presets(): void {
static::add_plugin($presetid, 'block', 'mnet_hosts', true);
static::add_plugin($presetid, 'block', 'private_files', true);
static::add_plugin($presetid, 'block', 'blog_recent', true);
static::add_plugin($presetid, 'block', 'rss_client', true);
static::add_plugin($presetid, 'block', 'search_forums', true);
static::add_plugin($presetid, 'block', 'section_links', true);
static::add_plugin($presetid, 'block', 'selfcompletion', true);
static::add_plugin($presetid, 'block', 'social_activities', true);
static::add_plugin($presetid, 'block', 'tags', true);
static::add_plugin($presetid, 'block', 'feedback', true);

// Course formats: Enable Social format.
static::add_plugin($presetid, 'format', 'social', true);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ Feature: Enable Block Completion in a course using manual self completion
| user | course | role |
| teacher1 | C1 | editingteacher |
| student1 | C1 | student |
And I enable "selfcompletion" "block" plugin
And I log in as "teacher1"
And I am on "Course 1" course homepage with editing mode on
And I add the "Course completion status" block
Expand Down
33 changes: 33 additions & 0 deletions blocks/course_summary/db/install.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
<?php
// This file is part of Moodle - http://moodle.org/
//
// Moodle is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// Moodle is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with Moodle. If not, see <http://www.gnu.org/licenses/>.

/**
* Course summary block installation.
*
* @package block_course_summary
* @copyright 2021 Amaia Anabitarte <amaia@moodle.com>
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/

/**
* Perform the post-install procedures.
*/
function xmldb_block_course_summary_install() {
global $DB;

// Disable course_summary on new installs by default.
$DB->set_field('block', 'visible', 0, ['name' => 'course_summary']);
}
13 changes: 12 additions & 1 deletion blocks/course_summary/db/upgrade.php
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@
* @param object $block
*/
function xmldb_block_course_summary_upgrade($oldversion, $block) {
global $CFG;
global $CFG, $DB;

// Automatically generated Moodle v3.6.0 release upgrade line.
// Put any upgrade step following this.
Expand All @@ -60,5 +60,16 @@ function xmldb_block_course_summary_upgrade($oldversion, $block) {
// Automatically generated Moodle v3.9.0 release upgrade line.
// Put any upgrade step following this.

if ($oldversion < 2021121600) {
// From Moodle 4.0, this block has been disabled by default in new installations.
// If the site has no instances of this block, it will disabled during the upgrading process too.
$totalcount = $DB->count_records('block_instances', ['blockname' => 'course_summary']);
if ($totalcount == 0) {
$DB->set_field('block', 'visible', 0, ['name' => 'course_summary']);
}

upgrade_block_savepoint(true, 2021121600, 'course_summary', false);
}

return true;
}
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ Feature: Course summary block used in a course
| user | course | role |
| student1 | C101 | student |
| teacher1 | C101 | editingteacher |
And I enable "course_summary" "block" plugin
And I log in as "teacher1"
And I am on "Course 1" course homepage with editing mode on
And I add the "Course/site summary" block
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ Feature: Course summary block used on the frontpage

Background:
Given I log in as "admin"
And I enable "course_summary" "block" plugin
And I am on site homepage
And I turn editing mode on
And I add the "Course/site summary" block
Expand Down
2 changes: 1 addition & 1 deletion blocks/course_summary/version.php
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,6 @@

defined('MOODLE_INTERNAL') || die();

$plugin->version = 2021052500; // The current plugin version (Date: YYYYMMDDXX).
$plugin->version = 2021121600; // The current plugin version (Date: YYYYMMDDXX).
$plugin->requires = 2021052500; // Requires this Moodle version.
$plugin->component = 'block_course_summary'; // Full name of the plugin (used for diagnostics)
7 changes: 6 additions & 1 deletion blocks/feedback/db/install.php
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,13 @@
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/

/**
* Perform the post-install procedures.
*/
function xmldb_block_feedback_install() {
global $DB;

}
// Disable feedback on new installs by default.
$DB->set_field('block', 'visible', 0, ['name' => 'feedback']);

}
62 changes: 62 additions & 0 deletions blocks/feedback/db/upgrade.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,62 @@
<?php
// This file is part of Moodle - http://moodle.org/
//
// Moodle is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// Moodle is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with Moodle. If not, see <http://www.gnu.org/licenses/>.

/**
* This file keeps track of upgrades to the feedback block
*
* Sometimes, changes between versions involve alterations to database structures
* and other major things that may break installations.
*
* The upgrade function in this file will attempt to perform all the necessary
* actions to upgrade your older installation to the current version.
*
* If there's something it cannot do itself, it will tell you what you need to do.
*
* The commands in here will all be database-neutral, using the methods of
* database_manager class
*
* Please do not forget to use upgrade_set_timeout()
* before any action that may take longer time to finish.
*
* @package block_feedback
* @copyright 2021 Sara Arjona (sara@moodle.com)
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/

defined('MOODLE_INTERNAL') || die();

/**
* Handles upgrading instances of this block.
*
* @param int $oldversion
* @param object $block
*/
function xmldb_block_feedback_upgrade($oldversion, $block) {
global $CFG, $DB;

if ($oldversion < 2021121600) {
// From Moodle 4.0, this block has been disabled by default in new installations.
// If the site has no instances of this block, it will disabled during the upgrading process too.
$totalcount = $DB->count_records('block_instances', ['blockname' => 'feedback']);
if ($totalcount == 0) {
$DB->set_field('block', 'visible', 0, ['name' => 'feedback']);
}

upgrade_block_savepoint(true, 2021121600, 'feedback', false);
}

return true;
}
2 changes: 1 addition & 1 deletion blocks/feedback/version.php
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@

defined('MOODLE_INTERNAL') || die();

$plugin->version = 2021052500; // The current plugin version (Date: YYYYMMDDXX).
$plugin->version = 2021121600; // The current plugin version (Date: YYYYMMDDXX).
$plugin->requires = 2021052500; // Requires this Moodle version.
$plugin->component = 'block_feedback'; // Full name of the plugin (used for diagnostics)

Expand Down
33 changes: 33 additions & 0 deletions blocks/rss_client/db/install.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
<?php
// This file is part of Moodle - http://moodle.org/
//
// Moodle is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// Moodle is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with Moodle. If not, see <http://www.gnu.org/licenses/>.

/**
* RSS client block installation.
*
* @package block_rss_client
* @copyright 2021 Amaia Anabitarte <amaia@moodle.com>
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/

/**
* Perform the post-install procedures.
*/
function xmldb_block_rss_client_install() {
global $DB;

// Disable rss_client on new installs by default.
$DB->set_field('block', 'visible', 0, ['name' => 'rss_client']);
}
13 changes: 12 additions & 1 deletion blocks/rss_client/db/upgrade.php
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@
* @return boolean
*/
function xmldb_block_rss_client_upgrade($oldversion) {
global $CFG;
global $CFG, $DB;

// Automatically generated Moodle v3.6.0 release upgrade line.
// Put any upgrade step following this.
Expand All @@ -45,5 +45,16 @@ function xmldb_block_rss_client_upgrade($oldversion) {
// Automatically generated Moodle v3.9.0 release upgrade line.
// Put any upgrade step following this.

if ($oldversion < 2021121600) {
// From Moodle 4.0, this block has been disabled by default in new installations.
// If the site has no instances of this block, it will disabled during the upgrading process too.
$totalcount = $DB->count_records('block_instances', ['blockname' => 'rss_client']);
if ($totalcount == 0) {
$DB->set_field('block', 'visible', 0, ['name' => 'rss_client']);
}

upgrade_block_savepoint(true, 2021121600, 'rss_client', false);
}

return true;
}
2 changes: 1 addition & 1 deletion blocks/rss_client/version.php
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,6 @@

defined('MOODLE_INTERNAL') || die();

$plugin->version = 2021052500; // The current plugin version (Date: YYYYMMDDXX).
$plugin->version = 2021121600; // The current plugin version (Date: YYYYMMDDXX).
$plugin->requires = 2021052500; // Requires this Moodle version.
$plugin->component = 'block_rss_client'; // Full name of the plugin (used for diagnostics)
33 changes: 33 additions & 0 deletions blocks/selfcompletion/db/install.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
<?php
// This file is part of Moodle - http://moodle.org/
//
// Moodle is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// Moodle is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with Moodle. If not, see <http://www.gnu.org/licenses/>.

/**
* Selfcompletion block installation.
*
* @package block_selfcompletion
* @copyright 2021 Amaia Anabitarte <amaia@moodle.com>
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/

/**
* Perform the post-install procedures.
*/
function xmldb_block_selfcompletion_install() {
global $DB;

// Disable selfcompletion on new installs by default.
$DB->set_field('block', 'visible', 0, ['name' => 'selfcompletion']);
}
13 changes: 12 additions & 1 deletion blocks/selfcompletion/db/upgrade.php
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@
* @param object $block
*/
function xmldb_block_selfcompletion_upgrade($oldversion, $block) {
global $CFG;
global $CFG, $DB;

// Automatically generated Moodle v3.6.0 release upgrade line.
// Put any upgrade step following this.
Expand All @@ -60,5 +60,16 @@ function xmldb_block_selfcompletion_upgrade($oldversion, $block) {
// Automatically generated Moodle v3.9.0 release upgrade line.
// Put any upgrade step following this.

if ($oldversion < 2021121600) {
// From Moodle 4.0, this block has been disabled by default in new installations.
// If the site has no instances of this block, it will disabled during the upgrading process too.
$totalcount = $DB->count_records('block_instances', ['blockname' => 'selfcompletion']);
if ($totalcount == 0) {
$DB->set_field('block', 'visible', 0, ['name' => 'selfcompletion']);
}

upgrade_block_savepoint(true, 2021121600, 'selfcompletion', false);
}

return true;
}
2 changes: 1 addition & 1 deletion blocks/selfcompletion/version.php
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,6 @@

defined('MOODLE_INTERNAL') || die();

$plugin->version = 2021052500; // The current plugin version (Date: YYYYMMDDXX).
$plugin->version = 2021121600; // The current plugin version (Date: YYYYMMDDXX).
$plugin->requires = 2021052500; // Requires this Moodle version.
$plugin->component = 'block_selfcompletion'; // Full name of the plugin (used for diagnostics)
29 changes: 29 additions & 0 deletions lib/db/upgrade.php
Original file line number Diff line number Diff line change
Expand Up @@ -3538,5 +3538,34 @@ function xmldb_main_upgrade($oldversion) {
upgrade_main_savepoint(true, 2021123000.03);
}

if ($oldversion < 2022011100.01) {
// The following blocks have been hidden by default, so they shouldn't be enabled in the Full core preset: Course/site
// summary, RSS feeds, Self completion and Feedback.
$params = ['name' => get_string('fullpreset', 'core_adminpresets'), 'iscore' => 1];
$fullpreset = $DB->get_record('adminpresets', $params);

if ($fullpreset) {
$blocknames = ['course_summary', 'feedback', 'rss_client', 'selfcompletion'];
list($blocksinsql, $blocksinparams) = $DB->get_in_or_equal($blocknames);

// Remove entries from the adminpresets_app_plug table (in case the preset has been applied).
$appliedpresets = $DB->get_records('adminpresets_app', ['adminpresetid' => $fullpreset->id], '', 'id');
if ($appliedpresets) {
list($appsinsql, $appsinparams) = $DB->get_in_or_equal(array_keys($appliedpresets));
$sql = "adminpresetapplyid $appsinsql AND plugin='block' AND name $blocksinsql";
$params = array_merge($appsinparams, $blocksinparams);
$DB->delete_records_select('adminpresets_app_plug', $sql, $params);
}

// Remove entries for these blocks from the adminpresets_plug table.
$sql = "adminpresetid = ? AND plugin='block' AND name $blocksinsql";
$params = array_merge([$fullpreset->id], $blocksinparams);
$DB->delete_records_select('adminpresets_plug', $sql, $params);
}

// Main savepoint reached.
upgrade_main_savepoint(true, 2022011100.01);
}

return true;
}
Loading

0 comments on commit 945058b

Please sign in to comment.