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
8868dbd2
Commit
8868dbd2
authored
Feb 29, 2016
by
Шакарим Сапа
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
- Немного изменена логика выполнения скрипта на измерение времени пребывания на странице
parent
8e9e4f90
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
11 additions
and
24 deletions
+11
-24
common/modules/triggers/components/conditions/conditions/CheckPresenceTime.php
...rs/components/conditions/conditions/CheckPresenceTime.php
+11
-24
No files found.
common/modules/triggers/components/conditions/conditions/CheckPresenceTime.php
View file @
8868dbd2
...
...
@@ -9,6 +9,8 @@
namespace
common\modules\triggers\components\conditions\conditions
;
use
common\modules\messageTemplate\components\Templates
;
use
common\modules\messageTemplate\models\MessageTemplate
;
use
common\modules\triggers\components\conditions\vendor\ConditionBase
;
use
common\modules\triggers\components\conditions\vendor\ConditionInterface
;
use
common\modules\triggers\models\TriggerCondition
;
...
...
@@ -49,39 +51,24 @@ class CheckPresenceTime extends ConditionBase implements ConditionInterface {
/** @var TriggerParam $paramTime */
$paramTime
=
TriggerParam
::
find
()
->
where
([
'condition_id'
=>
$condition
->
getPrimaryKey
(),
'key'
=>
'time'
])
->
one
();
// Если сработали условия что триггер есть, у него указаны время и URL и при этом он является триггером ДАННОГО типа
if
(
$condition
->
condition_id
==
self
::
CONDITION_ID
&&
$paramUrl
!==
null
&&
$paramUrl
->
value
==
\Yii
::
$app
->
request
->
getUrl
()
&&
$paramTime
!==
null
)
{
$now
=
new
\DateTime
();
$time
=
new
\DateTime
();
$time
->
modify
(
'+ '
.
(((
int
)
$trigger
->
timeout
<
(
int
)
$cron_time
)
?
$cron_time
:
(
int
)
$trigger
->
timeout
+
(
int
)
$cron_time
)
.
' second'
);
// Заносим запись в базу
$model
=
new
TriggerSchedule
();
$model
->
sended
=
0
;
$model
->
checked
=
0
;
$model
->
message
=
'Test the presence time'
;
$model
->
email
=
\common\modules\users\models\User
::
findOne
(
\Yii
::
$app
->
user
->
id
)
->
email
;
$model
->
time
=
$time
->
format
(
'Y-m-d H:i:s'
);
$model
->
date_create
=
$now
->
format
(
'Y-m-d H:i:s'
);
if
(
$model
->
save
())
{
$view
=
\Yii
::
$app
->
controller
->
view
;
// Создаем скрипт
$script
=
'$(document).ready(function() {
if
(
$condition
->
condition_id
==
self
::
CONDITION_ID
&&
$paramUrl
!==
null
&&
$paramUrl
->
value
==
\Yii
::
$app
->
request
->
getUrl
()
&&
$paramTime
!==
null
&&
!
\Yii
::
$app
->
user
->
isGuest
)
{
$view
=
\Yii
::
$app
->
controller
->
view
;
// Создаем скрипт
$script
=
'$(document).ready(function() {
var timer='
.
((
int
)
$paramTime
->
value
*
1000
)
.
';
setTimeout(function() {
$.ajax({
url: "/triggers/default/
dropschedule
",
url: "/triggers/default/
initTrigger
",
method: "GET",
async: false,
data: {
id: '
.
$
model
->
getPrimaryKey
()
.
'
id: '
.
$
trigger
->
getPrimaryKey
()
.
'
},
});
}, timer);
});'
;
// Регистрируем его
$view
->
registerJs
(
$script
,
$view
::
POS_READY
);
}
else
{
throw
new
BadRequestHttpException
(
current
(
current
(
$model
->
getErrors
())),
500
);
}
// Регистрируем его
$view
->
registerJs
(
$script
,
$view
::
POS_READY
);
}
}
}
...
...
@@ -92,6 +79,6 @@ class CheckPresenceTime extends ConditionBase implements ConditionInterface {
* @return bool
*/
public
function
check
(
$time
){
return
tru
e
;
return
fals
e
;
}
}
\ No newline at end of file
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