Adding all_day field in the calendar_event course table + adding support to course and admin calendar in the new agenda_js.php script

skala
Julio Montoya 14 years ago
parent 4041c52e29
commit d4dd6a33a3
  1. 296
      main/calendar/agenda.lib.php
  2. 30
      main/calendar/agenda_js.php
  3. 40
      main/css/base.css
  4. 20
      main/inc/ajax/agenda.ajax.php
  5. 9
      main/inc/lib/add_course.lib.inc.php
  6. 13
      main/install/update-db-1.8.8-1.9.0.inc.php
  7. 230
      main/template/default/agenda/month.tpl

@ -5,6 +5,16 @@ class Agenda {
function __construct() { function __construct() {
$this->tbl_global_agenda = Database::get_main_table(TABLE_MAIN_SYSTEM_CALENDAR); $this->tbl_global_agenda = Database::get_main_table(TABLE_MAIN_SYSTEM_CALENDAR);
$this->tbl_personal_agenda = Database::get_user_personal_table(TABLE_PERSONAL_AGENDA); $this->tbl_personal_agenda = Database::get_user_personal_table(TABLE_PERSONAL_AGENDA);
$this->course = null;
$this->tbl_course_agenda = null;
$course_info = api_get_course_info();
if (!empty($course_info)) {
$this->course = $course_info;
$this->tbl_course_agenda = Database::get_course_table(TABLE_AGENDA, $course_info['db_name']);
}
$this->events = array(); $this->events = array();
$this->event_platform_color = 'red';//red $this->event_platform_color = 'red';//red
@ -30,7 +40,7 @@ class Agenda {
$end = date('Y-m-d H:i:s', $end); $end = date('Y-m-d H:i:s', $end);
$start = api_get_utc_datetime($start); $start = api_get_utc_datetime($start);
$end = api_get_utc_datetime($end); $end = api_get_utc_datetime($end);
$all_day = isset($all_day) && $all_day == 'true' ? 1:0; $all_day = isset($all_day) && $all_day == 'true' ? 1:0;
$attributes = array(); $attributes = array();
$id = null; $id = null;
@ -45,7 +55,18 @@ class Agenda {
$id = Database::insert($this->tbl_personal_agenda, $attributes); $id = Database::insert($this->tbl_personal_agenda, $attributes);
break; break;
case 'course': case 'course':
//$attributes['user'] = api_get_user_id();
$attributes['title'] = $title;
$attributes['content'] = $content;
$attributes['start_date'] = $start;
$attributes['end_date'] = $end;
$attributes['all_day'] = $all_day;
$attributes['session_id'] = api_get_session_id();
//simple course event
$id = Database::insert($this->tbl_course_agenda, $attributes);
api_item_property_update($this->course, TOOL_CALENDAR_EVENT, $id,"AgendaAdded", api_get_user_id(), '','',$start, $end);
break; break;
case 'admin': case 'admin':
$attributes['title'] = $title; $attributes['title'] = $title;
@ -56,10 +77,8 @@ class Agenda {
$attributes['access_url_id'] = api_get_current_access_url_id(); $attributes['access_url_id'] = api_get_current_access_url_id();
$id = Database::insert($this->tbl_global_agenda, $attributes); $id = Database::insert($this->tbl_global_agenda, $attributes);
break; break;
} }
return $id;
return $id;
} }
function edit_event($id, $start, $end, $all_day, $view, $type, $title, $content) { function edit_event($id, $start, $end, $all_day, $view, $type, $title, $content) {
@ -74,22 +93,28 @@ class Agenda {
$all_day = isset($all_day) && $all_day == '1' ? 1:0; $all_day = isset($all_day) && $all_day == '1' ? 1:0;
$attributes = array(); $attributes = array();
switch($type) { switch($type) {
case 'personal': case 'personal':
$attributes['title'] = $title; $attributes['title'] = $title;
$attributes['text'] = $content; $attributes['text'] = $content;
$attributes['date'] = $start; $attributes['date'] = $start;
$attributes['enddate'] = $end; $attributes['enddate'] = $end;
Database::update($this->tbl_personal_agenda, $attributes, array('id = ?' =>$id)); Database::update($this->tbl_personal_agenda, $attributes, array('id = ?' => $id));
break; break;
case 'course': case 'course':
$attributes['title'] = $title;
$attributes['content'] = $content;
$attributes['start_date'] = $start;
$attributes['end_date'] = $end;
Database::update($this->tbl_course_agenda, $attributes, array('id = ?' => $id));
break; break;
case 'admin': case 'admin':
$attributes['title'] = $title; $attributes['title'] = $title;
$attributes['content'] = $content; $attributes['content'] = $content;
$attributes['start_date'] = $start; $attributes['start_date'] = $start;
$attributes['end_date'] = $end; $attributes['end_date'] = $end;
Database::update($this->tbl_global_agenda, $attributes, array('id = ?' =>$id)); Database::update($this->tbl_global_agenda, $attributes, array('id = ?' => $id));
break; break;
break; break;
} }
@ -101,6 +126,7 @@ class Agenda {
Database::delete($this->tbl_personal_agenda, array('id = ?' =>$id)); Database::delete($this->tbl_personal_agenda, array('id = ?' =>$id));
break; break;
case 'course': case 'course':
Database::delete($this->tbl_course_agenda, array('id = ?' =>$id));
break; break;
case 'admin': case 'admin':
Database::delete($this->tbl_global_agenda, array('id = ?' =>$id)); Database::delete($this->tbl_global_agenda, array('id = ?' =>$id));
@ -118,8 +144,7 @@ class Agenda {
* @param int course id *integer* not the course code * @param int course id *integer* not the course code
* *
*/ */
function get_events($start, $end, $type, $user_id, $course_id = null) { function get_events($start, $end, $type, $user_id, $course_id = null) {
switch($type) { switch($type) {
case 'admin': case 'admin':
$this->get_platform_events($start, $end); $this->get_platform_events($start, $end);
@ -132,17 +157,21 @@ class Agenda {
default: default:
$this->get_personal_events($start, $end); $this->get_personal_events($start, $end);
$this->get_platform_events($start, $end); $this->get_platform_events($start, $end);
$my_course_list = CourseManager::get_courses_list_by_user_id(api_get_user_id(), true); $my_course_list = array();
if (!api_is_anonymous()) {
foreach($my_course_list as $course_info_item) { $my_course_list = CourseManager::get_courses_list_by_user_id(api_get_user_id(), true);
if (isset($course_id) && !empty($course_id)) { }
if ($course_info_item['course_id'] == $course_id) { if (!empty($my_course_list)) {
foreach($my_course_list as $course_info_item) {
if (isset($course_id) && !empty($course_id)) {
if ($course_info_item['course_id'] == $course_id) {
$this->get_course_events($start, $end, $course_info_item);
}
} else {
$this->get_course_events($start, $end, $course_info_item); $this->get_course_events($start, $end, $course_info_item);
} }
} else { }
$this->get_course_events($start, $end, $course_info_item); }
}
}
break; break;
} }
if (!empty($this->events)) { if (!empty($this->events)) {
@ -154,18 +183,29 @@ class Agenda {
function move_event($id, $type, $day_delta, $minute_delta) { function move_event($id, $type, $day_delta, $minute_delta) {
// we convert the hour delta into minutes and add the minute delta // we convert the hour delta into minutes and add the minute delta
$delta = ($day_delta * 60 * 24) + $minute_delta; $delta = ($day_delta * 60 * 24) + $minute_delta;
$delta = intval($delta);
//$table_agenda = Database::get_course_table ( TABLE_AGENDA ); $event = $this->get_event($id, $type);
switch($type) {
case 'personal': if (!empty($event)){
$personal_event = $this->get_personal_event($id); switch($type) {
if (!empty($personal_event)) { case 'personal':
$sql = "UPDATE $this->tbl_personal_agenda SET date = DATE_ADD(date,INTERVAL $delta MINUTE), enddate = DATE_ADD(enddate,INTERVAL $delta MINUTE) $sql = "UPDATE $this->tbl_personal_agenda SET date = DATE_ADD(date, INTERVAL $delta MINUTE), enddate = DATE_ADD(enddate, INTERVAL $delta MINUTE)
WHERE id=".intval($id);
$result = Database::query($sql);
break;
case 'course':
$sql = "UPDATE $this->tbl_course_agenda SET start_date = DATE_ADD(start_date,INTERVAL $delta MINUTE), end_date = DATE_ADD(end_date, INTERVAL $delta MINUTE)
WHERE id=".intval($id);
$result = Database::query($sql);
break;
case 'admin':
$sql = "UPDATE $this->tbl_global_agenda SET start_date = DATE_ADD(start_date,INTERVAL $delta MINUTE), end_date = DATE_ADD(end_date, INTERVAL $delta MINUTE)
WHERE id=".intval($id); WHERE id=".intval($id);
$result = Database::query($sql); $result = Database::query($sql);
} break;
break; }
} }
return 1; return 1;
} }
@ -173,16 +213,35 @@ class Agenda {
* Gets a single personal event * Gets a single personal event
* @param int event id * @param int event id
*/ */
function get_personal_event($id) { function get_event($id, $type) {
// make sure events of the personal agenda can only be seen by the user himself // make sure events of the personal agenda can only be seen by the user himself
$user = api_get_user_id(); $id = intval($id);
$sql = " SELECT * FROM ".$this->tbl_personal_agenda." WHERE id=".$id." AND user = ".$user; $event = null;
$result = Database::query($sql); switch($type) {
$item = null; case 'personal':
if (Database::num_rows($result)) { $user = api_get_user_id();
$item = Database::fetch_array($result); $sql = " SELECT * FROM ".$this->tbl_personal_agenda." WHERE id=".$id." AND user = ".$user;
$result = Database::query($sql);
if (Database::num_rows($result)) {
$event = Database::fetch_array($result, 'ASSOC');
}
break;
case 'course':
$sql = " SELECT * FROM ".$this->tbl_course_agenda." WHERE id=".$id;
$result = Database::query($sql);
if (Database::num_rows($result)) {
$event = Database::fetch_array($result, 'ASSOC');
}
break;
case 'admin':
$sql = " SELECT * FROM ".$this->tbl_global_agenda." WHERE id=".$id;
$result = Database::query($sql);
if (Database::num_rows($result)) {
$event = Database::fetch_array($result, 'ASSOC');
}
break;
} }
return $item; return $event;
} }
/** /**
@ -226,82 +285,40 @@ class Agenda {
return $my_events; return $my_events;
} }
function get_platform_events($start, $end) {
$start = intval($start);
$end = intval($end);
$start = api_get_utc_datetime($start);
$end = api_get_utc_datetime($end);
$access_url_id = api_get_current_access_url_id();
$sql = "SELECT * FROM ".$this->tbl_global_agenda."
WHERE start_date>='".$start."' AND end_date<='".$end."' AND access_url_id = $access_url_id ";
$result = Database::query($sql);
$my_events = array();
if (Database::num_rows($result)) {
while ($row = Database::fetch_array($result, 'ASSOC')) {
$event = array();
$event['id'] = 'platform_'.$row['id'];
$event['title'] = $row['title'];
$event['className'] = 'platform';
$event['allDay'] = 'false';
$event['borderColor'] = $event['backgroundColor'] = $this->event_platform_color;
$event['editable'] = false;
if (!empty($row['start_date']) && $row['start_date'] != '0000-00-00 00:00:00') {
$event['start'] = $this->format_event_date($row['start_date']);
}
if (!empty($row['end_date']) && $row['end_date'] != '0000-00-00 00:00:00') {
$event['end'] = $this->format_event_date($row['end_date']);
}
$event['description'] = $row['content'];
$event['allDay'] = isset($row['all_day']) && $row['all_day'] == 1 ? $row['all_day'] : 0;
$my_events[] = $event;
$this->events[]= $event;
}
}
return $my_events;
}
function get_course_events($start, $end, $course_info, $group_id = 0) { function get_course_events($start, $end, $course_info, $group_id = 0) {
$group_memberships = GroupManager::get_group_ids($course_info['db_name'], api_get_user_id()); $group_memberships = GroupManager::get_group_ids($course_info['db_name'], api_get_user_id());
$tlb_course_agenda = Database::get_course_table(TABLE_AGENDA, $course_info['db_name']); $tlb_course_agenda = Database::get_course_table(TABLE_AGENDA, $course_info['db_name']);
$tbl_property = Database::get_course_table(TABLE_ITEM_PROPERTY, $course_info['db_name']); $tbl_property = Database::get_course_table(TABLE_ITEM_PROPERTY, $course_info['db_name']);
$user_id = api_get_user_id(); $user_id = api_get_user_id();
if (is_array($group_memberships) && 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 $sql = "SELECT agenda.*, ip.visibility, ip.to_group_id, ip.insert_user_id, ip.ref
FROM ".$tlb_course_agenda." agenda, ".$tbl_property." ip FROM ".$tlb_course_agenda." agenda, ".$tbl_property." ip
WHERE agenda.id = ip.ref ".$show_all_current." WHERE agenda.id = ip.ref ".$show_all_current."
AND ip.tool='".TOOL_CALENDAR_EVENT."' AND ip.tool='".TOOL_CALENDAR_EVENT."'
AND ( ip.to_user_id=$user_id OR ip.to_group_id IN (0, ".implode(", ", $group_memberships).") ) AND ( ip.to_user_id=$user_id OR ip.to_group_id IN (0, ".implode(", ", $group_memberships).") )
AND ip.visibility='1' AND ip.visibility='1'
"; ";
} else { } else {
if (api_get_user_id()) { if (api_get_user_id()) {
$sql="SELECT agenda.*, ip.visibility, ip.to_group_id, ip.insert_user_id, ip.ref $sql="SELECT agenda.*, ip.visibility, ip.to_group_id, ip.insert_user_id, ip.ref
FROM ".$tlb_course_agenda." agenda, ".$tbl_property." ip FROM ".$tlb_course_agenda." agenda, ".$tbl_property." ip
WHERE agenda.id = ip.ref ".$show_all_current." WHERE agenda.id = ip.ref ".$show_all_current."
AND ip.tool='".TOOL_CALENDAR_EVENT."' AND ip.tool='".TOOL_CALENDAR_EVENT."'
AND ( ip.to_user_id=$user_id OR ip.to_group_id='0') AND ( ip.to_user_id=$user_id OR ip.to_group_id='0')
AND ip.visibility='1' AND ip.visibility='1'
"; ";
} else { } else {
$sql="SELECT agenda.*, ip.visibility, ip.to_group_id, ip.insert_user_id, ip.ref $sql="SELECT agenda.*, ip.visibility, ip.to_group_id, ip.insert_user_id, ip.ref
FROM ".$tlb_course_agenda." agenda, ".$tbl_property." ip FROM ".$tlb_course_agenda." agenda, ".$tbl_property." ip
WHERE agenda.id = ip.ref ".$show_all_current." WHERE agenda.id = ip.ref ".$show_all_current."
AND ip.tool='".TOOL_CALENDAR_EVENT."' AND ip.tool='".TOOL_CALENDAR_EVENT."'
AND ip.to_group_id='0' AND ip.to_group_id='0'
AND ip.visibility='1' AND ip.visibility='1'
"; ";
} }
} }
$result = Database::query($sql); $result = Database::query($sql);
$events = array(); $events = array();
@ -311,44 +328,95 @@ class Agenda {
if (api_get_course_int_id()) { if (api_get_course_int_id()) {
if ($row['session_id'] != api_get_session_id()) { if ($row['session_id'] != api_get_session_id()) {
continue; continue;
} }
} }
$event = array(); $event = array();
$event['id'] = 'course_'.$row['id']; $event['id'] = 'course_'.$row['id'];
$event['title'] = $row['title']; $event['title'] = $row['title'];
$event['className'] = 'course'; $event['className'] = 'course';
$event['allDay'] = 'false'; $event['allDay'] = 'false';
// var_dump($row); // var_dump($row);
$event['borderColor'] = $event['backgroundColor'] = $this->event_course_color; $event['borderColor'] = $event['backgroundColor'] = $this->event_course_color;
if (isset($row['session_id']) && !empty($row['session_id'])) { if (isset($row['session_id']) && !empty($row['session_id'])) {
$event['borderColor'] = $event['backgroundColor'] = $this->event_session_color; $event['borderColor'] = $event['backgroundColor'] = $this->event_session_color;
} }
if (isset($row['to_group_id']) && !empty($row['to_group_id'])) { if (isset($row['to_group_id']) && !empty($row['to_group_id'])) {
$event['borderColor'] = $event['backgroundColor'] = $this->event_group_color; $event['borderColor'] = $event['backgroundColor'] = $this->event_group_color;
} }
$event['editable'] = false; $event['editable'] = false;
if (api_is_allowed_to_edit()) {
$event['editable'] = true;
}
if (!empty($row['start_date']) && $row['start_date'] != '0000-00-00 00:00:00') { if (!empty($row['start_date']) && $row['start_date'] != '0000-00-00 00:00:00') {
$event['start'] = $this->format_event_date($row['start_date']); $event['start'] = $this->format_event_date($row['start_date']);
} }
if (!empty($row['end_date']) && $row['end_date'] != '0000-00-00 00:00:00') { if (!empty($row['end_date']) && $row['end_date'] != '0000-00-00 00:00:00') {
$event['end'] = $this->format_event_date($row['end_date']); $event['end'] = $this->format_event_date($row['end_date']);
$event['allDay'] = false; }
} else {
$event['allDay'] = true; $event['description'] = $row['content'];
} $event['allDay'] = isset($row['all_day']) && $row['all_day'] == 1 ? $row['all_day'] : 0;
$my_events[] = $event; $my_events[] = $event;
$this->events[] = $event;
}
}
return $events;
}
function get_platform_events($start, $end) {
$start = intval($start);
$end = intval($end);
$start = api_get_utc_datetime($start);
$end = api_get_utc_datetime($end);
$access_url_id = api_get_current_access_url_id();
$this->events[] = $event; $sql = "SELECT * FROM ".$this->tbl_global_agenda."
WHERE start_date>='".$start."' AND end_date<='".$end."' AND access_url_id = $access_url_id ";
$result = Database::query($sql);
$my_events = array();
if (Database::num_rows($result)) {
while ($row = Database::fetch_array($result, 'ASSOC')) {
$event = array();
$event['id'] = 'platform_'.$row['id'];
$event['title'] = $row['title'];
$event['className'] = 'platform';
$event['allDay'] = 'false';
$event['borderColor'] = $event['backgroundColor'] = $this->event_platform_color;
$event['editable'] = false;
if (api_is_platform_admin()) {
$event['editable'] = true;
}
if (!empty($row['start_date']) && $row['start_date'] != '0000-00-00 00:00:00') {
$event['start'] = $this->format_event_date($row['start_date']);
}
if (!empty($row['end_date']) && $row['end_date'] != '0000-00-00 00:00:00') {
$event['end'] = $this->format_event_date($row['end_date']);
}
$event['description'] = $row['content'];
$event['allDay'] = isset($row['all_day']) && $row['all_day'] == 1 ? $row['all_day'] : 0;
$my_events[] = $event;
$this->events[]= $event;
} }
} }
return $my_events;
return $events;
} }
function format_event_date($utc_time) { function format_event_date($utc_time) {
return date('c', api_strtotime(api_get_local_time($utc_time))); return date('c', api_strtotime(api_get_local_time($utc_time)));
} }

@ -21,19 +21,33 @@ $htmlHeadXtra[] = api_get_js('fullcalendar/fullcalendar.min.js');
$htmlHeadXtra[] = api_get_css(api_get_path(WEB_LIBRARY_PATH).'javascript/fullcalendar/fullcalendar.css'); $htmlHeadXtra[] = api_get_css(api_get_path(WEB_LIBRARY_PATH).'javascript/fullcalendar/fullcalendar.css');
$htmlHeadXtra[] = api_get_css(api_get_path(WEB_LIBRARY_PATH).'javascript/qtip2/jquery.qtip.min.css'); $htmlHeadXtra[] = api_get_css(api_get_path(WEB_LIBRARY_PATH).'javascript/qtip2/jquery.qtip.min.css');
$tpl = new Template(); $tpl = new Template();
$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';
$agenda_ajax_url = api_get_path(WEB_AJAX_PATH).'agenda.ajax.php?type=personal&';
if (api_is_platform_admin() && $type == 'admin') { if (api_is_platform_admin() && $type == 'admin') {
$agenda_ajax_url = api_get_path(WEB_AJAX_PATH).'agenda.ajax.php?type=admin&'; $type = 'admin';
} }
//if (api_get_course_id() != -1 && $type == 'course') { //if (api_get_course_id() != -1 && $type == 'course') {
if (api_get_course_id() != -1 && isset($_REQUEST['cidReq'])) { if (isset($_REQUEST['cidReq']) && !empty($_REQUEST['cidReq'])) {
$agenda_ajax_url = api_get_path(WEB_AJAX_PATH).'agenda.ajax.php?type=course&'; $type = 'course';
}
$can_add_events = 0;
if (api_is_platform_admin()) {
$can_add_events = 1;
} }
if (api_is_allowed_to_edit()) {
$can_add_events = 1;
}
if ($type == 'personal' && !api_is_anonymous()) {
$can_add_events = 1;
}
$tpl->assign('type', $type);
$tpl->assign('can_add_events', $can_add_events);
$agenda_ajax_url = api_get_path(WEB_AJAX_PATH).'agenda.ajax.php?type='.$type.'&';
$tpl->assign('web_agenda_ajax_url', $agenda_ajax_url); $tpl->assign('web_agenda_ajax_url', $agenda_ajax_url);

@ -3518,7 +3518,7 @@ div.row div.formw {
} }
.formw { .formw {
width:85%; /* width:85%; */
} }
.formw iframe { .formw iframe {
text-align: left; text-align: left;
@ -3543,6 +3543,8 @@ fieldset {
} }
fieldset legend { fieldset legend {
color: #404040; color: #404040;
display: block; display: block;
@ -3619,17 +3621,41 @@ form div.error input, form div.error textarea {
width: 940px; width: 940px;
} }
/* Top bar experimenting changes */
#topbar_push { #topbar_push {
height:40px; height:40px;
}
#header {
/* padding-top: 41px !important;*/
} }
.topbar-inner, .topbar .fill { .topbar-inner, .topbar .fill {
height:40px; height:40px;
} }
.topbar li a { .topbar li a {
color:#BFBFBF; color:#BFBFBF;
}
/* agenda js */
#add_event_form fieldset {
width:400px;
}
.background_color_personal {
background:#3366CC;
width:100px;
display:block;
height:15px;
}
.background_color_admin {
background:red;
width:100px;
display:block;
height:15px;
} }
.background_color_course {
background:#458B00;
width:100px;
display:block;
height:15px;
}

@ -11,7 +11,7 @@ require_once api_get_path(SYS_CODE_PATH).'calendar/myagenda.inc.php';
require_once api_get_path(SYS_CODE_PATH).'calendar/agenda.lib.php'; require_once api_get_path(SYS_CODE_PATH).'calendar/agenda.lib.php';
$action = isset($_REQUEST['a']) ? $_REQUEST['a'] : null; $action = isset($_REQUEST['a']) ? $_REQUEST['a'] : null;
$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';
$agenda = new Agenda(); $agenda = new Agenda();
switch ($action) { switch ($action) {
@ -21,34 +21,30 @@ switch ($action) {
break; break;
case 'edit_event': case 'edit_event':
$id_list = explode('_', $_REQUEST['id']); $id_list = explode('_', $_REQUEST['id']);
$type = $id_list[0]; //$type = $id_list[0];
$id = $id_list[1]; $id = $id_list[1];
$agenda->edit_event($id, $_REQUEST['start'], $_REQUEST['end'], $_REQUEST['all_day'], $_REQUEST['view'], $type ,$_REQUEST['title'], $_REQUEST['content']); $agenda->edit_event($id, $_REQUEST['start'], $_REQUEST['end'], $_REQUEST['all_day'], $_REQUEST['view'], $type ,$_REQUEST['title'], $_REQUEST['content']);
break; break;
case 'delete_event': case 'delete_event':
$id_list = explode('_', $_REQUEST['id']); $id_list = explode('_', $_REQUEST['id']);
$type = $id_list[0]; //$type = $id_list[0];
$id = $id_list[1]; $id = $id_list[1];
$agenda->delete_event($id, $type); $agenda->delete_event($id, $type);
break; break;
case 'move_event': case 'move_event':
$day_delta = $_REQUEST['day_delta']; $day_delta = $_REQUEST['day_delta'];
$minute_delta = $_REQUEST['minute_delta']; $minute_delta = $_REQUEST['minute_delta'];
$type = $_REQUEST['type'][0]; //$type = $_REQUEST['type'][0];
$id = explode('_', $_REQUEST['id']); $id = explode('_', $_REQUEST['id']);
$id = $id[1]; $id = $id[1];
$agenda->move_event($id, $type, $day_delta, $minute_delta); $agenda->move_event($id, $type, $day_delta, $minute_delta);
break; break;
case 'get_events': case 'get_events':
$start = $_REQUEST['start']; $start = $_REQUEST['start'];
$end = $_REQUEST['end']; $end = $_REQUEST['end'];
$events = $agenda->get_events($start, $end, $type, api_get_user_id(), api_get_course_int_id()); $events = $agenda->get_events($start, $end, $type, api_get_user_id(), api_get_course_int_id());
echo $events; echo $events;
break; break;
case 'get_user_agenda': case 'get_user_agenda':
//Used in the admin user list //Used in the admin user list
api_protect_admin_script(); api_protect_admin_script();

@ -750,11 +750,7 @@ function update_Db_course($course_db_name) {
$sql = "ALTER TABLE `".$tbl_course_homepage . "` ADD INDEX ( session_id ) "; $sql = "ALTER TABLE `".$tbl_course_homepage . "` ADD INDEX ( session_id ) ";
Database::query($sql); Database::query($sql);
/* /* Agenda tool */
-----------------------------------------------------------
Agenda tool
-----------------------------------------------------------
*/
$sql = " $sql = "
CREATE TABLE `".$TABLETOOLAGENDA . "` ( CREATE TABLE `".$TABLETOOLAGENDA . "` (
@ -765,6 +761,7 @@ function update_Db_course($course_db_name) {
end_date datetime NOT NULL default '0000-00-00 00:00:00', end_date datetime NOT NULL default '0000-00-00 00:00:00',
parent_event_id INT NULL, parent_event_id INT NULL,
session_id int unsigned NOT NULL default 0, session_id int unsigned NOT NULL default 0,
all_day INT NOT NULL DEFAULT 0;
PRIMARY KEY (id) PRIMARY KEY (id)
)" . $charset_clause; )" . $charset_clause;
Database::query($sql); Database::query($sql);
@ -804,9 +801,7 @@ function update_Db_course($course_db_name) {
Database::query($sql); Database::query($sql);
/* /*
-----------------------------------------------------------
Document tool Document tool
-----------------------------------------------------------
*/ */
$sql = " $sql = "

@ -253,7 +253,6 @@ if (defined('SYSTEM_INSTALLATION')) {
} }
} }
/* // This fragment of code is not necessary so far.
// Get the courses databases queries list (c_q_list) // Get the courses databases queries list (c_q_list)
$c_q_list = get_sql_file_contents('migrate-db-'.$old_file_version.'-'.$new_file_version.'-post.sql', 'course'); $c_q_list = get_sql_file_contents('migrate-db-'.$old_file_version.'-'.$new_file_version.'-post.sql', 'course');
if (count($c_q_list) > 0) { if (count($c_q_list) > 0) {
@ -296,11 +295,21 @@ if (defined('SYSTEM_INSTALLATION')) {
} }
} }
} }
//Adding all_day to the calendar event table
$calendar_event_table = $row_course['db_name'].".calendar_event";
if ($singleDbForm) {
$calendar_event_table = "$prefix{$row_course['db_name']}_calendar_event";
}
$query = "ALTER TABLE `".$calendar_event_table."` ADD COLUMN all_day INTEGER NOT NULL DEFAULT 0;";
$res = Database::query($query);
if ($res === false) {
error_log('Error in '.$query.': '.Database::error());
}
} }
} }
} }
} }
*/
} else { } else {

@ -1,4 +1,4 @@
<script type='text/javascript'> <script type="text/javascript">
$(document).ready(function() { $(document).ready(function() {
var date = new Date(); var date = new Date();
@ -6,11 +6,11 @@ $(document).ready(function() {
var m = date.getMonth(); var m = date.getMonth();
var y = date.getFullYear(); var y = date.getFullYear();
$( "#dialog-form" ).dialog({ $("#dialog-form").dialog({
autoOpen: false, autoOpen: false,
modal : false, modal : false,
width : 500, width : 550,
height : 320 height : 350
}); });
var calendar = $('#calendar').fullCalendar({ var calendar = $('#calendar').fullCalendar({
@ -21,41 +21,46 @@ $(document).ready(function() {
}, },
selectable : true, selectable : true,
selectHelper: true, selectHelper: true,
select: function(start, end, allDay, jsEvent, view) { select: function(start, end, allDay, jsEvent, view) {
var start_date = Math.round(start.getTime() / 1000); /* When selecting one day or several days */
var end_date = Math.round(end.getTime() / 1000);
var url = '{$web_agenda_ajax_url}a=add_event&start='+start_date+'&end='+end_date+'&all_day='+allDay+'&view='+view.name; if ({$can_add_events} == 1) {
$('#start_date').html(start.getDate() +"/"+ start.getMonth() +"/"+start.getFullYear()); var start_date = Math.round(start.getTime() / 1000);
$('#end_date').html('- '+ end.getDate() +"/"+ end.getMonth() +"/"+end.getFullYear()); var end_date = Math.round(end.getTime() / 1000);
$("#dialog-form").dialog("open"); var url = '{$web_agenda_ajax_url}a=add_event&start='+start_date+'&end='+end_date+'&all_day='+allDay+'&view='+view.name;
$('#start_date').html(start.getDate() +"/"+ start.getMonth() +"/"+start.getFullYear());
$('#end_date').html('- '+ end.getDate() +"/"+ end.getMonth() +"/"+end.getFullYear());
$('#color_calendar').addClass('background_color_{$type}');
$("#dialog-form").dialog({ $("#dialog-form").dialog("open");
buttons: {
"Add event": function() { $("#dialog-form").dialog({
var params = $("#add_event_form").serialize(); buttons: {
$.ajax({ "Add event": function() {
url: url+'&'+params, var params = $("#add_event_form").serialize();
success:function(data) { $.ajax({
calendar.fullCalendar("refetchEvents"); url: url+'&'+params,
calendar.fullCalendar("rerenderEvents"); success:function(data) {
$("#dialog-form").dialog("close"); calendar.fullCalendar("refetchEvents");
} calendar.fullCalendar("rerenderEvents");
}); $("#dialog-form").dialog("close");
}, }
}, });
close: function() { },
$("#title").attr('value', ''); },
$("#content").attr('value', ''); close: function() {
} $("#title").attr('value', '');
}); $("#content").attr('value', '');
//prevent the browser to follow the link }
return false; });
calendar.fullCalendar('unselect'); //prevent the browser to follow the link
return false;
calendar.fullCalendar('unselect');
}
}, },
eventRender: function(event, element) { eventRender: function(event, element) {
if (event.description) { if (event.description) {
@ -65,79 +70,82 @@ $(document).ready(function() {
} }
}, },
eventClick: function(calEvent, jsEvent, view) { eventClick: function(calEvent, jsEvent, view) {
var start_date = Math.round(calEvent.start.getTime() / 1000);
if (calEvent.allDay == 1) {
var end_date = '';
} else {
var end_date = Math.round(calEvent.end.getTime() / 1000);
}
$('#start_date').html(calEvent.start.getDate() +"/"+ calEvent.start.getMonth() +"/"+calEvent.start.getFullYear());
if (end_date != '') { if (calEvent.editable) {
$('#end_date').html(calEvent.end.getDate() +"/"+ calEvent.end.getMonth() +"/"+calEvent.end.getFullYear());
} var start_date = Math.round(calEvent.start.getTime() / 1000);
if (calEvent.allDay == 1) {
$("#title").attr('value', calEvent.title); var end_date = '';
$("#content").attr('value', calEvent.description); } else {
var end_date = Math.round(calEvent.end.getTime() / 1000);
$("#dialog-form").dialog("open");
var url = '{$web_agenda_ajax_url}a=edit_event&id='+calEvent.id+'&start='+start_date+'&end='+end_date+'&all_day='+calEvent.allDay+'&view='+view.name;
var delete_url = '{$web_agenda_ajax_url}a=delete_event&id='+calEvent.id;
$("#dialog-form").dialog({
buttons: {
"Edit event" : function() {
var params = $("#add_event_form").serialize();
$.ajax({
url: url+'&'+params,
success:function() {
calEvent.title = $("#title").val();
calEvent.start = calEvent.start;
calEvent.end = calEvent.end;
calEvent.allDay = calEvent.allDay;
calEvent.description = $("#content").val();
calendar.fullCalendar('updateEvent',
calEvent,
true // make the event "stick"
);
$("#dialog-form").dialog("close");
}
});
},
"Delete": function() {
$.ajax({
url: delete_url,
success:function() {
calendar.fullCalendar('removeEvents',
calEvent
);
calendar.fullCalendar("refetchEvents");
calendar.fullCalendar("rerenderEvents");
$("#dialog-form").dialog( "close" );
}
});
}
},
close: function() {
$("#title").attr('value', '');
$("#content").attr('value', '');
} }
});
$('#color_calendar').addClass('background_color_{$type}');
$('#start_date').html(calEvent.start.getDate() +"/"+ calEvent.start.getMonth() +"/"+calEvent.start.getFullYear());
if (end_date != '') {
$('#end_date').html(calEvent.end.getDate() +"/"+ calEvent.end.getMonth() +"/"+calEvent.end.getFullYear());
}
$("#title").attr('value', calEvent.title);
$("#content").attr('value', calEvent.description);
$("#dialog-form").dialog("open");
var url = '{$web_agenda_ajax_url}a=edit_event&id='+calEvent.id+'&start='+start_date+'&end='+end_date+'&all_day='+calEvent.allDay+'&view='+view.name;
var delete_url = '{$web_agenda_ajax_url}a=delete_event&id='+calEvent.id;
$("#dialog-form").dialog({
buttons: {
"Edit event" : function() {
var params = $("#add_event_form").serialize();
$.ajax({
url: url+'&'+params,
success:function() {
calEvent.title = $("#title").val();
calEvent.start = calEvent.start;
calEvent.end = calEvent.end;
calEvent.allDay = calEvent.allDay;
calEvent.description = $("#content").val();
calendar.fullCalendar('updateEvent',
calEvent,
true // make the event "stick"
);
$("#dialog-form").dialog("close");
}
});
},
"Delete": function() {
$.ajax({
url: delete_url,
success:function() {
calendar.fullCalendar('removeEvents',
calEvent
);
calendar.fullCalendar("refetchEvents");
calendar.fullCalendar("rerenderEvents");
$("#dialog-form").dialog( "close" );
}
});
}
},
close: function() {
$("#title").attr('value', '');
$("#content").attr('value', '');
}
});
}
}, },
editable: true, editable: true,
events: "{$web_agenda_ajax_url}a=get_events", events: "{$web_agenda_ajax_url}a=get_events",
eventDrop: function(event, day_delta, minute_delta, all_day, revert_func) { eventDrop: function(event, day_delta, minute_delta, all_day, revert_func) {
$.ajax({ $.ajax({
url: '{$ajax_url}', url: '{$web_agenda_ajax_url}',
data: { data: {
a: 'move_event', id: event.id, day_delta: day_delta, minute_delta: minute_delta, type: event.className a: 'move_event', id: event.id, day_delta: day_delta, minute_delta: minute_delta
} }
}); });
}, },
@ -153,9 +161,20 @@ $(document).ready(function() {
}); });
</script> </script>
<div id="dialog-form" style="display:none;"> <div id="dialog-form" style="display:none;">
<div style="width:500px">
<form id="add_event_form" name="form"> <form id="add_event_form" name="form">
<fieldset>
<div class="row">
<div class="label">
<label for="date">{"Calendar"|get_lang}</label>
</div>
<div class="formw">
<span id="color_calendar" style="width:100px;"></span>
</div>
</div>
<div class="row"> <div class="row">
<div class="label"> <div class="label">
<label for="date">{"Date"|get_lang}</label> <label for="date">{"Date"|get_lang}</label>
@ -169,7 +188,7 @@ $(document).ready(function() {
<label for="name">{"Title"|get_lang}</label> <label for="name">{"Title"|get_lang}</label>
</div> </div>
<div class="formw"> <div class="formw">
<input type="text" name="title" id="title" size="52" /> <input type="text" name="title" id="title" size="40" />
</div> </div>
</div> </div>
<div class="row"> <div class="row">
@ -177,11 +196,12 @@ $(document).ready(function() {
<label for="name">{"Description"|get_lang}</label> <label for="name">{"Description"|get_lang}</label>
</div> </div>
<div class="formw"> <div class="formw">
<textarea name="content" id="content" cols="50" rows="7"></textarea> <textarea name="content" id="content" cols="40" rows="7"></textarea>
</div> </div>
</div> </div>
</fieldset>
</form> </form>
</div>
</div> </div>
<div id='loading' style='position:absolute; display:none'>{"Loading"|get_lang}...</div> <div id='loading' style='position:absolute; display:none'>{"Loading"|get_lang}...</div>
<div id='calendar'></div> <div id='calendar'></div>

Loading…
Cancel
Save