This repository has been archived by the owner on Jun 27, 2019. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 9
/
Copy pathModule.php
executable file
·108 lines (94 loc) · 2.74 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
<?php
namespace humhub\modules\dropbox;
use Yii;
use humhub\modules\user\models\User;
use humhub\modules\space\models\Space;
use humhub\modules\dropbox\models\DropboxPost;
use humhub\modules\content\components\ContentContainerModule;
use humhub\modules\content\components\ContentContainerActiveRecord;
class Module extends ContentContainerModule
{
/**
* @inheritdoc
*/
public function getContentContainerTypes()
{
return [
User::className(),
Space::className(),
];
}
/**
* On build of a Profile Navigation, check if this module is enabled.
* When enabled add a menu item
*
* @param type $event
*/
public static function onProfileMenuInit($event)
{
$user = $event->sender->user;
// Is Module enabled on this workspace?
if ($user->isModuleEnabled('dropbox')) {
$event->sender->addItem(array(
'label' => Yii::t('DropboxModule.base', 'Add Dropbox files'),
'url' => $user->createUrl('/dropbox/create/index'),
'isActive' => (Yii::$app->controller->module && Yii::$app->controller->module->id == 'dropbox'),
));
}
}
/**
* @inheritdoc
*/
public function getConfigUrl()
{
return \yii\helpers\Url::to(['/dropbox/admin']);
}
/**
* On build of a Space Navigation, check if this module is enabled.
* When enabled add a menu item
*
* @param type $event
*/
public static function onSpaceMenuInit($event)
{
$space = $event->sender->space;
if ($space->isModuleEnabled('dropbox')) {
$event->sender->addItem(array(
'label' => Yii::t('DropboxModule.base', 'Add Dropbox files'),
'url' => $space->createUrl('/dropbox/create/index'),
'icon' => '<i class="fa fa-dropbox"></i>',
'isActive' => (Yii::$app->controller->module && Yii::$app->controller->module->id == 'dropbox')
));
}
}
/**
* @inheritdoc
*/
public function disableContentContainer(ContentContainerActiveRecord $container)
{
foreach (DropboxPost::find()->contentContainer($container)->all() as $post) {
$post->delete();
}
}
/**
* @inheritdoc
*/
public function getContentContainerConfigUrl(ContentContainerActiveRecord $container)
{
if ($container instanceof User) {
return $container->createUrl('/dropbox/user');
}
return "";
}
/**
* @inheritdoc
*/
public function disable()
{
foreach (DropboxPost::find()->all() as $post) {
$post->delete();
}
parent::disable();
}
}
?>