From 2dad0a40d8caa844dcca074cf9560c4d064edf6f Mon Sep 17 00:00:00 2001 From: Julio Montoya Date: Thu, 21 Nov 2013 17:18:24 +0100 Subject: [PATCH] Fixing agenda view. --- main/calendar/agenda_js.php | 108 ++++++++++++++++++------- main/inc/lib/agenda.lib.php | 4 +- main/inc/lib/api.lib.php | 2 +- main/template/default/agenda/month.tpl | 81 +------------------ 4 files changed, 84 insertions(+), 111 deletions(-) diff --git a/main/calendar/agenda_js.php b/main/calendar/agenda_js.php index b8f1fcb590..38c990029f 100644 --- a/main/calendar/agenda_js.php +++ b/main/calendar/agenda_js.php @@ -13,8 +13,9 @@ $language_file = array('agenda', 'group', 'announcements'); // use anonymous mode when accessing this course tool $use_anonymous = true; -//Calendar type -$type = isset($_REQUEST['type']) && in_array($_REQUEST['type'], array('personal', 'course', 'admin')) ? $_REQUEST['type'] : 'personal'; +// Calendar type + +$type = isset($_REQUEST['type']) && in_array($_REQUEST['type'], array('personal', 'course', 'admin')) ? $_REQUEST['type'] : 'personal'; if ($type == 'personal') { $cidReset = true; // fixes #5162 @@ -35,16 +36,14 @@ $htmlHeadXtra[] = api_get_css(api_get_path(WEB_LIBRARY_PATH).'javascript/fullcal $htmlHeadXtra[] = api_get_css(api_get_path(WEB_LIBRARY_PATH).'javascript/qtip2/jquery.qtip.min.css'); if (api_is_platform_admin() && $type == 'admin') { - $type = 'admin'; + $type = 'admin'; } //if (api_get_course_id() != -1 && $type == 'course') { if (isset($_REQUEST['cidReq']) && !empty($_REQUEST['cidReq'])) { - $type = 'course'; + $type = 'course'; } - - $is_group_tutor = false; $session_id = api_get_session_id(); $group_id = api_get_group_id(); @@ -64,16 +63,16 @@ $tpl->assign('use_google_calendar', 0); $can_add_events = 0; switch($type) { - case 'admin': + case 'admin': api_protect_admin_script(); - $this_section = SECTION_PLATFORM_ADMIN; + $this_section = SECTION_PLATFORM_ADMIN; if (api_is_platform_admin()) { $can_add_events = 1; } - break; - case 'course': + break; + case 'course': api_protect_course_script(); - $this_section = SECTION_COURSES; + $this_section = SECTION_COURSES; if (api_is_allowed_to_edit()) { $can_add_events = 1; } @@ -82,8 +81,8 @@ switch($type) { $can_add_events = 1; } } - break; - case 'personal': + break; + case 'personal': if (api_is_anonymous()) { api_not_allowed(true); } @@ -92,11 +91,11 @@ switch($type) { $tpl->assign('use_google_calendar', 1); $tpl->assign('google_calendar_url', $extra_field_data['google_calendar_url']); } - $this_section = SECTION_MYAGENDA; + $this_section = SECTION_MYAGENDA; if (!api_is_anonymous()) { $can_add_events = 1; } - break; + break; } @@ -107,20 +106,25 @@ $months = api_get_months_long(); $months_short = api_get_months_short(); //Setting calendar translations -$tpl->assign('month_names', json_encode($months)); -$tpl->assign('month_names_short', json_encode($months_short)); -$tpl->assign('day_names', json_encode($days)); -$tpl->assign('day_names_short', json_encode($day_short)); -$tpl->assign('button_text', json_encode(array( - 'today' => get_lang('Today'), - 'month' => get_lang('Month'), - 'week' => get_lang('Week'), - 'day' => get_lang('Day') -))); +$tpl->assign('month_names', json_encode($months)); +$tpl->assign('month_names_short', json_encode($months_short)); +$tpl->assign('day_names', json_encode($days)); +$tpl->assign('day_names_short', json_encode($day_short)); +$tpl->assign( + 'button_text', + json_encode( + array( + 'today' => get_lang('Today'), + 'month' => get_lang('Month'), + 'week' => get_lang('Week'), + 'day' => get_lang('Day') + ) + ) +); //see http://docs.jquery.com/UI/Datepicker/$.datepicker.formatDate -$tpl->assign('js_format_date', 'D d M yy'); +$tpl->assign('js_format_date', 'D d M yy'); $region_value = api_get_language_isocode(); if ($region_value == 'en') { @@ -133,7 +137,7 @@ $export_icon = '../img/export.png'; $export_icon_low = '../img/export_low_fade.png'; $export_icon_high = '../img/export_high_fade.png'; -$tpl->assign('export_ical_confidential_icon', Display::return_icon($export_icon_high, get_lang('ExportiCalConfidential'))); +$tpl->assign('export_ical_confidential_icon', Display::return_icon($export_icon_high, get_lang('ExportiCalConfidential'))); $actions = null; if (api_is_allowed_to_edit(false,true) OR (api_get_course_setting('allow_user_edit_agenda') && !api_is_anonymous()) && api_is_allowed_to_session_edit(false,true) OR $is_group_tutor) { @@ -177,7 +181,7 @@ if (isset($_GET['user_id'])) { $tpl->assign('web_agenda_ajax_url', $agenda_ajax_url); $course_code = api_get_course_id(); - +$select = null; if ((api_is_allowed_to_edit() || $is_group_tutor) && $course_code != '-1' && $type == 'course') { $order = 'lastname'; if (api_is_western_name_order()) { @@ -196,4 +200,52 @@ if ((api_is_allowed_to_edit() || $is_group_tutor) && $course_code != '-1' && $ty $select = $agenda->construct_not_selected_select_form($group_list, $user_list, array()); $tpl->assign('visible_to', $select); } + +$form = new FormValidator('form-simple', '', null); +$form->addElement('label', get_lang('Date'), ''); +$form->addElement('label', get_lang('Title'), '
'); +$form->addElement('label', get_lang('Description'), '
'); +$tpl->assign('form_simple', $form->return_form()); + + +$form = new FormValidator('add_event_form', null, null); + +if (!empty($select)) { + $form->addElement( + 'label', + get_lang('To'), + $select, + array('id' => 'visible_to_input', 'style' => 'display:none') + ); +} + +$form->addElement( + 'label', + get_lang('To'), + '
', + array('id' => 'visible_to_read_only', 'style' => 'display:none') +); + +$form->addElement('label', get_lang('Agenda'), '
'); +$form->addElement('label', get_lang('Date'), ''); +$form->addElement( + 'label', + get_lang('Title'), + '' +); +$form->addElement( + 'label', + get_lang('Description'), + ' + ' +); + +if ($type == 'course') { + + $form->addElement('html', '
'); + $form->addElement('checkbox', 'add_as_annonuncement', array(null, null, get_lang('AddAsAnnouncement').' ('.get_lang('SendEmail').')')); + $form->addElement('html', '
'); +} +$tpl->assign('form_add', $form->return_form()); + $tpl->display('default/agenda/month.tpl'); diff --git a/main/inc/lib/agenda.lib.php b/main/inc/lib/agenda.lib.php index c430517b72..01fa2c797b 100644 --- a/main/inc/lib/agenda.lib.php +++ b/main/inc/lib/agenda.lib.php @@ -864,9 +864,7 @@ class Agenda $user_list = null, $to_already_selected = array() ) { - $html = ''; if ($to_already_selected == 'everyone') { $html .= ''; diff --git a/main/inc/lib/api.lib.php b/main/inc/lib/api.lib.php index eef44bb1f9..a46a992deb 100644 --- a/main/inc/lib/api.lib.php +++ b/main/inc/lib/api.lib.php @@ -3596,7 +3596,7 @@ function api_display_language_form($hide_if_no_choice = false) { '; $html .= '
'; - $html .= ''; foreach ($original_languages as $key => $value) { if ($folder[$key] == $user_selected_language) { $option_end = ' selected="selected" >'; diff --git a/main/template/default/agenda/month.tpl b/main/template/default/agenda/month.tpl index 756eca2177..67353738d5 100644 --- a/main/template/default/agenda/month.tpl +++ b/main/template/default/agenda/month.tpl @@ -449,90 +449,13 @@ $(document).ready(function() {