original_string: public static function set_favourite_conversations(int $userid, array $conversationids) {
          global $CFG, $USER;
  
          // All the business logic checks that really shouldn't be in here.
          if (empty($CFG->messaging)) {
              throw new moodle_exception('disabled', 'message');
          }
          $params = [
              'userid' => $userid,
              'conversations' => $conversationids
          ];
          $params = self::validate_parameters(self::set_favourite_conversations_parameters(), $params);
          $systemcontext = context_system::instance();
          self::validate_context($systemcontext);
  
          if (($USER->id != $params['userid']) && !has_capability('moodle/site:readallmessages', $systemcontext)) {
              throw new moodle_exception('You do not have permission to perform this action.');
          }
  
          foreach ($params['conversations'] as $conversationid) {
              \core_message\api::set_favourite_conversation($conversationid, $params['userid']);
          }
  
          return [];
      }
code: public static function set_favourite_conversations(int $userid, array $conversationids) {
          global $CFG, $USER;
  
          // All the business logic checks that really shouldn't be in here.
          if (empty($CFG->messaging)) {
              throw new moodle_exception('disabled', 'message');
          }
          $params = [
              'userid' => $userid,
              'conversations' => $conversationids
          ];
          $params = self::validate_parameters(self::set_favourite_conversations_parameters(), $params);
          $systemcontext = context_system::instance();
          self::validate_context($systemcontext);
  
          if (($USER->id != $params['userid']) && !has_capability('moodle/site:readallmessages', $systemcontext)) {
              throw new moodle_exception('You do not have permission to perform this action.');
          }
  
          foreach ($params['conversations'] as $conversationid) {
              \core_message\api::set_favourite_conversation($conversationid, $params['userid']);
          }
  
          return [];
      }
code_tokens: public static function set_favourite_conversations ( int $ userid , array $ conversationids ) { global $ CFG , $ USER ; // All the business logic checks that really shouldn't be in here. if ( empty ( $ CFG -> messaging ) ) { throw new moodle_exception ( 'disabled' , 'message' ) ; } $ params = [ 'userid' => $ userid , 'conversations' => $ conversationids ] ; $ params = self :: validate_parameters ( self :: set_favourite_conversations_parameters ( ) , $ params ) ; $ systemcontext = context_system :: instance ( ) ; self :: validate_context ( $ systemcontext ) ; if ( ( $ USER -> id != $ params [ 'userid' ] ) && ! has_capability ( 'moodle/site:readallmessages' , $ systemcontext ) ) { throw new moodle_exception ( 'You do not have permission to perform this action.' ) ; } foreach ( $ params [ 'conversations' ] as $ conversationid ) { \ core_message \ api :: set_favourite_conversation ( $ conversationid , $ params [ 'userid' ] ) ; } return [ ] ; }
docstring: Favourite a conversation, or list of conversations for a user.
  
  @param int $userid the id of the user, or 0 for the current user.
  @param array $conversationids the list of conversations ids to favourite.
  @return array
  @throws moodle_exception if messaging is disabled or if the user cannot perform the action.
docstring_tokens: Favourite a conversation or list of conversations for a user .