mirror of
https://github.com/moodle/moodle.git
synced 2025-08-04 16:36:37 +02:00
MDL-71917 core_message: Use $USER in WS delete_message_for_all_users
This commit is contained in:
parent
264fe69743
commit
f254b2b88f
1 changed files with 4 additions and 5 deletions
|
@ -4858,13 +4858,13 @@ class core_message_external extends external_api {
|
||||||
* Deletes a message for all users
|
* Deletes a message for all users
|
||||||
*
|
*
|
||||||
* @param int $messageid the message id
|
* @param int $messageid the message id
|
||||||
* @param int $userid the user id of who we want to delete the message for all users
|
* @param int $userid the user id of who we want to delete the message for all users, is no longer used.
|
||||||
* @return external_description
|
* @return external_description
|
||||||
* @throws moodle_exception
|
* @throws moodle_exception
|
||||||
* @since 3.7
|
* @since 3.7
|
||||||
*/
|
*/
|
||||||
public static function delete_message_for_all_users(int $messageid, int $userid) {
|
public static function delete_message_for_all_users(int $messageid, int $userid) {
|
||||||
global $CFG;
|
global $CFG, $USER;
|
||||||
|
|
||||||
// Check if private messaging between users is allowed.
|
// Check if private messaging between users is allowed.
|
||||||
if (empty($CFG->messaging)) {
|
if (empty($CFG->messaging)) {
|
||||||
|
@ -4882,11 +4882,10 @@ class core_message_external extends external_api {
|
||||||
$context = context_system::instance();
|
$context = context_system::instance();
|
||||||
self::validate_context($context);
|
self::validate_context($context);
|
||||||
|
|
||||||
$user = core_user::get_user($params['userid'], '*', MUST_EXIST);
|
core_user::require_active_user($USER);
|
||||||
core_user::require_active_user($user);
|
|
||||||
|
|
||||||
// Checks if a user can delete a message for all users.
|
// Checks if a user can delete a message for all users.
|
||||||
if (core_message\api::can_delete_message_for_all_users($user->id, $params['messageid'])) {
|
if (core_message\api::can_delete_message_for_all_users($USER->id, $params['messageid'])) {
|
||||||
\core_message\api::delete_message_for_all_users($params['messageid']);
|
\core_message\api::delete_message_for_all_users($params['messageid']);
|
||||||
} else {
|
} else {
|
||||||
throw new moodle_exception('You do not have permission to delete this message for everyone.');
|
throw new moodle_exception('You do not have permission to delete this message for everyone.');
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue