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
f7e119d1
Commit
f7e119d1
authored
4 months ago
by
Rasmus Fuhse
Committed by
Moritz Strohm
4 months ago
Browse files
Options
Downloads
Patches
Plain Diff
course/basicdata: fixed adding lecturers, deputies and tutors, fixes #4846
Closes #4846 Merge request
studip/studip!3631
parent
2d2951ec
No related branches found
No related tags found
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
app/controllers/course/basicdata.php
+36
-18
36 additions, 18 deletions
app/controllers/course/basicdata.php
with
36 additions
and
18 deletions
app/controllers/course/basicdata.php
+
36
−
18
View file @
f7e119d1
...
@@ -612,36 +612,46 @@ class Course_BasicdataController extends AuthenticatedController
...
@@ -612,36 +612,46 @@ class Course_BasicdataController extends AuthenticatedController
public
function
add_member_action
(
$course_id
,
$status
=
'dozent'
)
public
function
add_member_action
(
$course_id
,
$status
=
'dozent'
)
{
{
if
(
!
$GLOBALS
[
'perm'
]
->
have_studip_perm
(
'dozent'
,
$course_id
))
{
throw
new
AccessDeniedException
();
}
// We don't need to check the csrf protection at this point since it
// We don't need to check the csrf protection at this point since it
// is already checked by the multiperson search endpoint
// is already checked by the multiperson search endpoint
// load MultiPersonSearch object
// load MultiPersonSearch object
$mp
=
MultiPersonSearch
::
load
(
"add_member_
{
$status
}{
$course_id
}
"
);
$mp
=
MultiPersonSearch
::
load
(
"add_member_
{
$status
}{
$course_id
}
"
);
switch
(
$status
)
{
$course
=
Course
::
find
(
$course_id
);
case
'tutor'
:
$func
=
'addTutor'
;
break
;
case
'deputy'
:
$func
=
'addDeputy'
;
break
;
default
:
$func
=
'addTeacher'
;
break
;
}
$succeeded
=
[];
$succeeded
=
[];
$failed
=
[];
$failed
=
[];
foreach
(
$mp
->
getAddedUsers
()
as
$a
)
{
foreach
(
$mp
->
getAddedUsers
()
as
$a
)
{
$result
=
$this
->
$func
(
$a
,
$course_id
);
$user
=
User
::
find
(
$a
);
if
(
$result
!==
false
)
{
$result
=
false
;
$succeeded
[]
=
User
::
find
(
$a
)
->
getFullName
(
'no_title_rev'
);
if
(
$status
===
'deputy'
)
{
$result
=
Deputy
::
addDeputy
(
$user
->
id
,
$course
->
id
)
>
0
;
}
else
{
try
{
$course
->
addMember
(
$user
,
$status
===
'tutor'
?
'tutor'
:
'dozent'
);
$result
=
true
;
}
catch
(
\Studip\EnrolmentException
$e
)
{
$result
=
$e
->
getMessage
();
}
}
if
(
$result
===
true
)
{
$succeeded
[]
=
$user
->
getFullName
(
'no_title_rev'
);
}
elseif
(
is_string
(
$result
))
{
$failed
[]
=
[
$user
->
getFullName
(
'no_title_rev'
),
$result
];
}
else
{
}
else
{
$failed
[]
=
User
::
find
(
$a
)
->
getFullName
(
'no_title_rev'
);
$failed
[]
=
[
$user
->
getFullName
(
'no_title_rev'
)
]
;
}
}
}
}
// Only show the success messagebox once
// Only show the success messagebox once
if
(
$succeeded
)
{
if
(
$succeeded
)
{
$course
=
Course
::
find
(
$course_id
);
$status_title
=
get_title_for_status
(
$status
,
count
(
$succeeded
),
$course
->
status
);
$status_title
=
get_title_for_status
(
$status
,
count
(
$succeeded
),
$course
->
status
);
if
(
count
(
$succeeded
)
>
1
)
{
if
(
count
(
$succeeded
)
>
1
)
{
$messagetext
=
sprintf
(
$messagetext
=
sprintf
(
...
@@ -664,9 +674,17 @@ class Course_BasicdataController extends AuthenticatedController
...
@@ -664,9 +674,17 @@ class Course_BasicdataController extends AuthenticatedController
// only show an error messagebox once with list of errors!
// only show an error messagebox once with list of errors!
if
(
$failed
)
{
if
(
$failed
)
{
$messages
=
[];
foreach
(
$failed
as
$fail
)
{
if
(
is_array
(
$fail
))
{
$messages
[]
=
sprintf
(
'%s: %s'
,
$fail
[
0
],
$fail
[
1
]);
}
else
{
$messages
[]
=
$fail
;
}
}
PageLayout
::
postError
(
PageLayout
::
postError
(
_
(
'Bei den folgenden Nutzer/-innen ist ein Fehler aufgetreten'
)
,
_
(
'Bei den folgenden Nutzer/-innen ist ein Fehler aufgetreten'
)
,
array_map
(
'htmlReady'
,
$
failed
)
array_map
(
'htmlReady'
,
$
messages
)
);
);
}
}
$this
->
flash
[
'open'
]
=
'bd_personal'
;
$this
->
flash
[
'open'
]
=
'bd_personal'
;
...
...
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