aboutsummaryrefslogtreecommitdiff
path: root/lib/plugins
diff options
context:
space:
mode:
authorJan-Hendrik Willms <tleilax+studip@gmail.com>2024-05-06 09:03:33 +0000
committerJan-Hendrik Willms <tleilax+github@gmail.com>2024-05-06 15:07:47 +0200
commit98c5bc11a98166fc6d90e5849a9b0771403360b4 (patch)
treea59e00614f30aec2475e25fa49636fff783f3169 /lib/plugins
parent4232adaaf0a75f025615792b38d954ae5851d8c9 (diff)
fixes #3977
Closes #3977 Merge request studip/studip!2945
Diffstat (limited to 'lib/plugins')
-rw-r--r--lib/plugins/engine/PluginManager.class.php60
1 files changed, 34 insertions, 26 deletions
diff --git a/lib/plugins/engine/PluginManager.class.php b/lib/plugins/engine/PluginManager.class.php
index bb8a563..b66185e 100644
--- a/lib/plugins/engine/PluginManager.class.php
+++ b/lib/plugins/engine/PluginManager.class.php
@@ -427,41 +427,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
+ ];
+
+ $this->readPluginInfos();
- $db->exec("INSERT INTO roles_plugins (roleid, pluginid)
+ $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;
}