original_string: public static function send_message(message $eventdata, \stdClass $savemessage, array $processorlist) {
          global $CFG;
  
          require_once($CFG->dirroot.'/message/lib.php'); // This is most probably already included from messagelib.php file.
  
          if (empty($processorlist)) {
              // Trigger event for sending a message or notification - we need to do this before marking as read!
              self::trigger_message_events($eventdata, $savemessage);
  
              if ($eventdata->notification or empty($CFG->messaging)) {
                  // If they have deselected all processors and its a notification mark it read. The user doesn't want to be bothered.
                  // The same goes if the messaging is completely disabled.
                  if ($eventdata->notification) {
                      $savemessage->timeread = null;
                      \core_message\api::mark_notification_as_read($savemessage);
                  } else {
                      \core_message\api::mark_message_as_read($eventdata->userto->id, $savemessage);
                  }
              }
  
              return $savemessage->id;
          }
  
          // Let the manager do the sending or buffering when db transaction in progress.
          return self::send_message_to_processors($eventdata, $savemessage, $processorlist);
      }
code: public static function send_message(message $eventdata, \stdClass $savemessage, array $processorlist) {
          global $CFG;
  
          require_once($CFG->dirroot.'/message/lib.php'); // This is most probably already included from messagelib.php file.
  
          if (empty($processorlist)) {
              // Trigger event for sending a message or notification - we need to do this before marking as read!
              self::trigger_message_events($eventdata, $savemessage);
  
              if ($eventdata->notification or empty($CFG->messaging)) {
                  // If they have deselected all processors and its a notification mark it read. The user doesn't want to be bothered.
                  // The same goes if the messaging is completely disabled.
                  if ($eventdata->notification) {
                      $savemessage->timeread = null;
                      \core_message\api::mark_notification_as_read($savemessage);
                  } else {
                      \core_message\api::mark_message_as_read($eventdata->userto->id, $savemessage);
                  }
              }
  
              return $savemessage->id;
          }
  
          // Let the manager do the sending or buffering when db transaction in progress.
          return self::send_message_to_processors($eventdata, $savemessage, $processorlist);
      }
code_tokens: public static function send_message ( message $ eventdata , \ stdClass $ savemessage , array $ processorlist ) { global $ CFG ; require_once ( $ CFG -> dirroot . '/message/lib.php' ) ; // This is most probably already included from messagelib.php file. if ( empty ( $ processorlist ) ) { // Trigger event for sending a message or notification - we need to do this before marking as read! self :: trigger_message_events ( $ eventdata , $ savemessage ) ; if ( $ eventdata -> notification or empty ( $ CFG -> messaging ) ) { // If they have deselected all processors and its a notification mark it read. The user doesn't want to be bothered. // The same goes if the messaging is completely disabled. if ( $ eventdata -> notification ) { $ savemessage -> timeread = null ; \ core_message \ api :: mark_notification_as_read ( $ savemessage ) ; } else { \ core_message \ api :: mark_message_as_read ( $ eventdata -> userto -> id , $ savemessage ) ; } } return $ savemessage -> id ; } // Let the manager do the sending or buffering when db transaction in progress. return self :: send_message_to_processors ( $ eventdata , $ savemessage , $ processorlist ) ; }
docstring: Do the message sending.
  
  NOTE: to be used from message_send() only.
  
  @param \core\message\message $eventdata fully prepared event data for processors
  @param \stdClass $savemessage the message saved in 'message' table
  @param array $processorlist list of processors for target user
  @return int $messageid the id from 'messages' (false is not returned)
docstring_tokens: Do the message sending .