Merge branch 'MDL-63882-master' of git://github.com/damyon/moodle
authorDavid Monllao <davidm@moodle.com>
Tue, 13 Nov 2018 15:07:14 +0000 (16:07 +0100)
committerDavid Monllao <davidm@moodle.com>
Tue, 13 Nov 2018 15:07:14 +0000 (16:07 +0100)
1  2 
message/externallib.php

@@@ -700,19 -626,15 +700,19 @@@ class core_message_external extends ext
          $context = context_system::instance();
          self::validate_context($context);
  
-         $capability = 'moodle/site:manageallmessaging';
-         if (($USER->id != $userid) && !has_capability($capability, $context)) {
-             throw new required_capability_exception($context, $capability, 'nopermissions', '');
-         }
 -        $params = ['userid' => $userid];
 +        $params = [
 +            'userid' => $userid,
 +            'limitfrom' => $limitfrom,
 +            'limitnum' => $limitnum
 +        ];
          $params = self::validate_parameters(self::get_contact_requests_parameters(), $params);
  
 -        return \core_message\api::get_contact_requests($params['userid']);
+         $capability = 'moodle/site:manageallmessaging';
+         if (($USER->id != $params['userid']) && !has_capability($capability, $context)) {
+             throw new required_capability_exception($context, $capability, 'nopermissions', '');
+         }
 +        return \core_message\api::get_contact_requests($params['userid'], $params['limitfrom'], $params['limitnum']);
      }
  
      /**