Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
Stud.IP
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Requirements
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Locked files
Build
Pipelines
Jobs
Pipeline schedules
Test cases
Artifacts
Deploy
Releases
Package Registry
Container Registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Code review analytics
Issue analytics
Insights
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Marcus Eibrink-Lunzenauer
Stud.IP
Commits
65e8a124
Commit
65e8a124
authored
7 months ago
by
Elmar Ludwig
Browse files
Options
Downloads
Patches
Plain Diff
don't create plugin instances from navigation context, fixes #4317
Closes #4317 Merge request
studip/studip!3218
parent
ee67801a
No related branches found
Branches containing commit
No related tags found
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
lib/navigation/CourseNavigation.php
+31
-42
31 additions, 42 deletions
lib/navigation/CourseNavigation.php
lib/plugins/engine/PluginEngine.php
+10
-2
10 additions, 2 deletions
lib/plugins/engine/PluginEngine.php
with
41 additions
and
44 deletions
lib/navigation/CourseNavigation.php
+
31
−
42
View file @
65e8a124
...
...
@@ -47,60 +47,49 @@ class CourseNavigation extends Navigation
}
/**
* Initialize the subnavigation of this item. This method
* is called once before the first item is added or removed.
* Add an array of navigation items to the subnavigation of this
* object. The new items are inserted at the appropriate position
* for this tool according to the order defined in tools_activated.
*
* @param int $plugin_id id of the module
* @param array $navigations navigation items to add
*/
public
function
initSubN
avigation
(
)
public
function
addToolNavigation
(
$plugin_id
,
array
$n
avigation
s
)
{
parent
::
initSubNavigation
();
$found
=
null
;
$where
=
null
;
$admin_plugin_ids
=
[];
$core_admin
=
PluginManager
::
getInstance
()
->
getPlugin
(
CoreAdmin
::
class
);
if
(
$core_admin
)
{
$admin_plugin_ids
[]
=
$core_admin
->
getPluginId
();
}
$core_studygroup_admin
=
PluginManager
::
getInstance
()
->
getPlugin
(
CoreStudygroupAdmin
::
class
);
if
(
$core_studygroup_admin
)
{
$admin_plugin_ids
[]
=
$core_studygroup_admin
->
getPluginId
();
}
$tools
=
$this
->
range
->
tools
->
getArrayCopy
();
usort
(
$tools
,
function
(
$a
,
$b
)
use
(
$admin_plugin_ids
)
{
if
(
in_array
(
$a
[
'plugin_id'
],
$admin_plugin_ids
))
{
return
-
1
;
}
if
(
in_array
(
$b
[
'plugin_id'
],
$admin_plugin_ids
))
{
return
1
;
}
return
$a
[
'position'
]
-
$b
[
'position'
];
});
foreach
(
$tools
as
$tool
)
{
foreach
(
$this
->
range
->
tools
as
$tool
)
{
if
(
!
(
$this
->
range
instanceof
Institute
)
&&
!
Seminar_Perm
::
get
()
->
have_studip_perm
(
$tool
->
getVisibilityPermission
(),
$this
->
range
->
id
)
$found
&&
$tool
->
metadata
[
'navigation'
]
&&
$tool
->
metadata
[
'navigation'
]
!==
'admin'
)
{
continue
;
$where
=
$tool
->
metadata
[
'navigation'
];
break
;
}
$studip_module
=
$
tool
->
getStudipModule
();
if
(
!
(
$studip_module
instanceof
StudipModule
))
{
continue
;
if
(
$tool
->
plugin_id
=
=
$
plugin_id
)
{
$tool
->
metadata
[
'navigation'
]
=
key
(
$navigations
);
$found
=
$tool
;
}
}
$tool_nav
=
$studip_module
->
getTabNavigation
(
$this
->
range
->
id
)
?:
[];
// always insert admin module in first position
if
(
key
(
$navigations
)
===
'admin'
)
{
$where
=
key
(
$this
->
subnav
);
}
foreach
(
$tool_nav
as
$nav_name
=>
$navigation
)
{
if
(
!
$nav_name
||
!
$navigation
instanceof
Navigation
)
{
continue
;
foreach
(
$navigations
as
$key
=>
$nav
)
{
if
(
$this
->
range
instanceof
Institute
||
Seminar_Perm
::
get
()
->
have_studip_perm
(
$found
->
getVisibilityPermission
(),
$this
->
range
->
id
)
)
{
if
(
isset
(
$found
->
metadata
[
'displayname'
]))
{
$nav
->
setTitle
(
$found
->
getDisplayname
());
}
if
(
$tool
->
metadata
[
'displayname'
])
{
$navigation
->
setTitle
(
$tool
->
getDisplayname
());
}
$this
->
addSubNavigation
(
$nav_name
,
$navigation
);
$this
->
insertSubNavigation
(
$key
,
$nav
,
$where
);
}
}
}
...
...
This diff is collapsed.
Click to expand it.
lib/plugins/engine/PluginEngine.php
+
10
−
2
View file @
65e8a124
...
...
@@ -44,8 +44,16 @@ class PluginEngine
// load course plugins
if
(
Context
::
getId
())
{
self
::
getPlugins
(
StudipModule
::
class
);
self
::
getPlugins
(
StandardPlugin
::
class
);
$modules
=
self
::
getPlugins
(
StudipModule
::
class
,
Context
::
getId
());
$navigation
=
Navigation
::
getItem
(
'/course'
);
foreach
(
$modules
as
$module
)
{
$tabs
=
$module
->
getTabNavigation
(
Context
::
getId
());
if
(
$navigation
&&
$tabs
)
{
$navigation
->
addToolNavigation
(
$module
->
getPluginId
(),
$tabs
);
}
}
}
// load admin plugins
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment