diff --git a/main/announcements/announcements.php b/main/announcements/announcements.php index 28a71d8f1d..36d8b36745 100644 --- a/main/announcements/announcements.php +++ b/main/announcements/announcements.php @@ -1,4 +1,4 @@ - ".get_lang("AddAnnouncement")."
"; } - if (api_is_allowed_to_edit(false,true) && $announcement_number > 1) + if (api_is_allowed_to_edit() && $announcement_number > 1) { echo " ".get_lang("AnnouncementDeleteAll")."\n"; } // if announcementNumber > 1 @@ -1146,7 +1160,7 @@ if (isset($message) && $message == true) //$group_memberships=GroupManager::get_group_ids($_course['dbName'], $_user['user_id']); $group_memberships=GroupManager::get_group_ids($_course['dbName'],$_user['user_id']); - if (api_is_allowed_to_edit(false,true) ) + if (api_is_allowed_to_edit(false,true)) { // A.1. you are a course admin with a USER filter // => see only the messages of this specific user + the messages of the group (s)he is member of. @@ -1422,9 +1436,10 @@ if (isset($message) && $message == true) echo "
"; - - if(api_is_allowed_to_edit(false,true) OR (api_get_course_setting('allow_user_edit_announcement') && !api_is_anonymous())) + // we can edit if : we are the teacher OR the element belongs to the session we are coaching OR the option to allow users to edit is on + if(api_is_allowed_to_edit() OR (api_is_course_coach() && api_is_element_in_the_session(TOOL_ANNOUNCEMENT,$myrow['id'])) OR (api_get_course_setting('allow_user_edit_announcement') && !api_is_anonymous())) { + /*===================================================================== SHOW MOD/DEL/VIS FUNCTIONS =====================================================================*/ diff --git a/main/inc/lib/main_api.lib.php b/main/inc/lib/main_api.lib.php index e26863e7d2..6d1c6384f5 100644 --- a/main/inc/lib/main_api.lib.php +++ b/main/inc/lib/main_api.lib.php @@ -3119,6 +3119,10 @@ function api_is_element_in_the_session($tool, $element_id, $session_id=null) $table_tool = Database::get_course_table(TABLE_SURVEY); $key_field = 'survey_id'; break; + case TOOL_ANNOUNCEMENT : + $table_tool = Database::get_course_table(TABLE_ANNOUNCEMENT); + $key_field = 'id'; + break; default: return false; }