Minor cleaning white spaces

skala
Julio Montoya 13 years ago
parent 0bfaad22ca
commit 04b462ea5a
  1. 6659
      main/calendar/agenda.inc.php
  2. 906
      main/calendar/agenda.lib.php
  3. 81
      main/calendar/agenda_js.php
  4. 126
      main/inc/ajax/agenda.ajax.php

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

@ -6,7 +6,6 @@
/**
* INIT SECTION
*/
// name of the language file that needs to be included
$language_file = array('agenda', 'group', 'announcements');
@ -14,7 +13,7 @@ $language_file = array('agenda', 'group', 'announcements');
$use_anonymous = true;
//Calendar type
$type = isset($_REQUEST['type']) && in_array($_REQUEST['type'], array('personal', 'course', 'admin')) ? $_REQUEST['type'] : 'personal';
$type = isset($_REQUEST['type']) && in_array($_REQUEST['type'], array('personal', 'course', 'admin')) ? $_REQUEST['type'] : 'personal';
if ($type == 'personal') {
$cidReset = true; // fixes #5162
@ -24,11 +23,11 @@ require_once '../inc/global.inc.php';
require_once 'agenda.lib.php';
require_once 'agenda.inc.php';
$current_course_tool = TOOL_CALENDAR_EVENT;
$current_course_tool = TOOL_CALENDAR_EVENT;
$this_section = SECTION_MYAGENDA;
$htmlHeadXtra[] = api_get_jquery_libraries_js(array('jquery-ui','jquery-ui-i18n'));
$htmlHeadXtra[] = api_get_jquery_libraries_js(array('jquery-ui', 'jquery-ui-i18n'));
$htmlHeadXtra[] = api_get_js('qtip2/jquery.qtip.min.js');
$htmlHeadXtra[] = api_get_js('fullcalendar/fullcalendar.min.js');
$htmlHeadXtra[] = api_get_js('fullcalendar/gcal.js');
@ -36,12 +35,12 @@ $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';
}
@ -52,28 +51,28 @@ $group_id = api_get_group_id();
if (!empty($group_id)) {
$is_group_tutor = GroupManager::is_tutor_of_group(api_get_user_id(), $group_id);
$group_properties = GroupManager :: get_group_properties($group_id);
$interbreadcrumb[] = array ("url" => "../group/group.php", "name" => get_lang('Groups'));
$interbreadcrumb[] = array ("url"=>"../group/group_space.php?gidReq=".$group_id, "name"=> get_lang('GroupSpace').' '.$group_properties['name']);
$group_properties = GroupManager :: get_group_properties($group_id);
$interbreadcrumb[] = array("url" => "../group/group.php", "name" => get_lang('Groups'));
$interbreadcrumb[] = array("url" => "../group/group_space.php?gidReq=".$group_id, "name" => get_lang('GroupSpace').' '.$group_properties['name']);
}
$tpl = new Template(get_lang('Agenda'));
$tpl = new Template(get_lang('Agenda'));
$tpl->assign('use_google_calendar', 0);
$can_add_events = 0;
switch($type) {
case 'admin':
switch ($type) {
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,57 +91,57 @@ 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;
}
//Setting translations
$day_short = api_get_week_days_short();
$days = api_get_week_days_long();
$months = api_get_months_long();
$months_short = api_get_months_short();
$day_short = api_get_week_days_short();
$days = api_get_week_days_long();
$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') {
$region_value = 'en-GB';
}
$tpl->assign('region_value', $region_value);
$tpl->assign('region_value', $region_value);
$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) {
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) {
if ($type == 'course') {
if (isset($_GET['user_id'])) {
$filter = $_GET['user_id'];
}
$actions = display_courseadmin_links($filter);
}
$tpl->assign('actions', $actions);
$tpl->assign('actions', $actions);
}
//Calendar Type : course, admin, personal
@ -174,7 +173,7 @@ if (isset($_GET['user_id'])) {
$agenda_ajax_url = api_get_path(WEB_AJAX_PATH).'agenda.ajax.php?type='.$type;
}
$tpl->assign('web_agenda_ajax_url', $agenda_ajax_url);
$course_code = api_get_course_id();
$course_code = api_get_course_id();
if ((api_is_allowed_to_edit() || $is_group_tutor) && $course_code != '-1' && $type == 'course') {
$order = 'lastname';
@ -182,10 +181,10 @@ if ((api_is_allowed_to_edit() || $is_group_tutor) && $course_code != '-1' && $ty
$order = 'firstname';
}
if (!empty($group_id)) {
$group_list = array($group_id => $group_properties);
$user_list = GroupManager::get_subscribed_users($group_id);
$group_list = array($group_id => $group_properties);
$user_list = GroupManager::get_subscribed_users($group_id);
} else {
$user_list = CourseManager::get_user_list_from_course_code(api_get_course_id(), api_get_session_id(), null, $order);
$user_list = CourseManager::get_user_list_from_course_code(api_get_course_id(), api_get_session_id(), null, $order);
$group_list = CourseManager::get_group_list_of_course(api_get_course_id(), api_get_session_id());
}

@ -3,8 +3,7 @@
/**
* Responses to AJAX calls
*/
$type = isset($_REQUEST['type']) && in_array($_REQUEST['type'], array('personal', 'course', 'admin')) ? $_REQUEST['type'] : 'personal';
$type = isset($_REQUEST['type']) && in_array($_REQUEST['type'], array('personal', 'course', 'admin')) ? $_REQUEST['type'] : 'personal';
if ($type == 'personal') {
$cidReset = true; // fixes #5162
@ -20,7 +19,7 @@ $action = isset($_REQUEST['a']) ? $_REQUEST['a'] : null;
$group_id = api_get_group_id();
//var_dump($group_id);
if ($type =='course') {
if ($type == 'course') {
api_protect_course_script(true);
}
@ -32,98 +31,97 @@ $agenda = new Agenda();
$agenda->type = $type; //course,admin or personal
switch ($action) {
case 'add_event':
case 'add_event':
if ((!api_is_allowed_to_edit(null, true) && !$is_group_tutor) && $type == 'course') {
break;
}
$add_as_announcement = isset($_REQUEST['add_as_annonuncement']) ? $_REQUEST['add_as_annonuncement'] : null;
echo $agenda->add_event($_REQUEST['start'], $_REQUEST['end'], $_REQUEST['all_day'], $_REQUEST['view'],
$_REQUEST['title'], $_REQUEST['content'], $_REQUEST['users_to_send'], $add_as_announcement);
break;
case 'edit_event':
echo $agenda->add_event($_REQUEST['start'], $_REQUEST['end'], $_REQUEST['all_day'], $_REQUEST['view'], $_REQUEST['title'], $_REQUEST['content'], $_REQUEST['users_to_send'], $add_as_announcement);
break;
case 'edit_event':
if (!api_is_allowed_to_edit(null, true) && $type == 'course') {
break;
}
$id_list = explode('_', $_REQUEST['id']);
$id = $id_list[1];
$agenda->edit_event($id, $_REQUEST['start'], $_REQUEST['end'], $_REQUEST['all_day'], $_REQUEST['view'], $_REQUEST['title'], $_REQUEST['content']);
break;
case 'delete_event':
$id_list = explode('_', $_REQUEST['id']);
$id = $id_list[1];
$agenda->edit_event($id, $_REQUEST['start'], $_REQUEST['end'], $_REQUEST['all_day'], $_REQUEST['view'], $_REQUEST['title'], $_REQUEST['content']);
break;
case 'delete_event':
if (!api_is_allowed_to_edit(null, true) && $type == 'course') {
break;
}
$id_list = explode('_', $_REQUEST['id']);
$id = $id_list[1];
$agenda->delete_event($id);
break;
$id_list = explode('_', $_REQUEST['id']);
$id = $id_list[1];
$agenda->delete_event($id);
break;
case 'resize_event':
if (!api_is_allowed_to_edit(null, true) && $type == 'course') {
break;
}
$day_delta = $_REQUEST['day_delta'];
$minute_delta = $_REQUEST['minute_delta'];
$id = explode('_', $_REQUEST['id']);
$id = $id[1];
$agenda->resize_event($id, $day_delta, $minute_delta);
break;
case 'move_event':
$day_delta = $_REQUEST['day_delta'];
$minute_delta = $_REQUEST['minute_delta'];
$id = explode('_', $_REQUEST['id']);
$id = $id[1];
$agenda->resize_event($id, $day_delta, $minute_delta);
break;
case 'move_event':
if (!api_is_allowed_to_edit(null, true) && $type == 'course') {
break;
}
$day_delta = $_REQUEST['day_delta'];
$minute_delta = $_REQUEST['minute_delta'];
$id = explode('_', $_REQUEST['id']);
$id = $id[1];
$agenda->move_event($id, $day_delta, $minute_delta);
break;
case 'get_events':
$start = $_REQUEST['start'];
$end = $_REQUEST['end'];
$day_delta = $_REQUEST['day_delta'];
$minute_delta = $_REQUEST['minute_delta'];
$id = explode('_', $_REQUEST['id']);
$id = $id[1];
$agenda->move_event($id, $day_delta, $minute_delta);
break;
case 'get_events':
$start = $_REQUEST['start'];
$end = $_REQUEST['end'];
if (isset($_REQUEST['user_id'])) {
$sel_user = $_REQUEST['user_id'];
} else {
$sel_user = 0;
}
$events = $agenda->get_events($start, $end, api_get_course_int_id(), $group_id,$_REQUEST['user_id']);
echo $events;
break;
$events = $agenda->get_events($start, $end, api_get_course_int_id(), $group_id, $_REQUEST['user_id']);
echo $events;
break;
case 'get_user_agenda':
//Used in the admin user list
api_protect_admin_script();
//Used in the admin user list
api_protect_admin_script();
if (api_is_allowed_to_edit(null, true)) {
//@todo move this in the agenda class
$DaysShort = api_get_week_days_short();
$DaysShort = api_get_week_days_short();
$MonthsLong = api_get_months_long();
$user_id = intval($_REQUEST['user_id']);
$my_course_list = CourseManager::get_courses_list_by_user_id($user_id, true);
if (!is_array($my_course_list)) {
// this is for the special case if the user has no courses (otherwise you get an error)
$my_course_list = array();
}
$today = getdate();
$year = (!empty($_GET['year'])? (int)$_GET['year'] : NULL);
if ($year == NULL) {
$year = $today['year'];
}
$month = (!empty($_GET['month'])? (int)$_GET['month']:NULL);
if ($month == NULL) {
$month = $today['mon'];
}
$day = (!empty($_GET['day']) ? (int)$_GET['day']:NULL);
if ($day == NULL) {
$day = $today['mday'];
}
$monthName = $MonthsLong[$month -1];
$my_course_list = CourseManager::get_courses_list_by_user_id($user_id, true);
if (!is_array($my_course_list)) {
// this is for the special case if the user has no courses (otherwise you get an error)
$my_course_list = array();
}
$today = getdate();
$year = (!empty($_GET['year']) ? (int) $_GET['year'] : NULL);
if ($year == NULL) {
$year = $today['year'];
}
$month = (!empty($_GET['month']) ? (int) $_GET['month'] : NULL);
if ($month == NULL) {
$month = $today['mon'];
}
$day = (!empty($_GET['day']) ? (int) $_GET['day'] : NULL);
if ($day == NULL) {
$day = $today['mday'];
}
$monthName = $MonthsLong[$month - 1];
$agendaitems = get_myagendaitems($user_id, $my_course_list, $month, $year);
$agendaitems = get_global_agenda_items($agendaitems, $day, $month, $year, $week, "month_view");
$agendaitems = get_myagendaitems($user_id, $my_course_list, $month, $year);
$agendaitems = get_global_agenda_items($agendaitems, $day, $month, $year, $week, "month_view");
if (api_get_setting('allow_personal_agenda') == 'true') {
$agendaitems = get_personal_agenda_items($user_id, $agendaitems, $day, $month, $year, $week, "month_view");
}
display_mymonthcalendar($user_id, $agendaitems, $month, $year, array(), $monthName, false);
if (api_get_setting('allow_personal_agenda') == 'true') {
$agendaitems = get_personal_agenda_items($user_id, $agendaitems, $day, $month, $year, $week, "month_view");
}
display_mymonthcalendar($user_id, $agendaitems, $month, $year, array(), $monthName, false);
}
break;
default:

Loading…
Cancel
Save