original_string: public static function mute_conversations(int $userid, array $conversationids) {
          global $CFG, $USER;
  
          // Check if messaging is enabled.
          if (empty($CFG->messaging)) {
              throw new moodle_exception('disabled', 'message');
          }
  
          // Validate context.
          $context = context_system::instance();
          self::validate_context($context);
  
          $params = ['userid' => $userid, 'conversationids' => $conversationids];
          $params = self::validate_parameters(self::mute_conversations_parameters(), $params);
  
          $capability = 'moodle/site:manageallmessaging';
          if (($USER->id != $params['userid']) && !has_capability($capability, $context)) {
              throw new required_capability_exception($context, $capability, 'nopermissions', '');
          }
  
          foreach ($params['conversationids'] as $conversationid) {
              if (!\core_message\api::is_conversation_muted($params['userid'], $conversationid)) {
                  \core_message\api::mute_conversation($params['userid'], $conversationid);
              }
          }
  
          return [];
      }
code: public static function mute_conversations(int $userid, array $conversationids) {
          global $CFG, $USER;
  
          // Check if messaging is enabled.
          if (empty($CFG->messaging)) {
              throw new moodle_exception('disabled', 'message');
          }
  
          // Validate context.
          $context = context_system::instance();
          self::validate_context($context);
  
          $params = ['userid' => $userid, 'conversationids' => $conversationids];
          $params = self::validate_parameters(self::mute_conversations_parameters(), $params);
  
          $capability = 'moodle/site:manageallmessaging';
          if (($USER->id != $params['userid']) && !has_capability($capability, $context)) {
              throw new required_capability_exception($context, $capability, 'nopermissions', '');
          }
  
          foreach ($params['conversationids'] as $conversationid) {
              if (!\core_message\api::is_conversation_muted($params['userid'], $conversationid)) {
                  \core_message\api::mute_conversation($params['userid'], $conversationid);
              }
          }
  
          return [];
      }
code_tokens: public static function mute_conversations ( int $ userid , array $ conversationids ) { global $ CFG , $ USER ; // Check if messaging is enabled. if ( empty ( $ CFG -> messaging ) ) { throw new moodle_exception ( 'disabled' , 'message' ) ; } // Validate context. $ context = context_system :: instance ( ) ; self :: validate_context ( $ context ) ; $ params = [ 'userid' => $ userid , 'conversationids' => $ conversationids ] ; $ params = self :: validate_parameters ( self :: mute_conversations_parameters ( ) , $ params ) ; $ capability = 'moodle/site:manageallmessaging' ; if ( ( $ USER -> id != $ params [ 'userid' ] ) && ! has_capability ( $ capability , $ context ) ) { throw new required_capability_exception ( $ context , $ capability , 'nopermissions' , '' ) ; } foreach ( $ params [ 'conversationids' ] as $ conversationid ) { if ( ! \ core_message \ api :: is_conversation_muted ( $ params [ 'userid' ] , $ conversationid ) ) { \ core_message \ api :: mute_conversation ( $ params [ 'userid' ] , $ conversationid ) ; } } return [ ] ; }
docstring: Mutes conversations.
  
  @param int $userid The id of the user who is blocking
  @param array $conversationids The list of conversations being muted
  @return external_description
docstring_tokens: Mutes conversations .