Skip to content

Commit

Permalink
3.74v
Browse files Browse the repository at this point in the history
  • Loading branch information
remdex committed Jun 29, 2021
1 parent ceaf9df commit be73940
Show file tree
Hide file tree
Showing 12 changed files with 158 additions and 27 deletions.
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<script>
function confirmSave(){
if (parseInt($('#id_DepartmentID').val()) > 0 || confirm("<?php echo erTranslationClassLhTranslation::getInstance()->getTranslation('chat/cannedmsg','This change will be applied to all departments that use this canned message');?>")){
if (parseInt($('input[name=DepartmentID\\[\\]]:checked').length) > 0 || confirm("<?php echo erTranslationClassLhTranslation::getInstance()->getTranslation('chat/cannedmsg','This change will be applied to all departments that use this canned message');?>")){
return true;
} else {
return false;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,18 +1,24 @@
<div class="form-group">
<label><?php echo erTranslationClassLhTranslation::getInstance()->getTranslation('chat/cannedmsg','Department');?></label>
<?php

<div class="row" style="max-height: 500px; overflow: auto">

<?php
$params = array (
'input_name' => 'DepartmentID',
'input_name' => 'DepartmentID[]',
'display_name' => 'name',
'css_class' => 'form-control',
'selected_id' => $canned_message->department_id,
'multiple' => true,
'wrap_prepend' => '<div class="col-4">',
'wrap_append' => '</div>',
'selected_id' => $canned_message->department_ids_front,
'list_function' => 'erLhcoreClassModelDepartament::getList',
'list_function_params' => array_merge(array('limit' => '1000000'),$limitDepartments)
'list_function_params' => array_merge(array('sort' => 'sort_priority ASC, id ASC', 'limit' => '1000000'), $limitDepartments)
);

if (empty($limitDepartments) || (isset($showAnyDepartment) && $showAnyDepartment == true)) {
$params['optional_field'] = erTranslationClassLhTranslation::getInstance()->getTranslation('department/edit','Any');
$params['optional_field'] = erTranslationClassLhTranslation::getInstance()->getTranslation('department/edit','Any');
}

echo erLhcoreClassRenderHelper::renderCombobox( $params ); ?>
</div>
echo erLhcoreClassRenderHelper::renderCheckbox( $params ); ?>
</div></div>
15 changes: 14 additions & 1 deletion lhc_web/doc/CHANGELOG.txt
Original file line number Diff line number Diff line change
@@ -1,3 +1,16 @@
3.74v

1. Now you can send invitation message to mass users at once.
2. You can filter online visitors who are connected to website only. Using nodejshelper extension this gives live view who is connected.
3. Canned messages now can be assigned to more than one department.
4. Private messages between operators will have a sound now.
5. Canned messages import/export will support tags now.
6. Users import will have more fields to prefill now.
7. Department list will be sorted by same order as in the widget filters.

execute doc/update_db/update_246.sql for update


3.73v

1. Option to pass trigger_id as argument. Usefull in case you want to make some test on production.
Expand All @@ -6,7 +19,7 @@
4. UL,OL styling options. See bbcode documentation for a syntax.
5. Option to change font size from the widget. Can be activated in widget themes.

execute doc/update_db/update_244.sql for update
execute doc/update_db/update_245.sql for update

3.72v

Expand Down
17 changes: 14 additions & 3 deletions lhc_web/doc/update_db/structure.json
Original file line number Diff line number Diff line change
Expand Up @@ -5426,6 +5426,16 @@
"extra": "auto_increment"
}
],
"lh_canned_msg_dep": [
{
"field": "id",
"type": "bigint(20)",
"null": "NO",
"key": "PRI",
"default": null,
"extra": "auto_increment"
}
],
"lh_departament_limit_group_member": [
{
"field": "id",
Expand Down Expand Up @@ -7482,7 +7492,7 @@
},
{
"field": "username",
"type": "varchar(40)",
"type": "varchar(80)",
"null": "NO",
"key": "",
"default": null,
Expand Down Expand Up @@ -7617,7 +7627,7 @@
},
{
"field": "departments_ids",
"type": "varchar(100)",
"type": "varchar(500)",
"null": "NO",
"key": "",
"default": null,
Expand Down Expand Up @@ -9845,6 +9855,7 @@
"lh_abstract_stats": "CREATE TABLE `lh_abstract_stats` (\n `id` bigint(20) NOT NULL AUTO_INCREMENT,\n `type` int(11) NOT NULL,\n `lupdate` bigint(20) NOT NULL,\n `object_id` bigint(20) NOT NULL,\n `stats` longtext CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NOT NULL,\n PRIMARY KEY (`id`),\n KEY `type_object_id` (`type`,`object_id`)\n) ENGINE=InnoDB CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;",
"lh_chat_voice_video" : "CREATE TABLE IF NOT EXISTS `lh_chat_voice_video` (`id` bigint(20) NOT NULL AUTO_INCREMENT,`chat_id` bigint(20) NOT NULL,`user_id` bigint(20) NOT NULL,`op_status` tinyint(4) NOT NULL,`vi_status` tinyint(4) NOT NULL,`voice` tinyint(4) NOT NULL, `video` tinyint(4) NOT NULL,`screen_share` tinyint(4) NOT NULL,`status` tinyint(4) NOT NULL,`ctime` int(11) NOT NULL, `token` varchar(200) NOT NULL, PRIMARY KEY (`id`), KEY `chat_id` (`chat_id`) ) ENGINE=InnoDB CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;",
"lh_incoming_webhook" : "CREATE TABLE `lh_incoming_webhook` ( `id` int(11) NOT NULL AUTO_INCREMENT, `name` varchar(50) NOT NULL, `dep_id` int(11) NOT NULL, `identifier` varchar(50) NOT NULL, `scope` varchar(50) NOT NULL, `disabled` tinyint(1) NOT NULL, `configuration` longtext NOT NULL, PRIMARY KEY (`id`), KEY `identifier` (`identifier`)) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;",
"lh_chat_incoming" : "CREATE TABLE `lh_chat_incoming` ( `id` bigint(20) NOT NULL AUTO_INCREMENT, `chat_id` bigint(20) NOT NULL, `utime` bigint(20) NOT NULL, `incoming_id` int(11) NOT NULL, `payload` longtext NOT NULL, `chat_external_id` varchar(50) NOT NULL, PRIMARY KEY (`id`), KEY `chat_id` (`chat_id`), KEY `incoming_ext_id` (`incoming_id`,`chat_external_id`)) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;"
"lh_chat_incoming" : "CREATE TABLE `lh_chat_incoming` ( `id` bigint(20) NOT NULL AUTO_INCREMENT, `chat_id` bigint(20) NOT NULL, `utime` bigint(20) NOT NULL, `incoming_id` int(11) NOT NULL, `payload` longtext NOT NULL, `chat_external_id` varchar(50) NOT NULL, PRIMARY KEY (`id`), KEY `chat_id` (`chat_id`), KEY `incoming_ext_id` (`incoming_id`,`chat_external_id`)) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;",
"lh_canned_msg_dep" : "CREATE TABLE `lh_canned_msg_dep` (`id` bigint(20) NOT NULL AUTO_INCREMENT,`canned_id` int(11) NOT NULL,`dep_id` int(11) NOT NULL,PRIMARY KEY (`id`), KEY `canned_id` (`canned_id`),KEY `dep_id` (`dep_id`)) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;"
}
}
14 changes: 14 additions & 0 deletions lhc_web/doc/update_db/update_246.sql
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
CREATE TABLE `lh_canned_msg_dep` (
`id` bigint(20) NOT NULL AUTO_INCREMENT,
`canned_id` int(11) NOT NULL,
`dep_id` int(11) NOT NULL,
PRIMARY KEY (`id`),
KEY `canned_id` (`canned_id`),
KEY `dep_id` (`dep_id`)
) ENGINE=InnoDB AUTO_INCREMENT=0 DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;

ALTER TABLE `lh_users`
CHANGE `username` `username` varchar(80) COLLATE 'utf8mb4_unicode_ci' NOT NULL AFTER `id`,
COMMENT='';

ALTER TABLE `lh_users` CHANGE `departments_ids` `departments_ids` varchar(500) NOT NULL;
37 changes: 34 additions & 3 deletions lhc_web/lib/core/lhchat/lhchatadminvalidatorhelper.php
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ public static function validateCannedMessage(erLhcoreClassModelCannedMsg & $cann
ezcInputFormDefinitionElement::OPTIONAL, 'int',array('min_range' => 0)
),
'DepartmentID' => new ezcInputFormDefinitionElement(
ezcInputFormDefinitionElement::OPTIONAL, 'int',array('min_range' => 1)
ezcInputFormDefinitionElement::OPTIONAL, 'int',array('min_range' => 1),FILTER_REQUIRE_ARRAY
),
'AutoSend' => new ezcInputFormDefinitionElement(
ezcInputFormDefinitionElement::OPTIONAL, 'boolean'
Expand Down Expand Up @@ -117,7 +117,38 @@ public static function validateCannedMessage(erLhcoreClassModelCannedMsg & $cann
$Errors[] = erTranslationClassLhTranslation::getInstance()->getTranslation('chat/cannedmsg','Canned message tags should not contain # character');
}

if ( $form->hasValidData( 'DepartmentID' ) ) {

if ( !$form->hasValidData( 'DepartmentID' ) ) {

$response = erLhcoreClassChatEventDispatcher::getInstance()->dispatch('chat.validate_canned_msg_user_departments',array('canned_msg' => & $cannedMessage, 'errors' => & $Errors));

// Perhaps extension did some internal validation and we don't need anymore validate internaly
if ($response === false) {
$cannedMessage->department_id = 0;
}

if ($userDepartments !== true) {
if ($cannedMessage->department_id == 0 && !erLhcoreClassUser::instance()->hasAccessTo('lhcannedmsg','see_global')) {
$Errors[] = erTranslationClassLhTranslation::getInstance()->getTranslation('chat/cannedmsg','Please choose a department!');
}
}

} else {
$cannedMessage->department_ids = $form->DepartmentID;

// -1 means, individual per department
$cannedMessage->department_id = -1;

if ($userDepartments !== true) {
if (($cannedMessage->department_id == 0 && !erLhcoreClassUser::instance()->hasAccessTo('lhcannedmsg','see_global')) || !in_array($cannedMessage->department_id, $userDepartments)) {
$Errors[] = erTranslationClassLhTranslation::getInstance()->getTranslation('chat/cannedmsg','Please choose a department!');
}
}
}



/*if ( $form->hasValidData( 'DepartmentID' ) ) {
$cannedMessage->department_id = $form->DepartmentID;
if ($userDepartments !== true) {
Expand All @@ -139,7 +170,7 @@ public static function validateCannedMessage(erLhcoreClassModelCannedMsg & $cann
$Errors[] = erTranslationClassLhTranslation::getInstance()->getTranslation('chat/cannedmsg','Please choose a department!');
}
}
}
}*/

return $Errors;
}
Expand Down
1 change: 1 addition & 0 deletions lhc_web/lib/core/lhchat/lhchatexport.php
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ public static function exportCannedMessages($messages) {
foreach ($messages as $message) {
$values = $message->getState();
$values['tags_plain'] = $message->tags_plain;
$values['department_ids_front'] = implode(',',$message->department_ids_front);
if ($counter == 0) {
fputcsv($fp, array_keys($values));
}
Expand Down
4 changes: 2 additions & 2 deletions lhc_web/lib/core/lhcore/lhupdate.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@

class erLhcoreClassUpdate
{
const DB_VERSION = 245;
const LHC_RELEASE = 373;
const DB_VERSION = 246;
const LHC_RELEASE = 374;

public static function doTablesUpdate($definition){
$updateInformation = self::getTablesStatus($definition);
Expand Down
50 changes: 45 additions & 5 deletions lhc_web/lib/models/lhchat/erlhcoreclassmodelcannedmsg.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ class erLhcoreClassModelCannedMsg
public static $dbSessionHandler = 'erLhcoreClassChat::getSession';

public static $dbSortOrder = 'DESC';

public function getState()
{
return array(
Expand Down Expand Up @@ -61,7 +61,17 @@ public function __get($var)
}
}
return $this->department;
break;

case 'department_ids_front':
$this->department_ids_front = [];
if ($this->id > 0) {
$db = ezcDbInstance::get();
$stmt = $db->prepare("SELECT `dep_id` FROM `lh_canned_msg_dep` WHERE `canned_id` = " . $this->id);
$stmt->execute();
$this->department_ids_front = $stmt->fetchAll(PDO::FETCH_COLUMN);
}
return $this->department_ids_front;


case 'msg_to_user':
$this->msg_to_user = str_replace(array_keys($this->replaceData), array_values($this->replaceData), $this->msg);
Expand Down Expand Up @@ -134,6 +144,19 @@ public function afterSave()
$this->updateThis(array('update' => array('unique_id')));
}

$db = ezcDbInstance::get();
$stmt = $db->prepare('DELETE FROM `lh_canned_msg_dep` WHERE `canned_id` = :canned_id');
$stmt->bindValue(':canned_id', $this->id,PDO::PARAM_INT);
$stmt->execute();

if (isset($this->department_ids) && !empty($this->department_ids)) {
$values = [];
foreach ($this->department_ids as $department_id) {
$values[] = "(" . $this->id . "," . $department_id . ")";
}
$db->query('INSERT INTO `lh_canned_msg_dep` (`canned_id`,`dep_id`) VALUES ' . implode(',',$values));
}

$tagLinks = erLhcoreClassModelCannedMsgTagLink::getList(array('filter' => array('canned_id' => $this->id)));

$tagsArray = array();
Expand Down Expand Up @@ -209,7 +232,12 @@ public function afterRemove()
$tag->removeThis();
}
}
}
}

$db = ezcDbInstance::get();
$stmt = $db->prepare('DELETE FROM `lh_canned_msg_dep` WHERE `canned_id` = :canned_id');
$stmt->bindValue(':canned_id', $this->id,PDO::PARAM_INT);
$stmt->execute();
}

public function setReplaceData($replaceData)
Expand Down Expand Up @@ -237,7 +265,18 @@ public static function getCannedMessages($department_id, $user_id, $paramsFilter

if ($response === false) {
// Extension did not changed any filters, use default
$filter[] = $q->expr->lOr($q->expr->eq('department_id', $q->bindValue($department_id)), $q->expr->lAnd($q->expr->eq('department_id', $q->bindValue(0)), $q->expr->eq('user_id', $q->bindValue(0))), $q->expr->eq('user_id', $q->bindValue($user_id)));
$filter[] = $q->expr->lOr(
$q->expr->lAnd(
$q->expr->eq('department_id', $q->bindValue(0)),
$q->expr->eq('user_id', $q->bindValue(0))
),
$q->expr->lAnd( // Support old settings
$q->expr->eq('department_id', $q->bindValue($department_id)),
$q->expr->eq('user_id', $q->bindValue(0))
),
$q->expr->eq('user_id', $q->bindValue($user_id)),
'id IN (SELECT canned_id FROM lh_canned_msg_dep WHERE dep_id = ' . (int)$department_id . ')'
);

if (isset($paramsFilter['q']) && $paramsFilter['q'] != '') {
$filter[] = $q->expr->lOr(
Expand All @@ -249,7 +288,7 @@ public static function getCannedMessages($department_id, $user_id, $paramsFilter
if (isset($paramsFilter['id']) && !empty($paramsFilter['id'])) {
$filter[] = $q->expr->in('id', $paramsFilter['id']);
}

$q->where($filter);

$q->limit(5000, 0);
Expand Down Expand Up @@ -345,6 +384,7 @@ public function setMessageByChatLocale($locale) {
public $position = 0;
public $delay = 0;
public $department_id = 0;
public $department_ids = [];
public $user_id = 0;
public $auto_send = 0;
public $attr_int_1 = 0;
Expand Down
6 changes: 6 additions & 0 deletions lhc_web/modules/lhcannedmsg/import.php
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@

$canned = array_keys((new erLhcoreClassModelCannedMsg())->getState());
$canned[] = 'tags_plain';
$canned[] = 'department_ids_front';

$stats = array(
'updated' => 0,
Expand Down Expand Up @@ -68,6 +69,11 @@
$stats['updated']++;
}

// Set departments
if (isset($item['department_ids_front']) && !empty($item['department_ids_front'])) {
$cannedMessage->department_ids = explode(',', $item['department_ids_front']);
}

unset($item['id']);

$cannedMessage->setState($item);
Expand Down
2 changes: 1 addition & 1 deletion lhc_web/modules/lhchat/cannedmsgedit.php
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@

if (isset($_POST['Update_action']) || isset($_POST['Save_action']) )
{
$previousState = $Msg->getState();
$previousState = $Msg->getState();

$Errors = erLhcoreClassAdminChatValidatorHelper::validateCannedMessage($Msg, $userDepartments);

Expand Down
17 changes: 13 additions & 4 deletions lhc_web/modules/lhinstall/install.php
Original file line number Diff line number Diff line change
Expand Up @@ -1260,7 +1260,7 @@
KEY `unique_id` (`unique_id`)
) ENGINE=InnoDB CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;");

$db->query("CREATE TABLE IF NOT EXISTS `lh_chat_online_user_footprint` (
$db->query("CREATE TABLE IF NOT EXISTS `lh_chat_online_user_footprint` (
`id` int(11) NOT NULL AUTO_INCREMENT,
`chat_id` int(11) NOT NULL,
`online_user_id` int(11) NOT NULL,
Expand All @@ -1271,7 +1271,16 @@
KEY `online_user_id` (`online_user_id`)
) ENGINE=InnoDB CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;");

$db->query("CREATE TABLE `lh_abstract_proactive_chat_event` (
$db->query("CREATE TABLE `lh_canned_msg_dep` (
`id` bigint(20) NOT NULL AUTO_INCREMENT,
`canned_id` int(11) NOT NULL,
`dep_id` int(11) NOT NULL,
PRIMARY KEY (`id`),
KEY `canned_id` (`canned_id`),
KEY `dep_id` (`dep_id`)
) ENGINE=InnoDB CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;");

$db->query("CREATE TABLE `lh_abstract_proactive_chat_event` (
`id` int(11) NOT NULL AUTO_INCREMENT,
`vid_id` int(11) NOT NULL,
`ev_id` int(11) NOT NULL,
Expand Down Expand Up @@ -1869,7 +1878,7 @@
// Users
$db->query("CREATE TABLE IF NOT EXISTS `lh_users` (
`id` int(11) NOT NULL AUTO_INCREMENT,
`username` varchar(40) NOT NULL,
`username` varchar(80) NOT NULL,
`password` varchar(200) NOT NULL,
`email` varchar(100) NOT NULL,
`time_zone` varchar(100) NOT NULL,
Expand All @@ -1878,7 +1887,7 @@
`filepath` varchar(200) NOT NULL,
`filename` varchar(200) NOT NULL,
`job_title` varchar(100) NOT NULL,
`departments_ids` varchar(100) NOT NULL,
`departments_ids` varchar(500) NOT NULL,
`chat_nickname` varchar(100) NOT NULL,
`xmpp_username` varchar(200) NOT NULL,
`session_id` varchar(40) NOT NULL,
Expand Down

0 comments on commit be73940

Please sign in to comment.