MDL-55942 core: obey the mighty CiBoT

This commit is contained in:
Mark Nelson 2016-09-20 17:23:22 +08:00
parent 79f6c36c12
commit 7b55aaa12e
51 changed files with 371 additions and 330 deletions

View File

@ -125,7 +125,8 @@ 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 = '<img class="iconsmall" src="'.$OUTPUT->pix_url('t/message') . '" alt="'. get_string('messageselectadd') .'" />';
$anchorurl = new moodle_url('/message/index.php', array('id' => $user->id));
$anchortag = html_writer::link($anchorurl, $anchortagcontents, array('title' => get_string('messageselectadd')));
$anchortag = html_writer::link($anchorurl, $anchortagcontents,
array('title' => get_string('messageselectadd')));
$this->content->text .= '<div class="message">'.$anchortag.'</div>';
}

View File

@ -36,7 +36,7 @@ define(['jquery'], function($) {
* Determine how many rows should be set for the given element.
*
* @method calculateRows
* @param {jQuery object} element The textarea element
* @param {jQuery} element The textarea element
* @return {int} The number of rows for the element
* @private
*/
@ -69,7 +69,7 @@ define(['jquery'], function($) {
* Add the event listeners for all text areas within the given element.
*
* @method init
* @param {jQuery object|selector} root The container element of all enhanced text areas
* @param {jQuery|selector} root The container element of all enhanced text areas
* @public
*/
var init = function(root) {

View File

@ -281,7 +281,7 @@ define(['jquery', 'core/key_codes'], function($, keyCodes) {
*
* @method addScrollLockListener
* @private
* @param {jQuery object} element jQuery object to add event listeners to
* @param {jQuery} element jQuery object to add event listeners to
*/
var addScrollLockListener = function(element) {
// Lock mousewheel scrolling within the element to stop the annoying window scroll.
@ -316,6 +316,8 @@ define(['jquery', 'core/key_codes'], function($, keyCodes) {
return false;
}
return true;
});
};

View File

@ -38,8 +38,7 @@ define(['jquery', 'core/str', 'core/custom_interaction_events'],
/**
* Constructor for the PopoverRegionController.
*
* @param element jQuery object root element of the popover
* @return object PopoverRegionController
* @param {jQuery} element object root element of the popover
*/
var PopoverRegionController = function(element) {
this.root = $(element);
@ -52,6 +51,8 @@ define(['jquery', 'core/str', 'core/custom_interaction_events'],
/**
* The collection of events triggered by this controller.
*
* @returns {object}
*/
PopoverRegionController.prototype.events = function() {
return {
@ -66,7 +67,7 @@ define(['jquery', 'core/str', 'core/custom_interaction_events'],
* Return the container element for the content element.
*
* @method getContentContainer
* @return jQuery object
* @return {jQuery} object
*/
PopoverRegionController.prototype.getContentContainer = function() {
return this.contentContainer;
@ -76,7 +77,7 @@ define(['jquery', 'core/str', 'core/custom_interaction_events'],
* Return the content element.
*
* @method getContent
* @return jQuery object
* @return {jQuery} object
*/
PopoverRegionController.prototype.getContent = function() {
return this.content;
@ -86,7 +87,7 @@ define(['jquery', 'core/str', 'core/custom_interaction_events'],
* Checks if the popover is displayed.
*
* @method isMenuOpen
* @return bool
* @return {bool}
*/
PopoverRegionController.prototype.isMenuOpen = function() {
return !this.root.hasClass('collapsed');
@ -203,7 +204,7 @@ define(['jquery', 'core/str', 'core/custom_interaction_events'],
* Check if a content item has focus.
*
* @method contentItemHasFocus
* @return bool
* @return {bool}
*/
PopoverRegionController.prototype.contentItemHasFocus = function() {
return this.getContentItemWithFocus().length > 0;
@ -213,7 +214,7 @@ define(['jquery', 'core/str', 'core/custom_interaction_events'],
* Return the currently focused content item.
*
* @method getContentItemWithFocus
* @return jQuery object
* @return {jQuery} object
*/
PopoverRegionController.prototype.getContentItemWithFocus = function() {
var currentFocus = $(document.activeElement);

View File

@ -147,10 +147,10 @@ class renderer_base {
try {
// Grab a copy of the existing helper to be restored later.
$uniqidHelper = $mustache->getHelper('uniqid');
$uniqidhelper = $mustache->getHelper('uniqid');
} catch (Mustache_Exception_UnknownHelperException $e) {
// Helper doesn't exist.
$uniqidHelper = null;
$uniqidhelper = null;
}
// Provide 1 random value that will not change within a template
@ -169,15 +169,15 @@ class renderer_base {
}
}
$renderedTemplate = trim($template->render($context));
$renderedtemplate = trim($template->render($context));
// If we had an existing uniqid helper then we need to restore it to allow
// handle nested calls of render_from_template.
if ($uniqidHelper) {
$mustache->addHelper('uniqid', $uniqidHelper);
if ($uniqidhelper) {
$mustache->addHelper('uniqid', $uniqidhelper);
}
return $renderedTemplate;
return $renderedtemplate;
}
@ -3193,7 +3193,7 @@ EOD;
}
/**
* Returns the noticication menu
* Returns the notification menu
*
* @return string HTML for the notification menu
*/

View File

@ -74,7 +74,7 @@ define(['jquery', 'core_message/message_area_contacts', 'core_message/message_ar
SEARCHBOX: "[data-region='search-box']",
SEARCHFILTER: "[data-region='search-filter']",
SEARCHFILTERAREA: "[data-region='search-filter-area']",
SEARCHPEOPLEINCOURSE : "[data-action='search-people-in-course']",
SEARCHPEOPLEINCOURSE: "[data-action='search-people-in-course']",
SEARCHRESULTSAREA: "[data-region='search-results-area']",
SEARCHTEXTAREA: "[data-region='search-text-area']",
SELECTEDVIEWPROFILE: "[data-action='view-contact-profile'].selected",
@ -162,7 +162,7 @@ define(['jquery', 'core_message/message_area_contacts', 'core_message/message_ar
* Handles finding a node in the messaging area.
*
* @param {String} selector The selector for the node we are looking for
* @returns {jQuery} The node
* @return {jQuery} The node
*/
Messagearea.prototype.find = function(selector) {
return this.node.find(selector);
@ -171,7 +171,7 @@ define(['jquery', 'core_message/message_area_contacts', 'core_message/message_ar
/**
* Returns the ID of the user whose message area we are viewing.
*
* @returns {int} The user id
* @return {int} The user id
*/
Messagearea.prototype.getCurrentUserId = function() {
return this.node.data('userid');

View File

@ -230,16 +230,16 @@ define(['jquery', 'core/ajax', 'core/templates', 'core/notification', 'core/cust
/**
* Handles loading conversations.
*
* @returns {Promise} The promise resolved when the contact area has been rendered,
* @return {Promise|boolean} The promise resolved when the contact area has been rendered,
* @private
*/
Contacts.prototype._loadConversations = function() {
if (this._isDeleting) {
return;
return false;
}
if (this._isLoadingConversations) {
return;
return false;
}
// Tell the user we are loading items.
@ -284,16 +284,16 @@ define(['jquery', 'core/ajax', 'core/templates', 'core/notification', 'core/cust
/**
* Handles loading contacts.
*
* @returns {Promise} The promise resolved when the contact area has been rendered
* @return {Promise|boolean} The promise resolved when the contact area has been rendered
* @private
*/
Contacts.prototype._loadContacts = function() {
if (this._isDeleting) {
return;
return false;
}
if (this._isLoadingContacts) {
return;
return false;
}
// Tell the user we are loading items.
@ -384,7 +384,7 @@ define(['jquery', 'core/ajax', 'core/templates', 'core/notification', 'core/cust
* @param {String} webservice The web service to call
* @param {int} limitfrom
* @param {int} limitnum
* @returns {Promise} The promise resolved when the contact area has been rendered
* @return {Promise} The promise resolved when the contact area has been rendered
* @private
*/
Contacts.prototype._getItems = function(webservice, limitfrom, limitnum) {
@ -404,8 +404,8 @@ define(['jquery', 'core/ajax', 'core/templates', 'core/notification', 'core/cust
/**
* Handles deleting a conversation.
*
* @params {Event} event
* @params {int} The user id belonging to the messages we are deleting.
* @param {Event} event
* @param {int} userid The user id belonging to the messages we are deleting.
* @private
*/
Contacts.prototype._deleteConversation = function(event, userid) {
@ -420,9 +420,9 @@ define(['jquery', 'core/ajax', 'core/templates', 'core/notification', 'core/cust
/**
* Handles updating the last message in the contact.
*
* @params {Event} event
* @params {int} The user id belonging to the messages we are deleting
* @params {jQuery|null} The message we need to update the contact panel with
* @param {Event} event
* @param {int} userid The user id belonging to the messages we are deleting
* @param {jQuery|null} updatemessage The message we need to update the contact panel with
* @private
*/
Contacts.prototype._updateLastMessage = function(event, userid, updatemessage) {
@ -446,7 +446,6 @@ define(['jquery', 'core/ajax', 'core/templates', 'core/notification', 'core/cust
/**
* Handles adding a contact to the list.
*
* @param {int} userid
* @private
*/
Contacts.prototype._addContact = function() {
@ -506,6 +505,7 @@ define(['jquery', 'core/ajax', 'core/templates', 'core/notification', 'core/cust
*
* @param {String} selector
* @param {int} userid
* @return {jQuery} The user node
* @private
*/
Contacts.prototype._getUserNode = function(selector, userid) {
@ -530,6 +530,7 @@ define(['jquery', 'core/ajax', 'core/templates', 'core/notification', 'core/cust
* Converts a text message into the text that should be stored in the contact list
*
* @param {String} text
* @return {String} The altered text
*/
Contacts.prototype._getContactText = function(text) {
if (text.length > this._messageLength) {
@ -552,10 +553,10 @@ define(['jquery', 'core/ajax', 'core/templates', 'core/notification', 'core/cust
// Get the text we will display on the contact panel.
text = this._getContactText(text);
if (sentbyuser) {
Str.get_string('you', 'message').done(function (string) {
Str.get_string('you', 'message').done(function(string) {
// Ensure we display that the message is from this user.
user.find(this.messageArea.SELECTORS.LASTMESSAGEUSER).empty().append(string);
}.bind(this)).always(function () {
}.bind(this)).always(function() {
user.find(this.messageArea.SELECTORS.LASTMESSAGETEXT).empty().append(text);
}.bind(this));
} else {

View File

@ -115,7 +115,7 @@ define(['jquery', 'core/ajax', 'core/templates', 'core/notification', 'core/cust
*
* @param {Event} event
* @param {int} userid
* @returns {Promise} The promise resolved when the messages have been loaded.
* @return {Promise} The promise resolved when the messages have been loaded.
* @private
*/
Messages.prototype._viewMessages = function(event, userid) {
@ -160,12 +160,12 @@ define(['jquery', 'core/ajax', 'core/templates', 'core/notification', 'core/cust
/**
* Loads messages while scrolling.
*
* @returns {Promise} The promise resolved when the messages have been loaded.
* @return {Promise|boolean} The promise resolved when the messages have been loaded.
* @private
*/
Messages.prototype._loadMessages = function() {
if (this._isLoadingMessages) {
return;
return false;
}
this._isLoadingMessages = true;
@ -215,7 +215,7 @@ define(['jquery', 'core/ajax', 'core/templates', 'core/notification', 'core/cust
* Handles returning a list of messages to display.
*
* @param {int} userid
* @returns {Promise} The promise resolved when the contact area has been rendered
* @return {Promise} The promise resolved when the contact area has been rendered
* @private
*/
Messages.prototype._getMessages = function(userid) {
@ -238,7 +238,7 @@ define(['jquery', 'core/ajax', 'core/templates', 'core/notification', 'core/cust
/**
* Handles sending a message.
*
* @returns {Promise} The promise resolved once the message has been sent.
* @return {Promise|boolean} The promise resolved once the message has been sent.
* @private
*/
Messages.prototype._sendMessage = function() {
@ -247,12 +247,12 @@ define(['jquery', 'core/ajax', 'core/templates', 'core/notification', 'core/cust
// Do not do anything if it is empty.
if (text.trim() === '') {
return;
return false;
}
// If we are sending a message, don't do anything, be patient!
if (this._isSendingMessage) {
return;
return false;
}
// Ok, mark that we are sending a message.
@ -297,7 +297,6 @@ define(['jquery', 'core/ajax', 'core/templates', 'core/notification', 'core/cust
/**
* Handles selecting messages to delete.
*
* @returns {Promise} The promise resolved when the messages to delete have been selected.
* @private
*/
Messages.prototype._chooseMessagesToDelete = function() {
@ -332,7 +331,7 @@ define(['jquery', 'core/ajax', 'core/templates', 'core/notification', 'core/cust
read: isread
}
});
}.bind(this));
});
if (requests.length > 0) {
ajax.call(requests)[requests.length - 1].then(function() {
@ -382,7 +381,7 @@ define(['jquery', 'core/ajax', 'core/templates', 'core/notification', 'core/cust
/**
* Handles adding a scrolling event listener.
*
* @params {int} The number of messages received
* @param {int} numberreceived The number of messages received
* @private
*/
Messages.prototype._addScrollEventListener = function(numberreceived) {
@ -446,7 +445,6 @@ define(['jquery', 'core/ajax', 'core/templates', 'core/notification', 'core/cust
/**
* Handles hiding the delete checkboxes and replacing the response area.
*
* @return {Promise} JQuery promise object resolved when the template has been rendered.
* @private
*/
Messages.prototype._hideDeleteAction = function() {
@ -462,14 +460,14 @@ define(['jquery', 'core/ajax', 'core/templates', 'core/notification', 'core/cust
* @private
*/
Messages.prototype._triggerCancelMessagesToDelete = function() {
// Trigger event letting other modules know message deletion was canceled.
// Trigger event letting other modules know message deletion was canceled.
this.messageArea.trigger(this.messageArea.EVENTS.CANCELDELETEMESSAGES);
};
/**
* Handles adding messages to the DOM.
*
* @returns {Promise} The promise resolved when the message has been added to the DOM.
* @return {Promise} The promise resolved when the message has been added to the DOM.
* @private
*/
Messages.prototype._addMessageToDom = function() {
@ -497,7 +495,7 @@ define(['jquery', 'core/ajax', 'core/templates', 'core/notification', 'core/cust
/**
* Returns the ID of the other user in the conversation.
*
* @returns {int} The user id
* @return {int} The user id
* @private
*/
Messages.prototype._getUserId = function() {
@ -520,8 +518,8 @@ define(['jquery', 'core/ajax', 'core/templates', 'core/notification', 'core/cust
/**
* Select the previous message in the list.
*
* @params {event} e The jquery event
* @params {object} data Extra event data
* @param {event} e The jquery event
* @param {object} data Extra event data
* @private
*/
Messages.prototype._selectPreviousMessage = function(e, data) {
@ -540,8 +538,8 @@ define(['jquery', 'core/ajax', 'core/templates', 'core/notification', 'core/cust
/**
* Select the next message in the list.
*
* @params {event} e The jquery event
* @params {object} data Extra event data
* @param {event} e The jquery event
* @param {object} data Extra event data
* @private
*/
Messages.prototype._selectNextMessage = function(e, data) {
@ -560,7 +558,7 @@ define(['jquery', 'core/ajax', 'core/templates', 'core/notification', 'core/cust
/**
* Flag the response area as messaging.
*
* @params {event} e The jquery event
* @param {event} e The jquery event
* @private
*/
Messages.prototype._setMessaging = function(e) {
@ -570,7 +568,7 @@ define(['jquery', 'core/ajax', 'core/templates', 'core/notification', 'core/cust
/**
* Clear the response area as messaging flag.
*
* @params {event} e The jquery event
* @param {event} e The jquery event
* @private
*/
Messages.prototype._clearMessaging = function(e) {
@ -580,7 +578,7 @@ define(['jquery', 'core/ajax', 'core/templates', 'core/notification', 'core/cust
/**
* Turn on delete message mode.
*
* @params {event} e The jquery event
* @param {event} e The jquery event
* @private
*/
Messages.prototype._startDeleting = function(e) {
@ -603,7 +601,7 @@ define(['jquery', 'core/ajax', 'core/templates', 'core/notification', 'core/cust
/**
* Check or uncheck the message if the message area is in editing mode.
*
* @params {event} e The jquery event
* @param {event} e The jquery event
* @private
*/
Messages.prototype._toggleMessage = function(e) {
@ -624,7 +622,7 @@ define(['jquery', 'core/ajax', 'core/templates', 'core/notification', 'core/cust
* Adjust the height of the messages area to match the changed height of
* the response area.
*
* @params {event} e The jquery event
* @param {event} e The jquery event
* @private
*/
Messages.prototype._adjustMessagesAreaHeight = function(e) {
@ -641,8 +639,8 @@ define(['jquery', 'core/ajax', 'core/templates', 'core/notification', 'core/cust
/**
* Handle the event that triggers sending a message from the messages area.
*
* @params {event} e The jquery event
* @params {object} data Additional event data
* @param {event} e The jquery event
* @param {object} data Additional event data
* @private
*/
Messages.prototype._sendMessageHandler = function(e, data) {

View File

@ -70,7 +70,7 @@ define(['jquery', 'core/ajax', 'core/templates', 'core/notification', 'core/str'
*
* @param {Event} event
* @param {int} userid
* @returns {Promise} The promise resolved when the profile has been rendered
* @return {Promise} The promise resolved when the profile has been rendered
* @private
*/
Profile.prototype._viewProfile = function(event, userid) {
@ -117,7 +117,7 @@ define(['jquery', 'core/ajax', 'core/templates', 'core/notification', 'core/str'
/**
* Handles blocking the contact.
*
* @returns {Promise} The promise resolved when the contact has been blocked
* @return {Promise} The promise resolved when the contact has been blocked
* @private
*/
Profile.prototype._blockContact = function() {
@ -131,7 +131,7 @@ define(['jquery', 'core/ajax', 'core/templates', 'core/notification', 'core/str'
/**
* Handles unblocking the contact.
*
* @returns {Promise} The promise resolved when the contact has been unblocked
* @return {Promise} The promise resolved when the contact has been unblocked
* @private
*/
Profile.prototype._unblockContact = function() {
@ -145,7 +145,7 @@ define(['jquery', 'core/ajax', 'core/templates', 'core/notification', 'core/str'
/**
* Handles adding the contact.
*
* @returns {Promise} The promise resolved when the contact has been added
* @return {Promise} The promise resolved when the contact has been added
* @private
*/
Profile.prototype._addContact = function() {
@ -159,7 +159,7 @@ define(['jquery', 'core/ajax', 'core/templates', 'core/notification', 'core/str'
/**
* Handles removing the contact.
*
* @returns {Promise} The promise resolved when the contact has been removed
* @return {Promise} The promise resolved when the contact has been removed
* @private
*/
Profile.prototype._removeContact = function() {
@ -178,7 +178,7 @@ define(['jquery', 'core/ajax', 'core/templates', 'core/notification', 'core/str'
* @param {String} oldaction The data-action of the button
* @param {string} newaction The data-action to change the button to
* @param {String} newclass The CSS class we want to add
* @returns {Promise} The promise resolved when the action has been performed
* @return {Promise} The promise resolved when the action has been performed
* @private
*/
Profile.prototype._performAction = function(service, string, oldaction, newaction, newclass) {
@ -225,7 +225,7 @@ define(['jquery', 'core/ajax', 'core/templates', 'core/notification', 'core/str'
/**
* Returns the ID of the user whos profile we are viewing.
*
* @returns {int} The user ID
* @return {int} The user ID
* @private
*/
Profile.prototype._getUserId = function() {

View File

@ -177,13 +177,13 @@ define(['jquery', 'core/ajax', 'core/templates', 'core/notification', 'core/str'
this.messageArea.find(this.messageArea.SELECTORS.SEARCHRESULTSAREA).show();
if (this._searchArea == this._searchAreas.MESSAGES) {
this._requestTimeout = setTimeout(function () {
this._requestTimeout = setTimeout(function() {
this._clearSearchArea();
this._numMessagesDisplayed = 0;
this._searchMessages();
}.bind(this), 300);
} else if (this._searchArea == this._searchAreas.PEOPLEINCOURSE) {
this._requestTimeout = setTimeout(function () {
this._requestTimeout = setTimeout(function() {
this._clearSearchArea();
this._numPeopleDisplayed = 0;
this._searchPeopleInCourse();
@ -201,11 +201,11 @@ define(['jquery', 'core/ajax', 'core/templates', 'core/notification', 'core/str'
* Handles searching for messages.
*
* @private
* @returns {Promise} The promise resolved when the search area has been rendered
* @return {Promise|boolean} The promise resolved when the search area has been rendered
*/
Search.prototype._searchMessages = function() {
if (this._isLoading) {
return;
return false;
}
var str = this.messageArea.find(this.messageArea.SELECTORS.SEARCHBOX).val();
@ -257,7 +257,7 @@ define(['jquery', 'core/ajax', 'core/templates', 'core/notification', 'core/str'
* Handles searching for people.
*
* @private
* @returns {Promise} The promise resolved when the search area has been rendered
* @return {Promise} The promise resolved when the search area has been rendered
*/
Search.prototype._searchPeople = function() {
var str = this.messageArea.find(this.messageArea.SELECTORS.SEARCHBOX).val();
@ -288,11 +288,11 @@ define(['jquery', 'core/ajax', 'core/templates', 'core/notification', 'core/str'
* Handles searching for people in a course.
*
* @private
* @returns {Promise} The promise resolved when the search area has been rendered
* @return {Promise|boolean} The promise resolved when the search area has been rendered
*/
Search.prototype._searchPeopleInCourse = function() {
if (this._isLoading) {
return;
return false;
}
var str = this.messageArea.find(this.messageArea.SELECTORS.SEARCHBOX).val();

View File

@ -134,12 +134,12 @@ define(['core/custom_interaction_events'], function(CustomEvents) {
* @private
*/
Tabs.prototype._selectTab = function(tabselect, tabdeselect) {
var tabdeselect = this.messageArea.find(tabdeselect);
tabdeselect = this.messageArea.find(tabdeselect);
tabdeselect.removeClass('selected');
tabdeselect.attr('aria-selected', 'false');
tabdeselect.attr('tabindex', '-1');
var tabselect = this.messageArea.find(tabselect);
tabselect = this.messageArea.find(tabselect);
tabselect.addClass('selected');
tabselect.attr('aria-selected', 'true');
tabselect.attr('tabindex', '0');

View File

@ -22,10 +22,9 @@
* @package message
* @copyright 2016 Ryan Wyllie <ryan@moodle.com>
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
* @since 3.2
*/
define(['jquery', 'core/ajax', 'core/notification', 'core_message/notification_preference'],
function($, ajax, notification, NotificationPreference) {
define(['jquery', 'core_message/notification_preference'],
function($, NotificationPreference) {
var SELECTORS = {
PREFERENCE_KEY: '[data-preference-key]',
@ -34,9 +33,8 @@ define(['jquery', 'core/ajax', 'core/notification', 'core_message/notification_p
/**
* Constructor for the Preference.
*
* @param element jQuery object root element of the preference
* @param int the current user id
* @return object Preference
* @param {object} element jQuery object root element of the preference
* @param {int} userId The current user id
*/
var MessageNotificationPreference = function(element, userId) {
NotificationPreference.call(this, element, userId);
@ -50,13 +48,13 @@ define(['jquery', 'core/ajax', 'core/notification', 'core_message/notification_p
/**
* Set constructor.
*/
MessageNotificationPreference.prototype.constructor = NotificationPreference;
MessageNotificationPreference.prototype.constructor = MessageNotificationPreference;
/**
* Get the unique prefix key that identifies this user preference.
*
* @method getPreferenceKey
* @return string
* @return {string}
*/
MessageNotificationPreference.prototype.getPreferenceKey = function() {
return this.root.find(SELECTORS.PREFERENCE_KEY).attr('data-preference-key');

View File

@ -23,7 +23,6 @@
* @package message
* @copyright 2016 Ryan Wyllie <ryan@moodle.com>
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
* @since 3.2
*/
define(['jquery', 'theme_bootstrapbase/bootstrap', 'core/ajax', 'core/templates', 'core/str',
'core/notification', 'core/custom_interaction_events', 'core/popover_region_controller',
@ -43,15 +42,13 @@ define(['jquery', 'theme_bootstrapbase/bootstrap', 'core/ajax', 'core/templates'
* Constructor for the MessagePopoverController.
* Extends PopoverRegionController.
*
* @param element jQuery object root element of the popover
* @return object MessagePopoverController
* @param {object} element jQuery object root element of the popover
*/
var MessagePopoverController = function(element) {
// Initialise base class.
PopoverController.call(this, element);
this.markAllReadButton = this.root.find(SELECTORS.MARK_ALL_READ_BUTTON);
this.blockNonContactsButton = this.root.find(SELECTORS.BLOCK_NON_CONTACTS_BUTTON);
this.content = this.root.find(SELECTORS.CONTENT);
this.userId = this.root.attr('data-userid');
this.limit = 20;
@ -78,7 +75,7 @@ define(['jquery', 'theme_bootstrapbase/bootstrap', 'core/ajax', 'core/templates'
* Get the element holding the messages.
*
* @method getContent
* @return jQuery element
* @return {object} jQuery element
*/
MessagePopoverController.prototype.getContent = function() {
return this.content;
@ -162,9 +159,9 @@ define(['jquery', 'theme_bootstrapbase/bootstrap', 'core/ajax', 'core/templates'
* Render the message data with the appropriate template and add it to the DOM.
*
* @method renderMessages
* @param messages array message data
* @param container jQuery object the container to append the rendered messages
* @return jQuery promise that is resolved when all messages have been
* @param {array} messages Message data
* @param {object} container jQuery object the container to append the rendered messages
* @return {object} jQuery promise that is resolved when all messages have been
* rendered and added to the DOM
*/
MessagePopoverController.prototype.renderMessages = function(messages, container) {
@ -189,7 +186,7 @@ define(['jquery', 'theme_bootstrapbase/bootstrap', 'core/ajax', 'core/templates'
promise.then(function(html, js) {
allhtml[index] = html;
alljs[index] = js;
}.bind(this));
});
}.bind(this));
}
@ -208,7 +205,7 @@ define(['jquery', 'theme_bootstrapbase/bootstrap', 'core/ajax', 'core/templates'
* loading some and haven't already loaded all of them.
*
* @method loadMoreMessages
* @return jQuery promise that is resolved when messages have been
* @return {object} jQuery promise that is resolved when messages have been
* retrieved and added to the DOM
*/
MessagePopoverController.prototype.loadMoreMessages = function() {
@ -224,7 +221,7 @@ define(['jquery', 'theme_bootstrapbase/bootstrap', 'core/ajax', 'core/templates'
};
var container = this.getContent();
var promise = MessageRepo.query(request).then(function(result) {
return MessageRepo.query(request).then(function(result) {
var messages = result.contacts;
this.loadedAll = !messages.length || messages.length < this.limit;
this.initialLoad = true;
@ -234,10 +231,12 @@ define(['jquery', 'theme_bootstrapbase/bootstrap', 'core/ajax', 'core/templates'
this.incrementOffset();
return this.renderMessages(messages, container);
}
}.bind(this))
.always(function() { this.stopLoading(); }.bind(this));
return promise;
return false;
}.bind(this))
.always(function() {
this.stopLoading();
}.bind(this));
};
/**
@ -245,6 +244,7 @@ define(['jquery', 'theme_bootstrapbase/bootstrap', 'core/ajax', 'core/templates'
* the unread count and unread messages elements appropriately.
*
* @method markAllAsRead
* @return {Promise}
*/
MessagePopoverController.prototype.markAllAsRead = function() {
if (this.markAllReadButton.hasClass('loading')) {
@ -259,7 +259,9 @@ define(['jquery', 'theme_bootstrapbase/bootstrap', 'core/ajax', 'core/templates'
this.hideUnreadCount();
this.getContent().find(SELECTORS.CONTENT_ITEM_CONTAINER).removeClass('unread');
}.bind(this))
.always(function() { this.markAllReadButton.removeClass('loading'); }.bind(this));
.always(function() {
this.markAllReadButton.removeClass('loading');
}.bind(this));
};
/**

View File

@ -21,7 +21,6 @@
* @package message
* @copyright 2016 Ryan Wyllie <ryan@moodle.com>
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
* @since 3.2
*/
define(['jquery', 'core/ajax', 'core/notification',
'core_message/message_notification_preference', 'core/custom_interaction_events'],
@ -37,8 +36,7 @@ define(['jquery', 'core/ajax', 'core/notification',
/**
* Constructor for the MessagePreferences.
*
* @param {jQuery object} element The root element for the message preferences
* @return object MessagePreferences
* @param {object} element The root element for the message preferences
*/
var MessagePreferences = function(element) {
this.root = $(element);
@ -50,7 +48,7 @@ define(['jquery', 'core/ajax', 'core/notification',
* Check if the preferences have been disabled on this page.
*
* @method preferencesDisabled
* @return bool
* @return {bool}
*/
MessagePreferences.prototype.preferencesDisabled = function() {
return this.root.find(SELECTORS.PREFERENCES_CONTAINER).hasClass('disabled');
@ -60,6 +58,7 @@ define(['jquery', 'core/ajax', 'core/notification',
* Update the block messages from non-contacts user preference in the DOM and
* send a request to update on the server.
*
* @return {Promise}
* @method saveBlockNonContactsStatus
*/
MessagePreferences.prototype.saveBlockNonContactsStatus = function() {

View File

@ -21,14 +21,13 @@
* @package message
* @copyright 2016 Ryan Wyllie <ryan@moodle.com>
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
* @since 3.2
*/
define(['jquery', 'core/ajax', 'core/notification'], function($, Ajax, Notification) {
/**
* Retrieve a list of messages from the server.
*
* @param {object} args The request arguments:
* @return {jQuery promise}
* @return {object} jQuery promise
*/
var query = function(args) {
// Normalise the arguments to use limit/offset rather than limitnum/limitfrom.
@ -63,7 +62,7 @@ define(['jquery', 'core/ajax', 'core/notification'], function($, Ajax, Notificat
* for a given user.
*
* @param {object} args The request arguments:
* @return {jQuery promise}
* @return {object} jQuery promise
*/
var countUnreadConversations = function(args) {
var request = {
@ -82,7 +81,7 @@ define(['jquery', 'core/ajax', 'core/notification'], function($, Ajax, Notificat
* Mark all of unread messages for a user as read.
*
* @param {object} args The request arguments:
* @return {jQuery promise}
* @return {object} jQuery promise
*/
var markAllAsRead = function(args) {
var request = {

View File

@ -23,7 +23,6 @@
* @package message
* @copyright 2016 Ryan Wyllie <ryan@moodle.com>
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
* @since 3.2
*/
define(['jquery', 'theme_bootstrapbase/bootstrap', 'core/ajax', 'core/templates', 'core/str',
'core/notification', 'core/custom_interaction_events', 'core/popover_region_controller',
@ -45,8 +44,7 @@ define(['jquery', 'theme_bootstrapbase/bootstrap', 'core/ajax', 'core/templates'
* Constructor for the NotificationPopoverController.
* Extends PopoverRegionController.
*
* @param element jQuery object root element of the popover
* @return object NotificationPopoverController
* @param {object} element jQuery object root element of the popover
*/
var NotificationPopoverController = function(element) {
// Initialise base class.
@ -106,7 +104,7 @@ define(['jquery', 'theme_bootstrapbase/bootstrap', 'core/ajax', 'core/templates'
* depending on which is currently visible.
*
* @method getContent
* @return jQuery object currently visible content contianer
* @return {object} jQuery object currently visible content contianer
*/
NotificationPopoverController.prototype.getContent = function() {
return this.container;
@ -117,7 +115,7 @@ define(['jquery', 'theme_bootstrapbase/bootstrap', 'core/ajax', 'core/templates'
* to sent to the backend to correctly paginate the notifications.
*
* @method getOffset
* @return int current offset
* @return {int} current offset
*/
NotificationPopoverController.prototype.getOffset = function() {
return this.offset;
@ -137,7 +135,7 @@ define(['jquery', 'theme_bootstrapbase/bootstrap', 'core/ajax', 'core/templates'
* state of the popover.
*
* @method hasDoneInitialLoad
* @return bool true if first notification loaded, false otherwise
* @return {bool} true if first notification loaded, false otherwise
*/
NotificationPopoverController.prototype.hasDoneInitialLoad = function() {
return this.initialLoad;
@ -148,7 +146,7 @@ define(['jquery', 'theme_bootstrapbase/bootstrap', 'core/ajax', 'core/templates'
* state.
*
* @method hasLoadedAllContent
* @return bool true if all notifications loaded, false otherwise
* @return {bool} true if all notifications loaded, false otherwise
*/
NotificationPopoverController.prototype.hasLoadedAllContent = function() {
return this.loadedAll;
@ -159,7 +157,7 @@ define(['jquery', 'theme_bootstrapbase/bootstrap', 'core/ajax', 'core/templates'
* of the popover.
*
* @method setLoadedAllContent
* @param bool true if all content is loaded, false otherwise
* @param {bool} val True if all content is loaded, false otherwise
*/
NotificationPopoverController.prototype.setLoadedAllContent = function(val) {
this.loadedAll = val;
@ -210,10 +208,10 @@ define(['jquery', 'theme_bootstrapbase/bootstrap', 'core/ajax', 'core/templates'
* Render the notification data with the appropriate template and add it to the DOM.
*
* @method renderNotifications
* @param notifications array notification data
* @param container jQuery object the container to append the rendered notifications
* @return jQuery promise that is resolved when all notifications have been
* rendered and added to the DOM
* @param {array} notifications Notification data
* @param {object} container jQuery object the container to append the rendered notifications
* @return {object} jQuery promise that is resolved when all notifications have been
* rendered and added to the DOM
*/
NotificationPopoverController.prototype.renderNotifications = function(notifications, container) {
var promises = [];
@ -228,9 +226,9 @@ define(['jquery', 'theme_bootstrapbase/bootstrap', 'core/ajax', 'core/templates'
promise.then(function(html, js) {
allhtml[index] = html;
alljs[index] = js;
}.bind(this))
})
.fail(DebugNotification.exception);
}.bind(this));
});
}
return $.when.apply($.when, promises).then(function() {
@ -253,7 +251,7 @@ define(['jquery', 'theme_bootstrapbase/bootstrap', 'core/ajax', 'core/templates'
* All notifications are marked as read by the server when they are returned.
*
* @method loadMoreNotifications
* @return jQuery promise that is resolved when notifications have been
* @return {object} jQuery promise that is resolved when notifications have been
* retrieved and added to the DOM
*/
NotificationPopoverController.prototype.loadMoreNotifications = function() {
@ -272,7 +270,7 @@ define(['jquery', 'theme_bootstrapbase/bootstrap', 'core/ajax', 'core/templates'
};
var container = this.getContent();
var promise = NotificationRepo.query(request).then(function(result) {
return NotificationRepo.query(request).then(function(result) {
var notifications = result.notifications;
this.unreadCount = result.unreadcount;
this.setLoadedAllContent(!notifications.length || notifications.length < this.limit);
@ -283,16 +281,19 @@ define(['jquery', 'theme_bootstrapbase/bootstrap', 'core/ajax', 'core/templates'
this.incrementOffset();
return this.renderNotifications(notifications, container);
}
}.bind(this))
.always(function() { this.stopLoading(); }.bind(this));
return promise;
return false;
}.bind(this))
.always(function() {
this.stopLoading();
}.bind(this));
};
/**
* Send a request to the server to mark all unread notifications as read and update
* the unread count and unread notification elements appropriately.
*
* @return {Promise}
* @method markAllAsRead
*/
NotificationPopoverController.prototype.markAllAsRead = function() {
@ -303,18 +304,22 @@ define(['jquery', 'theme_bootstrapbase/bootstrap', 'core/ajax', 'core/templates'
this.unreadCount = 0;
this.root.find(SELECTORS.UNREAD_NOTIFICATION).removeClass('unread');
}.bind(this))
.always(function() { this.markAllReadButton.removeClass('loading'); }.bind(this));
.always(function() {
this.markAllReadButton.removeClass('loading');
}.bind(this));
};
/**
* Send a request to the server to mark a single notification as read and update
* the unread count and unread notification elements appropriately.
*
* @param {jQuery} element
* @return {Promise|boolean}
* @method markAllAsRead
*/
NotificationPopoverController.prototype.markNotificationAsRead = function(element) {
if (!element.hasClass('unread')) {
return;
return false;
}
return NotificationRepo.markAsRead(element.attr('data-id'))

View File

@ -22,10 +22,9 @@
* @package message
* @copyright 2016 Ryan Wyllie <ryan@moodle.com>
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
* @since 3.2
*/
define(['jquery', 'core/ajax', 'core/notification', 'core_message/notification_processor'],
function($, ajax, notification, NotificationProcessor) {
function($, Ajax, Notification, NotificationProcessor) {
var SELECTORS = {
PROCESSOR: '[data-processor-name]',
@ -35,9 +34,8 @@ define(['jquery', 'core/ajax', 'core/notification', 'core_message/notification_p
/**
* Constructor for the Preference.
*
* @param element jQuery object root element of the preference
* @param int the current user id
* @return object Preference
* @param {object} element jQuery object root element of the preference
* @param {int} userId The current user id
*/
var NotificationPreference = function(element, userId) {
this.root = $(element);
@ -48,7 +46,7 @@ define(['jquery', 'core/ajax', 'core/notification', 'core_message/notification_p
* Get the unique prefix key that identifies this user preference.
*
* @method getPreferenceKey
* @return string
* @return {string}
*/
NotificationPreference.prototype.getPreferenceKey = function() {
return this.root.attr('data-preference-key');
@ -58,7 +56,7 @@ define(['jquery', 'core/ajax', 'core/notification', 'core_message/notification_p
* Get the unique key for the logged in preference.
*
* @method getLoggedInPreferenceKey
* @return string
* @return {string}
*/
NotificationPreference.prototype.getLoggedInPreferenceKey = function() {
return this.getPreferenceKey() + '_loggedin';
@ -68,7 +66,7 @@ define(['jquery', 'core/ajax', 'core/notification', 'core_message/notification_p
* Get the unique key for the logged off preference.
*
* @method getLoggedOffPreferenceKey
* @return string
* @return {string}
*/
NotificationPreference.prototype.getLoggedOffPreferenceKey = function() {
return this.getPreferenceKey() + '_loggedoff';
@ -78,7 +76,7 @@ define(['jquery', 'core/ajax', 'core/notification', 'core_message/notification_p
* Get the list of Processors available for this preference.
*
* @method getProcessors
* @return array
* @return {array}
*/
NotificationPreference.prototype.getProcessors = function() {
return this.root.find(SELECTORS.PROCESSOR).map(function(index, element) {
@ -110,6 +108,7 @@ define(['jquery', 'core/ajax', 'core/notification', 'core_message/notification_p
* Check if the preference is loading.
*
* @method isLoading
* @return {Boolean}
*/
NotificationPreference.prototype.isLoading = function() {
return this.root.hasClass('loading');
@ -119,7 +118,7 @@ define(['jquery', 'core/ajax', 'core/notification', 'core_message/notification_p
* Persist the current state of the processors for this preference.
*
* @method save
* @return promise
* @return {object} jQuery promise
*/
NotificationPreference.prototype.save = function() {
if (this.isLoading()) {
@ -158,7 +157,7 @@ define(['jquery', 'core/ajax', 'core/notification', 'core_message/notification_p
}
var args = {
userid : this.userId,
userid: this.userId,
preferences: [
{
type: this.getLoggedInPreferenceKey(),
@ -176,9 +175,11 @@ define(['jquery', 'core/ajax', 'core/notification', 'core_message/notification_p
args: args,
};
return ajax.call([request])[0]
.fail(notification.exception)
.always(function() { this.stopLoading(); }.bind(this));
return Ajax.call([request])[0]
.fail(Notification.exception)
.always(function() {
this.stopLoading();
}.bind(this));
};
return NotificationPreference;

View File

@ -21,7 +21,6 @@
* @package message
* @copyright 2016 Ryan Wyllie <ryan@moodle.com>
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
* @since 3.2
*/
define(['jquery'], function($) {
var SELECTORS = {
@ -34,8 +33,7 @@ define(['jquery'], function($) {
/**
* Constructor for the notification processor.
*
* @param element jQuery object root element of the processor
* @return object NotificationProcessor
* @param {object} element jQuery object root element of the processor
*/
var NotificationProcessor = function(element) {
this.root = $(element);
@ -45,7 +43,7 @@ define(['jquery'], function($) {
* Get the processor name.
*
* @method getName
* @return string
* @return {string}
*/
NotificationProcessor.prototype.getName = function() {
return this.root.attr('data-processor-name');
@ -55,7 +53,7 @@ define(['jquery'], function($) {
* Check if the processor is enabled when the user is logged in.
*
* @method isLoggedInEnabled
* @return bool
* @return {bool}
*/
NotificationProcessor.prototype.isLoggedInEnabled = function() {
var none = this.root.find(SELECTORS.STATE_NONE).find('input');
@ -74,7 +72,7 @@ define(['jquery'], function($) {
* Check if the processor is enabled when the user is logged out.
*
* @method isLoggedOffEnabled
* @return bool
* @return {bool}
*/
NotificationProcessor.prototype.isLoggedOffEnabled = function() {
var none = this.root.find(SELECTORS.STATE_NONE).find('input');

View File

@ -21,7 +21,6 @@
* @package message
* @copyright 2016 Ryan Wyllie <ryan@moodle.com>
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
* @since 3.2
*/
define(['jquery', 'core/ajax', 'core/notification', 'core/fragment', 'core/templates', 'core/str', 'tool_lp/dialogue'],
function($, Ajax, Notification, Fragment, Templates, Str, Dialogue) {
@ -34,8 +33,7 @@ define(['jquery', 'core/ajax', 'core/notification', 'core/fragment', 'core/templ
/**
* Constructor for the notification processor settings.
*
* @param element jQuery object root element of the processor
* @return object NotificationProcessorSettings
* @param {object} element jQuery object root element of the processor
*/
var NotificationProcessorSettings = function(element) {
this.root = $(element);
@ -85,12 +83,13 @@ define(['jquery', 'core/ajax', 'core/notification', 'core/fragment', 'core/templ
* status from the interface.
*
* @method updateConfiguredStatus
* @return {Promise|boolean}
*/
NotificationProcessorSettings.prototype.updateConfiguredStatus = function() {
var processorHeader = this.root.closest(SELECTORS.PROCESSOR);
if (!processorHeader.hasClass('unconfigured')) {
return;
return false;
}
var processorName = processorHeader.attr('data-processor-name');

View File

@ -21,7 +21,6 @@
* @package message
* @copyright 2015 Ryan Wyllie <ryan@moodle.com>
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
* @since 3.2
*/
define(['core/ajax', 'core/notification'], function(ajax, notification) {
/**
@ -90,7 +89,7 @@ define(['core/ajax', 'core/notification'], function(ajax, notification) {
};
/**
* Mark all notifications for the given user as read.
* Mark a specific notification as read.
*
* @param {int} id The notification id
* @param {int} timeread The read timestamp (optional)

View File

@ -22,7 +22,6 @@
* @package message
* @copyright 2016 Ryan Wyllie <ryan@moodle.com>
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
* @since 3.2
*/
define(['jquery', 'core/ajax', 'core/notification', 'core/custom_interaction_events', 'core_message/notification_preference',
'core_message/notification_processor_settings'],
@ -40,8 +39,7 @@ define(['jquery', 'core/ajax', 'core/notification', 'core/custom_interaction_eve
/**
* Constructor for the PreferencesController.
*
* @param element jQuery object root element of the preference
* @return object PreferencesController
* @param {object} element jQuery object root element of the preference
*/
var PreferencesController = function(element) {
this.root = $(element);
@ -54,7 +52,7 @@ define(['jquery', 'core/ajax', 'core/notification', 'core/custom_interaction_eve
* Check if the preferences are all disabled.
*
* @method isDisabled
* @return bool
* @return {bool}
*/
PreferencesController.prototype.isDisabled = function() {
return this.root.hasClass('disabled');
@ -85,6 +83,7 @@ define(['jquery', 'core/ajax', 'core/notification', 'core/custom_interaction_eve
* send a request to update on the server.
*
* @method toggleDisableAllStatus
* @return {Promise}
*/
PreferencesController.prototype.toggleDisableAllStatus = function() {
var checkbox = $(SELECTORS.DISABLE_NOTIFICATIONS);
@ -119,6 +118,11 @@ define(['jquery', 'core/ajax', 'core/notification', 'core/custom_interaction_eve
.fail(Notification.exception);
};
/**
* Set up all of the event listeners for the PreferencesController.
*
* @method registerEventListeners
*/
PreferencesController.prototype.registerEventListeners = function() {
var disabledNotificationsElement = $(SELECTORS.DISABLE_NOTIFICATIONS);

View File

@ -21,15 +21,13 @@
* @package message
* @copyright 2016 Ryan Wyllie <ryan@moodle.com>
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
* @since 3.2
*/
define(['jquery', 'core/ajax', 'core/notification', 'core/custom_interaction_events'],
function($, ajax, notification, CustomEvents) {
function($, Ajax, Notification, CustomEvents) {
/**
* Constructor for the ProcessorForm.
*
* @param element jQuery object root element of the preference
* @return object ProcessorForm
* @param {object} element jQuery object root element of the preference
*/
var ProcessorForm = function(element) {
this.root = $(element);
@ -75,7 +73,7 @@ define(['jquery', 'core/ajax', 'core/notification', 'core/custom_interaction_eve
* Check if this processor is loading.
*
* @method isLoading
* @return bool
* @return {bool}
*/
ProcessorForm.prototype.isLoading = function() {
return this.root.hasClass('loading');
@ -85,7 +83,7 @@ define(['jquery', 'core/ajax', 'core/notification', 'core/custom_interaction_eve
* Persist the processor configuration.
*
* @method save
* @return promise
* @return {object} jQuery promise
*/
ProcessorForm.prototype.save = function() {
if (this.isLoading()) {
@ -104,9 +102,11 @@ define(['jquery', 'core/ajax', 'core/notification', 'core/custom_interaction_eve
}
};
return ajax.call([request])[0]
.fail(notification.exception)
.always(function() { this.stopLoading(); }.bind(this));
return Ajax.call([request])[0]
.fail(Notification.exception)
.always(function() {
this.stopLoading();
}.bind(this));
};
return ProcessorForm;

View File

@ -21,17 +21,16 @@
* @package message
* @copyright 2016 Ryan Wyllie <ryan@moodle.com>
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
* @since 3.2
*/
define(['jquery', 'core/ajax', 'core/templates', 'core/notification', 'core/custom_interaction_events'],
function($, ajax, templates, notification, customEvents) {
function($, Ajax, Templates, Notification, CustomEvents) {
/**
* Check the state of the element, if the current user is a contact or not.
*
* @method isContact
* @param element jQuery object for the button
* @return bool
* @param {object} element jQuery object for the button
* @return {bool}
*/
var isContact = function(element) {
return element.attr('data-is-contact') == '1';
@ -41,7 +40,7 @@ define(['jquery', 'core/ajax', 'core/templates', 'core/notification', 'core/cust
* Record that the user is a contact.
*
* @method setContact
* @param element jQuery object for the button
* @param {object} element jQuery object for the button
*/
var setContact = function(element) {
element.attr('data-is-contact', '1');
@ -51,7 +50,7 @@ define(['jquery', 'core/ajax', 'core/templates', 'core/notification', 'core/cust
* Record that the user is not a contact.
*
* @method setNotContact
* @param element jQuery object for the button
* @param {object} element jQuery object for the button
*/
var setNotContact = function(element) {
element.attr('data-is-contact', '0');
@ -61,8 +60,8 @@ define(['jquery', 'core/ajax', 'core/templates', 'core/notification', 'core/cust
* Get the id for the user being viewed.
*
* @method getUserId
* @param element jQuery object for the button
* @return int
* @param {object} element jQuery object for the button
* @return {int}
*/
var getUserId = function(element) {
return element.attr('data-userid');
@ -72,8 +71,8 @@ define(['jquery', 'core/ajax', 'core/templates', 'core/notification', 'core/cust
* Check if this element is currently loading.
*
* @method isLoading
* @param element jQuery object for the button
* @return bool
* @param {object} element jQuery object for the button
* @return {bool}
*/
var isLoading = function(element) {
return element.hasClass('loading') || element.attr('disabled');
@ -84,9 +83,9 @@ define(['jquery', 'core/ajax', 'core/templates', 'core/notification', 'core/cust
* while the request is being performed.
*
* @method sendRequest
* @param element jQuery object for the button
* @param request request hash to send
* @return jQuery promise
* @param {object} element jQuery object for the button
* @param {object} request Request hash to send
* @return {object} jQuery promise
*/
var sendRequest = function(element, request) {
if (isLoading(element)) {
@ -96,8 +95,8 @@ define(['jquery', 'core/ajax', 'core/templates', 'core/notification', 'core/cust
element.addClass('loading');
element.attr('disabled', 'disabled');
return ajax.call([request])[0]
.fail(notification.exception)
return Ajax.call([request])[0]
.fail(Notification.exception)
.always(function() {
element.removeClass('loading');
element.removeAttr('disabled');
@ -110,7 +109,7 @@ define(['jquery', 'core/ajax', 'core/templates', 'core/notification', 'core/cust
* remove contact button upon success.
*
* @method addContact
* @param element jQuery object for the button
* @param {object} element jQuery object for the button
*/
var addContact = function(element) {
if (isLoading(element)) {
@ -125,8 +124,8 @@ define(['jquery', 'core/ajax', 'core/templates', 'core/notification', 'core/cust
};
sendRequest(element, request).done(function() {
setContact(element);
templates.render('message/remove_contact_button', {}).done(function(html, js) {
templates.replaceNodeContents(element, html, js);
Templates.render('message/remove_contact_button', {}).done(function(html, js) {
Templates.replaceNodeContents(element, html, js);
});
});
};
@ -137,7 +136,7 @@ define(['jquery', 'core/ajax', 'core/templates', 'core/notification', 'core/cust
* add contact button upon success.
*
* @method removeContact
* @param element jQuery object for the button
* @param {object} element jQuery object for the button
*/
var removeContact = function(element) {
if (isLoading(element)) {
@ -153,8 +152,8 @@ define(['jquery', 'core/ajax', 'core/templates', 'core/notification', 'core/cust
sendRequest(element, request).done(function() {
setNotContact(element);
templates.render('message/add_contact_button', {}).done(function(html, js) {
templates.replaceNodeContents(element, html, js);
Templates.render('message/add_contact_button', {}).done(function(html, js) {
Templates.replaceNodeContents(element, html, js);
});
});
};
@ -164,21 +163,21 @@ define(['jquery', 'core/ajax', 'core/templates', 'core/notification', 'core/cust
* ajax requests to add or remove a contact where appropriate.
*
* @method enhance
* @param element jQuery object for the button
* @param {object} element jQuery object for the button
*/
var enhance = function(element) {
element = $(element);
if (!element.children('.loading-icon').length) {
// Add the loading gif if it isn't already there.
templates.render('core/loading', {}).done(function(html, js) {
Templates.render('core/loading', {}).done(function(html, js) {
element.append(html, js);
});
}
customEvents.define(element, [customEvents.events.activate]);
CustomEvents.define(element, [CustomEvents.events.activate]);
element.on(customEvents.events.activate, function(e, data) {
element.on(CustomEvents.events.activate, function(e, data) {
if (isContact(element)) {
removeContact(element);
} else {

View File

@ -24,10 +24,10 @@
namespace core_message;
require_once($CFG->dirroot . '/lib/messagelib.php');
defined('MOODLE_INTERNAL') || die();
require_once($CFG->dirroot . '/lib/messagelib.php');
/**
* Class used to return information to display for the message area.
*
@ -64,7 +64,7 @@ class api {
JOIN {user} u2
ON m.useridto = u2.id
LEFT JOIN {message_contacts} mc2
ON (mc2.contactid = u2.id AND mc2.userid = ?)
ON (mc2.contactid = u2.id AND mc2.userid = ?)
WHERE ((useridto = ? AND timeusertodeleted = 0)
OR (useridfrom = ? AND timeuserfromdeleted = 0))
AND notification = 0
@ -79,7 +79,7 @@ class api {
JOIN {user} u
ON mr.useridfrom = u.id
LEFT JOIN {message_contacts} mc
ON (mc.contactid = u.id AND mc.userid = ?)
ON (mc.contactid = u.id AND mc.userid = ?)
JOIN {user} u2
ON mr.useridto = u2.id
LEFT JOIN {message_contacts} mc2
@ -144,7 +144,6 @@ class api {
ORDER BY " . $DB->sql_fullname();
$params = array_merge(array('userid' => $userid, 'userid2' => $userid, 'search' => '%' . $search . '%'), $params);
// Convert all the user records into contacts.
$contacts = array();
if ($users = $DB->get_records_sql($sql, $params, $limitfrom, $limitnum)) {
@ -189,8 +188,8 @@ class api {
AND " . $DB->sql_like($fullname, ':search', false) . "
AND u.id $exclude
ORDER BY " . $DB->sql_fullname();
if ($users = $DB->get_records_sql($sql, array('userid' => $userid, 'search' => '%' . $search . '%') +
$excludeparams, 0, $limitnum)) {
if ($users = $DB->get_records_sql($sql, array('userid' => $userid, 'search' => '%' . $search . '%') + $excludeparams,
0, $limitnum)) {
foreach ($users as $user) {
$contacts[] = \core_message\helper::create_contact($user);
}
@ -218,12 +217,12 @@ class api {
AND u.confirmed = 1
AND " . $DB->sql_like($fullname, ':search', false) . "
AND u.id $exclude
AND u.id NOT IN (SELECT contactid
FROM {message_contacts}
AND u.id NOT IN (SELECT contactid
FROM {message_contacts}
WHERE userid = :userid)
ORDER BY " . $DB->sql_fullname();
if ($users = $DB->get_records_sql($sql, array('userid' => $userid, 'search' => '%' . $search . '%') +
$excludeparams, 0, $limitnum)) {
if ($users = $DB->get_records_sql($sql, array('userid' => $userid, 'search' => '%' . $search . '%') + $excludeparams,
0, $limitnum)) {
foreach ($users as $user) {
$noncontacts[] = \core_message\helper::create_contact($user);
}
@ -342,8 +341,11 @@ class api {
$data->country = isset($userfields['country']) ? $userfields['country'] : '';
$data->email = isset($userfields['email']) ? $userfields['email'] : '';
$data->profileimageurl = isset($userfields['profileimageurl']) ? $userfields['profileimageurl'] : '';
$data->profileimageurlsmall = isset($userfields['profileimageurlsmall']) ?
$userfields['profileimageurlsmall'] : '';
if (isset($userfields['profileimageurlsmall'])) {
$data->profileimageurlsmall = $userfields['profileimageurlsmall'];
} else {
$data->profileimageurlsmall = '';
}
if (isset($userfields['lastaccess'])) {
$data->isonline = \core_message\helper::is_online($userfields['lastaccess']);
} else {

View File

@ -45,7 +45,8 @@ class helper {
* @param string $sort
* @return array of messages
*/
public static function get_messages($userid, $otheruserid, $timedeleted = 0, $limitfrom = 0, $limitnum = 0, $sort = 'timecreated ASC') {
public static function get_messages($userid, $otheruserid, $timedeleted = 0, $limitfrom = 0, $limitnum = 0,
$sort = 'timecreated ASC') {
global $DB;
$sql = "SELECT id, useridfrom, useridto, subject, fullmessage, fullmessagehtml, fullmessageformat,
@ -153,7 +154,7 @@ class helper {
}
}
// Check if the user is online.
$data->isonline = \core_message\helper::is_online($userfields->lastaccess);
$data->isonline = self::is_online($userfields->lastaccess);
$data->isblocked = isset($contact->blocked) ? $contact->blocked : 0;
$data->isread = isset($contact->isread) ? $contact->isread : 0;
$data->unreadcount = isset($contact->unreadcount) ? $contact->unreadcount : null;

View File

@ -24,6 +24,8 @@
namespace core_message\output\messagearea;
defined('MOODLE_INTERNAL') || die();
use renderable;
use templatable;

View File

@ -24,6 +24,8 @@
namespace core_message\output\messagearea;
defined('MOODLE_INTERNAL') || die();
use renderable;
use templatable;

View File

@ -24,6 +24,8 @@
namespace core_message\output\messagearea;
defined('MOODLE_INTERNAL') || die();
use renderable;
use templatable;

View File

@ -24,6 +24,8 @@
namespace core_message\output\messagearea;
defined('MOODLE_INTERNAL') || die();
use renderable;
use templatable;

View File

@ -24,6 +24,8 @@
namespace core_message\output\messagearea;
defined('MOODLE_INTERNAL') || die();
use renderable;
use templatable;

View File

@ -24,6 +24,8 @@
namespace core_message\output\messagearea;
defined('MOODLE_INTERNAL') || die();
use renderable;
use templatable;

View File

@ -24,6 +24,8 @@
namespace core_message\output\messagearea;
defined('MOODLE_INTERNAL') || die();
use renderable;
use templatable;

View File

@ -24,6 +24,8 @@
namespace core_message\output\messagearea;
defined('MOODLE_INTERNAL') || die();
use renderable;
use templatable;

View File

@ -24,6 +24,8 @@
namespace core_message\output;
defined('MOODLE_INTERNAL') || die();
require_once($CFG->dirroot . '/message/lib.php');
use renderable;
@ -41,25 +43,22 @@ use core_user;
class popup_notification implements templatable, renderable {
/**
* The notification.
* @var \stdClass The notification.
*/
protected $notification;
/**
* Indicates if the receiver of the notification should have their
* details embedded in the output.
* @var \stdClass Indicates if the receiver of the notification should have their details embedded in the output.
*/
protected $embeduserto;
/**
* Indicates if the sender of the notification should have their
* details embedded in the output.
* @var \stdClass Indicates if the sender of the notification should have their details embedded in the output.
*/
protected $embeduserfrom;
/**
* A cache for the receiver's full name, if it's already known, so that
* a DB lookup isn't required.
* @var string A cache for the receiver's full name, if it's already known, so that a DB lookup isn't required.
*/
protected $usertofullname;
@ -67,10 +66,11 @@ class popup_notification implements templatable, renderable {
* Constructor.
*
* @param \stdClass $notification
* @param \stdClass $embeduserto
* @param \stdClass $embeduserfrom
* @param string $usertofullname
*/
public function __construct($notification, $embeduserto,
$embeduserfrom, $usertofullname = '') {
public function __construct($notification, $embeduserto, $embeduserfrom, $usertofullname = '') {
$this->notification = $notification;
$this->embeduserto = $embeduserto;
$this->embeduserfrom = $embeduserfrom;

View File

@ -15,8 +15,7 @@
// along with Moodle. If not, see <http://www.gnu.org/licenses/>.
/**
* Contains message_notification_list class for displaying on message preferences
* page.
* Contains message_notification_list class for displaying on message preferences page.
*
* @package core_message
* @copyright 2016 Ryan Wyllie <ryan@moodle.com>
@ -25,26 +24,28 @@
namespace core_message\output\preferences;
defined('MOODLE_INTERNAL') || die();
/**
* Class to create context for the list of notifications on the message
* preferences page.
* Class to create context for the list of notifications on the message preferences page.
*
* @package core_message
* @copyright 2016 Ryan Wyllie <ryan@moodle.com>
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
class message_notification_list extends notification_list {
/**
* Create the list component output object.
*
* @param string $component
* @param array $readyprocessors
* @param array $providers
* @param stdClass $preferences
* @param stdClass $user
* @param \stdClass $preferences
* @param \stdClass $user
* @return message_notification_list_component
*/
protected function create_list_component($component, $readyprocessors, $providers, $preferences, $user) {
return new \core_message\output\preferences\message_notification_list_component(
$component, $readyprocessors, $providers, $preferences, $user);
return new message_notification_list_component($component, $readyprocessors, $providers, $preferences, $user);
}
}

View File

@ -15,8 +15,7 @@
// along with Moodle. If not, see <http://www.gnu.org/licenses/>.
/**
* Contains notification_list_component class for displaying on message preferences
* page.
* Contains notification_list_component class for displaying on message preferences page.
*
* @package core_message
* @copyright 2016 Ryan Wyllie <ryan@moodle.com>
@ -25,20 +24,22 @@
namespace core_message\output\preferences;
defined('MOODLE_INTERNAL') || die();
require_once($CFG->dirroot . '/message/lib.php');
use renderable;
use templatable;
/**
* Class to create context for a notification component on the message
* preferences page.
* Class to create context for a notification component on the message preferences page.
*
* @package core_message
* @copyright 2016 Ryan Wyllie <ryan@moodle.com>
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
class message_notification_list_component extends notification_list_component {
/**
* Determine if the preference should be displayed.
*

View File

@ -15,8 +15,7 @@
// along with Moodle. If not, see <http://www.gnu.org/licenses/>.
/**
* Contains notification_list class for displaying on message preferences
* page.
* Contains notification_list class for displaying on message preferences page.
*
* @package core_message
* @copyright 2016 Ryan Wyllie <ryan@moodle.com>
@ -25,13 +24,14 @@
namespace core_message\output\preferences;
defined('MOODLE_INTERNAL') || die();
use renderable;
use templatable;
use context_user;
/**
* Class to create context for the list of notifications on the message
* preferences page.
* Class to create context for the list of notifications on the message preferences page.
*
* @package core_message
* @copyright 2016 Ryan Wyllie <ryan@moodle.com>
@ -40,22 +40,22 @@ use context_user;
class notification_list implements templatable, renderable {
/**
* A list of message processors.
* @var array A list of message processors.
*/
protected $processors;
/**
* A list of message providers.
* @var array A list of message providers.
*/
protected $providers;
/**
* A list of message preferences.
* @var array A list of message preferences.
*/
protected $preferences;
/**
* A user.
* @var \stdClass A user.
*/
protected $user;
@ -64,8 +64,8 @@ class notification_list implements templatable, renderable {
*
* @param array $processors
* @param array $providers
* @param stdClass $preferences
* @param stdClass $user
* @param \stdClass $preferences
* @param \stdClass $user
*/
public function __construct($processors, $providers, $preferences, $user) {
$this->processors = $processors;
@ -80,12 +80,12 @@ class notification_list implements templatable, renderable {
* @param string $component
* @param array $readyprocessors
* @param array $providers
* @param stdClass $preferences
* @param stdClass $user
* @param \stdClass $preferences
* @param \stdClass $user
* @return notification_list_component
*/
protected function create_list_component($component, $readyprocessors, $providers, $preferences, $user) {
return new \core_message\output\preferences\notification_list_component(
$component, $readyprocessors, $providers, $preferences, $user);
return new notification_list_component($component, $readyprocessors, $providers, $preferences, $user);
}
public function export_for_template(\renderer_base $output) {
@ -102,7 +102,7 @@ class notification_list implements templatable, renderable {
foreach ($providers as $provider) {
if ($provider->component != 'moodle') {
if (substr($provider->component, 0, 4) == 'mod_') {
// Activities
// Activities.
$activitycomponents[] = $provider->component;
} else {
// Other stuff.
@ -111,7 +111,6 @@ class notification_list implements templatable, renderable {
}
}
$activitycomponents = array_unique($activitycomponents);
asort($activitycomponents);
$othercomponents = array_unique($othercomponents);

View File

@ -15,8 +15,7 @@
// along with Moodle. If not, see <http://www.gnu.org/licenses/>.
/**
* Contains notification_list_component class for displaying on message preferences
* page.
* Contains notification_list_component class for displaying on message preferences page.
*
* @package core_message
* @copyright 2016 Ryan Wyllie <ryan@moodle.com>
@ -25,14 +24,15 @@
namespace core_message\output\preferences;
defined('MOODLE_INTERNAL') || die();
require_once($CFG->dirroot . '/message/lib.php');
use renderable;
use templatable;
/**
* Class to create context for a notification component on the message
* preferences page.
* Class to create context for a notification component on the message preferences page.
*
* @package core_message
* @copyright 2016 Ryan Wyllie <ryan@moodle.com>
@ -41,27 +41,27 @@ use templatable;
class notification_list_component implements templatable, renderable {
/**
* A list of message processors.
* @var array A list of message processors.
*/
protected $processors;
/**
* A list of message providers.
* @var array A list of message providers.
*/
protected $providers;
/**
* A list of message preferences.
* @var array A list of message preferences.
*/
protected $preferences;
/**
* The component name.
* @var string The component name.
*/
protected $component;
/**
* A user.
* @var \stdClass A user.
*/
protected $user;
@ -71,7 +71,8 @@ class notification_list_component implements templatable, renderable {
* @param string $component
* @param array $processors
* @param array $providers
* @param stdClass $preferences
* @param \stdClass $preferences
* @param \stdClass $user
*/
public function __construct($component, $processors, $providers, $preferences, $user) {
$this->processors = $processors;
@ -84,7 +85,7 @@ class notification_list_component implements templatable, renderable {
/**
* Get the base key prefix for the given provider.
*
* @param stdClass message provider
* @param \stdClass $provider The message provider
* @return string
*/
private function get_preference_base($provider) {
@ -94,7 +95,7 @@ class notification_list_component implements templatable, renderable {
/**
* Get the display name for the given provider.
*
* @param stdClass $provider message provider
* @param \stdClass $provider The message provider
* @return string
*/
private function get_provider_display_name($provider) {
@ -152,7 +153,7 @@ class notification_list_component implements templatable, renderable {
];
foreach ($processors as $processor) {
$notificationprocessor = new \core_message\output\preferences\notification_list_processor($processor, $provider, $preferences);
$notificationprocessor = new notification_list_processor($processor, $provider, $preferences);
$notificationcontext['processors'][] = $notificationprocessor->export_for_template($output);
}

View File

@ -15,8 +15,7 @@
// along with Moodle. If not, see <http://www.gnu.org/licenses/>.
/**
* Contains notification_list_processor class for displaying on message preferences
* page.
* Contains notification_list_processor class for displaying on message preferences page.
*
* @package core_message
* @copyright 2016 Ryan Wyllie <ryan@moodle.com>
@ -25,14 +24,15 @@
namespace core_message\output\preferences;
defined('MOODLE_INTERNAL') || die();
require_once($CFG->dirroot . '/message/lib.php');
use renderable;
use templatable;
/**
* Class to create context for a notification component on the message
* preferences page.
* Class to create context for a notification component on the message preferences page.
*
* @package core_message
* @copyright 2016 Ryan Wyllie <ryan@moodle.com>
@ -41,26 +41,26 @@ use templatable;
class notification_list_processor implements templatable, renderable {
/**
* A notification processor.
* @var \stdClass A notification processor.
*/
protected $processor;
/**
* A notification provider.
* @var \stdClass A notification provider.
*/
protected $provider;
/**
* A list of message preferences.
* @var \stdClass A list of message preferences.
*/
protected $preferences;
/**
* Constructor.
*
* @param stdClass $processor
* @param stdClass $provider
* @param stdClass $preferences
* @param \stdClass $processor
* @param \stdClass $provider
* @param \stdClass $preferences
*/
public function __construct($processor, $provider, $preferences) {
$this->processor = $processor;
@ -81,8 +81,6 @@ class notification_list_processor implements templatable, renderable {
* Check if the given preference is enabled or not.
*
* @param string $name preference name
* @param stdClass $processor the processors for the preference
* @param stdClass $preferences the preferences config
* @return bool
*/
private function is_preference_enabled($name) {
@ -91,12 +89,12 @@ class notification_list_processor implements templatable, renderable {
$defaultpreferences = get_message_output_default_preferences();
$checked = false;
// See if user has touched this preference
// See if user has touched this preference.
if (isset($preferences->{$name})) {
// User have some preferneces for this state in the database, use them
// User has some preferences for this state in the database.
$checked = isset($preferences->{$name}[$processor->name]);
} else {
// User has not set this preference yet, using site default preferences set by admin
// User has not set this preference yet, using site default preferences set by admin.
$defaultpreference = 'message_provider_'.$name;
if (isset($defaultpreferences->{$defaultpreference})) {
$checked = (int)in_array($processor->name, explode(',', $defaultpreferences->{$defaultpreference}));
@ -108,9 +106,7 @@ class notification_list_processor implements templatable, renderable {
public function export_for_template(\renderer_base $output) {
$processor = $this->processor;
$provider = $this->provider;
$preferences = $this->preferences;
$preferencebase = $this->get_preference_base($provider);
$preferencebase = $this->get_preference_base();
$permitted = MESSAGE_DEFAULT_PERMITTED;
$defaultpreferences = get_message_output_default_preferences();
$defaultpreference = $processor->name.'_provider_'.$preferencebase.'_permitted';
@ -122,21 +118,20 @@ class notification_list_processor implements templatable, renderable {
'loggedin' => [
'name' => 'loggedin',
'displayname' => get_string('loggedindescription', 'message'),
'checked' => $this->is_preference_enabled($preferencebase.'_loggedin', $processor, $preferences),
'checked' => $this->is_preference_enabled($preferencebase.'_loggedin'),
],
'loggedoff' => [
'name' => 'loggedoff',
'displayname' => get_string('loggedoffdescription', 'message'),
'checked' => $this->is_preference_enabled($preferencebase.'_loggedoff', $processor, $preferences),
'checked' => $this->is_preference_enabled($preferencebase.'_loggedoff'),
],
];
// determine the default setting
// Determine the default setting.
if (isset($defaultpreferences->{$defaultpreference})) {
$permitted = $defaultpreferences->{$defaultpreference};
}
// If settings are disallowed or forced, just display the
// corresponding message, if not use user settings.
// If settings are disallowed or forced, just display the corresponding message, if not use user settings.
if ($permitted == 'disallowed') {
$context['locked'] = true;
$context['lockedmessage'] = get_string('disallowed', 'message');

View File

@ -15,8 +15,7 @@
// along with Moodle. If not, see <http://www.gnu.org/licenses/>.
/**
* Contains processor class for displaying on message preferences
* page.
* Contains processor class for displaying on message preferences page.
*
* @package core_message
* @copyright 2016 Ryan Wyllie <ryan@moodle.com>
@ -25,12 +24,13 @@
namespace core_message\output\preferences;
defined('MOODLE_INTERNAL') || die();
use renderable;
use templatable;
/**
* Class to create context for one of the message processors settings
* on the message preferences page.
* Class to create context for one of the message processors settings on the message preferences page.
*
* @package core_message
* @copyright 2016 Ryan Wyllie <ryan@moodle.com>
@ -39,31 +39,32 @@ use templatable;
class processor implements templatable, renderable {
/**
* The message processor.
* @var \stdClass The message processor.
*/
protected $processor;
/**
* A list of message preferences.
* @var \stdClass list of message preferences.
*/
protected $preferences;
/**
* A user.
* @var \stdClass A user.
*/
protected $user;
/**
* The processor type.
* @var string The processor type.
*/
protected $type;
/**
* Constructor.
*
* @param stdClass $processor
* @param stdClass $preferences
* @param stdClass $user
* @param \stdClass $processor
* @param \stdClass $preferences
* @param \stdClass $user
* @param string $type
*/
public function __construct($processor, $preferences, $user, $type) {
$this->processor = $processor;

View File

@ -24,6 +24,8 @@
namespace core_message\output;
defined('MOODLE_INTERNAL') || die();
require_once($CFG->dirroot . '/message/lib.php');
use renderable;
@ -39,12 +41,12 @@ use templatable;
class processor implements templatable, renderable {
/**
* The message processor
* @var \stdClass The message processor
*/
protected $processor;
/**
* The user
* @var \stdClass The user
*/
protected $user;

View File

@ -498,7 +498,8 @@ class core_message_external extends external_api {
* @throws moodle_exception
* @since 3.2
*/
public static function data_for_messagearea_search_people_in_course($userid, $courseid, $search, $limitfrom = 0, $limitnum = 0) {
public static function data_for_messagearea_search_people_in_course($userid, $courseid, $search, $limitfrom = 0,
$limitnum = 0) {
global $CFG, $PAGE, $USER;
// Check if messaging is enabled.
@ -865,7 +866,8 @@ class core_message_external extends external_api {
* @throws moodle_exception
* @since 3.2
*/
public static function data_for_messagearea_messages($currentuserid, $otheruserid, $limitfrom = 0, $limitnum = 0, $newest = false) {
public static function data_for_messagearea_messages($currentuserid, $otheruserid, $limitfrom = 0, $limitnum = 0,
$newest = false) {
global $CFG, $PAGE, $USER;
// Check if messaging is enabled.
@ -909,7 +911,8 @@ class core_message_external extends external_api {
public static function data_for_messagearea_messages_returns() {
return new external_single_structure(
array(
'iscurrentuser' => new external_value(PARAM_BOOL, 'Is the currently logged in user the user we are viewing the messages on behalf of?'),
'iscurrentuser' => new external_value(PARAM_BOOL, 'Is the currently logged in user the user we are viewing
the messages on behalf of?'),
'currentuserid' => new external_value(PARAM_INT, 'The current user\'s id'),
'otheruserid' => new external_value(PARAM_INT, 'The other user\'s id'),
'otheruserfullname' => new external_value(PARAM_NOTAGS, 'The other user\'s fullname'),
@ -1042,7 +1045,8 @@ class core_message_external extends external_api {
public static function data_for_messagearea_get_profile_returns() {
return new external_single_structure(
array(
'iscurrentuser' => new external_value(PARAM_BOOL, 'Is the currently logged in user the user we are viewing the profile on behalf of?'),
'iscurrentuser' => new external_value(PARAM_BOOL, 'Is the currently logged in user the user we are viewing
the profile on behalf of?'),
'currentuserid' => new external_value(PARAM_INT, 'The current user\'s id'),
'otheruserid' => new external_value(PARAM_INT, 'The id of the user whose profile we are viewing'),
'email' => new external_value(core_user::get_property_type('email'), 'An email address'),
@ -1071,7 +1075,6 @@ class core_message_external extends external_api {
/**
* Get contacts.
*
* @param array $userids array of user IDs.
* @return external_description
* @since Moodle 2.5
*/
@ -1581,7 +1584,8 @@ class core_message_external extends external_api {
}
$sort = $newestfirst ? 'DESC' : 'ASC';
$notifications = \core_message\api::get_popup_notifications($useridto, $status, $embeduserto, $embeduserfrom, $sort, $limit, $offset);
$notifications = \core_message\api::get_popup_notifications($useridto, $status, $embeduserto,
$embeduserfrom, $sort, $limit, $offset);
$notificationcontexts = [];
if ($notifications) {
@ -1625,11 +1629,13 @@ class core_message_external extends external_api {
'notifications' => new external_multiple_structure(
new external_single_structure(
array(
'id' => new external_value(PARAM_INT, 'Notification id (this is not guaranteed to be unique within this result set)'),
'id' => new external_value(PARAM_INT, 'Notification id (this is not guaranteed to be unique
within this result set)'),
'useridfrom' => new external_value(PARAM_INT, 'User from id'),
'useridto' => new external_value(PARAM_INT, 'User to id'),
'subject' => new external_value(PARAM_TEXT, 'The notification subject'),
'shortenedsubject' => new external_value(PARAM_TEXT, 'The notification subject shortened with ellipsis'),
'shortenedsubject' => new external_value(PARAM_TEXT, 'The notification subject shortened
with ellipsis'),
'text' => new external_value(PARAM_RAW, 'The message text formated'),
'fullmessage' => new external_value(PARAM_RAW, 'The message'),
'fullmessageformat' => new external_format_value('fullmessage'),
@ -1646,7 +1652,8 @@ class core_message_external extends external_api {
'read' => new external_value(PARAM_BOOL, 'notification read status'),
'deleted' => new external_value(PARAM_BOOL, 'notification deletion status'),
'iconurl' => new external_value(PARAM_URL, 'URL for notification icon'),
'component' => new external_value(PARAM_TEXT, 'The component that generated the notification', VALUE_OPTIONAL),
'component' => new external_value(PARAM_TEXT, 'The component that generated the notification',
VALUE_OPTIONAL),
'eventtype' => new external_value(PARAM_TEXT, 'The type of notification', VALUE_OPTIONAL),
), 'message'
)
@ -1715,7 +1722,7 @@ class core_message_external extends external_api {
// Check if the current user is the sender/receiver or just a privileged user.
if ($useridto != $USER->id and $useridfrom != $USER->id and
// deleteanymessage seems more reasonable here than readallmessages.
// The deleteanymessage cap seems more reasonable here than readallmessages.
!has_capability('moodle/site:deleteanymessage', $context)) {
throw new moodle_exception('accessdenied', 'admin');
}
@ -1972,7 +1979,8 @@ class core_message_external extends external_api {
return new external_function_parameters(
array(
'messageid' => new external_value(PARAM_INT, 'id of the message (in the message table)'),
'timeread' => new external_value(PARAM_INT, 'timestamp for when the message should be marked read', VALUE_DEFAULT, 0)
'timeread' => new external_value(PARAM_INT, 'timestamp for when the message should be marked read',
VALUE_DEFAULT, 0)
)
);
}
@ -2104,7 +2112,7 @@ class core_message_external extends external_api {
// Check if the current user is the sender/receiver or just a privileged user.
if ($useridto != $USER->id and $useridfrom != $USER->id and
// deleteanymessage seems more reasonable here than readallmessages.
// The deleteanymessage cap seems more reasonable here than readallmessages.
!has_capability('moodle/site:deleteanymessage', $context)) {
throw new moodle_exception('accessdenied', 'admin');
}
@ -2383,7 +2391,8 @@ class core_message_external extends external_api {
/**
* Get a message processor.
*
* @param string $name the name of the processor
* @param int $userid
* @param string $name the name of the processor
* @return external_description
* @throws moodle_exception
* @since 3.2

View File

@ -47,10 +47,10 @@ define('MESSAGE_SEARCH_MAX_RESULTS', 200);
define('MESSAGE_CONTACTS_PER_PAGE',10);
define('MESSAGE_MAX_COURSE_NAME_LENGTH', 30);
define('MESSAGE_UNREAD','unread');
define('MESSAGE_READ','read');
define('MESSAGE_TYPE_NOTIFICATION','notification');
define('MESSAGE_TYPE_MESSAGE','message');
define('MESSAGE_UNREAD', 'unread');
define('MESSAGE_READ', 'read');
define('MESSAGE_TYPE_NOTIFICATION', 'notification');
define('MESSAGE_TYPE_MESSAGE', 'message');
/**

View File

@ -53,18 +53,18 @@ $personalcontext = context_user::instance($user->id);
$PAGE->set_context($personalcontext);
$PAGE->set_pagelayout('admin');
// check access control
// Check access control.
if ($user->id == $USER->id) {
//editing own message profile
// Editing own message profile.
require_capability('moodle/user:editownmessageprofile', $systemcontext);
} else {
// teachers, parents, etc.
// Teachers, parents, etc.
require_capability('moodle/user:editmessageprofile', $personalcontext);
// no editing of guest user account
// No editing of guest user account.
if (isguestuser($user->id)) {
print_error('guestnoeditmessageother', 'message');
}
// no editing of admins by non admins!
// No editing of admins by non admins!
if (is_siteadmin($user) and !is_siteadmin($USER)) {
print_error('useradmineditadmin');
}
@ -72,12 +72,12 @@ if ($user->id == $USER->id) {
$PAGE->navigation->extend_for_user($user);
}
/// Display page header
// Display page header.
$strmessaging = get_string('notificationpreferences', 'message');
$PAGE->set_title($strmessaging);
$PAGE->set_heading(fullname($user));
// Grab the renderer
// Grab the renderer.
$renderer = $PAGE->get_renderer('core', 'message');
$messagingoptions = $renderer->render_user_notification_preferences($user);

View File

@ -17,12 +17,14 @@
/**
* Event observers definition.
*
* @package message_output_popup
* @package message_popup
* @category event
* @copyright 2016 Ryan Wyllie <ryan@moodle.com>
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
defined('MOODLE_INTERNAL') || die();
$observers = array(
// Message viewed.

View File

@ -224,10 +224,12 @@ class core_message_renderer extends plugin_renderer_base {
public function render_user_notification_preferences($user) {
$processors = get_message_processors();
$providers = message_get_providers_for_user($user->id);
$preferences = \core_message\api::get_all_message_preferences($processors, $providers, $user);
$notificationlistoutput = new \core_message\output\preferences\notification_list($processors, $providers, $preferences, $user);
return $this->render_from_template('message/preferences_notifications_list', $notificationlistoutput->export_for_template($this));
$preferences = \core_message\api::get_all_message_preferences($processors, $providers, $user);
$notificationlistoutput = new \core_message\output\preferences\notification_list($processors, $providers,
$preferences, $user);
return $this->render_from_template('message/preferences_notifications_list',
$notificationlistoutput->export_for_template($this));
}
/**
@ -251,7 +253,8 @@ class core_message_renderer extends plugin_renderer_base {
return $provider->component === 'moodle';
});
$preferences = \core_message\api::get_all_message_preferences($readyprocessors, $providers, $user);
$notificationlistoutput = new \core_message\output\preferences\message_notification_list($readyprocessors, $providers, $preferences, $user);
$notificationlistoutput = new \core_message\output\preferences\message_notification_list($readyprocessors,
$providers, $preferences, $user);
$context = $notificationlistoutput->export_for_template($this);
$context['blocknoncontacts'] = get_user_preferences('message_blocknoncontacts', '', $user->id) ? true : false;

View File

@ -110,9 +110,11 @@ class core_message_externallib_testcase extends externallib_advanced_testcase {
* @param stdClass $userto user object of the one receiving the message.
* @param string $message message to send.
* @param int $timecreated time the message was created.
* @param int $timeread the the message was read
* @return int the id of the message
*/
protected function send_fake_read_popup_notification($userfrom, $userto, $message = 'Hello world!', $timecreated = 0, $timeread = 0) {
protected function send_fake_read_popup_notification($userfrom, $userto, $message = 'Hello world!',
$timecreated = 0, $timeread = 0) {
global $DB;
$record = new stdClass();

View File

@ -125,9 +125,11 @@ class core_message_messagelib_testcase extends advanced_testcase {
* @param stdClass $userto user object of the one receiving the message.
* @param string $message message to send.
* @param int $timecreated time the message was created.
* @param int $timeread the the message was read
* @return int the id of the message
*/
protected function send_fake_read_popup_notification($userfrom, $userto, $message = 'Hello world!', $timecreated = 0, $timeread = 0) {
protected function send_fake_read_popup_notification($userfrom, $userto, $message = 'Hello world!',
$timecreated = 0, $timeread = 0) {
global $DB;
$record = new stdClass();

View File

@ -20,7 +20,7 @@
.status {
.online-text {
display: none;
color: #77dd77;
color: #7d7;
}
.offline-text {

View File

@ -398,7 +398,6 @@
width: 30px;
display: inline-block;
text-align: center;
vertical-align: middle;
float: left;
img {

View File

@ -5771,7 +5771,7 @@ a.ygtvspacer:hover {
}
.messaging-area-container .status .online-text {
display: none;
color: #77dd77;
color: #7d7;
}
.messaging-area-container .status .offline-text {
color: #ff6961;
@ -7786,7 +7786,6 @@ body.path-question-type .mform fieldset.hidden {
width: 30px;
display: inline-block;
text-align: center;
vertical-align: middle;
float: left;
}
.popover-region-messages.popover-region .popover-region-container .popover-region-content-container .popover-region-content .content-item-container .content-item .profile-image-container img {