MDL-66753 blocks: Remove block_participants from core

This commit is contained in:
Alexander Bias 2019-09-27 14:41:33 +02:00
parent 6ec1078469
commit 7ce941a455
11 changed files with 39 additions and 297 deletions

View File

@ -1,85 +0,0 @@
<?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/>.
/**
* Participants block
*
* @package block_participants
* @copyright 1999 onwards Martin Dougiamas (http://dougiamas.com)
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
defined('MOODLE_INTERNAL') || die();
require_once($CFG->dirroot . '/course/lib.php');
/**
* Participants block
*
* @package block_participants
* @copyright 1999 onwards Martin Dougiamas (http://dougiamas.com)
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
class block_participants extends block_list {
function init() {
$this->title = get_string('pluginname', 'block_participants');
}
function get_content() {
global $CFG, $OUTPUT;
if (empty($this->instance)) {
$this->content = '';
return $this->content;
}
$this->content = new stdClass();
$this->content->items = array();
$this->content->icons = array();
$this->content->footer = '';
// user/index.php expect course context, so get one if page has module context.
$currentcontext = $this->page->context->get_course_context(false);
if (empty($currentcontext)) {
$this->content = '';
return $this->content;
} else if ($this->page->course->id == SITEID) {
if (!course_can_view_participants(context_system::instance())) {
$this->content = '';
return $this->content;
}
} else {
if (!course_can_view_participants($currentcontext)) {
$this->content = '';
return $this->content;
}
}
$icon = $OUTPUT->pix_icon('i/users', '');
$this->content->items[] = '<a title="'.get_string('listofallpeople').'" href="'.
$CFG->wwwroot.'/user/index.php?contextid='.$currentcontext->id.'">'.$icon.get_string('participants').'</a>';
return $this->content;
}
// my moodle can only have SITEID and it's redundant here, so take it away
function applicable_formats() {
return array('all' => true, 'my' => false, 'tag' => false);
}
}

View File

@ -1,46 +0,0 @@
<?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/>.
/**
* Privacy Subsystem implementation for block_participants.
*
* @package block_participants
* @copyright 2018 Zig Tan <zig@moodle.com>
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
namespace block_participants\privacy;
defined('MOODLE_INTERNAL') || die();
/**
* Privacy Subsystem for block_participants implementing null_provider.
*
* @copyright 2018 Zig Tan <zig@moodle.com>
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
class provider implements \core_privacy\local\metadata\null_provider {
/**
* Get the language string identifier with the component's language
* file to explain why this plugin stores no data.
*
* @return string
*/
public static function get_reason() : string {
return 'privacy:metadata';
}
}

View File

@ -1,41 +0,0 @@
<?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/>.
/**
* Participants block caps.
*
* @package block_participants
* @copyright Mark Nelson <markn@moodle.com>
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
defined('MOODLE_INTERNAL') || die();
$capabilities = array(
'block/participants:addinstance' => array(
'riskbitmask' => RISK_SPAM | RISK_XSS,
'captype' => 'write',
'contextlevel' => CONTEXT_BLOCK,
'archetypes' => array(
'editingteacher' => CAP_ALLOW,
'manager' => CAP_ALLOW
),
'clonepermissionsfrom' => 'moodle/site:manageblocks'
),
);

View File

@ -1,27 +0,0 @@
<?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/>.
/**
* Strings for component 'block_participants', language 'en', branch 'MOODLE_20_STABLE'
*
* @package block_participants
* @copyright 1999 onwards Martin Dougiamas {@link http://moodle.com}
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
$string['participants:addinstance'] = 'Add a new people block';
$string['pluginname'] = 'People';
$string['privacy:metadata'] = 'The People block only shows data stored in other locations.';

View File

@ -1,40 +0,0 @@
@block @block_participants
Feature: People Block used in a course
In order to view participants in a course
As a teacher
I can add the people block to a course
Background:
Given the following "courses" exist:
| fullname | shortname | category |
| Course 1 | C101 | 0 |
And the following "users" exist:
| username | firstname | lastname | email |
| student1 | Sam | Student | student1@example.com |
And the following "course enrolments" exist:
| user | course | role |
| student1 | C101 | student |
And I log in as "admin"
And I am on "Course 1" course homepage with editing mode on
And I add the "People" block
And I log out
Scenario: Student can view participants link
When I log in as "student1"
And I am on "Course 1" course homepage
Then "People" "block" should exist
And I should see "Participants" in the "People" "block"
Scenario: Student can follow participants link and be directed to the correct page
When I log in as "student1"
And I am on "Course 1" course homepage
And I click on "Participants" "link" in the "People" "block"
Then I should see "Participants" in the "#page-content" "css_element"
Scenario: Student without permission can not view participants link
Given the following "permission overrides" exist:
| capability | permission | role | contextlevel | reference |
| moodle/course:viewparticipants | Prevent | student | Course | C101 |
When I log in as "student1"
And I am on "Course 1" course homepage
Then "People" "block" should not exist

View File

@ -1,26 +0,0 @@
@block @block_participants
Feature: People Block used on frontpage
In order to view participants in a site
As a admin
I can add the people block to the front page
Background:
Given the following "users" exist:
| username | firstname | lastname | email |
| student1 | Sam | Student | student1@example.com |
And I log in as "admin"
And I am on site homepage
And I navigate to "Turn editing on" in current page administration
And I add the "People" block
And I log out
Scenario: Admin can view site participants link
When I log in as "admin"
And I am on site homepage
Then "People" "block" should exist
And I should see "Participants" in the "People" "block"
Scenario: Student can not follow participants link on frontpage
When I log in as "student1"
And I am on site homepage
Then "People" "block" should not exist

View File

@ -1,29 +0,0 @@
<?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/>.
/**
* Version details
*
* @package block_participants
* @copyright 1999 onwards Martin Dougiamas (http://dougiamas.com)
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
defined('MOODLE_INTERNAL') || die();
$plugin->version = 2019052000; // The current plugin version (Date: YYYYMMDDXX)
$plugin->requires = 2019051100; // Requires this Moodle version
$plugin->component = 'block_participants'; // Full name of the plugin (used for diagnostics)

View File

@ -3,6 +3,7 @@ information provided here is intended especially for developers.
=== 3.8 ===
* Block block_community is no longer a part of core.
* Block block_participants is no longer a part of core.
=== 3.7 ===
* The block:addinstance capability is no longer required if the block can only be added to a dashboard.

View File

@ -1647,7 +1647,7 @@ class core_plugin_manager {
$plugins = array(
'qformat' => array('blackboard', 'learnwise'),
'auth' => array('radius', 'fc', 'nntp', 'pam', 'pop3', 'imap'),
'block' => array('course_overview', 'messages', 'community'),
'block' => array('course_overview', 'messages', 'community', 'participants'),
'cachestore' => array('memcache'),
'enrol' => array('authorize'),
'report' => array('search'),
@ -1718,7 +1718,7 @@ class core_plugin_manager {
'completionstatus', 'course_list', 'course_summary',
'feedback', 'globalsearch', 'glossary_random', 'html',
'login', 'lp', 'mentees', 'mnet_hosts', 'myoverview', 'myprofile',
'navigation', 'news_items', 'online_users', 'participants',
'navigation', 'news_items', 'online_users',
'private_files', 'quiz_results', 'recent_activity', 'recentlyaccesseditems',
'recentlyaccessedcourses', 'rss_client', 'search_forums', 'section_links',
'selfcompletion', 'settings', 'site_main_menu',

View File

@ -3556,5 +3556,40 @@ function xmldb_main_upgrade($oldversion) {
upgrade_main_savepoint(true, 2019092700.01);
}
if ($oldversion < 2019100400.01) {
// If block_participants is no longer present, remove it.
if (!file_exists($CFG->dirroot . '/blocks/participants/block_participants.php')) {
// Delete instances.
$instances = $DB->get_records_list('block_instances', 'blockname', ['participants']);
$instanceids = array_keys($instances);
if (!empty($instanceids)) {
$DB->delete_records_list('block_positions', 'blockinstanceid', $instanceids);
$DB->delete_records_list('block_instances', 'id', $instanceids);
list($sql, $params) = $DB->get_in_or_equal($instanceids, SQL_PARAMS_NAMED);
$params['contextlevel'] = CONTEXT_BLOCK;
$DB->delete_records_select('context', "contextlevel=:contextlevel AND instanceid " . $sql, $params);
$preferences = array();
foreach ($instances as $instanceid => $instance) {
$preferences[] = 'block' . $instanceid . 'hidden';
$preferences[] = 'docked_block_instance_' . $instanceid;
}
$DB->delete_records_list('user_preferences', 'name', $preferences);
}
// Delete the block from the block table.
$DB->delete_records('block', array('name' => 'participants'));
// Remove capabilities.
capabilities_cleanup('block_participants');
// Clean config.
unset_all_config_for_plugin('block_participants');
}
upgrade_main_savepoint(true, 2019100400.01);
}
return true;
}

View File

@ -29,7 +29,7 @@
defined('MOODLE_INTERNAL') || die();
$version = 2019100400.00; // YYYYMMDD = weekly release date of this DEV branch.
$version = 2019100400.01; // YYYYMMDD = weekly release date of this DEV branch.
// RR = release increments - 00 in DEV branches.
// .XX = incremental changes.