Skip to content
Permalink
Browse files

Patters update

* User's context update
  • Loading branch information...
sergejey committed Sep 11, 2019
1 parent 6e295b0 commit c76f52617accd7f275eb5da2b1297071a9d0da3d
Showing with 8 additions and 17 deletions.
  1. +5 −7 lib/context.inc.php
  2. +3 −10 modules/patterns/patterns.class.php
@@ -23,19 +23,17 @@ function context_getuser()
* Summary of context_getcurrent
* @return int|string
*/
function context_getcurrent()
function context_getcurrent($from_user_id = 0)
{
$user_id = context_getuser();
if (!$from_user_id) {
$from_user_id = context_getuser();
}
$sqlQuery = "SELECT ID, ACTIVE_CONTEXT_ID, ACTIVE_CONTEXT_EXTERNAL
FROM users
WHERE ID = '" . (int)$user_id . "'";
WHERE ID = '" . (int)$from_user_id . "'";
$user = SQLSelectOne($sqlQuery);
if (!$user['ID'])
return 0;
if ($user['ACTIVE_CONTEXT_EXTERNAL'])
{
return 'ext' . (int)$user['ACTIVE_CONTEXT_ID'];
@@ -252,18 +252,11 @@ function edit_patterns(&$out, $id)
*/
function checkAllPatterns($from_user_id = 0)
{
global $session;
$current_context = context_getcurrent();
$current_context = context_getcurrent($from_user_id);
//DebMes("current context:".$current_context);
if ($from_user_id && preg_match('/^ext(\d+)/', $current_context, $m)) {
$res = $this->checkExtPatterns($m[1]);
} else {
$patterns = SQLSelect("SELECT * FROM patterns WHERE 1 AND PARENT_ID='" . (int)$current_context . "' AND PATTERN_TYPE=0 ORDER BY PRIORITY DESC, TITLE");
$total = count($patterns);
$res = 0;
@@ -753,7 +746,7 @@ function checkPattern($id, $from_user_id = 0)
if ($condition_matched) {
DebMes("Pattern matched: ".$rec['TITLE'],'patterns');
DebMes("Pattern matched: " . $rec['TITLE'], 'patterns');
$is_common = 0;
if ($rec['PARENT_ID']) {
@@ -843,7 +836,7 @@ function buildTree_patterns($res, $parent_id = 0, $level = 0)
function processSubscription($event, &$details)
{
if ($event == 'SAY' || $event == 'COMMAND') {
$member_id = $details['member_id'];
$member_id = (int)$details['member_id'];
$res = $this->checkAllPatterns($member_id);
if ($event == 'COMMAND' && $res) {
$details['BREAK'] = true;

0 comments on commit c76f526

Please sign in to comment.
You can’t perform that action at this time.