diff --git a/main/calendar/agenda.inc.php b/main/calendar/agenda.inc.php index 7577dfa253..0b6178a504 100644 --- a/main/calendar/agenda.inc.php +++ b/main/calendar/agenda.inc.php @@ -23,11 +23,11 @@ */ // the variables for the days and the months // Defining the shorts for the days -$DaysShort = api_get_week_days_short(); +$DaysShort = api_get_week_days_short(); // Defining the days of the week to allow translation of the days -$DaysLong = api_get_week_days_long(); +$DaysLong = api_get_week_days_long(); // Defining the months of the year to allow translation of the months -$MonthsLong = api_get_months_long(); +$MonthsLong = api_get_months_long(); /* ============================================================================== @@ -66,8 +66,8 @@ function get_calendar_items($month, $year) $repeats = array(); $session_condition = intval($_SESSION['id_session'])==0 ? '' : ' AND agenda.session_id IN (0,'.intval($_SESSION['id_session']).') '; - - + + /*-------------------------------------------------- CONSTRUCT THE SQL STATEMENT --------------------------------------------------*/ @@ -98,7 +98,7 @@ function get_calendar_items($month, $year) $start = time(); $stop = mktime(0,0,0,1,1,2038);//by default, set year to maximum for mktime() } - + // by default we use the id of the current user. The course administrator can see the agenda of other users by using the user / group filter $user_id=$_user['user_id']; if ($_SESSION['user']!==null) @@ -250,7 +250,7 @@ function get_calendar_items($month, $year) //echo "
".$sql."
"; $result=Database::query($sql,__FILE__,__LINE__) or die(Database::error()); - + ///////////////// $data=array(); while ($row=Database::fetch_array($result)) @@ -322,21 +322,21 @@ function display_minimonthcalendar($agendaitems, $month, $year, $monthName) { $month_curday = array(); $items_curday = $agendaitems[$curday][$curday]; - + foreach ($items_curday as $item_curday) { $start_date_item = $item_curday['start_date']; $month_item = (int)substr($start_date_item,5,2); if($month == $month_item) { $month_curday[] = $item_curday['start_date']; } - } - - if (!empty($month_curday)) { + } + + if (!empty($month_curday)) { echo "".$dayheader.""; } else { echo $dayheader; } - } + } else { echo $dayheader; @@ -406,7 +406,7 @@ function display_monthcalendar($month, $year) $today = getdate(); while ($curday <=$numberofdays[$month]) { - echo "\n"; + echo "\n"; for ($ii=0; $ii<7; $ii++) { if (($curday == -1)&&($ii==$startdayofweek)) @@ -418,7 +418,7 @@ function display_monthcalendar($month, $year) $bgcolor = $ii<5 ? "class=\"row_odd\"" : "class=\"row_even\""; $dayheader = "$curday"; - + if (key_exists($curday,$data)) { $dayheader="".$curday.""; foreach ($data[$curday] as $key=>$agenda_item) @@ -437,7 +437,7 @@ function display_monthcalendar($month, $year) //echo $agendaitems['title']; } - } + } } if (($curday==$today['mday'])&&($year ==$today['year'])&&($month == $today['mon'])) @@ -509,47 +509,47 @@ function move(fbox, tbox) fLength++; } } - + //arrFbox.sort(); - //arrTbox.sort() + //arrTbox.sort() var arrFboxGroup = new Array(); var arrFboxUser = new Array(); - var prefix_x; - + var prefix_x; + for (x = 0; x < arrFbox.length; x++) { - prefix_x = arrFbox[x].substring(0,2); + prefix_x = arrFbox[x].substring(0,2); if (prefix_x == 'G:') { - arrFboxGroup.push(arrFbox[x]); + arrFboxGroup.push(arrFbox[x]); } else { - arrFboxUser.push(arrFbox[x]); - } - } - + arrFboxUser.push(arrFbox[x]); + } + } + arrFboxGroup.sort(); arrFboxUser.sort(); - arrFbox = arrFboxGroup.concat(arrFboxUser); - + arrFbox = arrFboxGroup.concat(arrFboxUser); + var arrTboxGroup = new Array(); - var arrTboxUser = new Array(); - var prefix_y; - + var arrTboxUser = new Array(); + var prefix_y; + for (y = 0; y < arrTbox.length; y++) { - prefix_y = arrTbox[y].substring(0,2); + prefix_y = arrTbox[y].substring(0,2); if (prefix_y == 'G:') { arrTboxGroup.push(arrTbox[y]); } else { arrTboxUser.push(arrTbox[y]); - } - } - + } + } + arrTboxGroup.sort(); arrTboxUser.sort(); arrTbox = arrTboxGroup.concat(arrTboxUser); fbox.length = 0; tbox.length = 0; - + var c; for(c = 0; c < arrFbox.length; c++) { @@ -569,7 +569,7 @@ function move(fbox, tbox) function checkDate(month, day, year) { - var monthLength = + var monthLength = new Array(31,28,31,30,31,30,31,31,30,31,30,31); if (!day || !month || !year) @@ -584,14 +584,14 @@ function checkDate(month, day, year) if (day > monthLength[month-1]) return false; - + return true; -} +} -function mktime() -{ +function mktime() +{ var no, ma = 0, mb = 0, i = 0, d = new Date(), argv = arguments, argc = argv.length; - d.setHours(0,0,0); d.setDate(1); d.setMonth(1); d.setYear(1972); + d.setHours(0,0,0); d.setDate(1); d.setMonth(1); d.setYear(1972); var dateManip = { 0: function(tt){ return d.setHours(tt); }, 1: function(tt){ return d.setMinutes(tt); }, @@ -599,7 +599,7 @@ function mktime() 3: function(tt){ set = d.setMonth(parseInt(tt)-1); ma = d.getFullYear() - 1972; return set; }, 4: function(tt){ return d.setDate(tt+mb); }, 5: function(tt){ return d.setYear(tt+ma); } - }; + }; for( i = 0; i < argc; i++ ){ no = parseInt(argv[i]*1); if (isNaN(no)) { @@ -611,10 +611,10 @@ function mktime() return false; } } - } + } return Math.floor(d.getTime()/1000); -} - +} + function validate() { var f = document.new_calendar_item; @@ -623,52 +623,52 @@ function validate() } function selectAll(cbList,bSelect,showwarning) -{ +{ var start_day = document.new_calendar_item.fday.value; var start_month = document.new_calendar_item.fmonth.value; - var start_year = document.new_calendar_item.fyear.value; - var start_hour = document.new_calendar_item.fhour.value; + var start_year = document.new_calendar_item.fyear.value; + var start_hour = document.new_calendar_item.fhour.value; var start_minute = document.new_calendar_item.fminute.value; var start_date = mktime(start_hour,start_minute,0,start_month,start_day,start_year) - + var ends_day = document.new_calendar_item.end_fday.value; var ends_month = document.new_calendar_item.end_fmonth.value; - var ends_year = document.new_calendar_item.end_fyear.value; - var ends_hour = document.new_calendar_item.end_fhour.value; + var ends_year = document.new_calendar_item.end_fyear.value; + var ends_hour = document.new_calendar_item.end_fhour.value; var ends_minute = document.new_calendar_item.end_fminute.value; - var ends_date = mktime(ends_hour,ends_minute,0,ends_month,ends_day,ends_year) - + var ends_date = mktime(ends_hour,ends_minute,0,ends_month,ends_day,ends_year) + msg_err1 = document.getElementById(\"err_date\"); msg_err2 = document.getElementById(\"err_start_date\"); msg_err3 = document.getElementById(\"err_end_date\"); msg_err4 = document.getElementById(\"err_title\"); - - if (start_date > ends_date) { - msg_err1.style.display =\"block\"; + + if (start_date > ends_date) { + msg_err1.style.display =\"block\"; msg_err1.innerHTML=\"".get_lang('EndDateCannotBeBeforeTheStartDate')."\"; - msg_err2.innerHTML=\"\";msg_err3.innerHTML=\"\"; + msg_err2.innerHTML=\"\";msg_err3.innerHTML=\"\"; } else if (checkDate(start_month,start_day,start_year) == false) { msg_err2.style.display =\"block\"; msg_err2.innerHTML=\"".get_lang('InvalidDate')."\"; - msg_err1.innerHTML=\"\";msg_err3.innerHTML=\"\"; + msg_err1.innerHTML=\"\";msg_err3.innerHTML=\"\"; } else if (checkDate(ends_month,ends_day,ends_year) == false) { msg_err3.style.display =\"block\"; msg_err3.innerHTML=\"".get_lang('InvalidDate')."\"; - msg_err1.innerHTML=\"\";msg_err2.innerHTML=\"\"; + msg_err1.innerHTML=\"\";msg_err2.innerHTML=\"\"; } else if (document.new_calendar_item.title.value == '') { msg_err4.style.display =\"block\"; msg_err4.innerHTML=\"".get_lang('FieldRequired')."\"; - msg_err1.innerHTML=\"\";msg_err2.innerHTML=\"\";msg_err3.innerHTML=\"\"; + msg_err1.innerHTML=\"\";msg_err2.innerHTML=\"\";msg_err3.innerHTML=\"\"; } else { if (cbList.length < 1) { if (!confirm(\"".get_lang('Send2All')."\")) { - return false; - } - } + return false; + } + } for (var i=0; i\n"; echo "\t\n"; // the form containing all the groups and all the users of the course @@ -813,9 +813,9 @@ function show_to_form($to_already_selected) echo "\t\t", - + "\n\t\t

 

", - + "\n\t\t"; @@ -837,7 +837,7 @@ function show_to_form($to_already_selected) function construct_not_selected_select_form($group_list=null, $user_list=null,$to_already_selected=array()) { echo "\t\t\n"; } @@ -891,37 +891,37 @@ function construct_selected_select_form($group_list=null, $user_list=null,$to_al // we load all the groups and all the users into a reference array that we use to search the name of the group / user $ref_array_groups=get_course_groups(); - - $ref_array_users=get_course_users(); + + $ref_array_users=get_course_users(); // we construct the form of the already selected groups / users echo "\t\t"; + + echo ""; + + echo ""; } @@ -1315,50 +1315,50 @@ function show_user_filter_form() */ function show_user_group_filter_form() { - echo "\n"; + // Groups $option = "\n\t"; - $group_list=get_course_groups(); + $group_list=get_course_groups(); //echo "\n\t"; - + $group_available_to_access =array(); - - if(!empty($group_list)){ + + if(!empty($group_list)){ foreach($group_list as $this_group) { - // echo ""; + // echo ""; $has_access = GroupManager::user_has_access(api_get_user_id(),$this_group['id'],GROUP_TOOL_CALENDAR); $result = GroupManager::get_group_properties($this_group['id']); - + if ($result['calendar_state']!='0') { $group_available_to_access[]=$this_group['id']; - } - - // lastedit - if ($has_access || $result['calendar_state']=='1') { + } + + // lastedit + if ($has_access || $result['calendar_state']=='1') { $option.= "\n\t\t"; + } } } - + $all = "\n\t"; $option = $all.$option; - - $option.= "\n\t"; - echo $option; - + + $option.= "\n\t"; + echo $option; + global $_course; - + // Users echo "\n\t"; $user_list=get_course_users(); foreach($user_list as $this_user) { echo "\n\t\t"; - } + echo ">".api_get_person_name($this_user['firstName'], $this_user['lastName']).""; + } echo "\n\t"; echo ""; } @@ -1375,7 +1375,7 @@ function load_edit_users($tool, $id) $tool=Database::escape_string($tool); $id=Database::escape_string($id); $TABLE_ITEM_PROPERTY = Database::get_course_table(TABLE_ITEM_PROPERTY); - + $sql="SELECT * FROM $TABLE_ITEM_PROPERTY WHERE tool='$tool' AND ref='$id'"; $result=Database::query($sql,__FILE__,__LINE__) or die (Database::error()); while ($row=Database::fetch_array($result)) @@ -1610,7 +1610,7 @@ function store_edited_agenda_item($id_attach,$file_comment) // step 3: update the attachments (=delete all and add those in the session update_added_resources("Agenda", $id); - // return the message; + // return the message; Display::display_confirmation_message(get_lang("EditSuccess")); } @@ -1689,7 +1689,7 @@ function delete_agenda_item($id) //resetting the $id; $id=null; - // displaying the result message in the yellow box + // displaying the result message in the yellow box Display::display_confirmation_message(get_lang("AgendaDeleteSuccess")); } // if (isset($id)&&$id&&isset($action)&&$action=="delete") } // if ($is_allowed_to_edit) @@ -1713,7 +1713,7 @@ function showhide_agenda_item($id) if (isset($_GET['id'])&&$_GET['id']&&isset($_GET['action'])&&$_GET['action']=="showhide") { $id=(int)addslashes($_GET['id']); - change_visibility($nameTools,$id); + change_visibility($nameTools,$id); Display::display_confirmation_message(get_lang("VisibilityChanged")); } } @@ -1801,22 +1801,22 @@ function display_agenda_items() if (!empty($_SESSION['user'])) { $group_memberships=GroupManager::get_group_ids($_course['dbName'],$_SESSION['user']); - + $show_user =true; $new_group_memberships=array(); foreach($group_memberships as $id) { - // did i have access to the same + // did i have access to the same $has_access = GroupManager::user_has_access(api_get_user_id(),$id,GROUP_TOOL_CALENDAR); $result = GroupManager::get_group_properties($id); - - if ($has_access && $result['calendar_state']!='0' ) - { - $new_group_memberships[]=$id; - } + + if ($has_access && $result['calendar_state']!='0' ) + { + $new_group_memberships[]=$id; + } } $group_memberships = $new_group_memberships; - + if (is_array($group_memberships) && count($group_memberships)>0) { $sql="SELECT @@ -1830,7 +1830,7 @@ function display_agenda_items() ORDER BY start_date ".$_SESSION['sort']; } else - { + { $sql="SELECT agenda.*, toolitemproperties.* FROM ".$TABLEAGENDA." agenda, ".$TABLE_ITEM_PROPERTY." toolitemproperties @@ -1846,19 +1846,19 @@ function display_agenda_items() // => see only the messages of this specific group elseif (!empty($_SESSION['group'])) { - - if (!empty($group_id)) { - $result = GroupManager::get_group_properties($group_id); + + if (!empty($group_id)) { + $result = GroupManager::get_group_properties($group_id); $has_access = GroupManager::user_has_access(api_get_user_id(),$group_id,GROUP_TOOL_CALENDAR); //echo '
';print_R($result);
-
-				// lastedit
+
+				// lastedit
 				if (!$has_access || $result['calendar_state']=='0' )
-				{
-					$group_id=0;
-				}
-			}
-
+				{
+					$group_id=0;
+				}
+			}
+
 			$sql="SELECT
 				agenda.*, toolitemproperties.*
 				FROM ".$TABLEAGENDA." agenda, ".$TABLE_ITEM_PROPERTY." toolitemproperties
@@ -1893,7 +1893,7 @@ function display_agenda_items()
 			{
 				// A.3.b.1 you are a course admin without user or group filter and WITHOUT studentview (= the normal course admin view)
 				// 	=> see all the messages of all the users and groups with editing possibilities
-
+
 				 if (api_is_course_admin())
 				 {
 					 $sql="SELECT
@@ -1911,7 +1911,7 @@ function display_agenda_items()
 				 	// A.3.b.2 you are a student with no group filter possibly showall
 				 	//when showing all the events we do not show the group events
 				 	//todo showing ALL events including the groups events that are available
-
+
 				 	$sql="SELECT
 						agenda.*, toolitemproperties.*
 						FROM ".$TABLEAGENDA." agenda, ".$TABLE_ITEM_PROPERTY." toolitemproperties
@@ -1921,17 +1921,17 @@ function display_agenda_items()
 						$session_condition
 						GROUP BY toolitemproperties.ref
 						ORDER BY start_date ".$_SESSION['sort'];
-
-
+
+
 					/*
 				 	if (is_array($group_memberships) && count($group_memberships)>0)
-				 	{
+				 	{
 				 		echo $sql="SELECT
 						agenda.*, toolitemproperties.*
 						FROM ".$TABLEAGENDA." agenda, ".$TABLE_ITEM_PROPERTY." toolitemproperties
 						WHERE agenda.id = toolitemproperties.ref  ".$show_all_current."
 						AND toolitemproperties.tool='".TOOL_CALENDAR_EVENT."'
-						AND toolitemproperties.visibility='1' AND toolitemproperties.to_group_id IN (0, ".implode(", ", $group_memberships).")
+						AND toolitemproperties.visibility='1' AND toolitemproperties.to_group_id IN (0, ".implode(", ", $group_memberships).")
 						$session_condition
 						GROUP BY toolitemproperties.ref
 						ORDER BY start_date ".$_SESSION['sort'];
@@ -1949,7 +1949,7 @@ function display_agenda_items()
 						ORDER BY start_date ".$_SESSION['sort'];
 				 	}
 				 	*/
-
+
 				 }
 			}
 		}
@@ -2199,8 +2199,8 @@ function display_agenda_items()
 				echo ' "> '.$user_filename.' ';
 				echo ''.$attachment_list['comment'].'';
 				if (api_is_allowed_to_edit()) {
-					echo '  '.Display::return_icon('delete.gif',get_lang('Delete')).'
'; - } + echo '  '.Display::return_icon('delete.gif',get_lang('Delete')).'
'; + } } @@ -2298,7 +2298,7 @@ function display_one_agenda_item($agenda_id) CONSTRUCT THE SQL STATEMENT --------------------------------------------------*/ $agenda_id = Database::escape_string($agenda_id); - + $sql="SELECT agenda.*, toolitemproperties.* FROM ".$TABLEAGENDA." agenda, ".$TABLE_ITEM_PROPERTY." toolitemproperties WHERE agenda.id = toolitemproperties.ref @@ -2600,7 +2600,7 @@ function show_add_form($id = '') { $form_title = get_lang('ModifyCalendarItem'); } - else + else { $form_title = get_lang('AddCalendarItem'); } @@ -2697,7 +2697,7 @@ function show_add_form($id = '') echo "\t\t\t\t\n"; } ?> - 'vertical-align: middle;')); ?> + 'vertical-align: middle;')); ?>    - + - '; @@ -2740,7 +2740,7 @@ function show_add_form($id = '') '.get_lang('EndDate').'
- '; + '; ?> + - + -
'; - + // the title of the agenda item echo '
*'.get_lang('ItemTitle').'
- + @@ -2860,7 +2860,7 @@ function show_add_form($id = '') echo '
'; - // the added resources + // the added resources /*echo '
'.get_lang('AddedResources').' @@ -2876,7 +2876,7 @@ function show_add_form($id = '') echo '
'; */ - + // File attachment echo '
@@ -2982,8 +2982,8 @@ function show_add_form($id = '') echo '
'; }//only show repeat fields if adding, not if editing - - + + // the submit button for storing the calendar item echo '
@@ -2994,7 +2994,7 @@ function show_add_form($id = '') $text=get_lang('ModifyEvent'); } else { $class='add'; - $text=get_lang('AgendaAdd'); + $text=get_lang('AgendaAdd'); } echo ''; echo '
@@ -3011,8 +3011,8 @@ function get_agendaitems($month, $year) $items = array (); $month = Database::escape_string($month); - $year = Database::escape_string($year); - + $year = Database::escape_string($year); + //databases of the courses $TABLEAGENDA = Database :: get_course_table(TABLE_AGENDA); $TABLE_ITEMPROPERTY = Database :: get_course_table(TABLE_ITEM_PROPERTY); @@ -3021,7 +3021,7 @@ function get_agendaitems($month, $year) // if the user is administrator of that course we show all the agenda items if (api_is_allowed_to_edit(false,true)) { //echo "course admin"; - + $sqlquery = "SELECT DISTINCT agenda.*, item_property.* FROM ".$TABLEAGENDA." agenda, @@ -3073,13 +3073,13 @@ function get_agendaitems($month, $year) global $_configuration; $root_url = $_configuration['root_web']; if ($_configuration['multiple_access_urls']==true) { - $access_url_id = api_get_current_access_url_id(); + $access_url_id = api_get_current_access_url_id(); if ($access_url_id != -1 ){ - $url = api_get_access_url($access_url_id); + $url = api_get_access_url($access_url_id); $root_url = $url['url']; - } + } } - + while ($item = Database::fetch_array($result)) { $agendaday = date('j',strtotime($item['start_date'])); @@ -3584,7 +3584,7 @@ function get_week_agendaitems($courses_dbs, $month, $year, $week = '') //Display the events in agenda $items[$agendaday][$item['start_date']] .= "$time ".$agenda_link.""; $items[$agendaday][$item['start_date']] .= "
".$item['title']."

"; - + } } // sorting by hour for every day @@ -4320,32 +4320,32 @@ function agenda_add_item($course_info, $title, $content, $db_start_date, $db_end { global $_course; $user_id = api_get_user_id(); - + // database table definitions $t_agenda = Database::get_course_table(TABLE_AGENDA,$course_info['dbName']); $agenda_table_attachment = Database::get_course_table(TABLE_AGENDA_ATTACHMENT); $item_property = Database::get_course_table(TABLE_ITEM_PROPERTY); - + // some filtering of the input data $content=stripslashes($content); $title=Database::escape_string(Security::remove_XSS($title)); - $content = Database::escape_string(Security::remove_XSS($content,COURSEMANAGERLOWSECURITY)); + $content = Database::escape_string(Security::remove_XSS($content,COURSEMANAGERLOWSECURITY)); $start_date = Database::escape_string($db_start_date); $end_date = Database::escape_string($db_end_date); isset($_SESSION['id_session'])?$id_session=intval($_SESSION['id_session']):$id_session=null; // store in the table calendar_event // check if exists in calendar_event table and if it is not deleted! - $sql = "SELECT * FROM $t_agenda agenda, $item_property item_property - WHERE agenda.title='$title' - AND agenda.content = '$content' + $sql = "SELECT * FROM $t_agenda agenda, $item_property item_property + WHERE agenda.title='$title' + AND agenda.content = '$content' AND agenda.start_date = '$start_date' - AND agenda.end_date = '$end_date' ".(!empty($parent_id)? " - AND agenda.parent_event_id = '$parent_id'":"")." + AND agenda.end_date = '$end_date' ".(!empty($parent_id)? " + AND agenda.parent_event_id = '$parent_id'":"")." AND agenda.session_id = '$id_session' AND item_property.tool = '".TOOL_CALENDAR_EVENT."' AND item_property.ref = agenda.id - AND item_property.visibility <> 2 + AND item_property.visibility <> 2 "; $result = Database::query($sql,__FILE__,__LINE__); $count = Database::num_rows($result); @@ -4417,7 +4417,7 @@ function delete_attachment_file($id_attach) { $last_id_file=Database::insert_id(); // update item_property api_item_property_update($_course, 'calendar_event_attachment', $id_attach ,'AgendaAttachmentDeleted', api_get_user_id()); - if (!empty($result)) { + if (!empty($result)) { Display::display_confirmation_message(get_lang("AttachmentFileDeleteSuccess")); } } @@ -4689,7 +4689,7 @@ function agenda_import_ical($course_info,$file) { * @param int Week number * @param string Type of view (month_view, week_view, day_view) * @return array The results of the database query, or null if not found - */ + */ function get_global_agenda_items($agendaitems, $day = "", $month = "", $year = "", $week = "", $type) { $tbl_global_agenda= Database::get_main_table(TABLE_MAIN_SYSTEM_CALENDAR); @@ -4770,7 +4770,7 @@ function get_global_agenda_items($agendaitems, $day = "", $month = "", $year = " } //$agendaitems[$halfhour] .= "
$hour:$minute ".get_lang('Evento Global'). ": ".$item['title']."
"; if (!is_array($agendaitems[$halfhour])) - $content = $agendaitems[$halfhour]; + $content = $agendaitems[$halfhour]; $agendaitems[$halfhour] = $content."
$hour:$minute ".get_lang('GlobalEvent'). ": ".$item['title']."
"; } } @@ -4795,6 +4795,6 @@ function display_ical_import_form()
-
'; + '; echo ''; }