original_string: public static function get_blocked_users($userid) {
          global $CFG, $USER, $PAGE;
  
          // Warnings array, it can be empty at the end but is mandatory.
          $warnings = array();
  
          // Validate params.
          $params = array(
              'userid' => $userid
          );
          $params = self::validate_parameters(self::get_blocked_users_parameters(), $params);
          $userid = $params['userid'];
  
          // Validate context.
          $context = context_system::instance();
          self::validate_context($context);
  
          // Check if private messaging between users is allowed.
          if (empty($CFG->messaging)) {
              throw new moodle_exception('disabled', 'message');
          }
  
          $user = core_user::get_user($userid, '*', MUST_EXIST);
          core_user::require_active_user($user);
  
          // Check if we have permissions for retrieve the information.
          $capability = 'moodle/site:manageallmessaging';
          if (($USER->id != $userid) && !has_capability($capability, $context)) {
              throw new required_capability_exception($context, $capability, 'nopermissions', '');
          }
  
          // Now, we can get safely all the blocked users.
          $users = \core_message\api::get_blocked_users($user->id);
  
          $blockedusers = array();
          foreach ($users as $user) {
              $newuser = array(
                  'id' => $user->id,
                  'fullname' => fullname($user),
              );
  
              $userpicture = new user_picture($user);
              $userpicture->size = 1; // Size f1.
              $newuser['profileimageurl'] = $userpicture->get_url($PAGE)->out(false);
  
              $blockedusers[] = $newuser;
          }
  
          $results = array(
              'users' => $blockedusers,
              'warnings' => $warnings
          );
          return $results;
      }
code: public static function get_blocked_users($userid) {
          global $CFG, $USER, $PAGE;
  
          // Warnings array, it can be empty at the end but is mandatory.
          $warnings = array();
  
          // Validate params.
          $params = array(
              'userid' => $userid
          );
          $params = self::validate_parameters(self::get_blocked_users_parameters(), $params);
          $userid = $params['userid'];
  
          // Validate context.
          $context = context_system::instance();
          self::validate_context($context);
  
          // Check if private messaging between users is allowed.
          if (empty($CFG->messaging)) {
              throw new moodle_exception('disabled', 'message');
          }
  
          $user = core_user::get_user($userid, '*', MUST_EXIST);
          core_user::require_active_user($user);
  
          // Check if we have permissions for retrieve the information.
          $capability = 'moodle/site:manageallmessaging';
          if (($USER->id != $userid) && !has_capability($capability, $context)) {
              throw new required_capability_exception($context, $capability, 'nopermissions', '');
          }
  
          // Now, we can get safely all the blocked users.
          $users = \core_message\api::get_blocked_users($user->id);
  
          $blockedusers = array();
          foreach ($users as $user) {
              $newuser = array(
                  'id' => $user->id,
                  'fullname' => fullname($user),
              );
  
              $userpicture = new user_picture($user);
              $userpicture->size = 1; // Size f1.
              $newuser['profileimageurl'] = $userpicture->get_url($PAGE)->out(false);
  
              $blockedusers[] = $newuser;
          }
  
          $results = array(
              'users' => $blockedusers,
              'warnings' => $warnings
          );
          return $results;
      }
code_tokens: public static function get_blocked_users ( $ userid ) { global $ CFG , $ USER , $ PAGE ; // Warnings array, it can be empty at the end but is mandatory. $ warnings = array ( ) ; // Validate params. $ params = array ( 'userid' => $ userid ) ; $ params = self :: validate_parameters ( self :: get_blocked_users_parameters ( ) , $ params ) ; $ userid = $ params [ 'userid' ] ; // Validate context. $ context = context_system :: instance ( ) ; self :: validate_context ( $ context ) ; // Check if private messaging between users is allowed. if ( empty ( $ CFG -> messaging ) ) { throw new moodle_exception ( 'disabled' , 'message' ) ; } $ user = core_user :: get_user ( $ userid , '*' , MUST_EXIST ) ; core_user :: require_active_user ( $ user ) ; // Check if we have permissions for retrieve the information. $ capability = 'moodle/site:manageallmessaging' ; if ( ( $ USER -> id != $ userid ) && ! has_capability ( $ capability , $ context ) ) { throw new required_capability_exception ( $ context , $ capability , 'nopermissions' , '' ) ; } // Now, we can get safely all the blocked users. $ users = \ core_message \ api :: get_blocked_users ( $ user -> id ) ; $ blockedusers = array ( ) ; foreach ( $ users as $ user ) { $ newuser = array ( 'id' => $ user -> id , 'fullname' => fullname ( $ user ) , ) ; $ userpicture = new user_picture ( $ user ) ; $ userpicture -> size = 1 ; // Size f1. $ newuser [ 'profileimageurl' ] = $ userpicture -> get_url ( $ PAGE ) -> out ( false ) ; $ blockedusers [ ] = $ newuser ; } $ results = array ( 'users' => $ blockedusers , 'warnings' => $ warnings ) ; return $ results ; }
docstring: Retrieve a list of users blocked
  
  @param  int $userid the user whose blocked users we want to retrieve
  @return external_description
  @since 2.9
docstring_tokens: Retrieve a list of users blocked