Source for file announcements.php
Documentation is available at announcements.php
<?php //$Id: announcements.php 15535 2008-06-10 17:29:54Z juliomontoya $
==============================================================================
Dokeos - elearning and course management software
Copyright (c) 2004-2008 Dokeos SPRL
Copyright (c) 2003 Ghent University (UGent)
Copyright (c) 2001 Universite catholique de Louvain (UCL)
Copyright (c) various contributors
For a full list of contributors, see "credits.txt".
The full license can be read in "license.txt".
This program is free software; you can redistribute it and/or
modify it under the terms of the GNU General Public License
as published by the Free Software Foundation; either version 2
of the License, or (at your option) any later version.
See the GNU General Public License for more details.
Contact address: Dokeos, rue du Corbeau, 108, B-1030 Brussels, Belgium
==============================================================================
==============================================================================
* @author Frederik Vermeire <frederik.vermeire@pandora.be>, UGent Internship
* @author Patrick Cool <patrick.cool@UGent.be>, Ghent University: code cleaning
* @abstract The task of the internship was to integrate the 'send messages to specific users' with the
* Announcements tool and also add the resource linker here. The database also needed refactoring
* as there was no title field (the title was merged into the content field)
* @package dokeos.announcements
* @todo make AWACS out of the configuration settings
* @todo this file is 1200+ lines without any functions -> needs to be split into
==============================================================================
==============================================================================
==============================================================================
// name of the language file that needs to be included
$language_file[] = 'announcements';
$language_file[] = 'group';
$language_file[] = 'survey';
// use anonymous mode when accessing this course tool
// setting the global file that gets the general configuration, the databases, the languages, ...
include('../inc/global.inc.php');
if(isset ($_GET['id_session']))
$_SESSION['id_session'] = $_GET['id_session'];
/* ------------ ACCESS RIGHTS ------------ */
// notice for unauthorized people.
-----------------------------------------------------------
-----------------------------------------------------------
// Configuration settings
$display_announcement_list = true;
$display_title_list = true;
// Maximum title messages to display
// Database Table Definitions
-----------------------------------------------------------
-----------------------------------------------------------
$_SESSION['source_type']= "Ad_Valvas";
include('../resourcelinker/resourcelinker.inc.php');
if (!empty($_POST['addresources'])) // When the "Add Resource" button is clicked we store all the form data into a session
include('announcements.inc.php');
$form_elements= array ('emailTitle'=> stripslashes($emailTitle), 'newContent'=> stripslashes($newContent), 'id'=> $id, 'to'=> $selectedform, 'emailoption'=> $email_ann);
$_SESSION['formelements']= $form_elements;
if($id) // this is to correctly handle edits
header("Location: ../resourcelinker/resourcelinker.php?source_id=7&action=$action&id=$id&originalresource=no&publish_survey=$surveyid&db_name=$db_name&cidReq=$cidReq");
header("Location: ../resourcelinker/resourcelinker.php?source_id=7&action=$action&id=$id&originalresource=no");
-----------------------------------------------------------
-----------------------------------------------------------
include(api_get_path(LIBRARY_PATH). 'events.lib.inc.php');
-----------------------------------------------------------
-----------------------------------------------------------
require_once(api_get_path(LIBRARY_PATH). 'groupmanager.lib.php');
require_once('announcements.inc.php');
require_once(api_get_path(INCLUDE_PATH). 'lib/mail.lib.inc.php');
require_once(api_get_path(INCLUDE_PATH). 'conf/mail.conf.php');
require_once(api_get_path(LIBRARY_PATH). 'debug.lib.inc.php');
require_once(api_get_path(LIBRARY_PATH). 'tracking.lib.php');
-----------------------------------------------------------
-----------------------------------------------------------
if (!empty($_POST['To']))
$form_elements= array ('emailTitle'=> $_POST['emailTitle'], 'newContent'=> $_POST['newContent'], 'id'=> $_POST['id'], 'emailoption'=> $_POST['email_ann']);
$_SESSION['formelements']= $form_elements;
$form_elements = $_SESSION['formelements'];
$title_to_modify = $form_elements["emailTitle"];
$content_to_modify = $form_elements["newContent"];
$announcement_to_modify = $form_elements["id"];
-----------------------------------------------------------
Show/hide user/group form
-----------------------------------------------------------
$setting_select_groupusers= true;
if (empty($_POST['To']) and !$_SESSION['select_groupusers'])
$_SESSION['select_groupusers']= "hide";
$select_groupusers_status= $_SESSION['select_groupusers'];
if (!empty($_POST['To']) and ($select_groupusers_status== "hide"))
$_SESSION['select_groupusers']= "show";
if (!empty($_POST['To']) and ($select_groupusers_status== "show"))
$_SESSION['select_groupusers']= "hide";
-----------------------------------------------------------
-----------------------------------------------------------
if (((!empty($_GET['action']) && $_GET['action'] == 'add') && $_GET['origin'] == "") || (!empty($_GET['action']) && $_GET['action'] == 'edit') || !empty($_POST['To']))
if ((empty($originalresource) || ($originalresource!== 'no')) and (!empty($action) && $action== 'add'))
$_SESSION['formelements']= null;
//unset($_SESSION['formelements']);
-----------------------------------------------------------
-----------------------------------------------------------
-----------------------------------------------------------
-----------------------------------------------------------
if(!empty($_GET['toolgroup'])){
if($_GET['toolgroup'] == strval(intval($_GET['toolgroup']))){ //check is integer
$toolgroup = $_GET['toolgroup'];
$_SESSION['select_groupusers'] = 'hide';
-----------------------------------------------------------
-----------------------------------------------------------
if (!empty($_SESSION['formelements']) and !empty($_GET['originalresource']) and $_GET['originalresource'] == 'no')
$form_elements = $_SESSION['formelements'];
$title_to_modify = $form_elements['emailTitle'];
$content_to_modify = $form_elements['newContent'];
$announcement_to_modify = $form_elements['id'];
$to = $form_elements['to'];
//load_edit_users('announcement',$announcement_to_modify);
$email_ann = $form_elements['emailoption'];
if(!empty($_GET['remind_inactive']))
$to[] = 'USER:'. intval($_GET['remind_inactive']);
-----------------------------------------------------------
-----------------------------------------------------------
if(!empty($_REQUEST['publish_survey']))
$sql_temp = "SELECT * FROM $db_name.survey WHERE survey_id='$surveyid'";
$template= $obj->template;
$interbreadcrumb[] = array ("url" => "../survey/survey_list.php?cidReq=$cidReq", "name" => get_lang('Survey'));
$nameTools12 = get_lang('PublishSurvey');
-----------------------------------------------------------
-----------------------------------------------------------
// showing the header if we are not in the learning path, if we are in
// the learning path, we do not include the banner so we have to explicitly
// include the stylesheet, which is normally done in the header
if (empty($_GET['origin']) or $_GET['origin'] !== 'learnpath')
//we are not in the learning path
Display::Display_header($nameTools,"Announcements");
//we are in the learning path, only display central data and change css
$display_title_list = false;
$display_announcement_list = false;
$display_specific_announcement = true;
$announcement_id = $_REQUEST['ann_id'];
?> <link rel="stylesheet" type="text/css" href=" <?php echo $clarolineRepositoryWeb ?>css/default.css">
<!-- css file for announcements -->
<link href="../css/announcements.css" rel="stylesheet" type="text/css">
// inserting an anchor (top) so one can jump back to the top of the page
echo "<a name=\"top\"></a>";
/*=============================================
=============================================*/
-----------------------------------------------------------
Change visibility of announcement
-----------------------------------------------------------
// $_GET['isStudentView']<>"false" is added to prevent that the visibility
// is changed after you do the following:
// change visibility -> studentview -> course manager view
if (isset ($_GET['isStudentView']) && $_GET['isStudentView']!= 'false')
if (isset ($_GET['id']) AND $_GET['id'] AND isset ($_GET['action']) AND $_GET['action']== "showhide")
-----------------------------------------------------------
-----------------------------------------------------------
if (!empty($_GET['action']) AND $_GET['action']== 'delete' AND isset ($_GET['id']))
//api_sql_query("DELETE FROM $tbl_announcement WHERE id='$delete'",__FILE__,__LINE__);
// tooledit : visibility = 2 : only visibile for platform administrator
$message = get_lang("AnnouncementDeleted");
-----------------------------------------------------------
-----------------------------------------------------------
if (!empty($_GET['action']) and $_GET['action']== 'delete_all')
//api_sql_query("DELETE FROM $tbl_announcement",__FILE__,__LINE__);
$message = get_lang("AnnouncementDeletedAll");
-----------------------------------------------------------
-----------------------------------------------------------
if (!empty($_GET['action']) and $_GET['action']== 'modify' AND isset ($_GET['id']))
// RETRIEVE THE CONTENT OF THE ANNOUNCEMENT TO MODIFY
$sql= "SELECT * FROM $tbl_announcement WHERE id='$id'";
$announcement_to_modify = $myrow['id'];
$content_to_modify = $myrow['content'];
$title_to_modify = $myrow['title'];
if ($originalresource!== "no") // and !addresources)
//unset_session_resources();
$display_announcement_list = false;
if ($to== "everyone" OR !empty($_SESSION['toolgroup']))
$_SESSION['select_groupusers']= "hide";
$_SESSION['select_groupusers']= "show";
-----------------------------------------------------------
Move announcement up/down
-----------------------------------------------------------
if (!empty($_GET['down']))
$thisAnnouncementId = intval($_GET['down']);
$thisAnnouncementId = intval($_GET['up']);
if (!empty($sortDirection))
$my_sql = "SELECT announcement.id, announcement.display_order " .
"FROM $tbl_announcement announcement, " .
"$tbl_item_property itemproperty " .
"WHERE itemproperty.ref=announcement.id " .
"AND itemproperty.visibility<>2 " .
"ORDER BY display_order $sortDirection";
// STEP 2 : FOUND THE NEXT ANNOUNCEMENT ID AND ORDER.
// COMMIT ORDER SWAP ON THE DB
if (isset ($thisAnnouncementOrderFound) && $thisAnnouncementOrderFound == true)
$nextAnnouncementId = $announcementId;
$nextAnnouncementOrder = $announcementOrder;
"SET display_order = '$nextAnnouncementOrder' " .
"WHERE id = '$thisAnnouncementId'",__FILE__ ,__LINE__ );
"SET display_order = '$thisAnnouncementOrder' " .
"WHERE id = '$nextAnnouncementId.'",__FILE__ ,__LINE__ );
// STEP 1 : FIND THE ORDER OF THE ANNOUNCEMENT
if ($announcementId == $thisAnnouncementId)
$thisAnnouncementOrder = $announcementOrder;
$thisAnnouncementOrderFound = true;
$message = get_lang('AnnouncementMoved');
-----------------------------------------------------------
-----------------------------------------------------------
$emailTitle= (!empty($_POST['emailTitle'])? $_POST['emailTitle']: '');
$newContent= (!empty($_POST['newContent'])? $_POST['newContent']: '');
$submitAnnouncement=isset ($_POST['submitAnnouncement'])? $_POST['submitAnnouncement']: 0;
if(isset ($id)&& $id) // there is an Id => the announcement already exists => update mode
$message = get_lang('AnnouncementModified');
$result = api_sql_query("SELECT MAX(display_order) FROM $tbl_announcement",__FILE__ ,__LINE__ );
if(!empty($_SESSION['toolgroup'])){
//$insert_id=store_advalvas_item($_POST['emailTitle'],$_POST['newContent'],$order,array('GROUP:'.$_SESSION['toolgroup']));
$insert_id= store_advalvas_group_item($_POST['emailTitle'],$_POST['newContent'],$order,array('GROUP:'. $_SESSION['toolgroup']),$_POST['selectedform']);
$insert_id= store_advalvas_item($_POST['emailTitle'],$_POST['newContent'],$order,$_POST['selectedform']);
$_SESSION['select_groupusers']= "hide";
$message = get_lang('AnnouncementAdded');
/*============================================================
MAIL WHEN USER COMES FROM SURVEY
======================================================= */
$to_email_address = $_POST['emailsAdd'];
$to_email_to = explode(',', $to_email_address);
$db_name = $_REQUEST['db_name'];
for($i= 0;$i< count($to_email);$i++ )
$to= trim($to_email[$i]);
$db_name = $_REQUEST['db_name'];
$newContentone= str_replace("#page#","choose_language.php",$newContent);
$newContenttwo= str_replace("#temp#",$template,$newContentone);
$newContentthree= str_replace("#sid#",$surveyid,$newContenttwo);
$newContentfour= str_replace("#mail#",$to,$newContentthree);
$newContentfive= str_replace("#db_name#",$db_name,$newContentfour);
$newContentsix= str_replace("#uid#","",$newContentfive);
if(eregi('^[0-9a-z_\.-]+@(([0-9]{1,3}\.){3}[0-9]{1,3}|([0-9a-z][0-9a-z-]*[0-9a-z]\.)+[a-z]{2,3})$', $to ))
$sender_name = $_SESSION['_user']['lastName']. ' '. $_SESSION['_user']['firstName'];
$email = $_SESSION['_user']['mail'];
$headers= "From:$sender_name\r\nReply-to: $email\r\nContent-type: text/html; charset=iso-8859-15";
//@mail($to,$subject,$message,$headers);
//api_send_mail($to,$subject,$message,$headers);
api_mail('',$to,$subject,$message,$sender_name,$email,$headers);
$sql_date= "SELECT * FROM $db_name.survey WHERE survey_id='$surveyid'";
$end_date= $obj_date->avail_till;
if($_REQUEST['reminder']== "1")
$sql_insert= "INSERT INTO $table_reminder(sid,db_name,email,subject,content,reminder_choice,reminder_time,avail_till) values('$surveyid','$db_name','$to','". addslashes($subject). "','". addslashes($message). "','1','$time','$end_date')";
else if($_REQUEST['reminder']== "2")
$sql_insert= "INSERT INTO $table_reminder(sid,db_name,email,subject,content,reminder_choice,reminder_time,avail_till) values('$surveyid','$db_name','$to','". addslashes($subject). "','". addslashes($message). "','1','$time','$end_date')";
else if($_REQUEST['reminder']== "3")
$sql_insert= "INSERT INTO $table_reminder(sid,db_name,email,subject,content,reminder_choice,reminder_time,avail_till) values('$surveyid','$db_name','$to','". addslashes($subject). "','". addslashes($message). "','1','$time','$end_date')";
/*===================================================================
===================================================================*/
if ($_POST['email_ann'] && empty($_POST['onlyThoseMails']))
$sent_to= sent_to("announcement", $insert_id);
$userlist = $sent_to['users'];
$grouplist = $sent_to['groups'];
// groepen omzetten in users
$grouplist = "'". implode("', '",$grouplist). "'"; //protect individual elements with surrounding quotes
WHERE gu.group_id IN (". $grouplist. ")";
$userlist [] = $u ['user_id']; // complete the user id list ...
// send to the created 'userlist'
$sqlmail = "SELECT user_id, lastname, firstname, email
WHERE user_id IN (". $userlist. ")";
else if(empty($_POST['not_selected_form']))
if(empty($_SESSION['id_session']) || api_get_setting('use_session_mode')== 'false')
$sqlmail = "SELECT user.user_id, user.email, user.lastname, user.firstname
FROM $tbl_course_user, $tbl_user
AND course_rel_user.user_id = user.user_id";
$sqlmail = "SELECT user.user_id, user.email, user.lastname, user.firstname
INNER JOIN $tbl_session_course_user
ON $tbl_user.user_id = $tbl_session_course_user.id_user
AND $tbl_session_course_user.course_code = '". $_course['id']. "'
AND $tbl_session_course_user.id_session = ". intval($_SESSION['id_session']);
/*=================================================================================
send email one by one to avoid antispam
=================================================================================*/
/* Header : Bericht van uw lesgever - GES ($_cid)
Body : John Doe (prenom + nom) <john_doe@hotmail.com> (email)
Morgen geen les!! (emailTitle)
Morgen is er geen les, de les wordt geschrapt wegens vergadering (newContent)
$emailSubject = $emailsubjbericht. " - ". $_course['official_code'];
$emailSubject = $emailTitle;
$newContentone= str_replace("#page#","choose_language.php",$newContent);
$newContenttwo= str_replace("#temp#",$template,$newContentone);
$newContentthree= str_replace("#sid#",$surveyid,$newContenttwo);
$newContentfour= str_replace("#mail#",$myrow["email"],$newContentthree);
$newContentfive= str_replace("#db_name#",$db_name,$newContentfour);
$newContentsix= str_replace("#uid#",$myrow["user_id"],$newContentfive);
$sender_name = $_SESSION['_user']['lastName']. ' '. $_SESSION['_user']['firstName'];
$email = $_SESSION['_user']['mail'];
$headers= "From:$sender_name\r\nReply-to: $email\r\nContent-type: text/html; charset=iso-8859-15";
//@mail($myrow["email"],stripslashes($emailTitle),$message,$headers);
$mail_body = $myrow["lastname"]. " ". $myrow["firstname"]. " <". $myrow["email"]. "><br /> \n\n". stripslashes($emailTitle). "<br />". trim(stripslashes($newContent)). " <br /><br />-- <br />";
$mail_body .= $_user['firstName']. ' '. $_user['lastName']. " ";
$mail_body .= "<". $_user['mail']. ">\n";
$mail_body .= $_course['official_code']. ' '. $_course['name'];
//set the charset and use it for the encoding of the email - small fix, not really clean (should check the content encoding origin first)
//here we use the encoding used for the webpage where the text is encoded (ISO-8859-1 in this case)
//$to_email_address =$_POST['emailsAdd'];
if(empty($charset)){$charset= 'ISO-8859-1';}
$headers['Content-Type'] = 'text/html';
$headers['charset'] = $charset;
$newmail = api_mail_html($myrow["lastname"]. ' '. $myrow["firstname"], $myrow["email"], stripslashes($emailSubject), $mail_body, $_SESSION['_user']['lastName']. ' '. $_SESSION['_user']['firstName'], $_SESSION['_user']['mail'],$headers);
$sql_date= "SELECT * FROM $db_name WHERE survey_id='$surveyid'";
$end_date= $obj_date->avail_till;
if($_REQUEST['reminder']== "1")
$sql= "INSERT INTO $table_reminder(sid,db_name,email,subject,content,reminder_choice,reminder_time,avail_till) values('$surveyid','$db_name','$mailid','". addslashes($emailSubject). "','". addslashes($mail_body). "','1','$time','$end_date')";
else if($_REQUEST['reminder']== "2")
$sql= "INSERT INTO $table_reminder(sid,db_name,email,subject,content,reminder_choice,reminder_time,avail_till) values('$surveyid','$db_name','$mailid','". addslashes($emailSubject). "','". addslashes($mail_body). "','1','$time','$end_date')";
else if($_REQUEST['reminder']== "3")
$sql= "INSERT INTO $table_reminder(sid,db_name,email,subject,content,reminder_choice,reminder_time,avail_till) values('$surveyid','$db_name','$mailid','". addslashes($emailSubject). "','". addslashes($mail_body). "','1','$time','$end_date')";
$message = $added_and_sent;
$_SESSION['formelements']= null;
unset ($content_to_modify);
if($_REQUEST['publish_survey'])
$surveyid= $_REQUEST['surveyid'];
$cidReq = $_REQUEST['cidReq'];
window.location.href="../survey/survey_list.php? <?php echo api_get_cidreq(); ?>&published=published&surveyid= <?php echo $_REQUEST['publish_survey']; ?>";
} // if $submit Announcement
/*====================================================
====================================================*/
if (empty($_GET['origin']) || $_GET['origin'] !== 'learnpath')
//api_display_tool_title($nameTools);
==============================================================================
==============================================================================
/*=====================================================================================
=====================================================================================*/
// The commands below will change these display settings if they need it
if (empty($_GET['origin']) OR $_GET['origin'] !== 'learnpath')
echo "\n\n<table width=\"100%\" border=\"0\" cellspacing=\"0\" cellpadding=\"0\">\n";
echo "\t\t<td width=\"20%\" valign=\"top\">\n";
/*======================================================================
======================================================================*/
if (empty($_GET['origin']) or $_GET['origin'] !== 'learnpath')
announcement.*, toolitemproperties.*
FROM $tbl_announcement announcement, $tbl_item_property toolitemproperties
WHERE announcement.id = toolitemproperties.ref
AND toolitemproperties.tool='announcement'
AND toolitemproperties.visibility<>'2'
GROUP BY toolitemproperties.ref
ORDER BY display_order DESC
else // students only get to see the visible announcements
if (empty($_GET['origin']) or $_GET['origin'] !== 'learnpath')
// the user is member of several groups => display personal announcements AND his group announcements AND the general announcements
announcement.*, toolitemproperties.*
FROM $tbl_announcement announcement, $tbl_item_property toolitemproperties
WHERE announcement.id = toolitemproperties.ref
AND toolitemproperties.tool='announcement'
AND toolitemproperties.visibility='1'
AND ( toolitemproperties.to_user_id='". $_user['user_id']. "'" .
"OR toolitemproperties.to_group_id IN (0, ". implode(", ", $group_memberships). ") )
GROUP BY toolitemproperties.ref
ORDER BY display_order DESC
// the user is not member of any group
// this is an identified user => show the general announcements AND his personal announcements
announcement.*, toolitemproperties.*
FROM $tbl_announcement announcement, $tbl_item_property toolitemproperties
WHERE announcement.id = toolitemproperties.ref
AND toolitemproperties.tool='announcement'
AND toolitemproperties.visibility='1'
AND ( toolitemproperties.to_user_id='". $_user['user_id']. "' OR toolitemproperties.to_group_id='0')
GROUP BY toolitemproperties.ref
ORDER BY display_order DESC
// the user is not identiefied => show only the general announcements
announcement.*, toolitemproperties.*
FROM $tbl_announcement announcement, $tbl_item_property toolitemproperties
WHERE announcement.id = toolitemproperties.ref
AND toolitemproperties.tool='announcement'
AND toolitemproperties.visibility='1'
AND toolitemproperties.to_group_id='0'
GROUP BY toolitemproperties.ref
ORDER BY display_order DESC
/*----------------------------------------------------
ADD ANNOUNCEMENT / DELETE ALL
----------------------------------------------------*/
echo "<a href='". api_get_self(). "?". api_get_cidreq(). "&action=add&origin=". (empty($_GET['origin'])? '': $_GET['origin']). "'><img src=\"../img/announce_add.gif\"> ". get_lang("AddAnnouncement"). "</a><br/>";
echo "<a href=\"". api_get_self(). "?". api_get_cidreq(). "&action=delete_all\" onclick=\"javascript:if(!confirm('". get_lang("ConfirmYourChoice"). "')) return false;\"><img src=\"../img/valves_delete.gif\"/> ". get_lang("AnnouncementDeleteAll"). "</a>\n";
} // if announcementNumber > 1
echo "<hr noshade size=\"1\">";
/*----------------------------------------------------
----------------------------------------------------*/
if ($display_title_list == true)
$title = $myrow['title'];
echo "\t\t\t\t\t<td width=\"15%\">\n";
if ($myrow['visibility']== 0)
{ $class= "class=\"invisible\"";}
echo "\t\t\t\t\t\t<a style=\"text-decoration:none\" href=\"announcements.php?". api_get_cidreq(). "#". $myrow['id']. "\" ". $class. ">" . api_trunc_str($title,$length) . "</a>\n";
echo "\t\t\t\t\t</td>\n\t\t\t\t</tr>\n";
} // end $display_title_list == true
if (empty($_GET['origin']) or $_GET['origin'] !== 'learnpath')
echo "\t\t<td width=\"20\" background=\"../img/verticalruler.gif\"> </td>\n";
echo "\t\t<td valign=\"top\">\n";
/*=======================================
=======================================*/
if (isset ($message) && $message == true)
$display_announcement_list = true;
/*==================================================================================
==================================================================================*/
if ($display_form == true)
// DISPLAY ADD ANNOUNCEMENT COMMAND
echo "<form method=\"post\" name=\"f1\" action=\"". api_get_self(). "?publish_survey=$surveyid&id=". $_GET['id']. "&db_name=$db_name&cidReq=". $_GET['cidReq']. "&action=". $_GET['action']. "\" style=\"margin:0px;\">\n";
//this variable defines if the course administrator can send a message to a specific user / group
//echo "sessiewaarde: ".$_SESSION['select_groupusers'];
if(empty($_SESSION['toolgroup'])){
if(isset ($_GET['id']) && is_array($to)){
elseif(isset ($_GET['remind_inactive']))
$_SESSION['select_groupusers']= "show";
elseif(isset ($_GET['remindallinactives']) && $_GET['remindallinactives']== 'true')
$since = isset ($_GET['since']) ? intval($_GET['since']) : 6;
$_SESSION['select_groupusers']= "show";
//echo ' <script type="text/javascript">document.onload = "document.getElementById(\'recipient_list\').style.display=\'block\'";</script>';
echo '<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'). '</span>';
echo "</td></tr></table>";
if (!isset ($announcement_to_modify) ) $announcement_to_modify = "";
if ($announcement_to_modify== '')
($email_ann== '1')? $checked= 'checked': $checked= '';
echo "<input class=\"checkbox\" type=checkbox value=\"1\" name=\"email_ann\" $checked> ". get_lang('EmailOption')," : ",
if (!isset ($announcement_to_modify) ) $announcement_to_modify = "";
if ($announcement_to_modify== '')
($email_ann== '1' || !empty($surveyid))? $checked= 'checked': $checked= '';
echo "<input class=\"checkbox\" type=checkbox value=\"1\" name=\"email_ann\" $checked> ". get_lang('EmailOption')," : ". get_lang('MyGroup'),
echo '<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>';
echo get_lang('EmailAddress'). ": <input type=\"text\" name=\"emailsAdd\" value=\"". $emails_add. "\" size=\"52\">(Comma separated for multiple)<br>";
echo get_lang('OnlyThoseAddresses'). ": <input type=\"checkbox\" name=\"onlyThoseMails\"><br>";
echo get_lang('EmailTitle'). ": <input type=\"text\" name=\"emailTitle\" value=\"". $title_to_modify. "\" size=\"52\"><br />";
if (!isset ($announcement_to_modify) ) $announcement_to_modify = "";
if (!isset ($content_to_modify) ) $content_to_modify = "";
if (!isset ($title_to_modify)) $title_to_modify = "";
echo "<br />\n<input type=\"hidden\" name=\"id\" value=\"". $announcement_to_modify. "\">";
$content_to_modify= '<br /><a href="'. api_get_path(WEB_CODE_PATH). '/survey/#page#?temp=#temp#&surveyid=#sid#&uid=#uid#&mail=#mail#&db_name=#db_name">'. get_lang('ClickHereToOpenSurvey'). '</a><br />
//api_disp_html_area('newContent',$content_to_modify,'250px');
require_once(api_get_path(LIBRARY_PATH) . "/fckeditor/fckeditor.php");
$oFCKeditor->Height = '250';
$oFCKeditor->Width = '100%';
$oFCKeditor->Value = $content_to_modify;
$oFCKeditor->Config['CustomConfigurationsPath'] = api_get_path(REL_PATH). "main/inc/lib/fckeditor/myconfig.js";
$oFCKeditor->ToolbarSet = "Announcements";
$sql= "SELECT isocode FROM ". $TBL_LANGUAGES. " WHERE english_name='". $_SESSION["_course"]["language"]. "'";
$oFCKeditor->Config['DefaultLanguage'] = $isocode_language;
echo $oFCKeditor->CreateHtml();
if(empty($_SESSION['toolgroup'])){
echo '<br /><input type="Submit" name="submitAnnouncement" value="'. get_lang('Ok'). '" onclick="selectAll(this.form.elements[3],true)" /><br /><br />';
echo '<br /><input type="Submit" name="submitAnnouncement" value="'. get_lang('Ok'). '" onclick="selectAll(this.form.elements[4],true)" /><br /><br />';
if((isset ($_GET['action']) && isset ($_GET['id']) && is_array($to))||isset ($_GET['remindallinactives'])||isset ($_GET['remind_inactive'])){
echo '<script>document.getElementById(\'recipient_list\').style.display=\'block\';</script>';
/*===============================================
DISPLAY ANNOUNCEMENT LIST
===============================================*/
if ($display_announcement_list && !$surveyid)
// by default we use the id of the current user. The course administrator can see the announcement of other users by using the user / group filter
$user_id= $_user['user_id'];
if (isset ($_SESSION['user']))
$user_id= $_SESSION['user'];
if (isset ($_SESSION['group']))
$group_id= $_SESSION['group'];
//$group_memberships=GroupManager::get_group_ids($_course['dbName'], $_user['user_id']);
// 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 (isset ($_SESSION['user']))
announcement.*, toolitemproperties.*
FROM $tbl_announcement announcement, $tbl_item_property toolitemproperties
WHERE announcement.id = toolitemproperties.ref
AND toolitemproperties.tool='announcement'
AND (toolitemproperties.to_user_id=$user_id OR toolitemproperties.to_group_id IN (0, ". implode(", ", $group_memberships). ") )
ORDER BY display_order DESC";
announcement.*, toolitemproperties.*
FROM $tbl_announcement announcement, $tbl_item_property toolitemproperties
WHERE announcement.id = toolitemproperties.ref
AND toolitemproperties.tool='announcement'
AND (toolitemproperties.to_user_id=$user_id OR toolitemproperties.to_group_id='0')
AND toolitemproperties.visibility='1'
ORDER BY display_order DESC";
// A.2. you are a course admin with a GROUP filter
// => see only the messages of this specific group
elseif (isset ($_SESSION['group']))
announcement.*, toolitemproperties.*
FROM $tbl_announcement announcement, $tbl_item_property toolitemproperties
WHERE announcement.id = toolitemproperties.ref
AND toolitemproperties.tool='announcement'
AND (toolitemproperties.to_group_id=$group_id OR toolitemproperties.to_group_id='0')
GROUP BY toolitemproperties.ref
ORDER BY display_order DESC";
// 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
if (isset ($isStudentView) and $isStudentView== "true")
announcement.*, toolitemproperties.*
FROM $tbl_announcement announcement, $tbl_item_property toolitemproperties
WHERE announcement.id = toolitemproperties.ref
AND toolitemproperties.tool='announcement'
AND toolitemproperties.visibility='1'
GROUP BY toolitemproperties.ref
ORDER BY display_order DESC";
// A.3.a you are a course admin without user or group filter and WTIHOUT studentview (= the normal course admin view)
// => see all the messages of all the users and groups with editing possibilities
announcement.*, toolitemproperties.*
FROM $tbl_announcement announcement, $tbl_item_property toolitemproperties
WHERE announcement.id = toolitemproperties.ref
AND toolitemproperties.tool='announcement'
AND (toolitemproperties.visibility='0' or toolitemproperties.visibility='1')
GROUP BY toolitemproperties.ref
ORDER BY display_order DESC";
announcement.*, toolitemproperties.*
FROM $tbl_announcement announcement, $tbl_item_property toolitemproperties
WHERE announcement.id = toolitemproperties.ref
AND toolitemproperties.tool='announcement'
AND (toolitemproperties.to_user_id=$user_id OR toolitemproperties.to_group_id IN (0, ". implode(", ", $group_memberships). ") )
AND toolitemproperties.visibility='1'
ORDER BY display_order DESC";
announcement.*, toolitemproperties.*
FROM $tbl_announcement announcement, $tbl_item_property toolitemproperties
WHERE announcement.id = toolitemproperties.ref
AND toolitemproperties.tool='announcement'
AND (toolitemproperties.to_user_id='". $_user['user_id']. "' OR toolitemproperties.to_group_id='0')
AND toolitemproperties.visibility='1'
ORDER BY display_order DESC";
announcement.*, toolitemproperties.*
FROM $tbl_announcement announcement, $tbl_item_property toolitemproperties
WHERE announcement.id = toolitemproperties.ref
AND toolitemproperties.tool='announcement'
AND toolitemproperties.to_group_id='0'
AND toolitemproperties.visibility='1'";
/*=================================================
=================================================*/
echo "<table><tr><td>". get_lang('NoAnnouncements'). "</td></tr></table>";
$bottomAnnouncement = $announcement_number;
echo "\t\t\t<table width=\"100%\" border=\"1\" cellpadding=\"5\" cellspacing=\"0\" id=\"agenda_list\">\n";
if (!in_array($myrow['id'], $displayed))
$title = $myrow['title'];
$content = $myrow['content'];
/*================================================
================================================*/
$last_post_datetime = $myrow['end_date'];
list ($last_post_date, $last_post_time) = split(" ", $last_post_datetime);
list ($year, $month, $day) = explode("-", $last_post_date);
list ($hour, $min) = explode(":", $last_post_time);
$announceDate = mktime((int) $hour, (int) $min, 0, (int) $month, (int) $day, (int) $year);
if ($myrow['visibility']== '0')
$stylenotbold= "datanotbold_hidden";
$text_style= "text_hidden";
$stylenotbold= "datanotbold";
echo "\t\t\t\t<tr class=\"". $style. "\">";
/*===================================================================
===================================================================*/
echo "<a name=\"".(int) ($myrow["id"]). "\"></a>\n";
if ($myrow['to_group_id']!== '0' and $myrow['to_group_id']!== 'NULL')
echo "\t\t\t\t\t\t<img alt=\"$alt_ug\" src='../img/group.gif'>\n";
if ($myrow['email_sent'] == '1')
echo "\t\t\t\t\t\t<img alt=\"$alt_mail\" src='../img/email.gif'>\n";
echo "\t\t\t\t\t</td>\n";
/*==================================================================
==================================================================*/
echo "\t\t\t\t\t<td>". $title. "</td>\n";
/*==================================================================
===================================================================*/
echo "\t\t\t\t\t<td class=\"". $stylenotbold. "\">" . get_lang("SentTo") . " : ";
$sent_to= sent_to("announcement", $myrow['id']);
echo ' '. get_lang('By'). ' : '. $user_info['lastName']. ' '. $user_info['firstName'];
echo "\t\t\t\t\t</td>\n","\t\t\t\t</tr>\n";
/*=========================================================
=========================================================*/
"\t\t\t\t\t<td class=\"announcements_datum\" colspan=\"3\">",
/*=========================================================
=========================================================*/
"\t\t\t\t<tr class=\"$text_style\">\n",
"\t\t\t\t\t<td colspan=\"3\">\n",
/*========================================================
========================================================*/
echo "<i>". get_lang('AddedResources'). "</i><br />";
/*=====================================================================
SHOW MOD/DEL/VIS FUNCTIONS
=====================================================================*/
"<img src=\"../img/edit.gif\" title=\"",get_lang('Modify'),"\" border=\"0\" align=\"absmiddle\">",
"<img src=\"../img/delete.gif\" title=\"",get_lang('Delete'),"\" border=\"0\" align=\"absmiddle\">",
if ($myrow['visibility']== 1)
$image_visibility= "visible";
$image_visibility= "invisible";
echo "<td valign=\"top\"><a href=\"". api_get_self(). "?". api_get_cidreq(). "&origin=". (!empty($_GET['origin'])? $_GET['origin']: ''). "&action=showhide&id=". $myrow['id']. "\">",
"<img src=\"../img/". $image_visibility. ".gif\" border=\"0\" alt=\"". get_lang('Visible'). "\"/></a></td>";
// DISPLAY MOVE UP COMMAND only if it is not the top announcement
"<img src=../img/up.gif border=0 title=\"". get_lang('Up'). "\" align=\"absmiddle\">",
if($iterator < $bottomAnnouncement)
"<img src=\"../img/down.gif\" border=\"0\" title=\"". get_lang('Down'). "\" align=\"absmiddle\">",
echo "<tr><td width=\"100%\" colspan=\"3\"><a href=\"#top\"><img src=\"../img/top.gif\" border=\"0\" alt=\"To top\" align=\"right\"></a></td></tr>";
$displayed[]= $myrow['id'];
} // end while ($myrow = Database::fetch_array($result))
} // end: if ($displayAnnoucementList)
==============================================================================
==============================================================================
if (empty($_GET['origin']) or $_GET['origin'] !== 'learnpath')
//we are not in learnpath tool
|