original_string: function send_message($eventdata){
          global $CFG;
  
          // Skip any messaging of suspended and deleted users.
          if ($eventdata->userto->auth === 'nologin' or $eventdata->userto->suspended or $eventdata->userto->deleted) {
              return true;
          }
  
          if (!empty($CFG->noemailever)) {
              // hidden setting for development sites, set in config.php if needed
              debugging('$CFG->noemailever is active, no jabber message sent.', DEBUG_MINIMAL);
              return true;
          }
  
          if (PHPUNIT_TEST) {
              // No connection to external servers allowed in phpunit tests.
              return true;
          }
  
          //hold onto jabber id preference because /admin/cron.php sends a lot of messages at once
          static $jabberaddresses = array();
  
          if (!array_key_exists($eventdata->userto->id, $jabberaddresses)) {
              $jabberaddresses[$eventdata->userto->id] = get_user_preferences('message_processor_jabber_jabberid', null, $eventdata->userto->id);
          }
          $jabberaddress = $jabberaddresses[$eventdata->userto->id];
  
          //calling s() on smallmessage causes Jabber to display things like &lt; Jabber != a browser
          $jabbermessage = fullname($eventdata->userfrom).': '.$eventdata->smallmessage;
  
          if (!empty($eventdata->contexturl)) {
              $jabbermessage .= "\n".get_string('view').': '.$eventdata->contexturl;
          }
  
          $jabbermessage .= "\n(".get_string('noreply','message').')';
  
          $conn = new XMPPHP_XMPP($CFG->jabberhost,$CFG->jabberport,$CFG->jabberusername,$CFG->jabberpassword,'moodle',$CFG->jabberserver);
  
          // No need to track the presence during the sending message process.
          $conn->track_presence = false;
  
          try {
              //$conn->useEncryption(false);
              $conn->connect();
              $conn->processUntil('session_start');
              $conn->presence();
              $conn->message($jabberaddress, $jabbermessage);
              $conn->disconnect();
          } catch(XMPPHP_Exception $e) {
              debugging($e->getMessage());
              return false;
          }
          return true;
      }
code: function send_message($eventdata){
          global $CFG;
  
          // Skip any messaging of suspended and deleted users.
          if ($eventdata->userto->auth === 'nologin' or $eventdata->userto->suspended or $eventdata->userto->deleted) {
              return true;
          }
  
          if (!empty($CFG->noemailever)) {
              // hidden setting for development sites, set in config.php if needed
              debugging('$CFG->noemailever is active, no jabber message sent.', DEBUG_MINIMAL);
              return true;
          }
  
          if (PHPUNIT_TEST) {
              // No connection to external servers allowed in phpunit tests.
              return true;
          }
  
          //hold onto jabber id preference because /admin/cron.php sends a lot of messages at once
          static $jabberaddresses = array();
  
          if (!array_key_exists($eventdata->userto->id, $jabberaddresses)) {
              $jabberaddresses[$eventdata->userto->id] = get_user_preferences('message_processor_jabber_jabberid', null, $eventdata->userto->id);
          }
          $jabberaddress = $jabberaddresses[$eventdata->userto->id];
  
          //calling s() on smallmessage causes Jabber to display things like &lt; Jabber != a browser
          $jabbermessage = fullname($eventdata->userfrom).': '.$eventdata->smallmessage;
  
          if (!empty($eventdata->contexturl)) {
              $jabbermessage .= "\n".get_string('view').': '.$eventdata->contexturl;
          }
  
          $jabbermessage .= "\n(".get_string('noreply','message').')';
  
          $conn = new XMPPHP_XMPP($CFG->jabberhost,$CFG->jabberport,$CFG->jabberusername,$CFG->jabberpassword,'moodle',$CFG->jabberserver);
  
          // No need to track the presence during the sending message process.
          $conn->track_presence = false;
  
          try {
              //$conn->useEncryption(false);
              $conn->connect();
              $conn->processUntil('session_start');
              $conn->presence();
              $conn->message($jabberaddress, $jabbermessage);
              $conn->disconnect();
          } catch(XMPPHP_Exception $e) {
              debugging($e->getMessage());
              return false;
          }
          return true;
      }
code_tokens: function send_message ( $ eventdata ) { global $ CFG ; // Skip any messaging of suspended and deleted users. if ( $ eventdata -> userto -> auth === 'nologin' or $ eventdata -> userto -> suspended or $ eventdata -> userto -> deleted ) { return true ; } if ( ! empty ( $ CFG -> noemailever ) ) { // hidden setting for development sites, set in config.php if needed debugging ( '$CFG->noemailever is active, no jabber message sent.' , DEBUG_MINIMAL ) ; return true ; } if ( PHPUNIT_TEST ) { // No connection to external servers allowed in phpunit tests. return true ; } //hold onto jabber id preference because /admin/cron.php sends a lot of messages at once static $ jabberaddresses = array ( ) ; if ( ! array_key_exists ( $ eventdata -> userto -> id , $ jabberaddresses ) ) { $ jabberaddresses [ $ eventdata -> userto -> id ] = get_user_preferences ( 'message_processor_jabber_jabberid' , null , $ eventdata -> userto -> id ) ; } $ jabberaddress = $ jabberaddresses [ $ eventdata -> userto -> id ] ; //calling s() on smallmessage causes Jabber to display things like &lt; Jabber != a browser $ jabbermessage = fullname ( $ eventdata -> userfrom ) . ': ' . $ eventdata -> smallmessage ; if ( ! empty ( $ eventdata -> contexturl ) ) { $ jabbermessage .= "\n" . get_string ( 'view' ) . ': ' . $ eventdata -> contexturl ; } $ jabbermessage .= "\n(" . get_string ( 'noreply' , 'message' ) . ')' ; $ conn = new XMPPHP_XMPP ( $ CFG -> jabberhost , $ CFG -> jabberport , $ CFG -> jabberusername , $ CFG -> jabberpassword , 'moodle' , $ CFG -> jabberserver ) ; // No need to track the presence during the sending message process. $ conn -> track_presence = false ; try { //$conn->useEncryption(false); $ conn -> connect ( ) ; $ conn -> processUntil ( 'session_start' ) ; $ conn -> presence ( ) ; $ conn -> message ( $ jabberaddress , $ jabbermessage ) ; $ conn -> disconnect ( ) ; } catch ( XMPPHP_Exception $ e ) { debugging ( $ e -> getMessage ( ) ) ; return false ; } return true ; }
docstring: Processes the message and sends a notification via jabber
  
  @param stdClass $eventdata the event data submitted by the message sender plus $eventdata->savedmessageid
  @return true if ok, false if error
docstring_tokens: Processes the message and sends a notification via jabber