diff --git a/blocks/messages/block_messages.php b/blocks/messages/block_messages.php deleted file mode 100644 index 79d74b87648..00000000000 --- a/blocks/messages/block_messages.php +++ /dev/null @@ -1,95 +0,0 @@ -. - -/** - * Mentees block. - * - * @package block_messages - * @copyright 1999 onwards Martin Dougiamas (http://dougiamas.com) - * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later - */ - -class block_messages extends block_base { - function init() { - $this->title = get_string('pluginname', 'block_messages'); - } - - function get_content() { - global $USER, $CFG, $DB, $OUTPUT; - - if (!$CFG->messaging) { - $this->content = new stdClass; - $this->content->text = ''; - $this->content->footer = ''; - if ($this->page->user_is_editing()) { - $this->content->text = get_string('disabled', 'message'); - } - return $this->content; - } - - if ($this->content !== NULL) { - return $this->content; - } - - $this->content = new stdClass; - $this->content->text = ''; - $this->content->footer = ''; - - if (empty($this->instance) or !isloggedin() or isguestuser() or empty($CFG->messaging)) { - return $this->content; - } - - $link = '/message/index.php'; - $action = null; //this was using popup_action() but popping up a fullsize window seems wrong - $this->content->footer = $OUTPUT->action_link($link, get_string('messages', 'message'), $action); - - $ufields = user_picture::fields('u', array('lastaccess')); - $users = $DB->get_records_sql("SELECT $ufields, COUNT(m.useridfrom) AS count - FROM {user} u, {message} m - WHERE m.useridto = ? AND u.id = m.useridfrom AND m.notification = 0 - GROUP BY $ufields", array($USER->id)); - - - //Now, we have in users, the list of users to show - //Because they are online - if (!empty($users)) { - $this->content->text .= ''; - } else { - $this->content->text .= '
'; - $this->content->text .= get_string('nomessages', 'message'); - $this->content->text .= '
'; - } - - return $this->content; - } -} - - diff --git a/blocks/messages/db/access.php b/blocks/messages/db/access.php deleted file mode 100644 index 4ea589d3bc3..00000000000 --- a/blocks/messages/db/access.php +++ /dev/null @@ -1,51 +0,0 @@ -. - -/** - * Messages block caps. - * - * @package block_messages - * @copyright Mark Nelson - * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later - */ - -defined('MOODLE_INTERNAL') || die(); - -$capabilities = array( - - 'block/messages:myaddinstance' => array( - 'captype' => 'write', - 'contextlevel' => CONTEXT_SYSTEM, - 'archetypes' => array( - 'user' => CAP_ALLOW - ), - - 'clonepermissionsfrom' => 'moodle/my:manageblocks' - ), - - 'block/messages:addinstance' => array( - 'riskbitmask' => RISK_SPAM | RISK_XSS, - - 'captype' => 'write', - 'contextlevel' => CONTEXT_BLOCK, - 'archetypes' => array( - 'editingteacher' => CAP_ALLOW, - 'manager' => CAP_ALLOW - ), - - 'clonepermissionsfrom' => 'moodle/site:manageblocks' - ), -); diff --git a/blocks/messages/lang/en/block_messages.php b/blocks/messages/lang/en/block_messages.php deleted file mode 100644 index c41e51c1f23..00000000000 --- a/blocks/messages/lang/en/block_messages.php +++ /dev/null @@ -1,27 +0,0 @@ -. - -/** - * Strings for component 'block_messages', language 'en', branch 'MOODLE_20_STABLE' - * - * @package block_messages - * @copyright 1999 onwards Martin Dougiamas {@link http://moodle.com} - * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later - */ - -$string['messages:addinstance'] = 'Add a new messages block'; -$string['messages:myaddinstance'] = 'Add a new messages block to Dashboard'; -$string['pluginname'] = 'Messages'; diff --git a/blocks/messages/styles.css b/blocks/messages/styles.css deleted file mode 100644 index 176f75664f0..00000000000 --- a/blocks/messages/styles.css +++ /dev/null @@ -1,25 +0,0 @@ -.block_messages .content { - text-align: left; - padding-top: 5px; -} - -.block_messages .content .list li.listentry { - clear: both; -} - -.block_messages .content .list li.listentry .user { - float: left; - position: relative; -} - -.block_messages .content .list li.listentry .message { - float: right; -} - -.block_messages .content .info { - text-align: center; -} - -.block_messages .content .footer { - clear: both; -} diff --git a/blocks/messages/tests/behat/block_messages_course.feature b/blocks/messages/tests/behat/block_messages_course.feature deleted file mode 100644 index 63dd4a511a3..00000000000 --- a/blocks/messages/tests/behat/block_messages_course.feature +++ /dev/null @@ -1,56 +0,0 @@ -@block @block_messages -Feature: The messages block allows users to list new messages an a course - In order to enable the messages block in a course - As a teacher - I can add the messages block to a course and view my messages - - Background: - Given the following "users" exist: - | username | firstname | lastname | email | idnumber | - | teacher1 | Teacher | 1 | teacher1@example.com | T1 | - | student1 | Student | 1 | student1@example.com | S1 | - And the following "courses" exist: - | fullname | shortname | category | - | Course 1 | C1 | 0 | - And the following "course enrolments" exist: - | user | course | role | - | teacher1 | C1 | editingteacher | - | student1 | C1 | student | - - Scenario: View the block by a user with messaging disabled. - Given the following config values are set as admin: - | messaging | 0 | - And I log in as "teacher1" - And I am on "Course 1" course homepage with editing mode on - And I add the "Messages" block - Then I should see "Messaging is disabled on this site" in the "Messages" "block" - - Scenario: View the block by a user who does not have any messages. - Given I log in as "teacher1" - And I am on "Course 1" course homepage with editing mode on - And I add the "Messages" block - Then I should see "No messages" in the "Messages" "block" - - @javascript - Scenario: View the block by a user who has messages. - Given I log in as "student1" - And I follow "Messages" in the user menu - And I send "This is message 1" message to "Teacher 1" user - And I send "This is message 2" message to "Teacher 1" user - And I log out - And I log in as "teacher1" - And I am on "Course 1" course homepage with editing mode on - And I add the "Messages" block - Then I should see "Student 1" in the "Messages" "block" - - @javascript - Scenario: Use the block to send a message to a user. - Given I log in as "teacher1" - And I am on "Course 1" course homepage with editing mode on - And I add the "Messages" block - And I click on "//a[normalize-space(.) = 'Messages']" "xpath_element" in the "Messages" "block" - And I send "This is message 1" message to "Student 1" user - And I log out - When I log in as "student1" - And I am on "Course 1" course homepage - Then I should see "Teacher 1" in the "Messages" "block" diff --git a/blocks/messages/tests/behat/block_messages_dashboard.feature b/blocks/messages/tests/behat/block_messages_dashboard.feature deleted file mode 100644 index 509057e5d4b..00000000000 --- a/blocks/messages/tests/behat/block_messages_dashboard.feature +++ /dev/null @@ -1,50 +0,0 @@ -@block @block_messages -Feature: The messages block allows users to list new messages on the dashboard - In order to enable the messages block on the dashboard - As a user - I can add the messages block to a my dashboard and view my messages - - Background: - Given the following "users" exist: - | username | firstname | lastname | email | idnumber | - | teacher1 | Teacher | 1 | teacher1@example.com | T1 | - | student1 | Student | 1 | student1@example.com | S1 | - - Scenario: View the block by a user with messaging disabled. - Given the following config values are set as admin: - | messaging | 0 | - And I log in as "teacher1" - And I press "Customise this page" - When I add the "Messages" block - Then I should see "Messaging is disabled on this site" in the "Messages" "block" - - Scenario: View the block by a user who does not have any messages. - Given I log in as "teacher1" - And I press "Customise this page" - When I add the "Messages" block - Then I should see "No messages" in the "Messages" "block" - - @javascript - Scenario: View the block by a user who has messages. - Given I log in as "student1" - And I follow "Messages" in the user menu - And I send "This is message 1" message to "Teacher 1" user - And I send "This is message 2" message to "Teacher 1" user - And I log out - When I log in as "teacher1" - And I press "Customise this page" - And I add the "Messages" block - Then I should see "Student 1" in the "Messages" "block" - - @javascript - Scenario: Use the block to send a message to a user. - Given I log in as "teacher1" - And I press "Customise this page" - And I add the "Messages" block - And I click on "//a[normalize-space(.) = 'Messages']" "xpath_element" in the "Messages" "block" - And I send "This is message 1" message to "Student 1" user - And I log out - When I log in as "student1" - And I press "Customise this page" - And I add the "Messages" block - Then I should see "Teacher 1" in the "Messages" "block" diff --git a/blocks/messages/tests/behat/block_messages_frontpage.feature b/blocks/messages/tests/behat/block_messages_frontpage.feature deleted file mode 100644 index 2c71001981b..00000000000 --- a/blocks/messages/tests/behat/block_messages_frontpage.feature +++ /dev/null @@ -1,58 +0,0 @@ -@block @block_messages -Feature: The messages block allows users to list new messages on the frontpage - In order to enable the messages block on the frontpage - As an admin - I can add the messages block to a the frontpage and view my messages - - Background: - Given the following "users" exist: - | username | firstname | lastname | email | idnumber | - | teacher1 | Teacher | 1 | teacher1@example.com | T1 | - | student1 | Student | 1 | student1@example.com | S1 | - And I log in as "admin" - And I am on site homepage - And I navigate to "Turn editing on" node in "Front page settings" - And I add the "Messages" block - And I log out - - Scenario: View the block by a user with messaging disabled. - Given the following config values are set as admin: - | messaging | 0 | - And I log in as "admin" - And I am on site homepage - When I navigate to "Turn editing on" node in "Front page settings" - And I should see "Messaging is disabled on this site" in the "Messages" "block" - Then I navigate to "Turn editing off" node in "Front page settings" - And I should not see "Messaging is disabled on this site" - - Scenario: View the block by a user who does not have any messages. - Given I log in as "teacher1" - When I am on site homepage - Then I should see "No messages" in the "Messages" "block" - - Scenario: Try to view the block as a guest user. - Given I log in as "guest" - When I am on site homepage - Then I should not see "Messages" - - @javascript - Scenario: View the block by a user who has messages. - Given I log in as "student1" - And I follow "Messages" in the user menu - And I send "This is message 1" message to "Teacher 1" user - And I send "This is message 2" message to "Teacher 1" user - And I log out - When I log in as "teacher1" - And I am on site homepage - Then I should see "Student 1" in the "Messages" "block" - - @javascript - Scenario: Use the block to send a message to a user. - Given I log in as "teacher1" - And I am on site homepage - And I click on "//a[normalize-space(.) = 'Messages']" "xpath_element" in the "Messages" "block" - And I send "This is message 1" message to "Student 1" user - And I log out - When I log in as "student1" - And I am on site homepage - Then I should see "Teacher 1" in the "Messages" "block" diff --git a/blocks/messages/version.php b/blocks/messages/version.php deleted file mode 100644 index 9faef4dd640..00000000000 --- a/blocks/messages/version.php +++ /dev/null @@ -1,29 +0,0 @@ -. - -/** - * Version details - * - * @package block_messages - * @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 = 2017051500; // The current plugin version (Date: YYYYMMDDXX) -$plugin->requires = 2017050500; // Requires this Moodle version -$plugin->component = 'block_messages'; // Full name of the plugin (used for diagnostics) diff --git a/blocks/upgrade.txt b/blocks/upgrade.txt index 6b8fc564aea..7ef8f0abd0c 100644 --- a/blocks/upgrade.txt +++ b/blocks/upgrade.txt @@ -9,6 +9,7 @@ information provided here is intended especially for developers. * Blocks can now be included in Moodle global search, with some limitations (at present, the search works only for blocks located directly on course pages or site home page). See the HTML block for an example. +* Block block_messages is no longer a part of core. === 3.3 === diff --git a/lib/classes/plugin_manager.php b/lib/classes/plugin_manager.php index 197b2418b0b..75b98b47f1f 100644 --- a/lib/classes/plugin_manager.php +++ b/lib/classes/plugin_manager.php @@ -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'), + 'block' => array('course_overview', 'messages'), 'enrol' => array('authorize'), 'report' => array('search'), 'repository' => array('alfresco'), @@ -1715,7 +1715,7 @@ class core_plugin_manager { 'calendar_upcoming', 'comments', 'community', 'completionstatus', 'course_list', 'course_summary', 'feedback', 'globalsearch', 'glossary_random', 'html', - 'login', 'lp', 'mentees', 'messages', 'mnet_hosts', 'myoverview', 'myprofile', + 'login', 'lp', 'mentees', 'mnet_hosts', 'myoverview', 'myprofile', 'navigation', 'news_items', 'online_users', 'participants', 'private_files', 'quiz_results', 'recent_activity', 'rss_client', 'search_forums', 'section_links', diff --git a/lib/db/upgrade.php b/lib/db/upgrade.php index 194277c0d47..ffa1522d7a3 100644 --- a/lib/db/upgrade.php +++ b/lib/db/upgrade.php @@ -2513,5 +2513,41 @@ function xmldb_main_upgrade($oldversion) { upgrade_main_savepoint(true, 2017092201.00); } + if ($oldversion < 2017092202.00) { + + if (!file_exists($CFG->dirroot . '/blocks/messages/block_messages.php')) { + + // Delete instances. + $instances = $DB->get_records_list('block_instances', 'blockname', ['messages']); + $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' => 'messages')); + + // Remove capabilities. + capabilities_cleanup('block_messages'); + + // Clean config. + unset_all_config_for_plugin('block_messages'); + } + + upgrade_main_savepoint(true, 2017092202.00); + } + return true; } diff --git a/version.php b/version.php index 8b87b992e7d..e16ff8969f2 100644 --- a/version.php +++ b/version.php @@ -29,7 +29,7 @@ defined('MOODLE_INTERNAL') || die(); -$version = 2017092201.00; // YYYYMMDD = weekly release date of this DEV branch. +$version = 2017092202.00; // YYYYMMDD = weekly release date of this DEV branch. // RR = release increments - 00 in DEV branches. // .XX = incremental changes.