From 72c8617b04c8e528f28509fa3ca523192dca8ac4 Mon Sep 17 00:00:00 2001 From: Arthur Portugal Date: Tue, 17 Nov 2009 16:17:19 -0500 Subject: [PATCH] Implemented attachment file for groups DT#818 --- main/announcements/announcements.inc.php | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) diff --git a/main/announcements/announcements.inc.php b/main/announcements/announcements.inc.php index cb949bfb4e..20e6674132 100644 --- a/main/announcements/announcements.inc.php +++ b/main/announcements/announcements.inc.php @@ -831,17 +831,15 @@ function store_advalvas_item($emailTitle, $newContent, $order, $to, $file_commen } -function store_advalvas_group_item($emailTitle,$newContent, $order, $to, $to_users) +function store_advalvas_group_item($emailTitle,$newContent, $order, $to, $to_users, $file_comment='') { global $_course; global $nameTools; global $_user; - global $tbl_announcement; - global $tbl_item_property; - // database definitions - $tbl_announcement = Database::get_course_table(TABLE_ANNOUNCEMENT); + $tbl_announcement = Database::get_course_table(TABLE_ANNOUNCEMENT); + $tbl_item_property = Database::get_course_table(TABLE_ITEM_PROPERTY); $newContent=stripslashes($newContent); $emailTitle = Database::escape_string(Security::remove_XSS($emailTitle)); @@ -851,7 +849,13 @@ function store_advalvas_group_item($emailTitle,$newContent, $order, $to, $to_use // store in the table announcement $sql = "INSERT INTO $tbl_announcement SET content = '$newContent', title = '$emailTitle', end_date = NOW(), display_order ='$order', session_id=".intval($_SESSION['id_session']); $result = Database::query($sql,__FILE__,__LINE__) or die (mysql_error()); + if ($result === false) { + return false; + } + + //store the attach file $last_id = Database::insert_id(); + $save_attachment = add_announcement_attachment_file($last_id, $file_comment, $_FILES['user_upload']); // store in item_property (first the groups, then the users if (!isset($to_users)) // !isset($to): when no user is selected we send it to everyone