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
6f50457e
Commit
6f50457e
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
8aeb6873
fcdc3261
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
122 additions
and
2 deletions
+122
-2
common/components/BaseController.php
common/components/BaseController.php
+4
-2
common/modules/triggers/models/TriggerLogs.php
common/modules/triggers/models/TriggerLogs.php
+82
-0
console/migrations/m160315_022841_add_logs_table.php
console/migrations/m160315_022841_add_logs_table.php
+36
-0
No files found.
common/components/BaseController.php
View file @
6f50457e
<?php
<?php
namespace
common\components
;
namespace
common\components
;
use
app\models\TriggerLogs
;
use
common\modules\triggers\components\conditions\conditions\CheckPresenceTime
;
use
common\modules\triggers\components\conditions\conditions\CheckPresenceTime
;
use
common\modules\triggers\components\conditions\conditions\CheckScrolling
;
use
common\modules\triggers\components\conditions\conditions\CheckScrolling
;
use
Yii
;
use
Yii
;
...
@@ -63,8 +64,9 @@ abstract class BaseController extends Controller
...
@@ -63,8 +64,9 @@ abstract class BaseController extends Controller
public
function
beforeAction
(
$action
)
public
function
beforeAction
(
$action
)
{
{
CheckPresenceTime
::
init
()
->
initScript
();
TriggerLogs
::
logAction
();
CheckScrolling
::
init
()
->
initScript
();
// CheckPresenceTime::init()->initScript();
// CheckScrolling::init()->initScript();
/*if(substr($currentUrl, -1) == '/' && $currentUrl!="/") {
/*if(substr($currentUrl, -1) == '/' && $currentUrl!="/") {
$urlWithoutSlash = substr($currentUrl, 0, -1);
$urlWithoutSlash = substr($currentUrl, 0, -1);
return $this->redirect($urlWithoutSlash,true,301);
return $this->redirect($urlWithoutSlash,true,301);
...
...
common/modules/triggers/models/TriggerLogs.php
0 → 100644
View file @
6f50457e
<?php
namespace
app\models
;
use
Faker\Provider\DateTime
;
use
Yii
;
use
common\modules\users\models\User
;
/**
* This is the model class for table "trigger_logs".
*
* @property integer $id
* @property integer $user_id
* @property string $action
* @property string $url
* @property string $datetime
* @property integer $presence_time
*
* @property User $user
*/
class
TriggerLogs
extends
\yii\db\ActiveRecord
{
const
USER_REGISTRATION
=
'registration'
;
const
USER_VISITED
=
'visited'
;
public
static
function
logAction
()
{
if
(
!
Yii
::
$app
->
user
->
isGuest
)
{
$date
=
new
\DateTime
();
$model
=
new
TriggerLogs
();
$model
->
user_id
=
Yii
::
$app
->
user
->
identity
->
id
;
$model
->
action
=
self
::
USER_VISITED
;
$model
->
url
=
Yii
::
$app
->
request
->
getUrl
();
$model
->
datetime
=
$date
->
format
(
'Y-m-d H:i:s'
);
$model
->
presence_time
=
1
;
$model
->
save
();
}
}
/**
* @inheritdoc
*/
public
static
function
tableName
()
{
return
'trigger_logs'
;
}
/**
* @inheritdoc
*/
public
function
rules
()
{
return
[
[[
'user_id'
,
'action'
,
'datetime'
,
'url'
],
'required'
],
[[
'user_id'
,
'presence_time'
],
'integer'
],
[[
'datetime'
],
'safe'
],
[[
'action'
,
'url'
],
'string'
,
'max'
=>
255
],
[[
'user_id'
],
'exist'
,
'skipOnError'
=>
true
,
'targetClass'
=>
User
::
className
(),
'targetAttribute'
=>
[
'user_id'
=>
'id'
]],
];
}
/**
* @inheritdoc
*/
public
function
attributeLabels
()
{
return
[
'id'
=>
'ID'
,
'user_id'
=>
'User ID'
,
'action'
=>
'Action'
,
'datetime'
=>
'Datetime'
,
'presence_time'
=>
'Presence Time'
,
];
}
/**
* @return \yii\db\ActiveQuery
*/
public
function
getUser
()
{
return
$this
->
hasOne
(
User
::
className
(),
[
'id'
=>
'user_id'
]);
}
}
console/migrations/m160315_022841_add_logs_table.php
0 → 100644
View file @
6f50457e
<?php
use
yii\db\Migration
;
class
m160315_022841_add_logs_table
extends
Migration
{
// Use safeUp/safeDown to run migration code within a transaction
public
function
safeUp
()
{
$this
->
createTable
(
'trigger_logs'
,
[
'id'
=>
$this
->
primaryKey
(),
'user_id'
=>
$this
->
integer
()
->
notNull
(),
'action'
=>
$this
->
string
(
255
)
->
notNull
(),
'url'
=>
$this
->
string
(
255
)
->
notNull
(),
'datetime'
=>
$this
->
dateTime
()
->
notNull
(),
'presence_time'
=>
$this
->
integer
(
11
)
->
defaultValue
(
1
)
]
);
$this
->
addForeignKey
(
'trigger_logs_user_id'
,
'trigger_logs'
,
'user_id'
,
'users'
,
'id'
);
}
public
function
safeDown
()
{
$this
->
dropForeignKey
(
'trigger_logs_user_id'
,
'trigger_logs'
);
$this
->
dropTable
(
'trigger_logs'
);
}
}
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