MDL-55942 core_message: renamed the term 'people' to 'user'

This commit is contained in:
Mark Nelson 2016-10-03 11:51:53 +08:00
parent 66e1bdda3f
commit 48e8bdba13
10 changed files with 84 additions and 84 deletions

View file

@ -152,8 +152,8 @@ $string['removefromyourcontacts'] = 'Remove from your contacts';
$string['requiresconfiguration'] = 'Requires configuration'; $string['requiresconfiguration'] = 'Requires configuration';
$string['savemysettings'] = 'Save my settings'; $string['savemysettings'] = 'Save my settings';
$string['search'] = 'Search'; $string['search'] = 'Search';
$string['searchforperson'] = 'Search for a person'; $string['searchforuser'] = 'Search for a user';
$string['searchforpersonorcourse'] = 'Search for a person or course'; $string['searchforuserorcourse'] = 'Search for a user or course';
$string['searchmessages'] = 'Search messages'; $string['searchmessages'] = 'Search messages';
$string['searchcombined'] = 'Search people and messages'; $string['searchcombined'] = 'Search people and messages';
$string['selectmessagestodelete'] = 'Select messages to delete'; $string['selectmessagestodelete'] = 'Select messages to delete';

View file

@ -659,17 +659,17 @@ $functions = array(
'type' => 'read', 'type' => 'read',
'ajax' => true, 'ajax' => true,
), ),
'core_message_data_for_messagearea_search_people' => array( 'core_message_data_for_messagearea_search_users' => array(
'classname' => 'core_message_external', 'classname' => 'core_message_external',
'methodname' => 'data_for_messagearea_search_people', 'methodname' => 'data_for_messagearea_search_users',
'classpath' => 'message/externallib.php', 'classpath' => 'message/externallib.php',
'description' => 'Retrieve the template data for searching for people', 'description' => 'Retrieve the template data for searching for people',
'type' => 'read', 'type' => 'read',
'ajax' => true, 'ajax' => true,
), ),
'core_message_data_for_messagearea_search_people_in_course' => array( 'core_message_data_for_messagearea_search_users_in_course' => array(
'classname' => 'core_message_external', 'classname' => 'core_message_external',
'methodname' => 'data_for_messagearea_search_people_in_course', 'methodname' => 'data_for_messagearea_search_users_in_course',
'classpath' => 'message/externallib.php', 'classpath' => 'message/externallib.php',
'description' => 'Retrieve the template data for searching for people in a course', 'description' => 'Retrieve the template data for searching for people in a course',
'type' => 'read', 'type' => 'read',

View file

@ -74,9 +74,9 @@ define(['jquery', 'core_message/message_area_contacts', 'core_message/message_ar
SEARCHBOX: "[data-region='search-box']", SEARCHBOX: "[data-region='search-box']",
SEARCHFILTER: "[data-region='search-filter']", SEARCHFILTER: "[data-region='search-filter']",
SEARCHFILTERAREA: "[data-region='search-filter-area']", SEARCHFILTERAREA: "[data-region='search-filter-area']",
SEARCHPEOPLEINCOURSE: "[data-action='search-people-in-course']",
SEARCHRESULTSAREA: "[data-region='search-results-area']", SEARCHRESULTSAREA: "[data-region='search-results-area']",
SEARCHTEXTAREA: "[data-region='search-text-area']", SEARCHTEXTAREA: "[data-region='search-text-area']",
SEARCHUSERSINCOURSE: "[data-action='search-users-in-course']",
SELECTEDVIEWPROFILE: "[data-action='view-contact-profile'].selected", SELECTEDVIEWPROFILE: "[data-action='view-contact-profile'].selected",
SELECTEDVIEWCONVERSATION: "[data-action='view-contact-msg'].selected", SELECTEDVIEWCONVERSATION: "[data-action='view-contact-msg'].selected",
SENDMESSAGE: "[data-action='send-message']", SENDMESSAGE: "[data-action='send-message']",
@ -106,8 +106,8 @@ define(['jquery', 'core_message/message_area_contacts', 'core_message/message_ar
MESSAGESDELETED: 'messages-deleted', MESSAGESDELETED: 'messages-deleted',
MESSAGESEARCHCANCELED: 'message-search-canceled', MESSAGESEARCHCANCELED: 'message-search-canceled',
MESSAGESENT: 'message-sent', MESSAGESENT: 'message-sent',
PEOPLESEARCHCANCELED: 'people-search-canceled', SENDMESSAGE: 'message-send',
SENDMESSAGE: 'message-send' USERSSEARCHCANCELED: 'users-search-canceled'
}; };
/** @type {jQuery} The jQuery node for the page region containing the message area. */ /** @type {jQuery} The jQuery node for the page region containing the message area. */

View file

@ -74,7 +74,7 @@ define(['jquery', 'core/ajax', 'core/templates', 'core/notification', 'core/cust
]); ]);
this.messageArea.onCustomEvent(this.messageArea.EVENTS.MESSAGESEARCHCANCELED, this._viewConversations.bind(this)); this.messageArea.onCustomEvent(this.messageArea.EVENTS.MESSAGESEARCHCANCELED, this._viewConversations.bind(this));
this.messageArea.onCustomEvent(this.messageArea.EVENTS.PEOPLESEARCHCANCELED, this._viewContacts.bind(this)); this.messageArea.onCustomEvent(this.messageArea.EVENTS.USERSSEARCHCANCELED, this._viewContacts.bind(this));
this.messageArea.onCustomEvent(this.messageArea.EVENTS.CONTACTSSELECTED, this._viewContacts.bind(this)); this.messageArea.onCustomEvent(this.messageArea.EVENTS.CONTACTSSELECTED, this._viewContacts.bind(this));
this.messageArea.onCustomEvent(this.messageArea.EVENTS.CONVERSATIONDELETED, this._deleteConversation.bind(this)); this.messageArea.onCustomEvent(this.messageArea.EVENTS.CONVERSATIONDELETED, this._deleteConversation.bind(this));
this.messageArea.onCustomEvent(this.messageArea.EVENTS.CONVERSATIONSSELECTED, this._viewConversations.bind(this)); this.messageArea.onCustomEvent(this.messageArea.EVENTS.CONVERSATIONSSELECTED, this._viewConversations.bind(this));

View file

@ -52,17 +52,17 @@ define(['jquery', 'core/ajax', 'core/templates', 'core/notification', 'core/str'
/** @type {String} The number of messages to retrieve. */ /** @type {String} The number of messages to retrieve. */
Search.prototype._numMessagesToRetrieve = 20; Search.prototype._numMessagesToRetrieve = 20;
/** @type {String} The number of people displayed. */ /** @type {String} The number of users displayed. */
Search.prototype._numPeopleDisplayed = 0; Search.prototype._numUsersDisplayed = 0;
/** @type {String} The number of people to retrieve. */ /** @type {String} The number of users to retrieve. */
Search.prototype._numPeopleToRetrieve = 20; Search.prototype._numUsersToRetrieve = 20;
/** @type {Array} The type of available search areas. **/ /** @type {Array} The type of available search areas. **/
Search.prototype._searchAreas = { Search.prototype._searchAreas = {
MESSAGES: 'messages', MESSAGES: 'messages',
PEOPLE: 'people', USERS: 'users',
PEOPLEINCOURSE: 'peopleincourse' USERSINCOURSE: 'usersincourse'
}; };
/** @type {int} The timeout before performing an ajax search */ /** @type {int} The timeout before performing an ajax search */
@ -77,24 +77,24 @@ define(['jquery', 'core/ajax', 'core/templates', 'core/notification', 'core/str'
// Handle searching for text. // Handle searching for text.
this.messageArea.find(this.messageArea.SELECTORS.SEARCHTEXTAREA).on('input', this._searchRequest.bind(this)); this.messageArea.find(this.messageArea.SELECTORS.SEARCHTEXTAREA).on('input', this._searchRequest.bind(this));
// Handle clicking on a course in the list of people. // Handle clicking on a course in the list of users.
this.messageArea.onDelegateEvent('click', this.messageArea.SELECTORS.SEARCHPEOPLEINCOURSE, function(e) { this.messageArea.onDelegateEvent('click', this.messageArea.SELECTORS.SEARCHUSERSINCOURSE, function(e) {
this._setFilter($(e.currentTarget).html()); this._setFilter($(e.currentTarget).html());
this._setPlaceholderText('searchforperson'); this._setPlaceholderText('searchforuser');
this._clearSearchArea(); this._clearSearchArea();
this._searchArea = this._searchAreas.PEOPLEINCOURSE; this._searchArea = this._searchAreas.USERSINCOURSE;
this._courseid = $(e.currentTarget).data('courseid'); this._courseid = $(e.currentTarget).data('courseid');
this._searchPeopleInCourse(); this._searchUsersInCourse();
}.bind(this)); }.bind(this));
// Handle deleting the search filter. // Handle deleting the search filter.
this.messageArea.onDelegateEvent('click', this.messageArea.SELECTORS.DELETESEARCHFILTER, function() { this.messageArea.onDelegateEvent('click', this.messageArea.SELECTORS.DELETESEARCHFILTER, function() {
this._hideSearchResults(); this._hideSearchResults();
// Filter has been removed, so we don't want to be searching in a course anymore. // Filter has been removed, so we don't want to be searching in a course anymore.
this._searchArea = this._searchAreas.PEOPLE; this._searchArea = this._searchAreas.USERS;
this._setPlaceholderText('searchforpersonorcourse'); this._setPlaceholderText('searchforuserorcourse');
// Go back the contacts. // Go back the contacts.
this.messageArea.trigger(this.messageArea.EVENTS.PEOPLESEARCHCANCELED); this.messageArea.trigger(this.messageArea.EVENTS.USERSSEARCHCANCELED);
}.bind(this)); }.bind(this));
// Handle events that occur outside this module. // Handle events that occur outside this module.
@ -105,8 +105,8 @@ define(['jquery', 'core/ajax', 'core/templates', 'core/notification', 'core/str'
}.bind(this)); }.bind(this));
this.messageArea.onCustomEvent(this.messageArea.EVENTS.CONTACTSSELECTED, function() { this.messageArea.onCustomEvent(this.messageArea.EVENTS.CONTACTSSELECTED, function() {
this._hideSearchResults(); this._hideSearchResults();
this._searchArea = this._searchAreas.PEOPLE; this._searchArea = this._searchAreas.USERS;
this._setPlaceholderText('searchforpersonorcourse'); this._setPlaceholderText('searchforuserorcourse');
}.bind(this)); }.bind(this));
this.messageArea.onCustomEvent(this.messageArea.EVENTS.MESSAGESENT, function() { this.messageArea.onCustomEvent(this.messageArea.EVENTS.MESSAGESENT, function() {
this._hideSearchResults(); this._hideSearchResults();
@ -126,7 +126,7 @@ define(['jquery', 'core/ajax', 'core/templates', 'core/notification', 'core/str'
this._enableSearching(); this._enableSearching();
}.bind(this)); }.bind(this));
// Event listeners for scrolling through messages and people in courses. // Event listeners for scrolling through messages and users in courses.
customEvents.define(this.messageArea.find(this.messageArea.SELECTORS.SEARCHRESULTSAREA), [ customEvents.define(this.messageArea.find(this.messageArea.SELECTORS.SEARCHRESULTSAREA), [
customEvents.events.scrollBottom customEvents.events.scrollBottom
]); ]);
@ -134,8 +134,8 @@ define(['jquery', 'core/ajax', 'core/templates', 'core/notification', 'core/str'
function() { function() {
if (this._searchArea == this._searchAreas.MESSAGES) { if (this._searchArea == this._searchAreas.MESSAGES) {
this._searchMessages(); this._searchMessages();
} else if (this._searchArea == this._searchAreas.PEOPLEINCOURSE) { } else if (this._searchArea == this._searchAreas.USERSINCOURSE) {
this._searchPeopleInCourse(); this._searchUsersInCourse();
} }
}.bind(this) }.bind(this)
); );
@ -161,13 +161,13 @@ define(['jquery', 'core/ajax', 'core/templates', 'core/notification', 'core/str'
if (this._searchArea == this._searchAreas.MESSAGES) { if (this._searchArea == this._searchAreas.MESSAGES) {
this._hideSearchResults(); this._hideSearchResults();
this.messageArea.trigger(this.messageArea.EVENTS.MESSAGESEARCHCANCELED); this.messageArea.trigger(this.messageArea.EVENTS.MESSAGESEARCHCANCELED);
} else if (this._searchArea == this._searchAreas.PEOPLE) { } else if (this._searchArea == this._searchAreas.USERS) {
this._hideSearchResults(); this._hideSearchResults();
this.messageArea.trigger(this.messageArea.EVENTS.PEOPLESEARCHCANCELED); this.messageArea.trigger(this.messageArea.EVENTS.USERSSEARCHCANCELED);
} else if (this._searchArea == this._searchAreas.PEOPLEINCOURSE) { } else if (this._searchArea == this._searchAreas.USERSINCOURSE) {
// We are still searching in a course, so need to list all the people again. // We are still searching in a course, so need to list all the users again.
this._clearSearchArea(); this._clearSearchArea();
this._searchPeopleInCourse(); this._searchUsersInCourse();
} }
return; return;
} }
@ -182,17 +182,17 @@ define(['jquery', 'core/ajax', 'core/templates', 'core/notification', 'core/str'
this._numMessagesDisplayed = 0; this._numMessagesDisplayed = 0;
this._searchMessages(); this._searchMessages();
}.bind(this), 300); }.bind(this), 300);
} else if (this._searchArea == this._searchAreas.PEOPLEINCOURSE) { } else if (this._searchArea == this._searchAreas.USERSINCOURSE) {
this._requestTimeout = setTimeout(function() { this._requestTimeout = setTimeout(function() {
this._clearSearchArea(); this._clearSearchArea();
this._numPeopleDisplayed = 0; this._numUsersDisplayed = 0;
this._searchPeopleInCourse(); this._searchUsersInCourse();
}.bind(this), 300); }.bind(this), 300);
} else { // Must be searching for people and courses } else { // Must be searching for users and courses
this._requestTimeout = setTimeout(function() { this._requestTimeout = setTimeout(function() {
this._clearSearchArea(); this._clearSearchArea();
this._numPeopleDisplayed = 0; this._numUsersDisplayed = 0;
this._searchPeople(); this._searchUsers();
}.bind(this), 300); }.bind(this), 300);
} }
}; };
@ -233,7 +233,7 @@ define(['jquery', 'core/ajax', 'core/templates', 'core/notification', 'core/str'
return promises[0]; return promises[0];
}.bind(this)).then(function(data) { }.bind(this)).then(function(data) {
numberreceived = data.contacts.length; numberreceived = data.contacts.length;
return templates.render('core_message/message_area_message_search_results', data); return templates.render('core_message/message_area_messages_search_results', data);
}).then(function(html, js) { }).then(function(html, js) {
// Remove the loading icon. // Remove the loading icon.
this.messageArea.find(this.messageArea.SELECTORS.SEARCHRESULTSAREA + " " + this.messageArea.find(this.messageArea.SELECTORS.SEARCHRESULTSAREA + " " +
@ -254,21 +254,21 @@ define(['jquery', 'core/ajax', 'core/templates', 'core/notification', 'core/str'
}; };
/** /**
* Handles searching for people. * Handles searching for users.
* *
* @private * @private
* @return {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() { Search.prototype._searchUsers = function() {
var str = this.messageArea.find(this.messageArea.SELECTORS.SEARCHBOX).val(); var str = this.messageArea.find(this.messageArea.SELECTORS.SEARCHBOX).val();
// Call the web service to get our data. // Call the web service to get our data.
var promises = ajax.call([{ var promises = ajax.call([{
methodname: 'core_message_data_for_messagearea_search_people', methodname: 'core_message_data_for_messagearea_search_users',
args: { args: {
userid: this.messageArea.getCurrentUserId(), userid: this.messageArea.getCurrentUserId(),
search: str, search: str,
limitnum: this._numPeopleToRetrieve limitnum: this._numUsersToRetrieve
} }
}]); }]);
@ -278,19 +278,19 @@ define(['jquery', 'core/ajax', 'core/templates', 'core/notification', 'core/str'
"<div style='text-align:center'>" + html + "</div>", js); "<div style='text-align:center'>" + html + "</div>", js);
return promises[0]; return promises[0];
}.bind(this)).then(function(data) { }.bind(this)).then(function(data) {
return templates.render('core_message/message_area_people_search_results', data); return templates.render('core_message/message_area_users_search_results', data);
}).then(function(html, js) { }).then(function(html, js) {
templates.replaceNodeContents(this.messageArea.find(this.messageArea.SELECTORS.SEARCHRESULTSAREA), html, js); templates.replaceNodeContents(this.messageArea.find(this.messageArea.SELECTORS.SEARCHRESULTSAREA), html, js);
}.bind(this)).fail(notification.exception); }.bind(this)).fail(notification.exception);
}; };
/** /**
* Handles searching for people in a course. * Handles searching for users in a course.
* *
* @private * @private
* @return {Promise|boolean} 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() { Search.prototype._searchUsersInCourse = function() {
if (this._isLoading) { if (this._isLoading) {
return false; return false;
} }
@ -302,13 +302,13 @@ define(['jquery', 'core/ajax', 'core/templates', 'core/notification', 'core/str'
// Call the web service to get our data. // Call the web service to get our data.
var promises = ajax.call([{ var promises = ajax.call([{
methodname: 'core_message_data_for_messagearea_search_people_in_course', methodname: 'core_message_data_for_messagearea_search_users_in_course',
args: { args: {
userid: this.messageArea.getCurrentUserId(), userid: this.messageArea.getCurrentUserId(),
courseid: this._courseid, courseid: this._courseid,
search: str, search: str,
limitfrom: this._numPeopleDisplayed, limitfrom: this._numUsersDisplayed,
limitnum: this._numPeopleToRetrieve limitnum: this._numUsersToRetrieve
} }
}]); }]);
@ -321,7 +321,7 @@ define(['jquery', 'core/ajax', 'core/templates', 'core/notification', 'core/str'
return promises[0]; return promises[0];
}.bind(this)).then(function(data) { }.bind(this)).then(function(data) {
numberreceived = data.contacts.length; numberreceived = data.contacts.length;
return templates.render('core_message/message_area_people_search_results', data); return templates.render('core_message/message_area_users_search_results', data);
}).then(function(html, js) { }).then(function(html, js) {
// Remove the loading icon. // Remove the loading icon.
this.messageArea.find(this.messageArea.SELECTORS.SEARCHRESULTSAREA + " " + this.messageArea.find(this.messageArea.SELECTORS.SEARCHRESULTSAREA + " " +
@ -331,8 +331,8 @@ define(['jquery', 'core/ajax', 'core/templates', 'core/notification', 'core/str'
// Show the new content. // Show the new content.
templates.appendNodeContents(this.messageArea.find(this.messageArea.SELECTORS.SEARCHRESULTSAREA), html, js); templates.appendNodeContents(this.messageArea.find(this.messageArea.SELECTORS.SEARCHRESULTSAREA), html, js);
// Increment the number of contacts displayed. // Increment the number of contacts displayed.
this._numPeopleDisplayed += numberreceived; this._numUsersDisplayed += numberreceived;
} else if (this._numPeopleDisplayed == 0) { // Must have nothing to begin with. } else if (this._numUsersDisplayed == 0) { // Must have nothing to begin with.
// Replace the new content. // Replace the new content.
templates.replaceNodeContents(this.messageArea.find(this.messageArea.SELECTORS.SEARCHRESULTSAREA), html, js); templates.replaceNodeContents(this.messageArea.find(this.messageArea.SELECTORS.SEARCHRESULTSAREA), html, js);
} }
@ -409,8 +409,8 @@ define(['jquery', 'core/ajax', 'core/templates', 'core/notification', 'core/str'
if (this._searchArea == this._searchAreas.MESSAGES) { if (this._searchArea == this._searchAreas.MESSAGES) {
this.messageArea.trigger(this.messageArea.EVENTS.MESSAGESEARCHCANCELED); this.messageArea.trigger(this.messageArea.EVENTS.MESSAGESEARCHCANCELED);
} else if (this._searchArea == this._searchAreas.PEOPLE) { } else if (this._searchArea == this._searchAreas.USERS) {
this.messageArea.trigger(this.messageArea.EVENTS.PEOPLESEARCHCANCELED); this.messageArea.trigger(this.messageArea.EVENTS.USERSSEARCHCANCELED);
} }
}; };

View file

@ -116,16 +116,16 @@ class api {
} }
/** /**
* Handles searching for people in a particular course in the message area. * Handles searching for user in a particular course in the message area.
* *
* @param int $userid The user id doing the searching * @param int $userid The user id doing the searching
* @param int $courseid The id of the course we are searching in * @param int $courseid The id of the course we are searching in
* @param string $search The string the user is searching * @param string $search The string the user is searching
* @param int $limitfrom * @param int $limitfrom
* @param int $limitnum * @param int $limitnum
* @return \core_message\output\messagearea\people_search_results * @return \core_message\output\messagearea\user_search_results
*/ */
public static function search_people_in_course($userid, $courseid, $search, $limitfrom = 0, $limitnum = 0) { public static function search_users_in_course($userid, $courseid, $search, $limitfrom = 0, $limitnum = 0) {
global $DB; global $DB;
// Get all the users in the course. // Get all the users in the course.
@ -152,18 +152,18 @@ class api {
} }
} }
return new \core_message\output\messagearea\people_search_results($contacts); return new \core_message\output\messagearea\user_search_results($contacts);
} }
/** /**
* Handles searching for people in the message area. * Handles searching for user in the message area.
* *
* @param int $userid The user id doing the searching * @param int $userid The user id doing the searching
* @param string $search The string the user is searching * @param string $search The string the user is searching
* @param int $limitnum * @param int $limitnum
* @return \core_message\output\messagearea\people_search_results * @return \core_message\output\messagearea\user_search_results
*/ */
public static function search_people($userid, $search, $limitnum = 0) { public static function search_users($userid, $search, $limitnum = 0) {
global $CFG, $DB; global $CFG, $DB;
require_once($CFG->dirroot . '/lib/coursecatlib.php'); require_once($CFG->dirroot . '/lib/coursecatlib.php');
@ -228,7 +228,7 @@ class api {
} }
} }
return new \core_message\output\messagearea\people_search_results($contacts, $courses, $noncontacts); return new \core_message\output\messagearea\user_search_results($contacts, $courses, $noncontacts);
} }
/** /**

View file

@ -15,7 +15,7 @@
// along with Moodle. If not, see <http://www.gnu.org/licenses/>. // along with Moodle. If not, see <http://www.gnu.org/licenses/>.
/** /**
* Contains class used to display people search results. * Contains class used to display user search results.
* *
* @package core_message * @package core_message
* @copyright 2016 Mark Nelson <markn@moodle.com> * @copyright 2016 Mark Nelson <markn@moodle.com>
@ -30,13 +30,13 @@ use renderable;
use templatable; use templatable;
/** /**
* Class used to display people search results. * Class used to display user search results.
* *
* @package core_message * @package core_message
* @copyright 2016 Mark Nelson <markn@moodle.com> * @copyright 2016 Mark Nelson <markn@moodle.com>
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/ */
class people_search_results implements templatable, renderable { class user_search_results implements templatable, renderable {
/** /**
* @var \core_message\output\messagearea\contact[] The list of contacts. * @var \core_message\output\messagearea\contact[] The list of contacts.

View file

@ -469,12 +469,12 @@ class core_message_external extends external_api {
} }
/** /**
* Get messagearea search people parameters. * Get messagearea search users in course parameters.
* *
* @return external_function_parameters * @return external_function_parameters
* @since 3.2 * @since 3.2
*/ */
public static function data_for_messagearea_search_people_in_course_parameters() { public static function data_for_messagearea_search_users_in_course_parameters() {
return new external_function_parameters( return new external_function_parameters(
array( array(
'userid' => new external_value(PARAM_INT, 'The id of the user who is performing the search'), 'userid' => new external_value(PARAM_INT, 'The id of the user who is performing the search'),
@ -487,7 +487,7 @@ class core_message_external extends external_api {
} }
/** /**
* Get messagearea search people results. * Get messagearea search users in course results.
* *
* @param int $userid The id of the user who is performing the search * @param int $userid The id of the user who is performing the search
* @param int $courseid The id of the course * @param int $courseid The id of the course
@ -498,7 +498,7 @@ class core_message_external extends external_api {
* @throws moodle_exception * @throws moodle_exception
* @since 3.2 * @since 3.2
*/ */
public static function data_for_messagearea_search_people_in_course($userid, $courseid, $search, $limitfrom = 0, public static function data_for_messagearea_search_users_in_course($userid, $courseid, $search, $limitfrom = 0,
$limitnum = 0) { $limitnum = 0) {
global $CFG, $PAGE, $USER; global $CFG, $PAGE, $USER;
@ -516,26 +516,26 @@ class core_message_external extends external_api {
'limitfrom' => $limitfrom, 'limitfrom' => $limitfrom,
'limitnum' => $limitnum 'limitnum' => $limitnum
); );
self::validate_parameters(self::data_for_messagearea_search_people_in_course_parameters(), $params); self::validate_parameters(self::data_for_messagearea_search_users_in_course_parameters(), $params);
self::validate_context($systemcontext); self::validate_context($systemcontext);
if (($USER->id != $userid) && !has_capability('moodle/site:readallmessages', $systemcontext)) { if (($USER->id != $userid) && !has_capability('moodle/site:readallmessages', $systemcontext)) {
throw new moodle_exception('You do not have permission to perform this action.'); throw new moodle_exception('You do not have permission to perform this action.');
} }
$search = \core_message\api::search_people_in_course($userid, $courseid, $search, $limitfrom, $limitnum); $search = \core_message\api::search_users_in_course($userid, $courseid, $search, $limitfrom, $limitnum);
$renderer = $PAGE->get_renderer('core_message'); $renderer = $PAGE->get_renderer('core_message');
return $search->export_for_template($renderer); return $search->export_for_template($renderer);
} }
/** /**
* Get messagearea search people returns. * Get messagearea search users in course returns.
* *
* @return external_single_structure * @return external_single_structure
* @since 3.2 * @since 3.2
*/ */
public static function data_for_messagearea_search_people_in_course_returns() { public static function data_for_messagearea_search_users_in_course_returns() {
return new external_single_structure( return new external_single_structure(
array( array(
'hascontacts' => new external_value(PARAM_BOOL, 'Are there contacts?'), 'hascontacts' => new external_value(PARAM_BOOL, 'Are there contacts?'),
@ -547,12 +547,12 @@ class core_message_external extends external_api {
} }
/** /**
* Get messagearea search people parameters. * Get messagearea search users parameters.
* *
* @return external_function_parameters * @return external_function_parameters
* @since 3.2 * @since 3.2
*/ */
public static function data_for_messagearea_search_people_parameters() { public static function data_for_messagearea_search_users_parameters() {
return new external_function_parameters( return new external_function_parameters(
array( array(
'userid' => new external_value(PARAM_INT, 'The id of the user who is performing the search'), 'userid' => new external_value(PARAM_INT, 'The id of the user who is performing the search'),
@ -563,7 +563,7 @@ class core_message_external extends external_api {
} }
/** /**
* Get messagearea search people results. * Get messagearea search users results.
* *
* @param int $userid The id of the user who is performing the search * @param int $userid The id of the user who is performing the search
* @param string $search The string being searched * @param string $search The string being searched
@ -572,7 +572,7 @@ class core_message_external extends external_api {
* @throws moodle_exception * @throws moodle_exception
* @since 3.2 * @since 3.2
*/ */
public static function data_for_messagearea_search_people($userid, $search, $limitnum = 0) { public static function data_for_messagearea_search_users($userid, $search, $limitnum = 0) {
global $CFG, $PAGE, $USER; global $CFG, $PAGE, $USER;
// Check if messaging is enabled. // Check if messaging is enabled.
@ -587,26 +587,26 @@ class core_message_external extends external_api {
'search' => $search, 'search' => $search,
'limitnum' => $limitnum 'limitnum' => $limitnum
); );
self::validate_parameters(self::data_for_messagearea_search_people_parameters(), $params); self::validate_parameters(self::data_for_messagearea_search_users_parameters(), $params);
self::validate_context($systemcontext); self::validate_context($systemcontext);
if (($USER->id != $userid) && !has_capability('moodle/site:readallmessages', $systemcontext)) { if (($USER->id != $userid) && !has_capability('moodle/site:readallmessages', $systemcontext)) {
throw new moodle_exception('You do not have permission to perform this action.'); throw new moodle_exception('You do not have permission to perform this action.');
} }
$search = \core_message\api::search_people($userid, $search, $limitnum); $search = \core_message\api::search_users($userid, $search, $limitnum);
$renderer = $PAGE->get_renderer('core_message'); $renderer = $PAGE->get_renderer('core_message');
return $search->export_for_template($renderer); return $search->export_for_template($renderer);
} }
/** /**
* Get messagearea search people returns. * Get messagearea search users returns.
* *
* @return external_single_structure * @return external_single_structure
* @since 3.2 * @since 3.2
*/ */
public static function data_for_messagearea_search_people_returns() { public static function data_for_messagearea_search_users_returns() {
return new external_single_structure( return new external_single_structure(
array( array(
'hascontacts' => new external_value(PARAM_BOOL, 'Are there contacts?'), 'hascontacts' => new external_value(PARAM_BOOL, 'Are there contacts?'),

View file

@ -6,7 +6,7 @@
{{#hascourses}} {{#hascourses}}
<div class="heading">{{#str}}courses{{/str}}</div> <div class="heading">{{#str}}courses{{/str}}</div>
{{#courses}} {{#courses}}
<div class="course" data-action="search-people-in-course" data-courseid="{{id}}"> <div class="course" data-action="search-users-in-course" data-courseid="{{id}}">
{{fullname}} {{fullname}}
</div> </div>
{{/courses}} {{/courses}}