Skip to content

Commit

Permalink
Separate permission to use [html] code
Browse files Browse the repository at this point in the history
  • Loading branch information
remdex committed Dec 27, 2021
1 parent b280bea commit c3881fb
Show file tree
Hide file tree
Showing 4 changed files with 21 additions and 2 deletions.
6 changes: 6 additions & 0 deletions lhc_web/lib/core/lhchat/lhchatworkflow.php
Expand Up @@ -875,6 +875,12 @@ public static function presendCannedMsg($chat) {

$msg = new erLhcoreClassModelmsg();
$msg->msg = $cannedMsg->msg_to_user;

if (strpos($msg->msg,'[html]') !== false && !erLhcoreClassUser::instance()->hasAccessTo('lhchat','htmlbbcodeenabled')) {
$msg->msg = '[html] is disabled for you!';
$msg->user_id = -1;
}

$msg->chat_id = $chat->id;
$msg->user_id = $chat->user_id;
$msg->name_support = $chat->user->name_support;
Expand Down
7 changes: 6 additions & 1 deletion lhc_web/modules/lhchat/addmsgadmin.php
Expand Up @@ -66,7 +66,12 @@
$msg->time = time();
$msg->name_support = $userData->name_support;

if (isset($_POST['meta_msg'])) {
if (strpos($msg->msg,'[html]') !== false && !$currentUser->hasAccessTo('lhchat','htmlbbcodeenabled')) {
$msg->msg = '[html] is disabled for you!';
$msg->user_id = -1;
}

if (isset($_POST['meta_msg']) && $currentUser->hasAccessTo('lhchat','metamsgenabled')) {
$meta_msg = json_decode($_POST['meta_msg'], true);
if (is_array($meta_msg)) {
$metaContent = [];
Expand Down
2 changes: 2 additions & 0 deletions lhc_web/modules/lhchat/module.php
Expand Up @@ -713,5 +713,7 @@
$FunctionList['subject_chats'] = array('explain' => 'Allow operator see subject filtered chats');
$FunctionList['subject_chats_options'] = array('explain' => 'Allow operator to choose what subjects should be applied as filter');
$FunctionList['export_chats'] = array('explain' => 'Allow operator to export filtered chats');
$FunctionList['htmlbbcodeenabled'] = array('explain' => 'Allow operator to use [html] bbcode.');
$FunctionList['metamsgenabled'] = array('explain' => 'Allow operator to use meta_msg in message add interface.');

?>
8 changes: 7 additions & 1 deletion lhc_web/modules/lhrestapi/addmsgadmin.php
Expand Up @@ -103,7 +103,12 @@
$msg->user_id = $messageUserId;
$msg->time = time();

if ($form->hasValidData('meta_msg') && $form->meta_msg != '') {
if (strpos($msg->msg,'[html]') !== false && !erLhcoreClassRestAPIHandler::hasAccessTo('lhchat','htmlbbcodeenabled')) {
$msg->msg = '[html] is disabled for you!';
$msg->user_id = -1;
}

if ($form->hasValidData('meta_msg') && $form->meta_msg != '' && erLhcoreClassRestAPIHandler::hasAccessTo('lhchat','metamsgenabled')) {
$metaParts = json_decode($form->meta_msg,true);
// Parse meta message as it was bot message and store it within message
// We cannot store directly meta message content because it may contain callbacks which can be internal functions
Expand All @@ -129,6 +134,7 @@
}
}


if ($form->hasValidData('operator_name') && $form->operator_name != '') {
$msg->name_support = $form->operator_name;
} elseif ($form->sender == 'bot') {
Expand Down

0 comments on commit c3881fb

Please sign in to comment.