-
Notifications
You must be signed in to change notification settings - Fork 1
/
bootstrap.php
91 lines (75 loc) · 2.52 KB
/
bootstrap.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
<?php
class ActivityBootstrap extends \Dsc\Bootstrap
{
protected $dir = __DIR__;
protected $namespace = 'Activity';
/**
* Runs before all global_apps
*
* @param unknown $app
*/
protected function preBase($app)
{
if (class_exists('\Modules\Factory'))
{
\Modules\Models\Conditions::register('\Activity\ModuleConditions\Visits', array(
'title'=>'Visits',
'icon'=>'fa fa-bolt',
'type'=>'activity',
'slug'=>'activity-visits',
));
}
}
protected function runAdmin()
{
\Dsc\System::instance()->getDispatcher()->addListener(\Activity\Listener::instance());
if (class_exists('\Minify\Factory'))
{
\Minify\Factory::registerPath($this->dir . "/src/");
$files = array(
'Activity/Assets/js/track.js',
);
foreach ($files as $file)
{
\Minify\Factory::js($file);
}
}
parent::runAdmin();
}
protected function preSite()
{
parent::preSite();
if (class_exists('\Minify\Factory'))
{
\Minify\Factory::registerPath($this->dir . "/src/");
$files = array(
'Activity/Assets/js/fingerprint.js',
'Activity/Assets/js/track.js',
);
foreach ($files as $file)
{
\Minify\Factory::js($file);
}
}
}
protected function postSite()
{
parent::postSite();
if (!\Audit::instance()->isbot())
{
$actor = \Activity\Models\Actors::fetch();
$app = \Base::instance();
// Track the site visit if it hasn't been done today for this actor
if (empty($actor->last_visit) || $actor->last_visit < date('Y-m-d', strtotime('today')))
{
\Activity\Models\Actions::track('Visited Site');
$actor->set('last_visit', date('Y-m-d', strtotime('today') ) )->set('visited', time())->save();
}
if ($this->input->get('ping', null, 'int') != 1)
{
$actor->markActive( !empty( $this->auth->getIdentity()->id ) );
}
}
}
}
$app = new ActivityBootstrap();