Minor cleaning code.

1.9.x
Julio Montoya 11 years ago
parent 2de4c45d71
commit 9980c0d49a
  1. 64
      main/calendar/agenda.lib.php
  2. 21
      main/calendar/agenda_js.php
  3. 11
      main/inc/ajax/agenda.ajax.php
  4. 7
      main/template/default/agenda/month.tpl

@ -241,13 +241,15 @@ class Agenda
/**
*
* Get agenda events
* @param int start tms
* @param int end tms
* @param int course id *integer* not the course code
* @param int user id
*
* @param int $start
* @param int $end
* @param int $course_id
* @param int $group_id
* @param int $user_id
* @return string
*/
function get_events($start, $end, $course_id = null, $group_id = null, $user_id = 0)
public function get_events($start, $end, $course_id = null, $group_id = null, $user_id = 0)
{
switch ($this->type) {
@ -261,13 +263,13 @@ class Agenda
break;
case 'personal':
default:
//Getting personal events
// Getting personal events
$this->get_personal_events($start, $end);
//Getting platform/admin events
// Getting platform/admin events
$this->get_platform_events($start, $end);
//Getting course events
// Getting course events
$my_course_list = array();
if (!api_is_anonymous()) {
@ -417,12 +419,12 @@ class Agenda
}
/**
*
* Gets personal events
* @param int start date tms
* @param int end date tms
* @param int $start
* @param int $end
* @return array
*/
function get_personal_events($start, $end)
public function get_personal_events($start, $end)
{
$start = intval($start);
$end = intval($end);
@ -431,7 +433,7 @@ class Agenda
$user_id = api_get_user_id();
$sql = "SELECT * FROM ".$this->tbl_personal_agenda."
WHERE date >= '".$start."' AND (enddate <='".$end."' OR enddate IS NULL) AND user = $user_id";
WHERE date >= '".$start."' AND (enddate <='".$end."' OR enddate IS NULL) AND user = $user_id";
$result = Database::query($sql);
$my_events = array();
@ -463,7 +465,16 @@ class Agenda
return $my_events;
}
function get_course_events($start, $end, $course_info, $group_id = 0, $session_id = 0, $user_id = 0)
/**
* @param $start
* @param $end
* @param $course_info
* @param int $group_id
* @param int $session_id
* @param int $user_id
* @return array
*/
public function get_course_events($start, $end, $course_info, $group_id = 0, $session_id = 0, $user_id = 0)
{
$course_id = $course_info['real_id'];
$user_id = intval($user_id);
@ -492,11 +503,11 @@ class Agenda
}
$session_id = intval($session_id);
if (is_array($group_memberships) && count($group_memberships) > 0) {
if (api_is_allowed_to_edit()) {
if (!empty($group_id)){
$where_condition = "( ip.to_group_id IN (0, ".implode(", ", $group_memberships).") ) ";
if (!empty($group_id)) {
$where_condition = "( ip.to_group_id IN (0, ".implode(", ", $group_memberships).") ) ";
} else {
if (!empty($user_id)) {
$where_condition = "( ip.to_user_id = $user_id OR ip.to_group_id IN (0, ".implode(", ", $group_memberships).") ) ";
@ -543,11 +554,10 @@ class Agenda
}
$result = Database::query($sql);
$events = array();
if (Database::num_rows($result)) {
$events_added = array();
while ($row = Database::fetch_array($result, 'ASSOC')) {
//to gather sent_tos
// to gather sent_tos
$sql = "SELECT to_user_id, to_group_id
FROM ".$tbl_property." ip
WHERE ip.tool = '".TOOL_CALENDAR_EVENT."' AND
@ -566,18 +576,11 @@ class Agenda
}
}
//Only show events from the session
/* if (api_get_course_int_id()) {
if ($row['session_id'] != api_get_session_id()) {
continue;
}
} */
$event = array();
$event['id'] = 'course_'.$row['id'];
//To avoid doubles
// To avoid doubles
if (in_array($row['id'], $events_added)) {
continue;
}
@ -676,6 +679,11 @@ class Agenda
return $this->events;
}
/**
* @param int $start tms
* @param int $end tms
* @return array
*/
function get_platform_events($start, $end)
{
$start = intval($start);
@ -942,4 +950,4 @@ class Agenda
self::construct_not_selected_select_form_validator($form, $group_list, $user_list, $to_already_selected);
}
}
}

@ -107,12 +107,14 @@ $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('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
@ -132,7 +134,10 @@ $tpl->assign('export_ical_confidential_icon', Display::return_icon($export_icon_
$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'];
@ -209,4 +214,4 @@ $content = $tpl->fetch('default/agenda/month.tpl');
$tpl->assign('content', $content);
//Loading main Chamilo 1 col template
$tpl->display_one_col_template();
$tpl->display_one_col_template();

@ -75,11 +75,14 @@ switch ($action) {
break;
case 'get_events':
$user_id = $_REQUEST['user_id'];
if (substr($user_id,0,1) == 'G') {
if (substr($user_id, 0, 1) == 'G') {
$length = strlen($user_id);
$group_id = substr($user_id,2,$length-1);
$group_id = substr($user_id, 2, $length-1);
}
$events = $agenda->get_events($_REQUEST['start'], $_REQUEST['end'], api_get_course_int_id(), $group_id , $user_id);
$start = isset($_REQUEST['start']) ? $_REQUEST['start'] : null;
$end = isset($_REQUEST['end']) ? $_REQUEST['end'] : null;
$events = $agenda->get_events($start, $end, api_get_course_int_id(), $group_id, $user_id);
echo $events;
break;
case 'get_user_agenda':
@ -124,4 +127,4 @@ switch ($action) {
default:
echo '';
}
exit;
exit;

@ -92,13 +92,14 @@ $(document).ready(function() {
header: {
left: 'today prev,next',
center: 'title',
right: 'month,agendaWeek,agendaDay'
right: 'month,agendaWeek,agendaDay, test'
},
{% if use_google_calendar == 1 %}
eventSources: [
'{{ google_calendar_url }}', //if you want to add more just add URL in this array
// if you want to add more just add URL in this array
'{{ google_calendar_url }}',
{
className: 'gcal-event' // an option!
className: 'gcal-event' // an option!
}
],
{% endif %}

Loading…
Cancel
Save