Skip to content

Commit

Permalink
Updates
Browse files Browse the repository at this point in the history
  • Loading branch information
remdex committed Mar 20, 2024
1 parent 66da7ac commit 20a6bd1
Show file tree
Hide file tree
Showing 3 changed files with 63 additions and 20 deletions.
64 changes: 61 additions & 3 deletions lhc_web/lib/core/lhcore/lhdbtrait.php
Expand Up @@ -401,6 +401,20 @@ public static function getConditions($params, $q)
}
}

if (isset($params['filterfields']) && count($params['filterfields']) > 0) {
foreach ($params['filterfields'] as $combination) {
foreach ($combination as $field => $fieldValue) {
if (is_array($fieldValue)) {
if (!empty($fieldValue)) {
$conditions[] = $q->expr->in($field, $fieldValue);
}
} else {
$conditions[] = $q->expr->eq($field, $q->bindValue($fieldValue));
}
}
}
}

if (isset($params['filterin']) && count($params['filterin']) > 0) {
foreach ($params['filterin'] as $field => $fieldValue) {
if (empty($fieldValue)) {
Expand All @@ -411,6 +425,18 @@ public static function getConditions($params, $q)
}
}

if (isset($params['filterinfields']) && count($params['filterinfields']) > 0) {
foreach ($params['filterinfields'] as $combination) {
foreach ($combination as $field => $fieldValue) {
if (empty($fieldValue)) {
break;
} else {
$conditions[] = $q->expr->in($field, $fieldValue);
}
}
}
}

if (isset($params['filterlt']) && count($params['filterlt']) > 0) {
foreach ($params['filterlt'] as $field => $fieldValue) {
$conditions[] = $q->expr->lt($field, $q->bindValue($fieldValue));
Expand All @@ -432,7 +458,7 @@ public static function getConditions($params, $q)
}

if (isset($params['filtergtfields']) && count($params['filtergtfields']) > 0) {
foreach ($params['filtergtfields'] as $field => $combination) {
foreach ($params['filtergtfields'] as $combination) {
foreach ($combination as $field => $fieldValue) {
$conditions[] = $q->expr->gt($field, $q->bindValue($fieldValue));
}
Expand All @@ -441,13 +467,29 @@ public static function getConditions($params, $q)

if (isset($params['filtergte']) && count($params['filtergte']) > 0) {
foreach ($params['filtergte'] as $field => $fieldValue) {
$conditions[] = $q->expr->gte($field, $fieldValue);
$conditions[] = $q->expr->gte($field, $q->bindValue($fieldValue));
}
}

if (isset($params['filtergtefields']) && count($params['filtergtefields']) > 0) {
foreach ($params['filtergtefields'] as $combination) {
foreach ($combination as $field => $fieldValue) {
$conditions[] = $q->expr->gte($field, $q->bindValue($fieldValue));
}
}
}

if (isset($params['filterlte']) && count($params['filterlte']) > 0) {
foreach ($params['filterlte'] as $field => $fieldValue) {
$conditions[] = $q->expr->lte($field, $fieldValue);
$conditions[] = $q->expr->lte($field, $q->bindValue($fieldValue));
}
}

if (isset($params['filterltefields']) && count($params['filterltefields']) > 0) {
foreach ($params['filterltefields'] as $combination) {
foreach ($combination as $field => $fieldValue) {
$conditions[] = $q->expr->lte($field, $q->bindValue($fieldValue));
}
}
}

Expand Down Expand Up @@ -483,6 +525,22 @@ public static function getConditions($params, $q)
}
}

if (isset($params['filterlikefields']) && count($params['filterlikefields']) > 0) {
foreach ($params['filterlikefields'] as $combination) {
foreach ($combination as $field => $fieldValue) {
$conditions[] = $q->expr->like($field, $q->bindValue('%' . $fieldValue . '%'));
}
}
}

if (isset($params['filternotlikefields']) && count($params['filternotlikefields']) > 0) {
foreach ($params['filternotlikefields'] as $combination) {
foreach ($combination as $field => $fieldValue) {
$conditions[] = $q->expr->not($q->expr->like($field, $q->bindValue('%' . $fieldValue . '%')));
}
}
}

if (isset($params['filterlikeright']) && count($params['filterlikeright']) > 0) {
foreach ($params['filterlikeright'] as $field => $fieldValue) {
$conditions[] = $q->expr->like($field, $q->bindValue($fieldValue . '%'));
Expand Down
Expand Up @@ -179,7 +179,7 @@ public static function processEventMail()
} else if ($conditionsCurrent['condition'] == 'notlike') {
$filterPrepared['filternotlikefields'][][$conditionAttr] = $valueAttr;
} else if ($conditionsCurrent['condition'] == 'contains') {
$filterPrepared['filterinfield'][][$conditionAttr] = explode(',', $valueAttr);
$filterPrepared['filterinfields'][][$conditionAttr] = explode(',', $valueAttr);
}
}
}
Expand Down Expand Up @@ -209,21 +209,6 @@ public static function processEventMail()

if ($conditionsCurrent['type'] == '1') { // Visitor message contains
// For that visitor should use event based events or contains just options
/*$paramsMessage = array('limit' => 1, 'sort' => 'id DESC', 'filter' => array('chat_id' => $chat->id), 'filternotin' => array('user_id' => array(-1)));
if ($previousMessageId > 0) {
$paramsMessage['filterlt']['id'] = $previousMessageId;
}
$messageLast = erLhcoreClassModelmsg::findOne($paramsMessage);
if ($messageLast instanceof erLhcoreClassModelmsg) {
$previousMessageId = $messageLast->id;
if ($messageLast->user_id == 0) {
$conditionItemValid = erLhcoreClassGenericBotWorkflow::checkPresenceMessage(array(
'pattern' => $conditionsCurrent['message_contains'],
'msg' => $messageLast->msg,
'words_typo' => 0,
))['found'];
}
}*/
} elseif ($conditionsCurrent['type'] == '3') { // No response from operator for n seconds
$conditionAttr = $conditionsCurrent['attr'];
if (strpos($conditionAttr, '{args.') !== false) {
Expand Down
2 changes: 1 addition & 1 deletion lhc_web/modules/lhcron/webhook.php
Expand Up @@ -5,6 +5,6 @@
* Run every 20 seconds
*
* */
//erLhcoreClassChatWebhookContinuous::processEvent();
erLhcoreClassChatWebhookContinuous::processEvent();
\LiveHelperChat\mailConv\Webhooks\Continous::processEventMail();

0 comments on commit 20a6bd1

Please sign in to comment.