Exemplo n.º 1
0
 /**
  * WiseChatStatsShortcode constructor.
  */
 public function __construct()
 {
     $this->options = WiseChatOptions::getInstance();
     $this->service = WiseChatContainer::get('services/WiseChatService');
     $this->messagesService = WiseChatContainer::get('services/WiseChatMessagesService');
     $this->channelsDAO = WiseChatContainer::get('dao/WiseChatChannelsDAO');
     $this->renderer = WiseChatContainer::get('rendering/WiseChatRenderer');
 }
Exemplo n.º 2
0
 public function __construct()
 {
     WiseChatContainer::load('model/WiseChatMessage');
     WiseChatContainer::load('dao/criteria/WiseChatMessagesCriteria');
     $this->usersDAO = WiseChatContainer::get('dao/user/WiseChatUsersDAO');
     $this->channelsDAO = WiseChatContainer::get('dao/WiseChatChannelsDAO');
     $this->channelUsersDAO = WiseChatContainer::get('dao/WiseChatChannelUsersDAO');
     $this->table = WiseChatInstaller::getMessagesTable();
 }
Exemplo n.º 3
0
 public function __construct()
 {
     WiseChatContainer::load('model/WiseChatChannel');
     $this->options = WiseChatOptions::getInstance();
     $this->channelsDAO = WiseChatContainer::get('dao/WiseChatChannelsDAO');
     $this->usersDAO = WiseChatContainer::get('dao/user/WiseChatUsersDAO');
     $this->channelUsersDAO = WiseChatContainer::get('dao/WiseChatChannelUsersDAO');
     $this->userService = WiseChatContainer::get('services/user/WiseChatUserService');
     $this->authentication = WiseChatContainer::getLazy('services/user/WiseChatAuthentication');
     $this->authorization = WiseChatContainer::getLazy('services/user/WiseChatAuthorization');
 }
Exemplo n.º 4
0
 public function __construct()
 {
     $this->options = WiseChatOptions::getInstance();
     $this->channelsDAO = WiseChatContainer::get('dao/WiseChatChannelsDAO');
     $this->bansDAO = WiseChatContainer::get('dao/WiseChatBansDAO');
     $this->usersDAO = WiseChatContainer::get('dao/user/WiseChatUsersDAO');
     $this->messagesDAO = WiseChatContainer::get('dao/WiseChatMessagesDAO');
     $this->filtersDAO = WiseChatContainer::get('dao/WiseChatFiltersDAO');
     $this->actions = WiseChatContainer::getLazy('services/user/WiseChatActions');
     $this->bansService = WiseChatContainer::get('services/WiseChatBansService');
     $this->messagesService = WiseChatContainer::get('services/WiseChatMessagesService');
 }
Exemplo n.º 5
0
 /**
  * @param WiseChatChannel $channel
  * @param array $arguments
  */
 public function __construct($channel, $arguments)
 {
     $this->messagesDAO = WiseChatContainer::get('dao/WiseChatMessagesDAO');
     $this->bansDAO = WiseChatContainer::get('dao/WiseChatBansDAO');
     $this->usersDAO = WiseChatContainer::get('dao/user/WiseChatUsersDAO');
     $this->channelUsersDAO = WiseChatContainer::get('dao/WiseChatChannelUsersDAO');
     $this->authentication = WiseChatContainer::getLazy('services/user/WiseChatAuthentication');
     $this->bansService = WiseChatContainer::get('services/WiseChatBansService');
     $this->messagesService = WiseChatContainer::get('services/WiseChatMessagesService');
     $this->arguments = $arguments;
     $this->channel = $channel;
 }
Exemplo n.º 6
0
 /**
  * Detects URLs in the text and converts them into shortcodes indicating either regular links or images.
  *
  * @param string $text HTML-encoded string
  * @param boolean $detectAndDownloadImages Whether to check and download images
  * @param boolean $detectYouTubeVideos
  *
  * @return string
  */
 public function filter($text, $detectAndDownloadImages, $detectYouTubeVideos = false)
 {
     $this->replacementOffset = 0;
     $this->createdAttachments = array();
     if (preg_match_all(self::URL_REGEXP, $text, $matches)) {
         if (count($matches) == 0) {
             return $text;
         }
         foreach ($matches[0] as $detectedURL) {
             $shortCode = null;
             $regularLink = false;
             $ytMatches = array();
             if ($detectAndDownloadImages && preg_match(self::URL_IMAGE_REGEXP, $detectedURL)) {
                 $imageUrl = $detectedURL;
                 if (!preg_match(self::URL_PROTOCOLS_REGEXP, $detectedURL)) {
                     $imageUrl = "http://" . $detectedURL;
                 }
                 try {
                     $result = $this->imagesService->downloadImage($imageUrl);
                     $this->createdAttachments[] = $result['id'];
                     $shortCode = WiseChatShortcodeConstructor::getImageShortcode($result['id'], $result['image'], $result['image-th'], $detectedURL);
                 } catch (Exception $ex) {
                     $regularLink = true;
                     $actions = WiseChatContainer::get('services/user/WiseChatActions');
                     $authentication = WiseChatContainer::get('services/user/WiseChatAuthentication');
                     $actions->publishAction('showErrorMessage', array('message' => $ex->getMessage()), $authentication->getUser());
                 }
             } elseif ($detectYouTubeVideos && preg_match(self::URL_YOUTUBE_REGEXP, $detectedURL, $ytMatches)) {
                 $movieId = array_pop($ytMatches);
                 $shortCode = WiseChatShortcodeConstructor::getYouTubeShortcode($movieId, $detectedURL);
             } elseif ($detectYouTubeVideos && preg_match(self::URL_YOUTUBE_REGEXP_2, $detectedURL, $ytMatches)) {
                 $movieId = array_pop($ytMatches);
                 $shortCode = WiseChatShortcodeConstructor::getYouTubeShortcode($movieId, $detectedURL);
             } else {
                 $regularLink = true;
             }
             if ($regularLink) {
                 $shortCode = sprintf('[link src="%s"]', $detectedURL);
             }
             if ($shortCode !== null) {
                 $text = $this->strReplaceFirst($detectedURL, $shortCode, $text);
             }
         }
     }
     return $text;
 }
Exemplo n.º 7
0
 public function widget($args, $instance)
 {
     extract($args, EXTR_SKIP);
     echo $before_widget;
     $wiseChat = WiseChatContainer::get('WiseChat');
     $channel = $instance['channel'];
     $options = $instance['options'];
     $parsedOptions = shortcode_parse_atts($options);
     if (is_array($parsedOptions)) {
         $parsedOptions['channel'] = $channel;
         echo $wiseChat->getRenderedShortcode($parsedOptions);
     } else {
         echo $wiseChat->getRenderedChat($channel);
     }
     echo $after_widget;
     $wiseChat->registerResources();
 }
Exemplo n.º 8
0
 /**
  * Method loads all user-defined filters and applies them to the given text.
  *
  * @param string $text A text to filter
  * @return string
  */
 public function filter($text)
 {
     $filtersChain = WiseChatContainer::get('dao/WiseChatFiltersDAO')->getAll();
     foreach ($filtersChain as $filter) {
         $type = $filter['type'];
         $replace = $filter['replace'];
         $replaceWith = $filter['with'];
         if ($type == 'text') {
             $text = str_replace($replace, $replaceWith, $text);
         } else {
             $matches = array();
             $replace = '/' . $replace . '/i';
             if (preg_match_all($replace, $text, $matches)) {
                 foreach ($matches[0] as $value) {
                     $text = self::strReplaceFirst($value, $replaceWith, $text);
                 }
             }
         }
     }
     return $text;
 }
Exemplo n.º 9
0
 public function __construct()
 {
     $this->options = WiseChatOptions::getInstance();
     $this->usersDAO = WiseChatContainer::get('dao/user/WiseChatUsersDAO');
     $this->userSettingsDAO = WiseChatContainer::get('dao/user/WiseChatUserSettingsDAO');
     $this->channelUsersDAO = WiseChatContainer::get('dao/WiseChatChannelUsersDAO');
     $this->actionsDAO = WiseChatContainer::get('dao/WiseChatActionsDAO');
     $this->renderer = WiseChatContainer::get('rendering/WiseChatRenderer');
     $this->cssRenderer = WiseChatContainer::get('rendering/WiseChatCssRenderer');
     $this->bansService = WiseChatContainer::get('services/WiseChatBansService');
     $this->userService = WiseChatContainer::get('services/user/WiseChatUserService');
     $this->messagesService = WiseChatContainer::get('services/WiseChatMessagesService');
     $this->service = WiseChatContainer::get('services/WiseChatService');
     $this->attachmentsService = WiseChatContainer::get('services/WiseChatAttachmentsService');
     $this->authentication = WiseChatContainer::getLazy('services/user/WiseChatAuthentication');
     WiseChatContainer::load('WiseChatCrypt');
     WiseChatContainer::load('WiseChatThemes');
     WiseChatContainer::load('rendering/WiseChatTemplater');
     $this->userService->initMaintenance();
     $this->shortCodeOptions = array();
 }
Exemplo n.º 10
0
require_once ABSPATH . WPINC . '/rewrite.php';
require_once ABSPATH . WPINC . '/author-template.php';
requireIfExists('class-wp-rewrite.php');
requireIfExists('rest-api.php');
require_once ABSPATH . WPINC . '/rewrite.php';
require_once ABSPATH . WPINC . '/kses.php';
require_once ABSPATH . WPINC . '/revision.php';
require_once ABSPATH . WPINC . '/capabilities.php';
requireIfExists('class-wp-roles.php');
requireIfExists('class-wp-role.php');
require_once ABSPATH . WPINC . '/pluggable.php';
require_once ABSPATH . WPINC . '/pluggable-deprecated.php';
requireIfExists('class-wp-user.php');
requireIfExists('class-wp-user-query.php');
$GLOBALS['wp_rewrite'] = new WP_Rewrite();
// NOTICE: hack for warning in plugin_basename() function:
$wp_plugin_paths = array();
wp_plugin_directory_constants();
wp_cookie_constants();
// removing images downloaded by the chat:
$wiseChatImagesService = WiseChatContainer::get('services/WiseChatImagesService');
add_action('delete_attachment', array($wiseChatImagesService, 'removeRelatedImages'));
$actionsMap = array('wise_chat_messages_endpoint' => 'messagesEndpoint', 'wise_chat_message_endpoint' => 'messageEndpoint', 'wise_chat_delete_message_endpoint' => 'messageDeleteEndpoint', 'wise_chat_user_ban_endpoint' => 'userBanEndpoint', 'wise_chat_maintenance_endpoint' => 'maintenanceEndpoint', 'wise_chat_settings_endpoint' => 'settingsEndpoint', 'wise_chat_prepare_image_endpoint' => 'prepareImageEndpoint');
$wiseChatEndpoints = WiseChatContainer::get('endpoints/WiseChatEndpoints');
$action = $_REQUEST['action'];
if (array_key_exists($action, $actionsMap)) {
    $method = $actionsMap[$action];
    $wiseChatEndpoints->{$method}();
} else {
    header('HTTP/1.0 400 Bad Request');
}
Exemplo n.º 11
0
 /**
  * WiseChatActions constructor.
  */
 public function __construct()
 {
     $this->actionsDAO = WiseChatContainer::get('dao/WiseChatActionsDAO');
 }
Exemplo n.º 12
0
 public function __construct()
 {
     $this->usersDAO = WiseChatContainer::get('dao/user/WiseChatUsersDAO');
     $this->messagesService = WiseChatContainer::get('services/WiseChatMessagesService');
 }
Exemplo n.º 13
0
 /**
  * Returns an instance of the requested tab object.
  *
  * @param string $tabKey A key from $this->tabs array
  *
  * @return WiseChatAbstractTab
  */
 private function getTabObject($tabKey)
 {
     $tabKey = ucfirst(str_replace('wise-chat-', '', $tabKey));
     $classPathAndName = "admin/WiseChat{$tabKey}Tab";
     return WiseChatContainer::get($classPathAndName);
 }
Exemplo n.º 14
0
 /**
  * Proxy method.
  *
  * @param string $name
  * @param mixed $arguments
  * @return mixed
  */
 public function __call($name, $arguments)
 {
     if ($this->targetClassObject === null) {
         $this->targetClassObject = WiseChatContainer::get($this->targetClassPathAndName);
     }
     return call_user_func_array(array($this->targetClassObject, $name), $arguments);
 }
Exemplo n.º 15
0
 /**
  * Publishes a message in the given channel of the chat and returns it.
  *
  * @param WiseChatUser $user Author of the message
  * @param WiseChatChannel $channel A channel to publish in
  * @param string $text Content of the message
  * @param boolean $isAdmin Indicates whether to mark the message as admin-owned
  *
  * @return WiseChatMessage|null
  * @throws Exception On validation error
  */
 public function addMessage($user, $channel, $text, $isAdmin = false)
 {
     $text = trim($text);
     $filteredMessage = $text;
     // basic validation:
     if ($user === null) {
         throw new Exception('User cannot be null');
     }
     if ($channel === null) {
         throw new Exception('Channel cannot be null');
     }
     if ($this->bansService->isIpAddressBanned($user->getIp())) {
         throw new Exception($this->options->getOption('message_error_3', 'You were banned from posting messages'));
     }
     // use bad words filtering:
     if ($this->options->isOptionEnabled('filter_bad_words')) {
         WiseChatContainer::load('rendering/filters/pre/WiseChatFilter');
         $badWordsFilterReplacement = $this->options->getOption('bad_words_replacement_text');
         $filteredMessage = WiseChatFilter::filter($filteredMessage, strlen($badWordsFilterReplacement) > 0 ? $badWordsFilterReplacement : null);
     }
     // auto-ban feature:
     if ($this->options->isOptionEnabled('enable_autoban') && $filteredMessage != $text) {
         $counter = $this->abuses->incrementAndGetAbusesCounter();
         $threshold = $this->options->getIntegerOption('autoban_threshold', 3);
         if ($counter >= $threshold && $threshold > 0) {
             $duration = $this->options->getIntegerOption('autoban_duration', 1440);
             $this->bansService->banIpAddress($user->getIp(), $this->bansService->getDurationFromString($duration . 'm'));
             $this->abuses->clearAbusesCounter();
         }
     }
     // flood prevention feature:
     if ($this->options->isOptionEnabled('enable_flood_control')) {
         $floodControlThreshold = $this->options->getIntegerOption('flood_control_threshold', 200);
         $floodControlTimeFrame = $this->options->getIntegerOption('flood_control_time_frame', 1);
         if ($floodControlThreshold > 0 && $floodControlTimeFrame > 0) {
             $messagesAmount = $this->messagesDAO->getNumberByCriteria(WiseChatMessagesCriteria::build()->setIp($user->getIp())->setMinimumTime(time() - $floodControlTimeFrame * 60));
             if ($messagesAmount > $floodControlThreshold) {
                 $duration = $this->options->getIntegerOption('flood_control_ban_duration', 1440);
                 $this->bansService->banIpAddress($user->getIp(), $this->bansService->getDurationFromString($duration . 'm'));
             }
         }
     }
     // go through the custom filters:
     $filterChain = WiseChatContainer::get('services/WiseChatFilterChain');
     $filteredMessage = $filterChain->filter($filteredMessage);
     // cut the message:
     $messageMaxLength = $this->options->getIntegerOption('message_max_length', 100);
     if ($messageMaxLength > 0) {
         $filteredMessage = substr($filteredMessage, 0, $messageMaxLength);
     }
     // convert images and links into proper shortcodes and download images (if enabled):
     /** @var WiseChatLinksPreFilter $linksPreFilter */
     $linksPreFilter = WiseChatContainer::get('rendering/filters/pre/WiseChatLinksPreFilter');
     $filteredMessage = $linksPreFilter->filter($filteredMessage, $this->options->isOptionEnabled('allow_post_images'), $this->options->isOptionEnabled('enable_youtube'));
     $message = new WiseChatMessage();
     $message->setTime(time());
     $message->setAdmin($isAdmin);
     $message->setUserName($user->getName());
     $message->setUserId($user->getId());
     $message->setText($filteredMessage);
     $message->setChannelName($channel->getName());
     $message->setIp($user->getIp());
     if ($user->getWordPressId() !== null) {
         $message->setWordPressUserId($user->getWordPressId());
     }
     $message = $this->messagesDAO->save($message);
     // mark attachments created by the links pre-filter:
     $createdAttachments = $linksPreFilter->getCreatedAttachments();
     if (count($createdAttachments) > 0) {
         $this->attachmentsService->markAttachmentsWithDetails($createdAttachments, $channel->getName(), $message->getId());
     }
     return $message;
 }
Exemplo n.º 16
0
 public static function uninstall()
 {
     if (!current_user_can('activate_plugins')) {
         return;
     }
     check_admin_referer('bulk-plugins');
     global $wpdb;
     // remove all messages and related images:
     /** @var WiseChatMessagesService $messagesService */
     $messagesService = WiseChatContainer::get('services/WiseChatMessagesService');
     $messagesService->deleteAll();
     $tableName = self::getMessagesTable();
     $sql = "DROP TABLE IF EXISTS {$tableName};";
     $wpdb->query($sql);
     $tableName = self::getBansTable();
     $sql = "DROP TABLE IF EXISTS {$tableName};";
     $wpdb->query($sql);
     $tableName = self::getActionsTable();
     $sql = "DROP TABLE IF EXISTS {$tableName};";
     $wpdb->query($sql);
     $tableName = self::getChannelUsersTable();
     $sql = "DROP TABLE IF EXISTS {$tableName};";
     $wpdb->query($sql);
     $tableName = self::getChannelsTable();
     $sql = "DROP TABLE IF EXISTS {$tableName};";
     $wpdb->query($sql);
     $tableName = self::getUsersTable();
     $sql = "DROP TABLE IF EXISTS {$tableName};";
     $wpdb->query($sql);
     WiseChatOptions::getInstance()->dropAllOptions();
 }
Exemplo n.º 17
0
 /**
  * @param WiseChatUser $user
  */
 private function fillWithGeoDetails($user)
 {
     /** @var WiseChatGeoService $geoService */
     $geoService = WiseChatContainer::get('services/WiseChatGeoService');
     $geoDetails = $geoService->getGeoDetails($this->getRemoteAddress());
     if ($geoDetails !== null) {
         $geoDetailsArray = $geoDetails->toArray();
         foreach ($geoDetailsArray as $key => $value) {
             $user->setDataProperty($key, $value);
         }
     }
 }
Exemplo n.º 18
0
 /**
  * Endpoint that prepares an image for further upload: 
  * - basic checks
  * - resizing
  * - fixing orientation
  *
  * @notice GIFs are returned unchanged because of the lack of proper resizing abilities
  *
  * @return null
  */
 public function prepareImageEndpoint()
 {
     $this->verifyCheckSum();
     try {
         $this->checkChatOpen();
         $this->checkUserAuthentication();
         $this->checkUserAuthorization();
         $this->checkUserWriteAuthorization();
         $this->checkPostParams(array('data'));
         $data = $this->getPostParam('data');
         $imagesService = WiseChatContainer::get('services/WiseChatImagesService');
         $decodedImageData = $imagesService->decodePrefixedBase64ImageData($data);
         if ($decodedImageData['mimeType'] == 'image/gif') {
             echo $data;
         } else {
             $preparedImageData = $imagesService->getPreparedImage($decodedImageData['data']);
             echo $imagesService->encodeBase64WithPrefix($preparedImageData, $decodedImageData['mimeType']);
         }
     } catch (WiseChatUnauthorizedAccessException $exception) {
         echo json_encode(array('error' => $exception->getMessage()));
         $this->sendUnauthorizedStatus();
     } catch (Exception $exception) {
         echo json_encode(array('error' => $exception->getMessage()));
         $this->sendBadRequestStatus();
     }
     die;
 }
Exemplo n.º 19
0
 /**
  * Returns information about the image stored in the temporary file.
  * If the file is not an image an exception is thrown.
  *
  * @param boolean $safeResize
  *
  * @return array
  * @throws \Exception
  */
 private function getTempFileImageInfo($safeResize)
 {
     $fileInfo = file_exists($this->tempFileName) ? getimagesize($this->tempFileName) : null;
     if (is_array($fileInfo)) {
         $mimeType = $fileInfo['mime'];
         if (!array_key_exists($mimeType, $this->supportedExtensions)) {
             $this->logError('Unsupported mime type: ' . $mimeType);
             throw new Exception($this->options->getEncodedOption('message_error_7', 'Unsupported type of file'));
         }
         $fileName = date('Ymd-His') . '-' . uniqid(rand()) . '.' . $this->supportedExtensions[$mimeType];
         if ($safeResize) {
             $imageEditor = WiseChatContainer::get('services/WiseChatImageEditor');
             $imageEditor->load($this->tempFileName);
             $imageEditor->resize($this->options->getIntegerOption('images_width_limit', 1000), $this->options->getIntegerOption('images_height_limit', 1000));
             $imageEditor->build();
         }
         return $_FILES[self::UPLOAD_FILE_NAME] = array('name' => $fileName, 'type' => $mimeType, 'tmp_name' => $this->tempFileName, 'error' => 0, 'size' => filesize($this->tempFileName));
     }
     $this->logError('The file is not an image');
     throw new Exception($this->options->getEncodedOption('message_error_7', 'Unsupported type of file'));
 }
Exemplo n.º 20
0
 /**
  * Returns rendered message content.
  *
  * @param WiseChatMessage $message
  *
  * @return string HTML source
  */
 private function getRenderedMessageContent($message)
 {
     $formattedMessage = htmlspecialchars($message->getText(), ENT_QUOTES, 'UTF-8');
     /** @var WiseChatLinksPostFilter $linksFilter */
     $linksFilter = WiseChatContainer::get('rendering/filters/post/WiseChatLinksPostFilter');
     $formattedMessage = $linksFilter->filter($formattedMessage, $this->options->isOptionEnabled('allow_post_links'));
     /** @var WiseChatAttachmentsPostFilter $attachmentsFilter */
     $attachmentsFilter = WiseChatContainer::get('rendering/filters/post/WiseChatAttachmentsPostFilter');
     $formattedMessage = $attachmentsFilter->filter($formattedMessage, $this->options->isOptionEnabled('enable_attachments_uploader'), $this->options->isOptionEnabled('allow_post_links'));
     /** @var WiseChatImagesPostFilter $imagesFilter */
     $imagesFilter = WiseChatContainer::get('rendering/filters/post/WiseChatImagesPostFilter');
     $formattedMessage = $imagesFilter->filter($formattedMessage, $this->options->isOptionEnabled('allow_post_images'), $this->options->isOptionEnabled('allow_post_links'));
     /** @var WiseChatYouTubePostFilter $youTubeFilter */
     $youTubeFilter = WiseChatContainer::get('rendering/filters/post/WiseChatYouTubePostFilter');
     $formattedMessage = $youTubeFilter->filter($formattedMessage, $this->options->isOptionEnabled('enable_youtube'), $this->options->isOptionEnabled('allow_post_links'), $this->options->getIntegerOption('youtube_width', 186), $this->options->getIntegerOption('youtube_height', 105));
     if ($this->options->isOptionEnabled('enable_twitter_hashtags')) {
         /** @var WiseChatHashtagsPostFilter $hashTagsFilter */
         $hashTagsFilter = WiseChatContainer::get('rendering/filters/post/WiseChatHashtagsPostFilter');
         $formattedMessage = $hashTagsFilter->filter($formattedMessage);
     }
     if ($this->options->isOptionEnabled('emoticons_enabled', true)) {
         /** @var WiseChatEmoticonsFilter $emoticonsFilter */
         $emoticonsFilter = WiseChatContainer::get('rendering/filters/post/WiseChatEmoticonsFilter');
         $formattedMessage = $emoticonsFilter->filter($formattedMessage);
     }
     if ($this->options->isOptionEnabled('multiline_support')) {
         $formattedMessage = str_replace("\n", '<br />', $formattedMessage);
     }
     return $formattedMessage;
 }
Exemplo n.º 21
0
function wise_chat_endpoint_prepare_image()
{
    $wiseChatEndpoints = WiseChatContainer::get('endpoints/WiseChatEndpoints');
    $wiseChatEndpoints->prepareImageEndpoint();
}
Exemplo n.º 22
0
 /**
  * Refreshes username after setting a new one.
  *
  * @param WiseChatUser $user
  *
  * @return null
  */
 private function refreshNewUserName($user)
 {
     WiseChatContainer::load('dao/criteria/WiseChatMessagesCriteria');
     $this->refreshUserName($user);
     $this->messagesDAO->updateUserNameByCriteria($user->getName(), WiseChatMessagesCriteria::build()->setUserId($user->getId()));
     /** @var WiseChatRenderer $renderer */
     $renderer = WiseChatContainer::get('rendering/WiseChatRenderer');
     $criteria = new WiseChatMessagesCriteria();
     $criteria->setUserId($user->getId());
     $messages = $this->messagesDAO->getAllByCriteria($criteria);
     if (count($messages) > 0) {
         $messagesIds = array();
         $renderedUserName = null;
         foreach ($messages as $message) {
             $messagesIds[] = $message->getId();
             if ($renderedUserName === null) {
                 $renderedUserName = $renderer->getRenderedUserName($message);
             }
         }
         $this->actions->publishAction('replaceUserNameInMessages', array('renderedUserName' => $renderedUserName, 'messagesIds' => $messagesIds));
     }
 }