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
Jan-Hendrik Willms
Stud.IP
Commits
01bf94bc
Commit
01bf94bc
authored
10 months ago
by
Jan-Hendrik Willms
Browse files
Options
Downloads
Patches
Plain Diff
fixes #4076
Closes #4076 Merge request
studip/studip!2919
parent
6d93659a
No related branches found
Branches containing commit
No related tags found
No related merge requests found
Pipeline
#22902
canceled
10 months ago
Stage: build
Stage: checks
Stage: analyse
Stage: test
Changes
3
Pipelines
2
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
lib/classes/ResponsiveHelper.php
+58
-59
58 additions, 59 deletions
lib/classes/ResponsiveHelper.php
lib/navigation/CourseNavigation.php
+42
-26
42 additions, 26 deletions
lib/navigation/CourseNavigation.php
lib/navigation/StudipNavigation.php
+1
-1
1 addition, 1 deletion
lib/navigation/StudipNavigation.php
with
101 additions
and
86 deletions
lib/classes/ResponsiveHelper.php
+
58
−
59
View file @
01bf94bc
...
...
@@ -210,30 +210,29 @@ class ResponsiveHelper
$courses
=
[];
}
$items
=
[];
$standardIcon
=
Icon
::
create
(
'seminar'
,
Icon
::
ROLE_INFO_ALT
)
->
asImagePath
();
// Add current course to list.
if
(
Context
::
get
())
{
$courses
[]
=
Context
::
get
();
}
foreach
(
$courses
as
$course
)
{
if
(
Context
::
isInstitute
())
{
$avatarClass
=
InstituteAvatar
::
class
;
$url
=
'dispatch.php/institute/overview'
;
$standardIcon
=
Icon
::
create
(
'institute'
,
Icon
::
ROLE_INFO_ALT
)
->
asImagePath
();
}
else
{
$avatarClass
=
CourseAvatar
::
class
;
$url
=
'dispatch.php/course/details'
;
if
(
Context
::
isInstitute
())
{
$avatarClass
=
InstituteAvatar
::
class
;
$url
=
'dispatch.php/institute/overview'
;
$standardIcon
=
Icon
::
create
(
'institute'
,
Icon
::
ROLE_INFO_ALT
)
->
asImagePath
();
}
$standardIcon
=
Icon
::
create
(
'seminar'
,
Icon
::
ROLE_INFO_ALT
)
->
asImagePath
();
}
$items
=
[];
foreach
(
$courses
as
$course
)
{
$avatar
=
$avatarClass
::
getAvatar
(
$course
->
id
);
$hasAvatar
=
$avatar
->
is_customized
();
$icon
=
$hasAvatar
?
$avatar
->
getURL
(
Avatar
::
SMALL
)
:
$standardIcon
;
$
cnav
=
[
$
items
[
'browse/my_courses/'
.
$course
->
id
]
=
[
'icon'
=>
$icon
,
'avatar'
=>
$hasAvatar
,
'title'
=>
$course
->
getFullName
(),
...
...
@@ -242,60 +241,60 @@ class ResponsiveHelper
'path'
=>
'browse/my_courses/'
.
$course
->
id
,
'visible'
=>
true
,
'active'
=>
Context
::
getId
()
===
$course
->
id
,
'children'
=>
[]
'children'
=>
self
::
getRangeNavigation
(
$course
,
'browse/my_courses/'
.
$course
->
id
,
$activated
),
];
$path
=
'browse/my_courses/'
.
$course
->
id
;
foreach
(
$course
->
tools
as
$tool
)
{
if
(
Seminar_Perm
::
get
()
->
have_studip_perm
(
$tool
->
getVisibilityPermission
(),
$course
->
id
))
{
$studip_module
=
$tool
->
getStudipModule
();
if
(
$studip_module
instanceof
StudipModule
)
{
$tool_nav
=
$studip_module
->
getTabNavigation
(
$course
->
id
)
?:
[];
foreach
(
$tool_nav
as
$nav_name
=>
$navigation
)
{
if
(
$nav_name
&&
is_a
(
$navigation
,
'Navigation'
))
{
if
(
!
empty
(
$tool
->
metadata
[
'displayname'
]))
{
$navigation
->
setTitle
(
$tool
->
getDisplayname
());
}
$cnav
[
'children'
][
$path
.
'/'
.
$nav_name
]
=
[
'icon'
=>
$navigation
->
getImage
()
?
$navigation
->
getImage
()
->
asImagePath
()
:
''
,
'title'
=>
$navigation
->
getTitle
(),
'url'
=>
URLHelper
::
getURL
(
$navigation
->
getURL
(),
[
'cid'
=>
$course
->
id
]),
'parent'
=>
'browse/my_courses/'
.
$course
->
id
,
'path'
=>
'browse/my_courses/'
.
$course
->
id
.
'/'
.
$nav_name
,
'visible'
=>
true
,
'active'
=>
$navigation
->
isActive
(),
'children'
=>
static
::
getChildren
(
$navigation
,
'browse/my_courses/'
.
$course
->
id
.
'/'
.
$nav_name
,
$activated
,
$course
->
id
),
];
}
}
}
}
}
}
if
(
$GLOBALS
[
'perm'
]
->
have_studip_perm
(
'tutor'
,
$course
->
id
))
{
$cnav
[
'children'
][
$path
.
'/plus'
]
=
[
'icon'
=>
Icon
::
create
(
'add'
,
Icon
::
ROLE_INFO_ALT
)
->
asImagePath
(),
'title'
=>
_
(
'Mehr...'
),
'url'
=>
URLHelper
::
getURL
(
'dispatch.php/course/plus/index'
,
[
'cid'
=>
$course
->
id
]),
'parent'
=>
'browse/my_courses/'
.
$course
->
id
,
'path'
=>
'browse/my_courses/'
.
$course
->
id
.
'/plus/index'
,
'visible'
=>
true
,
'active'
=>
false
,
'children'
=>
[],
];
}
return
$items
;
}
private
static
function
getRangeNavigation
(
Range
$range
,
string
$path_prefix
,
array
&
$activated
):
array
{
if
(
$range
->
id
===
Context
::
getId
())
{
$navigation
=
Navigation
::
getItem
(
'/course'
);
}
else
{
$navigation
=
new
CourseNavigation
(
$range
);
}
$items
[
'browse/my_courses/'
.
$course
->
id
]
=
$cnav
;
$result
=
[]
;
foreach
(
$navigation
as
$nav_name
=>
$nav
)
{
$result
[
$path_prefix
.
'/'
.
$nav_name
]
=
[
'icon'
=>
$nav
->
getImage
()
?
$nav
->
getImage
()
->
asImagePath
()
:
''
,
'title'
=>
$nav
->
getTitle
(),
'url'
=>
URLHelper
::
getURL
(
$nav
->
getURL
(),
[
'cid'
=>
$range
->
id
]),
'parent'
=>
'browse/my_courses/'
.
$range
->
id
,
'path'
=>
'browse/my_courses/'
.
$range
->
id
.
'/'
.
$nav_name
,
'visible'
=>
true
,
'active'
=>
$nav
->
isActive
(),
'children'
=>
static
::
getChildren
(
$nav
,
'browse/my_courses/'
.
$range
->
id
.
'/'
.
$nav_name
,
$activated
,
$range
->
id
),
];
}
return
$items
;
// Move admin page to the end
if
(
count
(
$result
)
>
0
)
{
$first_path
=
array_keys
(
$result
)[
0
];
if
(
str_ends_with
(
$first_path
,
'/admin'
))
{
$admin_navigation
=
array_slice
(
array_values
(
$result
),
0
,
1
)[
0
];
$admin_navigation
[
'title'
]
=
_
(
'Verwaltung'
);
$admin_navigation
[
'icon'
]
=
Icon
::
create
(
'add'
,
Icon
::
ROLE_INFO_ALT
)
->
asImagePath
();
$result
=
array_merge
(
array_slice
(
$result
,
1
),
[
$path_prefix
.
'/admin'
=>
$admin_navigation
]
);
}
}
return
$result
;
}
}
This diff is collapsed.
Click to expand it.
lib/navigation/CourseNavigation.php
+
42
−
26
View file @
01bf94bc
...
...
@@ -15,15 +15,23 @@
class
CourseNavigation
extends
Navigation
{
private
$range
;
/**
* Initialize a new Navigation instance.
*/
public
function
__construct
()
public
function
__construct
(
Range
$range
)
{
global
$user
,
$perm
;
if
(
!
(
$range
instanceof
Course
)
&&
!
(
$range
instanceof
Institute
))
{
throw
new
InvalidArgumentException
(
'Invalid range type "'
.
get_class
(
$range
)
.
'" for course navigation'
);
}
$this
->
range
=
$range
;
global
$user
;
// check if logged in
if
(
is_object
(
$user
)
&&
$user
->
id
!=
'nobody'
)
{
if
(
User
::
findCurrent
()
)
{
$coursetext
=
_
(
'Veranstaltungen'
);
$courseinfo
=
_
(
'Meine Veranstaltungen & Einrichtungen'
);
$courselink
=
'dispatch.php/my_courses'
;
...
...
@@ -35,8 +43,8 @@ class CourseNavigation extends Navigation
parent
::
__construct
(
$coursetext
,
$courselink
);
if
(
is_object
(
$user
))
{
$this
->
setImage
(
Icon
::
create
(
'seminar'
,
'navigation'
,
[
"
title
"
=>
$courseinfo
]));
if
(
User
::
findCurrent
(
))
{
$this
->
setImage
(
Icon
::
create
(
'seminar'
,
Icon
::
ROLE_NAVIGATION
,
[
'
title
'
=>
$courseinfo
]));
}
}
...
...
@@ -48,21 +56,19 @@ class CourseNavigation extends Navigation
{
parent
::
initSubNavigation
();
$context
=
Context
::
get
();
if
(
!
$context
)
{
return
;
}
$admin_plugin_ids
=
[];
$core_admin
=
PluginManager
::
getInstance
()
->
getPlugin
(
'CoreAdmin'
);
$core_admin
=
PluginManager
::
getInstance
()
->
getPlugin
(
CoreAdmin
::
class
);
if
(
$core_admin
)
{
$admin_plugin_ids
[]
=
$core_admin
->
getPluginId
();
}
$core_studygroup_admin
=
PluginManager
::
getInstance
()
->
getPlugin
(
'CoreStudygroupAdmin'
);
$core_studygroup_admin
=
PluginManager
::
getInstance
()
->
getPlugin
(
CoreStudygroupAdmin
::
class
);
if
(
$core_studygroup_admin
)
{
$admin_plugin_ids
[]
=
$core_studygroup_admin
->
getPluginId
();
}
$tools
=
$context
->
tools
->
getArrayCopy
();
$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
;
...
...
@@ -72,22 +78,32 @@ class CourseNavigation extends Navigation
}
return
$a
[
'position'
]
-
$b
[
'position'
];
});
foreach
(
$tools
as
$tool
)
{
if
(
Context
::
isInstitute
()
||
Seminar_Perm
::
get
()
->
have_studip_perm
(
$tool
->
getVisibilityPermission
(),
$context
->
id
))
{
$studip_module
=
$tool
->
getStudipModule
();
if
(
$studip_module
instanceof
StudipModule
)
{
$tool_nav
=
$studip_module
->
getTabNavigation
(
$context
->
id
)
?:
[];
foreach
(
$tool_nav
as
$nav_name
=>
$navigation
)
{
if
(
$nav_name
&&
is_a
(
$navigation
,
"Navigation"
))
{
if
(
$tool
->
metadata
[
'displayname'
])
{
$navigation
->
setTitle
(
$tool
->
getDisplayname
());
}
$this
->
addSubNavigation
(
$nav_name
,
$navigation
);
}
}
if
(
!
(
$this
->
range
instanceof
Institute
)
&&
!
Seminar_Perm
::
get
()
->
have_studip_perm
(
$tool
->
getVisibilityPermission
(),
$this
->
range
->
id
)
)
{
continue
;
}
$studip_module
=
$tool
->
getStudipModule
();
if
(
!
(
$studip_module
instanceof
StudipModule
))
{
continue
;
}
$tool_nav
=
$studip_module
->
getTabNavigation
(
$this
->
range
->
id
)
?:
[];
foreach
(
$tool_nav
as
$nav_name
=>
$navigation
)
{
if
(
!
$nav_name
||
!
$navigation
instanceof
Navigation
)
{
continue
;
}
if
(
$tool
->
metadata
[
'displayname'
])
{
$navigation
->
setTitle
(
$tool
->
getDisplayname
());
}
$this
->
addSubNavigation
(
$nav_name
,
$navigation
);
}
}
}
}
This diff is collapsed.
Click to expand it.
lib/navigation/StudipNavigation.php
+
1
−
1
View file @
01bf94bc
...
...
@@ -40,7 +40,7 @@ class StudipNavigation extends Navigation
// if a course is selected, the navigation for it will be loaded
if
(
Context
::
getId
())
{
$this
->
addSubNavigation
(
'course'
,
new
CourseNavigation
());
$this
->
addSubNavigation
(
'course'
,
new
CourseNavigation
(
Context
::
get
()
));
}
try
{
...
...
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