-
Notifications
You must be signed in to change notification settings - Fork 1
/
Module.php
83 lines (65 loc) · 2.07 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
<?php
namespace humhub\modules\social_share;
use Yii;
use yii\helpers\Url;
use humhub\models\Setting;
use humhub\modules\ui\menu\MenuLink;
use humhub\modules\admin\widgets\AdminMenu;
use humhub\modules\admin\permissions\ManageModules;
class Module extends \humhub\components\Module
{
/**
* On build of the dashboard sidebar widget, add the social_share widget if module is enabled.
*
* @param type $event
*/
public static function onSidebarInit($event) {
if (Yii::$app->hasModule('social_share')) {
$SISortOrderSet=800;
$social_share=Yii::$app->getModule('social_share');
if ($social_share->settings->get('SISortOrder') >= 0) {
$SISortOrderSet = $social_share->settings->get('SISortOrder');
}
$event->sender->addWidget(widgets\Sidebar::className(), array(), array('sortOrder' => intval($SISortOrderSet)));
}
}
public function getConfigUrl() {
return Url::to(['/social_share/config/config']);
}
/**
* Enables this module
*/
public function enable()
{
parent::enable();
$social_share=Yii::$app->getModule('social_share');
if ($social_share->settings->get('theGroups') == '') {
$social_share->settings->set('theGroups', 0);
}
if ($social_share->settings->get('ResponsiveTop') == '') {
$social_share->settings->set('ResponsiveTop', 0);
}
if ($social_share->settings->get('SISortOrder') == '') {
$social_share->settings->set('SISortOrder', 160);
}
if ($social_share->settings->get('PreviewMaxRows') == '') {
$social_share->settings->set('PreviewMaxRows', 50);
}
}
public static function onAdminMenuInit($event){
if (!Yii::$app->user->can(ManageModules::class)) {
return;
}
/** @var AdminMenu $menu */
$menu = $event->sender;
$menu->addEntry(new MenuLink([
'label' => 'Social Share',
'url' => Url::to(['/social_share/config/config']),
//'group' => 'manage',
'icon' => 'commenting-o',
'isActive' => (Yii::$app->controller->module && Yii::$app->controller->module->id == 'social_share' && Yii::$app->controller->id == 'admin'),
'sortOrder' => 700,
]));
}
}
?>