You are here

private function Cleantalk::createMsg in Anti Spam by CleanTalk 7.2

Same name and namespace in other branches
  1. 7.5 src/Cleantalk.php \Cleantalk::createMsg()
  2. 7 cleantalk.module \Cleantalk::createMsg()
  3. 7.4 src/Cleantalk.php \Cleantalk::createMsg()

Create msg for cleantalk server

Parameters

type $method:

CleantalkRequest $request:

Return value

\xmlrpcmsg

3 calls to Cleantalk::createMsg()
Cleantalk::isAllowMessage in ./cleantalk.module
Function checks whether it is possible to publish the message
Cleantalk::isAllowUser in ./cleantalk.module
Function checks whether it is possible to publish the message
Cleantalk::sendFeedback in ./cleantalk.module
Function sends the results of manual moderation

File

./cleantalk.module, line 720
Main CleanTalk integration module functions.

Class

Cleantalk
Cleantalk class create request

Code

private function createMsg($method, CleantalkRequest $request) {
  switch ($method) {
    case 'check_message':

      // Convert strings to UTF8
      $request->message = $this
        ->stringToUTF8($request->message, $this->data_codepage);
      $request->example = $this
        ->stringToUTF8($request->example, $this->data_codepage);
      $request->sender_email = $this
        ->stringToUTF8($request->sender_email, $this->data_codepage);
      $request->sender_nickname = $this
        ->stringToUTF8($request->sender_nickname, $this->data_codepage);
      $request->message = $this
        ->compressData($request->message);
      $request->example = $this
        ->compressData($request->example);
      break;
    case 'check_newuser':

      // Convert strings to UTF8
      $request->sender_email = $this
        ->stringToUTF8($request->sender_email, $this->data_codepage);
      $request->sender_nickname = $this
        ->stringToUTF8($request->sender_nickname, $this->data_codepage);
      break;
    case 'send_feedback':
      if (is_array($request->feedback)) {
        $request->feedback = implode(';', $request->feedback);
      }
      break;
  }
  $request->method_name = $method;

  //
  // Removing non UTF8 characters from request, because non UTF8 or malformed characters break json_encode().
  //
  foreach ($request as $param => $value) {
    if (!preg_match('//u', $value)) {
      $request->{$param} = 'Nulled. Not UTF8 encoded or malformed.';
    }
  }
  return $request;
}