diff --git a/main/calendar/agenda.inc.php b/main/calendar/agenda.inc.php index 72a2cfdc3e..4ec6b551eb 100644 --- a/main/calendar/agenda.inc.php +++ b/main/calendar/agenda.inc.php @@ -1,4 +1,4 @@ -'; + // attachment list + $attachment_list=get_attachment($myrow['id']); + + if (!empty($attachment_list)) { + + $realname=$attachment_list['path']; + $user_filename=$attachment_list['filename']; + $full_file_name = 'download.php?file='.$realname; + echo Display::return_icon('attachment.gif',get_lang('Attachment')); + echo ' '.$user_filename.' '; + echo ''.$attachment_list['comment'].'
'; + + } + + echo ''; + /*-------------------------------------------------- display: the added resources @@ -1740,7 +1756,6 @@ function display_agenda_items() $event_list.=$myrow['id'].','; $counter++; - /*-------------------------------------------------- display: jump-to-top icon --------------------------------------------------*/ @@ -1768,6 +1783,25 @@ function display_agenda_items() ""; } +/** + * Show a list with all the attachments according to the post's id + * @param the post's id + * @return array with the post info + * @author Christian Fasanando + * @version November 2008, dokeos 1.8.6 + */ + +function get_attachment($agenda_id) { + $agenda_table_attachment = Database::get_course_table(TABLE_AGENDA_ATTACHMENT); + $row=array(); + $sql = 'SELECT path, filename,comment FROM '. $agenda_table_attachment.' WHERE agenda_id = '.(int)$agenda_id.''; + $result=api_sql_query($sql, __FILE__, __LINE__); + if (Database::num_rows($result)!=0) { + $row=Database::fetch_array($result); + } + return $row; +} + /** * Displays only 1 agenda item. This is used when an agenda item is added to the learning path. * @author Patrick Cool , Ghent University @@ -1996,7 +2030,6 @@ function show_add_form($id = '') } else { - // we are coming from the resource linker so there might already have been some information in the form. // When we clicked on the button to add resources we stored every form information into a session and now we // are doing the opposite thing: getting the information out of the session and putting it into variables to @@ -2018,8 +2051,7 @@ function show_add_form($id = '') $to=$form_elements['to']; $repeat = $form_elements['repeat']; } - - + // switching the send to all/send to groups/send to users if ($_POST['To']) { @@ -2041,7 +2073,6 @@ function show_add_form($id = '') $repeat = !empty($_POST['repeat'])?true:false; } - // if the id is set then we are editing an agenda item if (is_int($id)) { @@ -2067,7 +2098,6 @@ function show_add_form($id = '') // we start a completely new item, we do not come from the resource linker if ($_GET['originalresource']!=="no" and $_GET['action']=="add") { - $_SESSION["formelements"]=null; unset_session_resources(); } @@ -2105,7 +2135,6 @@ function show_add_form($id = '') } else { - ?> @@ -2121,7 +2150,7 @@ function show_add_form($id = '') } echo ''.get_lang('ModifyRecipientList').''; show_to_form($to); - if (isset($_GET['id']) && $to!='everyone'){ + if (isset($_GET['id']) && $to!='everyone') { echo ''; } ?> @@ -2404,20 +2433,20 @@ function show_add_form($id = '') //for images $oFCKeditor->Config['ImageBrowserURL'] = $oFCKeditor->BasePath . "editor/filemanager/browser/default/browser.html?Type=Images&Connector=connectors/php/connector.php&ServerPath=$upload_path"; - $oFCKeditor->Config['ImageUploadURL'] = $oFCKeditor->BasePath . "editor/filemanager/upload/php/upload.php?Type=Images&ServerPath=$upload_path" ; + $oFCKeditor->Config['ImageUploadURL'] = $oFCKeditor->BasePath . "editor/filemanager/upload/php/upload.php?Type=Images&ServerPath=$upload_path" ; //for flash $oFCKeditor->Config['FlashBrowserURL'] = $oFCKeditor->BasePath . "editor/filemanager/browser/default/browser.html?Type=Flash&Connector=connectors/php/connector.php&ServerPath=$upload_path"; - $oFCKeditor->Config['FlashUploadURL'] = $oFCKeditor->BasePath . "editor/filemanager/upload/php/upload.php?Type=Flash&ServerPath=$upload_path" ; - $oFCKeditor->Config['MediaBrowserURL'] = $oFCKeditor->Config['FlashBrowserURL']; + $oFCKeditor->Config['FlashUploadURL'] = $oFCKeditor->BasePath . "editor/filemanager/upload/php/upload.php?Type=Flash&ServerPath=$upload_path" ; + $oFCKeditor->Config['MediaBrowserURL'] = $oFCKeditor->Config['FlashBrowserURL']; //for MP3 - $oFCKeditor->Config['MP3BrowserURL'] = $oFCKeditor->BasePath . "editor/filemanager/browser/default/browser.html?Type=MP3&Connector=connectors/php/connector.php&ServerPath=$upload_path"; - $oFCKeditor->Config['MP3UploadURL'] = $oFCKeditor->BasePath . "editor/filemanager/upload/php/upload.php?Type=MP3&ServerPath=$upload_path" ; + $oFCKeditor->Config['MP3BrowserURL'] = $oFCKeditor->BasePath . "editor/filemanager/browser/default/browser.html?Type=MP3&Connector=connectors/php/connector.php&ServerPath=$upload_path"; + $oFCKeditor->Config['MP3UploadURL'] = $oFCKeditor->BasePath . "editor/filemanager/upload/php/upload.php?Type=MP3&ServerPath=$upload_path" ; //for Videos $oFCKeditor->Config['VideoBrowserURL'] = $oFCKeditor->BasePath . "editor/filemanager/browser/default/browser.html?Type=Video&Connector=connectors/php/connector.php&ServerPath=$upload_path"; - $oFCKeditor->Config['VideoUploadURL'] = $oFCKeditor->BasePath . "editor/filemanager/upload/php/upload.php?Type=Video&ServerPath=$upload_path" ; + $oFCKeditor->Config['VideoUploadURL'] = $oFCKeditor->BasePath . "editor/filemanager/upload/php/upload.php?Type=Video&ServerPath=$upload_path" ; //link $oFCKeditor->Config['LinkBrowserURL'] = $oFCKeditor->BasePath . "editor/filemanager/browser/default/browser.html?Type=Images&Connector=connectors/php/connector.php&ServerPath=$upload_path"; @@ -2450,8 +2479,20 @@ function show_add_form($id = '') echo "\t\t\n\t\n"; /* END ADDED BY UGENT, Patrick Cool, march 2004 */ if(empty($id)) //only show repeat fields when adding the first time - { + { ?> +


+ + + + + + + +
+ + + /> @@ -3830,11 +3871,12 @@ function add_year($timestamp,$num=1) * @param int Parent id (optional) * @return int The new item's DB ID */ -function agenda_add_item($course_info, $title, $content, $db_start_date, $db_end_date,$group_id,$id_user,$to=array(), $parent_id=null) +function agenda_add_item($course_info, $title, $content, $db_start_date, $db_end_date,$group_id,$id_user,$to=array(), $parent_id=null,$file_comment) { + global $_course; $user_id = api_get_user_id(); $t_agenda = Database::get_course_table(TABLE_AGENDA,$course_info['dbName']); - + $agenda_table_attachment = Database::get_course_table(TABLE_AGENDA_ATTACHMENT); // some filtering of the input data $title = Database::escape_string($title); // no html allowed in the title $content = Database::escape_string($content); @@ -3849,6 +3891,46 @@ function agenda_add_item($course_info, $title, $content, $db_start_date, $db_end $result = api_sql_query($sql,__FILE__,__LINE__) or die (Database::error()); $last_id=Database::insert_id(); + + // Storing the attachments + + if(!empty($_FILES['user_upload']['name'])) { + $upload_ok = process_uploaded_file($_FILES['user_upload']); + } + + if ($upload_ok) { + $courseDir = $_course['path'].'/upload/calendar'; + $sys_course_path = api_get_path(SYS_COURSE_PATH); + $updir = $sys_course_path.$courseDir; + + // Try to add an extension to the file if it hasn't one + $new_file_name = add_ext_on_mime(stripslashes($_FILES['user_upload']['name']), $_FILES['user_upload']['type']); + // user's file name + $file_name =$_FILES['user_upload']['name']; + + if (!filter_extension($new_file_name)) { + Display :: display_error_message(get_lang('UplUnableToSaveFileFilteredExtension')); + } else { + $new_file_name = uniqid(''); + $new_path=$updir.'/'.$new_file_name; + $result= @move_uploaded_file($_FILES['user_upload']['tmp_name'], $new_path); + $safe_file_comment= Database::escape_string($file_comment); + $safe_file_name = Database::escape_string($file_name); + $safe_new_file_name = Database::escape_string($new_file_name); + // Storing the attachments if any + if ($result) { + $sql='INSERT INTO '.$agenda_table_attachment.'(filename,comment, path,agenda_id,size) '. + "VALUES ( '".$safe_file_name."', '".$safe_file_comment."', '".$safe_new_file_name."' , '".$last_id."', '".$_FILES['user_upload']['size']."' )"; + $result=api_sql_query($sql, __LINE__, __FILE__); + $message.=' / '.get_lang('FileUploadSucces').'
'; + + $last_id_file=Database::insert_id(); + api_item_property_update($_course, 'calendar_event_attachment', $last_id_file ,'AgendaAttachmentAdded', api_get_user_id()); + + } + } + } + // store in last_tooledit (first the groups, then the users $done = false; @@ -3894,7 +3976,7 @@ function agenda_add_item($course_info, $title, $content, $db_start_date, $db_end * @param int User ID * @return boolean False if error, True otherwise */ -function agenda_add_repeat_item($course_info,$orig_id,$type,$end,$orig_dest,$id_group=null,$id_user=null) +function agenda_add_repeat_item($course_info,$orig_id,$type,$end,$orig_dest,$id_group=null,$id_user=null,$file_comment) { $t_agenda = Database::get_course_table(TABLE_AGENDA,$course_info['dbName']); $t_agenda_r = Database::get_course_table(TABLE_AGENDA_REPEAT,$course_info['dbName']); @@ -3950,20 +4032,20 @@ function agenda_add_repeat_item($course_info,$orig_id,$type,$end,$orig_dest,$id_ case 'daily': for($i = $orig_start + 86400; ($i <= $end); $i += 86400) { - $res = agenda_add_item($course_info, $orig_title, $orig_content, date('Y-m-d H:i:s', $i), date('Y-m-d H:i:s', $i+$diff), $id_group, $id_user, $orig_dest, $orig_id); + $res = agenda_add_item($course_info, $orig_title, $orig_content, date('Y-m-d H:i:s', $i), date('Y-m-d H:i:s', $i+$diff), $id_group, $id_user, $orig_dest, $orig_id,$file_comment); } break; case 'weekly': for($i = $orig_start + 604800; ($i <= $end); $i += 604800) { - $res = agenda_add_item($course_info, $orig_title, $orig_content, date('Y-m-d H:i:s', $i), date('Y-m-d H:i:s', $i+$diff), $id_group, $id_user, $orig_dest, $orig_id); + $res = agenda_add_item($course_info, $orig_title, $orig_content, date('Y-m-d H:i:s', $i), date('Y-m-d H:i:s', $i+$diff), $id_group, $id_user, $orig_dest, $orig_id,$file_comment); } break; case 'monthlyByDate': $next_start = add_month($orig_start); while($next_start <= $end) { - $res = agenda_add_item($course_info, $orig_title, $orig_content, date('Y-m-d H:i:s', $next_start), date('Y-m-d H:i:s', $next_start+$diff), $id_group, $id_user, $orig_dest, $orig_id); + $res = agenda_add_item($course_info, $orig_title, $orig_content, date('Y-m-d H:i:s', $next_start), date('Y-m-d H:i:s', $next_start+$diff), $id_group, $id_user, $orig_dest, $orig_id,$file_comment); $next_start = add_month($next_start); } break; @@ -3977,7 +4059,7 @@ function agenda_add_repeat_item($course_info,$orig_id,$type,$end,$orig_dest,$id_ $next_start = add_year($orig_start); while($next_start <= $end) { - $res = agenda_add_item($course_info, $orig_title, $orig_content, date('Y-m-d H:i:s', $next_start), date('Y-m-d H:i:s', $next_start+$diff), $id_group, $id_user,$orig_dest, $orig_id); + $res = agenda_add_item($course_info, $orig_title, $orig_content, date('Y-m-d H:i:s', $next_start), date('Y-m-d H:i:s', $next_start+$diff), $id_group, $id_user,$orig_dest, $orig_id,$file_comment); $next_start = add_year($next_start); } break; diff --git a/main/calendar/agenda.php b/main/calendar/agenda.php index 09c56a2574..655f8d747f 100644 --- a/main/calendar/agenda.php +++ b/main/calendar/agenda.php @@ -1,4 +1,4 @@ -$_POST['fday'], 'month'=>$_POST['fmonth'], 'year'=>$_POST['fyear'], 'hour'=>$_POST['fhour'], 'minutes'=>$_POST['fminute'], @@ -183,7 +185,7 @@ if (empty($_GET['origin']) or $_GET['origin'] != 'learnpath') else { echo ""; - } +} /* ============================================================================== TRACKING @@ -293,7 +295,6 @@ $fck_attribute['ToolbarSet'] = 'Middle'; $fck_attribute['Config']['CreateDocumentDir'] = api_get_path('WEB_COURSE_PATH').$_course['path'].'/document/'; $fck_attribute['Config']['CreateDocumentWebDir'] = api_get_path('WEB_COURSE_PATH').$_course['path'].'/document/'; - if(isset($_SESSION['_course']) && $_SESSION['_course']['path']!='') { $upload_path = api_get_path(REL_COURSE_PATH).$_SESSION['_course']['path'].'/document/'; @@ -302,11 +303,6 @@ else { $upload_path = api_get_path(REL_PATH).'main/default_course_document/'; } - - - - - // THE RIGHT PART echo ""; @@ -327,14 +323,14 @@ if (api_is_allowed_to_edit(false,true) OR (api_get_course_setting('allow_user_ed $course_info = api_get_course_info(); $event_start = (int) $_POST['fyear'].'-'.(int) $_POST['fmonth'].'-'.(int) $_POST['fday'].' '.(int) $_POST['fhour'].':'.(int) $_POST['fminute'].':00'; $event_stop = (int) $_POST['end_fyear'].'-'.(int) $_POST['end_fmonth'].'-'.(int) $_POST['end_fday'].' '.(int) $_POST['end_fhour'].':'.(int) $_POST['end_fminute'].':00'; - $id = agenda_add_item($course_info,$_POST['title'],$_POST['content'],$event_start,$event_stop,$_REQUEST['group'],$_REQUEST['user'],$_POST['selectedform']); + $id = agenda_add_item($course_info,$_POST['title'],$_POST['content'],$event_start,$event_stop,$_REQUEST['group'],$_REQUEST['user'],$_POST['selectedform'],false,$_POST['file_comment']); if(!empty($_POST['repeat'])) { $end_y = intval($_POST['repeat_end_year']); $end_m = intval($_POST['repeat_end_month']); $end_d = intval($_POST['repeat_end_day']); $end = mktime(23, 59, 59, $end_m, $end_d, $end_y); - $res = agenda_add_repeat_item($course_info,$id,$_POST['repeat_type'],$end,null,$_REQUEST['group'],$_REQUEST['user']); + $res = agenda_add_repeat_item($course_info,$id,$_POST['repeat_type'],$end,null,$_REQUEST['group'],$_REQUEST['user'],$_POST['file_comment']); } display_agenda_items(); } diff --git a/main/calendar/download.php b/main/calendar/download.php new file mode 100644 index 0000000000..4895643d9f --- /dev/null +++ b/main/calendar/download.php @@ -0,0 +1,96 @@ + \ No newline at end of file diff --git a/main/inc/lib/add_course.lib.inc.php b/main/inc/lib/add_course.lib.inc.php index 0f74749c5f..f41f8205a9 100644 --- a/main/inc/lib/add_course.lib.inc.php +++ b/main/inc/lib/add_course.lib.inc.php @@ -236,6 +236,8 @@ function prepare_course_repository($courseRepository, $courseId) mkdir(api_get_path(SYS_COURSE_PATH).$courseRepository . "/upload/blog", $perm); mkdir(api_get_path(SYS_COURSE_PATH).$courseRepository . "/upload/learning_path", $perm); mkdir(api_get_path(SYS_COURSE_PATH).$courseRepository . "/upload/learning_path/images", $perm); + mkdir(api_get_path(SYS_COURSE_PATH).$courseRepository . "/upload/calendar", $perm); + mkdir(api_get_path(SYS_COURSE_PATH).$courseRepository . "/upload/calendar/images", $perm); mkdir(api_get_path(SYS_COURSE_PATH).$courseRepository . "/work", $perm); //create .htaccess in dropbox @@ -298,6 +300,7 @@ function update_Db_course($courseDbName) $TABLETOOLAGENDA = $courseDbName . 'calendar_event'; $TABLETOOLAGENDAREPEAT = $courseDbName . 'calendar_event_repeat'; $TABLETOOLAGENDAREPEATNOT = $courseDbName . 'calendar_event_repeat_not'; + $TABLETOOLAGENDAATTACHMENT = $courseDbName . 'calendar_event_attachment'; // Announcements $TABLETOOLANNOUNCEMENTS = $courseDbName . 'announcement'; @@ -762,6 +765,18 @@ function update_Db_course($courseDbName) )"; api_sql_query($sql,__FILE__,__LINE__); + + // Agenda Attachment + $sql = "CREATE TABLE `".$TABLETOOLAGENDAATTACHMENT."` ( + id int NOT NULL auto_increment, + path varchar(255) NOT NULL, + comment text, + size int NOT NULL default 0, + agenda_id int NOT NULL, + filename varchar(255) NOT NULL, + PRIMARY KEY (id) + )"; + api_sql_query($sql, __FILE__, __LINE__); /* ----------------------------------------------------------- Document tool diff --git a/main/inc/lib/database.lib.php b/main/inc/lib/database.lib.php index 2d97730690..bb03f604f5 100644 --- a/main/inc/lib/database.lib.php +++ b/main/inc/lib/database.lib.php @@ -1,4 +1,4 @@ - learning_path > images if(!is_dir($currentCourseRepositorySys."upload/learning_path/images")){ mkdir($currentCourseRepositorySys."upload/learning_path/images",$perm); - } + } + + //upload > calendar + if(!is_dir($currentCourseRepositorySys."upload/calendar")){ + mkdir($currentCourseRepositorySys."upload/calendar",$perm); + } + + //upload > calendar > images + if(!is_dir($currentCourseRepositorySys."upload/calendar/images")){ + mkdir($currentCourseRepositorySys."upload/calendar/images",$perm); + } } } else