소스 검색

[svn r14600] Added iCal export to course events

Yannick Warnier 17 년 전
부모
커밋
54dc6b4d53
2개의 변경된 파일17개의 추가작업 그리고 10개의 파일을 삭제
  1. 8 6
      main/calendar/agenda.inc.php
  2. 9 4
      main/calendar/ical_export.php

+ 8 - 6
main/calendar/agenda.inc.php

@@ -1090,14 +1090,14 @@ function get_agenda_item($id)
 {
 	global $TABLEAGENDA;
 	$id=(int)addslashes($_GET['id']);
-	$sql 			= "SELECT * FROM ".$TABLEAGENDA." WHERE id='".$id."'";
-	$result			= api_sql_query($sql,__FILE__,__LINE__);
-	$entry_to_edit 	= mysql_fetch_array($result);
-	$item['title']	= $entry_to_edit["title"];
+	$sql 					= "SELECT * FROM ".$TABLEAGENDA." WHERE id='".$id."'";
+	$result					= api_sql_query($sql,__FILE__,__LINE__);
+	$entry_to_edit 			= mysql_fetch_array($result);
+	$item['title']			= $entry_to_edit["title"];
 	$item['content']		= $entry_to_edit["content"];
-	$item['start_date']	= $entry_to_edit["start_date"];
+	$item['start_date']		= $entry_to_edit["start_date"];
 	$item['end_date']		= $entry_to_edit["end_date"];
-	$item['to']=load_edit_users(TOOL_CALENDAR_EVENT, $id);
+	$item['to']				= load_edit_users(TOOL_CALENDAR_EVENT, $id);
 	// if the item has been sent to everybody then we show the compact to form
 	if ($item['to']=="everyone")
 	{
@@ -1447,6 +1447,7 @@ function display_agenda_items()
 	$month_bar="";
 	$event_list="";
 	$counter=0;
+	$export_icon = api_get_path('WEB_IMG_PATH').'export.png';
 	while ($myrow=mysql_fetch_array($result))
 {
 	echo "<table class=\"data_table\">\n";
@@ -1544,6 +1545,7 @@ function display_agenda_items()
 	echo "<tr class='row_even'>";
 	echo "<td colspan='2'>";
 
+	echo '<a class="ical_export" href="ical_export.php?'.api_get_cidreq().'&type=public&id='.$myrow['id'].'" title="'.get_lang('ExportiCal').'"><img src="'.$export_icon.'" alt="'.get_lang('ExportiCal').'"/></a>';
 	echo '<a href="#" onclick="javascript:win_print=window.open(\'print.php?id='.$myrow['id'].'\',\'popup\',\'left=100,top=100,width=700,height=500,scrollbars=1,resizable=0\'); win_print.focus(); return false;">'.Display::return_icon('print.gif', get_lang('Print')).'</a>&nbsp;';
 
 	echo $content;

+ 9 - 4
main/calendar/ical_export.php

@@ -16,7 +16,6 @@ $this_section = SECTION_MYAGENDA;
 api_block_anonymous_users();
 require_once (api_get_path(LIBRARY_PATH).'groupmanager.lib.php');
 require_once (api_get_path(LIBRARY_PATH).'icalcreator/iCalcreator.class.php');
-require_once (api_get_path(SYS_CODE_PATH).'calendar/myagenda.inc.php');
 // setting the name of the tool
 $nameTools = get_lang('MyAgenda');
 
@@ -41,6 +40,7 @@ if(!empty($_GET['id']) && $_GET['id']==strval(intval($_GET['id'])))
 	switch($_GET['type'])
 	{
 		case 'personal':
+			require_once (api_get_path(SYS_CODE_PATH).'calendar/myagenda.inc.php');
 			$ical = new vcalendar();
 			$ai = get_personal_agenda_item($_GET['id']);
 			$ical->setConfig('unique_id',api_get_path(WEB_PATH));
@@ -67,11 +67,14 @@ if(!empty($_GET['id']) && $_GET['id']==strval(intval($_GET['id'])))
 			$vevent->setProperty('organizer',$user['mail']);
 			$vevent->setProperty('attendee',$user['mail']);
 			$ical->setComponent ($vevent); // add event to calendar
-			$err = $ical->setConfig('url',api_get_path(WEB_PATH));
-			$err = $ical->setConfig('filename',$y.$m.$d.$h.$M.$s.'-'.rand(1,1000).'.ics');
+			$ical->setConfig('url',api_get_path(WEB_PATH));
+			$ical->setConfig('filename',$y.$m.$d.$h.$M.$s.'-'.rand(1,1000).'.ics');
 			$ical->returnCalendar();
 			break;
 		case 'public':
+			$TABLEAGENDA 			= Database::get_course_table(TABLE_AGENDA);
+			$TABLE_ITEM_PROPERTY 	= Database::get_course_table(TABLE_ITEM_PROPERTY);
+			require_once (api_get_path(SYS_CODE_PATH).'calendar/agenda.inc.php');
 			$ical = new vcalendar();
 			$ai = get_agenda_item($_GET['id']);
 			$ical->setConfig('unique_id',api_get_path(WEB_PATH));
@@ -95,9 +98,11 @@ if(!empty($_GET['id']) && $_GET['id']==strval(intval($_GET['id'])))
 			//$vevent->setProperty( 'comment', 'This is a comment' );
 			$user = api_get_user_info($ai['user']);
 			$vevent->setProperty('organizer',$user['mail']);
-			$vevent->setProperty('attendee',$user['mail']);
+			//$vevent->setProperty('attendee',$user['mail']);
 			$course = api_get_course_info();
 			$vevent->setProperty( 'LOCATION', $course['name'] ); // property name - case independent
+			$ical->setConfig('url',api_get_path(WEB_PATH));
+			$ical->setConfig('filename',$y.$m.$d.$h.$M.$s.'-'.rand(1,1000).'.ics');
 			$ical->setComponent ($vevent); // add event to calendar
 			$ical->returnCalendar();
 			break;