OneBot: Leantime 改造版源码(BOM/Univer 表格/AI 接管/品牌替换等)
This commit is contained in:
23
app/Domain/Modulemanager/Controllers/Notavailable.php
Normal file
23
app/Domain/Modulemanager/Controllers/Notavailable.php
Normal file
@@ -0,0 +1,23 @@
|
||||
<?php
|
||||
|
||||
namespace Leantime\Domain\ModuleManager\Controllers;
|
||||
|
||||
use Leantime\Core\Controller\Frontcontroller;
|
||||
use Leantime\Core\Events\DispatchesEvents;
|
||||
use Symfony\Component\HttpFoundation\Response;
|
||||
|
||||
class Notavailable
|
||||
{
|
||||
/**
|
||||
* Redirects to the error page or a filtered alternative.
|
||||
*
|
||||
* @param array $params Request parameters
|
||||
*/
|
||||
public function get(array $params): Response
|
||||
{
|
||||
$redirect = BASE_URL.'errors/error404';
|
||||
$redirect = DispatchesEvents::dispatch_filter('notAvailableRedirect', $redirect, $params);
|
||||
|
||||
return Frontcontroller::redirect($redirect);
|
||||
}
|
||||
}
|
||||
50
app/Domain/Modulemanager/Services/Modulemanager.php
Normal file
50
app/Domain/Modulemanager/Services/Modulemanager.php
Normal file
@@ -0,0 +1,50 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* Module Manager
|
||||
*/
|
||||
|
||||
namespace Leantime\Domain\Modulemanager\Services;
|
||||
|
||||
use Leantime\Domain\Plugins\Services\Plugins;
|
||||
|
||||
class Modulemanager
|
||||
{
|
||||
use \Leantime\Core\Events\DispatchesEvents;
|
||||
|
||||
private Plugins $pluginService;
|
||||
|
||||
/**
|
||||
* __construct - get and test Session or make session
|
||||
*/
|
||||
public function __construct(Plugins $plugins)
|
||||
{
|
||||
$this->pluginService = $plugins;
|
||||
}
|
||||
|
||||
/**
|
||||
* Checks if a module is available and enabled.
|
||||
* This also checks plugins and whether they are installed and enabled
|
||||
*
|
||||
* @param string $module The name of the module to check availability for.
|
||||
* @return bool Returns true if the module is available, false otherwise.
|
||||
*/
|
||||
public function isModuleAvailable(string $module): bool
|
||||
{
|
||||
$available = false;
|
||||
|
||||
$plugins = $this->pluginService->getEnabledPlugins();
|
||||
|
||||
$filtered = collect($plugins)->filter(function ($plugin) use ($module) {
|
||||
return strtolower($plugin->foldername) == strtolower($module);
|
||||
});
|
||||
|
||||
if ($filtered->count() > 0) {
|
||||
$available = true;
|
||||
}
|
||||
|
||||
$available = static::dispatch_filter('moduleAvailability', $available, ['module' => $module]);
|
||||
|
||||
return $available;
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user