|
|
|
@ -193,9 +193,9 @@ if (api_is_allowed_to_edit(false,true) OR (api_get_course_setting('allow_user_ed |
|
|
|
|
if (api_get_session_id()!=0 && api_is_allowed_to_session_edit(false,true)==false) { |
|
|
|
|
api_not_allowed(); |
|
|
|
|
} |
|
|
|
|
if (!api_is_course_coach() || api_is_element_in_the_session(TOOL_ANNOUNCEMENT, $_GET['id'])) { |
|
|
|
|
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'); |
|
|
|
|
} |
|
|
|
@ -225,7 +225,7 @@ if (api_is_allowed_to_edit(false,true) OR (api_get_course_setting('allow_user_ed |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
//delete attachment file |
|
|
|
|
if (isset($_GET['action']) && $_GET['action'] == 'delete_attachment') { |
|
|
|
|
$id = $_GET['id_attach']; |
|
|
|
@ -235,7 +235,7 @@ if (api_is_allowed_to_edit(false,true) OR (api_get_course_setting('allow_user_ed |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/* |
|
|
|
|
Delete all announcements |
|
|
|
|
*/ |
|
|
|
@ -252,7 +252,7 @@ if (api_is_allowed_to_edit(false,true) OR (api_get_course_setting('allow_user_ed |
|
|
|
|
/* |
|
|
|
|
Modify announcement |
|
|
|
|
*/ |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if (!empty($_GET['action']) and $_GET['action']=='modify' AND isset($_GET['id'])) { |
|
|
|
|
if (api_get_session_id()!=0 && api_is_allowed_to_session_edit(false,true)==false) { |
|
|
|
|
api_not_allowed(); |
|
|
|
@ -269,7 +269,7 @@ if (api_is_allowed_to_edit(false,true) OR (api_get_course_setting('allow_user_ed |
|
|
|
|
$myrow = Database::fetch_array($rs); |
|
|
|
|
$last_id = $id; |
|
|
|
|
$edit_attachment = AnnouncementManager::edit_announcement_attachment_file($last_id, $_FILES['user_upload'], $file_comment); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if ($myrow) { |
|
|
|
|
$announcement_to_modify = $myrow['id']; |
|
|
|
|
$content_to_modify = $myrow['content']; |
|
|
|
@ -314,7 +314,7 @@ if (api_is_allowed_to_edit(false,true) OR (api_get_course_setting('allow_user_ed |
|
|
|
|
"$tbl_item_property itemproperty " . |
|
|
|
|
"WHERE |
|
|
|
|
announcement.c_id = $course_id AND |
|
|
|
|
itemproperty.c_id = $course_id AND |
|
|
|
|
itemproperty.c_id = $course_id AND |
|
|
|
|
itemproperty.ref=announcement.id " . |
|
|
|
|
"AND itemproperty.tool='".TOOL_ANNOUNCEMENT."' " . |
|
|
|
|
"AND itemproperty.visibility<>2 " . |
|
|
|
@ -368,11 +368,11 @@ if (api_is_allowed_to_edit(false,true) OR (api_get_course_setting('allow_user_ed |
|
|
|
|
$file_comment = $_POST['file_comment']; |
|
|
|
|
$file = $_FILES['user_upload']; |
|
|
|
|
AnnouncementManager::edit_announcement($id, $emailTitle, $newContent, $_POST['selectedform'], $file, $file_comment); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/* MAIL FUNCTION */ |
|
|
|
|
if ($_POST['email_ann'] && empty($_POST['onlyThoseMails'])) { |
|
|
|
|
AnnouncementManager::send_email($id); |
|
|
|
|
} |
|
|
|
|
if ($_POST['email_ann'] && empty($_POST['onlyThoseMails'])) { |
|
|
|
|
AnnouncementManager::send_email($id); |
|
|
|
|
} |
|
|
|
|
$message = get_lang('AnnouncementModified'); |
|
|
|
|
} |
|
|
|
|
} else { |
|
|
|
@ -393,13 +393,13 @@ if (api_is_allowed_to_edit(false,true) OR (api_get_course_setting('allow_user_ed |
|
|
|
|
} |
|
|
|
|
//store_resources($_SESSION['source_type'],$insert_id); |
|
|
|
|
$_SESSION['select_groupusers']="hide"; |
|
|
|
|
$message = get_lang('AnnouncementAdded'); |
|
|
|
|
$message = get_lang('AnnouncementAdded'); |
|
|
|
|
|
|
|
|
|
/* MAIL FUNCTION */ |
|
|
|
|
if ($_POST['email_ann'] && empty($_POST['onlyThoseMails'])) { |
|
|
|
|
AnnouncementManager::send_email($insert_id); |
|
|
|
|
AnnouncementManager::send_email($insert_id); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
} // end condition token |
|
|
|
|
} // isset |
|
|
|
|
|
|
|
|
@ -442,9 +442,9 @@ 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 |
|
|
|
|
ip.c_id = $course_id AND |
|
|
|
|
announcement.id = ip.ref AND |
|
|
|
|
ip.tool = 'announcement' AND |
|
|
|
|
ip.c_id = $course_id AND |
|
|
|
|
announcement.id = ip.ref AND |
|
|
|
|
ip.tool = 'announcement' AND |
|
|
|
|
ip.visibility <> '2' |
|
|
|
|
$group_condition |
|
|
|
|
$condition_session |
|
|
|
@ -480,10 +480,10 @@ if (api_is_allowed_to_edit(false,true)) { |
|
|
|
|
if (is_array($group_memberships) && count($group_memberships)>0) { |
|
|
|
|
$sql="SELECT announcement.*, ip.visibility, ip.to_group_id, ip.insert_user_id |
|
|
|
|
FROM $tbl_announcement announcement, $tbl_item_property ip |
|
|
|
|
WHERE |
|
|
|
|
WHERE |
|
|
|
|
announcement.c_id = $course_id AND |
|
|
|
|
ip.c_id = $course_id AND |
|
|
|
|
announcement.id = ip.ref AND |
|
|
|
|
ip.c_id = $course_id AND |
|
|
|
|
announcement.id = ip.ref AND |
|
|
|
|
ip.tool='announcement' |
|
|
|
|
AND ip.visibility='1' |
|
|
|
|
$cond_user_id |
|
|
|
@ -525,9 +525,9 @@ if (api_is_allowed_to_edit(false,true)) { |
|
|
|
|
// the user is not identiefied => show only the general announcements |
|
|
|
|
$sql="SELECT announcement.*, ip.visibility, ip.to_group_id, ip.insert_user_id |
|
|
|
|
FROM $tbl_announcement announcement, $tbl_item_property ip |
|
|
|
|
WHERE |
|
|
|
|
WHERE |
|
|
|
|
announcement.c_id = $course_id AND |
|
|
|
|
ip.c_id = $course_id AND |
|
|
|
|
ip.c_id = $course_id AND |
|
|
|
|
announcement.id = ip.ref |
|
|
|
|
AND ip.tool='announcement' |
|
|
|
|
AND ip.visibility='1' |
|
|
|
@ -560,18 +560,18 @@ if ((api_is_allowed_to_edit(false,true) OR (api_get_course_setting('allow_user_e |
|
|
|
|
} else { |
|
|
|
|
if (in_array($_GET['action'], array('view'))) { |
|
|
|
|
echo '<div class="actions">'; |
|
|
|
|
echo "<a href='".api_get_self()."?".api_get_cidreq()."&origin=".(empty($_GET['origin'])?'':$_GET['origin'])."'>".Display::return_icon('back.png',get_lang('Back'),'',ICON_SIZE_MEDIUM)."</a>"; |
|
|
|
|
echo "<a href='".api_get_self()."?".api_get_cidreq()."&origin=".(empty($_GET['origin'])?'':$_GET['origin'])."'>".Display::return_icon('back.png',get_lang('Back'),'',ICON_SIZE_MEDIUM)."</a>"; |
|
|
|
|
echo '</div>'; |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
if (api_is_allowed_to_edit() && $announcement_number > 1) { |
|
|
|
|
if (api_get_group_id() == 0 ) { |
|
|
|
|
if (!$show_actions) |
|
|
|
|
if (!$show_actions) |
|
|
|
|
echo '<div class="actions">'; |
|
|
|
|
if (!in_array($_GET['action'], array('add', 'modify','view'))) |
|
|
|
|
echo "<a href=\"".api_get_self()."?".api_get_cidreq()."&action=delete_all\" onclick=\"javascript:if(!confirm('".get_lang("ConfirmYourChoice")."')) return false;\">".Display::return_icon('delete_announce.png',get_lang('AnnouncementDeleteAll'),'',ICON_SIZE_MEDIUM)."</a>"; |
|
|
|
|
} // if announcementNumber > 1 |
|
|
|
|
if (!in_array($_GET['action'], array('add', 'modify','view'))) |
|
|
|
|
echo "<a href=\"".api_get_self()."?".api_get_cidreq()."&action=delete_all\" onclick=\"javascript:if(!confirm('".get_lang("ConfirmYourChoice")."')) return false;\">".Display::return_icon('delete_announce.png',get_lang('AnnouncementDeleteAll'),'',ICON_SIZE_MEDIUM)."</a>"; |
|
|
|
|
} // if announcementNumber > 1 |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
if ($show_actions) |
|
|
|
@ -613,7 +613,7 @@ if ($display_form) { |
|
|
|
|
|
|
|
|
|
//this variable defines if the course administrator can send a message to a specific user / group or not |
|
|
|
|
//@todo use formvalidator |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if (empty($_SESSION['toolgroup'])) { |
|
|
|
|
echo ' <div class="control-group"> |
|
|
|
|
<label class="control-label">'. |
|
|
|
@ -659,31 +659,29 @@ if ($display_form) { |
|
|
|
|
</div>'; |
|
|
|
|
|
|
|
|
|
if (!isset($announcement_to_modify) ) $announcement_to_modify =''; |
|
|
|
|
|
|
|
|
|
($email_ann=='1')?$checked='checked':$checked=''; |
|
|
|
|
echo ' <div class="control-group"> |
|
|
|
|
<div class="controls"> |
|
|
|
|
|
|
|
|
|
($email_ann=='1')?$checked='checked':$checked=''; |
|
|
|
|
echo ' <div class="control-group"> |
|
|
|
|
<div class="controls"> |
|
|
|
|
<label class="checkbox" for="email_ann"> |
|
|
|
|
<input id="email_ann" class="checkbox" type="checkbox" value="1" name="email_ann" checked> '.get_lang('EmailOption').'</label> |
|
|
|
|
</div> |
|
|
|
|
</div>'; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
} else { |
|
|
|
|
if (!isset($announcement_to_modify) ) { |
|
|
|
|
$announcement_to_modify =""; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
($email_ann=='1' || !empty($surveyid))?$checked='checked':$checked=''; |
|
|
|
|
echo '<div class="control-group"> |
|
|
|
|
<label> |
|
|
|
|
</label> |
|
|
|
|
<div class="controls"> |
|
|
|
|
<input class="checkbox" type="checkbox" value="1" name="email_ann" '.$checked.'> |
|
|
|
|
'.get_lang('EmailOption').': '.get_lang('MyGroup').' |
|
|
|
|
<a href="#" onclick="if(document.getElementById(\'recipient_list\').style.display==\'none\') document.getElementById(\'recipient_list\').style.display=\'block\'; else document.getElementById(\'recipient_list\').style.display=\'none\';">'.get_lang('ModifyRecipientList').'</a>'; |
|
|
|
|
AnnouncementManager::show_to_form_group($_SESSION['toolgroup']); |
|
|
|
|
echo '</div></div>'; |
|
|
|
|
echo '</div></div>'; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
// the announcement title |
|
|
|
@ -719,18 +717,15 @@ if ($display_form) { |
|
|
|
|
$oFCKeditor->Value = $content_to_modify; |
|
|
|
|
|
|
|
|
|
echo '<div class="row"><div class="formw">'; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
echo Display::display_normal_message(get_lang('Tags').' <br /><br />'.implode('<br />', AnnouncementManager::get_tags()), false); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
echo $oFCKeditor->CreateHtml(); |
|
|
|
|
echo '</div></div>'; |
|
|
|
|
|
|
|
|
|
//File attachment |
|
|
|
|
|
|
|
|
|
echo ' <div class="row"> |
|
|
|
|
<div class="label"> |
|
|
|
|
</div> |
|
|
|
|
<div class="formw"> |
|
|
|
|
echo ' <div class="control-group"> |
|
|
|
|
<div class="controls"> |
|
|
|
|
<a href="javascript://" onclick="return plus_attachment();"><span id="plus"><img style="vertical-align:middle;" src="../img/div_show.gif" alt="" /> '.get_lang('AddAnAttachment').'</span></a> |
|
|
|
|
<br /> |
|
|
|
|
<table id="options" style="display: none;"> |
|
|
|
@ -749,10 +744,10 @@ if ($display_form) { |
|
|
|
|
</table> |
|
|
|
|
</div> |
|
|
|
|
</div>'; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
echo'<br />'; |
|
|
|
|
echo '<div class="row"><div class="formw">'; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if (empty($_SESSION['toolgroup'])) { |
|
|
|
|
echo '<input type="hidden" name="submitAnnouncement" value="OK">'; |
|
|
|
|
echo '<input type="hidden" name="sec_token" value="'.$stok.'" />'; |
|
|
|
@ -790,36 +785,36 @@ if ($display_announcement_list) { |
|
|
|
|
//$group_id=$_SESSION['group']; |
|
|
|
|
} |
|
|
|
|
$group_id = api_get_group_id(); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
$group_memberships = GroupManager::get_group_ids($course_id, api_get_user_id()); |
|
|
|
|
|
|
|
|
|
//$is_group_member = GroupManager :: is_tutor(api_get_user_id()); |
|
|
|
|
|
|
|
|
|
//$is_group_member = GroupManager :: is_tutor(api_get_user_id()); |
|
|
|
|
|
|
|
|
|
if (api_is_allowed_to_edit(false,true) OR (api_get_course_setting('allow_user_edit_announcement') && !api_is_anonymous())) { |
|
|
|
|
// 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. |
|
|
|
|
if (!empty($_SESSION['user'])) { |
|
|
|
|
|
|
|
|
|
if (!empty($_SESSION['user'])) { |
|
|
|
|
|
|
|
|
|
if (is_array($group_memberships) && count($group_memberships) > 0 ) { |
|
|
|
|
$sql = "SELECT announcement.*, ip.visibility, ip.to_group_id, ip.insert_user_id, ip.insert_date |
|
|
|
|
FROM $tbl_announcement announcement, $tbl_item_property ip |
|
|
|
|
WHERE announcement.c_id = $course_id AND |
|
|
|
|
ip.c_id = $course_id AND |
|
|
|
|
announcement.id = ip.ref AND |
|
|
|
|
ip.tool = 'announcement' AND |
|
|
|
|
ip.c_id = $course_id AND |
|
|
|
|
announcement.id = ip.ref AND |
|
|
|
|
ip.tool = 'announcement' AND |
|
|
|
|
(ip.to_user_id=$user_id OR ip.to_group_id IN (0, ".implode(", ", $group_memberships).") ) |
|
|
|
|
$condition_session |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
ORDER BY display_order DESC"; |
|
|
|
|
|
|
|
|
|
} else { |
|
|
|
|
$sql = "SELECT announcement.*, ip.visibility, ip.to_group_id, ip.insert_user_id, ip.insert_date |
|
|
|
|
FROM $tbl_announcement announcement, $tbl_item_property ip |
|
|
|
|
WHERE announcement.c_id = $course_id AND |
|
|
|
|
ip.c_id = $course_id AND |
|
|
|
|
announcement.id = ip.ref AND |
|
|
|
|
ip.tool ='announcement' AND |
|
|
|
|
(ip.to_user_id = $user_id OR ip.to_group_id='0') AND |
|
|
|
|
ip.c_id = $course_id AND |
|
|
|
|
announcement.id = ip.ref AND |
|
|
|
|
ip.tool ='announcement' AND |
|
|
|
|
(ip.to_user_id = $user_id OR ip.to_group_id='0') AND |
|
|
|
|
ip.visibility='1' |
|
|
|
|
$condition_session |
|
|
|
|
ORDER BY display_order DESC"; |
|
|
|
@ -831,7 +826,7 @@ if ($display_announcement_list) { |
|
|
|
|
$sql="SELECT announcement.*, ip.visibility, ip.to_group_id, ip.insert_user_id, ip.insert_date |
|
|
|
|
FROM $tbl_announcement announcement, $tbl_item_property ip |
|
|
|
|
WHERE announcement.c_id = $course_id AND |
|
|
|
|
ip.c_id = $course_id AND |
|
|
|
|
ip.c_id = $course_id AND |
|
|
|
|
announcement.id = ip.ref |
|
|
|
|
AND ip.tool='announcement' |
|
|
|
|
AND ip.visibility<>'2' |
|
|
|
@ -840,7 +835,7 @@ if ($display_announcement_list) { |
|
|
|
|
GROUP BY ip.ref |
|
|
|
|
ORDER BY display_order DESC"; |
|
|
|
|
} else { |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// A.3 you are a course admin without any group or user filter |
|
|
|
|
// A.3.a you are a course admin without user or group filter but WITH studentview |
|
|
|
|
// => see all the messages of all the users and groups without editing possibilities |
|
|
|
@ -850,7 +845,7 @@ if ($display_announcement_list) { |
|
|
|
|
announcement.*, ip.visibility, ip.to_group_id, ip.insert_user_id, ip.insert_date |
|
|
|
|
FROM $tbl_announcement announcement, $tbl_item_property ip |
|
|
|
|
WHERE announcement.c_id = $course_id AND |
|
|
|
|
ip.c_id = $course_id AND |
|
|
|
|
ip.c_id = $course_id AND |
|
|
|
|
announcement.id = ip.ref |
|
|
|
|
AND ip.tool='announcement' |
|
|
|
|
AND ip.visibility='1' |
|
|
|
@ -863,7 +858,7 @@ if ($display_announcement_list) { |
|
|
|
|
$sql = "SELECT announcement.*, ip.visibility, ip.to_group_id, ip.insert_user_id, ip.insert_date |
|
|
|
|
FROM $tbl_announcement announcement, $tbl_item_property ip |
|
|
|
|
WHERE announcement.c_id = $course_id AND |
|
|
|
|
ip.c_id = $course_id AND |
|
|
|
|
ip.c_id = $course_id AND |
|
|
|
|
announcement.id = ip.ref |
|
|
|
|
AND ip.tool='announcement' |
|
|
|
|
AND (ip.visibility='0' or ip.visibility='1') |
|
|
|
@ -872,9 +867,9 @@ if ($display_announcement_list) { |
|
|
|
|
ORDER BY display_order DESC"; |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
} else { |
|
|
|
|
} else { |
|
|
|
|
//STUDENT |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if (is_array($group_memberships) && count($group_memberships)>0) { |
|
|
|
|
if ((api_get_course_setting('allow_user_edit_announcement') && !api_is_anonymous())) { |
|
|
|
|
if (api_get_group_id() == 0) { |
|
|
|
@ -898,7 +893,7 @@ if ($display_announcement_list) { |
|
|
|
|
$sql = "SELECT announcement.*, ip.visibility, ip.to_group_id, ip.insert_user_id, ip.insert_date |
|
|
|
|
FROM $tbl_announcement announcement, $tbl_item_property ip |
|
|
|
|
WHERE announcement.c_id = $course_id AND |
|
|
|
|
ip.c_id = $course_id AND |
|
|
|
|
ip.c_id = $course_id AND |
|
|
|
|
announcement.id = ip.ref |
|
|
|
|
AND ip.tool='announcement' |
|
|
|
|
$cond_user_id |
|
|
|
@ -917,8 +912,8 @@ if ($display_announcement_list) { |
|
|
|
|
FROM $tbl_announcement announcement, $tbl_item_property ip |
|
|
|
|
WHERE |
|
|
|
|
announcement.c_id = $course_id AND |
|
|
|
|
ip.c_id = $course_id AND |
|
|
|
|
announcement.id = ip.ref AND |
|
|
|
|
ip.c_id = $course_id AND |
|
|
|
|
announcement.id = ip.ref AND |
|
|
|
|
ip.tool='announcement' |
|
|
|
|
$cond_user_id |
|
|
|
|
$condition_session |
|
|
|
@ -937,7 +932,7 @@ if ($display_announcement_list) { |
|
|
|
|
FROM $tbl_announcement announcement, $tbl_item_property ip |
|
|
|
|
WHERE |
|
|
|
|
announcement.c_id = $course_id AND |
|
|
|
|
ip.c_id = $course_id AND |
|
|
|
|
ip.c_id = $course_id AND |
|
|
|
|
announcement.id = ip.ref |
|
|
|
|
AND ip.tool='announcement' |
|
|
|
|
$cond_user_id |
|
|
|
@ -951,7 +946,7 @@ if ($display_announcement_list) { |
|
|
|
|
$result = Database::query($sql); |
|
|
|
|
$num_rows = Database::num_rows($result); |
|
|
|
|
|
|
|
|
|
// DISPLAY: NO ITEMS |
|
|
|
|
// DISPLAY: NO ITEMS |
|
|
|
|
|
|
|
|
|
if (!isset($_GET['action']) || !in_array($_GET['action'], array('add', 'modify','view'))) |
|
|
|
|
if ($num_rows == 0) { |
|
|
|
@ -959,80 +954,80 @@ if ($display_announcement_list) { |
|
|
|
|
echo '<div id="no-data-view">'; |
|
|
|
|
echo '<h2>'.get_lang('Announcements').'</h2>'; |
|
|
|
|
echo Display::return_icon('valves.png', '', array(), 64); |
|
|
|
|
echo '<div class="controls">'; |
|
|
|
|
echo '<div class="controls">'; |
|
|
|
|
echo Display::url(get_lang('AddAnnouncement'), api_get_self()."?".api_get_cidreq()."&action=add&origin=".(empty($_GET['origin'])?'':$_GET['origin']) , array('class' => 'btn')); |
|
|
|
|
echo '</div>'; |
|
|
|
|
echo '</div>'; |
|
|
|
|
echo '</div>'; |
|
|
|
|
} else { |
|
|
|
|
//echo "<a href='".api_get_self()."?".api_get_cidreq()."&action=add&origin=".(empty($_GET['origin'])?'':$_GET['origin'])."'>".Display::return_icon('new_announce.png',get_lang('AddAnnouncement'),'',ICON_SIZE_MEDIUM)."</a>"; |
|
|
|
|
Display::display_warning_message(get_lang('NoAnnouncements')); |
|
|
|
|
Display::display_warning_message(get_lang('NoAnnouncements')); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
} else { |
|
|
|
|
|
|
|
|
|
} else { |
|
|
|
|
$iterator = 1; |
|
|
|
|
$bottomAnnouncement = $announcement_number; |
|
|
|
|
|
|
|
|
|
echo '<table width="100%" class="data_table">'; |
|
|
|
|
|
|
|
|
|
echo '<table width="100%" class="data_table">'; |
|
|
|
|
$ths = Display::tag('th', get_lang('Title')); |
|
|
|
|
$ths .= Display::tag('th', get_lang('By') ); |
|
|
|
|
$ths .= Display::tag('th', get_lang('By') ); |
|
|
|
|
$ths .= Display::tag('th', get_lang('LastUpdateDate') ); |
|
|
|
|
if (api_is_allowed_to_edit(false,true) OR (api_is_course_coach() && api_is_element_in_the_session(TOOL_ANNOUNCEMENT,$myrow['id'])) |
|
|
|
|
if (api_is_allowed_to_edit(false,true) 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())) { |
|
|
|
|
$ths .= Display::tag('th', get_lang('Modify')); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
echo Display::tag('tr', $ths); |
|
|
|
|
$displayed = array(); |
|
|
|
|
|
|
|
|
|
while ($myrow = Database::fetch_array($result, 'ASSOC')) { |
|
|
|
|
|
|
|
|
|
echo Display::tag('tr', $ths); |
|
|
|
|
$displayed = array(); |
|
|
|
|
|
|
|
|
|
while ($myrow = Database::fetch_array($result, 'ASSOC')) { |
|
|
|
|
if (!in_array($myrow['id'], $displayed)) { |
|
|
|
|
$sent_to_icon = ''; |
|
|
|
|
// the email icon |
|
|
|
|
if ($myrow['email_sent'] == '1') { |
|
|
|
|
$sent_to_icon = ' '.Display::return_icon('email.gif', get_lang('AnnounceSentByEmail')); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
$title = $myrow['title'].$sent_to_icon; |
|
|
|
|
|
|
|
|
|
/* DATE */ |
|
|
|
|
$last_post_datetime = $myrow['end_date']; |
|
|
|
|
|
|
|
|
|
$item_visibility = api_get_item_visibility($_course, TOOL_ANNOUNCEMENT, $myrow['id'], $session_id); |
|
|
|
|
|
|
|
|
|
/* 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'; |
|
|
|
|
} else { |
|
|
|
|
$style = ''; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
echo "<tr>"; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// show attachment list |
|
|
|
|
$attachment_list = array(); |
|
|
|
|
$attachment_list = AnnouncementManager::get_attachment($myrow['id']); |
|
|
|
|
|
|
|
|
|
$attachment_list = AnnouncementManager::get_attachment($myrow['id']); |
|
|
|
|
|
|
|
|
|
$attachment_icon = ''; |
|
|
|
|
if (count($attachment_list)>0) { |
|
|
|
|
$attachment_icon = ' '.Display::return_icon('attachment.gif',get_lang('Attachment')); |
|
|
|
|
$attachment_icon = ' '.Display::return_icon('attachment.gif',get_lang('Attachment')); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/* TITLE */ |
|
|
|
|
$title = Display::url($title.$attachment_icon, '?action=view&id='.$myrow['id']); |
|
|
|
|
echo Display::tag('td', Security::remove_XSS($title), array('class' => $style)); |
|
|
|
|
|
|
|
|
|
echo Display::tag('td', Security::remove_XSS($title), array('class' => $style)); |
|
|
|
|
|
|
|
|
|
$user_info = api_get_user_info($myrow['insert_user_id']); |
|
|
|
|
$username = sprintf(get_lang("LoginX"), $user_info['username']); |
|
|
|
|
$username_span = Display::tag('span', api_get_person_name($user_info['firstName'], $user_info['lastName']), array('title'=>$username)); |
|
|
|
|
echo Display::tag('td', $username_span); |
|
|
|
|
echo Display::tag('td', api_convert_and_format_date($myrow['insert_date'], DATE_TIME_FORMAT_LONG)); |
|
|
|
|
echo Display::tag('td', api_convert_and_format_date($myrow['insert_date'], DATE_TIME_FORMAT_LONG)); |
|
|
|
|
|
|
|
|
|
// 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 |
|
|
|
|
$modify_icons = ''; |
|
|
|
|
if (api_is_allowed_to_edit(false,true) OR (api_is_course_coach() && api_is_element_in_the_session(TOOL_ANNOUNCEMENT, $myrow['id'])) |
|
|
|
|
if (api_is_allowed_to_edit(false,true) 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())) { |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
$modify_icons = "<a href=\"".api_get_self()."?".api_get_cidreq()."&action=modify&id=".$myrow['id']."\">".Display::return_icon('edit.png', get_lang('Edit'),'',ICON_SIZE_SMALL)."</a>"; |
|
|
|
|
if ($myrow['visibility']==1) { |
|
|
|
|
$image_visibility="visible"; |
|
|
|
@ -1040,26 +1035,26 @@ if ($display_announcement_list) { |
|
|
|
|
} else { |
|
|
|
|
$image_visibility="invisible"; |
|
|
|
|
$alt_visibility=get_lang('Visible'); |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
$modify_icons .= "<a href=\"".api_get_self()."?".api_get_cidreq()."&origin=".(!empty($_GET['origin'])?Security::remove_XSS($_GET['origin']):'')."&action=showhide&id=".$myrow['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=\"".api_get_self()."?".api_get_cidreq()."&up=".$myrow["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=\"".api_get_self()."?".api_get_cidreq()."&down=".$myrow["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=\"".api_get_self()."?".api_get_cidreq()."&action=delete&id=".$myrow['id']."&sec_token=".$stok."\" onclick=\"javascript:if(!confirm('".addslashes(api_htmlentities(get_lang('ConfirmYourChoice'),ENT_QUOTES,$charset))."')) return false;\">". |
|
|
|
|
Display::return_icon('delete.png', get_lang('Delete'),'',ICON_SIZE_SMALL). |
|
|
|
|
"</a>"; |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
$iterator ++; |
|
|
|
|
echo Display::tag('td', $modify_icons); |
|
|
|
|
} |
|
|
|
|