mirror of
https://github.com/humhub/humhub.git
synced 2025-01-16 21:58:17 +01:00
- Fix: Disabled module notification category visible in notification settings.
- Enh: Added `ModuleManager::getEnabledModules()`
This commit is contained in:
parent
886676b3e8
commit
4ad0e8a767
@ -204,8 +204,10 @@ class ModuleManager extends Component
|
||||
*
|
||||
* - includeCoreModules: boolean, return also core modules (default: false)
|
||||
* - returnClass: boolean, return classname instead of module object (default: false)
|
||||
* - enabled: boolean, returns only enabled modules (core modules only when combined with `includeCoreModules`)
|
||||
*
|
||||
* @return array
|
||||
* @throws Exception
|
||||
*/
|
||||
public function getModules($options = [])
|
||||
{
|
||||
@ -220,6 +222,13 @@ class ModuleManager extends Component
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
if (isset($options['enabled']) && $options['enabled'] === true) {
|
||||
if(!in_array($class, $this->coreModules) && !in_array($id, $this->enabledModules)) {
|
||||
continue;
|
||||
}
|
||||
}
|
||||
|
||||
if (isset($options['returnClass']) && $options['returnClass']) {
|
||||
$modules[$id] = $class;
|
||||
} else {
|
||||
@ -233,6 +242,20 @@ class ModuleManager extends Component
|
||||
return $modules;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns all enabled modules and supportes further options as [[getModules()]].
|
||||
*
|
||||
* @param array $options
|
||||
* @return array
|
||||
* @throws Exception
|
||||
* @since 1.3.10
|
||||
*/
|
||||
public function getEnabledModules($options = [])
|
||||
{
|
||||
$options['enabled'] = true;
|
||||
return $this->getModules($options);
|
||||
}
|
||||
|
||||
/**
|
||||
* Checks if a moduleId exists, regardless it's activated or not
|
||||
*
|
||||
@ -249,6 +272,7 @@ class ModuleManager extends Component
|
||||
*
|
||||
* @return bool
|
||||
* @since 1.3.8
|
||||
* @throws Exception
|
||||
*/
|
||||
public function isCoreModule($id)
|
||||
{
|
||||
|
@ -1,5 +1,9 @@
|
||||
HumHub Change Log
|
||||
=================
|
||||
1.3.11 (Unreleased)
|
||||
---------------------------
|
||||
- Fix: Disabled module notification category visible in notification settings.
|
||||
- Enh: Added `ModuleManager::getEnabledModules()`
|
||||
|
||||
1.3.10 (February 22, 2019)
|
||||
---------------------------
|
||||
|
@ -60,6 +60,7 @@ class NotificationManager
|
||||
*
|
||||
* @param \humhub\modules\notification\components\BaseNotification $notification
|
||||
* @param ActiveQueryUser $userQuery
|
||||
* @throws \yii\base\InvalidConfigException
|
||||
*/
|
||||
public function sendBulk(BaseNotification $notification, $userQuery)
|
||||
{
|
||||
@ -108,6 +109,7 @@ class NotificationManager
|
||||
*
|
||||
* @param User $user |null the user
|
||||
* @return BaseTarget[] the target
|
||||
* @throws \yii\base\InvalidConfigException
|
||||
*/
|
||||
public function getTargets(User $user = null)
|
||||
{
|
||||
@ -169,6 +171,7 @@ class NotificationManager
|
||||
*
|
||||
* @param Content $content
|
||||
* @return ActiveQueryUser
|
||||
* @throws \yii\base\Exception
|
||||
*/
|
||||
public function getFollowers(Content $content)
|
||||
{
|
||||
@ -382,6 +385,7 @@ class NotificationManager
|
||||
* Returns all available Notifications
|
||||
*
|
||||
* @return BaseNotification[]
|
||||
* @throws \yii\base\Exception
|
||||
*/
|
||||
public function getNotifications()
|
||||
{
|
||||
@ -422,11 +426,12 @@ class NotificationManager
|
||||
/**
|
||||
* Searches for all Notifications exported by modules.
|
||||
* @return type
|
||||
* @throws \yii\base\Exception
|
||||
*/
|
||||
protected function searchModuleNotifications()
|
||||
{
|
||||
$result = [];
|
||||
foreach (Yii::$app->moduleManager->getModules(['includeCoreModules' => true]) as $module) {
|
||||
foreach (Yii::$app->moduleManager->getEnabledModules(['includeCoreModules' => true]) as $module) {
|
||||
if ($module instanceof Module && $module->hasNotifications()) {
|
||||
$result = array_merge($result, $this->createNotifications($module->getNotifications()));
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user