From 04f3fe5330a8a398aea391829597c86263be50d0 Mon Sep 17 00:00:00 2001 From: Julio Montoya Date: Thu, 20 May 2010 14:40:47 +0200 Subject: [PATCH] Adding global events in course agenda and personal agenda see CT#325 --- main/admin/calendar.lib.php | 14 +++--- main/admin/calendar.php | 58 +++++----------------- main/calendar/agenda.inc.php | 90 +++++++++++++++++++++++++---------- main/calendar/agenda.php | 1 - main/img/calendar_global.png | Bin 0 -> 946 bytes main/img/loading1.gif | Bin 0 -> 673 bytes 6 files changed, 85 insertions(+), 78 deletions(-) create mode 100644 main/img/calendar_global.png create mode 100644 main/img/loading1.gif 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 0000000000000000000000000000000000000000..74169fd4b9cb7a52fc325112f613527ffaf7f276 GIT binary patch literal 946 zcmV;j15NyiP)Px#24YJ`L;(K){{a7>y{D4^000SaNLh0L01FcU01FcV0GgZ_00007bV*G`2igS` z3r311W96b4i!O?HO<*ttq=y8%*n5xK1r=y_DO#> z7di)VTrYMGjbqf>Ml8wxhkRcC`ts!@1gMqE{>$a%HH%qLJ>usq7Kwa5-VyIjU{Qzq9##fZG8mRpw=Qb zMy+X(hf=f1t3xUVbpkG~ABq!2u|bTjliD~Tsb7%JPpUQS-QQI29th>Pc^DZ%|0&d8 zRVA5%pel%@IYmWr;!sgU1!D}audkTbS2Ule`peIRKYjSXkMG{m-qDc|DxT+&LQ=aV zc~vEjgMxVS)7>Fw>MtE&rZEvKia6pO{gvdYNF z2vHQFiGSlbCRA0L@$~e>!NCFLav5U`rBaFc`FV1=97jh-oSmID2nGiSiK6IDeVDeD zwtI7P!_CbNQ&UqIV_02X<>cgq@$qr)@9&wJnPF^fjJCEmeBW<$mcnmUn8{>_qKJGx z&-3#$VHh$nFn}?JhldCD_V!p=Sz&W?lXAKIX5IjP8aU^uR;zS&b}~6R$<@^rJ3BiR z3I+Q6`>9kaSZi5WSYUa1nTv}Hj*pLN6%?iq^78V6a}MA4DHe-tY-}(zG{oH89G>UV z-QCUF+8Unc;hZCiBJS?)zH>!rt))__;GDzrJW8b!TU%RnbaYTC6gWRWr>CcfVzJ2f z_BIO(3#clkQi;*g(eGLgYqeTKwuo?ec*yPTExzxwzP^qzhUw{PW@l%)yu4(0cNgaz z6B82*4-YrInZn!O-`BprJ}Q+8%`e^z&+`a^pkeaVufFd$JekYoxW2xw+oqWyJ=BVH zRzVQF$+gB|5CmkiS*;84_&-opve~Q#LEw3di;KT6EiL`oYS90RAPD&U`STzD0@l^B UwGrI%Pyhe`07*qoM6N<$g884mqyPW_ literal 0 HcmV?d00001 diff --git a/main/img/loading1.gif b/main/img/loading1.gif new file mode 100644 index 0000000000000000000000000000000000000000..d0bce1542342e912da81a2c260562df172f30d73 GIT binary patch literal 673 zcmZ?wbhEHb6krfw_{6~Q|Nnmm28Kh24mmkF0U1e2Nli^nlO|14{Lk&@8WQa67~pE8 zXTZz|lvDgC+Z`3#dv5h=E26FfcG1 zbL_hF&)}42ws10s6^G;;cE1^EoUR)U5A70}d2pLv!jVIT7j&Z~EblI3x0K*v_sV|m z0kj3v921Z^em#l`(k(o@H$3ZdDRc@9NidXDNbqrumReCGv$gd8+e8WW28HVqkJ_9i zH>s*<31KtHjANIPvi2#*6BEu%3Dak5O_t&NBI)H?V$TxT}#l{vOTn5naXTfF^&~Hhq+NX@#Ccc>y7T?;vjI&jdhsDsPJyAw*m0Qz>i}K7# zL9w50Ng{fT}A5JUe8lRK1h7_Y2;BWJDd=c6f&i?Wv5(5q?6|P zQw{>maxZP<537OA37Uk}7@%_$4o$EWe_Zl>&#id|lE-BpDC#+Fn|msJ%_2h{Hg1vP z#N8WAzfWasG}yq|xqE)DrWaOofX=z|?*pgc%{ig5vl!pqDlC|q&~Z0$&Rvsft&VO- z4MZj+%-+Vx%W}v;V76hyp=;+R;x+~t^Q%*xuFTQAF2})fSfTHDAs>sO!OBw`)&)o$ c0!CNZt))x~rAZP^^P&YOFfdqy5)K#u0POD40{{R3 literal 0 HcmV?d00001