Filter function updates

1.9.x
unknown 13 years ago
parent 251329d010
commit e4373fbb2f
  1. 31
      main/calendar/agenda.inc.php
  2. 20
      main/calendar/agenda.lib.php
  3. 7
      main/inc/ajax/agenda.ajax.php
  4. 30
      main/template/default/agenda/month.tpl

@ -26,8 +26,15 @@ $(function() {
setFocus();
$("#selected_form_id_search").change(function() {
var temp ="&user_id="+$("#selected_form_id_search").val();
url = window.location+temp;
window.location.replace(url);
var position =String(window.location).indexOf("&user");
var url_length = String(window.location).length;
var url = String(window.location).substring(0,position)+temp;
if (position > 0){
window.location.replace(url);
} else {
url = String(window.location)+temp;
window.location.replace(url);
}
});
});
</script>';
@ -956,7 +963,7 @@ function show_to_form($to_already_selected)
*/
function construct_not_selected_select_form($group_list = null, $user_list = null, $to_already_selected = array())
{
echo '<select data-placeholder="'.get_lang('Select').'" style="width:150px;" class="chzn-select" id="selected_form_id" name="selected_form[]" multiple="multiple">';
echo '<select data-placeholder="'.get_lang('Select').'" style="width:150px;" class="chzn-select" id="selected_form_id_search" name="selected_form[]" multiple="multiple">';
// Adding the groups to the select form
if (isset($to_already_selected) && $to_already_selected === 'everyone') {
@ -1011,15 +1018,23 @@ function show_to($filter = 0, $id = null)
function construct_to_select_form($group_list = null, $user_list = null, $filter = 0, $id = null)
{
$result = '<form class="form-search">';
if (empty($id)) {
$id = 'selected_form_id';
}
$result .= '<select data-placeholder= "'.get_lang('Everyone').'" name="sel_to" class="chzn-select" id="'.$id.'">';
$result = '<form class="form-search">';
$result .= '<select data-placeholder= "'.get_lang('Everyone').'" name="sel_to" class="chzn-select" id="selected_form_id_search">';
// adding the groups to the select form
$result .= '<option value=""></option>';
$result .= '<option value="0">'.get_lang('Everyone').'</option>';
if (is_array($group_list)) {
$result .= '<optgroup label="'.get_lang('Groups').'">';
$this_group_name = count($group_list);
foreach ($group_list as $this_group) {
$group_filter = 'G:'.$this_group['id'];
$selected = $group_filter == $filter ? "selected" : null;
$result .= "<option value=G:".$this_group['id']." ".$selected.">".$this_group['name']."</option>";
}
$result .= "</optgroup>";
}
// adding the individual users to the select form
if (!empty($user_list)) {
$result .= '<optgroup label="'.get_lang('Users').'">';

@ -481,7 +481,7 @@ class Agenda
$group_memberships = GroupManager::get_group_ids($course_id, api_get_user_id());
$user_id = api_get_user_id();
} else {
$group_memberships = array_keys($group_name_list);
$group_memberships = GroupManager::get_group_ids($course_id, $user_id);
}
$tlb_course_agenda = Database::get_course_table(TABLE_AGENDA);
@ -492,13 +492,17 @@ class Agenda
}
$session_id = intval($session_id);
if (is_array($group_memberships) && count($group_memberships) > 0) {
if (api_is_allowed_to_edit()) {
if (!empty($user_id)) {
$where_condition = "( ip.to_user_id = $user_id AND ip.to_group_id is null OR 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 {
$where_condition = "( ip.to_group_id is null OR ip.to_group_id IN (0, ".implode(", ", $group_memberships).") ) ";
if (!empty($user_id)) {
$where_condition = "( ip.to_user_id = $user_id OR ip.to_group_id IN (0, ".implode(", ", $group_memberships).") ) ";
} else {
$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).") ) ";
@ -516,7 +520,11 @@ class Agenda
GROUP BY id";
} else {
if (api_is_allowed_to_edit()) {
$where_condition = "";
if ($user_id == 0) {
$where_condition = "";
} else {
$where_condition = "( ip.to_user_id=".$user_id. ") AND ";
}
} else {
$where_condition = "( ip.to_user_id=$user_id OR ip.to_group_id='0') AND ";
}

@ -74,7 +74,12 @@ switch ($action) {
$agenda->move_event($id, $day_delta, $minute_delta);
break;
case 'get_events':
$events = $agenda->get_events($_REQUEST['start'], $_REQUEST['end'], api_get_course_int_id(), $group_id, $_REQUEST['user_id']);
$user_id = $_REQUEST['user_id'];
if (substr($user_id,0,1) == 'G') {
$length = strlen($user_id);
$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);
echo $events;
break;
case 'get_user_agenda':

@ -179,10 +179,34 @@ $(document).ready(function() {
$.ajax({
url: url+'&'+params,
success:function(data) {
calendar.fullCalendar("refetchEvents");
calendar.fullCalendar("rerenderEvents");
var user = $('#users_to_send_id').val();
if (user.length > 1) {
user = 0;
} else {
user = user[0];
}
var user_length = String(user).length;
if (String(user).substring(0,1) == 'G') {
var user_id = String(user).substring(6,user_length);
var user_id = "G:"+user_id;
} else {
var user_id = String(user).substring(5,user_length);
}
var temp = "&user_id="+user_id;
var position =String(window.location).indexOf("&user");
var url_length = String(window.location).length;
var url = String(window.location).substring(0,position)+temp;
if (position > 0) {
window.location.replace(url);
} else {
url = String(window.location)+temp;
window.location.replace(url);
}
//calendar.fullCalendar("refetchEvents");
//calendar.fullCalendar("rerenderEvents");
$("#dialog-form").dialog("close");
}
}
});
}
},

Loading…
Cancel
Save