-
Notifications
You must be signed in to change notification settings - Fork 8
/
Copy pathModule.php
115 lines (95 loc) · 2.52 KB
/
Module.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
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
<?php
/**
* @link https://www.humhub.org/
* @copyright Copyright (c) 2018 HumHub GmbH & Co. KG
* @license https://www.humhub.com/licences
*/
namespace humhub\modules\legal;
use Yii;
use yii\helpers\Url;
class Module extends \humhub\components\Module
{
/**
* @inheritdoc
*/
public $resourcesPath = 'resources';
/**
* @inheritdoc
*/
public function getConfigUrl()
{
return Url::to(['/legal/admin']);
}
/**
* @return array of page keys
*/
public function getEnabledPages()
{
if (empty($this->settings->get('enabledPages'))) {
return [];
}
return explode(',', $this->settings->get('enabledPages'));
}
/**
* @param string|null $setting Setting name: 'icon', 'modal', null - to return array of all enabled settings
* @return array|bool Config for external links
*/
public function getExternalLinksConfig(?string $setting = null)
{
$config = empty($this->settings->get('externalLinks'))
? []
: explode(',', $this->settings->get('externalLinks'));
return $setting === null ? $config : in_array($setting, $config);
}
/**
* @return bool
*/
public function showPagesAfterRegistration()
{
return (bool)$this->settings->get('showPagesAfterRegistration', false);
}
/**
* @param $pageKey
* @return bool
*/
public function isPageEnabled($pageKey)
{
if (in_array($pageKey, $this->getEnabledPages())) {
return true;
}
return false;
}
/**
* @return string
*/
public function getDefaultLanguage()
{
if (empty($this->settings->get('defaultLanguage'))) {
return Yii::$app->language;
}
return $this->settings->get('defaultLanguage');
}
public function isAllowedExportUserData(): bool
{
return Yii::$app->hasModule('rest') && Yii::$app->getModule('rest')->isActivated;
}
public function isEnabledExportUserData(): bool
{
return $this->isAllowedExportUserData() && $this->settings->get('exportUserData', false);
}
public function getExportUserDays(): int
{
return (int) $this->settings->get('exportUserDays', 1);
}
public function showAgeCheck(): bool
{
return (bool) $this->settings->get('showAgeCheck', false);
}
/**
* @return string
*/
public function getMinimumAge()
{
return $this->settings->get('minimumAge', 16);
}
}