File tree Expand file tree Collapse file tree 1 file changed +11
-2
lines changed Expand file tree Collapse file tree 1 file changed +11
-2
lines changed Original file line number Diff line number Diff line change 14
14
$ courseId = api_get_course_int_id ();
15
15
$ groupId = api_get_group_id ();
16
16
$ sessionId = api_get_session_id ();
17
+ $ currentUserId = api_get_user_id ();
17
18
18
19
$ isTutor = false ;
19
20
if (!empty ($ groupId )) {
26
27
27
28
switch ($ action ) {
28
29
case 'preview ' :
30
+ $ userInCourse = false ;
31
+ if (CourseManager::is_user_subscribed_in_course ($ currentUserId , CourseManager::get_course_code_from_course_id ($ courseId ), $ sessionId )) {
32
+ $ userInCourse = true ;
33
+ }
29
34
$ allowToEdit = (
30
35
api_is_allowed_to_edit (false , true ) ||
31
- (api_get_course_setting ('allow_user_edit_announcement ' ) && !api_is_anonymous ()) ||
36
+ (api_get_course_setting ('allow_user_edit_announcement ' ) && !api_is_anonymous () && $ userInCourse ) ||
32
37
($ sessionId && api_is_coach () && api_get_configuration_value ('allow_coach_to_edit_announcements ' ))
33
38
);
34
39
47
52
48
53
// Last chance ... students can send announcements.
49
54
if ($ groupProperties ['announcements_state ' ] == GroupManager::TOOL_PRIVATE_BETWEEN_USERS ) {
50
- $ allowToEdit = true ;
55
+ // check if user is a group member to give access
56
+ $ groupInfo = GroupManager::get_group_properties ($ groupId );
57
+ if (array_key_exists ($ currentUserId ,GroupManager::get_subscribed_users ($ groupInfo ))) {
58
+ $ allowToEdit = true ;
59
+ }
51
60
}
52
61
}
53
62
You can’t perform that action at this time.
0 commit comments