|
|
|
@ -1440,7 +1440,6 @@ class AnnouncementManager |
|
|
|
|
'announcement.session_id' |
|
|
|
|
); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
$group_memberships = GroupManager::get_group_ids( |
|
|
|
|
$courseId, |
|
|
|
|
api_get_user_id() |
|
|
|
@ -1716,6 +1715,7 @@ class AnnouncementManager |
|
|
|
|
ICON_SIZE_SMALL |
|
|
|
|
); |
|
|
|
|
|
|
|
|
|
$isTutor = false; |
|
|
|
|
if (!empty($group_id)) { |
|
|
|
|
$groupInfo = GroupManager::get_group_properties(api_get_group_id()); |
|
|
|
|
//User has access in the group? |
|
|
|
@ -1725,25 +1725,25 @@ class AnnouncementManager |
|
|
|
|
); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
while ($myrow = Database::fetch_array($result, 'ASSOC')) { |
|
|
|
|
if (!in_array($myrow['id'], $displayed)) { |
|
|
|
|
while ($row = Database::fetch_array($result, 'ASSOC')) { |
|
|
|
|
if (!in_array($row['id'], $displayed)) { |
|
|
|
|
$sent_to_icon = ''; |
|
|
|
|
// the email icon |
|
|
|
|
if ($myrow['email_sent'] == '1') { |
|
|
|
|
if ($row['email_sent'] == '1') { |
|
|
|
|
$sent_to_icon = ' '.$emailIcon; |
|
|
|
|
} |
|
|
|
|
$groupReference = ($myrow['to_group_id'] > 0) ? ' <span class="label label-info">'.get_lang('Group').'</span> ' : ''; |
|
|
|
|
$title = $myrow['title'].$groupReference.$sent_to_icon; |
|
|
|
|
$groupReference = ($row['to_group_id'] > 0) ? ' <span class="label label-info">'.get_lang('Group').'</span> ' : ''; |
|
|
|
|
$title = $row['title'].$groupReference.$sent_to_icon; |
|
|
|
|
$item_visibility = api_get_item_visibility( |
|
|
|
|
$courseInfo, |
|
|
|
|
TOOL_ANNOUNCEMENT, |
|
|
|
|
$myrow['id'], |
|
|
|
|
$row['id'], |
|
|
|
|
$session_id |
|
|
|
|
); |
|
|
|
|
$myrow['visibility'] = $item_visibility; |
|
|
|
|
$row['visibility'] = $item_visibility; |
|
|
|
|
|
|
|
|
|
// show attachment list |
|
|
|
|
$attachment_list = self::get_attachment($myrow['id']); |
|
|
|
|
$attachment_list = self::get_attachment($row['id']); |
|
|
|
|
|
|
|
|
|
$attachment_icon = ''; |
|
|
|
|
if (count($attachment_list) > 0) { |
|
|
|
@ -1751,7 +1751,7 @@ class AnnouncementManager |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
/* TITLE */ |
|
|
|
|
$user_info = api_get_user_info($myrow['insert_user_id']); |
|
|
|
|
$user_info = api_get_user_info($row['insert_user_id']); |
|
|
|
|
$username = sprintf(get_lang("LoginX"), $user_info['username']); |
|
|
|
|
|
|
|
|
|
$username_span = Display::tag( |
|
|
|
@ -1762,62 +1762,62 @@ class AnnouncementManager |
|
|
|
|
|
|
|
|
|
$title = Display::url( |
|
|
|
|
$title.$attachment_icon, |
|
|
|
|
$actionUrl.'&action=view&id='.$myrow['id'] |
|
|
|
|
$actionUrl.'&action=view&id='.$row['id'] |
|
|
|
|
); |
|
|
|
|
|
|
|
|
|
// 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(false, true) || |
|
|
|
|
(api_is_session_general_coach() && api_is_element_in_the_session(TOOL_ANNOUNCEMENT, $myrow['id'])) || |
|
|
|
|
(api_is_session_general_coach() && api_is_element_in_the_session(TOOL_ANNOUNCEMENT, $row['id'])) || |
|
|
|
|
(api_get_course_setting('allow_user_edit_announcement') && !api_is_anonymous()) || |
|
|
|
|
($myrow['to_group_id'] == $group_id && $isTutor) |
|
|
|
|
($row['to_group_id'] == $group_id && $isTutor) |
|
|
|
|
) { |
|
|
|
|
$modify_icons = "<a href=\"".$actionUrl."&action=modify&id=".$myrow['id']."\">".$editIcon."</a>"; |
|
|
|
|
if ($myrow['visibility'] == 1) { |
|
|
|
|
$modify_icons = "<a href=\"".$actionUrl."&action=modify&id=".$row['id']."\">".$editIcon."</a>"; |
|
|
|
|
if ($row['visibility'] == 1) { |
|
|
|
|
$image_visibility = "visible"; |
|
|
|
|
$alt_visibility = get_lang('Hide'); |
|
|
|
|
} else { |
|
|
|
|
$image_visibility = "invisible"; |
|
|
|
|
$alt_visibility = get_lang('Visible'); |
|
|
|
|
} |
|
|
|
|
$modify_icons .= "<a href=\"".$actionUrl."&action=showhide&id=".$myrow['id']."&sec_token=".$stok."\">". |
|
|
|
|
$modify_icons .= "<a href=\"".$actionUrl."&action=showhide&id=".$row['id']."&sec_token=".$stok."\">". |
|
|
|
|
Display::return_icon($image_visibility.'.png', $alt_visibility, '', ICON_SIZE_SMALL)."</a>"; |
|
|
|
|
|
|
|
|
|
// DISPLAY MOVE UP COMMAND only if it is not the top announcement |
|
|
|
|
if ($iterator != 1) { |
|
|
|
|
$modify_icons .= "<a href=\"".$actionUrl."&action=move&up=".$myrow["id"]."&sec_token=".$stok."\">". |
|
|
|
|
$modify_icons .= "<a href=\"".$actionUrl."&action=move&up=".$row["id"]."&sec_token=".$stok."\">". |
|
|
|
|
Display::return_icon('up.gif', get_lang('Up'))."</a>"; |
|
|
|
|
} else { |
|
|
|
|
$modify_icons .= Display::return_icon('up_na.gif', get_lang('Up')); |
|
|
|
|
} |
|
|
|
|
if ($iterator < $bottomAnnouncement) { |
|
|
|
|
$modify_icons .= "<a href=\"".$actionUrl."&action=move&down=".$myrow["id"]."&sec_token=".$stok."\">". |
|
|
|
|
$modify_icons .= "<a href=\"".$actionUrl."&action=move&down=".$row["id"]."&sec_token=".$stok."\">". |
|
|
|
|
Display::return_icon('down.gif', get_lang('Down'))."</a>"; |
|
|
|
|
} else { |
|
|
|
|
$modify_icons .= Display::return_icon('down_na.gif', get_lang('Down')); |
|
|
|
|
} |
|
|
|
|
if (api_is_allowed_to_edit(false, true)) { |
|
|
|
|
$modify_icons .= "<a href=\"".$actionUrl."&action=delete&id=".$myrow['id']."&sec_token=".$stok."\" onclick=\"javascript:if(!confirm('".addslashes(api_htmlentities(get_lang('ConfirmYourChoice'), ENT_QUOTES, api_get_system_encoding()))."')) return false;\">". |
|
|
|
|
$modify_icons .= "<a href=\"".$actionUrl."&action=delete&id=".$row['id']."&sec_token=".$stok."\" onclick=\"javascript:if(!confirm('".addslashes(api_htmlentities(get_lang('ConfirmYourChoice'), ENT_QUOTES, api_get_system_encoding()))."')) return false;\">". |
|
|
|
|
$deleteIcon."</a>"; |
|
|
|
|
} |
|
|
|
|
$iterator++; |
|
|
|
|
} else { |
|
|
|
|
$modify_icons = Display::url( |
|
|
|
|
Display::return_icon('default.png'), |
|
|
|
|
$actionUrl.'&action=view&id='.$myrow['id'] |
|
|
|
|
$actionUrl.'&action=view&id='.$row['id'] |
|
|
|
|
); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
$announcement = [ |
|
|
|
|
'id' => $myrow['id'], |
|
|
|
|
'id' => $row['id'], |
|
|
|
|
'title' => $title, |
|
|
|
|
'username' => $username_span, |
|
|
|
|
'insert_date' => api_convert_and_format_date( |
|
|
|
|
$myrow['insert_date'], |
|
|
|
|
$row['insert_date'], |
|
|
|
|
DATE_TIME_FORMAT_LONG |
|
|
|
|
), |
|
|
|
|
'lastedit_date' => api_convert_and_format_date( |
|
|
|
|
$myrow['lastedit_date'], |
|
|
|
|
$row['lastedit_date'], |
|
|
|
|
DATE_TIME_FORMAT_LONG |
|
|
|
|
), |
|
|
|
|
'actions' => $modify_icons |
|
|
|
@ -1825,7 +1825,7 @@ class AnnouncementManager |
|
|
|
|
|
|
|
|
|
$results[] = $announcement; |
|
|
|
|
} |
|
|
|
|
$displayed[] = $myrow['id']; |
|
|
|
|
$displayed[] = $row['id']; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
return $results; |
|
|
|
|