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
134251f0
Commit
134251f0
authored
Mar 15, 2016
by
Олег Гиммельшпах
Browse files
Options
Browse Files
Download
Plain Diff
Merge branch 'master' of git.task-on.com:ktask/task-on.com
parents
9789f7ee
ac49ea04
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
46 additions
and
5 deletions
+46
-5
common/components/BaseController.php
common/components/BaseController.php
+2
-2
common/modules/triggers/controllers/DefaultController.php
common/modules/triggers/controllers/DefaultController.php
+16
-0
common/modules/triggers/models/TriggerLogs.php
common/modules/triggers/models/TriggerLogs.php
+28
-3
No files found.
common/components/BaseController.php
View file @
134251f0
<?php
namespace
common\components
;
use
app
\models\TriggerLogs
;
use
common\modules\triggers
\models\TriggerLogs
;
use
common\modules\triggers\components\conditions\conditions\CheckPresenceTime
;
use
common\modules\triggers\components\conditions\conditions\CheckScrolling
;
use
Yii
;
...
...
@@ -64,7 +64,7 @@ abstract class BaseController extends Controller
public
function
beforeAction
(
$action
)
{
//
TriggerLogs::logAction();
TriggerLogs
::
logAction
();
// CheckPresenceTime::init()->initScript();
// CheckScrolling::init()->initScript();
/*if(substr($currentUrl, -1) == '/' && $currentUrl!="/") {
...
...
common/modules/triggers/controllers/DefaultController.php
View file @
134251f0
...
...
@@ -4,6 +4,7 @@ namespace common\modules\triggers\controllers;
use
common\components\BaseController
;
use
common\modules\triggers\components\conditions\Conditions
;
use
common\modules\triggers\models\TriggerLogs
;
use
common\modules\triggers\models\TriggerSchedule
;
use
common\modules\triggers\models\TriggerTrigger
;
use
\DateTime
;
...
...
@@ -18,10 +19,25 @@ class DefaultController extends BaseController
return
[
'Index'
=>
'Главная страница модуля'
,
'Rechecktriggers'
=>
'Запуск проверки срабатывания триггеров'
,
'Settimeoflogs'
=>
'Фиксация времени логов'
,
'Inittrigger'
=>
'Initiate trigger By id'
];
}
/**
* @param $id
* @param $value
*/
public
function
actionSettimeoflogs
(
$id
,
$value
)
{
/** @var TriggerLogs $model */
$model
=
TriggerLogs
::
findOne
(
$id
);
if
(
!
is_null
(
$model
))
{
$model
->
presence_time
=
$value
;
$model
->
save
(
false
);
}
}
public
function
actionInittrigger
(
$id
){
if
(
\Yii
::
$app
->
request
->
isAjax
)
{
/** @var TriggerTrigger $trigger */
...
...
common/modules/triggers/models/TriggerLogs.php
View file @
134251f0
...
...
@@ -25,15 +25,40 @@ class TriggerLogs extends \yii\db\ActiveRecord
public
static
function
logAction
()
{
if
(
!
Yii
::
$app
->
user
->
isGuest
)
{
if
(
!
Yii
::
$app
->
user
->
isGuest
&&
!
Yii
::
$app
->
request
->
isAjax
)
{
$action
=
self
::
USER_VISITED
;
if
(
Yii
::
$app
->
controller
->
action
->
id
==
'registration'
)
$action
=
self
::
USER_REGISTRATION
;
$date
=
new
\DateTime
();
$model
=
new
TriggerLogs
();
$model
->
user_id
=
Yii
::
$app
->
user
->
identity
->
id
;
$model
->
action
=
self
::
USER_VISITED
;
$model
->
action
=
$action
;
$model
->
url
=
Yii
::
$app
->
request
->
getUrl
();
$model
->
datetime
=
$date
->
format
(
'Y-m-d H:i:s'
);
$model
->
presence_time
=
1
;
$model
->
save
();
if
(
$model
->
save
())
{
$view
=
\Yii
::
$app
->
controller
->
view
;
// Создаем скрипт
$script
=
'$(document).ready(function() {
var id='
.
(
$model
->
getPrimaryKey
())
.
';
var interval = 5;
var value = 5;
setInterval(function() {
$.ajax({
url: "/triggers/default/settimeoflogs",
method: "GET",
async: false,
data: {
id: id,
value: value
},
});
value += interval;
}, (interval*1000));
});'
;
// Регистрируем его
$view
->
registerJs
(
$script
,
$view
::
POS_READY
);
}
}
}
/**
...
...
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