Module   A
last analyzed

Complexity

Total Complexity 7

Size/Duplication

Total Lines 35
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 0

Importance

Changes 1
Bugs 0 Features 0
Metric Value
wmc 7
c 1
b 0
f 0
lcom 0
cbo 0
dl 0
loc 35
rs 10

3 Methods

Rating   Name   Duplication   Size   Complexity  
A onLayoutAddonsInit() 0 6 2
A showPrivacybox() 0 12 4
A getConfigUrl() 0 4 1
1
<?php
2
3
namespace humhub\modules\privacybox;
4
5
use Yii;
6
use yii\helpers\Url;
7
8
class Module extends \humhub\components\Module
9
{
10
11
    /**
12
     * On Init of Dashboard Sidebar, add the widget
13
     *
14
     * @param type $event
15
     */
16
    public static function onLayoutAddonsInit($event)
17
    {
18
        if (self::showPrivacybox()) {
19
            $event->sender->addWidget(widgets\PrivacyboxModal::className(), [], ['sortOrder' => 99999]);
20
        }
21
    }
22
23
    public static function showPrivacybox()
24
    {
25
        $settings = Yii::$app->getModule('privacybox')->settings;
26
        if(Yii::$app->user->isGuest || !$settings->get('active')) {
27
            return false;
28
        }
29
30
        $lastSeenTS = $settings->user()->get('timestamp');
31
        $currentTermsTS = $settings->get('timestamp');
32
33
        return $currentTermsTS != null && $lastSeenTS != $currentTermsTS;
34
    }
35
36
37
    public function getConfigUrl()
38
    {
39
        return Url::to(['/privacybox/admin/index']);
40
    }
41
42
}
43