Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
T
taskonsite-архив-перенесен
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Packages
Packages
Container Registry
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Dmitry Korolev
taskonsite-архив-перенесен
Commits
9219658c
Commit
9219658c
authored
Mar 16, 2016
by
Шакарим Сапа
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
- Доработаны триггеры отвечающие за проверку выполненности условий
parent
8893bf63
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
32 additions
and
2 deletions
+32
-2
common/modules/triggers/components/conditions/Conditions.php
common/modules/triggers/components/conditions/Conditions.php
+32
-2
No files found.
common/modules/triggers/components/conditions/Conditions.php
View file @
9219658c
...
...
@@ -11,6 +11,7 @@ namespace common\modules\triggers\components\conditions;
use
common\modules\triggers\controllers\TriggerAdminController
;
use
common\modules\triggers\models\TriggerCondition
;
use
common\modules\triggers\models\TriggerTrigger
;
use
common\modules\users\models\User
;
use
yii\web\ServerErrorHttpException
;
class
Conditions
{
...
...
@@ -180,17 +181,46 @@ class Conditions {
return
false
;
}
public
function
handleUserByTriggerId
(
$user_id
,
$trigger_id
)
{
/** @var User $user */
$user
=
User
::
findOne
(
$user_id
);
if
(
!
is_null
(
$user
))
{
// Результирующий массив
$resultArray
=
[];
// Получили все условия в рамках триггера
$conditions
=
TriggerCondition
::
find
()
->
where
([
'trigger_id'
=>
$trigger_id
])
->
all
();
// Привели массив в понятный вид
$conditionsArray
=
[];
foreach
(
$conditions
as
$i
=>
$condition
)
{
$conditionsArray
[
$i
][]
=
$condition
;
}
// На выходе получаем массив необходимого формата
// Обрабатываем отформатированный массив
foreach
(
$conditionsArray
as
$key
=>
$array
)
{
$resultArray
[]
=
self
::
checkConditionsArray
(
$array
,
null
,
[
'email'
=>
$user
->
email
]);
}
// Проверяем результат
if
(
count
(
$resultArray
)
>
0
)
{
foreach
(
$resultArray
as
$result
)
if
(
$result
===
false
)
return
false
;
return
true
;
}
}
return
false
;
}
/**
* Проверяем массив параметров на срабатывание хотябы одного условия
* @param $array
* @param $message
* @return bool
*/
public
static
function
checkConditionsArray
(
$array
,
$message
){
public
static
function
checkConditionsArray
(
$array
,
$message
=
null
,
$params
=
array
()
){
foreach
(
$array
as
$item
)
{
$object
=
Conditions
::
init
()
->
getConditionById
(
$item
->
condition_id
);
$object
->
model
=
$item
;
if
(
$object
->
check
(
$message
)
==
true
)
if
(
$object
->
check
(
$message
,
$params
)
==
true
)
return
true
;
}
return
false
;
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment