original_string: public static function unset_favourite_conversation(int $conversationid, int $userid) {
          global $DB;
  
          // Get the context for this conversation.
          $conversation = $DB->get_record('message_conversations', ['id' => $conversationid]);
          $userctx = \context_user::instance($userid);
          if (empty($conversation->contextid)) {
              // When the conversation hasn't any contextid value defined, the favourite will be added to the user context.
              $conversationctx = $userctx;
          } else {
              // If the contextid is defined, the favourite will be added there.
              $conversationctx = \context::instance_by_id($conversation->contextid);
          }
  
          $ufservice = \core_favourites\service_factory::get_service_for_user_context($userctx);
          $ufservice->delete_favourite('core_message', 'message_conversations', $conversationid, $conversationctx);
      }
code: public static function unset_favourite_conversation(int $conversationid, int $userid) {
          global $DB;
  
          // Get the context for this conversation.
          $conversation = $DB->get_record('message_conversations', ['id' => $conversationid]);
          $userctx = \context_user::instance($userid);
          if (empty($conversation->contextid)) {
              // When the conversation hasn't any contextid value defined, the favourite will be added to the user context.
              $conversationctx = $userctx;
          } else {
              // If the contextid is defined, the favourite will be added there.
              $conversationctx = \context::instance_by_id($conversation->contextid);
          }
  
          $ufservice = \core_favourites\service_factory::get_service_for_user_context($userctx);
          $ufservice->delete_favourite('core_message', 'message_conversations', $conversationid, $conversationctx);
      }
code_tokens: public static function unset_favourite_conversation ( int $ conversationid , int $ userid ) { global $ DB ; // Get the context for this conversation. $ conversation = $ DB -> get_record ( 'message_conversations' , [ 'id' => $ conversationid ] ) ; $ userctx = \ context_user :: instance ( $ userid ) ; if ( empty ( $ conversation -> contextid ) ) { // When the conversation hasn't any contextid value defined, the favourite will be added to the user context. $ conversationctx = $ userctx ; } else { // If the contextid is defined, the favourite will be added there. $ conversationctx = \ context :: instance_by_id ( $ conversation -> contextid ) ; } $ ufservice = \ core_favourites \ service_factory :: get_service_for_user_context ( $ userctx ) ; $ ufservice -> delete_favourite ( 'core_message' , 'message_conversations' , $ conversationid , $ conversationctx ) ; }
docstring: Unset a conversation as a favourite for the given user.
  
  @param int $conversationid the id of the conversation to unset as a favourite.
  @param int $userid the id to whom the favourite belongs.
  @throws \moodle_exception if the favourite does not exist for the user.
docstring_tokens: Unset a conversation as a favourite for the given user .