diff --git a/main/admin/calendar.lib.php b/main/admin/calendar.lib.php index bf8ae91c7c..ba2bd8eea5 100755 --- a/main/admin/calendar.lib.php +++ b/main/admin/calendar.lib.php @@ -653,7 +653,7 @@ function display_agenda_items() $stop = 0; // this is to make a difference between showing everything (all months) or only the current month) // $show_all_current is a part of the sql statement - if ($_SESSION['show']!=="showall") + if ($_SESSION['show_all_admin']!=="showall") { $show_all_current=" AND MONTH(start_date)=$select_month AND year(start_date)=$select_year"; $start = mktime(0,0,0,$select_month,1,$select_year); @@ -762,11 +762,10 @@ function display_agenda_items() // the icons. If the message is sent to one or more specific users/groups // we add the groups icon // 2do: if it is sent to groups we display the group icon, if it is sent to a user we show the user icon - Display::display_icon('agenda.gif', get_lang('Agenda')); - if ($myrow['to_group_id']!=='0') - { + Display::display_icon('calendar_global.png', get_lang('Agenda')); + /*if ($myrow['to_group_id']!=='0') { echo Display::return_icon('group.gif', get_lang('AllUsersOfThePlatform')); - } + }*/ echo " ".$myrow['title'].""; echo ""; @@ -1666,9 +1665,8 @@ function get_agendaitems($month, $year) return $agendaitems; } -function display_upcoming_events() -{ - echo ''.get_lang('UpcomingEvent').'
'; +function display_upcoming_events() { + echo '
'.get_lang('UpcomingEvent').'
'; $number_of_items_to_show = (int)api_get_setting('number_of_upcoming_events'); //databases of the courses diff --git a/main/admin/calendar.php b/main/admin/calendar.php index 48b2e67491..bf48c1632a 100755 --- a/main/admin/calendar.php +++ b/main/admin/calendar.php @@ -52,19 +52,17 @@ require_once 'calendar.lib.php'; 4. filter user or group */ // 1. show all or show current month? -if (!$_SESSION['show']) -{ - $_SESSION['show']="showall"; +if (!$_SESSION['show_all_admin']) { + $_SESSION['show_all_admin']="showall"; } if (!empty($_GET['action']) and $_GET['action']=="showcurrent") { - $_SESSION['show']="showcurrent"; + $_SESSION['show_all_admin']='showcurrent'; } if (!empty($_GET['action']) and $_GET['action']=="showall") { - $_SESSION['show']="showall"; + $_SESSION['show_all_admin']='showall'; } -//echo $_SESSION['show']; // 2. sorting order (ASC or DESC) if (empty($_GET['sort']) and empty($_SESSION['sort'])) @@ -189,13 +187,12 @@ if (empty($_GET['origin']) or $_GET['origin']!='learnpath') { // the small calendar $MonthName = $MonthsLong[$select_month -1]; $agenda_items=get_calendar_items($select_month,$select_year); - if (api_get_setting('display_mini_month_calendar') == 'true') - { + if (api_get_setting('display_mini_month_calendar') == 'true') { display_minimonthcalendar($agenda_items, $select_month,$select_year, $MonthName); } - /*if (api_get_setting('display_upcoming_events') == 'true') { + if (api_get_setting('display_upcoming_events') == 'true') { display_upcoming_events(); - }*/ + } echo ''; echo ' '; } @@ -206,17 +203,13 @@ echo ''; echo '
'; echo '
'; -if (api_is_allowed_to_edit(false,true)) -{ +if (api_is_allowed_to_edit(false,true)) { switch ($_GET['action']) { case "add": if(!empty($_POST['ical_submit'])) { $course_info = api_get_course_info(); - agenda_import_ical($course_info,$_FILES['ical_import']); - if (api_get_setting('display_upcoming_events') == 'true') { - display_upcoming_events(); - } + agenda_import_ical($course_info,$_FILES['ical_import']); display_agenda_items(); } elseif ($_POST['submit_event']) { @@ -232,10 +225,7 @@ if (api_is_allowed_to_edit(false,true)) $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']); - } - if (api_get_setting('display_upcoming_events') == 'true') { - display_upcoming_events(); - } + } display_agenda_items(); } else { show_add_form(); @@ -249,22 +239,12 @@ if (api_is_allowed_to_edit(false,true)) { $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); - if (api_get_setting('display_upcoming_events') == 'true') { - display_upcoming_events(); - } display_agenda_items(); - } - else - { + } else { $id=(int)$_GET['id']; show_add_form($id); } - } - else - { - if (api_get_setting('display_upcoming_events') == 'true') { - display_upcoming_events(); - } + } else { display_agenda_items(); } break; @@ -282,10 +262,7 @@ if (api_is_allowed_to_edit(false,true)) } } } - if (api_get_setting('display_upcoming_events') == 'true') { - display_upcoming_events(); - } - display_agenda_items(); + display_agenda_items(); break; case "showhide": @@ -294,9 +271,6 @@ if (api_is_allowed_to_edit(false,true)) { // a coach can only delete an element belonging to his session showhide_agenda_item($id); } - if (api_get_setting('display_upcoming_events') == 'true') { - display_upcoming_events(); - } display_agenda_items(); break; case "announce": //copying the agenda item into an announcement @@ -308,9 +282,6 @@ if (api_is_allowed_to_edit(false,true)) echo '
'; Display::display_normal_message(get_lang('CopiedAsAnnouncement').''.get_lang('NewAnnouncement').'', false); } - if (api_get_setting('display_upcoming_events') == 'true') { - display_upcoming_events(); - } display_agenda_items(); break; case "delete_attach": //delete attachment file @@ -318,9 +289,6 @@ if (api_is_allowed_to_edit(false,true)) if (!empty($id_attach)) { delete_attachment_file($id_attach); } - if (api_get_setting('display_upcoming_events') == 'true') { - display_upcoming_events(); - } display_agenda_items(); break; diff --git a/main/calendar/agenda.inc.php b/main/calendar/agenda.inc.php index 3849d55cc5..04a69bbf40 100755 --- a/main/calendar/agenda.inc.php +++ b/main/calendar/agenda.inc.php @@ -86,7 +86,8 @@ function get_calendar_items($month, $year) { $stop = 0; // this is to make a difference between showing everything (all months) or only the current month) // $show_all_current is a part of the sql statement - if ($_SESSION['show']!=="showall") { + + if ($_SESSION['show']!=='showall') { $show_all_current=" AND MONTH(start_date)=$select_month AND year(start_date)=$select_year"; $start = mktime(0,0,0,$select_month,1,$select_year); $stop = 0; @@ -236,10 +237,8 @@ function get_calendar_items($month, $year) { } } } // you are a student - - - $result=Database::query($sql) or die(Database::error()); - + + $result=Database::query($sql); $data=array(); while ($row=Database::fetch_array($result, 'ASSOC')) { $datum_item=(int)substr($row['start_date'],8,2); @@ -247,7 +246,7 @@ function get_calendar_items($month, $year) { $data[$datum_item][intval($datum_item)][] = $row; } - //Check my personal calendar items + //Check my personal agenda events if (api_get_setting('allow_personal_agenda') == 'true') { $tbl_personal_agenda = Database :: get_user_personal_table(TABLE_PERSONAL_AGENDA); // 1. creating the SQL statement for getting the personal agenda items in MONTH view @@ -259,8 +258,21 @@ function get_calendar_items($month, $year) { $row['calendar_type'] = 'personal'; $data[$datum_item][$datum_item][] = $row; } - } - + } + /* + //Check global agenda events */ + $table_agenda_system = Database :: get_main_table(TABLE_MAIN_SYSTEM_CALENDAR); + $sql = "SELECT DISTINCT * FROM ".$table_agenda_system." + WHERE + MONTH(start_date)='".$month."' + AND YEAR(start_date)='".$year."' + ORDER BY start_date "; + $result=Database::query($sql); + while ($row = Database::fetch_array($result, 'ASSOC')) { + $datum_item=intval(substr($row['start_date'],8,2)); + $row['calendar_type'] = 'global'; + $data[$datum_item][$datum_item][] = $row; + } return $data; } @@ -276,8 +288,7 @@ function get_calendar_items($month, $year) { * @return html code * @todo refactor this so that $monthName is no longer needed as a parameter */ -function display_minimonthcalendar($agendaitems, $month, $year, $monthName) -{ +function display_minimonthcalendar($agendaitems, $month, $year, $monthName) { global $DaysShort; //Handle leap year $numberofdays = array (0, 31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31); @@ -420,14 +431,16 @@ function display_monthcalendar($month, $year) { if (key_exists($curday, $data)) { foreach ($data[$curday] as $key=>$agenda_item) { - $dayheader ="".$curday.""; + + $dayheader = "".$curday.""; + $some_content = false; foreach ($agenda_item as $key=>$value) { $month_start_date = (int)substr($value['start_date'],5,2); - $start_time = api_convert_and_format_date($value['start_date']); + $start_time = api_convert_and_format_date($value['start_date']); - if ($month == $month_start_date) { + $some_content = true; $start_time = api_convert_and_format_date($value['start_date'], TIME_NO_SEC_FORMAT, date_default_timezone_get()); $end_time = api_convert_and_format_date($value['end_date'], TIME_NO_SEC_FORMAT, date_default_timezone_get()); @@ -435,9 +448,12 @@ function display_monthcalendar($month, $year) { //Setting a personal event to green $personal_start = $personal_end = ''; if ($value['calendar_type'] == 'personal') { - $personal_start = '
'; + $personal_start = '
'.get_lang('MyAgenda'); + $personal_end = '
'; + } elseif ($value['calendar_type'] == 'global') { + $personal_start = '
'.get_lang('GlobalEvent'); $personal_end = '
'; - } + } $dayheader.= $personal_start; if ($value['end_date']=='0000-00-00 00:00:00') { @@ -458,7 +474,12 @@ function display_monthcalendar($month, $year) { } else { //$dayheader=$curday; } - } + } + //Do not show links with no content + if ($some_content == false) { + $dayheader = $curday; + } + } } //var_dump($dayheader); @@ -2014,6 +2035,20 @@ function display_agenda_items($select_month, $select_year) { } } + + + //Check global agenda events */ + $table_agenda_system = Database :: get_main_table(TABLE_MAIN_SYSTEM_CALENDAR); + $sql = "SELECT DISTINCT id, title, content , start_date, end_date FROM ".$table_agenda_system." + WHERE 1=1 ".$show_all_current." + ORDER BY start_date "; + $result=Database::query($sql); + while ($row = Database::fetch_array($result, 'ASSOC')) { + $row['calendar_type'] = 'global'; + $my_events[] = $row; + } + + //while($myrow = Database::fetch_array($result)) { foreach ($my_events as $myrow) { $is_repeated = !empty($myrow['parent_event_id']); @@ -2058,7 +2093,7 @@ function display_agenda_items($select_month, $select_year) { // the icons. If the message is sent to one or more specific users/groups // we add the groups icon // 2do: if it is sent to groups we display the group icon, if it is sent to a user we show the user icon - if ($myrow['calendar_type'] != 'personal') { + if ($myrow['calendar_type'] == 'course') { Display::display_icon('agenda.gif', get_lang('Agenda')); if ($myrow['to_group_id']!=='0') { echo Display::return_icon('group.gif', get_lang('ItemForUserSelection')); @@ -2066,26 +2101,33 @@ function display_agenda_items($select_month, $select_year) { echo ''; echo $myrow['title']; echo ''; - } else { + } elseif ($myrow['calendar_type'] == 'personal') { Display::display_icon('calendar_personal.gif', get_lang('Personal')); echo ''; echo $myrow['title']; echo ''; - } + } else { + Display::display_icon('calendar_global.png', get_lang('Personal')); + echo ''; + echo $myrow['title']; + echo ''; + } echo ''; - if ($myrow['calendar_type'] != 'personal') { + if ($myrow['calendar_type'] == 'course') { // the message has been sent to echo "".get_lang('SentTo').": "; $sent_to=sent_to(TOOL_CALENDAR_EVENT, $myrow["ref"]); $sent_to_form=sent_to_form($sent_to); echo $sent_to_form; echo ''; - } else { + } elseif ($myrow['calendar_type'] == 'personal') { echo ''.get_lang('Personal').''; + } elseif ($myrow['calendar_type'] == 'global') { + echo ''.get_lang('GlobalEvent').''; } - if (!$is_repeated && (api_is_allowed_to_edit(false,true) OR (api_get_course_setting('allow_user_edit_agenda') && !api_is_anonymous())) && $myrow['calendar_type'] != 'personal' ) { + if (!$is_repeated && (api_is_allowed_to_edit(false,true) OR (api_get_course_setting('allow_user_edit_agenda') && !api_is_anonymous())) && $myrow['calendar_type'] == 'course' ) { 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 echo ''.get_lang('Modify'); @@ -2102,7 +2144,7 @@ function display_agenda_items($select_month, $select_year) { echo ''; echo ''; - if ($myrow['calendar_type'] != 'personal') { + if ($myrow['calendar_type'] == 'course') { if ($myrow['end_date']<>'0000-00-00 00:00:00') { echo get_lang('EndTimeWindow').": "; echo api_convert_and_format_date($myrow['end_date'], null, date_default_timezone_get()); @@ -2114,7 +2156,7 @@ function display_agenda_items($select_month, $select_year) { $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())) && $myrow['calendar_type'] != 'personal') { + if (!$is_repeated && (api_is_allowed_to_edit(false,true) OR (api_get_course_setting('allow_user_edit_agenda') && !api_is_anonymous())) && $myrow['calendar_type'] == 'course') { 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'].'&'; diff --git a/main/calendar/agenda.php b/main/calendar/agenda.php index eabecc115f..45e747183e 100755 --- a/main/calendar/agenda.php +++ b/main/calendar/agenda.php @@ -76,7 +76,6 @@ if (!empty($_GET['action']) and $_GET['action']=="showcurrent") { if (!empty($_GET['action']) and $_GET['action']=="showall") { $_SESSION['show']="showall"; } -//echo $_SESSION['show']; // 2. sorting order (ASC or DESC) if (empty($_GET['sort']) and empty($_SESSION['sort'])) { diff --git a/main/img/calendar_global.png b/main/img/calendar_global.png new file mode 100644 index 0000000000..74169fd4b9 Binary files /dev/null and b/main/img/calendar_global.png differ diff --git a/main/img/loading1.gif b/main/img/loading1.gif new file mode 100644 index 0000000000..d0bce15423 Binary files /dev/null and b/main/img/loading1.gif differ