";
- echo "| ".get_lang("StartTimeWindow").": ";
- echo api_format_date($myrow["start_date"]);
+ echo " | ".get_lang("StartTimeWindow").": ";
+ echo api_format_date($myrow["start_date"], DATE_TIME_FORMAT_LONG);
echo " | ";
echo "";
- if ($myrow["end_date"]<>"0000-00-00 00:00:00")
- {
+ if ($myrow["end_date"]<>"0000-00-00 00:00:00") {
+ $myrow["end_date"] = api_get_local_time($myrow["end_date"]);
echo get_lang("EndTimeWindow").": ";
- echo api_convert_and_format_date($myrow["end_date"], null, date_default_timezone_get());
+ echo api_format_date($myrow["end_date"], DATE_TIME_FORMAT_LONG);
}
echo " | ";
-
- // attachment list
- //$attachment_list=get_attachment($myrow['id']);
-
- /*--------------------------------------------------
- display: edit delete button (course admin only)
- --------------------------------------------------*/
-
-
- if (!$is_repeated && (api_is_allowed_to_edit(false,true) OR (api_get_course_setting('allow_user_edit_agenda') && !api_is_anonymous())))
- {
+
+ if (!$is_repeated && (api_is_allowed_to_edit(false,true) OR (api_get_course_setting('allow_user_edit_agenda') && !api_is_anonymous()))) {
if( ! (api_is_course_coach() && !api_is_element_in_the_session(TOOL_AGENDA, $myrow['id'] ) ) )
{ // a coach can only delete an element belonging to his session
$mylink = api_get_self().'?'.api_get_cidreq().'&origin='.Security::remove_XSS($_GET['origin']).'&id='.$myrow['id'];
@@ -836,19 +801,14 @@ function display_agenda_items()
echo Display::return_icon('delete.gif', get_lang('Delete'))."";
}
- if (!$is_repeated && (api_is_allowed_to_edit(false,true) OR (api_get_course_setting('allow_user_edit_agenda') && !api_is_anonymous())))
- {
- if( ! (api_is_course_coach() && !api_is_element_in_the_session(TOOL_AGENDA, $myrow['id'] ) ) )
- { // a coach can only delete an element belonging to his session
+ if (!$is_repeated && (api_is_allowed_to_edit(false,true) OR (api_get_course_setting('allow_user_edit_agenda') && !api_is_anonymous()))) {
+ if( ! (api_is_course_coach() && !api_is_element_in_the_session(TOOL_AGENDA, $myrow['id'] ) ) ) {
+ // a coach can only delete an element belonging to his session
$td_colspan= '';
- }
- else
- {
+ } else {
$td_colspan= ' | ';
}
- }
- else
- {
+ } else {
$td_colspan= ' | ';
}
$mylink = 'calendar_ical_export.php?'.api_get_cidreq().'&type=course&id='.$myrow['id'];
@@ -1210,8 +1170,7 @@ function show_add_form($id = '')
$htmlHeadXtra[] = to_javascript();
// the default values for the forms
- if ($_GET['originalresource'] !== 'no')
- {
+ if ($_GET['originalresource'] !== 'no') {
$day = date('d');
$month = date('m');
$year = date('Y');
@@ -1224,9 +1183,7 @@ function show_add_form($id = '')
$end_hours = 17;
$end_minutes= '00';
$repeat = false;
- }
- else
- {
+ } 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
@@ -1252,8 +1209,7 @@ function show_add_form($id = '')
// switching the send to all/send to groups/send to users
- if ($_POST['To'])
- {
+ if ($_POST['To']) {
$day = $_POST['fday'];
$month = $_POST['fmonth'];
$year = $_POST['fyear'];
@@ -1274,17 +1230,22 @@ function show_add_form($id = '')
// if the id is set then we are editing an agenda item
- if (is_int($id))
- {
+ if (is_int($id)) {
//echo "before get_agenda_item".$_SESSION['allow_individual_calendar'];
$item_2_edit=get_agenda_item($id);
$title = $item_2_edit['title'];
$content= $item_2_edit['content'];
+
+ // start date
+ $item_2_edit['start_date'] = api_get_local_time($item_2_edit['start_date']);
+
// start date
list($datepart, $timepart) = split(" ", $item_2_edit['start_date']);
list($year, $month, $day) = explode("-", $datepart);
list($hours, $minutes, $seconds) = explode(":", $timepart);
+
// end date
+ $item_2_edit['end_date'] = api_get_local_time($item_2_edit['end_date']);
list($datepart, $timepart) = split(" ", $item_2_edit['end_date']);
list($end_year, $end_month, $end_day) = explode("-", $datepart);
list($end_hours, $end_minutes, $end_seconds) = explode(":", $timepart);
@@ -1710,7 +1671,7 @@ function display_upcoming_events() {
$counter = 0;
while ($item = Database::fetch_array($result,'ASSOC')) {
if ($counter < $number_of_items_to_show) {
- echo $item['start_date'],' - ',$item['title'],' ';
+ echo api_get_local_time($item['start_date']),' - ',$item['title'],' ';
$counter++;
}
}
@@ -2847,10 +2808,15 @@ function agenda_add_item($course_info, $title, $content, $db_start_date, $db_end
// some filtering of the input data
$title = Database::escape_string($title); // no html allowed in the title
$content = Database::escape_string($content);
+
+ $db_start_date = api_get_utc_datetime($db_start_date);
$start_date = Database::escape_string($db_start_date);
- $end_date = Database::escape_string($db_end_date);
+
+ $db_end_date = api_get_utc_datetime($db_end_date);
+ $end_date = Database::escape_string($db_end_date);
+
- isset($_SESSION['id_session'])?$id_session=intval($_SESSION['id_session']):$id_session=null;
+ 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
diff --git a/main/admin/calendar.php b/main/admin/calendar.php
index bf48c1632a..ad2c90d1e8 100755
--- a/main/admin/calendar.php
+++ b/main/admin/calendar.php
@@ -29,15 +29,14 @@ $tool_name= get_lang('SubscribeCoursesToSession');
$id_session=intval($_GET['id_session']);
-if(!api_is_platform_admin())
-{
+if (!api_is_platform_admin()) {
$sql = 'SELECT session_admin_id FROM '.Database :: get_main_table(TABLE_MAIN_SESSION).' WHERE id='.$id_session;
$rs = Database::query($sql);
- if(Database::result($rs,0,0)!=$_user['user_id'])
- {
+ if(Database::result($rs,0,0)!= api_get_user_id()) {
api_not_allowed(true);
}
}
+
/*
Libraries
*/
@@ -153,33 +152,26 @@ echo "";
//setting the default year and month
$select_year = '';
$select_month = '';
-if(!empty($_GET['year']))
-{
+if(!empty($_GET['year'])) {
$select_year = (int)$_GET['year'];
}
-if(!empty($_GET['month']))
-{
+if(!empty($_GET['month'])) {
$select_month = (int)$_GET['month'];
}
-if (empty($select_year) && empty($select_month))
-{
+if (empty($select_year) && empty($select_month)) {
$today = getdate();
$select_year = $today['year'];
$select_month = $today['mon'];
}
echo '';
-if (api_is_allowed_to_edit(false,true) OR (api_get_course_setting('allow_user_edit_agenda') && !api_is_anonymous()))
-{
+if (api_is_allowed_to_edit(false,true) OR (api_get_course_setting('allow_user_edit_agenda') && !api_is_anonymous())) {
display_student_links();
display_courseadmin_links();
}
echo '
';
-
-
-echo ''
- . '';
+echo '';
// THE LEFT PART
if (empty($_GET['origin']) or $_GET['origin']!='learnpath') {
@@ -204,28 +196,27 @@ echo '';
echo ' ';
if (api_is_allowed_to_edit(false,true)) {
- switch ($_GET['action'])
- {
+ switch ($_GET['action']) {
case "add":
if(!empty($_POST['ical_submit'])) {
$course_info = api_get_course_info();
- agenda_import_ical($course_info,$_FILES['ical_import']);
+ agenda_import_ical($course_info, $_FILES['ical_import']);
display_agenda_items();
} elseif ($_POST['submit_event']) {
- $course_info = api_get_course_info();
+ $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,$_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,$_POST['file_comment']);
- }
+ }*/
display_agenda_items();
} else {
show_add_form();
@@ -235,14 +226,14 @@ if (api_is_allowed_to_edit(false,true)) {
case "edit":
if( ! (api_is_course_coach() && !api_is_element_in_the_session(TOOL_AGENDA, intval($_REQUEST['id']) ) ) )
{ // a coach can only delete an element belonging to his session
- if ($_POST['submit_event'])
- { $my_id_attach = (int)$_REQUEST['id_attach'];
- $my_file_comment = Database::escape_string($_REQUEST['file_comment']);
- store_edited_agenda_item($my_id_attach,$my_file_comment);
- display_agenda_items();
+ if ($_POST['submit_event']) {
+ $my_id_attach = (int)$_REQUEST['id_attach'];
+ $my_file_comment = Database::escape_string($_REQUEST['file_comment']);
+ store_edited_agenda_item($my_id_attach,$my_file_comment);
+ display_agenda_items();
} else {
- $id=(int)$_GET['id'];
- show_add_form($id);
+ $id=(int)$_GET['id'];
+ show_add_form($id);
}
} else {
display_agenda_items();
@@ -296,28 +287,18 @@ if (api_is_allowed_to_edit(false,true)) {
}
// this is for students and whenever the courseaministrator has not chosen any action. It is in fact the default behaviour
-if (!$_GET['action'] OR $_GET['action']=="showall" OR $_GET['action']=="showcurrent" OR $_GET['action']=="view")
-{
- if ($_GET['origin'] != 'learnpath')
- {
- if (!$_SESSION['view'] OR $_SESSION['view'] <> 'month')
- {
- if(!empty($_GET['agenda_id']))
- {
+if (!$_GET['action'] OR $_GET['action']=="showall" OR $_GET['action']=="showcurrent" OR $_GET['action']=="view") {
+ if ($_GET['origin'] != 'learnpath') {
+ if (!$_SESSION['view'] OR $_SESSION['view'] <> 'month') {
+ if(!empty($_GET['agenda_id'])) {
display_one_agenda_item((int)$_GET['agenda_id']);
- }
- else
- {
+ } else {
display_agenda_items();
}
- }
- else
- {
+ } else {
display_monthcalendar($select_month, $select_year);
}
- }
- else
- {
+ } else {
display_one_agenda_item((int)$_GET['agenda_id']);
}
}
@@ -329,5 +310,4 @@ echo " ";
// The footer is displayed only if we are not in the learnpath
if ($_GET['origin'] != 'learnpath') {
Display::display_footer();
-}
-?>
\ No newline at end of file
+}
\ No newline at end of file
|