original_string: public static function can_create_contact(int $userid, int $requesteduserid) : bool {
          global $CFG;
  
          // If we can't message at all, then we can't create a contact.
          if (empty($CFG->messaging)) {
              return false;
          }
  
          // If we can message anyone on the site then we can create a contact.
          if ($CFG->messagingallusers) {
              return true;
          }
  
          // We need to check if they are in the same course.
          return enrol_sharing_course($userid, $requesteduserid);
      }
code: public static function can_create_contact(int $userid, int $requesteduserid) : bool {
          global $CFG;
  
          // If we can't message at all, then we can't create a contact.
          if (empty($CFG->messaging)) {
              return false;
          }
  
          // If we can message anyone on the site then we can create a contact.
          if ($CFG->messagingallusers) {
              return true;
          }
  
          // We need to check if they are in the same course.
          return enrol_sharing_course($userid, $requesteduserid);
      }
code_tokens: public static function can_create_contact ( int $ userid , int $ requesteduserid ) : bool { global $ CFG ; // If we can't message at all, then we can't create a contact. if ( empty ( $ CFG -> messaging ) ) { return false ; } // If we can message anyone on the site then we can create a contact. if ( $ CFG -> messagingallusers ) { return true ; } // We need to check if they are in the same course. return enrol_sharing_course ( $ userid , $ requesteduserid ) ; }
docstring: Checks if a user can create a contact request.
  
  @param int $userid The id of the user who is creating the contact request
  @param int $requesteduserid The id of the user being requested
  @return bool
docstring_tokens: Checks if a user can create a contact request .