From 4e7e39674fe4c65958485ec15da15d458dcbe89b Mon Sep 17 00:00:00 2001 From: Julio Montoya Date: Wed, 20 Apr 2011 16:50:50 +0200 Subject: [PATCH] More - Improving UI in agenda an announcements --- main/announcements/announcements.inc.php | 50 ++++++++++++++++----- main/calendar/agenda.inc.php | 55 +++++++++++------------- 2 files changed, 65 insertions(+), 40 deletions(-) diff --git a/main/announcements/announcements.inc.php b/main/announcements/announcements.inc.php index 92193a4e7a..d4fb07584c 100755 --- a/main/announcements/announcements.inc.php +++ b/main/announcements/announcements.inc.php @@ -142,9 +142,33 @@ class AnnouncementManager { $content = make_clickable($content); $content = text_filter($content); - echo ""; - echo ""; - echo ""; + echo "

".$title."

$content
"; + echo ""; + + + 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) { + $image_visibility="visible"; + $alt_visibility=get_lang('Hide'); + } else { + $image_visibility="invisible"; + $alt_visibility=get_lang('Visible'); + } + global $stok; + + $modify_icons .= "". + Display::return_icon($image_visibility.'.png', $alt_visibility,'',22).""; + + if (api_is_allowed_to_edit(false,true)) { + $modify_icons .= "". + Display::return_icon('delete.png', get_lang('Delete'),'',22). + ""; + } + echo ""; + } + + echo ""; //echo ""; echo ""; @@ -157,10 +181,11 @@ class AnnouncementManager { $sent_to_form = self::sent_to_form($sent_to); echo Display::tag('td', get_lang('SentTo').' : '.$sent_to_form, array('class'=>'announcements_datum')); - echo "'; - + echo ''; + } echo "

".$title."

$modify_icons
$content
" . get_lang('AnnouncementPublishedOn') . " : " .api_convert_and_format_date($result['end_date'], DATE_FORMAT_LONG). "
" . get_lang('LastUpdateDate') . " : " .api_convert_and_format_date($result['insert_date'], DATE_TIME_FORMAT_LONG). "
"; + $attachment_list = self::get_attachment($announcement_id); if (count($attachment_list)>0) { + echo "
"; $realname=$attachment_list['path']; $user_filename=$attachment_list['filename']; $full_file_name = 'download.php?file='.$realname; @@ -168,9 +193,8 @@ class AnnouncementManager { echo Display::return_icon('attachment.gif',get_lang('Attachment')); echo ' '.$user_filename.' '; echo ''.$attachment_list['comment'].''; - } - echo '
"; } else { api_not_allowed(); @@ -923,10 +947,14 @@ class AnnouncementManager { $output[]= " ".get_lang('Everybody'); } } - if (!empty($output)) { - $output = implode(', ', $output); - return $output; - } + + if (!empty($output)) { + $output = array_filter($output); + if (count($output) > 0) { + $output = implode(', ', $output); + } + return $output; + } } diff --git a/main/calendar/agenda.inc.php b/main/calendar/agenda.inc.php index 9bcc1f259a..c53dde05e1 100755 --- a/main/calendar/agenda.inc.php +++ b/main/calendar/agenda.inc.php @@ -1246,7 +1246,7 @@ function sent_to_form($sent_to_array) { if (isset($sent_to_array['users'])) { if (is_array($sent_to_array['users'])) { foreach ($sent_to_array['users'] as $user_id) { - $user_info=api_get_user_info($user_id); + $user_info= api_get_user_info($user_id); $output[] = api_get_person_name($user_info['firstName'], $user_info['lastName']); } } @@ -1254,11 +1254,11 @@ function sent_to_form($sent_to_array) { } else { // there is only one user/group if (is_array($sent_to_array['users'])) { - $user_info=api_get_user_info($sent_to_array['users'][0]); + $user_info = api_get_user_info($sent_to_array['users'][0]); $output[]= api_get_person_name($user_info['firstName'], $user_info['lastName']); } if (is_array($sent_to_array['groups']) and $sent_to_array['groups'][0]!==0) { - $group_id=$sent_to_array['groups'][0]; + $group_id = $sent_to_array['groups'][0]; $output[]= $group_names[$group_id]['name']; } if (is_array($sent_to_array['groups']) and $sent_to_array['groups'][0]==0) { @@ -1266,8 +1266,11 @@ function sent_to_form($sent_to_array) { } } - if (!empty($output)) { - $output = implode(', ', $output); + if (!empty($output)) { + $output = array_filter($output); + if (count($output) > 0) { + $output = implode(', ', $output); + } return $output; } } @@ -2287,8 +2290,6 @@ function display_one_agenda_item($agenda_id) { echo ""; // DISPLAY : the icon, title, destinees of the item - - $myrow["start_date"] = api_get_local_time($myrow["start_date"]); // highlight: if a date in the small calendar is clicked we highlight the relevant items @@ -2320,19 +2321,10 @@ function display_one_agenda_item($agenda_id) { if ($myrow['to_group_id']!=='0') { echo Display::return_icon('group.png',' ','',22); } - //if ($myrow['visibility']==1) { echo ' '.$myrow['title']; - echo ""; - + echo ""; echo ""; - - // the message has been sent to - echo ""; - + if (api_is_allowed_to_edit(false,true)) { if (!(api_is_course_coach() && !api_is_element_in_the_session(TOOL_AGENDA, $myrow['id']))) { @@ -2342,7 +2334,7 @@ function display_one_agenda_item($agenda_id) { $export_icon_low = '../img/export_low_fade.png'; $export_icon_high = '../img/export_high_fade.png'; - echo ''; - echo ''; } - echo ''; + + // the message has been sent to + echo ''; + echo ""; + if ($repeat) { echo ''; echo ''; echo ''; - } - + } - /*-------------------------------------------------- - DISPLAY: the added resources - --------------------------------------------------*/ + /* DISPLAY: the added resources */ if (check_added_resources("Agenda", $myrow["id"])) { echo "
".get_lang("SentTo").": "; - $sent_to=sent_to(TOOL_CALENDAR_EVENT, $myrow["ref"]); - $sent_to_form=sent_to_form($sent_to); - echo $sent_to_form; - echo "'; + 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']; @@ -2403,10 +2395,11 @@ function display_one_agenda_item($agenda_id) { echo $content; echo '
'; + $attachment_list = get_attachment($agenda_id); if (!empty($attachment_list)) { + echo '
'; $realname=$attachment_list['path']; $user_filename=$attachment_list['filename']; $full_file_name = 'download.php?file='.$realname; @@ -2415,24 +2408,30 @@ function display_one_agenda_item($agenda_id) { if (api_is_allowed_to_edit()) { echo '  '.Display::return_icon('delete.png',get_lang('Delete'),'',22).'
'; } - echo '
'.$attachment_list['comment'].''; + echo '
'.$attachment_list['comment'].''; + echo '
".get_lang("SentTo").": "; + $sent_to=sent_to(TOOL_CALENDAR_EVENT, $myrow["ref"]); + $sent_to_form=sent_to_form($sent_to); + echo $sent_to_form; + echo "
'; echo get_lang('RepeatedEvent').' ',get_lang('RepeatedEventViewOriginalEvent'),''; echo '
"; echo "".get_lang("AddedResources")."
"; @@ -2451,8 +2450,6 @@ function display_one_agenda_item($agenda_id) { } - - /** * Show the form for adding a new agenda item. This is the same function that is used whenever we are editing an * agenda item. When the id parameter is empty (default behaviour), then we show an empty form, else we are editing and