Initial import of space_profiles module
This commit is contained in:
76
Events.php
Normal file
76
Events.php
Normal file
@@ -0,0 +1,76 @@
|
||||
<?php
|
||||
|
||||
namespace humhub\modules\space_profiles;
|
||||
|
||||
use Yii;
|
||||
|
||||
class Events
|
||||
{
|
||||
public static function onSpaceMenuInit($event): void
|
||||
{
|
||||
$space = $event->sender->space ?? null;
|
||||
if ($space === null || !$space->moduleManager->isEnabled('space_profiles')) {
|
||||
return;
|
||||
}
|
||||
|
||||
$event->sender->addItem([
|
||||
'label' => Yii::t('SpaceProfilesModule.base', 'Rescue Profile'),
|
||||
'group' => 'modules',
|
||||
'url' => $space->createUrl('/space_profiles/profile/view'),
|
||||
'icon' => '<i class="fa fa-id-card"></i>',
|
||||
'sortOrder' => 90,
|
||||
'isActive' => (
|
||||
Yii::$app->controller
|
||||
&& Yii::$app->controller->module
|
||||
&& Yii::$app->controller->module->id === 'space_profiles'
|
||||
&& Yii::$app->controller->id === 'profile'
|
||||
),
|
||||
]);
|
||||
}
|
||||
|
||||
public static function onRescueSettingsMenuInit($event): void
|
||||
{
|
||||
$space = $event->sender->space ?? null;
|
||||
if ($space === null || !$space->moduleManager->isEnabled('space_profiles')) {
|
||||
return;
|
||||
}
|
||||
|
||||
$event->sender->addItem([
|
||||
'label' => Yii::t('SpaceProfilesModule.base', 'Space Profile'),
|
||||
'url' => $space->createUrl('/space_profiles/settings'),
|
||||
'sortOrder' => 200,
|
||||
'isActive' => (
|
||||
Yii::$app->controller
|
||||
&& Yii::$app->controller->module
|
||||
&& Yii::$app->controller->module->id === 'space_profiles'
|
||||
&& Yii::$app->controller->id === 'settings'
|
||||
),
|
||||
]);
|
||||
}
|
||||
|
||||
public static function onSpaceAdminMenuInitFallback($event): void
|
||||
{
|
||||
$space = $event->sender->space ?? null;
|
||||
if ($space === null || !$space->moduleManager->isEnabled('space_profiles')) {
|
||||
return;
|
||||
}
|
||||
|
||||
if ($space->moduleManager->isEnabled('rescue_foundation') || !$space->isAdmin()) {
|
||||
return;
|
||||
}
|
||||
|
||||
$event->sender->addItem([
|
||||
'label' => Yii::t('SpaceProfilesModule.base', 'Space Profile'),
|
||||
'group' => 'admin',
|
||||
'url' => $space->createUrl('/space_profiles/settings'),
|
||||
'icon' => '<i class="fa fa-id-card"></i>',
|
||||
'sortOrder' => 590,
|
||||
'isActive' => (
|
||||
Yii::$app->controller
|
||||
&& Yii::$app->controller->module
|
||||
&& Yii::$app->controller->module->id === 'space_profiles'
|
||||
&& Yii::$app->controller->id === 'settings'
|
||||
),
|
||||
]);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user