Should fix bug when hiding announcements in a session see #4463

skala
Julio Montoya 13 years ago
parent ae35d7f8ae
commit 477ad96203
  1. 3
      main/announcements/announcements.inc.php
  2. 8
      main/announcements/announcements.php
  3. 11
      main/inc/lib/main_api.lib.php

@ -88,7 +88,8 @@ class AnnouncementManager {
* @return bool False on failure, True on success
*/
public static function change_visibility_announcement($_course, $id) {
$item_visibility = api_get_item_visibility($_course, TOOL_ANNOUNCEMENT, $id);
$session_id = api_get_session_id();
$item_visibility = api_get_item_visibility($_course, TOOL_ANNOUNCEMENT, $id, $session_id);
if ($item_visibility == '1') {
api_item_property_update($_course, TOOL_ANNOUNCEMENT, $id, 'invisible', api_get_user_id());
} else {

@ -198,6 +198,7 @@ if (api_is_allowed_to_edit(false,true) OR (api_get_course_setting('allow_user_ed
}
if (!api_is_course_coach() || api_is_element_in_the_session(TOOL_ANNOUNCEMENT, $_GET['id'])) {
if ($ctok == $_GET['sec_token']) {
AnnouncementManager::change_visibility_announcement($_course, $_GET['id']);
$message = get_lang('VisibilityChanged');
}
@ -552,8 +553,7 @@ if(api_is_allowed_to_edit(false,true)) {
}
$sql = "SELECT announcement.*, ip.visibility, ip.to_group_id, ip.insert_user_id
FROM $tbl_announcement announcement, $tbl_item_property ip
WHERE
announcement.c_id = $course_id AND
WHERE announcement.c_id = $course_id AND
ip.c_id = $course_id AND
announcement.id = ip.ref AND
ip.tool = 'announcement' AND
@ -1113,6 +1113,9 @@ if ($display_announcement_list) {
/* DATE */
$last_post_datetime = $myrow['end_date'];
$item_visibility = api_get_item_visibility($_course, TOOL_ANNOUNCEMENT, $myrow['id'], $session_id);
$myrow['visibility'] = $item_visibility;
// the styles
if ($myrow['visibility'] == '0') {
$style='invisible';
@ -1126,7 +1129,6 @@ if ($display_announcement_list) {
$attachment_list = array();
$attachment_list = AnnouncementManager::get_attachment($myrow['id']);
$attachment = '';
$attachment_icon = '';
if (count($attachment_list)>0) {
$attachment_icon = ' '.Display::return_icon('attachment.gif',get_lang('Attachment'));

@ -1817,16 +1817,20 @@ function api_get_session_image($session_id, $status_id) {
* @param bool optional, true to accept content with session=0 as well, false for strict session condition
* @return string condition of the session
*/
function api_get_session_condition($session_id, $and = true, $with_base_content = false) {
function api_get_session_condition($session_id, $and = true, $with_base_content = false, $session_field = "session_id") {
$session_id = intval($session_id);
if (empty($session_field)) {
$session_field = "session_id";
}
//condition to show resources by session
$condition_session = '';
$condition_add = $and ? " AND " : " WHERE ";
if ($with_base_content) {
$condition_session = $condition_add." (session_id = $session_id OR session_id = 0) ";
$condition_session = $condition_add." ( $session_field = $session_id OR $session_field = 0) ";
} else {
$condition_session = $condition_add." session_id = $session_id ";
$condition_session = $condition_add." $session_field = $session_id ";
}
return $condition_session;
}
@ -2758,6 +2762,7 @@ function api_item_property_update($_course, $tool, $item_id, $lastedit_type, $us
$session_id = api_get_session_id();
}
// Definition of tables.
$TABLE_ITEMPROPERTY = Database::get_course_table(TABLE_ITEM_PROPERTY);

Loading…
Cancel
Save