2 /****************************************************************/
4 /****************************************************************/
5 /* Copyright (c) 2002-2010 */
6 /* Inclusive Design Institute */
9 /* This program is free software. You can redistribute it and/or*/
10 /* modify it under the terms of the GNU General Public License */
11 /* as published by the Free Software Foundation. */
12 /****************************************************************/
14 define('AT_INCLUDE_PATH', '../../../include/');
15 require (AT_INCLUDE_PATH.'vitals.inc.php');
16 require(AT_INCLUDE_PATH.'lib/tinymce.inc.php');
18 authenticate(AT_PRIV_ANNOUNCEMENTS);
20 if (defined('AT_FORCE_GET_FILE') && AT_FORCE_GET_FILE) {
21 $content_base_href = 'get.php/';
23 $content_base_href = 'content/' . $_SESSION['course_id'] . '/';
26 if (isset($_POST['cancel'])) {
27 $msg->addFeedback('CANCELLED');
28 header('Location: '.AT_BASE_HREF.'mods/_standard/announcements/index.php');
30 } else if ($_POST['edit_news']) {
31 $_POST['title'] = trim($_POST['title']);
32 $_POST['body_text'] = trim($_POST['body_text']);
33 $_POST['aid'] = intval($_POST['aid']);
34 $_POST['formatting'] = intval($_POST['formatting']);
36 if (($_POST['title'] == '') && ($_POST['body_text'] == '')) {
37 $msg->addErros('ANN_BOTH_EMPTY');
40 if (!$msg->containsErrors() && isset($_POST['submit'])) {
41 $_POST['title'] = $addslashes($_POST['title']);
42 $_POST['body_text'] = $addslashes($_POST['body_text']);
43 //Check if the title has exceeded the DB length, 100
44 $_POST['title'] = validate_length($_POST['title'], 100);
46 $sql = "UPDATE ".TABLE_PREFIX."news SET title='$_POST[title]', body='$_POST[body_text]', formatting=$_POST[formatting], date=date WHERE news_id=$_POST[aid] AND course_id=$_SESSION[course_id]";
47 $result = mysql_query($sql,$db);
49 /* update announcement RSS: */
50 if (file_exists(AT_CONTENT_DIR . 'feeds/' . $_SESSION['course_id'] . '/RSS1.0.xml')) {
51 @unlink(AT_CONTENT_DIR . 'feeds/' . $_SESSION['course_id'] . '/RSS1.0.xml');
53 if (file_exists(AT_CONTENT_DIR . 'feeds/' . $_SESSION['course_id'] . '/RSS2.0.xml')) {
54 @unlink(AT_CONTENT_DIR . 'feeds/' . $_SESSION['course_id'] . '/RSS2.0.xml');
57 $msg->addFeedback('ACTION_COMPLETED_SUCCESSFULLY');
58 header('Location: '.AT_BASE_HREF.'mods/_standard/announcements/index.php');
63 if (!isset($_REQUEST['setvisual']) && !isset($_REQUEST['settext'])) {
64 if ($_SESSION['prefs']['PREF_CONTENT_EDITOR'] == 1) {
65 $_POST['formatting'] = 1;
66 $_REQUEST['settext'] = 0;
67 $_REQUEST['setvisual'] = 0;
69 } else if ($_SESSION['prefs']['PREF_CONTENT_EDITOR'] == 2) {
70 $_POST['formatting'] = 1;
71 $_POST['settext'] = 0;
72 $_POST['setvisual'] = 1;
74 } else { // else if == 0
75 $_POST['formatting'] = 0;
76 $_REQUEST['settext'] = 0;
77 $_REQUEST['setvisual'] = 0;
81 if ((!$_POST['setvisual'] && $_POST['settext']) || !$_GET['setvisual']){
82 $onload = 'document.form.title.focus();';
85 require(AT_INCLUDE_PATH.'header.inc.php');
87 if (($_POST['setvisual'] && !$_POST['settext']) || $_GET['setvisual']) {
91 if (isset($_GET['aid'])) {
92 $aid = intval($_GET['aid']);
94 $aid = intval($_POST['aid']);
98 $msg->printErrors('ITEM_NOT_FOUND');
99 require (AT_INCLUDE_PATH.'footer.inc.php');
103 $sql = "SELECT * FROM ".TABLE_PREFIX."news WHERE news_id=$aid AND course_id=$_SESSION[course_id]";
104 $result = mysql_query($sql,$db);
105 if (!($row = mysql_fetch_array($result))) {
106 $msg->printErrors('ITEM_NOT_FOUND');
107 require (AT_INCLUDE_PATH.'footer.inc.php');
110 $_POST['formatting'] = intval($row['formatting']);
111 $savant->assign('row', $row);
112 $savant->display('instructor/announcements/edit_news.tmpl.php');
113 require (AT_INCLUDE_PATH.'footer.inc.php'); ?>