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
db07cf0a
Commit
db07cf0a
authored
2 years ago
by
Moritz Strohm
Browse files
Options
Downloads
Patches
Plain Diff
TIC #877
Merge request
studip/studip!488
parent
3ac58fb1
No related branches found
No related tags found
No related merge requests found
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
app/controllers/course/members.php
+133
-7
133 additions, 7 deletions
app/controllers/course/members.php
app/controllers/messages.php
+62
-31
62 additions, 31 deletions
app/controllers/messages.php
app/views/course/members/circular_mail.php
+101
-0
101 additions, 0 deletions
app/views/course/members/circular_mail.php
with
296 additions
and
38 deletions
app/controllers/course/members.php
+
133
−
7
View file @
db07cf0a
...
...
@@ -1423,15 +1423,13 @@ class Course_MembersController extends AuthenticatedController
if
(
$this
->
is_tutor
||
$this
->
config
->
COURSE_STUDENT_MAILING
)
{
$widget
->
addLink
(
_
(
'Nachricht an alle eingetragenen Teilnehmenden (Rundmail)'
),
URLHelper
::
getURL
(
'dispatch.php/messages/write'
,
[
'course_id'
=>
$this
->
course_id
,
'default_subject'
=>
$this
->
subject
,
'filter'
=>
'all'
,
'emailrequest'
=>
1
_
(
'Rundmail schreiben'
),
URLHelper
::
getURL
(
'dispatch.php/course/members/circular_mail'
,
[
'course_id'
=>
$this
->
course_id
,
'default_subject'
=>
$this
->
subject
]),
Icon
::
create
(
'inbox'
)
)
->
asDialog
();
)
->
asDialog
(
'size=auto'
);
}
if
(
$this
->
is_tutor
)
{
//Calculate the course institutes here since they are needed
...
...
@@ -1820,4 +1818,132 @@ class Course_MembersController extends AuthenticatedController
$this
->
redirect
(
'course/members'
);
}
public
function
circular_mail_action
()
{
if
(
!
$this
->
is_tutor
||
(
$this
->
config
->
COURSE_STUDENT_MAILING
&&
!
$this
->
is_autor
))
{
throw
new
AccessDeniedException
();
}
//Calculate the amount of recipients for each group:
$this
->
user_count
=
CourseMember
::
countByCourseAndStatus
(
$this
->
course_id
,
'user'
);
$this
->
autor_count
=
CourseMember
::
countByCourseAndStatus
(
$this
->
course_id
,
'autor'
);
$this
->
tutor_count
=
CourseMember
::
countByCourseAndStatus
(
$this
->
course_id
,
'tutor'
);
$this
->
dozent_count
=
CourseMember
::
countByCourseAndStatus
(
$this
->
course_id
,
'dozent'
);
//Use the correct names for thte four status groups:
$sem
=
Seminar
::
GetInstance
(
$this
->
course_id
);
$this
->
user_name
=
get_title_for_status
(
'user'
,
0
,
$sem
->
status
);
$this
->
autor_name
=
get_title_for_status
(
'autor'
,
0
,
$sem
->
status
);
$this
->
tutor_name
=
get_title_for_status
(
'tutor'
,
0
,
$sem
->
status
);
$this
->
dozent_name
=
get_title_for_status
(
'dozent'
,
0
,
$sem
->
status
);
if
(
$this
->
is_tutor
)
{
$this
->
awaiting_count
=
AdmissionApplication
::
countBySql
(
"seminar_id = :course_id AND status = 'awaiting'"
,
[
'course_id'
=>
$this
->
course_id
]
);
$this
->
accepted_count
=
AdmissionApplication
::
countBySql
(
"seminar_id = :course_id AND status = 'accepted'"
,
[
'course_id'
=>
$this
->
course_id
]
);
}
$this
->
default_selected_groups
=
[
'dozent'
,
'tutor'
,
'autor'
,
'user'
];
$this
->
all_available_groups
=
$this
->
default_selected_groups
;
if
(
$this
->
is_tutor
)
{
//The user has at least tutor permissions:
if
(
$this
->
accepted_count
)
{
$this
->
all_available_groups
[]
=
'accepted'
;
}
if
(
$this
->
awaiting_count
)
{
$this
->
all_available_groups
[]
=
'awaiting'
;
}
}
if
(
Request
::
submitted
(
'write'
))
{
CSRFProtection
::
verifyUnsafeRequest
();
$this
->
selected_groups
=
Request
::
getArray
(
'selected_groups'
);
//Filter all selected groups by the list of all available groups:
$filtered_groups
=
[];
foreach
(
$this
->
selected_groups
as
$group
)
{
if
(
in_array
(
$group
,
$this
->
all_available_groups
))
{
$filtered_groups
[]
=
$group
;
}
}
if
(
$filtered_groups
==
$this
->
default_selected_groups
)
{
$this
->
redirect
(
URLHelper
::
getURL
(
'dispatch.php/messages/write'
,
[
'course_id'
=>
$this
->
course_id
,
'default_subject'
=>
$this
->
subject
,
'filter'
=>
'all'
,
'emailrequest'
=>
1
]
));
}
elseif
(
$filtered_groups
==
$this
->
all_available_groups
)
{
$this
->
redirect
(
URLHelper
::
getURL
(
'dispatch.php/messages/write'
,
[
'course_id'
=>
$this
->
course_id
,
'default_subject'
=>
$this
->
subject
,
'filter'
=>
'really_all'
,
'emailrequest'
=>
1
]
));
}
else
{
//Do custom filtering.
$filters
=
[];
$who_param
=
[];
foreach
(
$filtered_groups
as
$group
)
{
if
(
$group
===
'awaiting'
)
{
$filters
[]
=
'awaiting'
;
}
elseif
(
$group
===
'accepted'
)
{
$filters
[]
=
'prelim'
;
}
elseif
(
$group
===
'user'
)
{
$filters
[]
=
'all'
;
$who_param
[]
=
'user'
;
}
elseif
(
$group
===
'autor'
)
{
$filters
[]
=
'all'
;
$who_param
[]
=
'autor'
;
}
elseif
(
$group
===
'tutor'
)
{
$filters
[]
=
'all'
;
$who_param
[]
=
'tutor'
;
}
elseif
(
$group
===
'dozent'
)
{
$filters
[]
=
'all'
;
$who_param
[]
=
'dozent'
;
}
}
$filters
=
array_unique
(
$filters
);
if
(
!
$filters
)
{
PageLayout
::
postError
(
_
(
'Es wurde keine Gruppe ausgewählt!'
)
);
return
;
}
$url_params
=
[
'course_id'
=>
$this
->
course_id
,
'default_subject'
=>
$this
->
subject
,
'filter'
=>
implode
(
','
,
array_unique
(
$filters
)),
'emailrequest'
=>
1
];
if
(
$who_param
)
{
$url_params
[
'who'
]
=
implode
(
','
,
$who_param
);
}
//print_r($url_params);die();
$this
->
redirect
(
URLHelper
::
getURL
(
'dispatch.php/messages/write'
,
$url_params
));
}
}
}
}
This diff is collapsed.
Click to expand it.
app/controllers/messages.php
+
62
−
31
View file @
db07cf0a
...
...
@@ -287,57 +287,83 @@ class MessagesController extends AuthenticatedController {
}
//check if the message shall be sent to all (or some) members of a course:
$filter
=
Request
::
get
(
'filter'
);
$course
=
Course
::
find
(
Request
::
option
(
'course_id'
));
if
(
$filter
&&
$course
)
{
if
(
$GLOBALS
[
'perm'
]
->
have_studip_perm
(
'tutor'
,
$course
->
id
)
||
(
$GLOBALS
[
'perm'
]
->
have_studip_perm
(
'autor'
,
$course
->
id
)
&&
(
$course
->
getSemClass
()[
'studygroup_mode'
]
||
CourseConfig
::
get
(
$course
->
id
)
->
COURSE_STUDENT_MAILING
)))
{
$this
->
default_message
->
receivers
=
[];
$filters
=
explode
(
','
,
Request
::
get
(
'filter'
,
''
));
if
(
$filters
&&
Request
::
option
(
'course_id'
))
{
$additional
=
''
;
$course
=
new
Course
(
Request
::
option
(
'course_id'
));
$allow_tutor_filters
=
false
;
if
(
$GLOBALS
[
'perm'
]
->
have_studip_perm
(
'tutor'
,
$course
->
id
)
||
$course
->
getSemClass
()[
'studygroup_mode'
]
||
CourseConfig
::
get
(
$course
->
id
)
->
COURSE_STUDENT_MAILING
)
{
$allow_tutor_filters
=
true
;
$additional
=
" AND seminar_user.visible != 'no'"
;
}
$this
->
default_message
->
receivers
=
[];
$all_recipients
=
[];
foreach
(
$filters
as
$filter
)
{
$query
=
''
;
$params
=
[
$course
->
id
,
Request
::
option
(
'who'
)];
if
(
$GLOBALS
[
'perm'
]
->
have_studip_perm
(
'tutor'
,
$course
->
id
))
{
if
(
$filter
===
'send_sms_to_all'
)
{
$query
=
"SELECT user_id, 'rec' AS snd_rec
$params
=
[
'course_id'
=>
$course
->
id
];
if
(
Request
::
get
(
'who'
))
{
$params
[
'status'
]
=
explode
(
','
,
Request
::
get
(
'who'
,
''
));
}
if
(
$filter
===
'send_sms_to_all'
&&
$allow_tutor_filters
)
{
$query
=
"SELECT user_id, 'rec' AS snd_rec
FROM seminar_user
JOIN auth_user_md5 USING (user_id)
WHERE Seminar_id =
?
AND status
= ?
WHERE Seminar_id =
:course_id
AND status
IN ( :status )
{
$additional
}
ORDER BY Nachname, Vorname"
;
}
elseif
(
$filter
===
'all'
)
{
$query
=
"SELECT user_id, 'rec' AS snd_rec
}
elseif
(
$filter
===
'all'
)
{
if
(
$params
[
'status'
])
{
$additional
.
=
' AND seminar_user.status IN ( :status )'
;
}
$query
=
"SELECT user_id, 'rec' AS snd_rec
FROM seminar_user
JOIN auth_user_md5 USING (user_id)
WHERE Seminar_id =
?
WHERE Seminar_id =
:course_id
{
$additional
}
ORDER BY Nachname, Vorname"
;
}
elseif
(
$filter
===
'prelim'
)
{
$query
=
"SELECT user_id, 'rec' AS snd_rec
}
elseif
(
$filter
===
'really_all'
&&
$allow_tutor_filters
)
{
$query
=
"SELECT user_id, 'rec' as snd_rec
FROM seminar_user
WHERE seminar_id = :course_id
UNION SELECT user_id, 'rec' as snd_rec FROM admission_seminar_user WHERE seminar_id = :course_id
UNION SELECT user_id, 'rec' as snd_rec FROM priorities WHERE seminar_id = :course_id"
;
}
elseif
(
$filter
===
'prelim'
&&
$allow_tutor_filters
)
{
$query
=
"SELECT user_id, 'rec' AS snd_rec
FROM admission_seminar_user
JOIN auth_user_md5 USING (user_id)
WHERE
s
eminar_id =
?
AND status = 'accepted'
WHERE
S
eminar_id =
:course_id
AND status = 'accepted'
ORDER BY Nachname, Vorname"
;
}
elseif
(
$filter
===
'awaiting'
)
{
$query
=
"SELECT user_id, 'rec' AS snd_rec
}
elseif
(
$filter
===
'awaiting'
&&
$allow_tutor_filters
)
{
$query
=
"SELECT user_id, 'rec' AS snd_rec
FROM admission_seminar_user
JOIN auth_user_md5 USING (user_id)
WHERE seminar_id = ? AND status = 'awaiting'
WHERE Seminar_id = :course_id AND status = 'awaiting'
ORDER BY Nachname, Vorname"
;
}
elseif
(
$filter
===
'inst_status'
)
{
$query
=
"SELECT user_id, 'rec' AS snd_rec
FROM user_inst
JOIN auth_user_md5 USING (user_id)
WHERE Institut_id = :course_id AND inst_perms IN ( :status )
{
$additional
}
ORDER BY Nachname, Vorname"
;
}
elseif
(
$filter
===
'not_grouped'
)
{
$query
=
"SELECT seminar_user.user_id, 'rec' as snd_rec
}
elseif
(
$filter
===
'not_grouped'
&&
$allow_tutor_filters
)
{
$query
=
"SELECT seminar_user.user_id, 'rec' as snd_rec
FROM seminar_user
JOIN auth_user_md5 USING (user_id)
LEFT JOIN statusgruppen ON range_id = seminar_id
LEFT JOIN statusgruppe_user ON statusgruppen.statusgruppe_id = statusgruppe_user.statusgruppe_id
AND seminar_user.user_id = statusgruppe_user.user_id
WHERE seminar_id =
?
WHERE seminar_id =
:course_id
GROUP BY seminar_user.user_id
HAVING COUNT(statusgruppe_user.statusgruppe_id) = 0
ORDER BY Nachname, Vorname"
;
}
elseif
(
$filter
===
'claiming'
)
{
$cs
=
CourseSet
::
getSetForCourse
(
$course
->
id
);
if
(
is_object
(
$cs
)
&&
!
$cs
->
hasAlgorithmRun
())
{
foreach
(
AdmissionPriority
::
getPrioritiesByCourse
(
$cs
->
getId
(),
$course
->
id
)
as
$user_id
=>
$p
)
{
$this
->
default_message
->
receivers
[]
=
MessageUser
::
build
([
'user_id'
=>
$user_id
,
'snd_rec'
=>
'rec'
]);
}
}
elseif
(
$filter
===
'claiming'
&&
$allow_tutor_filters
)
{
$cs
=
CourseSet
::
getSetForCourse
(
$course
->
id
);
if
(
is_object
(
$cs
)
&&
!
$cs
->
hasAlgorithmRun
())
{
foreach
(
AdmissionPriority
::
getPrioritiesByCourse
(
$cs
->
getId
(),
$course
->
id
)
as
$user_id
=>
$p
)
{
$all_recipients
=
array_merge
(
$all_recipients
,
MessageUser
::
build
([
'user_id'
=>
$user_id
,
'snd_rec'
=>
'rec'
])
);
}
}
}
else
{
...
...
@@ -348,11 +374,16 @@ class MessagesController extends AuthenticatedController {
ORDER BY Nachname, Vorname"
;
}
if
(
$query
)
{
$this
->
default_message
->
receivers
=
DBManager
::
get
()
->
fetchAll
(
$query
,
$params
,
'MessageUser::build'
);
$all_recipients
=
array_merge
(
$all_recipients
,
DBManager
::
get
()
->
fetchAll
(
$query
,
$params
,
'MessageUser::build'
)
);
}
}
$this
->
default_message
->
receivers
=
$all_recipients
;
}
if
(
Request
::
option
(
'prof_id'
)
&&
Request
::
option
(
'deg_id'
)
&&
$GLOBALS
[
'perm'
]
->
have_perm
(
'root'
))
{
$query
=
"SELECT DISTINCT user_id,'rec' as snd_rec
FROM user_studiengang
...
...
This diff is collapsed.
Click to expand it.
app/views/course/members/circular_mail.php
0 → 100644
+
101
−
0
View file @
db07cf0a
<form
class=
"default"
method=
"post"
action=
"
<?=
$controller
->
link_for
(
'course/members/circular_mail'
)
?>
"
data-dialog
>
<?=
CSRFProtection
::
tokenTag
()
?>
<fieldset>
<legend>
<?=
_
(
'An wen möchten Sie eine Rundmail schreiben?'
)
?>
</legend>
<p
aria-hidden=
"true"
>
<?=
_
(
'An wen möchten Sie eine Rundmail schreiben?'
)
?>
</p>
<?
if
(
in_array
(
'dozent'
,
$all_available_groups
))
:
?>
<label>
<input
type=
"checkbox"
name=
"selected_groups[]"
value=
"dozent"
<?
if
(
!
$dozent_count
)
:
echo
'disabled'
;
?>
<?
elseif
(
in_array
(
'dozent'
,
$default_selected_groups
))
:
echo
'checked'
;
?>
<?
endif
;
?>
>
<?=
htmlready
(
$dozent_name
)
?>
<em>
(
<?=
sprintf
(
ngettext
(
'%u Person'
,
'%u Personen'
,
$dozent_count
),
$dozent_count
)
?>
)
</em>
</label>
<?
endif
?>
<?
if
(
in_array
(
'tutor'
,
$all_available_groups
))
:
?>
<label>
<input
type=
"checkbox"
name=
"selected_groups[]"
value=
"tutor"
<?
if
(
!
$tutor_count
)
:
echo
'disabled'
;
?>
<?
elseif
(
in_array
(
'tutor'
,
$default_selected_groups
))
:
echo
'checked'
;
?>
<?
endif
;
?>
>
<?=
htmlReady
(
$tutor_name
)
?>
<em>
(
<?=
sprintf
(
ngettext
(
'%u Person'
,
'%u Personen'
,
$tutor_count
),
$tutor_count
)
?>
)
</em>
</label>
<?
endif
?>
<?
if
(
in_array
(
'autor'
,
$all_available_groups
))
:
?>
<label>
<input
type=
"checkbox"
name=
"selected_groups[]"
value=
"autor"
<?
if
(
!
$autor_count
)
:
echo
'disabled'
;
?>
<?
elseif
(
in_array
(
'autor'
,
$default_selected_groups
))
:
echo
'checked'
;
?>
<?
endif
;
?>
>
<?=
htmlReady
(
$autor_name
)
?>
<em>
(
<?=
sprintf
(
ngettext
(
'%u Person'
,
'%u Personen'
,
$autor_count
),
$autor_count
)
?>
)
</em>
</label>
<?
endif
?>
<?
if
(
in_array
(
'user'
,
$all_available_groups
))
:
?>
<label>
<input
type=
"checkbox"
name=
"selected_groups[]"
value=
"user"
<?
if
(
!
$user_count
)
:
echo
'disabled'
;
?>
<?
elseif
(
in_array
(
'user'
,
$default_selected_groups
))
:
echo
'checked'
;
?>
<?
endif
;
?>
>
<?=
htmlReady
(
$user_name
)
?>
<em>
(
<?=
sprintf
(
ngettext
(
'%u Person'
,
'%u Personen'
,
$user_count
),
$user_count
)
?>
)
</em>
</label>
<?
endif
?>
<?
if
(
in_array
(
'accepted'
,
$all_available_groups
))
:
?>
<label>
<input
type=
"checkbox"
name=
"selected_groups[]"
value=
"accepted"
<?
if
(
!
$accepted_count
)
:
echo
'disabled'
;
?>
<?
elseif
(
in_array
(
'accepted'
,
$default_selected_groups
))
:
echo
'checked'
;
?>
<?
endif
;
?>
>
<?=
_
(
'Alle vorläufig akzeptierten Teilnehmende der Veranstaltung'
)
?>
<em>
(
<?=
sprintf
(
ngettext
(
'%u Person'
,
'%u Personen'
,
$accepted_count
),
$accepted_count
)
?>
)
</em>
</label>
<?
endif
?>
<?
if
(
in_array
(
'awaiting'
,
$all_available_groups
))
:
?>
<label>
<input
type=
"checkbox"
name=
"selected_groups[]"
value=
"awaiting"
<?
if
(
!
$awaiting_count
)
:
echo
'disabled'
;
?>
<?
elseif
(
in_array
(
'awaiting'
,
$default_selected_groups
))
:
echo
'checked'
;
?>
<?
endif
;
?>
>
<?=
_
(
'Alle Personen auf der Warteliste der Veranstaltung'
)
?>
<em>
(
<?=
sprintf
(
ngettext
(
'%u Person'
,
'%u Personen'
,
$awaiting_count
),
$awaiting_count
)
?>
)
</em>
</label>
<?
endif
?>
</fieldset>
<div
data-dialog-button
>
<?=
\Studip\Button
::
create
(
_
(
'Rundmail schreiben'
),
'write'
)
?>
</div>
</form>
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