diff options
Diffstat (limited to 'lib/plugins')
| -rw-r--r-- | lib/plugins/core/AdminCourseAction.php (renamed from lib/plugins/core/AdminCourseAction.class.php) | 0 | ||||
| -rw-r--r-- | lib/plugins/core/AdminCourseContents.php (renamed from lib/plugins/core/AdminCourseContents.class.php) | 4 | ||||
| -rw-r--r-- | lib/plugins/core/AdminCourseWidgetPlugin.php (renamed from lib/plugins/core/AdminCourseWidgetPlugin.class.php) | 0 | ||||
| -rw-r--r-- | lib/plugins/core/AdministrationPlugin.php (renamed from lib/plugins/core/AdministrationPlugin.class.php) | 2 | ||||
| -rw-r--r-- | lib/plugins/core/CorePlugin.php | 4 | ||||
| -rw-r--r-- | lib/plugins/core/DetailspagePlugin.php (renamed from lib/plugins/core/DetailspagePlugin.class.php) | 6 | ||||
| -rw-r--r-- | lib/plugins/core/ExternPagePlugin.php | 4 | ||||
| -rw-r--r-- | lib/plugins/core/FileUploadHook.php (renamed from lib/plugins/core/FileUploadHook.class.php) | 0 | ||||
| -rw-r--r-- | lib/plugins/core/FilesystemPlugin.php (renamed from lib/plugins/core/FilesystemPlugin.class.php) | 5 | ||||
| -rw-r--r-- | lib/plugins/core/ForumModule.php (renamed from lib/plugins/core/ForumModule.class.php) | 4 | ||||
| -rw-r--r-- | lib/plugins/core/HomepagePlugin.php (renamed from lib/plugins/core/HomepagePlugin.class.php) | 6 | ||||
| -rw-r--r-- | lib/plugins/core/LibraryPlugin.php (renamed from lib/plugins/core/LibraryPlugin.class.php) | 2 | ||||
| -rw-r--r-- | lib/plugins/core/MetricsPlugin.php (renamed from lib/plugins/core/MetricsPlugin.class.php) | 0 | ||||
| -rw-r--r-- | lib/plugins/core/PortalPlugin.php (renamed from lib/plugins/core/PortalPlugin.class.php) | 6 | ||||
| -rw-r--r-- | lib/plugins/core/PrivacyPlugin.php (renamed from lib/plugins/core/PrivacyPlugin.class.php) | 0 | ||||
| -rw-r--r-- | lib/plugins/core/QuestionnaireAssignmentPlugin.php (renamed from lib/plugins/core/QuestionnaireAssignmentPlugin.class.php) | 4 | ||||
| -rw-r--r-- | lib/plugins/core/RESTAPIPlugin.class.php | 26 | ||||
| -rw-r--r-- | lib/plugins/core/Role.php (renamed from lib/plugins/core/Role.class.php) | 2 | ||||
| -rw-r--r-- | lib/plugins/core/ScorePlugin.php (renamed from lib/plugins/core/ScorePlugin.class.php) | 0 | ||||
| -rw-r--r-- | lib/plugins/core/StandardPlugin.php (renamed from lib/plugins/core/StandardPlugin.class.php) | 2 | ||||
| -rw-r--r-- | lib/plugins/core/StudIPPlugin.php (renamed from lib/plugins/core/StudIPPlugin.class.php) | 8 | ||||
| -rw-r--r-- | lib/plugins/core/SystemPlugin.php (renamed from lib/plugins/core/SystemPlugin.class.php) | 2 | ||||
| -rw-r--r-- | lib/plugins/core/WebServicePlugin.php (renamed from lib/plugins/core/WebServicePlugin.class.php) | 0 | ||||
| -rw-r--r-- | lib/plugins/db/RolePersistence.php (renamed from lib/plugins/db/RolePersistence.class.php) | 6 | ||||
| -rw-r--r-- | lib/plugins/engine/PluginEngine.php (renamed from lib/plugins/engine/PluginEngine.class.php) | 21 | ||||
| -rw-r--r-- | lib/plugins/engine/PluginManager.php (renamed from lib/plugins/engine/PluginManager.class.php) | 90 | ||||
| -rw-r--r-- | lib/plugins/engine/PluginRepository.php (renamed from lib/plugins/engine/PluginRepository.class.php) | 4 |
27 files changed, 96 insertions, 112 deletions
diff --git a/lib/plugins/core/AdminCourseAction.class.php b/lib/plugins/core/AdminCourseAction.php index 046502c..046502c 100644 --- a/lib/plugins/core/AdminCourseAction.class.php +++ b/lib/plugins/core/AdminCourseAction.php diff --git a/lib/plugins/core/AdminCourseContents.class.php b/lib/plugins/core/AdminCourseContents.php index 065cc9e..0e07b58 100644 --- a/lib/plugins/core/AdminCourseContents.class.php +++ b/lib/plugins/core/AdminCourseContents.php @@ -15,9 +15,11 @@ interface AdminCourseContents /** * Returns the value of the additional column for the course-overview table in the admin-area. + * * @param Course $course : A Course-object of the given ... course * @param string $index : the index that comes from adminAvailableContents to identify the column. - * @return Flexi_Template | String : Either one will do, but string is preferred, because it can exported as CSV-file more easily. + * + * @return Flexi\Template | String : Either one will do, but string is preferred, because it can exported as CSV-file more easily. */ public function adminAreaGetCourseContent($course, $index); } diff --git a/lib/plugins/core/AdminCourseWidgetPlugin.class.php b/lib/plugins/core/AdminCourseWidgetPlugin.php index c554626..c554626 100644 --- a/lib/plugins/core/AdminCourseWidgetPlugin.class.php +++ b/lib/plugins/core/AdminCourseWidgetPlugin.php diff --git a/lib/plugins/core/AdministrationPlugin.class.php b/lib/plugins/core/AdministrationPlugin.php index c9aa8da..6856e6a 100644 --- a/lib/plugins/core/AdministrationPlugin.class.php +++ b/lib/plugins/core/AdministrationPlugin.php @@ -1,7 +1,7 @@ <?php # Lifter010: TODO /* - * AdministrationPlugin.class.php - administration plugin interface + * AdministrationPlugin.php - administration plugin interface * * NOTE: This interface is deprecated, use SystemPlugin instead. * diff --git a/lib/plugins/core/CorePlugin.php b/lib/plugins/core/CorePlugin.php index 7f1aaed..056efaf 100644 --- a/lib/plugins/core/CorePlugin.php +++ b/lib/plugins/core/CorePlugin.php @@ -1,6 +1,6 @@ <?php /** - * CorePlugin.class.php - base class + * CorePlugin.php - base class * * @author André Noack <noack@data-quest.de> * @copyright 2021 Authors @@ -70,7 +70,7 @@ abstract class CorePlugin if (!empty($metadata['description_' . $language])) { return $metadata['description_' . $language]; } - $description = $metadata['descriptionlong'] ?? $metadata['description']; + $description = $metadata['descriptionlong'] ?? $metadata['description'] ?? ''; if ($this->plugin_info['description_mode'] === 'override_description') { return $this->plugin_info['description']; diff --git a/lib/plugins/core/DetailspagePlugin.class.php b/lib/plugins/core/DetailspagePlugin.php index 15eda09..3cc3b57 100644 --- a/lib/plugins/core/DetailspagePlugin.class.php +++ b/lib/plugins/core/DetailspagePlugin.php @@ -1,6 +1,6 @@ <?php /* - * DetailspagePlugin.class.php + * DetailspagePlugin.php * * Copyright (c) 2019 - Rasmus Fuhse <fuhse@data-quest.de> * @@ -12,7 +12,7 @@ interface DetailspagePlugin { /** - * Return a template (an instance of the Flexi_Template class) + * Return a template (an instance of the Flexi\Template class) * to be rendered on the details page. Return NULL to * render nothing for this plugin or this course. * @@ -21,7 +21,7 @@ interface DetailspagePlugin * * title title to display, defaults to plugin name * - * @return object template object to render or NULL + * @return Flexi\Template|null template object to render or NULL */ public function getDetailspageTemplate($course); } diff --git a/lib/plugins/core/ExternPagePlugin.php b/lib/plugins/core/ExternPagePlugin.php index 5b40775..d12efc5 100644 --- a/lib/plugins/core/ExternPagePlugin.php +++ b/lib/plugins/core/ExternPagePlugin.php @@ -42,10 +42,10 @@ interface ExternPagePlugin public function getExternPage(ExternPageConfig $config): ExternPage; /** - * Returns a Flexi_Template or a path to the template file. This template contains the form + * Returns a Flexi\Template or a path to the template file. This template contains the form * to configure the external page. * - * @return string|Flexi_Template + * @return string|Flexi\Template */ public function getConfigurationFormTemplate(); diff --git a/lib/plugins/core/FileUploadHook.class.php b/lib/plugins/core/FileUploadHook.php index 27323fd..27323fd 100644 --- a/lib/plugins/core/FileUploadHook.class.php +++ b/lib/plugins/core/FileUploadHook.php diff --git a/lib/plugins/core/FilesystemPlugin.class.php b/lib/plugins/core/FilesystemPlugin.php index 6d4c46c..31b4b5b 100644 --- a/lib/plugins/core/FilesystemPlugin.class.php +++ b/lib/plugins/core/FilesystemPlugin.php @@ -34,11 +34,12 @@ interface FilesystemPlugin /** * This method is used to get a folder-object for this plugin. - * Not recommended but still possible is to return a Flexi_Template for the folder, if you want to + * Not recommended but still possible is to return a Flexi\Template for the folder, if you want to * take care of the frontend of displaying the folder as well. * * @param null $folder_id : folder_id of folder to get or null if you want the top-folder - * @return FolderType|Flexi_Template + * + * @return FolderType|Flexi\Template */ public function getFolder($folder_id = null); diff --git a/lib/plugins/core/ForumModule.class.php b/lib/plugins/core/ForumModule.php index 33784db..e72ffc2 100644 --- a/lib/plugins/core/ForumModule.class.php +++ b/lib/plugins/core/ForumModule.php @@ -1,6 +1,6 @@ <?php /** - * ForumModule.class.php - Interface for all intersections between the Stud.IP + * ForumModule.php - Interface for all intersections between the Stud.IP * Core and something that behaves like a forum * * Implement all interface methods and you can integrate your plugin like @@ -137,4 +137,4 @@ interface ForumModule extends StandardPlugin * @return string a single-page HTML-view of all contents in one string */ function getDump($seminar_id); -}
\ No newline at end of file +} diff --git a/lib/plugins/core/HomepagePlugin.class.php b/lib/plugins/core/HomepagePlugin.php index 74d0204..b0dbd65 100644 --- a/lib/plugins/core/HomepagePlugin.class.php +++ b/lib/plugins/core/HomepagePlugin.php @@ -1,7 +1,7 @@ <?php # Lifter010: TODO /* - * HomepagePlugin.class.php - home page plugin interface + * HomepagePlugin.php - home page plugin interface * * Copyright (c) 2008 - Marcus Lunzenauer <mlunzena@uos.de> * Copyright (c) 2009 - Elmar Ludwig @@ -15,7 +15,7 @@ interface HomepagePlugin { /** - * Return a template (an instance of the Flexi_Template class) + * Return a template (an instance of the Flexi\Template class) * to be rendered on the given user's home page. Return NULL to * render nothing for this plugin. * @@ -27,7 +27,7 @@ interface HomepagePlugin * admin_url admin link for this plugin (if any) * admin_title title for admin link (default: Administration) * - * @return object template object to render or NULL + * @return Flexi\Template|null template object to render or NULL */ function getHomepageTemplate($user_id); } diff --git a/lib/plugins/core/LibraryPlugin.class.php b/lib/plugins/core/LibraryPlugin.php index a7fb873..3c1a751 100644 --- a/lib/plugins/core/LibraryPlugin.class.php +++ b/lib/plugins/core/LibraryPlugin.php @@ -2,7 +2,7 @@ /* - * LibraryPlugin.class.php - A plugin class for library plugins. + * LibraryPlugin.php - A plugin class for library plugins. * * Copyright (c) 2020 Moritz Strohm * diff --git a/lib/plugins/core/MetricsPlugin.class.php b/lib/plugins/core/MetricsPlugin.php index 95edaf1..95edaf1 100644 --- a/lib/plugins/core/MetricsPlugin.class.php +++ b/lib/plugins/core/MetricsPlugin.php diff --git a/lib/plugins/core/PortalPlugin.class.php b/lib/plugins/core/PortalPlugin.php index dce5774..826e410 100644 --- a/lib/plugins/core/PortalPlugin.class.php +++ b/lib/plugins/core/PortalPlugin.php @@ -1,7 +1,7 @@ <?php # Lifter010: TODO /* - * PortalPlugin.class.php - start / portal page plugin interface + * PortalPlugin.php - start / portal page plugin interface * * Copyright (c) 2008 - Marcus Lunzenauer <mlunzena@uos.de> * Copyright (c) 2009 - Elmar Ludwig @@ -15,7 +15,7 @@ interface PortalPlugin { /** - * Return a template (an instance of the Flexi_Template class) + * Return a template (an instance of the Flexi\Template class) * to be rendered on the start or portal page. Return NULL to * render nothing for this plugin. * @@ -27,7 +27,7 @@ interface PortalPlugin * admin_url admin link for this plugin (if any) * admin_title title for admin link (default: Administration) * - * @return ?Flexi_Template template object to render or NULL + * @return ?Flexi\Template template object to render or NULL */ function getPortalTemplate(); } diff --git a/lib/plugins/core/PrivacyPlugin.class.php b/lib/plugins/core/PrivacyPlugin.php index 73a971d..73a971d 100644 --- a/lib/plugins/core/PrivacyPlugin.class.php +++ b/lib/plugins/core/PrivacyPlugin.php diff --git a/lib/plugins/core/QuestionnaireAssignmentPlugin.class.php b/lib/plugins/core/QuestionnaireAssignmentPlugin.php index 6892f8a..cadaf52 100644 --- a/lib/plugins/core/QuestionnaireAssignmentPlugin.class.php +++ b/lib/plugins/core/QuestionnaireAssignmentPlugin.php @@ -39,8 +39,10 @@ interface QuestionnaireAssignmentPlugin * This template will get displayed when someone at tools -> questionnaires * wants to edit the contexts of the questionnaire. Maybe you don't want to provide a * template here, so return null or just a readonly html-snippet. + * * @param Questionnaire $questionnaire - * @return null|Flexi_Template + * + * @return null|Flexi\Template */ public function getQuestionnaireAssignmentEditTemplate(Questionnaire $questionnaire); diff --git a/lib/plugins/core/RESTAPIPlugin.class.php b/lib/plugins/core/RESTAPIPlugin.class.php deleted file mode 100644 index f69344c..0000000 --- a/lib/plugins/core/RESTAPIPlugin.class.php +++ /dev/null @@ -1,26 +0,0 @@ -<?php -/* - * REST-API Plugins add maps to the REST-API router. - * - * Copyright (c) 2014 - Marcus Lunzenauer <mlunzena@uos.de> - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License as - * published by the Free Software Foundation; either version 2 of - * the License, or (at your option) any later version. - */ - -/** - * @deprecated Since Stud.IP 5.0. Will be removed in Stud.IP 6.0. - */ -interface RESTAPIPlugin -{ - /** - * Returns one or more instances of RESTAPI\RouteMap to register - * to the Router. - * - * @return RouteMap|Array either a single instance of class - * RouteMap or an array of them - */ - public function getRouteMaps(); -} diff --git a/lib/plugins/core/Role.class.php b/lib/plugins/core/Role.php index 3ca8a11..91e00e8 100644 --- a/lib/plugins/core/Role.class.php +++ b/lib/plugins/core/Role.php @@ -1,6 +1,6 @@ <?php /** - * Role.class.php + * Role.php * * @author Dennis Reil <dennis.reil@offis.de> * @author Michael Riehemann <michael.riehemann@uni-oldenburg.de> diff --git a/lib/plugins/core/ScorePlugin.class.php b/lib/plugins/core/ScorePlugin.php index 064ddc3..064ddc3 100644 --- a/lib/plugins/core/ScorePlugin.class.php +++ b/lib/plugins/core/ScorePlugin.php diff --git a/lib/plugins/core/StandardPlugin.class.php b/lib/plugins/core/StandardPlugin.php index 960ffd0..5180891 100644 --- a/lib/plugins/core/StandardPlugin.class.php +++ b/lib/plugins/core/StandardPlugin.php @@ -1,7 +1,7 @@ <?php # Lifter010: TODO /* - * StandardPlugin.class.php - course or institute plugin interface + * StandardPlugin.php - course or institute plugin interface * * Copyright (c) 2008 - Marcus Lunzenauer <mlunzena@uos.de> * Copyright (c) 2009 - Elmar Ludwig diff --git a/lib/plugins/core/StudIPPlugin.class.php b/lib/plugins/core/StudIPPlugin.php index be2c776..6642dbd 100644 --- a/lib/plugins/core/StudIPPlugin.class.php +++ b/lib/plugins/core/StudIPPlugin.php @@ -1,6 +1,6 @@ <?php /** - * StudIPPlugin.class.php - generic plugin base class + * StudIPPlugin.php - generic plugin base class * * @author Elmar Ludwig <ludwig@uos.de> * @copyright 2009 Authors @@ -95,7 +95,7 @@ abstract class StudIPPlugin if (!empty($metadata['description_' . $language])) { return $metadata['description_' . $language]; } - $description = $metadata['descriptionlong'] ?? $metadata['description']; + $description = $metadata['descriptionlong'] ?? $metadata['description'] ?? ''; if ($this->plugin_info['description_mode'] === 'override_description') { return $this->plugin_info['description']; @@ -196,14 +196,14 @@ abstract class StudIPPlugin $action = $args[0] !== '' ? array_shift($args).'_action' : 'show_action'; if (!method_exists($this, $action)) { - $dispatcher = app(\Trails_Dispatcher::class); + $dispatcher = app(\Trails\Dispatcher::class); $dispatcher->trails_root = $this->getPluginPath(); $dispatcher->trails_uri = rtrim(PluginEngine::getLink($this, [], null, true), '/'); $dispatcher->default_controller = 'index'; $dispatcher->current_plugin = $this; try { $dispatcher->dispatch($unconsumed_path); - } catch (Trails_UnknownAction $exception) { + } catch (Trails\Exceptions\UnknownAction $exception) { if (count($args) > 0) { throw $exception; } else { diff --git a/lib/plugins/core/SystemPlugin.class.php b/lib/plugins/core/SystemPlugin.php index c204567..0ffd16f 100644 --- a/lib/plugins/core/SystemPlugin.class.php +++ b/lib/plugins/core/SystemPlugin.php @@ -1,7 +1,7 @@ <?php # Lifter010: TODO /* - * SystemPlugin.class.php - generic system plugin interface + * SystemPlugin.php - generic system plugin interface * * Copyright (c) 2008 - Marcus Lunzenauer <mlunzena@uos.de> * Copyright (c) 2009 - Elmar Ludwig diff --git a/lib/plugins/core/WebServicePlugin.class.php b/lib/plugins/core/WebServicePlugin.php index ff3e757..ff3e757 100644 --- a/lib/plugins/core/WebServicePlugin.class.php +++ b/lib/plugins/core/WebServicePlugin.php diff --git a/lib/plugins/db/RolePersistence.class.php b/lib/plugins/db/RolePersistence.php index b11fa4a..54a0053 100644 --- a/lib/plugins/db/RolePersistence.class.php +++ b/lib/plugins/db/RolePersistence.php @@ -1,6 +1,6 @@ <?php /** - * RolePersistence.class.php + * RolePersistence.php * * Funktionen für das Rollenmanagement * @@ -29,7 +29,7 @@ class RolePersistence { if (self::$all_roles === null) { // read cache - $cache = StudipCacheFactory::getCache(); + $cache = \Studip\Cache\Factory::getCache(); // cache miss, retrieve from database self::$all_roles = $cache->read(self::ROLES_CACHE_KEY); @@ -675,7 +675,7 @@ class RolePersistence public static function expireRolesCache() { self::$all_roles = null; - StudipCacheFactory::getCache()->expire(self::ROLES_CACHE_KEY); + \Studip\Cache\Factory::getCache()->expire(self::ROLES_CACHE_KEY); } /** diff --git a/lib/plugins/engine/PluginEngine.class.php b/lib/plugins/engine/PluginEngine.php index ecf00cf..25974c5 100644 --- a/lib/plugins/engine/PluginEngine.class.php +++ b/lib/plugins/engine/PluginEngine.php @@ -3,8 +3,7 @@ /** * Factory Class for the plugin engine * @author Dennis Reil, <dennis.reil@offis.de> - * @package pluginengine - * @subpackage engine + * @template P of StudIPPlugin */ class PluginEngine @@ -38,27 +37,28 @@ class PluginEngine global $user, $perm; // load system plugins - self::getPlugins('SystemPlugin'); + self::getPlugins(SystemPlugin::class); // load homepage plugins - self::getPlugins('HomepagePlugin'); + self::getPlugins(HomepagePlugin::class); // load course plugins if (Context::getId()) { - self::getPlugins('StudipModule'); - self::getPlugins('StandardPlugin'); + self::getPlugins(StudipModule::class); + self::getPlugins(StandardPlugin::class); } // load admin plugins if (is_object($user) && $perm->have_perm('admin')) { - self::getPlugins('AdministrationPlugin'); + self::getPlugins(AdministrationPlugin::class); } } /** * Get instance of the plugin specified by plugin class name. * - * @param string $class class name of plugin + * @param class-string<P> $class class name of plugin + * @return P */ public static function getPlugin ($class) { @@ -70,10 +70,9 @@ class PluginEngine * returns all enabled plugins. The optional context parameter can be * used to get only plugins that are activated in the given context. * - * @template T - * @param T $type plugin type or null (all types) + * @param class-string<P>|null $type plugin type or null (all types) * @param string $context context range id (optional) - * @return T[] all plugins of the specified type + * @return P[]|StudIPPlugin[] all plugins of the specified type */ public static function getPlugins ($type, $context = null) { diff --git a/lib/plugins/engine/PluginManager.class.php b/lib/plugins/engine/PluginManager.php index be4f766..ec434a9 100644 --- a/lib/plugins/engine/PluginManager.class.php +++ b/lib/plugins/engine/PluginManager.php @@ -1,14 +1,11 @@ <?php -# Lifter010: TODO -/* - * PluginManager.class.php - plugin manager for Stud.IP +/** + * PluginManager.php - plugin manager for Stud.IP * - * Copyright (c) 2009 Elmar Ludwig + * @copyright 2009 Elmar Ludwig + * @license GPL2 or any later version * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License as - * published by the Free Software Foundation; either version 2 of - * the License, or (at your option) any later version. + * @template P of StudIPPlugin */ class PluginManager @@ -354,10 +351,10 @@ class PluginManager $path = 'lib/modules'; } - $pluginfile = $basepath.'/'.$path.'/'.$class.'.class.php'; + $pluginfile = $basepath.'/'.$path.'/'.$class.'.php'; if (!file_exists($pluginfile)) { - $pluginfile = $basepath.'/'.$path.'/'.$class.'.php'; + $pluginfile = $basepath.'/'.$path.'/'.$class.'.class.php'; if (!file_exists($pluginfile)) { return null; @@ -427,41 +424,49 @@ class PluginManager $this->plugins[$id]['name'] = $name; $this->plugins[$id]['path'] = $path; $this->plugins[$id]['type'] = $type; + } else { + foreach ($this->plugins as $plugin) { + $common_types = array_intersect($type, $plugin['type']); - return $id; - } - - foreach ($this->plugins as $plugin) { - $common_types = array_intersect($type, $plugin['type']); - - if (count($common_types) > 0 && $plugin['position'] >= $position) { - $position = $plugin['position'] + 1; + if (count($common_types) > 0 && $plugin['position'] >= $position) { + $position = $plugin['position'] + 1; + } } - } - $sql = 'INSERT INTO plugins ( + $sql = 'INSERT INTO plugins ( pluginname, pluginclassname, pluginpath, plugintype, navigationpos, dependentonid ) VALUES (?,?,?,?,?,?)'; - $stmt = $db->prepare($sql); - $stmt->execute([$name, $class, $path, join(',', $type), $position, $depends]); - $id = $db->lastInsertId(); - - $this->plugins[$id] = [ - 'id' => $id, - 'name' => $name, - 'class' => $class, - 'path' => $path, - 'type' => $type, - 'enabled' => false, - 'position' => $position, - 'depends' => $depends - ]; + $stmt = $db->prepare($sql); + $stmt->execute([$name, $class, $path, join(',', $type), $position, $depends]); + $id = $db->lastInsertId(); - $this->readPluginInfos(); + $this->plugins[$id] = [ + 'id' => $id, + 'name' => $name, + 'class' => $class, + 'path' => $path, + 'type' => $type, + 'enabled' => false, + 'position' => $position, + 'depends' => $depends + ]; - $db->exec("INSERT INTO roles_plugins (roleid, pluginid) + $this->readPluginInfos(); + + $db->exec("INSERT INTO roles_plugins (roleid, pluginid) SELECT roleid, $id FROM roles WHERE `system` = 'y' AND rolename != 'Nobody'"); + } + + if (!in_array(StandardPlugin::class, $type)) { + ToolActivation::findEachBySQL( + function (ToolActivation $activation) use ($id) { + $this->setPluginActivated($id, $activation->range_id, false); + }, + 'plugin_id = ?', + [$id] + ); + } return $id; } @@ -568,7 +573,7 @@ class PluginManager * Get instance of the plugin specified by plugin meta data. * * @param array $plugin_info plugin meta data - * @return object + * @return P */ protected function getCachedPlugin ($plugin_info) { @@ -586,7 +591,7 @@ class PluginManager } if ($plugin_class) { - $plugin = $plugin_class->newInstance(); + $plugin = app()->get($class); } return $this->plugin_cache[$class] = $plugin; @@ -595,8 +600,8 @@ class PluginManager /** * Get instance of the plugin specified by plugin class name. * - * @param string $class class name of plugin - * @return object + * @param class-string<P> $class class name of plugin + * @return P|null */ public function getPlugin ($class) { @@ -615,7 +620,7 @@ class PluginManager * Get instance of the plugin specified by plugin id. * * @param int $id id of the plugin - * @return object $plugin + * @return P|null $plugin */ public function getPluginById ($id) { @@ -635,8 +640,9 @@ class PluginManager * returns all enabled plugins. The optional context parameter can be * used to get only plugins that are activated in the given context. * - * @param string $type plugin type or null (all types) + * @param class-string<P>|null $type plugin type or null (all types) * @param string $context context range id (optional) + * @return P[]|StudIPPlugin[] */ public function getPlugins ($type, $context = null) { diff --git a/lib/plugins/engine/PluginRepository.class.php b/lib/plugins/engine/PluginRepository.php index 14415f4..4bd24c6 100644 --- a/lib/plugins/engine/PluginRepository.class.php +++ b/lib/plugins/engine/PluginRepository.php @@ -1,7 +1,7 @@ <?php /* - * PluginRepository.class.php - query plugin meta data + * PluginRepository.php - query plugin meta data * * Copyright (c) 2008 Elmar Ludwig * @@ -55,7 +55,7 @@ class PluginRepository */ public function readMetadata($url) { - $cache = StudipCacheFactory::getCache(); + $cache = \Studip\Cache\Factory::getCache(); $cache_key = 'plugin_metadata/'.$url; $metadata = $cache->read($cache_key); |
