Merge branch 'MDL-57115-master' of git://github.com/ankitagarwal/moodle
This commit is contained in:
@@ -1,95 +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/>.
|
||||
|
||||
/**
|
||||
* 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 .= '<ul class="list">';
|
||||
foreach ($users as $user) {
|
||||
$timeago = format_time(time() - $user->lastaccess);
|
||||
$this->content->text .= '<li class="listentry"><div class="user"><a href="'.$CFG->wwwroot.'/user/view.php?id='.$user->id.'&course='.SITEID.'" title="'.$timeago.'">';
|
||||
$this->content->text .= $OUTPUT->user_picture($user, array('courseid'=>SITEID)); //TODO: user might not have capability to view frontpage profile :-(
|
||||
$this->content->text .= fullname($user).'</a></div>';
|
||||
|
||||
$link = '/message/index.php?usergroup=unread&id='.$user->id;
|
||||
$anchortagcontents = $OUTPUT->pix_icon('t/message', fullname($user)) . ' ' . $user->count;
|
||||
|
||||
$action = null; // popup is gone now
|
||||
$anchortag = $OUTPUT->action_link($link, $anchortagcontents, $action);
|
||||
|
||||
$this->content->text .= '<div class="message">'.$anchortag.'</div></li>';
|
||||
}
|
||||
$this->content->text .= '</ul>';
|
||||
} else {
|
||||
$this->content->text .= '<div class="info">';
|
||||
$this->content->text .= get_string('nomessages', 'message');
|
||||
$this->content->text .= '</div>';
|
||||
}
|
||||
|
||||
return $this->content;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -1,51 +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/>.
|
||||
|
||||
/**
|
||||
* Messages block caps.
|
||||
*
|
||||
* @package block_messages
|
||||
* @copyright Mark Nelson <[email protected]>
|
||||
* @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'
|
||||
),
|
||||
);
|
||||
@@ -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_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';
|
||||
@@ -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;
|
||||
}
|
||||
@@ -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"
|
||||
@@ -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"
|
||||
@@ -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"
|
||||
@@ -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_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)
|
||||
@@ -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 ===
|
||||
|
||||
|
||||
@@ -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',
|
||||
|
||||
@@ -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;
|
||||
}
|
||||
|
||||
+1
-1
@@ -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.
|
||||
|
||||
|
||||
Reference in New Issue
Block a user