diff --git a/blocks/online_users/block_online_users.php b/blocks/online_users/block_online_users.php
index dcf31333131..ec32a5ae589 100644
--- a/blocks/online_users/block_online_users.php
+++ b/blocks/online_users/block_online_users.php
@@ -39,7 +39,7 @@ class block_online_users extends block_base {
}
function get_content() {
- global $USER, $CFG, $DB, $OUTPUT, $PAGE;
+ global $USER, $CFG, $DB, $OUTPUT;
if ($this->content !== NULL) {
return $this->content;
@@ -106,7 +106,6 @@ class block_online_users extends block_base {
if (isloggedin() && has_capability('moodle/site:sendmessage', $this->page->context)
&& !empty($CFG->messaging) && !isguestuser()) {
$canshowicon = true;
- message_messenger_requirejs();
} else {
$canshowicon = false;
}
@@ -126,10 +125,7 @@ class block_online_users extends block_base {
if ($canshowicon and ($USER->id != $user->id) and !isguestuser($user)) { // Only when logged in and messaging active etc
$anchortagcontents = '
';
$anchorurl = new moodle_url('/message/index.php', array('id' => $user->id));
- $anchortag = html_writer::link($anchorurl, $anchortagcontents, array_merge(
- message_messenger_sendmessage_link_params($user),
- array('title' => get_string('messageselectadd'))
- ));
+ $anchortag = html_writer::link($anchorurl, $anchortagcontents, array('title' => get_string('messageselectadd')));
$this->content->text .= '
'.$anchortag.'
';
}
diff --git a/lang/en/message.php b/lang/en/message.php
index 6e5abeeb7ba..adac6978474 100644
--- a/lang/en/message.php
+++ b/lang/en/message.php
@@ -59,7 +59,6 @@ $string['emailtagline'] = 'This is a copy of a message sent to you at "{$a->site
$string['emptysearchstring'] = 'You must search for something';
$string['enabled'] = 'Enabled';
$string['errorcallingprocessor'] = 'Error calling defined output';
-$string['errorwhilesendingmessage'] = 'An error occurred while sending the message; please try again later.';
$string['errortranslatingdefault'] = 'Error translating default setting provided by plugin, using system defaults instead.';
$string['eventmessagecontactadded'] = 'Message contact added';
$string['eventmessagecontactblocked'] = 'Message contact blocked';
@@ -99,11 +98,9 @@ $string['message'] = 'Message';
$string['messagehistory'] = 'Message history';
$string['messagehistoryfull'] = 'All messages';
$string['messagenavigation'] = 'Message navigation:';
-$string['messagetosend'] = 'Message to send';
$string['messagepreferences'] = 'Message preferences';
$string['messageprocessors'] = 'Message processors';
$string['messages'] = 'Messages';
-$string['messagesent'] = 'Message sent';
$string['messaging'] = 'Messaging';
$string['messagingblockednoncontact'] = '{$a} will not be able to reply as you have blocked non-contacts';
$string['messagingdisabled'] = 'Messaging is disabled on this site, emails will be sent instead';
@@ -160,7 +157,6 @@ $string['selectmessagestodelete'] = 'Select messages or conversations to delete'
$string['send'] = 'Send';
$string['sendingvia'] = 'Sending "{$a->provider}" via "{$a->processor}"';
$string['sendingviawhen'] = 'Sending "{$a->provider}" via "{$a->processor}" when {$a->state}';
-$string['sendingmessage'] = 'Sending message';
$string['sendmessage'] = 'Send message';
$string['sendmessageto'] = 'Send message to {$a}';
$string['sendmessagetopopup'] = 'Send message to {$a} - new window';
diff --git a/lib/outputrenderers.php b/lib/outputrenderers.php
index 3e34107e365..9cbfa2128a4 100644
--- a/lib/outputrenderers.php
+++ b/lib/outputrenderers.php
@@ -4163,7 +4163,7 @@ EOD;
'title' => get_string('message', 'message'),
'url' => new moodle_url('/message/index.php', array('id' => $user->id)),
'image' => 'message',
- 'linkattributes' => message_messenger_sendmessage_link_params($user),
+ 'linkattributes' => array('role' => 'button'),
'page' => $this->page
),
'togglecontact' => array(
@@ -4237,9 +4237,7 @@ EOD;
foreach ($contextheader->additionalbuttons as $button) {
if (!isset($button->page)) {
// Include js for messaging.
- if ($button['buttontype'] === 'message') {
- message_messenger_requirejs();
- } else if ($button['buttontype'] === 'togglecontact') {
+ if ($button['buttontype'] === 'togglecontact') {
message_togglecontact_requirejs();
}
$image = $this->pix_icon($button['formattedimage'], $button['title'], 'moodle', array(
diff --git a/message/ajax.php b/message/ajax.php
deleted file mode 100644
index 7a4bb6573bf..00000000000
--- a/message/ajax.php
+++ /dev/null
@@ -1,82 +0,0 @@
-.
-
-/**
- * Ajax point of entry for messaging API.
- *
- * @package core_message
- * @copyright 2015 Frédéric Massart - FMCorz.net
- * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
- */
-
-define('AJAX_SCRIPT', true);
-
-require('../config.php');
-require_once($CFG->libdir . '/filelib.php');
-require_once(__DIR__ . '/lib.php');
-
-// Only real logged in users.
-require_login(null, false, null, true, true);
-if (isguestuser()) {
- throw new require_login_exception('Guests are not allowed here.');
-}
-
-// Messaging needs to be enabled.
-if (empty($CFG->messaging)) {
- throw new moodle_exception('disabled', 'core_message');
-}
-
-$PAGE->set_context(null);
-require_sesskey();
-$action = optional_param('action', null, PARAM_ALPHA);
-$response = null;
-
-switch ($action) {
-
- // Sending a message.
- case 'sendmessage':
-
- $userid = required_param('userid', PARAM_INT);
- if (empty($userid) || isguestuser($userid) || $userid == $USER->id) {
- // Cannot send messags to self, nobody or a guest.
- throw new coding_exception('Invalid user to send the message to');
- }
-
- $message = required_param('message', PARAM_RAW);
- $user2 = core_user::get_user($userid);
-
- // Only attempt to send the message if we have permission to message
- // the recipient.
- if (message_can_post_message($user2, $USER)) {
- $messageid = message_post_message($USER, $user2, $message, FORMAT_MOODLE);
-
- if (!$messageid) {
- throw new moodle_exception('errorwhilesendingmessage', 'core_message');
- }
- } else {
- throw new moodle_exception('unabletomessageuser', 'core_message');
- }
-
- $response = array();
- break;
-}
-
-if ($response !== null) {
- echo json_encode($response);
- exit();
-}
-
-throw new coding_exception('Invalid request');
diff --git a/message/lib.php b/message/lib.php
index bc673e3a55c..3577b305366 100644
--- a/message/lib.php
+++ b/message/lib.php
@@ -1972,41 +1972,6 @@ function message_count_unread_popup_notifications($useridto = 0) {
);
}
-/**
- * Requires the JS libraries to send a message using a dialog.
- *
- * @return void
- */
-function message_messenger_requirejs() {
- global $PAGE;
-
- static $done = false;
- if ($done) {
- return;
- }
-
- $PAGE->requires->yui_module(
- array('moodle-core_message-messenger'),
- 'Y.M.core_message.messenger.init',
- array(array())
- );
- $PAGE->requires->strings_for_js(array(
- 'errorwhilesendingmessage',
- 'messagesent',
- 'messagetosend',
- 'sendingmessage',
- 'sendmessage',
- 'viewconversation',
- ), 'core_message');
- $PAGE->requires->strings_for_js(array(
- 'userisblockingyou',
- 'userisblockingyounoncontact'
- ), 'message');
- $PAGE->requires->string_for_js('error', 'core');
-
- $done = true;
-}
-
/**
* Requires the JS libraries for the toggle contact button.
*
@@ -2024,29 +1989,6 @@ function message_togglecontact_requirejs() {
$done = true;
}
-/**
- * Returns the attributes to place on a link to open the 'Send message' dialog.
- *
- * @param object $user User object.
- * @return void
- */
-function message_messenger_sendmessage_link_params($user) {
- $params = array(
- 'data-trigger' => 'core_message-messenger::sendmessage',
- 'data-fullname' => fullname($user),
- 'data-userid' => $user->id,
- 'role' => 'button'
- );
-
- if (message_is_user_non_contact_blocked($user)) {
- $params['data-blocked-string'] = 'userisblockingyounoncontact';
- } else if (message_is_user_blocked($user)) {
- $params['data-blocked-string'] = 'userisblockingyou';
- }
-
- return $params;
-}
-
/**
* Returns the attributes to place on a contact button.
*
diff --git a/message/tests/behat/send_message.feature b/message/tests/behat/send_message.feature
deleted file mode 100644
index 33e6e0b9451..00000000000
--- a/message/tests/behat/send_message.feature
+++ /dev/null
@@ -1,71 +0,0 @@
-@core @core_message
-Feature: Users can send messages to each other
- In order to communicate with another user
- As a user
- I can send private messages
-
- Background:
- Given the following "users" exist:
- | username | firstname | lastname | email |
- | user1 | User | One | one@example.com |
- | user2 | User | Two | two@example.com |
-
- @javascript
- Scenario: Using the 'Send message' dialog on one's profile
- Given the following config values are set as admin:
- | forceloginforprofiles | 0 |
- And I log in as "user1"
- And I follow "Messages" in the user menu
- And I set the field "Search people and messages" to "User Two"
- And I press "Search people and messages"
- And I follow "Picture of User Two"
- When I press "Message"
- And I set the field "Message to send" to "Lorem ipsum sa messagus textus"
- And I press "Send message"
- And I am on homepage
- And I follow "Messages" in the user menu
- And I set the field "Search people and messages" to "User Two"
- And I press "Search people and messages"
- And I follow "Send message to User Two"
- Then I should see "Lorem ipsum sa messagus textus"
-
- @javascript
- Scenario: Using the 'Send message' dialog on one's course profile
- Given the following "courses" exist:
- | fullname | shortname | category |
- | Course 1 | C1 | 0 |
- And the following "course enrolments" exist:
- | user | course | role |
- | user1 | C1 | student |
- | user2 | C1 | student |
- And I log in as "user1"
- And I follow "Course 1"
- And I follow "Participants"
- And I follow "User Two"
- When I press "Message"
- And I set the field "Message to send" to "Lorem ipsum sa messagus textus"
- And I press "Send message"
- And I am on homepage
- And I follow "Messages" in the user menu
- And I set the field "Search people and messages" to "User Two"
- And I press "Search people and messages"
- And I follow "Send message to User Two"
- Then I should see "Lorem ipsum sa messagus textus"
-
- @javascript
- Scenario: Using the 'Messages' page
- Given the following "courses" exist:
- | fullname | shortname | category |
- | Course 1 | C1 | 0 |
- And the following "course enrolments" exist:
- | user | course | role |
- | user1 | C1 | student |
- | user2 | C1 | student |
- And I log in as "user1"
- And I follow "Messages" in the user menu
- And I set the field "Search people and messages" to "User Two"
- And I press "Search people and messages"
- And I follow "Send message to User Two"
- When I set the field "message" to "Lorem ipsum sa messagus textus"
- And I press "Send message"
- Then I should see "Lorem ipsum sa messagus textus"
diff --git a/message/yui/build/moodle-core_message-messenger/moodle-core_message-messenger-debug.js b/message/yui/build/moodle-core_message-messenger/moodle-core_message-messenger-debug.js
deleted file mode 100644
index 09c52d5a495..00000000000
--- a/message/yui/build/moodle-core_message-messenger/moodle-core_message-messenger-debug.js
+++ /dev/null
@@ -1,636 +0,0 @@
-YUI.add('moodle-core_message-messenger', function (Y, NAME) {
-
-// 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 .
-/* eslint-disable no-unused-vars */
-
-/**
- * Messenger constants.
- *
- * @module moodle-core_message-messenger
- * @package core_message
- * @copyright 2015 Frédéric Massart - FMCorz.net
- * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
- */
-
-
-/**
- * Cascading Style Sheet References.
- *
- * Using the name "CSS" would redefine the existing JS object CSS.
- *
- * @type {Object}
- */
-var CSSR = {};
-
-/**
- * Object containing a reference to the selectors.
- *
- * @type {Object}
- */
-var SELECTORS = {};
-// 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 .
-/* global SELECTORS */
-
-/**
- * Messenger manager.
- *
- * @module moodle-core_message-messenger
- * @package core_message
- * @copyright 2015 Frédéric Massart - FMCorz.net
- * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
- */
-
-SELECTORS.MANAGER = {
- SENDMESSAGE: '[data-trigger="core_message-messenger::sendmessage"]'
-};
-
-/**
- * Messenger manager.
- *
- * @namespace M.core_message.messenger
- * @class MANAGER
- * @constructor
- */
-var MANAGER = function() {
- MANAGER.superclass.constructor.apply(this, arguments);
-};
-Y.namespace('M.core_message.messenger').Manager = Y.extend(MANAGER, Y.Base, {
-
- _sendMessageDialog: null,
- _events: [],
-
- /**
- * Initializer.
- *
- * @method initializer
- */
- initializer: function() {
- this._setEvents();
- },
-
- /**
- * Sending a message.
- *
- * @method sendMessage
- * @param {Number} userid The user ID to send a message to.
- * @param {String} fullname The fullname of the user.
- * @param {EventFacade} e The event triggered, when any it should be passed to the dialog.
- */
- sendMessage: function(userid, fullname, e) {
- var Klass;
- if (!this._sendMessageDialog) {
- Klass = Y.namespace('M.core_message.messenger.sendMessage');
- this._sendMessageDialog = new Klass({
- url: this.get('url')
- });
- }
-
- this._sendMessageDialog.prepareForUser(userid, fullname);
- this._sendMessageDialog.show(e);
- },
-
- /**
- * Pop up an alert dialogue to notify the logged in user that they are blocked from
- * messaging the target user.
- *
- * @method alertBlocked
- * @param {String} blockedString The identifier to retrieve the blocked user message.
- * @param {String} fullName The target user's full name.
- */
- alertBlocked: function(blockedString, fullName) {
- new M.core.alert({
- title: M.util.get_string('error', 'core'),
- message: M.util.get_string(blockedString, 'message', fullName)
- });
- },
-
- /**
- * Register the events.
- *
- * @method _setEvents.
- */
- _setEvents: function() {
- var captureEvent = function(e) {
- var target = e.currentTarget,
- userid = parseInt(target.getData('userid'), 10),
- fullname = target.getData('fullname'),
- blockedString = target.getData('blocked-string');
-
- if (!userid || !fullname) {
- return;
- }
-
- // Pass the validation before preventing defaults.
- e.preventDefault();
- if (blockedString) {
- this.alertBlocked(blockedString, fullname);
- } else {
- this.sendMessage(userid, fullname, e);
- }
- };
-
- this._events.push(Y.delegate('click', captureEvent, 'body', SELECTORS.MANAGER.SENDMESSAGE, this));
- this._events.push(Y.one(Y.config.doc).delegate('key', captureEvent, 'space', SELECTORS.MANAGER.SENDMESSAGE, this));
- }
-
-}, {
- NAME: 'core_message-messenger-manager',
- ATTRS: {
-
- /**
- * URL to the message Ajax actions.
- *
- * @attribute url
- * @default M.cfg.wwwroot + '/message/ajax.php'
- * @type String
- */
- url: {
- readonly: true,
- value: M.cfg.wwwroot + '/message/ajax.php'
- }
- }
-});
-
-var MANAGERINST;
-Y.namespace('M.core_message.messenger').init = function(config) {
- if (!MANAGERINST) {
- // Prevent duplicates of the manager if this function is called more than once.
- MANAGERINST = new MANAGER(config);
- }
- return MANAGERINST;
-};
-// 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 .
-/* global CSSR, SELECTORS */
-
-/**
- * Send message dialog.
- *
- * @module moodle-core_message-messenger
- * @package core_message
- * @copyright 2015 Frédéric Massart - FMCorz.net
- * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
- */
-
-CSSR.SENDMSGDIALOG = {
- ACCESSHIDE: 'accesshide',
- ACTIONS: 'message-actions',
- FOOTER: 'message-footer',
- HIDDEN: 'hidden',
- HISTORYLINK: 'message-history',
- INPUT: 'message-input',
- INPUTAREA: 'message-area',
- NOTICE: 'message-notice',
- NOTICEAREA: 'message-notice-area',
- PREFIX: 'core_message-messenger-sendmessage',
- SENDBTN: 'message-send',
- WRAPPER: 'message-wrapper'
-};
-
-SELECTORS.SENDMSGDIALOG = {
- FORM: 'form',
- HISTORYLINK: '.message-history',
- INPUT: '.message-input',
- NOTICE: '.message-notice div',
- NOTICEAREA: '.message-notice-area',
- SENDBTN: '.message-send'
-};
-
-/**
- * Send message dialog.
- *
- * @namespace M.core_message
- * @class SENDMSGDIALOG
- * @constructor
- */
-var SENDMSGDIALOG = function() {
- SENDMSGDIALOG.superclass.constructor.apply(this, arguments);
-};
-Y.namespace('M.core_message.messenger').sendMessage = Y.extend(SENDMSGDIALOG, M.core.dialogue, {
-
- _bb: null,
- _sendLock: false,
- _hide: null,
- /**
- * Initializer.
- *
- * @method initializer
- */
- initializer: function() {
- var tpl,
- content;
-
- this._bb = this.get('boundingBox');
- this._hide = this.hide;
-
- // Prepare the content area.
- tpl = Y.Handlebars.compile(
- ''
- );
- content = Y.Node.create(
- tpl({
- CSSR: CSSR.SENDMSGDIALOG,
- id: Y.guid(),
- labelStr: M.util.get_string('messagetosend', 'core_message'),
- loadingIcon: M.util.image_url('i/loading', 'moodle'),
- sendStr: M.util.get_string('sendmessage', 'core_message'),
- viewHistoryStr: M.util.get_string('viewconversation', 'core_message')
- })
- );
- this.setStdModContent(Y.WidgetStdMod.BODY, content, Y.WidgetStdMod.REPLACE);
-
- // Use standard dialogue class name. This removes the default styling of the footer.
- this._bb.one('.moodle-dialogue-wrap').addClass('moodle-dialogue-content');
-
- // Set the events listeners.
- this._setEvents();
- },
-
- /**
- * Prepare the dialog for a user.
- *
- * @method prepareForUser
- * @param {Number} userid The user ID.
- * @param {String} fullname The user full name.
- */
- prepareForUser: function(userid, fullname) {
- var title;
-
- this.set('userid', userid);
- this.set('fullname', fullname);
-
- // Prepare the title.
- title = Y.Node.create('' + Y.Escape.html(fullname) + '
');
- this.setStdModContent(Y.WidgetStdMod.HEADER, title, Y.WidgetStdMod.REPLACE);
-
- // Update the link to the conversation.
- this._bb.one(SELECTORS.SENDMSGDIALOG.HISTORYLINK)
- .set('href', M.cfg.wwwroot + '/message/index.php?id=' + this.get('userid'));
-
- // Set the content as empty and lock send.
- this._bb.one(SELECTORS.SENDMSGDIALOG.INPUT).set('value', '');
-
- // Register form with formchangechecker
- Y.use('moodle-core-formchangechecker', function() {
- M.core_formchangechecker.init({formid: "messageform"});
- });
- },
-
- /**
- * Send the message to the user.
- *
- * @method sendMessage
- * @param {String} message The message to be sent.
- */
- sendMessage: function(message) {
- if (this._sendLock) {
- // Do not proceed if the lock is active.
- return;
- }
-
- if (!message || !this._validateMessage(message)) {
- // Do not send falsy messages.
- return;
- }
-
- // Actually send the message.
- this._ioSend = Y.io(this.get('url'), {
- method: 'POST',
- data: {
- sesskey: M.cfg.sesskey,
- action: 'sendmessage',
- userid: this.get('userid'),
- message: message
- },
- on: {
- start: function() {
- var img = '
';
- this.setSendLock(true);
- this.showNotice(img + ' ' + M.util.get_string('sendingmessage', 'core_message'));
- },
- success: function(id, response) {
- var data = null;
-
- try {
- data = Y.JSON.parse(response.responseText);
- if (data.error) {
- this.hideNotice();
- new M.core.ajaxException(data);
- return;
- }
- } catch (e) {
- this.hideNotice();
- new M.core.exception(e);
- return;
- }
-
- // Show a success message.
- this.showNotice(M.util.get_string('messagesent', 'core_message'));
-
- // Hide the dialog.
- Y.later(1300, this, function() {
- this.setSendLock(false);
- this.hideNotice();
- this.hide();
- });
- },
- failure: function() {
- this.setSendLock(false);
- this.hideNotice();
- new M.core.alert({
- title: M.util.get_string('error', 'core'),
- message: M.util.get_string('errorwhilesendingmessage', 'core_message')
- });
- }
- },
- context: this
- });
- },
-
- /**
- * Override the default hide function.
- * @method hide
- */
- hide: function() {
- var self = this;
-
- if (!M.core_formchangechecker.get_form_dirty_state()) {
- return SENDMSGDIALOG.superclass.hide.call(this, arguments);
- }
-
- Y.use('moodle-core-notification-confirm', function() {
- var confirm = new M.core.confirm({
- title: M.util.get_string('confirm', 'moodle'),
- question: M.util.get_string('changesmadereallygoaway', 'moodle'),
- yesLabel: M.util.get_string('confirm', 'moodle'),
- noLabel: M.util.get_string('cancel', 'moodle')
- });
- confirm.on('complete-yes', function() {
- M.core_formchangechecker.reset_form_dirty_state();
- confirm.hide();
- confirm.destroy();
- return SENDMSGDIALOG.superclass.hide.call(this, arguments);
- }, self);
- });
- },
-
- /**
- * Show a notice.
- *
- * @method hideNotice.
- */
- hideNotice: function() {
- this._bb.one(SELECTORS.SENDMSGDIALOG.NOTICEAREA).hide();
- },
-
- /**
- * Show a notice.
- *
- * @param {String} html String to show.
- * @method showNotice.
- */
- showNotice: function(html) {
- this._bb.one(SELECTORS.SENDMSGDIALOG.NOTICE).setHTML(html);
- this._bb.one(SELECTORS.SENDMSGDIALOG.NOTICEAREA).show();
- },
-
- /**
- * Set the send lock.
- *
- * We do not lock the send button because that would cause a focus change on screenreaders
- * which then conflicts with the aria-live region reading out that we are sending a message.
- *
- * @method setSendLock
- * @param {Boolean} lock When true, enables the lock.
- */
- setSendLock: function(lock) {
- if (lock) {
- this._sendLock = true;
- } else {
- this._sendLock = false;
- }
- },
-
- /**
- * Register the events.
- *
- * @method _setEvents.
- */
- _setEvents: function() {
- // Form submit.
- this._bb.one(SELECTORS.SENDMSGDIALOG.FORM).on('submit', function(e) {
- var message = this._bb.one(SELECTORS.SENDMSGDIALOG.INPUT).get('value');
- e.preventDefault();
- this.sendMessage(message);
- }, this);
- },
-
- /**
- * Validates a message.
- *
- * @method _validateMessage
- * @param {String} message A message to be validated.
- */
- _validateMessage: function(message) {
- var trimmed;
- if (!message) {
- return false;
- }
-
- // Basic validation.
- trimmed = message.replace(' ', '')
- .replace(' ', '')
- .replace(/(
(<\/br\s*\/?>)?)+/, '')
- .trim();
-
- return trimmed.length > 1;
- }
-
-}, {
- NAME: 'core_message-messenger-sendmessage',
- CSS_PREFIX: CSSR.SENDMSGDIALOG.PREFIX,
- ATTRS: {
-
- /**
- * Fullname of the user.
- *
- * @attribute fullname
- * @default ''
- * @type String
- */
- fullname: {
- validator: Y.Lang.isString,
- value: ''
- },
-
- /**
- * URL to the message Ajax actions.
- *
- * @attribute url
- * @default null
- * @type String
- */
- url: {
- validator: Y.Lang.isString,
- value: null
- },
-
- /**
- * User ID this dialog interacts with.
- *
- * @attribute userid
- * @default 0
- * @type Number
- */
- userid: {
- validator: Y.Lang.isNumber,
- value: 0
- }
- }
-});
-
-Y.Base.modifyAttrs(Y.namespace('M.core_message.messenger.sendMessage'), {
-
- /**
- * List of extra classes.
- *
- * @attribute extraClasses
- * @default ['core_message-messenger-sendmessage']
- * @type Array
- */
- extraClasses: {
- value: ['core_message-messenger-sendmessage']
- },
-
- /**
- * Whether to focus on the target that caused the Widget to be shown.
- *
- * @attribute focusOnPreviousTargetAfterHide
- * @default true
- * @type Node
- */
- focusOnPreviousTargetAfterHide: {
- value: true
- },
-
- /**
- *
- * Width.
- *
- * @attribute width
- * @default '260px'
- * @type String|Number
- */
- width: {
- value: '360px'
- },
-
- /**
- * Boolean indicating whether or not the Widget is visible.
- *
- * @attribute visible
- * @default false
- * @type Boolean
- */
- visible: {
- value: false
- },
-
- /**
- * Whether the widget should be modal or not.
- *
- * @attribute modal
- * @type Boolean
- * @default true
- */
- modal: {
- value: true
- },
-
- /**
- * Whether the widget should be draggable or not.
- *
- * @attribute draggable
- * @type Boolean
- * @default false
- */
- draggable: {
- value: false
- },
-
- /**
- * Whether to display the dialogue centrally on the screen.
- *
- * @attribute center
- * @type Boolean
- * @default false
- */
- center: {
- value: true
- }
-
-});
-
-
-}, '@VERSION@', {
- "requires": [
- "escape",
- "handlebars",
- "io-base",
- "moodle-core-notification-ajaxexception",
- "moodle-core-notification-alert",
- "moodle-core-notification-dialogue",
- "moodle-core-notification-exception"
- ]
-});
diff --git a/message/yui/build/moodle-core_message-messenger/moodle-core_message-messenger-min.js b/message/yui/build/moodle-core_message-messenger/moodle-core_message-messenger-min.js
deleted file mode 100644
index 5f5a09827ea..00000000000
--- a/message/yui/build/moodle-core_message-messenger/moodle-core_message-messenger-min.js
+++ /dev/null
@@ -1,2 +0,0 @@
-YUI.add("moodle-core_message-messenger",function(e,t){var n={},r={};r.MANAGER={SENDMESSAGE:'[data-trigger="core_message-messenger::sendmessage"]'};var i=function(){i.superclass.constructor.apply(this,arguments)};e.namespace("M.core_message.messenger").Manager=e.extend(i,e.Base,{_sendMessageDialog:null,_events:[],initializer:function(){this._setEvents()},sendMessage:function(t,n,r){var i;this._sendMessageDialog||(i=e.namespace("M.core_message.messenger.sendMessage"),this._sendMessageDialog=new i({url:this.get("url")})),this._sendMessageDialog.prepareForUser(t,n),this._sendMessageDialog.show(r)},alertBlocked:function(e,t){new M.core.alert({title:M.util.get_string("error","core"),message:M.util.get_string(e,"message",t)})},_setEvents:function(){var t=function(e){var t=e.currentTarget,n=parseInt(t.getData("userid"),10),r=t.getData("fullname"),i=t.getData("blocked-string");if(!n||!r)return;e.preventDefault(),i?this.alertBlocked(i,r):this.sendMessage(n,r,e)};this._events.push(e.delegate("click",t,"body",r.MANAGER.SENDMESSAGE,this)),this._events.push(e.one(e.config.doc).delegate("key",t,"space",r.MANAGER.SENDMESSAGE,this))}},{NAME:"core_message-messenger-manager",ATTRS:{url:{readonly:!0,value:M.cfg.wwwroot+"/message/ajax.php"}}});var s;e.namespace("M.core_message.messenger").init=function(e){return s||(s=new i(e)),s},n.SENDMSGDIALOG={ACCESSHIDE:"accesshide",ACTIONS:"message-actions",FOOTER:"message-footer",HIDDEN:"hidden",HISTORYLINK:"message-history",INPUT:"message-input",INPUTAREA:"message-area",NOTICE:"message-notice",NOTICEAREA:"message-notice-area",PREFIX:"core_message-messenger-sendmessage",SENDBTN:"message-send",WRAPPER:"message-wrapper"},r.SENDMSGDIALOG={FORM:"form",HISTORYLINK:".message-history",INPUT:".message-input",NOTICE:".message-notice div",NOTICEAREA:".message-notice-area",SENDBTN:".message-send"};var o=function(){o.superclass.constructor.apply(this,arguments)};e.namespace("M.core_message.messenger").sendMessage=e.extend(o,M.core.dialogue,{_bb:null,_sendLock:!1,_hide:null,initializer:function(){var t,r;this._bb=this.get("boundingBox"),this._hide=this.hide,t=e.Handlebars.compile(''),r=e.Node.create(t({CSSR:n.SENDMSGDIALOG,id:e.guid(),labelStr:M.util.get_string("messagetosend","core_message"),loadingIcon:M.util.image_url("i/loading","moodle"),sendStr:M.util.get_string("sendmessage","core_message"),viewHistoryStr:M.util.get_string("viewconversation","core_message")})),this.setStdModContent(e.WidgetStdMod.BODY,r,e.WidgetStdMod.REPLACE),this._bb.one(".moodle-dialogue-wrap").addClass("moodle-dialogue-content"),this._setEvents()},prepareForUser:function(t,n){var i;this.set("userid",t),this.set("fullname",n),i=e.Node.create(""+e.Escape.html(n)+"
"),this.setStdModContent(e.WidgetStdMod.HEADER,i,e.WidgetStdMod.REPLACE),this._bb.one(r.SENDMSGDIALOG.HISTORYLINK).set("href",M.cfg.wwwroot+"/message/index.php?id="+this.get("userid")),this._bb.one(r.SENDMSGDIALOG.INPUT).set("value",""),e.use("moodle-core-formchangechecker",function(){M.core_formchangechecker.init({formid:"messageform"})})},sendMessage:function(t){if(this._sendLock)return;if(!t||!this._validateMessage(t))return;this._ioSend=e.io(this.get("url"),{method:"POST",data:{sesskey:M.cfg.sesskey,action:"sendmessage",userid:this.get("userid"),message:t},on:{start:function(){var e='
';this.setSendLock(!0),this.showNotice(e+" "+M.util.get_string("sendingmessage","core_message"))},success:function(t,n){var r=null;try{r=e.JSON.parse(n.responseText);if(r.error){this.hideNotice(),new M.core.ajaxException(r);return}}catch(i){this.hideNotice(),new M.core.exception(i);return}this.showNotice(M.util.get_string("messagesent","core_message")),e.later(1300,this,function(){this.setSendLock(!1),this.hideNotice(),this.hide()})},failure:function(){this.setSendLock(!1),this.hideNotice(),new M.core.alert({title:M.util.get_string("error","core"),message:M.util.get_string("errorwhilesendingmessage","core_message")})}},context:this})},hide:function(){var t=this;if(!M.core_formchangechecker.get_form_dirty_state())return o.superclass.hide.call(this,arguments);e.use("moodle-core-notification-confirm",function(){var e=new M.core.confirm({title:M.util.get_string("confirm","moodle"),question:M.util.get_string("changesmadereallygoaway","moodle"),yesLabel:M.util.get_string("confirm","moodle"),noLabel:M.util.get_string("cancel","moodle")});e.on("complete-yes",function(){return M.core_formchangechecker.reset_form_dirty_state(),e.hide(),e.destroy(),o.superclass.hide.call(this,arguments)},t)})},hideNotice:function(){this._bb.one(r.SENDMSGDIALOG.NOTICEAREA).hide()},showNotice:function(e){this._bb.one(r.SENDMSGDIALOG.NOTICE).setHTML(e),this._bb.one(r.SENDMSGDIALOG.NOTICEAREA).show()},setSendLock:function(e){e?this._sendLock=!0:this._sendLock=!1},_setEvents:function(){this._bb.one(r.SENDMSGDIALOG.FORM).on("submit",function(e){var t=this._bb.one(r.SENDMSGDIALOG.INPUT).get("value");e.preventDefault(),this.sendMessage(t)},this)},_validateMessage:function(e){var t;return e?(t=e.replace(" ","").replace(" ","").replace(/(
(<\/br\s*\/?>)?)+/,"").trim(),t.length>1):!1}},{NAME:"core_message-messenger-sendmessage",CSS_PREFIX:n.SENDMSGDIALOG.PREFIX,ATTRS:{fullname:{validator:e.Lang.isString,value:""},url:{validator:e.Lang.isString,value:null},userid:{validator:e.Lang.isNumber,value:0}}}),e.Base.modifyAttrs(e.namespace("M.core_message.messenger.sendMessage"),{extraClasses
-:{value:["core_message-messenger-sendmessage"]},focusOnPreviousTargetAfterHide:{value:!0},width:{value:"360px"},visible:{value:!1},modal:{value:!0},draggable:{value:!1},center:{value:!0}})},"@VERSION@",{requires:["escape","handlebars","io-base","moodle-core-notification-ajaxexception","moodle-core-notification-alert","moodle-core-notification-dialogue","moodle-core-notification-exception"]});
diff --git a/message/yui/build/moodle-core_message-messenger/moodle-core_message-messenger.js b/message/yui/build/moodle-core_message-messenger/moodle-core_message-messenger.js
deleted file mode 100644
index 09c52d5a495..00000000000
--- a/message/yui/build/moodle-core_message-messenger/moodle-core_message-messenger.js
+++ /dev/null
@@ -1,636 +0,0 @@
-YUI.add('moodle-core_message-messenger', function (Y, NAME) {
-
-// 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 .
-/* eslint-disable no-unused-vars */
-
-/**
- * Messenger constants.
- *
- * @module moodle-core_message-messenger
- * @package core_message
- * @copyright 2015 Frédéric Massart - FMCorz.net
- * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
- */
-
-
-/**
- * Cascading Style Sheet References.
- *
- * Using the name "CSS" would redefine the existing JS object CSS.
- *
- * @type {Object}
- */
-var CSSR = {};
-
-/**
- * Object containing a reference to the selectors.
- *
- * @type {Object}
- */
-var SELECTORS = {};
-// 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 .
-/* global SELECTORS */
-
-/**
- * Messenger manager.
- *
- * @module moodle-core_message-messenger
- * @package core_message
- * @copyright 2015 Frédéric Massart - FMCorz.net
- * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
- */
-
-SELECTORS.MANAGER = {
- SENDMESSAGE: '[data-trigger="core_message-messenger::sendmessage"]'
-};
-
-/**
- * Messenger manager.
- *
- * @namespace M.core_message.messenger
- * @class MANAGER
- * @constructor
- */
-var MANAGER = function() {
- MANAGER.superclass.constructor.apply(this, arguments);
-};
-Y.namespace('M.core_message.messenger').Manager = Y.extend(MANAGER, Y.Base, {
-
- _sendMessageDialog: null,
- _events: [],
-
- /**
- * Initializer.
- *
- * @method initializer
- */
- initializer: function() {
- this._setEvents();
- },
-
- /**
- * Sending a message.
- *
- * @method sendMessage
- * @param {Number} userid The user ID to send a message to.
- * @param {String} fullname The fullname of the user.
- * @param {EventFacade} e The event triggered, when any it should be passed to the dialog.
- */
- sendMessage: function(userid, fullname, e) {
- var Klass;
- if (!this._sendMessageDialog) {
- Klass = Y.namespace('M.core_message.messenger.sendMessage');
- this._sendMessageDialog = new Klass({
- url: this.get('url')
- });
- }
-
- this._sendMessageDialog.prepareForUser(userid, fullname);
- this._sendMessageDialog.show(e);
- },
-
- /**
- * Pop up an alert dialogue to notify the logged in user that they are blocked from
- * messaging the target user.
- *
- * @method alertBlocked
- * @param {String} blockedString The identifier to retrieve the blocked user message.
- * @param {String} fullName The target user's full name.
- */
- alertBlocked: function(blockedString, fullName) {
- new M.core.alert({
- title: M.util.get_string('error', 'core'),
- message: M.util.get_string(blockedString, 'message', fullName)
- });
- },
-
- /**
- * Register the events.
- *
- * @method _setEvents.
- */
- _setEvents: function() {
- var captureEvent = function(e) {
- var target = e.currentTarget,
- userid = parseInt(target.getData('userid'), 10),
- fullname = target.getData('fullname'),
- blockedString = target.getData('blocked-string');
-
- if (!userid || !fullname) {
- return;
- }
-
- // Pass the validation before preventing defaults.
- e.preventDefault();
- if (blockedString) {
- this.alertBlocked(blockedString, fullname);
- } else {
- this.sendMessage(userid, fullname, e);
- }
- };
-
- this._events.push(Y.delegate('click', captureEvent, 'body', SELECTORS.MANAGER.SENDMESSAGE, this));
- this._events.push(Y.one(Y.config.doc).delegate('key', captureEvent, 'space', SELECTORS.MANAGER.SENDMESSAGE, this));
- }
-
-}, {
- NAME: 'core_message-messenger-manager',
- ATTRS: {
-
- /**
- * URL to the message Ajax actions.
- *
- * @attribute url
- * @default M.cfg.wwwroot + '/message/ajax.php'
- * @type String
- */
- url: {
- readonly: true,
- value: M.cfg.wwwroot + '/message/ajax.php'
- }
- }
-});
-
-var MANAGERINST;
-Y.namespace('M.core_message.messenger').init = function(config) {
- if (!MANAGERINST) {
- // Prevent duplicates of the manager if this function is called more than once.
- MANAGERINST = new MANAGER(config);
- }
- return MANAGERINST;
-};
-// 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 .
-/* global CSSR, SELECTORS */
-
-/**
- * Send message dialog.
- *
- * @module moodle-core_message-messenger
- * @package core_message
- * @copyright 2015 Frédéric Massart - FMCorz.net
- * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
- */
-
-CSSR.SENDMSGDIALOG = {
- ACCESSHIDE: 'accesshide',
- ACTIONS: 'message-actions',
- FOOTER: 'message-footer',
- HIDDEN: 'hidden',
- HISTORYLINK: 'message-history',
- INPUT: 'message-input',
- INPUTAREA: 'message-area',
- NOTICE: 'message-notice',
- NOTICEAREA: 'message-notice-area',
- PREFIX: 'core_message-messenger-sendmessage',
- SENDBTN: 'message-send',
- WRAPPER: 'message-wrapper'
-};
-
-SELECTORS.SENDMSGDIALOG = {
- FORM: 'form',
- HISTORYLINK: '.message-history',
- INPUT: '.message-input',
- NOTICE: '.message-notice div',
- NOTICEAREA: '.message-notice-area',
- SENDBTN: '.message-send'
-};
-
-/**
- * Send message dialog.
- *
- * @namespace M.core_message
- * @class SENDMSGDIALOG
- * @constructor
- */
-var SENDMSGDIALOG = function() {
- SENDMSGDIALOG.superclass.constructor.apply(this, arguments);
-};
-Y.namespace('M.core_message.messenger').sendMessage = Y.extend(SENDMSGDIALOG, M.core.dialogue, {
-
- _bb: null,
- _sendLock: false,
- _hide: null,
- /**
- * Initializer.
- *
- * @method initializer
- */
- initializer: function() {
- var tpl,
- content;
-
- this._bb = this.get('boundingBox');
- this._hide = this.hide;
-
- // Prepare the content area.
- tpl = Y.Handlebars.compile(
- ''
- );
- content = Y.Node.create(
- tpl({
- CSSR: CSSR.SENDMSGDIALOG,
- id: Y.guid(),
- labelStr: M.util.get_string('messagetosend', 'core_message'),
- loadingIcon: M.util.image_url('i/loading', 'moodle'),
- sendStr: M.util.get_string('sendmessage', 'core_message'),
- viewHistoryStr: M.util.get_string('viewconversation', 'core_message')
- })
- );
- this.setStdModContent(Y.WidgetStdMod.BODY, content, Y.WidgetStdMod.REPLACE);
-
- // Use standard dialogue class name. This removes the default styling of the footer.
- this._bb.one('.moodle-dialogue-wrap').addClass('moodle-dialogue-content');
-
- // Set the events listeners.
- this._setEvents();
- },
-
- /**
- * Prepare the dialog for a user.
- *
- * @method prepareForUser
- * @param {Number} userid The user ID.
- * @param {String} fullname The user full name.
- */
- prepareForUser: function(userid, fullname) {
- var title;
-
- this.set('userid', userid);
- this.set('fullname', fullname);
-
- // Prepare the title.
- title = Y.Node.create('' + Y.Escape.html(fullname) + '
');
- this.setStdModContent(Y.WidgetStdMod.HEADER, title, Y.WidgetStdMod.REPLACE);
-
- // Update the link to the conversation.
- this._bb.one(SELECTORS.SENDMSGDIALOG.HISTORYLINK)
- .set('href', M.cfg.wwwroot + '/message/index.php?id=' + this.get('userid'));
-
- // Set the content as empty and lock send.
- this._bb.one(SELECTORS.SENDMSGDIALOG.INPUT).set('value', '');
-
- // Register form with formchangechecker
- Y.use('moodle-core-formchangechecker', function() {
- M.core_formchangechecker.init({formid: "messageform"});
- });
- },
-
- /**
- * Send the message to the user.
- *
- * @method sendMessage
- * @param {String} message The message to be sent.
- */
- sendMessage: function(message) {
- if (this._sendLock) {
- // Do not proceed if the lock is active.
- return;
- }
-
- if (!message || !this._validateMessage(message)) {
- // Do not send falsy messages.
- return;
- }
-
- // Actually send the message.
- this._ioSend = Y.io(this.get('url'), {
- method: 'POST',
- data: {
- sesskey: M.cfg.sesskey,
- action: 'sendmessage',
- userid: this.get('userid'),
- message: message
- },
- on: {
- start: function() {
- var img = '
';
- this.setSendLock(true);
- this.showNotice(img + ' ' + M.util.get_string('sendingmessage', 'core_message'));
- },
- success: function(id, response) {
- var data = null;
-
- try {
- data = Y.JSON.parse(response.responseText);
- if (data.error) {
- this.hideNotice();
- new M.core.ajaxException(data);
- return;
- }
- } catch (e) {
- this.hideNotice();
- new M.core.exception(e);
- return;
- }
-
- // Show a success message.
- this.showNotice(M.util.get_string('messagesent', 'core_message'));
-
- // Hide the dialog.
- Y.later(1300, this, function() {
- this.setSendLock(false);
- this.hideNotice();
- this.hide();
- });
- },
- failure: function() {
- this.setSendLock(false);
- this.hideNotice();
- new M.core.alert({
- title: M.util.get_string('error', 'core'),
- message: M.util.get_string('errorwhilesendingmessage', 'core_message')
- });
- }
- },
- context: this
- });
- },
-
- /**
- * Override the default hide function.
- * @method hide
- */
- hide: function() {
- var self = this;
-
- if (!M.core_formchangechecker.get_form_dirty_state()) {
- return SENDMSGDIALOG.superclass.hide.call(this, arguments);
- }
-
- Y.use('moodle-core-notification-confirm', function() {
- var confirm = new M.core.confirm({
- title: M.util.get_string('confirm', 'moodle'),
- question: M.util.get_string('changesmadereallygoaway', 'moodle'),
- yesLabel: M.util.get_string('confirm', 'moodle'),
- noLabel: M.util.get_string('cancel', 'moodle')
- });
- confirm.on('complete-yes', function() {
- M.core_formchangechecker.reset_form_dirty_state();
- confirm.hide();
- confirm.destroy();
- return SENDMSGDIALOG.superclass.hide.call(this, arguments);
- }, self);
- });
- },
-
- /**
- * Show a notice.
- *
- * @method hideNotice.
- */
- hideNotice: function() {
- this._bb.one(SELECTORS.SENDMSGDIALOG.NOTICEAREA).hide();
- },
-
- /**
- * Show a notice.
- *
- * @param {String} html String to show.
- * @method showNotice.
- */
- showNotice: function(html) {
- this._bb.one(SELECTORS.SENDMSGDIALOG.NOTICE).setHTML(html);
- this._bb.one(SELECTORS.SENDMSGDIALOG.NOTICEAREA).show();
- },
-
- /**
- * Set the send lock.
- *
- * We do not lock the send button because that would cause a focus change on screenreaders
- * which then conflicts with the aria-live region reading out that we are sending a message.
- *
- * @method setSendLock
- * @param {Boolean} lock When true, enables the lock.
- */
- setSendLock: function(lock) {
- if (lock) {
- this._sendLock = true;
- } else {
- this._sendLock = false;
- }
- },
-
- /**
- * Register the events.
- *
- * @method _setEvents.
- */
- _setEvents: function() {
- // Form submit.
- this._bb.one(SELECTORS.SENDMSGDIALOG.FORM).on('submit', function(e) {
- var message = this._bb.one(SELECTORS.SENDMSGDIALOG.INPUT).get('value');
- e.preventDefault();
- this.sendMessage(message);
- }, this);
- },
-
- /**
- * Validates a message.
- *
- * @method _validateMessage
- * @param {String} message A message to be validated.
- */
- _validateMessage: function(message) {
- var trimmed;
- if (!message) {
- return false;
- }
-
- // Basic validation.
- trimmed = message.replace(' ', '')
- .replace(' ', '')
- .replace(/(
(<\/br\s*\/?>)?)+/, '')
- .trim();
-
- return trimmed.length > 1;
- }
-
-}, {
- NAME: 'core_message-messenger-sendmessage',
- CSS_PREFIX: CSSR.SENDMSGDIALOG.PREFIX,
- ATTRS: {
-
- /**
- * Fullname of the user.
- *
- * @attribute fullname
- * @default ''
- * @type String
- */
- fullname: {
- validator: Y.Lang.isString,
- value: ''
- },
-
- /**
- * URL to the message Ajax actions.
- *
- * @attribute url
- * @default null
- * @type String
- */
- url: {
- validator: Y.Lang.isString,
- value: null
- },
-
- /**
- * User ID this dialog interacts with.
- *
- * @attribute userid
- * @default 0
- * @type Number
- */
- userid: {
- validator: Y.Lang.isNumber,
- value: 0
- }
- }
-});
-
-Y.Base.modifyAttrs(Y.namespace('M.core_message.messenger.sendMessage'), {
-
- /**
- * List of extra classes.
- *
- * @attribute extraClasses
- * @default ['core_message-messenger-sendmessage']
- * @type Array
- */
- extraClasses: {
- value: ['core_message-messenger-sendmessage']
- },
-
- /**
- * Whether to focus on the target that caused the Widget to be shown.
- *
- * @attribute focusOnPreviousTargetAfterHide
- * @default true
- * @type Node
- */
- focusOnPreviousTargetAfterHide: {
- value: true
- },
-
- /**
- *
- * Width.
- *
- * @attribute width
- * @default '260px'
- * @type String|Number
- */
- width: {
- value: '360px'
- },
-
- /**
- * Boolean indicating whether or not the Widget is visible.
- *
- * @attribute visible
- * @default false
- * @type Boolean
- */
- visible: {
- value: false
- },
-
- /**
- * Whether the widget should be modal or not.
- *
- * @attribute modal
- * @type Boolean
- * @default true
- */
- modal: {
- value: true
- },
-
- /**
- * Whether the widget should be draggable or not.
- *
- * @attribute draggable
- * @type Boolean
- * @default false
- */
- draggable: {
- value: false
- },
-
- /**
- * Whether to display the dialogue centrally on the screen.
- *
- * @attribute center
- * @type Boolean
- * @default false
- */
- center: {
- value: true
- }
-
-});
-
-
-}, '@VERSION@', {
- "requires": [
- "escape",
- "handlebars",
- "io-base",
- "moodle-core-notification-ajaxexception",
- "moodle-core-notification-alert",
- "moodle-core-notification-dialogue",
- "moodle-core-notification-exception"
- ]
-});
diff --git a/message/yui/src/messenger/build.json b/message/yui/src/messenger/build.json
deleted file mode 100644
index f9d999824d1..00000000000
--- a/message/yui/src/messenger/build.json
+++ /dev/null
@@ -1,12 +0,0 @@
-{
- "name": "moodle-core_message-messenger",
- "builds": {
- "moodle-core_message-messenger": {
- "jsfiles": [
- "constants.js",
- "manager.js",
- "sendmessage.js"
- ]
- }
- }
-}
diff --git a/message/yui/src/messenger/js/constants.js b/message/yui/src/messenger/js/constants.js
deleted file mode 100644
index 4e3adb12501..00000000000
--- a/message/yui/src/messenger/js/constants.js
+++ /dev/null
@@ -1,41 +0,0 @@
-// 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 .
-/* eslint-disable no-unused-vars */
-
-/**
- * Messenger constants.
- *
- * @module moodle-core_message-messenger
- * @package core_message
- * @copyright 2015 Frédéric Massart - FMCorz.net
- * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
- */
-
-
-/**
- * Cascading Style Sheet References.
- *
- * Using the name "CSS" would redefine the existing JS object CSS.
- *
- * @type {Object}
- */
-var CSSR = {};
-
-/**
- * Object containing a reference to the selectors.
- *
- * @type {Object}
- */
-var SELECTORS = {};
diff --git a/message/yui/src/messenger/js/manager.js b/message/yui/src/messenger/js/manager.js
deleted file mode 100644
index 559529a3dc4..00000000000
--- a/message/yui/src/messenger/js/manager.js
+++ /dev/null
@@ -1,144 +0,0 @@
-// 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 .
-/* global SELECTORS */
-
-/**
- * Messenger manager.
- *
- * @module moodle-core_message-messenger
- * @package core_message
- * @copyright 2015 Frédéric Massart - FMCorz.net
- * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
- */
-
-SELECTORS.MANAGER = {
- SENDMESSAGE: '[data-trigger="core_message-messenger::sendmessage"]'
-};
-
-/**
- * Messenger manager.
- *
- * @namespace M.core_message.messenger
- * @class MANAGER
- * @constructor
- */
-var MANAGER = function() {
- MANAGER.superclass.constructor.apply(this, arguments);
-};
-Y.namespace('M.core_message.messenger').Manager = Y.extend(MANAGER, Y.Base, {
-
- _sendMessageDialog: null,
- _events: [],
-
- /**
- * Initializer.
- *
- * @method initializer
- */
- initializer: function() {
- this._setEvents();
- },
-
- /**
- * Sending a message.
- *
- * @method sendMessage
- * @param {Number} userid The user ID to send a message to.
- * @param {String} fullname The fullname of the user.
- * @param {EventFacade} e The event triggered, when any it should be passed to the dialog.
- */
- sendMessage: function(userid, fullname, e) {
- var Klass;
- if (!this._sendMessageDialog) {
- Klass = Y.namespace('M.core_message.messenger.sendMessage');
- this._sendMessageDialog = new Klass({
- url: this.get('url')
- });
- }
-
- this._sendMessageDialog.prepareForUser(userid, fullname);
- this._sendMessageDialog.show(e);
- },
-
- /**
- * Pop up an alert dialogue to notify the logged in user that they are blocked from
- * messaging the target user.
- *
- * @method alertBlocked
- * @param {String} blockedString The identifier to retrieve the blocked user message.
- * @param {String} fullName The target user's full name.
- */
- alertBlocked: function(blockedString, fullName) {
- new M.core.alert({
- title: M.util.get_string('error', 'core'),
- message: M.util.get_string(blockedString, 'message', fullName)
- });
- },
-
- /**
- * Register the events.
- *
- * @method _setEvents.
- */
- _setEvents: function() {
- var captureEvent = function(e) {
- var target = e.currentTarget,
- userid = parseInt(target.getData('userid'), 10),
- fullname = target.getData('fullname'),
- blockedString = target.getData('blocked-string');
-
- if (!userid || !fullname) {
- return;
- }
-
- // Pass the validation before preventing defaults.
- e.preventDefault();
- if (blockedString) {
- this.alertBlocked(blockedString, fullname);
- } else {
- this.sendMessage(userid, fullname, e);
- }
- };
-
- this._events.push(Y.delegate('click', captureEvent, 'body', SELECTORS.MANAGER.SENDMESSAGE, this));
- this._events.push(Y.one(Y.config.doc).delegate('key', captureEvent, 'space', SELECTORS.MANAGER.SENDMESSAGE, this));
- }
-
-}, {
- NAME: 'core_message-messenger-manager',
- ATTRS: {
-
- /**
- * URL to the message Ajax actions.
- *
- * @attribute url
- * @default M.cfg.wwwroot + '/message/ajax.php'
- * @type String
- */
- url: {
- readonly: true,
- value: M.cfg.wwwroot + '/message/ajax.php'
- }
- }
-});
-
-var MANAGERINST;
-Y.namespace('M.core_message.messenger').init = function(config) {
- if (!MANAGERINST) {
- // Prevent duplicates of the manager if this function is called more than once.
- MANAGERINST = new MANAGER(config);
- }
- return MANAGERINST;
-};
diff --git a/message/yui/src/messenger/js/sendmessage.js b/message/yui/src/messenger/js/sendmessage.js
deleted file mode 100644
index 26b433c031f..00000000000
--- a/message/yui/src/messenger/js/sendmessage.js
+++ /dev/null
@@ -1,436 +0,0 @@
-// 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 .
-/* global CSSR, SELECTORS */
-
-/**
- * Send message dialog.
- *
- * @module moodle-core_message-messenger
- * @package core_message
- * @copyright 2015 Frédéric Massart - FMCorz.net
- * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
- */
-
-CSSR.SENDMSGDIALOG = {
- ACCESSHIDE: 'accesshide',
- ACTIONS: 'message-actions',
- FOOTER: 'message-footer',
- HIDDEN: 'hidden',
- HISTORYLINK: 'message-history',
- INPUT: 'message-input',
- INPUTAREA: 'message-area',
- NOTICE: 'message-notice',
- NOTICEAREA: 'message-notice-area',
- PREFIX: 'core_message-messenger-sendmessage',
- SENDBTN: 'message-send',
- WRAPPER: 'message-wrapper'
-};
-
-SELECTORS.SENDMSGDIALOG = {
- FORM: 'form',
- HISTORYLINK: '.message-history',
- INPUT: '.message-input',
- NOTICE: '.message-notice div',
- NOTICEAREA: '.message-notice-area',
- SENDBTN: '.message-send'
-};
-
-/**
- * Send message dialog.
- *
- * @namespace M.core_message
- * @class SENDMSGDIALOG
- * @constructor
- */
-var SENDMSGDIALOG = function() {
- SENDMSGDIALOG.superclass.constructor.apply(this, arguments);
-};
-Y.namespace('M.core_message.messenger').sendMessage = Y.extend(SENDMSGDIALOG, M.core.dialogue, {
-
- _bb: null,
- _sendLock: false,
- _hide: null,
- /**
- * Initializer.
- *
- * @method initializer
- */
- initializer: function() {
- var tpl,
- content;
-
- this._bb = this.get('boundingBox');
- this._hide = this.hide;
-
- // Prepare the content area.
- tpl = Y.Handlebars.compile(
- ''
- );
- content = Y.Node.create(
- tpl({
- CSSR: CSSR.SENDMSGDIALOG,
- id: Y.guid(),
- labelStr: M.util.get_string('messagetosend', 'core_message'),
- loadingIcon: M.util.image_url('i/loading', 'moodle'),
- sendStr: M.util.get_string('sendmessage', 'core_message'),
- viewHistoryStr: M.util.get_string('viewconversation', 'core_message')
- })
- );
- this.setStdModContent(Y.WidgetStdMod.BODY, content, Y.WidgetStdMod.REPLACE);
-
- // Use standard dialogue class name. This removes the default styling of the footer.
- this._bb.one('.moodle-dialogue-wrap').addClass('moodle-dialogue-content');
-
- // Set the events listeners.
- this._setEvents();
- },
-
- /**
- * Prepare the dialog for a user.
- *
- * @method prepareForUser
- * @param {Number} userid The user ID.
- * @param {String} fullname The user full name.
- */
- prepareForUser: function(userid, fullname) {
- var title;
-
- this.set('userid', userid);
- this.set('fullname', fullname);
-
- // Prepare the title.
- title = Y.Node.create('' + Y.Escape.html(fullname) + '
');
- this.setStdModContent(Y.WidgetStdMod.HEADER, title, Y.WidgetStdMod.REPLACE);
-
- // Update the link to the conversation.
- this._bb.one(SELECTORS.SENDMSGDIALOG.HISTORYLINK)
- .set('href', M.cfg.wwwroot + '/message/index.php?id=' + this.get('userid'));
-
- // Set the content as empty and lock send.
- this._bb.one(SELECTORS.SENDMSGDIALOG.INPUT).set('value', '');
-
- // Register form with formchangechecker
- Y.use('moodle-core-formchangechecker', function() {
- M.core_formchangechecker.init({formid: "messageform"});
- });
- },
-
- /**
- * Send the message to the user.
- *
- * @method sendMessage
- * @param {String} message The message to be sent.
- */
- sendMessage: function(message) {
- if (this._sendLock) {
- // Do not proceed if the lock is active.
- return;
- }
-
- if (!message || !this._validateMessage(message)) {
- // Do not send falsy messages.
- return;
- }
-
- // Actually send the message.
- this._ioSend = Y.io(this.get('url'), {
- method: 'POST',
- data: {
- sesskey: M.cfg.sesskey,
- action: 'sendmessage',
- userid: this.get('userid'),
- message: message
- },
- on: {
- start: function() {
- var img = '
';
- this.setSendLock(true);
- this.showNotice(img + ' ' + M.util.get_string('sendingmessage', 'core_message'));
- },
- success: function(id, response) {
- var data = null;
-
- try {
- data = Y.JSON.parse(response.responseText);
- if (data.error) {
- this.hideNotice();
- new M.core.ajaxException(data);
- return;
- }
- } catch (e) {
- this.hideNotice();
- new M.core.exception(e);
- return;
- }
-
- // Show a success message.
- this.showNotice(M.util.get_string('messagesent', 'core_message'));
-
- // Hide the dialog.
- Y.later(1300, this, function() {
- this.setSendLock(false);
- this.hideNotice();
- this.hide();
- });
- },
- failure: function() {
- this.setSendLock(false);
- this.hideNotice();
- new M.core.alert({
- title: M.util.get_string('error', 'core'),
- message: M.util.get_string('errorwhilesendingmessage', 'core_message')
- });
- }
- },
- context: this
- });
- },
-
- /**
- * Override the default hide function.
- * @method hide
- */
- hide: function() {
- var self = this;
-
- if (!M.core_formchangechecker.get_form_dirty_state()) {
- return SENDMSGDIALOG.superclass.hide.call(this, arguments);
- }
-
- Y.use('moodle-core-notification-confirm', function() {
- var confirm = new M.core.confirm({
- title: M.util.get_string('confirm', 'moodle'),
- question: M.util.get_string('changesmadereallygoaway', 'moodle'),
- yesLabel: M.util.get_string('confirm', 'moodle'),
- noLabel: M.util.get_string('cancel', 'moodle')
- });
- confirm.on('complete-yes', function() {
- M.core_formchangechecker.reset_form_dirty_state();
- confirm.hide();
- confirm.destroy();
- return SENDMSGDIALOG.superclass.hide.call(this, arguments);
- }, self);
- });
- },
-
- /**
- * Show a notice.
- *
- * @method hideNotice.
- */
- hideNotice: function() {
- this._bb.one(SELECTORS.SENDMSGDIALOG.NOTICEAREA).hide();
- },
-
- /**
- * Show a notice.
- *
- * @param {String} html String to show.
- * @method showNotice.
- */
- showNotice: function(html) {
- this._bb.one(SELECTORS.SENDMSGDIALOG.NOTICE).setHTML(html);
- this._bb.one(SELECTORS.SENDMSGDIALOG.NOTICEAREA).show();
- },
-
- /**
- * Set the send lock.
- *
- * We do not lock the send button because that would cause a focus change on screenreaders
- * which then conflicts with the aria-live region reading out that we are sending a message.
- *
- * @method setSendLock
- * @param {Boolean} lock When true, enables the lock.
- */
- setSendLock: function(lock) {
- if (lock) {
- this._sendLock = true;
- } else {
- this._sendLock = false;
- }
- },
-
- /**
- * Register the events.
- *
- * @method _setEvents.
- */
- _setEvents: function() {
- // Form submit.
- this._bb.one(SELECTORS.SENDMSGDIALOG.FORM).on('submit', function(e) {
- var message = this._bb.one(SELECTORS.SENDMSGDIALOG.INPUT).get('value');
- e.preventDefault();
- this.sendMessage(message);
- }, this);
- },
-
- /**
- * Validates a message.
- *
- * @method _validateMessage
- * @param {String} message A message to be validated.
- */
- _validateMessage: function(message) {
- var trimmed;
- if (!message) {
- return false;
- }
-
- // Basic validation.
- trimmed = message.replace(' ', '')
- .replace(' ', '')
- .replace(/(
(<\/br\s*\/?>)?)+/, '')
- .trim();
-
- return trimmed.length > 1;
- }
-
-}, {
- NAME: 'core_message-messenger-sendmessage',
- CSS_PREFIX: CSSR.SENDMSGDIALOG.PREFIX,
- ATTRS: {
-
- /**
- * Fullname of the user.
- *
- * @attribute fullname
- * @default ''
- * @type String
- */
- fullname: {
- validator: Y.Lang.isString,
- value: ''
- },
-
- /**
- * URL to the message Ajax actions.
- *
- * @attribute url
- * @default null
- * @type String
- */
- url: {
- validator: Y.Lang.isString,
- value: null
- },
-
- /**
- * User ID this dialog interacts with.
- *
- * @attribute userid
- * @default 0
- * @type Number
- */
- userid: {
- validator: Y.Lang.isNumber,
- value: 0
- }
- }
-});
-
-Y.Base.modifyAttrs(Y.namespace('M.core_message.messenger.sendMessage'), {
-
- /**
- * List of extra classes.
- *
- * @attribute extraClasses
- * @default ['core_message-messenger-sendmessage']
- * @type Array
- */
- extraClasses: {
- value: ['core_message-messenger-sendmessage']
- },
-
- /**
- * Whether to focus on the target that caused the Widget to be shown.
- *
- * @attribute focusOnPreviousTargetAfterHide
- * @default true
- * @type Node
- */
- focusOnPreviousTargetAfterHide: {
- value: true
- },
-
- /**
- *
- * Width.
- *
- * @attribute width
- * @default '260px'
- * @type String|Number
- */
- width: {
- value: '360px'
- },
-
- /**
- * Boolean indicating whether or not the Widget is visible.
- *
- * @attribute visible
- * @default false
- * @type Boolean
- */
- visible: {
- value: false
- },
-
- /**
- * Whether the widget should be modal or not.
- *
- * @attribute modal
- * @type Boolean
- * @default true
- */
- modal: {
- value: true
- },
-
- /**
- * Whether the widget should be draggable or not.
- *
- * @attribute draggable
- * @type Boolean
- * @default false
- */
- draggable: {
- value: false
- },
-
- /**
- * Whether to display the dialogue centrally on the screen.
- *
- * @attribute center
- * @type Boolean
- * @default false
- */
- center: {
- value: true
- }
-
-});
diff --git a/message/yui/src/messenger/meta/messenger.json b/message/yui/src/messenger/meta/messenger.json
deleted file mode 100644
index 99cc8140e53..00000000000
--- a/message/yui/src/messenger/meta/messenger.json
+++ /dev/null
@@ -1,13 +0,0 @@
-{
- "moodle-core_message-messenger": {
- "requires": [
- "escape",
- "handlebars",
- "io-base",
- "moodle-core-notification-ajaxexception",
- "moodle-core-notification-alert",
- "moodle-core-notification-dialogue",
- "moodle-core-notification-exception"
- ]
- }
-}
diff --git a/theme/bootstrapbase/less/moodle/message.less b/theme/bootstrapbase/less/moodle/message.less
index f794f342e34..b6739f0abfc 100644
--- a/theme/bootstrapbase/less/moodle/message.less
+++ b/theme/bootstrapbase/less/moodle/message.less
@@ -584,67 +584,6 @@
width: auto;
}
-/** Messenger send message dialog */
-.core_message-messenger-sendmessage-hidden {
- display: none;
-}
-.core_message-messenger-sendmessage {
- .message-actions {
- position: relative;
- }
- .message-area {
- height: 240px;
- max-height: 100%;
- position: relative;
- margin-bottom: 10px;
- }
- .message-input {
- width: 100%;
- height: 100%;
- .box-sizing(border-box);
- }
- .message-send {
- margin: 0;
- float: right;
- }
- .message-notice-area {
- display: table;
- position: absolute;
- top: 0;
- bottom: 0;
- left: 0;
- right: 0;
- width: 100%;
- height: 100%;
- }
- .message-notice {
- display: table-cell;
- vertical-align: middle;
- text-align: center;
- > div {
- background: #eee;
- padding: 5px;
- font-size: 12px;
- }
- }
- .message-footer {
- margin-top: 3px;
- line-height: 20px;
- }
- .message-history {
- position: absolute;
- bottom: 0;
- }
-}
-
-.dir-rtl {
- .core_message-messenger-sendmessage {
- .message-send {
- float: left;
- }
- }
-}
-
.preferences-container {
.container-fluid {
padding: 0;
diff --git a/theme/bootstrapbase/style/moodle.css b/theme/bootstrapbase/style/moodle.css
index 99cc01f7833..62702187ad3 100644
--- a/theme/bootstrapbase/style/moodle.css
+++ b/theme/bootstrapbase/style/moodle.css
@@ -6241,61 +6241,6 @@ a.ygtvspacer:hover {
#page-user-action_redir #edit-messagebody {
width: auto;
}
-/** Messenger send message dialog */
-.core_message-messenger-sendmessage-hidden {
- display: none;
-}
-.core_message-messenger-sendmessage .message-actions {
- position: relative;
-}
-.core_message-messenger-sendmessage .message-area {
- height: 240px;
- max-height: 100%;
- position: relative;
- margin-bottom: 10px;
-}
-.core_message-messenger-sendmessage .message-input {
- width: 100%;
- height: 100%;
- -webkit-box-sizing: border-box;
- -moz-box-sizing: border-box;
- box-sizing: border-box;
-}
-.core_message-messenger-sendmessage .message-send {
- margin: 0;
- float: right;
-}
-.core_message-messenger-sendmessage .message-notice-area {
- display: table;
- position: absolute;
- top: 0;
- bottom: 0;
- left: 0;
- right: 0;
- width: 100%;
- height: 100%;
-}
-.core_message-messenger-sendmessage .message-notice {
- display: table-cell;
- vertical-align: middle;
- text-align: center;
-}
-.core_message-messenger-sendmessage .message-notice > div {
- background: #eee;
- padding: 5px;
- font-size: 12px;
-}
-.core_message-messenger-sendmessage .message-footer {
- margin-top: 3px;
- line-height: 20px;
-}
-.core_message-messenger-sendmessage .message-history {
- position: absolute;
- bottom: 0;
-}
-.dir-rtl .core_message-messenger-sendmessage .message-send {
- float: left;
-}
.preferences-container .container-fluid {
padding: 0;
}