[svn r15173] Fixes and improvements in calendar - now displaying cours title correctly for events

skala
Yannick Warnier 18 years ago
parent d0436cc06a
commit 55154e906e
  1. 47
      index.php
  2. 41
      main/calendar/myagenda.inc.php
  3. 8
      main/calendar/myagenda.php
  4. 9
      main/inc/lib/main_api.lib.php

@ -20,7 +20,7 @@
/**
* @package dokeos.main
* @author Patrick Cool <patrick.cool@UGent.be>, Ghent University, Refactoring
* @version $Id: index.php 15166 2008-04-29 06:03:54Z yannoo $
* @version $Id: index.php 15173 2008-04-29 17:29:11Z yannoo $
* @todo check the different @todos in this page and really do them
* @todo check if the news management works as expected
*/
@ -504,24 +504,35 @@ function display_anonymous_right_menu()
*/
function handle_login_failed()
{
switch ($_GET['error'])
if(!isset($_GET['error']))
{
case '':
$message = get_lang("InvalidId");
if (api_is_self_registration_allowed())
{
$message = get_lang("InvalidForSelfRegistration");
}
break;
case 'account_expired':
$message=get_lang('AccountExpired');
break;
case 'account_inactive':
$message=get_lang('AccountInactive');
break;
case 'user_password_incorrect':
$message=get_lang('InvalidId');
break;
$message = get_lang("InvalidId");
if (api_is_self_registration_allowed())
{
$message = get_lang("InvalidForSelfRegistration");
}
}
else
{
switch ($_GET['error'])
{
case '':
$message = get_lang("InvalidId");
if (api_is_self_registration_allowed())
{
$message = get_lang("InvalidForSelfRegistration");
}
break;
case 'account_expired':
$message=get_lang('AccountExpired');
break;
case 'account_inactive':
$message=get_lang('AccountInactive');
break;
case 'user_password_incorrect':
$message=get_lang('InvalidId');
break;
}
}
echo "<div id=\"login_fail\">".$message."</div>";
}

@ -87,13 +87,13 @@ function get_agendaitems($courses_dbs, $month, $year)
DISTINCT agenda.*, item_property.*
FROM ".$TABLEAGENDA." agenda,
".$TABLE_ITEMPROPERTY." item_property
WHERE agenda.id = item_property.ref ".$show_all_current."
WHERE agenda.id = item_property.ref
AND MONTH(agenda.start_date)='".$month."'
AND YEAR(agenda.start_date)='".$year."'
AND item_property.tool='".TOOL_CALENDAR_EVENT."'
AND item_property.visibility='1'
GROUP BY agenda.id
ORDER BY start_date ".$sort;
ORDER BY start_date ";
}
// if the user is not an administrator of that course
else
@ -133,6 +133,7 @@ function get_agendaitems($courses_dbs, $month, $year)
while ($item = mysql_fetch_array($result))
{
$agendaday = date("j",strtotime($item['start_date']));
if(!isset($items[$agendaday])){$items[$agendaday]=array();}
$time= date("H:i",strtotime($item['start_date']));
$URL = api_get_path(WEB_PATH)."main/calendar/agenda.php?cidReq=".urlencode($array_course_info["code"])."&amp;day=$agendaday&amp;month=$month&amp;year=$year#$agendaday"; // RH //Patrick Cool: to highlight the relevant agenda item
if ($setting_agenda_link == 'coursecode')
@ -144,13 +145,21 @@ function get_agendaitems($courses_dbs, $month, $year)
{
$agenda_link = Display::return_icon('course_home.gif');
}
$items[$agendaday][$item['start_time']] .= "<i>".$time."</i> <a href=\"$URL\" title=\"".$array_course_info["name"]."\">".$agenda_link."</a> ".$item['title']."<br />";
if(!isset($items[$agendaday][$item['start_date']]))
{
$items[$agendaday][$item['start_date']] = '';
}
$items[$agendaday][$item['start_date']] .= "<i>".$time."</i> <a href=\"$URL\" title=\"".Security::remove_XSS($array_course_info['title'])."\">".$agenda_link."</a> ".Security::remove_XSS($item['title'])."<br />";
}
}
// sorting by hour for every day
$agendaitems = array ();
while (list ($agendaday, $tmpitems) = each($items))
{
if(!isset($agendaitems[$agendaday]))
{
$agendaitems[$agendaday] = '';
}
sort($tmpitems);
while (list ($key, $val) = each($tmpitems))
{
@ -162,8 +171,14 @@ function get_agendaitems($courses_dbs, $month, $year)
}
/**
* Show the monthcalender of the given month
* @param array Agendaitems
* @param int Month number
* @param int Year number
* @param array Array of strings containing long week day names (deprecated, you can send an empty array instead)
* @param string The month name
* @return void Direct output
*/
function display_monthcalendar($agendaitems, $month, $year, $weekdaynames, $monthName)
function display_monthcalendar($agendaitems, $month, $year, $weekdaynames=array(), $monthName)
{
global $DaysShort,$course_path;
//Handle leap year
@ -174,8 +189,9 @@ function display_monthcalendar($agendaitems, $month, $year, $weekdaynames, $mont
$dayone = getdate(mktime(0, 0, 0, $month, 1, $year));
//Start the week on monday
$startdayofweek = $dayone['wday'] <> 0 ? ($dayone['wday'] - 1) : 6;
$backwardsURL = api_get_self()."?coursePath=".urlencode($course_path)."&amp;courseCode=".Security::remove_XSS($_GET['courseCode'])."&amp;action=view&amp;view=month&amp;month=". ($month == 1 ? 12 : $month -1)."&amp;year=". ($month == 1 ? $year -1 : $year);
$forewardsURL = api_get_self()."?coursePath=".urlencode($course_path)."&amp;courseCode=".Security::remove_XSS($_GET['courseCode'])."&amp;action=view&amp;view=month&amp;month=". ($month == 12 ? 1 : $month +1)."&amp;year=". ($month == 12 ? $year +1 : $year);
$g_cc = (isset($_GET['courseCode'])?$_GET['courseCode']:'');
$backwardsURL = api_get_self()."?coursePath=".urlencode($course_path)."&amp;courseCode=".Security::remove_XSS($g_cc)."&amp;action=view&amp;view=month&amp;month=". ($month == 1 ? 12 : $month -1)."&amp;year=". ($month == 1 ? $year -1 : $year);
$forewardsURL = api_get_self()."?coursePath=".urlencode($course_path)."&amp;courseCode=".Security::remove_XSS($g_cc)."&amp;action=view&amp;view=month&amp;month=". ($month == 12 ? 1 : $month +1)."&amp;year=". ($month == 12 ? $year +1 : $year);
echo "<table id=\"agenda_list\">\n", "<tr class=\"title\">\n", "<td width=\"10%\"><a href=\"", $backwardsURL, "\">&#171;</a></td>\n", "<td width=\"80%\" colspan=\"5\">", $monthName, " ", $year, "</td>\n", "<td width=\"10%\"><a href=\"", $forewardsURL, "\">&#187;</a></td>\n", "</tr>\n";
@ -200,7 +216,7 @@ function display_monthcalendar($agendaitems, $month, $year, $weekdaynames, $mont
{
$bgcolor = $ii < 5 ? $class = "class=\"days_week\"" : $class = "class=\"days_weekend\"";
$dayheader = "<b>$curday</b>";
if (($curday == $today[mday]) && ($year == $today[year]) && ($month == $today[mon]))
if (($curday == $today['mday']) && ($year == $today['year']) && ($month == $today['mon']))
{
$dayheader = "$curday - ".get_lang("Today")."<br />";
$class = "class=\"days_today\"";
@ -236,8 +252,9 @@ function display_minimonthcalendar($agendaitems, $month, $year, $monthName)
$dayone = getdate(mktime(0, 0, 0, $month, 1, $year));
//Start the week on monday
$startdayofweek = $dayone['wday'] <> 0 ? ($dayone['wday'] - 1) : 6;
$backwardsURL = api_get_self()."?coursePath=".urlencode($course_path)."&amp;courseCode=".Security::remove_XSS($_GET['courseCode'])."&amp;month=". ($month == 1 ? 12 : $month -1)."&amp;year=". ($month == 1 ? $year -1 : $year);
$forewardsURL = api_get_self()."?coursePath=".urlencode($course_path)."&amp;courseCode=".Security::remove_XSS($_GET['courseCode'])."&amp;month=". ($month == 12 ? 1 : $month +1)."&amp;year=". ($month == 12 ? $year +1 : $year);
$g_cc = (isset($_GET['courseCode'])?$_GET['courseCode']:'');
$backwardsURL = api_get_self()."?coursePath=".urlencode($course_path)."&amp;courseCode=".Security::remove_XSS($g_cc)."&amp;month=". ($month == 1 ? 12 : $month -1)."&amp;year=". ($month == 1 ? $year -1 : $year);
$forewardsURL = api_get_self()."?coursePath=".urlencode($course_path)."&amp;courseCode=".Security::remove_XSS($g_cc)."&amp;month=". ($month == 12 ? 1 : $month +1)."&amp;year=". ($month == 12 ? $year +1 : $year);
echo "<table id=\"smallcalendar\">\n", "<tr class=\"title\">\n", "<td width=\"10%\"><a href=\"", $backwardsURL, "\">&#171;</a></td>\n", "<td width=\"80%\" colspan=\"5\">", $monthName, " ", $year, "</td>\n", "<td width=\"10%\"><a href=\"", $forewardsURL, "\">&#187;</a></td>\n", "</tr>\n";
@ -262,13 +279,13 @@ function display_minimonthcalendar($agendaitems, $month, $year, $monthName)
{
$bgcolor = $ii < 5 ? $class = "class=\"days_week\"" : $class = "class=\"days_weekend\"";
$dayheader = "$curday";
if (($curday == $today[mday]) && ($year == $today[year]) && ($month == $today[mon]))
if (($curday == $today['mday']) && ($year == $today['year']) && ($month == $today['mon']))
{
$dayheader = "$curday";
$class = "class=\"days_today\"";
}
echo "\t<td ".$class.">";
if ($agendaitems[$curday] <> "")
if (!empty($agendaitems[$curday]))
{
echo "<a href=\"".api_get_self()."?action=view&amp;view=day&amp;day=".$curday."&amp;month=".$month."&amp;year=".$year."\">".$dayheader."</a>";
}
@ -1157,4 +1174,4 @@ function calculate_start_end_of_week($week_number, $year)
$start_end_array['end']['year'] = $end_year;
return $start_end_array;
}
?>
?>

@ -118,7 +118,7 @@ $MonthsLong = array (get_lang("JanuaryLong"), get_lang("FebruaryLong"), get_lang
6. delete personal agenda
============================================================================== */
// 1. The default values. if there is no session yet, we have by default the month view
if (!$_SESSION['view'])
if (empty($_SESSION['view']))
{
$_SESSION['view'] = "month";
}
@ -243,7 +243,7 @@ if (isset ($_user['user_id']))
{
$agendaitems = get_personal_agenda_items($agendaitems, $day, $month, $year, $week, "month_view");
}
display_monthcalendar($agendaitems, $month, $year, $langDay_of_weekNames['long'], $monthName);
display_monthcalendar($agendaitems, $month, $year, array(), $monthName);
break;
case "week_view" :
$agendaitems = get_week_agendaitems($courses_dbs, $month, $year, $week);
@ -251,7 +251,7 @@ if (isset ($_user['user_id']))
{
$agendaitems = get_personal_agenda_items($agendaitems, $day, $month, $year, $week, "week_view");
}
display_weekcalendar($agendaitems, $month, $year, $langDay_of_weekNames['long'], $monthName);
display_weekcalendar($agendaitems, $month, $year, array(), $monthName);
break;
case "day_view" :
$agendaitems = get_day_agendaitems($courses_dbs, $month, $year, $day);
@ -259,7 +259,7 @@ if (isset ($_user['user_id']))
{
$agendaitems = get_personal_agenda_items($agendaitems, $day, $month, $year, $week, "day_view");
}
display_daycalendar($agendaitems, $day, $month, $year, $langDay_of_weekNames['long'], $monthName);
display_daycalendar($agendaitems, $day, $month, $year, array(), $monthName);
break;
case "personal_view" :
show_personal_agenda();

@ -259,7 +259,14 @@ function api_get_navigator()
*/
function api_is_self_registration_allowed()
{
return $GLOBALS["allowSelfReg"];
if(isset($GLOBALS['allowSelfReg']))
{
return $GLOBALS["allowSelfReg"];
}
else
{
return false;
}
}
/**
* Returns a full path to a certain Dokeos area, which you specify

Loading…
Cancel
Save