From 7285c4849e657bfba085069d68cf87b6099b644c Mon Sep 17 00:00:00 2001 From: Julio Montoya Date: Thu, 21 Apr 2011 16:33:59 +0200 Subject: [PATCH] More fixes in the agenda and announcements tools --- main/announcements/announcements.inc.php | 2 +- main/announcements/announcements.php | 8 +- main/calendar/agenda.inc.php | 111 ++++++++++------------- 3 files changed, 51 insertions(+), 70 deletions(-) diff --git a/main/announcements/announcements.inc.php b/main/announcements/announcements.inc.php index d4fb07584c..eea4becdaa 100755 --- a/main/announcements/announcements.inc.php +++ b/main/announcements/announcements.inc.php @@ -148,7 +148,7 @@ class AnnouncementManager { if (api_is_allowed_to_edit(false,true) || (api_get_course_setting('allow_user_edit_announcement') && !api_is_anonymous())) { $modify_icons = "".Display::return_icon('edit.png', get_lang('Edit'),'',22).""; - if ($myrow['visibility']==1) { + if ($result['visibility'] == 1) { $image_visibility="visible"; $alt_visibility=get_lang('Hide'); } else { diff --git a/main/announcements/announcements.php b/main/announcements/announcements.php index 968f8330bd..141bd6385a 100755 --- a/main/announcements/announcements.php +++ b/main/announcements/announcements.php @@ -1331,14 +1331,14 @@ if ($display_announcement_list && !$surveyid) { // DISPLAY MOVE UP COMMAND only if it is not the top announcement if ($iterator != 1) { - $modify_icons .= "".Display::return_icon('up.gif', get_lang('Up')).""; + $modify_icons .= "".Display::return_icon('up.gif', get_lang('Up')).""; } else { - $modify_icons .= Display::return_icon('up_na.gif', get_lang('Up')); + $modify_icons .= Display::return_icon('up_na.gif', get_lang('Up')); } if ($iterator < $bottomAnnouncement) { - $modify_icons .= "".Display::return_icon('down.gif', get_lang('Down')).""; + $modify_icons .= "".Display::return_icon('down.gif', get_lang('Down')).""; } else { - $modify_icons .= Display::return_icon('down_na.gif', get_lang('Down')); + $modify_icons .= Display::return_icon('down_na.gif', get_lang('Down')); } if (api_is_allowed_to_edit(false,true)) { diff --git a/main/calendar/agenda.inc.php b/main/calendar/agenda.inc.php index 52379757ac..6726718cdd 100755 --- a/main/calendar/agenda.inc.php +++ b/main/calendar/agenda.inc.php @@ -1783,54 +1783,35 @@ function display_agenda_items($agenda_items, $day = false) { } if ($_GET['sort'] == 'asc') { - $sort = 'desc'; + $sort_inverse = 'desc'; + $sort = 'asc'; } else { - $sort = 'asc'; + $sort_inverse = 'asc'; + $sort = 'desc'; } if ($_GET['col'] == 'end') { $sort_item = 'end_date_tms'; + $col = 'end'; } else { $sort_item = 'start_date_tms'; + $col = 'start'; } - - //Ordering - //var_dump($agenda_items); - - /*$ordering_array = array(); - foreach ($agenda_items as $item) { - $date = intval(api_strtotime($item['start_date'])); - if ($sort_item == 'end') { - if (!empty($item['end_date'] && )) - $date = intval(api_strtotime($item['end_date'])); - } - $ordering_array[$date] = $item; - } - - if ($sort == 'ASC') { - krsort($ordering_array); - } else { - ksort($ordering_array); - }*/ - + $agenda_items = msort($agenda_items, $sort_item, $sort); - - //var_dump($sort_item); - //$agenda_items = $ordering_array; //DISPLAY: NO ITEMS if (empty($agenda_items)) { echo Display::display_warning_message(get_lang('NoAgendaItems')); - } else { - + } else { echo ''; $th = Display::tag('th', get_lang('Title')); //$th .= Display::tag('th', get_lang('Content')); $url = api_get_self().'?'.api_get_cidreq().'&month='.intval($_GET['month']).'&year='.intval($_GET['year']).'&day='.intval($_GET['day']); - $th .= Display::tag('th', Display::url(get_lang('StartTimeWindow'), $url.'&sort='.$sort.'&col=start')); - $th .= Display::tag('th', Display::url(get_lang('EndTimeWindow'), $url.'&sort='.$sort.'&col=end')); + $th .= Display::tag('th', Display::url(get_lang('StartTimeWindow'), $url.'&sort='.$sort_inverse.'&col=start')); + $th .= Display::tag('th', Display::url(get_lang('EndTimeWindow'), $url.'&sort='.$sort_inverse.'&col=end')); if ((api_is_allowed_to_edit(false,true) OR (api_get_course_setting('allow_user_edit_agenda') && !api_is_anonymous()))) { if (!(api_is_course_coach() && !api_is_element_in_the_session(TOOL_AGENDA, $myrow['id']))) { @@ -1906,40 +1887,40 @@ function display_agenda_items($agenda_items, $day = false) { 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'].'&'; + $mylink = api_get_self().'?'.api_get_cidreq().'&origin='.Security::remove_XSS($_GET['origin']).'&id='.$myrow['id'].'&sort='.$sort.'&col='.$col.'&'; // edit - echo ''; + echo ''; echo Display::return_icon('edit.png', get_lang('ModifyCalendarItem'),'',22).""; - echo ''; + echo ''; echo Display::return_icon('new_announce.png', get_lang('AddAnnouncement'), array (),22)." "; - if ($myrow['visibility']==1) { - $image_visibility="visible"; - $text_visibility=get_lang("Hide"); + if ($myrow['visibility'] == 1) { + $image_visibility = "visible"; + $text_visibility = get_lang("Hide"); $next_action = 0; } else { - $image_visibility="invisible"; - $text_visibility=get_lang("Show"); + $image_visibility = "invisible"; + $text_visibility = get_lang("Show"); $next_action = 1; } - echo ''.Display::return_icon($image_visibility.'.png', $text_visibility,'',22).' '; - echo " "; + echo ''.Display::return_icon($image_visibility.'.png', $text_visibility,'',22).' '; + echo " "; echo Display::return_icon('delete.png', get_lang('Delete'),'',22)." "; } - $mylink = 'ical_export.php?'.api_get_cidreq().'&type=course&id='.$myrow['id']; - //echo ''.Display::return_icon($export_icon_high, get_lang('ExportiCalConfidential')).' '; - //echo ''.Display::return_icon($export_icon_low, get_lang('ExportiCalPrivate')).' '; - //echo ''.Display::return_icon($export_icon, get_lang('ExportiCalPublic')).' '; + $mylink = 'ical_export.php?'.api_get_cidreq().'&type=course&id='.$myrow['id']; + //echo ''.Display::return_icon($export_icon_high, get_lang('ExportiCalConfidential')).' '; + //echo ''.Display::return_icon($export_icon_low, get_lang('ExportiCalPrivate')).' '; + //echo ''.Display::return_icon($export_icon, get_lang('ExportiCalPublic')).' '; echo ''.Display::return_icon('printer.png', get_lang('Print'),'',22).' '; echo ''; } else { if ($is_repeated && (api_is_allowed_to_edit(false,true)) || (api_get_course_setting('allow_user_edit_agenda') && !api_is_anonymous()) ) { echo ''; } @@ -2102,7 +2083,7 @@ function display_one_agenda_item($agenda_id) { echo '"; } @@ -2171,7 +2152,7 @@ function display_one_agenda_item($agenda_id) { echo Display::return_icon('attachment.gif',get_lang('Attachment')); echo ' '.$user_filename.''; if (api_is_allowed_to_edit()) { - echo '  '.Display::return_icon('delete.png',get_lang('Delete'),'',22).'
'; + echo '  '.Display::return_icon('delete.png',get_lang('Delete'),'',22).'
'; } echo '
'.$attachment_list['comment'].''; echo ''; @@ -2320,7 +2301,7 @@ function show_add_form($id = '') { - " method="post" name="new_calendar_item"> + " method="post" name="new_calendar_item"> @@ -2410,7 +2391,7 @@ function show_add_form($id = '') { 'vertical-align: middle;')); ?> -    +    'vertical-align: middle;')); ?> -    +   
'; - echo get_lang('RepeatedEvent'),' ',get_lang('RepeatedEventViewOriginalEvent'),''; + echo get_lang('RepeatedEvent'),' ',get_lang('RepeatedEventViewOriginalEvent'),''; echo ''; if (!$repeat && api_is_allowed_to_edit(false,true)) { // edit - $mylink = api_get_self()."?".api_get_cidreq()."&origin=".Security::remove_XSS($_GET['origin'])."&id=".$myrow['id']; + $mylink = api_get_self()."?".api_get_cidreq()."&origin=".Security::remove_XSS($_GET['origin'])."&id=".$myrow['id']; if (!empty($_GET['agenda_id'])) { // rather ugly hack because the id parameter is already set above but below we set it again $mylink .= '&agenda_id='.Security::remove_XSS($_GET['agenda_id']).'&id='.Security::remove_XSS($_GET['agenda_id']); @@ -2117,16 +2098,16 @@ function display_one_agenda_item($agenda_id) { echo ''.Display::return_icon($image_visibility.'.png', get_lang('Visible'),'',22).''; - echo "", + echo "", Display::return_icon('edit.png', get_lang('ModifyCalendarItem'),'',22), "", - "", + "", Display::return_icon('delete.png', get_lang('Delete'),'',22),""; } - $mylink = 'ical_export.php?'.api_get_cidreq().'&type=course&id='.$myrow['id']; - //echo ''.Display::return_icon($export_icon_high, get_lang('ExportiCalConfidential')).' '; - //echo ''.Display::return_icon($export_icon_low, get_lang('ExportiCalPrivate')).' '; - //echo ''.Display::return_icon($export_icon, get_lang('ExportiCalPublic')).' '; + $mylink = 'ical_export.php?'.api_get_cidreq().'&type=course&id='.$myrow['id']; + //echo ''.Display::return_icon($export_icon_high, get_lang('ExportiCalConfidential')).' '; + //echo ''.Display::return_icon($export_icon_low, get_lang('ExportiCalPrivate')).' '; + //echo ''.Display::return_icon($export_icon, get_lang('ExportiCalPublic')).' '; echo ''.Display::return_icon('printer.png', get_lang('Print'),'',22).' '; echo "
"; // the forward and backwards url - $backwardsURL = api_get_self()."?coursePath=".urlencode($course_path)."&courseCode=".Security::remove_XSS($_GET['courseCode'])."&action=view&view=day&day=".date("j", $previousday)."&month=".date("n", $previousday)."&year=".date("Y", $previousday); - $forewardsURL = api_get_self()."?coursePath=".urlencode($course_path)."&courseCode=".Security::remove_XSS($_GET['courseCode'])."&action=view&view=day&day=".date("j", $nextday)."&month=".date("n", $nextday)."&year=".date("Y", $nextday); + $backwardsURL = api_get_self()."?coursePath=".urlencode($course_path)."&courseCode=".Security::remove_XSS($_GET['courseCode'])."&action=view&view=day&day=".date("j", $previousday)."&month=".date("n", $previousday)."&year=".date("Y", $previousday); + $forewardsURL = api_get_self()."?coursePath=".urlencode($course_path)."&courseCode=".Security::remove_XSS($_GET['courseCode'])."&action=view&view=day&day=".date("j", $nextday)."&month=".date("n", $nextday)."&year=".date("Y", $nextday); // The title row containing the day echo "", "", "
".Display::return_icon('action_prev.png',get_lang('Previous')).""; echo $DaysLong[$day_of_the_week]." ".date("j", $today)." ".$MonthsLong[date("n", $today) - 1]." ".date("Y", $today); @@ -3006,8 +2987,8 @@ function display_weekcalendar($agendaitems, $month, $year, $weekdaynames, $month $timestamp_last_date_of_week = $today + ((7 - $day_of_the_week) * 24 * 60 * 60); // timestamp of the sunday of this week */ - $backwardsURL = api_get_self()."?coursePath=".urlencode($course_path)."&courseCode=".Security::remove_XSS($_GET['courseCode'])."&action=view&view=week&week=". ($week_number -1); - $forewardsURL = api_get_self()."?coursePath=".urlencode($course_path)."&courseCode=".Security::remove_XSS($_GET['courseCode'])."&action=view&view=week&week=". ($week_number +1); + $backwardsURL = api_get_self()."?coursePath=".urlencode($course_path)."&courseCode=".Security::remove_XSS($_GET['courseCode'])."&action=view&view=week&week=". ($week_number -1); + $forewardsURL = api_get_self()."?coursePath=".urlencode($course_path)."&courseCode=".Security::remove_XSS($_GET['courseCode'])."&action=view&view=week&week=". ($week_number +1); echo ''; // The title row containing the the week information (week of the year (startdate of week - enddate of week) @@ -3147,7 +3128,7 @@ function get_day_agendaitems($courses_dbs, $month, $year, $day) { } else { $agenda_link = Display::return_icon('course_home.png',' ','',22); } - $URL = api_get_path(WEB_CODE_PATH).'calendar/agenda.php?cidReq='.urlencode($array_course_info["code"])."&day=$day&month=$month&year=$year#$day"; // RH //Patrick Cool: to highlight the relevant agenda item + $URL = api_get_path(WEB_CODE_PATH).'calendar/agenda.php?cidReq='.urlencode($array_course_info["code"])."&day=$day&month=$month&year=$year#$day"; // RH //Patrick Cool: to highlight the relevant agenda item $items[$halfhour][] .= "".$hours.":".$minutes."".$agenda_link." ".$item['title']."
"; } @@ -3257,7 +3238,7 @@ function get_week_agendaitems($courses_dbs, $month, $year, $week = '') { $agenda_link = Display::return_icon('course_home.png',' ','',22); } - $URL = api_get_path(WEB_CODE_PATH)."calendar/agenda.php?cidReq=".urlencode($array_course_info["code"])."&day=$agendaday&month=$month&year=$year#$agendaday"; // RH //Patrick Cool: to highlight the relevant agenda item + $URL = api_get_path(WEB_CODE_PATH)."calendar/agenda.php?cidReq=".urlencode($array_course_info["code"])."&day=$agendaday&month=$month&year=$year#$agendaday"; // RH //Patrick Cool: to highlight the relevant agenda item //Display the events in agenda $items[$agendaday][$item['start_date']] .= "$start_time - $end_time".$agenda_link.""; $items[$agendaday][$item['start_date']] .= "
".$item['title']."

"; @@ -4444,7 +4425,7 @@ function get_global_agenda_items($agendaitems, $day = "", $month = "", $year = " // if the student has specified a course we a add a link to that course if ($item['course'] <> "") { - $url = api_get_path(WEB_CODE_PATH)."admin/agenda.php?cidReq=".urlencode($item['course'])."&day=$day&month=$month&year=$year#$day"; // RH //Patrick Cool: to highlight the relevant agenda item + $url = api_get_path(WEB_CODE_PATH)."admin/agenda.php?cidReq=".urlencode($item['course'])."&day=$day&month=$month&year=$year#$day"; // RH //Patrick Cool: to highlight the relevant agenda item $course_link = "".$item['course'].""; } else { $course_link = ""; @@ -4464,7 +4445,7 @@ function get_global_agenda_items($agendaitems, $day = "", $month = "", $year = " if ($agendatime['1'] >= '30') { $halfhour = $halfhour +1; } - //$agendaitems[$halfhour] .= "
$hour:$minute ".get_lang('Evento Global'). ": ".$item['title']."
"; + //$agendaitems[$halfhour] .= "
$hour:$minute ".get_lang('Evento Global'). ": ".$item['title']."
"; if (!is_array($agendaitems[$halfhour])) $content = $agendaitems[$halfhour]; $agendaitems[$halfhour] = $content."
$hour:$minute ".get_lang('GlobalEvent'). ": ".$item['title']."
"; @@ -4476,7 +4457,7 @@ function get_global_agenda_items($agendaitems, $day = "", $month = "", $year = " function display_ical_import_form() { echo '
'.get_lang('ICalFileImport').'
'; - echo ''; + echo ''; echo '
* '.get_lang('ICalFileImport').'