This repository has been archived by the owner on Dec 29, 2022. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 10
/
Module.php
90 lines (77 loc) · 2.08 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
<?php
namespace tracker;
use humhub\modules\content\components\ContentContainerModule;
use humhub\modules\space\models\Space;
use humhub\modules\user\models\User;
use tracker\permissions\AddDocument;
use tracker\permissions\AddReceiversToDocument;
use tracker\permissions\CreateIssue;
use tracker\permissions\EditIssue;
use tracker\permissions\GrandViewAllDocuments;
use tracker\permissions\ViewAllDocuments;
use yii\helpers\Url;
/**
* Main class of module tracker issue
*
* @author Evgeniy Tkachenko <[email protected]>
*/
class Module extends ContentContainerModule
{
public $id = 'tracker-issues';
public $documentRootPath;
/** @var bool */
public $showOnTopMenu = true;
public $resourcesPath = 'resources';
public function init()
{
\Yii::setAlias('tracker', __DIR__);
if (!is_dir($this->documentRootPath)) {
$this->documentRootPath = \Yii::getAlias('@webroot/uploads/documents/');
}
parent::init();
}
/**
* @inheritdoc
*/
public function getContentContainerTypes()
{
return [Space::class, User::class];
}
/**
* @inheritdoc
*/
public function getPermissions($contentContainer = null)
{
if ($contentContainer !== null) {
return [
new CreateIssue(['contentContainer' => $contentContainer]),
new EditIssue(['contentContainer' => $contentContainer]),
];
}
return [
new AddDocument(),
new AddReceiversToDocument(),
new ViewAllDocuments(),
new GrandViewAllDocuments(),
];
}
/**
* @inheritdoc
*/
public function disable()
{
foreach (\tracker\models\Issue::find()->each() as $issue) {
/** @var $issue \tracker\models\Issue */
$issue->delete();
}
parent::disable();
}
public function getConfigUrl()
{
return Url::to(['/' . $this->getIdentifier() . '/config']);
}
public static function getIdentifier()
{
return 'tracker-issues';
}
}