diff --git a/main/announcements/announcements.inc.php b/main/announcements/announcements.inc.php index cffd658067..76b0a7e6c3 100755 --- a/main/announcements/announcements.inc.php +++ b/main/announcements/announcements.inc.php @@ -100,25 +100,35 @@ class AnnouncementManager { $tbl_announcement = Database::get_course_table(TABLE_ANNOUNCEMENT); $tbl_item_property = Database::get_course_table(TABLE_ITEM_PROPERTY); - - if (api_get_user_id() != 0) { - $sql_query = " SELECT announcement.*, toolitemproperties.* - FROM $tbl_announcement announcement, $tbl_item_property toolitemproperties - WHERE announcement.id = toolitemproperties.ref - AND announcement.id = '$announcement_id' - AND toolitemproperties.tool='announcement' - AND (toolitemproperties.to_user_id='".api_get_user_id()."' OR toolitemproperties.to_group_id='0') - AND toolitemproperties.visibility='1' - ORDER BY display_order DESC"; - + + if ((api_get_course_setting('allow_user_edit_announcement') && !api_is_anonymous())) { + $sql_query = " SELECT announcement.*, toolitemproperties.* + FROM $tbl_announcement announcement, $tbl_item_property toolitemproperties + WHERE announcement.id = toolitemproperties.ref + AND announcement.id = '$announcement_id' + AND toolitemproperties.tool='announcement' + AND (toolitemproperties.to_user_id='".api_get_user_id()."' OR toolitemproperties.to_group_id='0') + ORDER BY display_order DESC"; } else { - $sql_query = " SELECT announcement.*, toolitemproperties.* - FROM $tbl_announcement announcement, $tbl_item_property toolitemproperties - WHERE announcement.id = toolitemproperties.ref - AND announcement.id = '$announcement_id' - AND toolitemproperties.tool='announcement' - AND toolitemproperties.to_group_id='0' - AND toolitemproperties.visibility='1'"; + if (api_get_user_id() != 0) { + $sql_query = " SELECT announcement.*, toolitemproperties.* + FROM $tbl_announcement announcement, $tbl_item_property toolitemproperties + WHERE announcement.id = toolitemproperties.ref + AND announcement.id = '$announcement_id' + AND toolitemproperties.tool='announcement' + AND (toolitemproperties.to_user_id='".api_get_user_id()."' OR toolitemproperties.to_group_id='0') + AND toolitemproperties.visibility='1' + ORDER BY display_order DESC"; + + } else { + $sql_query = " SELECT announcement.*, toolitemproperties.* + FROM $tbl_announcement announcement, $tbl_item_property toolitemproperties + WHERE announcement.id = toolitemproperties.ref + AND announcement.id = '$announcement_id' + AND toolitemproperties.tool='announcement' + AND toolitemproperties.to_group_id='0' + AND toolitemproperties.visibility='1'"; + } } $sql_result = Database::query($sql_query); if (Database::num_rows($sql_result) > 0 ) { diff --git a/main/announcements/announcements.php b/main/announcements/announcements.php index fe4706475c..51ccaf5a04 100755 --- a/main/announcements/announcements.php +++ b/main/announcements/announcements.php @@ -1088,7 +1088,7 @@ if ($display_announcement_list && !$surveyid) { $group_memberships = GroupManager::get_group_ids($_course['dbName'],api_get_user_id()); - if (api_is_allowed_to_edit(false,true)) { + if (api_is_allowed_to_edit(false,true) OR (api_get_course_setting('allow_user_edit_announcement') && !api_is_anonymous())) { // A.1. you are a course admin with a USER filter // => see only the messages of this specific user + the messages of the group (s)he is member of. if (!empty($_SESSION['user'])) { diff --git a/main/calendar/agenda.inc.php b/main/calendar/agenda.inc.php index a6fcaf51ef..4400f94fe7 100755 --- a/main/calendar/agenda.inc.php +++ b/main/calendar/agenda.inc.php @@ -300,29 +300,26 @@ 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()."?".api_get_cidreq()."&coursePath=".(empty($_GET['coursePath'])?'':Security::remove_XSS($_GET['coursePath']))."&courseCode=".(empty($_GET['courseCode'])?'':Security::remove_XSS($_GET['courseCode']))."&month=". ($month == 1 ? 12 : $month -1)."&year=". ($month == 1 ? $year -1 : $year); - $forewardsURL = api_get_self()."?".api_get_cidreq()."&coursePath=".(empty($_GET['coursePath'])?'':Security::remove_XSS($_GET['coursePath']))."&courseCode=".(empty($_GET['courseCode'])?'':Security::remove_XSS($_GET['courseCode']))."&month=". ($month == 12 ? 1 : $month +1)."&year=". ($month == 12 ? $year +1 : $year); - + $backwardsURL = api_get_self()."?".api_get_cidreq()."&coursePath=".(empty($_GET['coursePath'])?'':Security::remove_XSS($_GET['coursePath']))."&courseCode=".(empty($_GET['courseCode'])?'':Security::remove_XSS($_GET['courseCode']))."&month=". ($month == 1 ? 12 : $month -1)."&year=". ($month == 1 ? $year -1 : $year); + $forewardsURL = api_get_self()."?".api_get_cidreq()."&coursePath=".(empty($_GET['coursePath'])?'':Security::remove_XSS($_GET['coursePath']))."&courseCode=".(empty($_GET['courseCode'])?'':Security::remove_XSS($_GET['courseCode']))."&month=". ($month == 12 ? 1 : $month +1)."&year=". ($month == 12 ? $year +1 : $year); + + $month_link = Display::url($monthName. " ".$year, api_get_self()."?".api_get_cidreq()."&month=". ($month)."&year=".$year); echo "", "", "", - "", - "", ""; + "", + ""; echo ""; - for ($ii = 1; $ii < 8; $ii ++) - { + for ($ii = 1; $ii < 8; $ii ++) { echo ""; } echo ""; $curday = -1; $today = getdate(); - while ($curday <= $numberofdays[$month]) - { + while ($curday <= $numberofdays[$month]) { echo ""; - for ($ii = 0; $ii < 7; $ii ++) - { - if (($curday == -1) && ($ii == $startdayofweek)) - { + for ($ii = 0; $ii < 7; $ii ++) { + if (($curday == -1) && ($ii == $startdayofweek)) { $curday = 1; } if (($curday > 0) && ($curday <= $numberofdays[$month])) { @@ -331,8 +328,7 @@ function display_minimonthcalendar($agendaitems, $month, $year, $monthName) { if (($curday == $today['mday']) && ($year == $today['year']) && ($month == $today['mon'])) { $dayheader = "$curday"; $class = "class=\"days_today\""; - } - + } echo "
".Display::return_icon('action_prev.png',get_lang('Previous'))." ", $monthName, " ", $year, " ".Display::return_icon('action_next.png',get_lang('Next'))."
".$month_link. " ".Display::return_icon('action_next.png',get_lang('Next'))."
", $DaysShort[$ii % 7], "
"; if (!empty($agendaitems[$curday])) { $month_curday = array(); @@ -449,16 +445,16 @@ function display_monthcalendar($month, $year) { switch($value['calendar_type']) { case 'personal': - $bg_color = '#D0E7F4'; - $subtitle = get_lang('MyAgenda'); - break; + $bg_color = '#D0E7F4'; + $subtitle = Display::return_icon('user.png', get_lang('MyAgenda'), array(), 22); + break; case 'global': - $bg_color = '#FFBC89'; - $subtitle = get_lang('GlobalEvent'); + $bg_color = '#FFBC89'; + $subtitle = Display::return_icon('view_remove.png', get_lang('GlobalEvent'), array(), 22); break; case 'course': $bg_color = '#CAFFAA'; - $subtitle = get_lang('Course'); + $subtitle = Display::return_icon('course.png', get_lang('Course'), array(), 22); break; default: //$time = ''.$start_time.' - '.$end_time.' '; @@ -468,7 +464,7 @@ function display_monthcalendar($month, $year) { $dayheader.= '
'; $value['title'] = Display::tag('strong', $value['title']); - $dayheader .= $time.' - '.$subtitle.'
'.$value['title']; + $dayheader .= $time.' '.$subtitle.'
'.$value['title']; $dayheader .= '
'; } } @@ -1711,31 +1707,55 @@ function showhide_agenda_item($id) { * @author Yannick Warnier - cleanup * @author Julio Montoya - More cleanup */ -function display_agenda_items($select_month, $select_year) { +function display_agenda_items($select_month, $select_year, $select_day = false) { + + if ($_GET['sort'] == 'ASC') { + $sort = 'DESC'; + } else { + $sort = 'ASC'; + } + + if ($_GET['col'] == 'end') { + $sort_item = 'end_date'; + } else { + $sort_item = 'start_date'; + } + + $select_month = intval($select_month); + $select_year = intval($select_year); + + if ($select_day) { + $select_day = intval($select_day); + } + $TABLEAGENDA = Database::get_course_table(TABLE_AGENDA); $TABLE_ITEM_PROPERTY = Database::get_course_table(TABLE_ITEM_PROPERTY); - $select_month = intval($select_month); - $select_year = intval($select_year); - global $charset, $_course; // getting the group memberships - $group_memberships = GroupManager::get_group_ids($_course['dbName'],api_get_user_id()); + $group_memberships = GroupManager::get_group_ids($_course['dbName'], api_get_user_id()); // getting the name of the groups $group_names = get_course_groups(); - $start = 0; - $stop = 0; + //$start = 0; + //$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 (!empty($select_month) && !empty($select_year)) { - $show_all_current =" AND MONTH(start_date)=$select_month AND year(start_date)=$select_year"; - $show_all_current_personal =" AND MONTH(date)=$select_month AND year(date)=$select_year"; - $start = mktime(0,0,0,$select_month,1,$select_year); + if (!empty($select_month) && !empty($select_year)) { + $show_all_current = " AND MONTH(start_date) = $select_month AND year(start_date) = $select_year"; + if ($select_day) { + $show_all_current .= ' AND DAY(start_date) = "'.$select_day.'"'; + } + $show_all_current_personal =" AND MONTH(date) = $select_month AND year(date) = $select_year"; + + if ($select_day) { + $show_all_current_personal .= ' AND DAY(date) = "'.$select_day.'"'; + } + /*$start = mktime(0,0,0,$select_month,1,$select_year); $stop = 0; if (empty($select_year)) { $select_year = date('Y');} if (empty($select_month)) { $select_month = date('m');} @@ -1743,12 +1763,12 @@ function display_agenda_items($select_month, $select_year) { $stop = mktime(0,0,0,1,1,$select_year+1)-1; } else { $stop = mktime(0,0,0,$select_month+1,1,$select_year)-1; - } + }*/ } else { - $show_all_current=''; + $show_all_current = ''; $show_all_current_personal = ''; - $start = time(); - $stop = mktime(0,0,0,1,1,2038);//by default, set year to maximum for mktime() + //$start = time(); + //$stop = mktime(0,0,0,1,1,2038);//by default, set year to maximum for mktime() } // by default we use the id of the current user. The course administrator can see the agenda of other users by using the user / group filter @@ -1802,7 +1822,7 @@ function display_agenda_items($select_month, $select_year) { AND ( ip.to_user_id=$user_id OR ip.to_group_id IN (0, ".implode(", ", $group_memberships).") ) AND ip.visibility='1' $session_condition - ORDER BY start_date ".$_SESSION['sort']; + ORDER BY $sort_item $sort"; } else { //AND ( ip.to_user_id=$user_id OR ip.to_group_id='0') $sql="SELECT agenda.*, ip.visibility, ip.to_group_id, ip.insert_user_id, ip.ref @@ -1812,7 +1832,7 @@ function display_agenda_items($select_month, $select_year) { AND ( ip.to_user_id=$user_id) AND ip.visibility='1' $session_condition - ORDER BY start_date ".$_SESSION['sort']; + ORDER BY $sort_item $sort"; } } // A.2. you are a course admin with a GROUP filter @@ -1837,7 +1857,7 @@ function display_agenda_items($select_month, $select_year) { AND ip.lastedit_type<>'CalendareventDeleted' $session_condition GROUP BY ip.ref - ORDER BY start_date ".$_SESSION['sort']; + ORDER BY $sort_item $sort"; //removed - > AND toolitemproperties.visibility='1' } // A.3 you are a course admin without any group or user filter @@ -1853,7 +1873,7 @@ function display_agenda_items($select_month, $select_year) { AND ip.visibility='1' $session_condition GROUP BY ip.ref - ORDER BY start_date ".$_SESSION['sort']; + ORDER $sort_item $sort"; } // A.3.b you are a course admin or a student @@ -1870,7 +1890,7 @@ function display_agenda_items($select_month, $select_year) { AND ( ip.visibility='0' OR ip.visibility='1') $session_condition GROUP BY ip.ref - ORDER BY start_date ".$_SESSION['sort']; + ORDER BY $sort_item $sort"; } else { // A.3.b.2 you are a student with no group filter possibly showall //when showing all the events we do not show the group events @@ -1883,7 +1903,7 @@ function display_agenda_items($select_month, $select_year) { AND ( ip.visibility='0' OR ip.visibility='1') $session_condition GROUP BY ip.ref - ORDER BY start_date ".$_SESSION['sort']; + ORDER BY $sort_item $sort"; /* if (is_array($group_memberships) && count($group_memberships)>0) @@ -1896,7 +1916,7 @@ function display_agenda_items($select_month, $select_year) { AND toolitemproperties.visibility='1' AND toolitemproperties.to_group_id IN (0, ".implode(", ", $group_memberships).") $session_condition GROUP BY toolitemproperties.ref - ORDER BY start_date ".$_SESSION['sort']; + ORDER BY start_date ".$sort; } else { @@ -1908,7 +1928,7 @@ function display_agenda_items($select_month, $select_year) { AND toolitemproperties.visibility='1' AND toolitemproperties.to_group_id='0' $session_condition GROUP BY toolitemproperties.ref - ORDER BY start_date ".$_SESSION['sort']; + ORDER BY start_date ".$sort; } */ } @@ -1917,7 +1937,8 @@ function display_agenda_items($select_month, $select_year) { } //if (is_allowed_to_edit() OR( api_get_course_setting('allow_user_edit_agenda') && !api_is_anonymous())) // B. you are a student else { - if (is_array($group_memberships) and count($group_memberships)>0) { + + if (is_array($group_memberships) && count($group_memberships)>0) { $sql="SELECT agenda.*, ip.visibility, ip.to_group_id, ip.insert_user_id, ip.ref FROM ".$TABLEAGENDA." agenda, ".$TABLE_ITEM_PROPERTY." ip @@ -1926,10 +1947,10 @@ function display_agenda_items($select_month, $select_year) { AND ( ip.to_user_id=$user_id OR ip.to_group_id IN (0, ".implode(", ", $group_memberships).") ) AND ip.visibility='1' $session_condition - ORDER BY start_date ".$_SESSION['sort']; + ORDER BY $sort_item $sort"; } else { if (api_get_user_id()) { - $sql="SELECT + $sql="SELECT agenda.*, ip.visibility, ip.to_group_id, ip.insert_user_id, ip.ref FROM ".$TABLEAGENDA." agenda, ".$TABLE_ITEM_PROPERTY." ip WHERE agenda.id = ip.ref ".$show_all_current." @@ -1937,7 +1958,7 @@ function display_agenda_items($select_month, $select_year) { AND ( ip.to_user_id=$user_id OR ip.to_group_id='0') AND ip.visibility='1' $session_condition - ORDER BY start_date ".$_SESSION['sort']; + ORDER BY $sort_item $sort"; } else { $sql="SELECT agenda.*, ip.visibility, ip.to_group_id, ip.insert_user_id, ip.ref @@ -1947,18 +1968,15 @@ function display_agenda_items($select_month, $select_year) { AND ip.to_group_id='0' AND ip.visibility='1' $session_condition - ORDER BY start_date ".$_SESSION['sort']; + ORDER BY $sort_item $sort"; } } } // you are a student - //echo "
".$sql."
"; $result = Database::query($sql); $number_items = Database::num_rows($result); - - /* DISPLAY: THE ITEMS */ $month_bar=""; @@ -1969,9 +1987,13 @@ function display_agenda_items($select_month, $select_year) { $export_icon_high = 'export_high_fade.png'; $my_events = array(); - while($myrow = Database::fetch_array($result)) { + $avoid_doubles = array(); + while($myrow = Database::fetch_array($result,'ASSOC')) { $myrow['calendar_type'] = 'course'; - $my_events[] = $myrow; + if (!in_array($myrow['id'], $avoid_doubles)) { + $my_events[] = $myrow; + $avoid_doubles[] = $myrow['id']; + } } //Check my personal calendar items @@ -1979,7 +2001,7 @@ function display_agenda_items($select_month, $select_year) { $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 $sql = "SELECT id, title, text as content , date as start_date, enddate as end_date, parent_event_id FROM ".$tbl_personal_agenda." - WHERE user='".api_get_user_id()."' ".$show_all_current_personal." ORDER BY date ASC"; + WHERE user='".api_get_user_id()."' ".$show_all_current_personal." ORDER BY $sort_item $sort"; $result = Database::query($sql); while ($row = Database::fetch_array($result, 'ASSOC')) { $row['calendar_type'] = 'personal'; @@ -1995,7 +2017,7 @@ function display_agenda_items($select_month, $select_year) { $sql = "SELECT DISTINCT id, title, content , start_date, end_date FROM ".$table_agenda_system." WHERE 1=1 ".$show_all_current." AND access_url_id = $current_access_url_id - ORDER BY start_date "; + ORDER BY $sort_item $sort"; $result=Database::query($sql); while ($row = Database::fetch_array($result, 'ASSOC')) { $row['calendar_type'] = 'global'; @@ -2009,11 +2031,11 @@ function display_agenda_items($select_month, $select_year) { } else { echo ''; $th = Display::tag('th', get_lang('Title')); - //$th .= Display::tag('th', get_lang('Content')); - $th .= Display::tag('th', get_lang('StartTimeWindow')); - $th .= Display::tag('th', get_lang('EndTimeWindow')); + //$th .= Display::tag('th', get_lang('Content')); + + $th .= Display::tag('th', Display::url(get_lang('StartTimeWindow'), api_get_self().'?sort='.$sort.'&col='.$sort_item)); + $th .= Display::tag('th', Display::url(get_lang('EndTimeWindow'), api_get_self().'?sort='.$sort.'&col='.$sort_item)); - //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_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']))) { // a coach can only delete an element belonging to his session @@ -2026,7 +2048,7 @@ function display_agenda_items($select_month, $select_year) { echo Display::tag('tr', $th); - foreach ($my_events as $myrow) { + foreach ($my_events as $myrow) { $is_repeated = !empty($myrow['parent_event_id']); // Make the month bar appear only once. $myrow["start_date"] = api_get_local_time($myrow["start_date"]); @@ -2066,11 +2088,33 @@ function display_agenda_items($select_month, $select_year) { //Title echo "'; //Start date @@ -2079,41 +2123,17 @@ function display_agenda_items($select_month, $select_year) { echo ''; //End date - echo ''; + echo ''; - // attachment list - $attachment_list = get_attachment($myrow['id']); - - /* - if ((api_is_allowed_to_edit(false,true) OR (api_get_course_setting('allow_user_edit_agenda') && !api_is_anonymous()))) { - echo "'; - } */ - /*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'] == 'course') { - if (!(api_is_course_coach() && !api_is_element_in_the_session(TOOL_AGENDA, $myrow['id']))) { + echo ''; + } else { + if ($is_repeated && (api_is_allowed_to_edit(false,true)) || (api_get_course_setting('allow_user_edit_agenda') && !api_is_anonymous()) ) { echo ''; - } - + } + + if ( (api_is_allowed_to_edit(false,true) || (api_get_course_setting('allow_user_edit_agenda')&& !api_is_anonymous()) ) && ($myrow['calendar_type'] == 'personal' OR $myrow['calendar_type'] == 'global') ) { + echo ''; + } } @@ -2167,11 +2192,7 @@ function display_agenda_items($select_month, $select_year) { */ $counter++; - - - - echo ''; - + echo ""; @@ -2228,44 +2249,42 @@ function display_one_agenda_item($agenda_id) { $group_names = get_course_groups(); $agenda_id = intval($agenda_id); - - $sql="SELECT agenda.*, ip.visibility, ip.to_group_id, ip.insert_user_id, ip.ref - FROM ".$TABLEAGENDA." agenda, ".$TABLE_ITEM_PROPERTY." ip - WHERE agenda.id = ip.ref - AND ip.tool='".TOOL_CALENDAR_EVENT."' - AND ip.visibility='1' - AND agenda.id='$agenda_id'"; + if (! (api_is_allowed_to_edit(false,true) || (api_get_course_setting('allow_user_edit_agenda') && !api_is_anonymous()))) { + $visibility_condition = " AND ip.visibility='1' "; + } + + $sql = "SELECT agenda.*, ip.visibility, ip.to_group_id, ip.insert_user_id, ip.ref + FROM ".$TABLEAGENDA." agenda, ".$TABLE_ITEM_PROPERTY." ip + WHERE agenda.id = ip.ref + AND ip.tool='".TOOL_CALENDAR_EVENT."' + $visibility_condition + AND agenda.id='$agenda_id'"; + $result=Database::query($sql); $number_items=Database::num_rows($result); - $myrow=Database::fetch_array($result); // there should be only one item so no need for a while loop + $myrow = Database::fetch_array($result,'ASSOC'); // there should be only one item so no need for a while loop $sql_rep = "SELECT * FROM $TABLEAGENDA WHERE id = $agenda_id AND parent_event_id IS NOT NULL AND parent_event_id !=0"; $res_rep = Database::query($sql_rep); $repeat = false; $repeat_id = 0; - if(Database::num_rows($res_rep)>0) - { + if (Database::num_rows($res_rep) > 0) { $repeat=true; $row_rep = Database::fetch_array($res_rep); $repeat_id = $row_rep['parent_event_id']; } - /*-------------------------------------------------- - DISPLAY: NO ITEMS - --------------------------------------------------*/ + // DISPLAY: NO ITEMS if ($number_items==0) { - echo "
"; $attach_icon = ''; + + // attachment list + $attachment_list = get_attachment($myrow['id']); + if (!empty($attachment_list)) { $attach_icon = ' '.Display::return_icon('attachment.gif',get_lang('Attachment')); - } - $agenda_url = api_get_path(WEB_CODE_PATH).'calendar/agenda.php?agenda_id='.$myrow['id']; - echo Display::url($myrow['title'].$attach_icon, $agenda_url); + } + $title_class = ''; + if (isset($myrow['visibility']) && $myrow['visibility'] == 0) { + $title_class = 'invisible'; + } + + switch($myrow['calendar_type']) { + case 'global': + $icon_type = Display::return_icon('view_remove.png', get_lang('GlobalEvent'), array(), 22); + echo $icon_type.' '.$myrow['title'].$attach_icon; + break; + case 'personal': + $icon_type = Display::return_icon('user.png', get_lang(' '), array(), 22); + echo $icon_type.' '.$myrow['title'].$attach_icon; + break; + case 'course': + $icon_type = Display::return_icon('course.png',get_lang('Course'), array(), 22); + $agenda_url = api_get_path(WEB_CODE_PATH).'calendar/agenda.php?agenda_id='.$myrow['id']; + echo Display::url($icon_type.' '.$myrow['title'].$attach_icon, $agenda_url, array('class' => $title_class)); + break; + } echo ''; - if ($myrow['calendar_type'] == 'course') { - if ($myrow['end_date']<>'0000-00-00 00:00:00') { - echo api_convert_and_format_date($myrow['end_date']); - } - } - echo ''; + if ($myrow['end_date']<>'0000-00-00 00:00:00') { + echo api_convert_and_format_date($myrow['end_date']); + } + echo '"; - if ($myrow['calendar_type'] == 'course') { - // the message has been sent to - $sent_to = sent_to(TOOL_CALENDAR_EVENT, $myrow["ref"]); - $sent_to_form = sent_to_form($sent_to); - if ($myrow['to_group_id']!=='0') { - echo ' '.Display::return_icon('group.png', get_lang('ItemForUserSelection'),'',22); - } - echo $sent_to_form; - } elseif ($myrow['calendar_type'] == 'personal') { - echo get_lang('Personal'); - } elseif ($myrow['calendar_type'] == 'global') { - echo get_lang('GlobalEvent'); - } - echo ''; + if (!(api_is_course_coach() && !api_is_element_in_the_session(TOOL_AGENDA, $myrow['id']))) { - echo ''; // 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'].'&'; @@ -2135,22 +2155,27 @@ function display_agenda_items($select_month, $select_year) { } echo ''.Display::return_icon($image_visibility.'.png', $text_visibility,'',22).' '; echo " "; - echo Display::return_icon('delete.png', get_lang('Delete'),'',22)." "; + 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')).' '; - echo ''.Display::return_icon('printer.png', get_lang('Print'),'',22).' '; - } else { - - if ($is_repeated && (api_is_allowed_to_edit(false,true))) { + echo ''.Display::return_icon('printer.png', get_lang('Print'),'',22).' '; + echo ''; echo get_lang('RepeatedEvent'),' ',get_lang('RepeatedEventViewOriginalEvent'),''; echo ''; + echo '
".get_lang("NoAgendaItems")."
"; + Display::display_warning_message(get_lang("NoAgendaItems")); + return false; } - /*-------------------------------------------------- - DISPLAY: THE ITEMS - --------------------------------------------------*/ + // DISPLAY: THE ITEMS echo ""; - /*-------------------------------------------------- - DISPLAY : the icon, title, destinees of the item - --------------------------------------------------*/ - echo ""; + // DISPLAY : the icon, title, destinees of the item + $myrow["start_date"] = api_get_local_time($myrow["start_date"]); @@ -2286,10 +2305,10 @@ function display_one_agenda_item($agenda_id) { $stylenotbold="datanotboldnow"; $text_style="textnow"; } - echo ""; + //if ($myrow['visibility']==1) { + echo ' '.$myrow['title']; + echo ""; + + echo ""; // the message has been sent to echo ""; - if (api_is_allowed_to_edit()) { - 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 ''; - } + + if (api_is_allowed_to_edit(false,true)) { + 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 + // DISPLAY: edit delete button (course admin only) + $export_icon = '../img/export.png'; + $export_icon_low = '../img/export_low_fade.png'; + $export_icon_high = '../img/export_high_fade.png'; + + echo '"; + } } /*-DISPLAY: the title */ echo ""; - echo ""; - echo ""; + echo ""; + echo '"; - /*- - DISPLAY: edit delete button (course admin only) - --------------------------------------------------*/ - $export_icon = '../img/export.png'; - $export_icon_low = '../img/export_low_fade.png'; - $export_icon_high = '../img/export_high_fade.png'; - if (api_is_allowed_to_edit()) { - echo '"; - if($repeat) { - echo ''; - echo ''; - echo ''; - } - } + + /*-------------------------------------------------- DISPLAY: the content --------------------------------------------------*/ @@ -2393,6 +2416,16 @@ function display_one_agenda_item($agenda_id) { } echo ''; + + if ($repeat) { + echo ''; + echo ''; + echo ''; + } + + /*-------------------------------------------------- DISPLAY: the added resources @@ -4636,8 +4669,7 @@ function get_global_agenda_items($agendaitems, $day = "", $month = "", $year = " $item['calendar_type'] = 'global'; $agendaitems[$day][] = $item; continue; - } - + } $start_time = api_convert_and_format_date($item['start_date'], TIME_NO_SEC_FORMAT); $end_time = ''; @@ -4677,8 +4709,7 @@ function get_global_agenda_items($agendaitems, $day = "", $month = "", $year = " return $agendaitems; } -function display_ical_import_form() -{ +function display_ical_import_form() { echo '
'.get_lang('ICalFileImport').'
'; echo ''; echo '
diff --git a/main/calendar/agenda.php b/main/calendar/agenda.php index 9627989366..6e99b9de76 100755 --- a/main/calendar/agenda.php +++ b/main/calendar/agenda.php @@ -12,6 +12,8 @@ $use_anonymous = true; // setting the global file that gets the general configuration, the databases, the languages, ... require_once '../inc/global.inc.php'; +api_protect_course_script(true); + //session if(isset($_GET['id_session'])) { $_SESSION['id_session'] = intval($_GET['id_session']); @@ -22,29 +24,23 @@ $this_section=SECTION_COURSES; //error_reporting(E_ALL); require_once api_get_path(LIBRARY_PATH).'groupmanager.lib.php'; -/* ACCESS RIGHTS */ -// notice for unauthorized people. -api_protect_course_script(); - -/* - Resource linker (Patrick Cool, march 2004) -*/ +/* Resource linker (Patrick Cool, march 2004) */ $_SESSION['source_type'] = 'Agenda'; require_once '../resourcelinker/resourcelinker.inc.php'; require_once api_get_path(LIBRARY_PATH).'fileUpload.lib.php'; -if (!empty($addresources)) // When the "Add Resource" button is clicked we store all the form data into a session -{ -$form_elements= array ('day'=>Security::remove_XSS($_POST['fday']), 'month'=>Security::remove_XSS($_POST['fmonth']), 'year'=>Security::remove_XSS($_POST['fyear']), 'hour'=>Security::remove_XSS($_POST['fhour']), 'minutes'=>Security::remove_XSS($_POST['fminute']), - 'end_day'=>Security::remove_XSS($_POST['end_fday']), 'end_month'=>Security::remove_XSS($_POST['end_fmonth']), 'end_year'=>Security::remove_XSS($_POST['end_fyear']), 'end_hours'=>Security::remove_XSS($_POST['end_fhour']), 'end_minutes'=>Security::remove_XSS($_POST['end_fminute']), - 'title'=>Security::remove_XSS(stripslashes($_POST['title'])), 'content'=>Security::remove_XSS(stripslashes($_POST['content'])), 'id'=>Security::remove_XSS($_POST['id']), 'action'=>Security::remove_XSS($_POST['action']), 'to'=>Security::remove_XSS($_POST['selectedform'])); -$_SESSION['formelements']=$form_elements; -// this is to correctly handle edits -if($id){$action="edit";} -//print_r($form_elements); -header('Location: '.api_get_path(WEB_CODE_PATH)."resourcelinker/resourcelinker.php?source_id=1&action=$action&id=$id&originalresource=no"); -exit; +if (!empty($addresources)) { + // When the "Add Resource" button is clicked we store all the form data into a session + $form_elements= array ('day'=>Security::remove_XSS($_POST['fday']), 'month'=>Security::remove_XSS($_POST['fmonth']), 'year'=>Security::remove_XSS($_POST['fyear']), 'hour'=>Security::remove_XSS($_POST['fhour']), 'minutes'=>Security::remove_XSS($_POST['fminute']), + 'end_day'=>Security::remove_XSS($_POST['end_fday']), 'end_month'=>Security::remove_XSS($_POST['end_fmonth']), 'end_year'=>Security::remove_XSS($_POST['end_fyear']), 'end_hours'=>Security::remove_XSS($_POST['end_fhour']), 'end_minutes'=>Security::remove_XSS($_POST['end_fminute']), + 'title'=>Security::remove_XSS(stripslashes($_POST['title'])), 'content'=>Security::remove_XSS(stripslashes($_POST['content'])), 'id'=>Security::remove_XSS($_POST['id']), 'action'=>Security::remove_XSS($_POST['action']), 'to'=>Security::remove_XSS($_POST['selectedform'])); + $_SESSION['formelements']=$form_elements; + // this is to correctly handle edits + if($id){$action="edit";} + //print_r($form_elements); + header('Location: '.api_get_path(WEB_CODE_PATH)."resourcelinker/resourcelinker.php?source_id=1&action=$action&id=$id&originalresource=no"); + exit; } if (!empty($_GET['view'])) { @@ -73,7 +69,7 @@ if (!empty($_GET['action']) and $_GET['action']=="showcurrent") { if (!empty($_GET['action']) and $_GET['action']=="showall") { $_SESSION['show']="showall"; } - +/* // 2. sorting order (ASC or DESC) if (empty($_GET['sort']) and empty($_SESSION['sort'])) { $_SESSION['sort']="DESC"; @@ -83,7 +79,7 @@ if (!empty($_GET['sort']) and $_GET['sort']=="asc") { } if (!empty($_GET['sort']) and $_GET['sort']=="desc") { $_SESSION['sort']="DESC"; -} +}*/ // 3. showing or hiding the send-to-specific-groups-or-users form $setting_allow_individual_calendar=true; @@ -202,6 +198,11 @@ if(!empty($_GET['year'])) { if(!empty($_GET['month'])) { $select_month = (int)$_GET['month']; } + +if(!empty($_GET['day'])) { + $select_day = (int)$_GET['day']; +} + if (empty($select_year) && empty($select_month)) { $today = getdate(); $select_year = $today['year']; @@ -270,8 +271,8 @@ if (api_is_allowed_to_edit(false,true) OR (api_get_course_setting('allow_user_ed break; case "showhide": $id=(int)$_GET['id']; - if( ! (api_is_course_coach() && !api_is_element_in_the_session(TOOL_AGENDA, $id ) ) ) - { // a coach can only delete an element belonging to his session + if (!(api_is_course_coach() && !api_is_element_in_the_session(TOOL_AGENDA, $id ) ) ) { + // a coach can only delete an element belonging to his session showhide_agenda_item($id); } break; @@ -305,9 +306,9 @@ if (empty($_GET['origin']) or $_GET['origin']!='learnpath') { echo '
"; + echo "

"; // adding an internal anchor - echo ""; + //echo ""; // the icons. If the message is sent to one or more specific users/groups // we add the groups icon @@ -2298,8 +2317,11 @@ function display_one_agenda_item($agenda_id) { if ($myrow['to_group_id']!=='0') { echo Display::return_icon('group.png',' ','',22); } - echo $myrow['title']; - echo "

".get_lang("SentTo").": "; @@ -2307,61 +2329,62 @@ function display_one_agenda_item($agenda_id) { $sent_to_form=sent_to_form($sent_to); echo $sent_to_form; echo "'.get_lang('Modify'); - 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']; + 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']); + } + if ($myrow['visibility'] == 1) { + $image_visibility="visible"; + $next_action = 0; + } else { + $image_visibility="invisible"; + $next_action = 1; + } + + echo ''.Display::return_icon($image_visibility.'.png', get_lang('Visible'),'',22).''; + + 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')).' '; + echo ''.Display::return_icon('printer.png', get_lang('Print'),'',22).' '; + echo "
".get_lang("StartTime").": "; + echo ''.get_lang("StartTime").": "; echo api_format_date($myrow['start_date']); echo "".get_lang("EndTime").": "; + echo "
'.get_lang("EndTime").": "; echo api_convert_and_format_date($myrow['end_date']); 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']; - 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']); - } - echo "", - Display::return_icon('edit.png', get_lang('ModifyCalendarItem'),'',22), "", - "", - Display::return_icon('delete.png', get_lang('Delete'),'',22),""; - if ($myrow['visibility']==1) { - $image_visibility="visible"; - } else { - $image_visibility="invisible"; - } - echo ''.Display::return_icon($image_visibility.'.png', get_lang('Visible'),'',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')).' '; - echo ''.Display::return_icon('printer.png', get_lang('Print'),'',22).' '; - echo "
',get_lang('RepeatedEvent'),'',get_lang('RepeatedEventViewOriginalEvent'),'
'; + echo get_lang('RepeatedEvent').' ',get_lang('RepeatedEventViewOriginalEvent'),''; + echo '
'; // the small calendar $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') { - display_minimonthcalendar($agenda_items, $select_month,$select_year, $MonthName); + display_minimonthcalendar($agenda_items, $select_month, $select_year, $MonthName); } echo '
'; if (api_get_setting('display_upcoming_events') == 'true') { @@ -345,7 +346,7 @@ if (api_is_allowed_to_edit(false,true) OR (api_get_course_setting('allow_user_ed } break; case 'edit' : - if ( !(api_is_course_coach() && !api_is_element_in_the_session(TOOL_AGENDA, intval($_REQUEST['id'])))) { + if (!(api_is_course_coach() && !api_is_element_in_the_session(TOOL_AGENDA, intval($_REQUEST['id'])))) { if ($_POST['submit_event']) { display_agenda_items($select_month, $select_year); } else { @@ -381,8 +382,11 @@ if (!$_GET['action'] || $_GET['action']=='showall' || $_GET['action']=='showcur if (!$_SESSION['view'] || $_SESSION['view'] <> 'month') { if(!empty($_GET['agenda_id'])) { display_one_agenda_item($_GET['agenda_id']); - } else { - display_agenda_items($select_month, $select_year); + } else { + $select_day; + $MonthName = $MonthsLong[$select_month -1]; + echo Display::tag('h2', $select_day.' '.$MonthName.' '.$select_year); + display_agenda_items($select_month, $select_year, $select_day); } } else { display_monthcalendar($select_month, $select_year); diff --git a/main/calendar/myagenda.inc.php b/main/calendar/myagenda.inc.php index e2a9637302..7e290a841b 100755 --- a/main/calendar/myagenda.inc.php +++ b/main/calendar/myagenda.inc.php @@ -213,24 +213,25 @@ function display_mymonthcalendar($agendaitems, $month, $year, $weekdaynames=arra if (!empty($value['end_date']) && $value['end_date'] != '0000-00-00 00:00:00') { $end_time = '- '.api_convert_and_format_date($value['end_date'], DATE_TIME_FORMAT_LONG); } - $time = ''.$start_time.' '.$end_time; - switch($value['calendar_type']) { + $time = ''.$start_time.' '.$end_time; + + switch($value['calendar_type']) { case 'personal': - $bg_color = '#D0E7F4'; - $subtitle = get_lang('MyAgenda'); + $bg_color = '#D0E7F4'; + $subtitle = Display::return_icon('user.png', get_lang('MyAgenda'), array(), 22); break; case 'global': $bg_color = '#FFBC89'; - $subtitle = get_lang('GlobalEvent'); + $subtitle = Display::return_icon('view_remove.png', get_lang('GlobalEvent'), array(), 22); break; case 'course': - $bg_color = '#CAFFAA'; - $subtitle = get_lang('Course').' '.$value['url']; - break; + $bg_color = '#CAFFAA'; + $subtitle = Display::return_icon('course.png', get_lang('Course'), array(), 22).' '.$value['url']; + break; default: //$time = ''.$start_time.' - '.$end_time.' '; break; - } + } $result = '
'; $value['title'] = Display::tag('strong', $value['title']); diff --git a/main/inc/lib/social.lib.php b/main/inc/lib/social.lib.php index f2b19ba28a..8f4ff61ec4 100755 --- a/main/inc/lib/social.lib.php +++ b/main/inc/lib/social.lib.php @@ -756,10 +756,10 @@ class SocialManager extends UserManager { $my_announcement_by_user_id= intval($user_id); $announcements = array(); foreach ($course_list_code as $course) { - $content = AnnouncementManager::get_all_annoucement_by_user_course($course['dbName'],$my_announcement_by_user_id); + $content = AnnouncementManager::get_all_annoucement_by_user_course($course['dbName'], $my_announcement_by_user_id); $course_info=api_get_course_info($course['code']); if (!empty($content)) { - $announcements[] = '
  • '6')).'
  • '; + $announcements[] = '
  • '6')).$course_info['name'].' ('.$content['count'].')
  • '; } } if (!empty($announcements)) { diff --git a/main/social/profile.php b/main/social/profile.php index f0688b185b..a1cf16413f 100755 --- a/main/social/profile.php +++ b/main/social/profile.php @@ -59,6 +59,7 @@ if (isset($_GET['u'])) { $libpath = api_get_path(LIBRARY_PATH); require_once api_get_path(SYS_CODE_PATH).'calendar/myagenda.inc.php'; require_once api_get_path(SYS_CODE_PATH).'announcements/announcements.inc.php'; + require_once $libpath.'course.lib.php'; require_once $libpath.'formvalidator/FormValidator.class.php'; require_once $libpath.'magpierss/rss_fetch.inc';