From 48e8bdba13b62eac116a1327a1a89d0532ea3af9 Mon Sep 17 00:00:00 2001 From: Mark Nelson Date: Mon, 3 Oct 2016 11:51:53 +0800 Subject: [PATCH] MDL-55942 core_message: renamed the term 'people' to 'user' --- lang/en/message.php | 4 +- lib/db/services.php | 8 +- message/amd/src/message_area.js | 6 +- message/amd/src/message_area_contacts.js | 2 +- message/amd/src/message_area_search.js | 92 +++++++++---------- message/classes/api.php | 16 ++-- ...ch_results.php => user_search_results.php} | 6 +- message/externallib.php | 32 +++---- ...age_area_messages_search_results.mustache} | 0 ...essage_area_users_search_results.mustache} | 2 +- 10 files changed, 84 insertions(+), 84 deletions(-) rename message/classes/output/messagearea/{people_search_results.php => user_search_results.php} (94%) rename message/templates/{message_area_message_search_results.mustache => message_area_messages_search_results.mustache} (100%) rename message/templates/{message_area_people_search_results.mustache => message_area_users_search_results.mustache} (88%) diff --git a/lang/en/message.php b/lang/en/message.php index 6fb25546aa7..d552c771ddd 100644 --- a/lang/en/message.php +++ b/lang/en/message.php @@ -152,8 +152,8 @@ $string['removefromyourcontacts'] = 'Remove from your contacts'; $string['requiresconfiguration'] = 'Requires configuration'; $string['savemysettings'] = 'Save my settings'; $string['search'] = 'Search'; -$string['searchforperson'] = 'Search for a person'; -$string['searchforpersonorcourse'] = 'Search for a person or course'; +$string['searchforuser'] = 'Search for a user'; +$string['searchforuserorcourse'] = 'Search for a user or course'; $string['searchmessages'] = 'Search messages'; $string['searchcombined'] = 'Search people and messages'; $string['selectmessagestodelete'] = 'Select messages to delete'; diff --git a/lib/db/services.php b/lib/db/services.php index 2a89989a5ce..88c9ca35c3a 100644 --- a/lib/db/services.php +++ b/lib/db/services.php @@ -659,17 +659,17 @@ $functions = array( 'type' => 'read', 'ajax' => true, ), - 'core_message_data_for_messagearea_search_people' => array( + 'core_message_data_for_messagearea_search_users' => array( 'classname' => 'core_message_external', - 'methodname' => 'data_for_messagearea_search_people', + 'methodname' => 'data_for_messagearea_search_users', 'classpath' => 'message/externallib.php', 'description' => 'Retrieve the template data for searching for people', 'type' => 'read', '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', - 'methodname' => 'data_for_messagearea_search_people_in_course', + 'methodname' => 'data_for_messagearea_search_users_in_course', 'classpath' => 'message/externallib.php', 'description' => 'Retrieve the template data for searching for people in a course', 'type' => 'read', diff --git a/message/amd/src/message_area.js b/message/amd/src/message_area.js index 671afaf5ee4..47465093670 100644 --- a/message/amd/src/message_area.js +++ b/message/amd/src/message_area.js @@ -74,9 +74,9 @@ 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']", SEARCHRESULTSAREA: "[data-region='search-results-area']", SEARCHTEXTAREA: "[data-region='search-text-area']", + SEARCHUSERSINCOURSE: "[data-action='search-users-in-course']", SELECTEDVIEWPROFILE: "[data-action='view-contact-profile'].selected", SELECTEDVIEWCONVERSATION: "[data-action='view-contact-msg'].selected", SENDMESSAGE: "[data-action='send-message']", @@ -106,8 +106,8 @@ define(['jquery', 'core_message/message_area_contacts', 'core_message/message_ar MESSAGESDELETED: 'messages-deleted', MESSAGESEARCHCANCELED: 'message-search-canceled', 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. */ diff --git a/message/amd/src/message_area_contacts.js b/message/amd/src/message_area_contacts.js index 7cda7338445..b9800a0670f 100644 --- a/message/amd/src/message_area_contacts.js +++ b/message/amd/src/message_area_contacts.js @@ -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.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.CONVERSATIONDELETED, this._deleteConversation.bind(this)); this.messageArea.onCustomEvent(this.messageArea.EVENTS.CONVERSATIONSSELECTED, this._viewConversations.bind(this)); diff --git a/message/amd/src/message_area_search.js b/message/amd/src/message_area_search.js index 6933a103b4f..123fdca5ad7 100644 --- a/message/amd/src/message_area_search.js +++ b/message/amd/src/message_area_search.js @@ -52,17 +52,17 @@ define(['jquery', 'core/ajax', 'core/templates', 'core/notification', 'core/str' /** @type {String} The number of messages to retrieve. */ Search.prototype._numMessagesToRetrieve = 20; - /** @type {String} The number of people displayed. */ - Search.prototype._numPeopleDisplayed = 0; + /** @type {String} The number of users displayed. */ + Search.prototype._numUsersDisplayed = 0; - /** @type {String} The number of people to retrieve. */ - Search.prototype._numPeopleToRetrieve = 20; + /** @type {String} The number of users to retrieve. */ + Search.prototype._numUsersToRetrieve = 20; /** @type {Array} The type of available search areas. **/ Search.prototype._searchAreas = { MESSAGES: 'messages', - PEOPLE: 'people', - PEOPLEINCOURSE: 'peopleincourse' + USERS: 'users', + USERSINCOURSE: 'usersincourse' }; /** @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. this.messageArea.find(this.messageArea.SELECTORS.SEARCHTEXTAREA).on('input', this._searchRequest.bind(this)); - // Handle clicking on a course in the list of people. - this.messageArea.onDelegateEvent('click', this.messageArea.SELECTORS.SEARCHPEOPLEINCOURSE, function(e) { + // Handle clicking on a course in the list of users. + this.messageArea.onDelegateEvent('click', this.messageArea.SELECTORS.SEARCHUSERSINCOURSE, function(e) { this._setFilter($(e.currentTarget).html()); - this._setPlaceholderText('searchforperson'); + this._setPlaceholderText('searchforuser'); this._clearSearchArea(); - this._searchArea = this._searchAreas.PEOPLEINCOURSE; + this._searchArea = this._searchAreas.USERSINCOURSE; this._courseid = $(e.currentTarget).data('courseid'); - this._searchPeopleInCourse(); + this._searchUsersInCourse(); }.bind(this)); // Handle deleting the search filter. this.messageArea.onDelegateEvent('click', this.messageArea.SELECTORS.DELETESEARCHFILTER, function() { this._hideSearchResults(); // Filter has been removed, so we don't want to be searching in a course anymore. - this._searchArea = this._searchAreas.PEOPLE; - this._setPlaceholderText('searchforpersonorcourse'); + this._searchArea = this._searchAreas.USERS; + this._setPlaceholderText('searchforuserorcourse'); // Go back the contacts. - this.messageArea.trigger(this.messageArea.EVENTS.PEOPLESEARCHCANCELED); + this.messageArea.trigger(this.messageArea.EVENTS.USERSSEARCHCANCELED); }.bind(this)); // Handle events that occur outside this module. @@ -105,8 +105,8 @@ define(['jquery', 'core/ajax', 'core/templates', 'core/notification', 'core/str' }.bind(this)); this.messageArea.onCustomEvent(this.messageArea.EVENTS.CONTACTSSELECTED, function() { this._hideSearchResults(); - this._searchArea = this._searchAreas.PEOPLE; - this._setPlaceholderText('searchforpersonorcourse'); + this._searchArea = this._searchAreas.USERS; + this._setPlaceholderText('searchforuserorcourse'); }.bind(this)); this.messageArea.onCustomEvent(this.messageArea.EVENTS.MESSAGESENT, function() { this._hideSearchResults(); @@ -126,7 +126,7 @@ define(['jquery', 'core/ajax', 'core/templates', 'core/notification', 'core/str' this._enableSearching(); }.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.events.scrollBottom ]); @@ -134,8 +134,8 @@ define(['jquery', 'core/ajax', 'core/templates', 'core/notification', 'core/str' function() { if (this._searchArea == this._searchAreas.MESSAGES) { this._searchMessages(); - } else if (this._searchArea == this._searchAreas.PEOPLEINCOURSE) { - this._searchPeopleInCourse(); + } else if (this._searchArea == this._searchAreas.USERSINCOURSE) { + this._searchUsersInCourse(); } }.bind(this) ); @@ -161,13 +161,13 @@ define(['jquery', 'core/ajax', 'core/templates', 'core/notification', 'core/str' if (this._searchArea == this._searchAreas.MESSAGES) { this._hideSearchResults(); this.messageArea.trigger(this.messageArea.EVENTS.MESSAGESEARCHCANCELED); - } else if (this._searchArea == this._searchAreas.PEOPLE) { + } else if (this._searchArea == this._searchAreas.USERS) { this._hideSearchResults(); - this.messageArea.trigger(this.messageArea.EVENTS.PEOPLESEARCHCANCELED); - } else if (this._searchArea == this._searchAreas.PEOPLEINCOURSE) { - // We are still searching in a course, so need to list all the people again. + this.messageArea.trigger(this.messageArea.EVENTS.USERSSEARCHCANCELED); + } else if (this._searchArea == this._searchAreas.USERSINCOURSE) { + // We are still searching in a course, so need to list all the users again. this._clearSearchArea(); - this._searchPeopleInCourse(); + this._searchUsersInCourse(); } return; } @@ -182,17 +182,17 @@ define(['jquery', 'core/ajax', 'core/templates', 'core/notification', 'core/str' this._numMessagesDisplayed = 0; this._searchMessages(); }.bind(this), 300); - } else if (this._searchArea == this._searchAreas.PEOPLEINCOURSE) { + } else if (this._searchArea == this._searchAreas.USERSINCOURSE) { this._requestTimeout = setTimeout(function() { this._clearSearchArea(); - this._numPeopleDisplayed = 0; - this._searchPeopleInCourse(); + this._numUsersDisplayed = 0; + this._searchUsersInCourse(); }.bind(this), 300); - } else { // Must be searching for people and courses + } else { // Must be searching for users and courses this._requestTimeout = setTimeout(function() { this._clearSearchArea(); - this._numPeopleDisplayed = 0; - this._searchPeople(); + this._numUsersDisplayed = 0; + this._searchUsers(); }.bind(this), 300); } }; @@ -233,7 +233,7 @@ define(['jquery', 'core/ajax', 'core/templates', 'core/notification', 'core/str' return promises[0]; }.bind(this)).then(function(data) { 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) { // Remove the loading icon. 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 * @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(); // Call the web service to get our data. var promises = ajax.call([{ - methodname: 'core_message_data_for_messagearea_search_people', + methodname: 'core_message_data_for_messagearea_search_users', args: { userid: this.messageArea.getCurrentUserId(), search: str, - limitnum: this._numPeopleToRetrieve + limitnum: this._numUsersToRetrieve } }]); @@ -278,19 +278,19 @@ define(['jquery', 'core/ajax', 'core/templates', 'core/notification', 'core/str' "
" + html + "
", js); return promises[0]; }.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) { templates.replaceNodeContents(this.messageArea.find(this.messageArea.SELECTORS.SEARCHRESULTSAREA), html, js); }.bind(this)).fail(notification.exception); }; /** - * Handles searching for people in a course. + * Handles searching for users in a course. * * @private * @return {Promise|boolean} The promise resolved when the search area has been rendered */ - Search.prototype._searchPeopleInCourse = function() { + Search.prototype._searchUsersInCourse = function() { if (this._isLoading) { return false; } @@ -302,13 +302,13 @@ define(['jquery', 'core/ajax', 'core/templates', 'core/notification', 'core/str' // Call the web service to get our data. 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: { userid: this.messageArea.getCurrentUserId(), courseid: this._courseid, search: str, - limitfrom: this._numPeopleDisplayed, - limitnum: this._numPeopleToRetrieve + limitfrom: this._numUsersDisplayed, + limitnum: this._numUsersToRetrieve } }]); @@ -321,7 +321,7 @@ define(['jquery', 'core/ajax', 'core/templates', 'core/notification', 'core/str' return promises[0]; }.bind(this)).then(function(data) { 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) { // Remove the loading icon. 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. templates.appendNodeContents(this.messageArea.find(this.messageArea.SELECTORS.SEARCHRESULTSAREA), html, js); // Increment the number of contacts displayed. - this._numPeopleDisplayed += numberreceived; - } else if (this._numPeopleDisplayed == 0) { // Must have nothing to begin with. + this._numUsersDisplayed += numberreceived; + } else if (this._numUsersDisplayed == 0) { // Must have nothing to begin with. // Replace the new content. 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) { this.messageArea.trigger(this.messageArea.EVENTS.MESSAGESEARCHCANCELED); - } else if (this._searchArea == this._searchAreas.PEOPLE) { - this.messageArea.trigger(this.messageArea.EVENTS.PEOPLESEARCHCANCELED); + } else if (this._searchArea == this._searchAreas.USERS) { + this.messageArea.trigger(this.messageArea.EVENTS.USERSSEARCHCANCELED); } }; diff --git a/message/classes/api.php b/message/classes/api.php index 75cb783bd62..d6baed9652b 100644 --- a/message/classes/api.php +++ b/message/classes/api.php @@ -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 $courseid The id of the course we are searching in * @param string $search The string the user is searching * @param int $limitfrom * @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; // 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 string $search The string the user is searching * @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; 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); } /** diff --git a/message/classes/output/messagearea/people_search_results.php b/message/classes/output/messagearea/user_search_results.php similarity index 94% rename from message/classes/output/messagearea/people_search_results.php rename to message/classes/output/messagearea/user_search_results.php index a9ee73bfa46..e4d1c045b39 100644 --- a/message/classes/output/messagearea/people_search_results.php +++ b/message/classes/output/messagearea/user_search_results.php @@ -15,7 +15,7 @@ // along with Moodle. If not, see . /** - * Contains class used to display people search results. + * Contains class used to display user search results. * * @package core_message * @copyright 2016 Mark Nelson @@ -30,13 +30,13 @@ use renderable; use templatable; /** - * Class used to display people search results. + * Class used to display user search results. * * @package core_message * @copyright 2016 Mark Nelson * @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. diff --git a/message/externallib.php b/message/externallib.php index 8642aded798..326283d260f 100644 --- a/message/externallib.php +++ b/message/externallib.php @@ -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 * @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( array( '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 $courseid The id of the course @@ -498,7 +498,7 @@ 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, + public static function data_for_messagearea_search_users_in_course($userid, $courseid, $search, $limitfrom = 0, $limitnum = 0) { global $CFG, $PAGE, $USER; @@ -516,26 +516,26 @@ class core_message_external extends external_api { 'limitfrom' => $limitfrom, '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); if (($USER->id != $userid) && !has_capability('moodle/site:readallmessages', $systemcontext)) { 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'); return $search->export_for_template($renderer); } /** - * Get messagearea search people returns. + * Get messagearea search users in course returns. * * @return external_single_structure * @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( array( '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 * @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( array( '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 string $search The string being searched @@ -572,7 +572,7 @@ class core_message_external extends external_api { * @throws moodle_exception * @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; // Check if messaging is enabled. @@ -587,26 +587,26 @@ class core_message_external extends external_api { 'search' => $search, '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); if (($USER->id != $userid) && !has_capability('moodle/site:readallmessages', $systemcontext)) { 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'); return $search->export_for_template($renderer); } /** - * Get messagearea search people returns. + * Get messagearea search users returns. * * @return external_single_structure * @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( array( 'hascontacts' => new external_value(PARAM_BOOL, 'Are there contacts?'), diff --git a/message/templates/message_area_message_search_results.mustache b/message/templates/message_area_messages_search_results.mustache similarity index 100% rename from message/templates/message_area_message_search_results.mustache rename to message/templates/message_area_messages_search_results.mustache diff --git a/message/templates/message_area_people_search_results.mustache b/message/templates/message_area_users_search_results.mustache similarity index 88% rename from message/templates/message_area_people_search_results.mustache rename to message/templates/message_area_users_search_results.mustache index c20a9ec2df0..c58b5d9be66 100644 --- a/message/templates/message_area_people_search_results.mustache +++ b/message/templates/message_area_users_search_results.mustache @@ -6,7 +6,7 @@ {{#hascourses}}
{{#str}}courses{{/str}}
{{#courses}} -
+
{{fullname}}
{{/courses}}