Adding global events in course agenda and personal agenda see CT#325

skala
Julio Montoya 15 years ago
parent 9446154dd1
commit 04f3fe5330
  1. 14
      main/admin/calendar.lib.php
  2. 58
      main/admin/calendar.php
  3. 90
      main/calendar/agenda.inc.php
  4. 1
      main/calendar/agenda.php
  5. BIN
      main/img/calendar_global.png
  6. BIN
      main/img/loading1.gif

@ -653,7 +653,7 @@ function display_agenda_items()
$stop = 0; $stop = 0;
// this is to make a difference between showing everything (all months) or only the current month) // 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 // $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"; $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); $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 // the icons. If the message is sent to one or more specific users/groups
// we add the groups icon // 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 // 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')); Display::display_icon('calendar_global.png', get_lang('Agenda'));
if ($myrow['to_group_id']!=='0') /*if ($myrow['to_group_id']!=='0') {
{
echo Display::return_icon('group.gif', get_lang('AllUsersOfThePlatform')); echo Display::return_icon('group.gif', get_lang('AllUsersOfThePlatform'));
} }*/
echo " ".$myrow['title'].""; echo " ".$myrow['title']."";
echo "</th>"; echo "</th>";
@ -1666,9 +1665,8 @@ function get_agendaitems($month, $year)
return $agendaitems; return $agendaitems;
} }
function display_upcoming_events() function display_upcoming_events() {
{ echo '<br /><b>'.get_lang('UpcomingEvent').'</b><br />';
echo '<b>'.get_lang('UpcomingEvent').'</b><br />';
$number_of_items_to_show = (int)api_get_setting('number_of_upcoming_events'); $number_of_items_to_show = (int)api_get_setting('number_of_upcoming_events');
//databases of the courses //databases of the courses

@ -52,19 +52,17 @@ require_once 'calendar.lib.php';
4. filter user or group 4. filter user or group
*/ */
// 1. show all or show current month? // 1. show all or show current month?
if (!$_SESSION['show']) if (!$_SESSION['show_all_admin']) {
{ $_SESSION['show_all_admin']="showall";
$_SESSION['show']="showall";
} }
if (!empty($_GET['action']) and $_GET['action']=="showcurrent") if (!empty($_GET['action']) and $_GET['action']=="showcurrent")
{ {
$_SESSION['show']="showcurrent"; $_SESSION['show_all_admin']='showcurrent';
} }
if (!empty($_GET['action']) and $_GET['action']=="showall") 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) // 2. sorting order (ASC or DESC)
if (empty($_GET['sort']) and empty($_SESSION['sort'])) if (empty($_GET['sort']) and empty($_SESSION['sort']))
@ -189,13 +187,12 @@ if (empty($_GET['origin']) or $_GET['origin']!='learnpath') {
// the small calendar // the small calendar
$MonthName = $MonthsLong[$select_month -1]; $MonthName = $MonthsLong[$select_month -1];
$agenda_items=get_calendar_items($select_month,$select_year); $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); 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(); display_upcoming_events();
}*/ }
echo '</td>'; echo '</td>';
echo '<td width="20" background="../img/verticalruler.gif">&nbsp;</td>'; echo '<td width="20" background="../img/verticalruler.gif">&nbsp;</td>';
} }
@ -206,17 +203,13 @@ echo '<td valign="top">';
echo '<div class="sort" style="float:right">'; echo '<div class="sort" style="float:right">';
echo '</div>'; echo '</div>';
if (api_is_allowed_to_edit(false,true)) if (api_is_allowed_to_edit(false,true)) {
{
switch ($_GET['action']) switch ($_GET['action'])
{ {
case "add": case "add":
if(!empty($_POST['ical_submit'])) { if(!empty($_POST['ical_submit'])) {
$course_info = api_get_course_info(); $course_info = api_get_course_info();
agenda_import_ical($course_info,$_FILES['ical_import']); agenda_import_ical($course_info,$_FILES['ical_import']);
if (api_get_setting('display_upcoming_events') == 'true') {
display_upcoming_events();
}
display_agenda_items(); display_agenda_items();
} elseif ($_POST['submit_event']) { } elseif ($_POST['submit_event']) {
@ -232,10 +225,7 @@ if (api_is_allowed_to_edit(false,true))
$end_d = intval($_POST['repeat_end_day']); $end_d = intval($_POST['repeat_end_day']);
$end = mktime(23, 59, 59, $end_m, $end_d, $end_y); $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']); $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(); display_agenda_items();
} else { } else {
show_add_form(); show_add_form();
@ -249,22 +239,12 @@ if (api_is_allowed_to_edit(false,true))
{ $my_id_attach = (int)$_REQUEST['id_attach']; { $my_id_attach = (int)$_REQUEST['id_attach'];
$my_file_comment = Database::escape_string($_REQUEST['file_comment']); $my_file_comment = Database::escape_string($_REQUEST['file_comment']);
store_edited_agenda_item($my_id_attach,$my_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(); display_agenda_items();
} } else {
else
{
$id=(int)$_GET['id']; $id=(int)$_GET['id'];
show_add_form($id); show_add_form($id);
} }
} } else {
else
{
if (api_get_setting('display_upcoming_events') == 'true') {
display_upcoming_events();
}
display_agenda_items(); display_agenda_items();
} }
break; break;
@ -282,10 +262,7 @@ if (api_is_allowed_to_edit(false,true))
} }
} }
} }
if (api_get_setting('display_upcoming_events') == 'true') { display_agenda_items();
display_upcoming_events();
}
display_agenda_items();
break; break;
case "showhide": 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 { // a coach can only delete an element belonging to his session
showhide_agenda_item($id); showhide_agenda_item($id);
} }
if (api_get_setting('display_upcoming_events') == 'true') {
display_upcoming_events();
}
display_agenda_items(); display_agenda_items();
break; break;
case "announce": //copying the agenda item into an announcement case "announce": //copying the agenda item into an announcement
@ -308,9 +282,6 @@ if (api_is_allowed_to_edit(false,true))
echo '<br />'; echo '<br />';
Display::display_normal_message(get_lang('CopiedAsAnnouncement').'<a href="../announcements/announcements.php?id='.$ann_id.$tool_group_link.'">'.get_lang('NewAnnouncement').'</a>', false); Display::display_normal_message(get_lang('CopiedAsAnnouncement').'<a href="../announcements/announcements.php?id='.$ann_id.$tool_group_link.'">'.get_lang('NewAnnouncement').'</a>', false);
} }
if (api_get_setting('display_upcoming_events') == 'true') {
display_upcoming_events();
}
display_agenda_items(); display_agenda_items();
break; break;
case "delete_attach": //delete attachment file case "delete_attach": //delete attachment file
@ -318,9 +289,6 @@ if (api_is_allowed_to_edit(false,true))
if (!empty($id_attach)) { if (!empty($id_attach)) {
delete_attachment_file($id_attach); delete_attachment_file($id_attach);
} }
if (api_get_setting('display_upcoming_events') == 'true') {
display_upcoming_events();
}
display_agenda_items(); display_agenda_items();
break; break;

@ -86,7 +86,8 @@ function get_calendar_items($month, $year) {
$stop = 0; $stop = 0;
// this is to make a difference between showing everything (all months) or only the current month) // 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 // $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"; $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); $start = mktime(0,0,0,$select_month,1,$select_year);
$stop = 0; $stop = 0;
@ -236,10 +237,8 @@ function get_calendar_items($month, $year) {
} }
} }
} // you are a student } // you are a student
$result=Database::query($sql);
$result=Database::query($sql) or die(Database::error());
$data=array(); $data=array();
while ($row=Database::fetch_array($result, 'ASSOC')) { while ($row=Database::fetch_array($result, 'ASSOC')) {
$datum_item=(int)substr($row['start_date'],8,2); $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; $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') { if (api_get_setting('allow_personal_agenda') == 'true') {
$tbl_personal_agenda = Database :: get_user_personal_table(TABLE_PERSONAL_AGENDA); $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 // 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'; $row['calendar_type'] = 'personal';
$data[$datum_item][$datum_item][] = $row; $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; return $data;
} }
@ -276,8 +288,7 @@ function get_calendar_items($month, $year) {
* @return html code * @return html code
* @todo refactor this so that $monthName is no longer needed as a parameter * @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; global $DaysShort;
//Handle leap year //Handle leap year
$numberofdays = array (0, 31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31); $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)) { if (key_exists($curday, $data)) {
foreach ($data[$curday] as $key=>$agenda_item) { foreach ($data[$curday] as $key=>$agenda_item) {
$dayheader ="<a href='".api_get_self()."?".api_get_cidreq()."&amp;sort=asc&amp;toolgroup=".Security::remove_XSS($_GET['toolgroup'])."&amp;view=list&amp;origin=$origin&amp;month=$month&amp;year=$year&amp;day=$curday#$curday'>".$curday."</a>";
$dayheader = "<a href='".api_get_self()."?".api_get_cidreq()."&amp;sort=asc&amp;toolgroup=".Security::remove_XSS($_GET['toolgroup'])."&amp;view=list&amp;origin=$origin&amp;month=$month&amp;year=$year&amp;day=$curday#$curday'>".$curday."</a>";
$some_content = false;
foreach ($agenda_item as $key=>$value) { foreach ($agenda_item as $key=>$value) {
$month_start_date = (int)substr($value['start_date'],5,2); $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) { 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()); $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()); $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 //Setting a personal event to green
$personal_start = $personal_end = ''; $personal_start = $personal_end = '';
if ($value['calendar_type'] == 'personal') { if ($value['calendar_type'] == 'personal') {
$personal_start = '<div style="color:green;">'; $personal_start = '<div style="color:green;">'.get_lang('MyAgenda');
$personal_end = '</div>';
} elseif ($value['calendar_type'] == 'global') {
$personal_start = '<div style="color:red;">'.get_lang('GlobalEvent');
$personal_end = '</div>'; $personal_end = '</div>';
} }
$dayheader.= $personal_start; $dayheader.= $personal_start;
if ($value['end_date']=='0000-00-00 00:00:00') { if ($value['end_date']=='0000-00-00 00:00:00') {
@ -458,7 +474,12 @@ function display_monthcalendar($month, $year) {
} else { } else {
//$dayheader=$curday; //$dayheader=$curday;
} }
} }
//Do not show links with no content
if ($some_content == false) {
$dayheader = $curday;
}
} }
} }
//var_dump($dayheader); //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)) { //while($myrow = Database::fetch_array($result)) {
foreach ($my_events as $myrow) { foreach ($my_events as $myrow) {
$is_repeated = !empty($myrow['parent_event_id']); $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 // the icons. If the message is sent to one or more specific users/groups
// we add the groups icon // 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 // 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')); Display::display_icon('agenda.gif', get_lang('Agenda'));
if ($myrow['to_group_id']!=='0') { if ($myrow['to_group_id']!=='0') {
echo Display::return_icon('group.gif', get_lang('ItemForUserSelection')); echo Display::return_icon('group.gif', get_lang('ItemForUserSelection'));
@ -2066,26 +2101,33 @@ function display_agenda_items($select_month, $select_year) {
echo '<span style="padding-left:5px; font-size:130%; ">'; echo '<span style="padding-left:5px; font-size:130%; ">';
echo $myrow['title']; echo $myrow['title'];
echo '</span>'; echo '</span>';
} else { } elseif ($myrow['calendar_type'] == 'personal') {
Display::display_icon('calendar_personal.gif', get_lang('Personal')); Display::display_icon('calendar_personal.gif', get_lang('Personal'));
echo '<span style="padding-left:5px; font-size:130%; ">'; echo '<span style="padding-left:5px; font-size:130%; ">';
echo $myrow['title']; echo $myrow['title'];
echo '</span>'; echo '</span>';
} } else {
Display::display_icon('calendar_global.png', get_lang('Personal'));
echo '<span style="padding-left:5px; font-size:130%; ">';
echo $myrow['title'];
echo '</span>';
}
echo '</th>'; echo '</th>';
if ($myrow['calendar_type'] != 'personal') { if ($myrow['calendar_type'] == 'course') {
// the message has been sent to // the message has been sent to
echo "<th>".get_lang('SentTo').": "; echo "<th>".get_lang('SentTo').": ";
$sent_to=sent_to(TOOL_CALENDAR_EVENT, $myrow["ref"]); $sent_to=sent_to(TOOL_CALENDAR_EVENT, $myrow["ref"]);
$sent_to_form=sent_to_form($sent_to); $sent_to_form=sent_to_form($sent_to);
echo $sent_to_form; echo $sent_to_form;
echo '</th>'; echo '</th>';
} else { } elseif ($myrow['calendar_type'] == 'personal') {
echo '<th>'.get_lang('Personal').'</th>'; echo '<th>'.get_lang('Personal').'</th>';
} elseif ($myrow['calendar_type'] == 'global') {
echo '<th>'.get_lang('GlobalEvent').'</th>';
} }
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'] ) ) ) { 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 // a coach can only delete an element belonging to his session
echo '<th>'.get_lang('Modify'); echo '<th>'.get_lang('Modify');
@ -2102,7 +2144,7 @@ function display_agenda_items($select_month, $select_year) {
echo '</td>'; echo '</td>';
echo '<td>'; echo '<td>';
if ($myrow['calendar_type'] != 'personal') { if ($myrow['calendar_type'] == 'course') {
if ($myrow['end_date']<>'0000-00-00 00:00:00') { if ($myrow['end_date']<>'0000-00-00 00:00:00') {
echo get_lang('EndTimeWindow').": "; echo get_lang('EndTimeWindow').": ";
echo api_convert_and_format_date($myrow['end_date'], null, date_default_timezone_get()); 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']); $attachment_list=get_attachment($myrow['id']);
/*Display: edit delete button (course admin only) */ /*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'] ) ) ) { 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 // a coach can only delete an element belonging to his session
$mylink = api_get_self().'?'.api_get_cidreq().'&amp;origin='.Security::remove_XSS($_GET['origin']).'&amp;id='.$myrow['id'].'&amp;'; $mylink = api_get_self().'?'.api_get_cidreq().'&amp;origin='.Security::remove_XSS($_GET['origin']).'&amp;id='.$myrow['id'].'&amp;';

@ -76,7 +76,6 @@ if (!empty($_GET['action']) and $_GET['action']=="showcurrent") {
if (!empty($_GET['action']) and $_GET['action']=="showall") { if (!empty($_GET['action']) and $_GET['action']=="showall") {
$_SESSION['show']="showall"; $_SESSION['show']="showall";
} }
//echo $_SESSION['show'];
// 2. sorting order (ASC or DESC) // 2. sorting order (ASC or DESC)
if (empty($_GET['sort']) and empty($_SESSION['sort'])) { if (empty($_GET['sort']) and empty($_SESSION['sort'])) {

Binary file not shown.

After

Width:  |  Height:  |  Size: 946 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 673 B

Loading…
Cancel
Save