12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484 |
- <?php //$Id: announcements.php 12263 2007-05-03 13:34:40Z elixir_julian $
- /*
- ==============================================================================
- Dokeos - elearning and course management software
- Copyright (c) 2004-2005 Dokeos S.A.
- 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, 44 rue des palais, B-1030 Brussels, Belgium
- Mail: info@dokeos.com
- ==============================================================================
- */
- /**
- ==============================================================================
- * @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
- * multiple functions
- ==============================================================================
- */
- /*
- ==============================================================================
- INIT SECTION
- ==============================================================================
- */
- // name of the language file that needs to be included
- $language_file[] = "announcements";
- $language_file[] = "group";
- $language_file[] = "survey";
- // setting the global file that gets the general configuration, the databases, the languages, ...
- include('../inc/global.inc.php');
- $this_section=SECTION_COURSES;
- $nameTools = get_lang('Announcement');
- //session
- if(isset($_GET['id_session']))
- $_SESSION['id_session'] = $_GET['id_session'];
- /* ------------ ACCESS RIGHTS ------------ */
- // notice for unauthorized people.
- api_protect_course_script();
- /*
- -----------------------------------------------------------
- Constants and variables
- -----------------------------------------------------------
- */
- // Configuration settings
- $display_announcement_list = true;
- $display_form = false;
- $display_title_list = true;
- // Maximum title messages to display
- $maximum = '12';
- // Length of the titles
- $length = '36';
- // Database Table Definitions
- $tbl_course_user = Database::get_main_table(TABLE_MAIN_COURSE_USER);
- $tbl_user = Database::get_main_table(TABLE_MAIN_USER);
- $tbl_courses = Database::get_main_table(TABLE_MAIN_COURSE);
- $tbl_sessions = Database::get_main_table(TABLE_MAIN_SESSION);
- $tbl_session_course_user= Database::get_main_table(TABLE_MAIN_SESSION_COURSE_USER);
- $tbl_group = Database::get_course_table(TABLE_GROUP);
- $tbl_groupUser = Database::get_course_table(TABLE_GROUP_USER);
- $tbl_announcement = Database::get_course_table(TABLE_ANNOUNCEMENT);
- $tbl_item_property = Database::get_course_table(TABLE_ITEM_PROPERTY);
- /*
- -----------------------------------------------------------
- Resource linker
- -----------------------------------------------------------
- */
- $_SESSION['source_type']="Ad_Valvas";
- include('../resourcelinker/resourcelinker.inc.php');
- if ($_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
- {
- $action="edit";
- }else
- {
- $action="add";
- }
- // ============== //
- // 7 = Ad_Valvas //
- // ============== //
- if($surveyid)
- {
- header("Location: ../resourcelinker/resourcelinker.php?source_id=7&action=$action&id=$id&originalresource=no&publish_survey=$surveyid&db_name=$db_name&cidReq=$cidReq");
- exit;
- }
- else
- {
- header("Location: ../resourcelinker/resourcelinker.php?source_id=7&action=$action&id=$id&originalresource=no");
- exit;
- }
- exit;
- }
- /*
- -----------------------------------------------------------
- Tracking
- -----------------------------------------------------------
- */
- include(api_get_path(LIBRARY_PATH).'events.lib.inc.php');
- event_access_tool(TOOL_ANNOUNCEMENT);
- /*
- -----------------------------------------------------------
- Libraries
- -----------------------------------------------------------
- */
- 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');
- /*
- -----------------------------------------------------------
- POST TO
- -----------------------------------------------------------
- */
- if ($_POST['To'])
- {
- $display_form = true;
- $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 (!$_POST['To'] and !$_SESSION['select_groupusers'])
- {
- $_SESSION['select_groupusers']="hide";
- }
- $select_groupusers_status=$_SESSION['select_groupusers'];
- if ($_POST['To'] and ($select_groupusers_status=="hide"))
- {
- $_SESSION['select_groupusers']="show";
- }
- if ($_POST['To'] and ($select_groupusers_status=="show"))
- {
- $_SESSION['select_groupusers']="hide";
- }
- /*
- -----------------------------------------------------------
- Action handling
- -----------------------------------------------------------
- */
- // display the form
- if (($_GET['action'] == 'add' && $_GET['origin'] == "") || $_GET['action'] == 'edit' || $_POST['To'])
- {
- $display_form = true;
- }
- // clear all resources
- if ($originalresource!=="no" and $action=="add")
- {
- $_SESSION["formelements"]=null;
- unset_session_resources();
- }
- /*
- -----------------------------------------------------------
- Javascript
- -----------------------------------------------------------
- */
- $htmlHeadXtra[] = to_javascript();
- /*
- -----------------------------------------------------------
- Filter user/group
- -----------------------------------------------------------
- */
- /* if ($_GET['user'] or $_GET['group'])
- {
- $_SESSION['user']=$_GET['user'];
- $_SESSION['group']=$_GET['group'];
- }
- if ($_GET['user']=="none" or $_GET['group']=="none")
- {
- api_session_unregister("user");
- api_session_unregister("group");
- }
- if ($_GET['isStudentView']=="false")
- {
- api_session_unregister("user");
- api_session_unregister("group");
- }
- */
- if(!empty($_GET['toolgroup'])){
- if($_GET['toolgroup'] == strval(intval($_GET['toolgroup']))){ //check is integer
- $toolgroup = $_GET['toolgroup'];
- $_SESSION['select_groupusers'] = 'hide';
- }else{
- $toolgroup = 0;
- }
- api_session_register("toolgroup");
- }
- /*
- -----------------------------------------------------------
- Sessions
- -----------------------------------------------------------
- */
- if ($_SESSION['formelements'] 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'];
- }
- /*
- -----------------------------------------------------------
- Survey
- -----------------------------------------------------------
- */
- $surveyid=$_REQUEST['publish_survey'];
- $cidReq=$_REQUEST['cidReq'];
- if($surveyid)
- {
- $db_name=$_REQUEST['db_name'];
- $sql_temp = "SELECT * FROM $db_name.survey WHERE survey_id='$surveyid'";
- $res_temp = api_sql_query($sql_temp, __FILE__, __LINE__);
- $obj=@mysql_fetch_object($res_temp);
- $template=$obj->template;
- }
- if($surveyid)
- {
- $interbreadcrumb[] = array ("url" => "../survey/survey_list.php?cidReq=$cidReq", "name" => get_lang('Survey'));
- $nameTools = get_lang('PublishSurvey');
- }
- else
- $nameTools = get_lang('Announcement');
- $nameTools12 = get_lang('PublishSurvey');
- /*
- -----------------------------------------------------------
- Learning path & css
- -----------------------------------------------------------
- */
- // 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 ($_GET['origin'] !== 'learnpath')
- {
- //we are not in the learning path
- Display::Display_header($nameTools,"Announcements");
- }
- else
- {
- //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">
- <?php
- }
- // inserting an anchor (top) so one can jump back to the top of the page
- echo "<a name=\"top\"></a>";
- /*=============================================
- ACTION HANDLING
- =============================================*/
- if (api_is_allowed_to_edit() OR api_get_course_setting('allow_user_edit_announcement'))
- {
- /*
- -----------------------------------------------------------
- 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 ($_GET['isStudentView']<>"false")
- {
- if (isset($_GET['id']) AND $_GET['id'] AND isset($_GET['action']) AND $_GET['action']=="showhide")
- {
- $id=intval(addslashes($_GET['id']));
- change_visibility(TOOL_ANNOUNCEMENT,$id);
- $message = get_lang("Visible");
- }
- }
- /*
- -----------------------------------------------------------
- Delete announcement
- -----------------------------------------------------------
- */
- if ($_GET['action']=="delete" AND isset($_GET['id']))
- {
- //api_sql_query("DELETE FROM $tbl_announcement WHERE id='$delete'",__FILE__,__LINE__);
- $id=intval(addslashes($_GET['id']));
- // tooledit : visibility = 2 : only visibile for platform administrator
- api_sql_query("UPDATE $tbl_item_property SET visibility='2' WHERE tool='".TOOL_ANNOUNCEMENT."' and ref='".$id."'",__FILE__,__LINE__);
- delete_added_resource("Ad_Valvas", $delete);
- $id = null;
- $emailTitle = null;
- $newContent = null;
- $message = get_lang("AnnouncementDeleted");
- }
- /*
- -----------------------------------------------------------
- Delete all announcements
- -----------------------------------------------------------
- */
- if ($_GET['action']=="delete_all")
- {
- //api_sql_query("DELETE FROM $tbl_announcement",__FILE__,__LINE__);
- api_sql_query("UPDATE $tbl_item_property SET visibility='2' WHERE tool='".TOOL_ANNOUNCEMENT."'",__FILE__,__LINE__);
- delete_all_resources_type("Ad_Valvas");
- $id = null;
- $emailTitle = null;
- $newContent = null;
- $message = get_lang("AnnouncementDeletedAll");
- }
- /*
- -----------------------------------------------------------
- Modify announcement
- -----------------------------------------------------------
- */
- if ($_GET['action']=="modify" AND isset($_GET['id']))
- {
- $display_form = true;
- // RETRIEVE THE CONTENT OF THE ANNOUNCEMENT TO MODIFY
- $id = intval(addslashes($_GET['id']));
- $sql="SELECT * FROM $tbl_announcement WHERE id='$id'";
- $result = api_sql_query($sql,__FILE__,__LINE__);
- $myrow = mysql_fetch_array($result);
- if ($myrow)
- {
- $announcement_to_modify = $myrow['id'];
- $content_to_modify = $myrow['content'];
- $title_to_modify = $myrow['title'];
- if ($originalresource!=="no") // and !addresources)
- {
- //unset_session_resources();
- edit_added_resources("Ad_Valvas", $announcement_to_modify);
- $to=load_edit_users("announcement", $announcement_to_modify);
- }
- $display_announcement_list = false;
- }
- if ($to=="everyone" OR !empty($_SESSION['toolgroup']))
- {
- $_SESSION['select_groupusers']="hide";
- }
- else
- {
- $_SESSION['select_groupusers']="show";
- }
- }
- /*
- -----------------------------------------------------------
- Move announcement up/down
- -----------------------------------------------------------
- */
- if ($_GET['down'])
- {
- $thisAnnouncementId = intval($_GET['down']);
- $sortDirection = "DESC";
- }
- if ($_GET['up'])
- {
- $thisAnnouncementId = intval($_GET['up']);
- $sortDirection = "ASC";
- }
- if ($sortDirection)
- {
- if (!in_array(trim(strtoupper($sortDirection)), array('ASC', 'DESC')))
- {
- $sortDirection='ASC';
- }
- $my_sql = "SELECT announcement.id, announcement.display_order " .
- "FROM $tbl_announcement announcement, " .
- "$tbl_item_property itemproperty " .
- "WHERE itemproperty.ref=announcement.id " .
- "AND itemproperty.tool='".TOOL_ANNOUNCEMENT."' " .
- "AND itemproperty.visibility<>2 " .
- "ORDER BY display_order $sortDirection";
- $result = api_sql_query($my_sql,__FILE__,__LINE__);
- while (list ($announcementId, $announcementOrder) = mysql_fetch_row($result))
- {
- // STEP 2 : FOUND THE NEXT ANNOUNCEMENT ID AND ORDER.
- // COMMIT ORDER SWAP ON THE DB
- if (isset ($thisAnnouncementOrderFound) && $thisAnnouncementOrderFound == true)
- {
- $nextAnnouncementId = $announcementId;
- $nextAnnouncementOrder = $announcementOrder;
- api_sql_query("UPDATE $tbl_announcement " .
- "SET display_order = '$nextAnnouncementOrder' " .
- "WHERE id = '$thisAnnouncementId'",__FILE__,__LINE__);
- api_sql_query("UPDATE $tbl_announcement " .
- "SET display_order = '$thisAnnouncementOrder' " .
- "WHERE id = '$nextAnnouncementId.'",__FILE__,__LINE__);
- break;
- }
- // STEP 1 : FIND THE ORDER OF THE ANNOUNCEMENT
- if ($announcementId == $thisAnnouncementId)
- {
- $thisAnnouncementOrder = $announcementOrder;
- $thisAnnouncementOrderFound = true;
- }
- }
- // show message
- $message = get_lang('AnnouncementMoved');
- }
- /*
- -----------------------------------------------------------
- Submit announcement
- -----------------------------------------------------------
- */
- if (api_is_allowed_to_edit() OR api_get_course_setting('allow_user_edit_announcement'))
- {
- $emailTitle=$_POST['emailTitle'];
- $newContent=$_POST['newContent'];
- $submitAnnouncement=isset($_POST['submitAnnouncement'])?$_POST['submitAnnouncement']:0;
- $id=intval($_POST['id']);
- if ($submitAnnouncement)
- {
-
- if(isset($id)&&$id) // there is an Id => the announcement already exists => update mode
- {
- $edit_id = edit_advalvas_item($id,$emailTitle,$newContent,$_POST['selectedform']);
- if(!$delete)
- {
- update_added_resources("Ad_Valvas", $id);
- }
- $message = get_lang('AnnouncementModified');
- }
- else //insert mode
- {
- if(!$surveyid){
- $result = api_sql_query("SELECT MAX(display_order) FROM $tbl_announcement",__FILE__,__LINE__);
-
- list($orderMax) = mysql_fetch_row($result);
- $order = $orderMax + 1;
- if(!empty($_SESSION['toolgroup'])){
- $insert_id=store_advalvas_item($_POST['emailTitle'],$_POST['newContent'],$order,array('GROUP:'.$_SESSION['toolgroup']));
- }else{
- $insert_id=store_advalvas_item($_POST['emailTitle'],$_POST['newContent'],$order,$_POST['selectedform']);
- }
-
- store_resources($_SESSION['source_type'],$insert_id);
-
- $_SESSION['select_groupusers']="hide";
-
- $message = get_lang('AnnouncementAdded');
- }
- /*============================================================
- MAIL WHEN USER COMES FROM SURVEY
- ======================================================= */
- if($_POST['emailsAdd'])
- {
- $to_email_address =$_POST['emailsAdd'];
- $to_email_to = explode(',', $to_email_address);
- $to_email = array_unique($to_email_to);
- $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 ))
- {
- $subject=stripslashes($emailTitle);
- $message=stripslashes($newContentsix);
- $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'";
- $res_date=api_sql_query($sql_date);
- $obj_date=mysql_fetch_object($res_date);
- $end_date=$obj_date->avail_till;
- $table_reminder = Database :: get_main_table(TABLE_MAIN_SURVEY_REMINDER);
- if($_REQUEST['reminder']=="1")
- {
- $time=getdate();
- $time = $time['yday'];
- $time = $time+7;
- $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')";
- api_sql_query($sql_insert);
- }
- else if($_REQUEST['reminder']=="2")
- {
- $time=getdate();
- $time = $time['yday'];
- $time = $time+14;
- $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')";
- api_sql_query($sql_insert);
- }
- else if($_REQUEST['reminder']=="3")
- {
- $time=getdate();
- $time = $time['yday'];
- $time = $time+30;
- $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')";
- api_sql_query($sql_insert);
- }
- }
- }
- }
- /*===================================================================
- MAIL FUNCTION
- ===================================================================*/
- if (empty($_POST['onlyThoseMails']))
- {
-
- $sent_to=sent_to("announcement", $insert_id);
-
- $userlist = $sent_to['users'];
- $grouplist = $sent_to['groups'];
- // groepen omzetten in users
- if ($grouplist)
- {
- $grouplist = "'".implode("', '",$grouplist)."'"; //protect individual elements with surrounding quotes
- $sql = "SELECT user_id
- FROM $tbl_groupUser gu
- WHERE gu.group_id IN (".$grouplist.")";
- $groupMemberResult = api_sql_query($sql,__FILE__,__LINE__);
- if ($groupMemberResult)
- {
- while ($u = mysql_fetch_array($groupMemberResult))
- {
- $userlist [] = $u [user_id]; // complete the user id list ...
- }
- }
- }
- if(is_array($userlist))
- {
- $userlist = "'".implode("', '", array_unique($userlist) )."'";
- // send to the created 'userlist'
- $sqlmail = "SELECT user_id, lastname, firstname, email
- FROM $tbl_user
- WHERE user_id IN (".$userlist.")";
- }
- else if(empty($_POST['not_selected_form']))
- {
- // send to everybody
- $sqlmail = "SELECT user.user_id, user.email, user.lastname, user.firstname
- FROM $tbl_course_user, $tbl_user
- WHERE course_code='".mysql_real_escape_string($_course['sysCode'])."'
- AND course_rel_user.user_id = user.user_id";
- }
- if($sqlmail!=''){
- $result = api_sql_query($sqlmail,__FILE__,__LINE__);
- /*=================================================================================
- send email one by one to avoid antispam
- =================================================================================*/
- while ($myrow = mysql_fetch_array($result))
- {
- /* 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)
- */
- $emailsubjbericht = get_lang('professorMessage');
- $emailSubject = $emailsubjbericht. " - ".$_course['official_code'];
- $db_name = $_REQUEST['db_name'];
- if($surveyid) {
- $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);
- $message=stripslashes($newContentsix);
- $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);
- api_mail('',$myrow["email"],stripslashes($emailTitle),$message,$sender_name,$email);
- }
- else{
- $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'];
- //$mail_body;
- $headers = array();
- if(empty($charset)){$charset='ISO-8859-1';}
- $headers['Content-Type'] = 'text/html';
- $headers['charset'] = $charset;
- $mailid=$myrow["email"];
- $newmail = api_mail_html($myrow["lastname"].' '.$myrow["firstname"], $myrow["email"], $emailSubject, $mail_body, $_SESSION['_user']['lastName'].' '.$_SESSION['_user']['firstName'], $_SESSION['_user']['mail'],$headers);
- }
- $sql_date="SELECT * FROM $db_name.survey WHERE survey_id='$surveyid'";
- $res_date=api_sql_query($sql_date);
- $obj_date=mysql_fetch_object($res_date);
- $end_date=$obj_date->avail_till;
- $table_reminder = Database :: get_main_table(TABLE_MAIN_SURVEY_REMINDER);
- if($_REQUEST['reminder']=="1")
- {
- $time=getdate();
- $time = $time['yday'];
- $time = $time+7;
- $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')";
- api_sql_query($sql);
- }
- else if($_REQUEST['reminder']=="2")
- {
- $time=getdate();
- $time = $time['yday'];
- $time = $time+14;
- $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')";
- api_sql_query($sql);
- }
- else if($_REQUEST['reminder']=="3")
- {
- $time=getdate();
- $time = $time['yday'];
- $time = $time+30;
- $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')";
- api_sql_query($sql);
- }
- }
- update_mail_sent($insert_id);
- $message = $added_and_sent;
- }
- } // $email_ann*/
- } // isset
- // UNSET VARIABLES
- unset_session_resources();
- unset($form_elements);
- $_SESSION['formelements']=null;
- $newContent = null;
- $emailTitle = null;
- unset($emailTitle);
- unset($newContent);
- unset($content_to_modify);
- unset($title_to_modify);
- if($_REQUEST['publish_survey'])
- {
- $surveyid=$_REQUEST['surveyid'];
- $cidReq = $_REQUEST['cidReq'];
- ?>
- <script>
- window.location.href="../survey/survey_list.php?<?php echo api_get_cidreq(); ?>&published=published&surveyid=<?php echo $_REQUEST['publish_survey']; ?>";
- </script>
- <?php
- }
- } // if $submit Announcement
- }
- }
- /*====================================================
- Tool Title
- ====================================================*/
- if ($_GET['origin'] !== 'learnpath')
- {
- //api_display_tool_title($nameTools);
- //Display::display_introduction_section(TOOL_ANNOUNCEMENT, $is_allowed);
- }
- /*
- ==============================================================================
- MAIN SECTION
- ==============================================================================
- */
- /*=====================================================================================
- MAIN CODE HTML
- =====================================================================================*/
- // The commands below will change these display settings if they need it
- if ($_GET['origin'] !== 'learnpath')
- {
- echo "\n\n<table width=\"100%\" border=\"0\" cellspacing=\"0\" cellpadding=\"0\">\n";
- echo "\t<tr>\n";
- echo "\t\t<td width=\"20%\" valign=\"top\">\n";
- }
- /*======================================================================
- DISPLAY LEFT COLUMN
- ======================================================================*/
- if(api_is_allowed_to_edit() OR api_get_course_setting('allow_user_edit_announcement')) // check teacher status
- {
- if ($_GET['origin'] !== 'learnpath')
- {
- $sql="SELECT
- 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
- LIMIT 0,$maximum";
- }
- }
- else // students only get to see the visible announcements
- {
- if ($_GET['origin'] !== 'learnpath')
- {
- $group_memberships=GroupManager::get_group_ids($_course['dbName'], $_user['user_id']);
- // the user is member of several groups => display personal announcements AND his group announcements AND the general announcements
- if (is_array($group_memberships))
- {
- $sql="SELECT
- 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
- LIMIT 0,$maximum";
- }
- // the user is not member of any group
- else
- {
- // this is an identified user => show the general announcements AND his personal announcements
- if ($_user['user_id'])
- {
- $sql="SELECT
- 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
- LIMIT 0,$maximum";
- }
- // the user is not identiefied => show only the general announcements
- else
- {
- $sql="SELECT
- 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
- LIMIT 0,$maximum";
- }
- }
- }
- }
- $result = api_sql_query($sql,__FILE__,__LINE__);
- $announcement_number = mysql_num_rows($result);
- /*----------------------------------------------------
- ADD ANNOUNCEMENT / DELETE ALL
- ----------------------------------------------------*/
- if(!$surveyid)
- {
- if ((api_is_allowed_to_edit() OR api_get_course_setting('allow_user_edit_announcement')) and ($_GET['origin'] !== 'learnpath'))
- {
- echo "<a href='".api_get_self()."?".api_get_cidreq()."&action=add&origin=".$_GET['origin']."'><img src=\"../img/announce_add.gif\"> ".get_lang("AddAnnouncement")."</a><br/>";
- if ($announcement_number > 1)
- {
- 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\">";
- }
- }
- /*----------------------------------------------------
- ANNOUNCEMENTS LIST
- ----------------------------------------------------*/
- if(!$surveyid)
- {
-
- if ($display_title_list == true)
- {
- echo "\t\t\t<table>\n";
- while ($myrow = mysql_fetch_array($result))
- {
- $title = $myrow['title'];
- echo "\t\t\t\t<tr>\n";
- echo "\t\t\t\t\t<td width=\"15%\">\n";
- if ($myrow['visibility']==0)
- { $class="class=\"invisible\"";}
- else
- { $class="";}
- 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";
- }
- echo "\t\t\t</table>\n";
- } // end $display_title_list == true
- }
- if ($_GET['origin'] !== 'learnpath')
- {
- echo "\t\t</td>\n";
- echo "\t\t<td width=\"20\" background=\"../img/verticalruler.gif\"> </td>\n";
- // START RIGHT PART
- echo "\t\t<td valign=\"top\">\n";
- }
- /*=======================================
- DISPLAY ACTION MESSAGE
- =======================================*/
- if ($message == true)
- {
- Display::display_normal_message($message);
- $display_announcement_list = true;
- $display_form = false;
- }
- /*==================================================================================
- DISPLAY FORM
- ==================================================================================*/
- if ($display_form == true)
- {
-
- $content_to_modify=stripslashes($content_to_modify);
- $title_to_modify=stripslashes($title_to_modify);
-
- // 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
- // or not
- //echo "sessiewaarde: ".$_SESSION['select_groupusers'];
- if(empty($_SESSION['toolgroup'])){
-
- echo "<table><tr><td>";
- echo get_lang("SentTo").": ";
- echo "</td><td>";
- if(isset($_GET['id']) && is_array($to)){
- echo ' ';
- }
- else{
- echo get_lang("Everybody");
- }
- echo "</td><td>";
- 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>";
- show_to_form($to);
- echo "<br /><br />";
- 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')," : ",
- "<br /><br />";*/
- }
- }else{
- 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'),
- //"<br><br>";
- }
- }
- if($surveyid){
- 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 />";
- unset($title_to_modify);
- $title_to_modify = null;
- 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."\">";
- if($surveyid){
- $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 />
- '.get_lang('OrCopyPasteUrl').' <br />
- '.api_get_path(WEB_CODE_PATH).'/survey/#page#?temp=#temp#&surveyid=#sid#&uid=#uid#&mail=#mail#&db_name=#db_name ';
- }
- //api_disp_html_area('newContent',$content_to_modify,'250px');
-
- require_once(api_get_path(LIBRARY_PATH) . "/fckeditor/fckeditor.php");
- $oFCKeditor = new FCKeditor('newContent') ;
- $oFCKeditor->BasePath = api_get_path(WEB_PATH) . 'main/inc/lib/fckeditor/' ;
- $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";
-
- $TBL_LANGUAGES = Database::get_main_table(TABLE_MAIN_LANGUAGE);
- $sql="SELECT isocode FROM ".$TBL_LANGUAGES." WHERE english_name='".$_SESSION["_course"]["language"]."'";
- $result_sql=api_sql_query($sql);
- $isocode_language=mysql_result($result_sql,0,0);
- $oFCKeditor->Config['DefaultLanguage'] = $isocode_language;
-
- echo $oFCKeditor->CreateHtml();
- /*echo "<br /><table>",
- "<tr>",
- "<td colspan=7>";
- if ($_SESSION['select_groupusers']=="show")
- {
- show_addresource_button("onClick=\"selectAll(this.form.elements[4],true)\"");
- }
- else
- {
- show_addresource_button();
- }
- // sessies
- $form_elements=$_SESSION['formelements'];
- echo "</td>",
- "</tr>";
- if ($_SESSION['addedresource']){
- if(!$surveyid){
- echo "<tr>";
- echo "<td colspan='7'>";
- echo display_resources(0);
- $test=$_SESSION['addedresource'];
- echo "</td></tr>";
- }
- }
- echo "</table>";*/
- ?>
- <br /><input type="Submit" name="submitAnnouncement" value="<?php echo get_lang('Ok') ?>" onclick="selectAll(this.form.elements[3],true)" /><br /><br />
- <?php
- "</form><br />\n";
- if(isset($_GET['action']) && isset($_GET['id']) && is_array($to)){
- echo '<script>document.getElementById(\'recipient_list\').style.display=\'block\';</script>';
- }
- } // displayform
- /*===============================================
- 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 ($_SESSION['user']!==null)
- {
- $user_id=$_SESSION['user'];
- }
- if ($_SESSION['group']!==null)
- {
- $group_id=$_SESSION['group'];
- }
- //$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() OR api_get_course_setting('allow_user_edit_announcement'))
- {
- // 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 ($_SESSION['user']!==null)
- {
- if (is_array($group_memberships))
- {
- $sql="SELECT
- 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";
- }
- else
- {
- $sql="SELECT
- 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 ($_SESSION['group']!==null)
- {
- $sql="SELECT
- 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
- else
- {
- // 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 ($isStudentView=="true")
- {
- $sql="SELECT
- 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
- else
- {
- $sql="SELECT
- 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";
- }
- }
- }
- else //STUDENT
- {
- if (is_array($group_memberships))
- {
- $sql="SELECT
- 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";
- }
- else
- {
- if ($_user['user_id'])
- {
- $sql="SELECT
- 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";
- }
- else
- {
- $sql="SELECT
- 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'";
- }
- }
- }
- $result = api_sql_query($sql,__FILE__,__LINE__);
- $num_rows = mysql_num_rows($result);
- /*=================================================
- DISPLAY: NO ITEMS
- =================================================*/
- if ($num_rows == 0)
- {
- echo "<table><tr><td>".get_lang('NoAnnouncements')."</td></tr></table>";
- }
- $iterator = 1;
- $bottomAnnouncement = $announcement_number;
- echo "\t\t\t<table width=\"100%\" border=\"1\" cellpadding=\"5\" cellspacing=\"0\" id=\"agenda_list\">\n";
- $displayed=array();
- while ($myrow = mysql_fetch_array($result))
- {
- if (!in_array($myrow['id'], $displayed))
- {
- $title = $myrow['title'];
- $content = $myrow['content'];
- $content = make_clickable($content);
- $content = text_filter($content);
- /*================================================
- DATE
- ================================================*/
- $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($hour, $min, 0, $month, $day, $year);
- // the styles
- if ($myrow['visibility']=='0')
- {
- $style="data_hidden";
- $stylenotbold="datanotbold_hidden";
- $text_style="text_hidden";
- }
- else
- {
- $style="data";
- $stylenotbold="datanotbold";
- $text_style="text";
- }
- echo "\t\t\t\t<tr class=\"".$style."\">";
- /*===================================================================
- THE ICONS
- ===================================================================*/
- echo "\t\t\t\t\t<td>\n";
- // anchoring
- echo "<a name=\"".(int)($myrow["id"])."\"></a>\n";
- // User or group icon
- 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";
- }
- // the email icon
- 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";
- /*==================================================================
- TITLE
- ==================================================================*/
- echo "\t\t\t\t\t<td>".$title."</td>\n";
- /*==================================================================
- SENT TO
- ===================================================================*/
- echo "\t\t\t\t\t<td class=\"".$stylenotbold."\">" . get_lang("SentTo") . " : ";
- $sent_to=sent_to("announcement", $myrow['id']);
- // echo $myrow['id'];
- $sent_to_form=sent_to_form($sent_to);
- echo $sent_to_form,
- "\t\t\t\t\t</td>\n",
- "\t\t\t\t</tr>\n";
- /*=========================================================
- TITLE
- =========================================================*/
- echo "\t\t\t\t<tr>\n",
- "\t\t\t\t\t<td class=\"announcements_datum\" colspan=\"3\">",
- get_lang('AnnouncementPublishedOn')," : ",ucfirst(format_locale_date($dateFormatLong,strtotime($last_post_date))),
- "</td>\n",
- "\t\t\t\t</tr>\n",
- /*=========================================================
- CONTENT
- =========================================================*/
- "\t\t\t\t<tr class=\"$text_style\">\n",
- "\t\t\t\t\t<td colspan=\"3\">\n",
- $content,
- "\t\t\t\t\t</td>\n",
- "\t\t\t\t</tr>\n",
- /*========================================================
- RESOURCES
- ========================================================*/
- "<tr>\n",
- "<td colspan=\"3\">\n";
- if (check_added_resources("Ad_Valvas", $myrow["id"]))
- {
- echo "<i>".get_lang('AddedResources')."</i><br />";
- display_added_resources("Ad_Valvas", $myrow["id"]);
- }
- echo "<br />";
- if(api_is_allowed_to_edit())
- {
- /*=====================================================================
- SHOW MOD/DEL/VIS FUNCTIONS
- =====================================================================*/
- echo "<table><tr>";
- echo "<td valign=\"top\"><a href=\"".api_get_self()."?".api_get_cidreq()."&action=modify&id=".$myrow['id']."\">",
- "<img src=\"../img/edit.gif\" title=\"",get_lang('Modify'),"\" border=\"0\" align=\"absmiddle\">",
- "</a></td>";
- if (api_is_allowed_to_edit()) echo "<td valign=\"top\"><a href=\"".api_get_self()."?".api_get_cidreq()."&action=delete&id=".$myrow['id']."\" onclick=\"javascript:if(!confirm('".addslashes(htmlentities(get_lang('ConfirmYourChoice')))."')) return false;\">",
- "<img src=\"../img/delete.gif\" title=\"",get_lang('Delete'),"\" border=\"0\" align=\"absmiddle\">",
- "</a></td>";
- if ($myrow['visibility']==1)
- {
- $image_visibility="visible";
- }
- else
- {
- $image_visibility="invisible";
- }
- echo "<td valign=\"top\"><a href=\"".api_get_self()."?".api_get_cidreq()."&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
- if($iterator != 1)
- {
- echo "<td valign=\"top\"><a href=\"".api_get_self()."?".api_get_cidreq()."&up=",$myrow["id"],"\">",
- "<img src=../img/up.gif border=0 title=\"".get_lang('Up')."\" align=\"absmiddle\">",
- "</a></td>";
- }
- if($iterator < $bottomAnnouncement)
- {
- echo "<td valign=\"top\"><a href=\"".api_get_self()."?".api_get_cidreq()."&down=".$myrow["id"]."\">",
- "<img src=\"../img/down.gif\" border=\"0\" title=\"".get_lang('Down')."\" align=\"absmiddle\">",
- "</a></td>";
- }
- echo "</tr></table>";
- echo "</td>\n",
- "</tr>\n";
- $iterator ++;
- } // is_allowed_to_edit
- 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 = mysql_fetch_array($result))
- echo "</table>";
- } // end: if ($displayAnnoucementList)
- echo "</table>";
- if ($display_specific_announcement) display_announcement($announcement_id);
- /*
- ==============================================================================
- FOOTER
- ==============================================================================
- */
- if ($_GET['origin'] !== 'learnpath')
- {
- //we are not in learnpath tool
- Display::display_footer();
- }
- ?>
|