[svn r20444] FS#306 - The Agenda tool: Improvements for better encoding management.

skala
Ivan Tcholakov 17 years ago
parent ea5faceb57
commit 0c89c52b51
  1. 36
      main/calendar/agenda.inc.php
  2. 10
      main/calendar/ical_export.php
  3. 6
      main/calendar/myagenda.inc.php
  4. 4
      main/calendar/myagenda.php
  5. 12
      main/calendar/print.php

@ -1,4 +1,4 @@
<?php //$Id: agenda.inc.php 20101 2009-04-25 01:05:54Z yannoo $ <?php //$Id: agenda.inc.php 20444 2009-05-10 09:18:51Z ivantcholakov $
/* /*
============================================================================== ==============================================================================
@ -2049,7 +2049,7 @@ function display_agenda_items()
{ {
$month_bar = date("m",strtotime($myrow["start_date"])).date("Y",strtotime($myrow["start_date"])); $month_bar = date("m",strtotime($myrow["start_date"])).date("Y",strtotime($myrow["start_date"]));
echo "\t<tr>\n\t\t<td class=\"agenda_month_divider\" colspan=\"3\" valign=\"top\">". echo "\t<tr>\n\t\t<td class=\"agenda_month_divider\" colspan=\"3\" valign=\"top\">".
ucfirst(format_locale_date("%B %Y",strtotime($myrow["start_date"]))). api_ucfirst(format_locale_date("%B %Y",strtotime($myrow["start_date"]))).
"</td>\n\t</tr>\n"; "</td>\n\t</tr>\n";
} }
@ -2118,15 +2118,15 @@ function display_agenda_items()
--------------------------------------------------*/ --------------------------------------------------*/
echo "<tr class='row_odd'>"; echo "<tr class='row_odd'>";
echo "\t\t<td>".get_lang("StartTimeWindow").": "; echo "\t\t<td>".get_lang("StartTimeWindow").": ";
echo ucfirst(format_locale_date($dateFormatLong,strtotime($myrow["start_date"])))."&nbsp;&nbsp;&nbsp;"; echo api_ucfirst(format_locale_date($dateFormatLong,strtotime($myrow["start_date"])))."&nbsp;&nbsp;&nbsp;";
echo ucfirst(strftime($timeNoSecFormat,strtotime($myrow["start_date"]))).""; echo api_ucfirst(strftime($timeNoSecFormat,strtotime($myrow["start_date"])))."";
echo "</td>\n"; echo "</td>\n";
echo "\t\t<td>"; echo "\t\t<td>";
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 ucfirst(format_locale_date($dateFormatLong,strtotime($myrow["end_date"])))."&nbsp;&nbsp;&nbsp;"; echo api_ucfirst(format_locale_date($dateFormatLong,strtotime($myrow["end_date"])))."&nbsp;&nbsp;&nbsp;";
echo ucfirst(strftime($timeNoSecFormat,strtotime($myrow["end_date"]))).""; echo api_ucfirst(strftime($timeNoSecFormat,strtotime($myrow["end_date"])))."";
} }
echo "</td>\n"; echo "</td>\n";
@ -2148,7 +2148,7 @@ function display_agenda_items()
echo '<a href="'.$mylink.'&amp;action=edit&amp;id_attach='.$attachment_list['id'].'" title="'.get_lang("ModifyCalendarItem").'">'; echo '<a href="'.$mylink.'&amp;action=edit&amp;id_attach='.$attachment_list['id'].'" title="'.get_lang("ModifyCalendarItem").'">';
echo Display::return_icon('edit.gif', get_lang('ModifyCalendarItem'))."</a>"; echo Display::return_icon('edit.gif', get_lang('ModifyCalendarItem'))."</a>";
echo "<a href=\"".$mylink."&amp;action=delete\" onclick=\"javascript:if(!confirm('".addslashes(htmlentities(get_lang("ConfirmYourChoice"),ENT_QUOTES,$charset))."')) return false;\" title=\"".get_lang("Delete")."\"> "; echo "<a href=\"".$mylink."&amp;action=delete\" onclick=\"javascript:if(!confirm('".addslashes(api_htmlentities(get_lang("ConfirmYourChoice"),ENT_QUOTES,$charset))."')) return false;\" title=\"".get_lang("Delete")."\"> ";
echo Display::return_icon('delete.gif', get_lang('Delete'))."</a>"; echo Display::return_icon('delete.gif', get_lang('Delete'))."</a>";
echo '<a href="'.$mylink.'&amp;action=announce" title="'.get_lang("AddAnnouncement").'">'; echo '<a href="'.$mylink.'&amp;action=announce" title="'.get_lang("AddAnnouncement").'">';
@ -2213,7 +2213,7 @@ function display_agenda_items()
echo ' "> '.$user_filename.' </a>'; echo ' "> '.$user_filename.' </a>';
echo '<span class="forum_attach_comment" >'.$attachment_list['comment'].'</span>'; echo '<span class="forum_attach_comment" >'.$attachment_list['comment'].'</span>';
if (api_is_allowed_to_edit()) { if (api_is_allowed_to_edit()) {
echo '&nbsp;&nbsp;<a href="'.api_get_self().'?'.api_get_cidreq().'&amp;origin='.Security::remove_XSS($_GET['origin']).'&amp;action=delete_attach&amp;id_attach='.$attachment_list['id'].'" onclick="javascript:if(!confirm(\''.addslashes(htmlentities(get_lang("ConfirmYourChoice"),ENT_QUOTES,$charset)).'\')) return false;">'.Display::return_icon('delete.gif',get_lang('Delete')).'</a><br />'; echo '&nbsp;&nbsp;<a href="'.api_get_self().'?'.api_get_cidreq().'&amp;origin='.Security::remove_XSS($_GET['origin']).'&amp;action=delete_attach&amp;id_attach='.$attachment_list['id'].'" onclick="javascript:if(!confirm(\''.addslashes(api_htmlentities(get_lang("ConfirmYourChoice"),ENT_QUOTES,$charset)).'\')) return false;">'.Display::return_icon('delete.gif',get_lang('Delete')).'</a><br />';
} }
} }
@ -2254,7 +2254,7 @@ function display_agenda_items()
if(!empty($event_list)) if(!empty($event_list))
{ {
$event_list=substr($event_list,0,-1); $event_list=api_substr($event_list,0,-1);
} }
else else
{ {
@ -2410,12 +2410,12 @@ function display_one_agenda_item($agenda_id)
--------------------------------------------------*/ --------------------------------------------------*/
echo "\t<tr class='row_odd'>\n"; echo "\t<tr class='row_odd'>\n";
echo "\t\t<td>".get_lang("StartTime").": "; echo "\t\t<td>".get_lang("StartTime").": ";
echo ucfirst(format_locale_date($dateFormatLong,strtotime($myrow["start_date"])))."&nbsp;&nbsp;&nbsp;"; echo api_ucfirst(format_locale_date($dateFormatLong,strtotime($myrow["start_date"])))."&nbsp;&nbsp;&nbsp;";
echo ucfirst(strftime($timeNoSecFormat,strtotime($myrow["start_date"]))).""; echo api_ucfirst(strftime($timeNoSecFormat,strtotime($myrow["start_date"])))."";
echo "</td>\n"; echo "</td>\n";
echo "\t\t<td>".get_lang("EndTime").": "; echo "\t\t<td>".get_lang("EndTime").": ";
echo ucfirst(format_locale_date($dateFormatLong,strtotime($myrow["end_date"])))."&nbsp;&nbsp;&nbsp;"; echo api_ucfirst(format_locale_date($dateFormatLong,strtotime($myrow["end_date"])))."&nbsp;&nbsp;&nbsp;";
echo ucfirst(strftime($timeNoSecFormat,strtotime($myrow["end_date"]))).""; echo api_ucfirst(strftime($timeNoSecFormat,strtotime($myrow["end_date"])))."";
echo "</td>\n"; echo "</td>\n";
/*-------------------------------------------------- /*--------------------------------------------------
@ -2431,7 +2431,7 @@ function display_one_agenda_item($agenda_id)
$mylink = api_get_self()."?".api_get_cidreq()."&amp;origin=".Security::remove_XSS($_GET['origin'])."&amp;id=".$myrow['id']; $mylink = api_get_self()."?".api_get_cidreq()."&amp;origin=".Security::remove_XSS($_GET['origin'])."&amp;id=".$myrow['id'];
echo "<a href=\"".$mylink."&amp;action=edit\">", echo "<a href=\"".$mylink."&amp;action=edit\">",
Display::return_icon('edit.gif', get_lang('ModifyCalendarItem')), "</a>", Display::return_icon('edit.gif', get_lang('ModifyCalendarItem')), "</a>",
"<a href=\"".$mylink."&amp;action=delete\" onclick=\"javascript:if(!confirm('".addslashes(htmlentities(get_lang("ConfirmYourChoice"),ENT_QUOTES,$charset))."')) return false;\">", "<a href=\"".$mylink."&amp;action=delete\" onclick=\"javascript:if(!confirm('".addslashes(api_htmlentities(get_lang("ConfirmYourChoice"),ENT_QUOTES,$charset))."')) return false;\">",
Display::return_icon('delete.gif', get_lang('Delete')),"</a>"; Display::return_icon('delete.gif', get_lang('Delete')),"</a>";
if ($myrow['visibility']==1) { if ($myrow['visibility']==1) {
$image_visibility="visible"; $image_visibility="visible";
@ -3462,7 +3462,7 @@ function get_day_agendaitems($courses_dbs, $month, $year, $day)
if ($setting_agenda_link == 'coursecode') if ($setting_agenda_link == 'coursecode')
{ {
$title=$array_course_info['title']; $title=$array_course_info['title'];
$agenda_link = substr($title, 0, 14); $agenda_link = api_substr($title, 0, 14);
} }
else else
{ {
@ -3580,7 +3580,7 @@ function get_week_agendaitems($courses_dbs, $month, $year, $week = '')
if ($setting_agenda_link == 'coursecode') if ($setting_agenda_link == 'coursecode')
{ {
$title=$array_course_info['title']; $title=$array_course_info['title'];
$agenda_link = substr($title, 0, 14); $agenda_link = api_substr($title, 0, 14);
} }
else else
{ {
@ -4650,9 +4650,9 @@ function agenda_import_ical($course_info,$file)
$ve = $ical->getComponent(0); $ve = $ical->getComponent(0);
//print_r($ve); //print_r($ve);
$ttitle = $ve->getProperty('summary'); $ttitle = $ve->getProperty('summary');
$title = mb_convert_encoding($ttitle,$charset,'UTF-8'); $title = api_convert_encoding($ttitle,$charset,'UTF-8');
$tdesc = $ve->getProperty('description'); $tdesc = $ve->getProperty('description');
$desc = mb_convert_encoding($tdesc,$charset,'UTF-8'); $desc = api_convert_encoding($tdesc,$charset,'UTF-8');
$ts = $ve->getProperty('dtstart'); $ts = $ve->getProperty('dtstart');
$start_date = $ts['year'].'-'.$ts['month'].'-'.$ts['day'].' '.$ts['hour'].':'.$ts['min'].':'.$ts['sec']; $start_date = $ts['year'].'-'.$ts['month'].'-'.$ts['day'].' '.$ts['hour'].':'.$ts['min'].':'.$ts['sec'];
$ts = $ve->getProperty('dtend'); $ts = $ve->getProperty('dtend');

@ -66,7 +66,7 @@ if(!empty($_GET['id']) && $_GET['id']==strval(intval($_GET['id'])))
case 'personal': case 'personal':
require_once (api_get_path(SYS_CODE_PATH).'calendar/myagenda.inc.php'); require_once (api_get_path(SYS_CODE_PATH).'calendar/myagenda.inc.php');
$ai = get_personal_agenda_item($_GET['id']); $ai = get_personal_agenda_item($_GET['id']);
$vevent->setProperty( 'summary', mb_convert_encoding($ai['title'],'UTF-8',$charset)); $vevent->setProperty( 'summary', api_convert_encoding($ai['title'],'UTF-8',$charset));
if(empty($ai['date'])){header('location:'.$_SERVER['HTTP_REFERER']);} if(empty($ai['date'])){header('location:'.$_SERVER['HTTP_REFERER']);}
list($y,$m,$d,$h,$M,$s) = preg_split('/[\s:-]/',$ai['date']); list($y,$m,$d,$h,$M,$s) = preg_split('/[\s:-]/',$ai['date']);
$vevent->setProperty('dtstart',array('year'=>$y,'month'=>$m,'day'=>$d,'hour'=>$h,'min'=>$M,'sec'=>$s)); $vevent->setProperty('dtstart',array('year'=>$y,'month'=>$m,'day'=>$d,'hour'=>$h,'min'=>$M,'sec'=>$s));
@ -81,7 +81,7 @@ if(!empty($_GET['id']) && $_GET['id']==strval(intval($_GET['id'])))
} }
$vevent->setProperty('dtend',array('year'=>$y2,'month'=>$m2,'day'=>$d2,'hour'=>$h2,'min'=>$M2,'sec'=>$s2)); $vevent->setProperty('dtend',array('year'=>$y2,'month'=>$m2,'day'=>$d2,'hour'=>$h2,'min'=>$M2,'sec'=>$s2));
//$vevent->setProperty( 'LOCATION', get_lang('Unknown') ); // property name - case independent //$vevent->setProperty( 'LOCATION', get_lang('Unknown') ); // property name - case independent
$vevent->setProperty( 'description', mb_convert_encoding($ai['text'],'UTF-8',$charset)); $vevent->setProperty( 'description', api_convert_encoding($ai['text'],'UTF-8',$charset));
//$vevent->setProperty( 'comment', 'This is a comment' ); //$vevent->setProperty( 'comment', 'This is a comment' );
$user = api_get_user_info($ai['user']); $user = api_get_user_info($ai['user']);
$vevent->setProperty('organizer',$user['mail']); $vevent->setProperty('organizer',$user['mail']);
@ -96,7 +96,7 @@ if(!empty($_GET['id']) && $_GET['id']==strval(intval($_GET['id'])))
$TABLE_ITEM_PROPERTY = Database::get_course_table(TABLE_ITEM_PROPERTY); $TABLE_ITEM_PROPERTY = Database::get_course_table(TABLE_ITEM_PROPERTY);
require_once (api_get_path(SYS_CODE_PATH).'calendar/agenda.inc.php'); require_once (api_get_path(SYS_CODE_PATH).'calendar/agenda.inc.php');
$ai = get_agenda_item($_GET['id']); $ai = get_agenda_item($_GET['id']);
$vevent->setProperty( 'summary', mb_convert_encoding($ai['title'],'UTF-8',$charset)); $vevent->setProperty( 'summary', api_convert_encoding($ai['title'],'UTF-8',$charset));
if(empty($ai['start_date'])){header('location:'.$_SERVER['HTTP_REFERER']);} if(empty($ai['start_date'])){header('location:'.$_SERVER['HTTP_REFERER']);}
list($y,$m,$d,$h,$M,$s) = preg_split('/[\s:-]/',$ai['start_date']); list($y,$m,$d,$h,$M,$s) = preg_split('/[\s:-]/',$ai['start_date']);
$vevent->setProperty('dtstart',array('year'=>$y,'month'=>$m,'day'=>$d,'hour'=>$h,'min'=>$M,'sec'=>$s)); $vevent->setProperty('dtstart',array('year'=>$y,'month'=>$m,'day'=>$d,'hour'=>$h,'min'=>$M,'sec'=>$s));
@ -110,7 +110,7 @@ if(!empty($_GET['id']) && $_GET['id']==strval(intval($_GET['id'])))
list($y2,$m2,$d2,$h2,$M2,$s2) = preg_split('/[\s:-]/',$ai['end_date']); list($y2,$m2,$d2,$h2,$M2,$s2) = preg_split('/[\s:-]/',$ai['end_date']);
} }
$vevent->setProperty('dtend',array('year'=>$y2,'month'=>$m2,'day'=>$d2,'hour'=>$h2,'min'=>$M2,'sec'=>$s2)); $vevent->setProperty('dtend',array('year'=>$y2,'month'=>$m2,'day'=>$d2,'hour'=>$h2,'min'=>$M2,'sec'=>$s2));
$vevent->setProperty( 'description', mb_convert_encoding($ai['content'],'UTF-8',$charset)); $vevent->setProperty( 'description', api_convert_encoding($ai['content'],'UTF-8',$charset));
//$vevent->setProperty( 'comment', 'This is a comment' ); //$vevent->setProperty( 'comment', 'This is a comment' );
$user = api_get_user_info($ai['user']); $user = api_get_user_info($ai['user']);
$vevent->setProperty('organizer',$user['mail']); $vevent->setProperty('organizer',$user['mail']);
@ -140,4 +140,4 @@ else
header('location:'.$_SERVER['HTTP_REFERER']); header('location:'.$_SERVER['HTTP_REFERER']);
die(); die();
} }
?> ?>

@ -139,7 +139,7 @@ function get_myagendaitems($courses_dbs, $month, $year)
if ($setting_agenda_link == 'coursecode') if ($setting_agenda_link == 'coursecode')
{ {
$title=$array_course_info['title']; $title=$array_course_info['title'];
$agenda_link = substr($title, 0, 14); $agenda_link = api_substr($title, 0, 14);
} }
else else
{ {
@ -748,7 +748,7 @@ function show_personal_agenda()
// adding an internal anchor // adding an internal anchor
echo "<a name=\"".$myrow["id"]."\"></a>"; echo "<a name=\"".$myrow["id"]."\"></a>";
echo date("d", strtotime($myrow["date"]))." ".$MonthsLong[date("n", strtotime($myrow["date"])) - 1]." ".date("Y", strtotime($myrow["date"]))."&nbsp;"; echo date("d", strtotime($myrow["date"]))." ".$MonthsLong[date("n", strtotime($myrow["date"])) - 1]." ".date("Y", strtotime($myrow["date"]))."&nbsp;";
echo ucfirst(strftime(get_lang("timeNoSecFormat"), strtotime($myrow["date"]))); echo api_ucfirst(strftime(get_lang("timeNoSecFormat"), strtotime($myrow["date"])));
echo "</td>"; echo "</td>";
echo '<td class="'.$style.'">'; echo '<td class="'.$style.'">';
echo '<a class="ical_export" href="ical_export.php?type=personal&id='.$myrow['id'].'&class=confidential" title="'.get_lang('ExportiCalConfidential').'">'.Display::return_icon($export_icon_high, get_lang('ExportiCalConfidential')).'</a>'; echo '<a class="ical_export" href="ical_export.php?type=personal&id='.$myrow['id'].'&class=confidential" title="'.get_lang('ExportiCalConfidential').'">'.Display::return_icon($export_icon_high, get_lang('ExportiCalConfidential')).'</a>';
@ -778,7 +778,7 @@ function show_personal_agenda()
--------------------------------------------------*/ --------------------------------------------------*/
echo "\t<tr>\n\t\t<td class=\"".$text_style."\" colspan='2'>"; echo "\t<tr>\n\t\t<td class=\"".$text_style."\" colspan='2'>";
echo "<a href=\"myagenda.php?action=edit_personal_agenda_item&amp;id=".$myrow['id']."\">".Display::return_icon('edit.gif', get_lang('Edit'))."</a>"; echo "<a href=\"myagenda.php?action=edit_personal_agenda_item&amp;id=".$myrow['id']."\">".Display::return_icon('edit.gif', get_lang('Edit'))."</a>";
echo "<a href=\"".api_get_self()."?action=delete&amp;id=".$myrow['id']."\" onclick=\"javascript:if(!confirm('".addslashes(htmlentities(get_lang('ConfirmYourChoice'),ENT_QUOTES,$charset))."')) return false;\">".Display::return_icon('delete.gif', get_lang('Delete'))."</a>"; echo "<a href=\"".api_get_self()."?action=delete&amp;id=".$myrow['id']."\" onclick=\"javascript:if(!confirm('".addslashes(api_htmlentities(get_lang('ConfirmYourChoice'),ENT_QUOTES,$charset))."')) return false;\">".Display::return_icon('delete.gif', get_lang('Delete'))."</a>";
echo "</td></tr>"; echo "</td></tr>";
} }
} }

@ -1,4 +1,4 @@
<?php //$Id: myagenda.php 20343 2009-05-05 20:31:47Z juliomontoya $ <?php //$Id: myagenda.php 20444 2009-05-10 09:18:51Z ivantcholakov $
/* /*
============================================================================== ==============================================================================
Dokeos - elearning and course management software Dokeos - elearning and course management software
@ -78,7 +78,7 @@ $nameTools = get_lang('MyAgenda');
// if we come from inside a course and click on the 'My Agenda' link we show a link back to the course // if we come from inside a course and click on the 'My Agenda' link we show a link back to the course
// in the breadcrumbs // in the breadcrumbs
if(!empty($_GET['coursePath'])) { if(!empty($_GET['coursePath'])) {
$course_path = htmlentities(strip_tags($_GET['coursePath']),ENT_QUOTES,$charset); $course_path = api_htmlentities(strip_tags($_GET['coursePath']),ENT_QUOTES,$charset);
$course_path = str_replace(array('../','..\\'),array('',''),$course_path); $course_path = str_replace(array('../','..\\'),array('',''),$course_path);
} }

@ -41,7 +41,7 @@ $result = api_sql_query($sql,__FILE__,__LINE__);
<body style="margin: 15px; padding: 0px;"> <body style="margin: 15px; padding: 0px;">
<center> <center>
<input type="button" value="<?php echo htmlentities(get_lang('Print'),ENT_QUOTES,$charset); ?>" onClick="javascript:window.print();" /> <input type="button" value="<?php echo api_htmlentities(get_lang('Print'),ENT_QUOTES,$charset); ?>" onClick="javascript:window.print();" />
</center> </center>
<br /><br /> <br /><br />
@ -60,15 +60,15 @@ while($row=Database::fetch_array($result))
echo get_lang('StartTime').' : '; echo get_lang('StartTime').' : ';
echo ucfirst(format_locale_date($dateFormatLong,strtotime($row["start_date"])))."&nbsp;&nbsp;&nbsp;"; echo api_ucfirst(format_locale_date($dateFormatLong,strtotime($row["start_date"])))."&nbsp;&nbsp;&nbsp;";
echo ucfirst(strftime($timeNoSecFormat,strtotime($row["start_date"]))).""; echo api_ucfirst(strftime($timeNoSecFormat,strtotime($row["start_date"])))."";
echo '<br />'; echo '<br />';
echo get_lang('EndTime').' : '; echo get_lang('EndTime').' : ';
echo ucfirst(format_locale_date($dateFormatLong,strtotime($row["end_date"])))."&nbsp;&nbsp;&nbsp;"; echo api_ucfirst(format_locale_date($dateFormatLong,strtotime($row["end_date"])))."&nbsp;&nbsp;&nbsp;";
echo ucfirst(strftime($timeNoSecFormat,strtotime($row["end_date"]))).""; echo api_ucfirst(strftime($timeNoSecFormat,strtotime($row["end_date"])))."";
echo '<br /><br />'; echo '<br /><br />';
@ -78,7 +78,7 @@ while($row=Database::fetch_array($result))
<br /><br /> <br /><br />
<center> <center>
<input type="button" value="<?php echo htmlentities(get_lang('Print'),ENT_QUOTES,$charset); ?>" onClick="javascript:window.print();" /> <input type="button" value="<?php echo api_htmlentities(get_lang('Print'),ENT_QUOTES,$charset); ?>" onClick="javascript:window.print();" />
</center> </center>
</body> </body>

Loading…
Cancel
Save