Some fixes in the calendar layout + minor code style fixes in the session category list

skala
Julio Montoya 13 years ago
parent 59682e41ac
commit 8811a617ae
  1. 9
      main/admin/session_category_list.php
  2. 122
      main/calendar/agenda.lib.php
  3. 7
      main/css/base.css
  4. 5
      main/inc/ajax/agenda.ajax.php
  5. 36
      main/template/default/agenda/month.tpl

@ -5,12 +5,11 @@ $language_file='admin';
$cidReset=true;
require_once '../inc/global.inc.php';
require_once api_get_path(LIBRARY_PATH).'formvalidator/FormValidator.class.php';
require_once api_get_path(LIBRARY_PATH).'sessionmanager.lib.php';
api_protect_admin_script(true);
// setting the section (for the tabs)
$this_section=SECTION_PLATFORM_ADMIN;
$this_section = SECTION_PLATFORM_ADMIN;
$htmlHeadXtra[] = '<script language="javascript">
function selectAll(idCheck,numRows,action) {
for(i=0;i<numRows;i++) {
@ -24,8 +23,8 @@ $htmlHeadXtra[] = '<script language="javascript">
}
</script>';
$tbl_session_category = Database::get_main_table(TABLE_MAIN_SESSION_CATEGORY);
$tbl_session = Database::get_main_table(TABLE_MAIN_SESSION);
$tbl_session_category = Database::get_main_table(TABLE_MAIN_SESSION_CATEGORY);
$tbl_session = Database::get_main_table(TABLE_MAIN_SESSION);
$page=intval($_GET['page']);
$action= Security::remove_XSS($_REQUEST['action']);

@ -57,7 +57,7 @@ class Agenda {
$attributes['title'] = $title;
$attributes['text'] = $content;
$attributes['date'] = $start;
$attributes['enddate'] = $end;
$attributes['enddate'] = $end;
$attributes['all_day'] = $all_day;
$id = Database::insert($this->tbl_personal_agenda, $attributes);
break;
@ -67,7 +67,7 @@ class Agenda {
$attributes['content'] = $content;
$attributes['start_date'] = $start;
$attributes['end_date'] = $end;
$attributes['all_day'] = $all_day;
$attributes['all_day'] = $all_day;
$attributes['session_id'] = api_get_session_id();
$attributes['c_id'] = $this->course['real_id'];
@ -103,8 +103,7 @@ class Agenda {
if (isset($add_as_announcement) && !empty($add_as_announcement)) {
self::store_agenda_item_as_announcement($id);
}
}
}
break;
case 'admin':
@ -264,12 +263,18 @@ class Agenda {
break;
case 'personal':
default:
//Getting personal events
$this->get_personal_events($start, $end);
//Getting platform/admin events
$this->get_platform_events($start, $end);
//Getting course events
$my_course_list = array();
if (!api_is_anonymous()) {
$my_course_list = CourseManager::get_courses_list_by_user_id(api_get_user_id(), true);
}
}
if (!empty($my_course_list)) {
foreach($my_course_list as $course_info_item) {
if (isset($course_id) && !empty($course_id)) {
@ -364,6 +369,7 @@ class Agenda {
$start = api_get_utc_datetime($start);
$end = api_get_utc_datetime($end);
$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";
@ -376,6 +382,9 @@ class Agenda {
$event['className'] = 'personal';
$event['borderColor'] = $event['backgroundColor'] = $this->event_personal_color;
$event['editable'] = true;
$event['sent_to'] = get_lang('Me');
$event['type'] = 'personal';
if (!empty($row['date']) && $row['date'] != '0000-00-00 00:00:00') {
$event['start'] = $this->format_event_date($row['date']);
@ -384,7 +393,7 @@ class Agenda {
if (!empty($row['enddate']) && $row['enddate'] != '0000-00-00 00:00:00') {
$event['end'] = $this->format_event_date($row['enddate']);
}
$event['description'] = $row['text'];
$event['description'] = $row['text'];
$event['allDay'] = isset($row['all_day']) && $row['all_day'] == 1 ? $row['all_day'] : 0;
$my_events[] = $event;
$this->events[]= $event;
@ -397,7 +406,21 @@ class Agenda {
$course_id = $course_info['real_id'];
$group_memberships = GroupManager::get_group_ids($course_id, api_get_user_id());
$group_list = GroupManager::get_group_list(null, $course_info['code']);
$group_name_list = array();
if (!empty($group_list)) {
foreach($group_list as $group) {
$group_name_list[$group['id']]= $group['name'];
}
}
if (!api_is_allowed_to_edit()) {
$group_memberships = GroupManager::get_group_ids($course_id, api_get_user_id());
} else {
$group_memberships = array_keys($group_name_list);
}
$tlb_course_agenda = Database::get_course_table(TABLE_AGENDA);
$tbl_property = Database::get_course_table(TABLE_ITEM_PROPERTY);
@ -408,36 +431,38 @@ class Agenda {
}
if (is_array($group_memberships) && count($group_memberships) >0 ) {
$sql = "SELECT DISTINCT agenda.*, ip.visibility, ip.to_group_id, ip.insert_user_id, ip.ref
FROM ".$tlb_course_agenda." agenda, ".$tbl_property." ip
WHERE agenda.id = ip.ref 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.visibility = '1' AND
agenda.c_id = $course_id AND
ip.c_id = $course_id";
if (api_is_allowed_to_edit()) {
$where_condition = "( ip.to_group_id is null OR ip.to_group_id IN (0, ".implode(", ", $group_memberships).") ) ";
} else {
$where_condition = "( ip.to_user_id = $user_id OR ip.to_group_id IN (0, ".implode(", ", $group_memberships).") ) ";
}
$sql = "SELECT DISTINCT agenda.*, ip.visibility, ip.to_group_id, ip.insert_user_id, ip.ref
FROM ".$tlb_course_agenda." agenda, ".$tbl_property." ip
WHERE agenda.id = ip.ref AND
ip.tool ='".TOOL_CALENDAR_EVENT."' AND
$where_condition AND
ip.visibility = '1' AND
agenda.c_id = $course_id AND
ip.c_id = $course_id";
} else {
if (api_is_allowed_to_edit()) {
$sql="SELECT DISTINCT agenda.*, ip.visibility, ip.to_group_id, ip.insert_user_id, ip.ref
FROM ".$tlb_course_agenda." agenda, ".$tbl_property." ip
WHERE agenda.id = ip.ref
AND ip.tool='".TOOL_CALENDAR_EVENT."'
AND ip.visibility='1' AND
agenda.c_id = $course_id AND
ip.c_id = $course_id
";
} else {
$sql="SELECT DISTINCT agenda.*, ip.visibility, ip.to_group_id, ip.insert_user_id, ip.ref
FROM ".$tlb_course_agenda." agenda, ".$tbl_property." ip
WHERE agenda.id = ip.ref
AND ip.tool='".TOOL_CALENDAR_EVENT."'
AND ( ip.to_user_id=$user_id OR ip.to_group_id='0')
AND ip.visibility='1' AND
agenda.c_id = $course_id AND
ip.c_id = $course_id ";
}
if (api_is_allowed_to_edit()) {
$where_condition = "";
} else {
$where_condition = "( ip.to_user_id=$user_id OR ip.to_group_id='0')";
}
$sql="SELECT DISTINCT agenda.*, ip.visibility, ip.to_group_id, ip.insert_user_id, ip.ref
FROM ".$tlb_course_agenda." agenda, ".$tbl_property." ip
WHERE agenda.id = ip.ref AND
ip.tool='".TOOL_CALENDAR_EVENT."' AND
$where_condition AND
ip.visibility='1' AND
agenda.c_id = $course_id AND
ip.c_id = $course_id";
}
$result = Database::query($sql);
@ -467,6 +492,7 @@ class Agenda {
}
$event['editable'] = false;
if (api_is_allowed_to_edit() && $this->type == 'course') {
$event['editable'] = true;
}
@ -477,6 +503,28 @@ class Agenda {
if (!empty($row['end_date']) && $row['end_date'] != '0000-00-00 00:00:00') {
$event['end'] = $this->format_event_date($row['end_date']);
}
$event['sent_to'] = '';
$event['type'] = $this->type;
//Event Sent to a group?
if (isset($row['to_group_id']) && !empty($row['to_group_id'])) {
$event['sent_to'] = $group_name_list[$row['to_group_id']];
$event['type'] = 'group';
}
//Event sent to a user?
if (isset($row['to_user_id'])) {
$event['sent_to'] = $row['to_user_id'];
}
//Event sent to everyone!
if (empty($event['sent_to'])) {
$event['sent_to'] = get_lang('Everyone');
}
$event['description'] = $row['content'];
$event['allDay'] = isset($row['all_day']) && $row['all_day'] == 1 ? $row['all_day'] : 0;
@ -512,6 +560,8 @@ class Agenda {
$event['allDay'] = 'false';
$event['borderColor'] = $event['backgroundColor'] = $this->event_platform_color;
$event['editable'] = false;
$event['type'] = 'admin';
if (api_is_platform_admin() && $this->type == 'admin') {
$event['editable'] = true;

@ -3790,10 +3790,17 @@ form div.error input, form div.error textarea {
.label_tag.admin_event {
background:red;
}
.label_tag.course_event {
background:#458B00;
}
.label_tag.group_event {
background:#A0522D;
}
.label_tag.important {
background-color: #c43c35;

@ -13,6 +13,11 @@ require_once api_get_path(SYS_CODE_PATH).'calendar/agenda.lib.php';
$action = isset($_REQUEST['a']) ? $_REQUEST['a'] : null;
$type = isset($_REQUEST['type']) && in_array($_REQUEST['type'], array('personal', 'course', 'admin')) ? $_REQUEST['type'] : 'personal';
if ($type =='course') {
// Access control
api_protect_course_script(true);
}
$agenda = new Agenda();
$agenda->type = $type; //course,admin or personal

@ -82,6 +82,7 @@ $(document).ready(function() {
dayNamesShort: {$day_names_short},
selectable : true,
selectHelper: true,
//add event
select: function(start, end, allDay, jsEvent, view) {
/* When selecting one day or several days */
@ -89,7 +90,9 @@ $(document).ready(function() {
var end_date = Math.round(end.getTime() / 1000);
$('#visible_to_input').show();
$('#add_as_announcement_div').show();
$('#add_as_announcement_div').show();
$('#visible_to_read_only').hide();
//Cleans the selected attr
clean_user_select();
@ -116,7 +119,8 @@ $(document).ready(function() {
$('#end_date').html(' - ' + end.toDateString());
}
$('#color_calendar').html('{$type_label}');
$('#color_calendar').addClass('label_tag');
$('#color_calendar').removeClass('group_event');
$('#color_calendar').addClass('label_tag');
$('#color_calendar').addClass('{$type}_event');
allFields.removeClass( "ui-state-error" );
@ -160,7 +164,7 @@ $(document).ready(function() {
},
eventClick: function(calEvent, jsEvent, view) {
//edit event
if (calEvent.editable) {
var start_date = Math.round(calEvent.start.getTime() / 1000);
if (calEvent.allDay == 1) {
@ -170,12 +174,19 @@ $(document).ready(function() {
}
$('#visible_to_input').hide();
$('#visible_to_read_only').show();
$('#add_as_announcement_div').hide();
$("#visible_to_read_only_users").html(calEvent.sent_to);
$('#color_calendar').html('{$type_label}');
$('#color_calendar').addClass('label_tag');
$('#color_calendar').addClass('{$type}_event');
$('#color_calendar').removeClass('course_event');
$('#color_calendar').removeClass('personal_event');
$('#color_calendar').removeClass('group_event');
$('#color_calendar').addClass(calEvent.type+'_event');
$('#start_date').html(calEvent.start.getDate() +"/"+ calEvent.start.getMonth() +"/"+calEvent.start.getFullYear());
@ -206,9 +217,10 @@ $(document).ready(function() {
success:function() {
calEvent.title = $("#title").val();
calEvent.start = calEvent.start;
calEvent.end = calEvent.end;
calEvent.end = calEvent.end;
calEvent.allDay = calEvent.allDay;
calEvent.description = $("#content").val();
calEvent.description = $("#content").val();
calendar.fullCalendar('updateEvent',
calEvent,
true // make the event "stick"
@ -269,10 +281,20 @@ $(document).ready(function() {
<label for="date">{"To"|get_lang}</label>
</div>
<div class="formw">
{$visible_to}
{$visible_to}
</div>
</div>
{/if}
<div id="visible_to_read_only" class="row" style="display:none">
<div class="label">
<label for="date">{"To"|get_lang}</label>
</div>
<div class="formw">
<div id="visible_to_read_only_users"></div>
</div>
</div>
<div class="row">

Loading…
Cancel
Save