Merge branch 'MDL-63909_master' of git://github.com/markn86/moodle

This commit is contained in:
Damyon Wiese 2018-11-12 14:01:01 +08:00
commit 75e6661940
7 changed files with 86 additions and 38 deletions

View File

@ -1037,7 +1037,8 @@ $functions = array(
'classname' => 'core_message_external',
'methodname' => 'data_for_messagearea_contacts',
'classpath' => 'message/externallib.php',
'description' => 'Retrieve the template data for the contact list',
'description' => '** DEPRECATED ** Please do not call this function any more.
Retrieve the template data for the contact list',
'type' => 'read',
'ajax' => true,
'services' => array(MOODLE_OFFICIAL_MOBILE_SERVICE),
@ -1046,7 +1047,8 @@ $functions = array(
'classname' => 'core_message_external',
'methodname' => 'data_for_messagearea_messages',
'classpath' => 'message/externallib.php',
'description' => 'Retrieve the template data for the messages',
'description' => '** DEPRECATED ** Please do not call this function any more.
Retrieve the template data for the messages',
'type' => 'read',
'ajax' => true,
'services' => array(MOODLE_OFFICIAL_MOBILE_SERVICE),
@ -1055,7 +1057,8 @@ $functions = array(
'classname' => 'core_message_external',
'methodname' => 'data_for_messagearea_get_most_recent_message',
'classpath' => 'message/externallib.php',
'description' => 'Retrieve the template data for the most recent message',
'description' => '** DEPRECATED ** Please do not call this function any more.
Retrieve the template data for the most recent message',
'type' => 'read',
'ajax' => true,
),
@ -1063,7 +1066,8 @@ $functions = array(
'classname' => 'core_message_external',
'methodname' => 'data_for_messagearea_get_profile',
'classpath' => 'message/externallib.php',
'description' => 'Retrieve the template data for the users\'s profile',
'description' => '** DEPRECATED ** Please do not call this function any more.
Retrieve the template data for the users\'s profile',
'type' => 'read',
'ajax' => true,
),

View File

@ -151,7 +151,7 @@ class api {
/**
* Handles searching for user in a particular course in the message area.
*
* TODO: This function should be removed once new group messaging UI is in place and old messaging UI is removed.
* TODO: This function should be removed once the new group messaging UI is in place and the old messaging UI is removed.
* For now we are not removing/deprecating this function for backwards compatibility with messaging UI.
* But we are deprecating data_for_messagearea_search_users_in_course external function.
* Followup: MDL-63915
@ -197,7 +197,7 @@ class api {
/**
* Handles searching for user in the message area.
*
* TODO: This function should be removed once new group messaging UI is in place and old messaging UI is removed.
* TODO: This function should be removed once the new group messaging UI is in place and the old messaging UI is removed.
* For now we are not removing/deprecating this function for backwards compatibility with messaging UI.
* But we are deprecating data_for_messagearea_search_users external function.
* Followup: MDL-63915
@ -808,6 +808,10 @@ class api {
/**
* Returns the contacts to display in the contacts area.
*
* TODO: This function should be removed once the new group messaging UI is in place and the old messaging UI is removed.
* For now we are not removing/deprecating this function for backwards compatibility with messaging UI.
* Followup: MDL-63915
*
* @param int $userid The user id
* @param int $limitfrom
* @param int $limitnum
@ -929,7 +933,10 @@ class api {
/**
* Returns the messages to display in the message area.
*
* @deprecated since 3.6
* TODO: This function should be removed once the new group messaging UI is in place and the old messaging UI is removed.
* For now we are not removing/deprecating this function for backwards compatibility with messaging UI.
* Followup: MDL-63915
*
* @param int $userid the current user
* @param int $otheruserid the other user
* @param int $limitfrom
@ -941,8 +948,6 @@ class api {
*/
public static function get_messages($userid, $otheruserid, $limitfrom = 0, $limitnum = 0,
$sort = 'timecreated ASC', $timefrom = 0, $timeto = 0) {
debugging('\core_message\api::get_messages() is deprecated, please use ' .
'\core_message\api::get_conversation_messages() instead.', DEBUG_DEVELOPER);
if (!empty($timefrom)) {
// Get the conversation between userid and otheruserid.
@ -1013,15 +1018,15 @@ class api {
/**
* Returns the most recent message between two users.
*
* @deprecated since 3.6
* TODO: This function should be removed once the new group messaging UI is in place and the old messaging UI is removed.
* For now we are not removing/deprecating this function for backwards compatibility with messaging UI.
* Followup: MDL-63915
*
* @param int $userid the current user
* @param int $otheruserid the other user
* @return \stdClass|null
*/
public static function get_most_recent_message($userid, $otheruserid) {
debugging('\core_message\api::get_most_recent_message() is deprecated, please use ' .
'\core_message\api::get_most_recent_conversation_message() instead.', DEBUG_DEVELOPER);
// We want two messages here so we get an accurate 'blocktime' value.
if ($messages = helper::get_messages($userid, $otheruserid, 0, 0, 2, 'timecreated DESC')) {
// Swap the order so we now have them in historical order.
@ -1058,6 +1063,10 @@ class api {
/**
* Returns the profile information for a contact for a user.
*
* TODO: This function should be removed once the new group messaging UI is in place and the old messaging UI is removed.
* For now we are not removing/deprecating this function for backwards compatibility with messaging UI.
* Followup: MDL-63915
*
* @param int $userid The user id
* @param int $otheruserid The id of the user whose profile we want to view.
* @return \stdClass

View File

@ -37,7 +37,10 @@ class helper {
/**
* Helper function to retrieve the messages between two users
*
* @deprecated since 3.6
* TODO: This function should be removed once the new group messaging UI is in place and the old messaging UI is removed.
* For now we are not removing/deprecating this function for backwards compatibility with messaging UI.
* Followup: MDL-63915
*
* @param int $userid the current user
* @param int $otheruserid the other user
* @param int $timedeleted the time the message was deleted
@ -50,9 +53,6 @@ class helper {
*/
public static function get_messages($userid, $otheruserid, $timedeleted = 0, $limitfrom = 0, $limitnum = 0,
$sort = 'timecreated ASC', $timefrom = 0, $timeto = 0) {
debugging('\core_message\helper::get_messages() is deprecated, please use ' .
'\core_message\helper::get_conversation_messages() instead.', DEBUG_DEVELOPER);
global $DB;
$hash = self::get_conversation_hash([$userid, $otheruserid]);
@ -229,15 +229,15 @@ class helper {
/**
* Helper function to return an array of messages.
*
* @deprecated since 3.6
* TODO: This function should be removed once the new group messaging UI is in place and the old messaging UI is removed.
* For now we are not removing/deprecating this function for backwards compatibility with messaging UI.
* Followup: MDL-63915
*
* @param int $userid
* @param array $messages
* @return array
*/
public static function create_messages($userid, $messages) {
debugging('\core_message\helper::create_messages() is deprecated, please use ' .
'\core_message\helper::create_conversation_messages() instead.', DEBUG_DEVELOPER);
// Store the messages.
$arrmessages = array();

View File

@ -1581,6 +1581,7 @@ class core_message_external extends external_api {
/**
* The messagearea contacts return parameters.
*
* @deprecated since 3.6
* @return external_function_parameters
* @since 3.2
*/
@ -1591,6 +1592,7 @@ class core_message_external extends external_api {
/**
* Get messagearea contacts parameters.
*
* @deprecated since 3.6
* @param int $userid The id of the user who we are viewing conversations for
* @param int $limitfrom
* @param int $limitnum
@ -1630,6 +1632,7 @@ class core_message_external extends external_api {
/**
* The messagearea contacts return structure.
*
* @deprecated since 3.6
* @return external_single_structure
* @since 3.2
*/
@ -1637,9 +1640,19 @@ class core_message_external extends external_api {
return self::data_for_messagearea_conversations_returns();
}
/**
* Marking the method as deprecated.
*
* @return bool
*/
public static function data_for_messagearea_contacts_is_deprecated() {
return true;
}
/**
* The messagearea messages parameters.
*
* @deprecated since 3.6
* @return external_function_parameters
* @since 3.2
*/
@ -1660,6 +1673,7 @@ class core_message_external extends external_api {
/**
* Get messagearea messages.
*
* @deprecated since 3.6
* @param int $currentuserid The current user's id
* @param int $otheruserid The other user's id
* @param int $limitfrom
@ -1732,6 +1746,7 @@ class core_message_external extends external_api {
/**
* The messagearea messages return structure.
*
* @deprecated since 3.6
* @return external_single_structure
* @since 3.2
*/
@ -1753,6 +1768,15 @@ class core_message_external extends external_api {
);
}
/**
* Marking the method as deprecated.
*
* @return bool
*/
public static function data_for_messagearea_messages_is_deprecated() {
return true;
}
/**
* The conversation messages parameters.
*
@ -1858,6 +1882,7 @@ class core_message_external extends external_api {
/**
* The get most recent message return parameters.
*
* @deprecated since 3.6
* @return external_function_parameters
* @since 3.2
*/
@ -1873,6 +1898,7 @@ class core_message_external extends external_api {
/**
* Get the most recent message in a conversation.
*
* @deprecated since 3.6
* @param int $currentuserid The current user's id
* @param int $otheruserid The other user's id
* @return stdClass
@ -1910,6 +1936,7 @@ class core_message_external extends external_api {
/**
* The get most recent message return structure.
*
* @deprecated since 3.6
* @return external_single_structure
* @since 3.2
*/
@ -1917,9 +1944,19 @@ class core_message_external extends external_api {
return self::get_messagearea_message_structure();
}
/**
* Marking the method as deprecated.
*
* @return bool
*/
public static function data_for_messagearea_get_most_recent_message_is_deprecated() {
return true;
}
/**
* The get profile parameters.
*
* @deprecated since 3.6
* @return external_function_parameters
* @since 3.2
*/
@ -1935,6 +1972,7 @@ class core_message_external extends external_api {
/**
* Get the profile information for a contact.
*
* @deprecated since 3.6
* @param int $currentuserid The current user's id
* @param int $otheruserid The id of the user whose profile we are viewing
* @return stdClass
@ -1972,6 +2010,7 @@ class core_message_external extends external_api {
/**
* The get profile return structure.
*
* @deprecated since 3.6
* @return external_single_structure
* @since 3.2
*/
@ -1993,6 +2032,15 @@ class core_message_external extends external_api {
);
}
/**
* Marking the method as deprecated.
*
* @return bool
*/
public static function data_for_messagearea_get_profile_is_deprecated() {
return true;
}
/**
* Get contacts parameters description.
*

View File

@ -1898,7 +1898,6 @@ class core_message_api_testcase extends core_message_messagelib_testcase {
// Retrieve the messages.
$messages = \core_message\api::get_messages($user1->id, $user2->id);
$this->assertDebuggingCalledCount(3);
// Confirm the message data is correct.
$this->assertEquals(4, count($messages));
@ -2421,7 +2420,6 @@ class core_message_api_testcase extends core_message_messagelib_testcase {
// Retrieve the most recent messages.
$message = \core_message\api::get_most_recent_message($user1->id, $user2->id);
$this->assertDebuggingCalledCount(3);
// Check the results are correct.
$this->assertEquals($user2->id, $message->useridfrom);
@ -3189,7 +3187,6 @@ class core_message_api_testcase extends core_message_messagelib_testcase {
// Retrieve the messages from $time, which should be all of them.
$messages = \core_message\api::get_messages($user1->id, $user2->id, 0, 0, 'timecreated ASC', $time);
$this->assertDebuggingCalledCount(3);
// Confirm the message data is correct.
$this->assertEquals(4, count($messages));
@ -3206,7 +3203,6 @@ class core_message_api_testcase extends core_message_messagelib_testcase {
// Retrieve the messages from $time + 3, which should only be the 2 last messages.
$messages = \core_message\api::get_messages($user1->id, $user2->id, 0, 0, 'timecreated ASC', $time + 3);
$this->assertDebuggingCalledCount(3);
// Confirm the message data is correct.
$this->assertEquals(2, count($messages));
@ -3238,7 +3234,6 @@ class core_message_api_testcase extends core_message_messagelib_testcase {
// Retrieve the messages up until $time + 4, which should be all of them.
$messages = \core_message\api::get_messages($user1->id, $user2->id, 0, 0, 'timecreated ASC', 0, $time + 4);
$this->assertDebuggingCalledCount(3);
// Confirm the message data is correct.
$this->assertEquals(4, count($messages));
@ -3255,7 +3250,6 @@ class core_message_api_testcase extends core_message_messagelib_testcase {
// Retrieve the messages up until $time + 2, which should be the first two.
$messages = \core_message\api::get_messages($user1->id, $user2->id, 0, 0, 'timecreated ASC', 0, $time + 2);
$this->assertDebuggingCalledCount(3);
// Confirm the message data is correct.
$this->assertEquals(2, count($messages));
@ -3287,7 +3281,6 @@ class core_message_api_testcase extends core_message_messagelib_testcase {
// Retrieve the messages from $time + 2 up until $time + 3, which should be 2nd and 3rd message.
$messages = \core_message\api::get_messages($user1->id, $user2->id, 0, 0, 'timecreated ASC', $time + 2, $time + 3);
$this->assertDebuggingCalledCount(3);
// Confirm the message data is correct.
$this->assertEquals(2, count($messages));

View File

@ -3147,7 +3147,6 @@ class core_message_externallib_testcase extends externallib_advanced_testcase {
// Retrieve the messages.
$result = core_message_external::data_for_messagearea_messages($user1->id, $user2->id);
$this->assertDebuggingCalledCount(3);
// We need to execute the return values cleaning process to simulate the web service server.
$result = external_api::clean_returnvalue(core_message_external::data_for_messagearea_messages_returns(),
@ -3212,7 +3211,6 @@ class core_message_externallib_testcase extends externallib_advanced_testcase {
// Retrieve the messages from $time - 3, which should be the 3 most recent messages.
$result = core_message_external::data_for_messagearea_messages($user1->id, $user2->id, 0, 0, false, $time - 3);
$this->assertDebuggingCalledCount(3);
// We need to execute the return values cleaning process to simulate the web service server.
$result = external_api::clean_returnvalue(core_message_external::data_for_messagearea_messages_returns(),
@ -3253,7 +3251,6 @@ class core_message_externallib_testcase extends externallib_advanced_testcase {
// Retrieve the messages.
$result = core_message_external::data_for_messagearea_messages($user1->id, $user2->id);
$this->assertDebuggingCalledCount(3);
// We need to execute the return values cleaning process to simulate the web service server.
$result = external_api::clean_returnvalue(core_message_external::data_for_messagearea_messages_returns(),
@ -3613,7 +3610,6 @@ class core_message_externallib_testcase extends externallib_advanced_testcase {
// Get the most recent message.
$result = core_message_external::data_for_messagearea_get_most_recent_message($user1->id, $user2->id);
$this->assertDebuggingCalledCount(3);
// We need to execute the return values cleaning process to simulate the web service server.
$result = external_api::clean_returnvalue(core_message_external::data_for_messagearea_get_most_recent_message_returns(),
@ -3647,7 +3643,6 @@ class core_message_externallib_testcase extends externallib_advanced_testcase {
// Get the most recent message.
$result = core_message_external::data_for_messagearea_get_most_recent_message($user1->id, $user2->id);
$this->assertDebuggingCalledCount(3);
// We need to execute the return values cleaning process to simulate the web service server.
$result = external_api::clean_returnvalue(core_message_external::data_for_messagearea_get_most_recent_message_returns(),

View File

@ -31,11 +31,6 @@ information provided here is intended especially for developers.
- \core_message\api::delete_conversation()
- \core_message\api::is_user_non_contact_blocked()
- \core_message\api::create_conversation_between_users()
- \core_message\api::get_messages()
- \core_message\api::get_most_recent_message()
- \core_message\helper::get_messages()
- \core_message\helper::create_messages()
- \core_message\api::search_users()
* The method \core_message\api::can_delete_conversation() now expects a 'conversationid' to be passed
as the second parameter.
* The following web services have been deprecated. Please do not call these any more.
@ -50,6 +45,10 @@ information provided here is intended especially for developers.
- core_message_external::data_for_messagearea_search_users_in_course().
- core_message_external::data_for_messagearea_search_users(),
please use core_message_external::message_search_users() instead.
- core_message_external::data_for_messagearea_contacts().
- core_message_external::data_for_messagearea_messages().
- core_message_external::data_for_messagearea_get_most_recent_message().
- core_message_external::data_for_messagearea_get_profile().
* The following function has been added for getting the privacy messaging preference:
- get_user_privacy_messaging_preference()