<div class="message_block">
    <div class="message_block-user">
        <div class="pull-left"><?php echo $data->type > 0 ? '['.FuncHelper::time($data->time).']' : '';?> <span class="user-login"><?php echo Users::getLoginWithLink($data->id_user); ?></span>:</div>
        <div class="pull-right">
            <?php if (RoleCategories::checkRoleForAdmins(Yii::app()->user->roleCat)): ?>
                <?php echo CHtml::link('уд', array('/chat/delete', 'id' => $data->id_chat), array('class' => 'delete-msg btn btn-default btn-sm')) ?>
                <?php if ($data->answer_type < 3): ?>
                    <?php echo CHtml::link('ред', array('/chat/edit/', 'id' => $data->id_chat), array('class' => 'edit btn btn-default btn-sm')) ?>
                <?php endif; ?>
            <?php endif; ?>
            <a href="?answ=<?php echo $data->id_chat; ?>" class="answer_link btn btn-default btn-sm">отв</a>
        </div>
        <div class="clearfix"></div>
    </div>
    <div class="message_block-message">
        <?php if ($data->answer_type > 2): ?>
            <em>Текст сообщения скрыт</em>
        <?php else: ?>
            <?php 
                if (strstr($data->message, Yii::app()->user->login)) {
                    $text = '<em>'.FuncHelper::outputText($data->message, true, true, true, false, false).'</em>'; 
                }
                else {
                    $text = FuncHelper::outputText($data->message, true, true, true, false, false); 
                }    
            ?>
            <?php if (RoleCategories::checkRoleForAdmins($data->idUser->idRole->id_cat_role)): ?>
                <span class="text-success"><?php echo $text; ?></span>
            <?php else: ?>
                <?php echo $text; ?>
            <?php endif; ?>
        <?php endif; ?>
    </div>
    <?php if ($data->answer): ?>
        <hr>
        <div class="message_block-answer">
            <div class="pull-left">
                <?php if ($data->answer_type > 2): ?>
                    <span class="text-danger"><?php echo FuncHelper::outputText($data->answer); ?></span>
                <?php elseif ($data->answer_type > 1): ?>
                    <span class="text-success"><?php echo FuncHelper::outputText($data->answer); ?></span>
                <?php else: ?>
                    <span class="text-muted"><?php echo FuncHelper::outputText($data->answer); ?></span>
                <?php endif; ?>
            </div>
            <div class="pull-right">
                <?php echo Users::getLoginWithLink($data->id_moder); ?>
            </div>
            <div class="clearfix"></div>
        </div>
    <?php endif; ?>
</div>