Fixing new agenda queries

skala
Julio Montoya 13 years ago
parent 5f405c14b5
commit 27309bc705
  1. 4
      main/announcements/announcements.php
  2. 28
      main/calendar/agenda.inc.php
  3. 39
      main/calendar/agenda.lib.php
  4. 34
      main/calendar/agenda_js.php
  5. 6
      main/calendar/myagenda.inc.php
  6. 59
      main/css/base.css
  7. 2
      main/forum/index.php
  8. 2
      main/forum/viewforumcategory.php
  9. 2
      main/inc/lib/display.lib.php
  10. 12
      main/inc/lib/groupmanager.lib.php
  11. 2
      main/inc/lib/tracking.lib.php
  12. 2
      main/permissions/user_permissions.inc.php
  13. 17
      main/template/default/agenda/month.tpl
  14. 2
      main/webservices/cm_webservice_announcements.php

@ -549,7 +549,7 @@ if(api_is_allowed_to_edit(false,true)) {
} else {
// students only get to see the visible announcements
if (empty($_GET['origin']) or $_GET['origin'] !== 'learnpath') {
$group_memberships=GroupManager::get_group_ids($_course['dbName'], $_user['user_id']);
$group_memberships=GroupManager::get_group_ids($_course['real_id'], $_user['user_id']);
if ((api_get_course_setting('allow_user_edit_announcement') && !api_is_anonymous())) {
@ -875,7 +875,7 @@ if ($display_announcement_list) {
//$group_id=$_SESSION['group'];
}
$group_id = api_get_group_id();
$group_memberships = GroupManager::get_group_ids($_course['dbName'],api_get_user_id());
$group_memberships = GroupManager::get_group_ids($_course['real_id'],api_get_user_id());
if (api_is_allowed_to_edit(false,true) OR (api_get_course_setting('allow_user_edit_announcement') && !api_is_anonymous())) {
// A.1. you are a course admin with a USER filter

@ -66,7 +66,7 @@ function get_calendar_items($select_month, $select_year, $select_day = false) {
$TABLEAGENDA = Database::get_course_table(TABLE_AGENDA);
$TABLE_ITEM_PROPERTY = Database::get_course_table(TABLE_ITEM_PROPERTY);
$group_memberships = GroupManager::get_group_ids($course_info['dbName'], api_get_user_id());
$group_memberships = GroupManager::get_group_ids($course_info['real_id'], api_get_user_id());
$repeats = array();
/* CONSTRUCT THE SQL STATEMENT */
@ -87,7 +87,7 @@ function get_calendar_items($select_month, $select_year, $select_day = false) {
// => see only the messages of this specific user + the messages of the group (s)he is member of.
if (!empty($_SESSION['user'])) {
$group_memberships = GroupManager::get_group_ids($course_info['dbName'], $_SESSION['user']);
$group_memberships = GroupManager::get_group_ids($course_info['real_id'], $_SESSION['user']);
$show_user =true;
$new_group_memberships=array();
@ -2725,8 +2725,8 @@ function get_agendaitems($month, $year) {
//databases of the courses
$TABLEAGENDA = Database :: get_course_table(TABLE_AGENDA);
$TABLE_ITEMPROPERTY = Database :: get_course_table(TABLE_ITEM_PROPERTY);
$group_memberships = GroupManager :: get_group_ids(Database::get_current_course_database(), api_get_user_id());
$course_info = api_get_course_info();
$group_memberships = GroupManager :: get_group_ids($course_info['real_id'], api_get_user_id());
// if the user is administrator of that course we show all the agenda items
if (api_is_allowed_to_edit(false,true)) {
//echo "course admin";
@ -2808,12 +2808,12 @@ function display_upcoming_events() {
//databases of the courses
$TABLEAGENDA = Database :: get_course_table(TABLE_AGENDA);
$TABLE_ITEMPROPERTY = Database :: get_course_table(TABLE_ITEM_PROPERTY);
$mycourse = api_get_course_info();
$myuser = api_get_user_info();
$session_id = api_get_session_id();
$mycourse = api_get_course_info();
$myuser = api_get_user_info();
$session_id = api_get_session_id();
$group_memberships = GroupManager :: get_group_ids($mycourse['dbName'], $myuser['user_id']);
$group_memberships = GroupManager :: get_group_ids($mycourse['real_id'], $myuser['user_id']);
// if the user is administrator of that course we show all the agenda items
if (api_is_allowed_to_edit(false,true)) {
//echo "course admin";
@ -3100,11 +3100,11 @@ function get_day_agendaitems($courses_dbs, $month, $year, $day) {
foreach ($courses_dbs as $key => $array_course_info) {
//echo $array_course_info['db'];
//databases of the courses
$TABLEAGENDA = Database :: get_course_table(TABLE_AGENDA, $array_course_info['db_name']);
$TABLE_ITEMPROPERTY = Database :: get_course_table(TABLE_ITEM_PROPERTY, $array_course_info['db_name']);
$TABLEAGENDA = Database :: get_course_table(TABLE_AGENDA);
$TABLE_ITEMPROPERTY = Database :: get_course_table(TABLE_ITEM_PROPERTY);
// getting all the groups of the user for the current course
$group_memberships = GroupManager :: get_group_ids($array_course_info['db_name'], api_get_user_id());
$group_memberships = GroupManager :: get_group_ids($array_course_info['real_id'], api_get_user_id());
$course_user_status = CourseManager::get_user_in_course_status(api_get_user_id(), $array_course_info['code']);
@ -3222,11 +3222,11 @@ function get_week_agendaitems($courses_dbs, $month, $year, $week = '') {
// get agenda-items for every course
foreach ($courses_dbs as $key => $array_course_info) {
//databases of the courses
$TABLEAGENDA = Database :: get_course_table(TABLE_AGENDA, $array_course_info["db_name"]);
$TABLE_ITEMPROPERTY = Database :: get_course_table(TABLE_ITEM_PROPERTY, $array_course_info["db_name"]);
$TABLEAGENDA = Database :: get_course_table(TABLE_AGENDA);
$TABLE_ITEMPROPERTY = Database :: get_course_table(TABLE_ITEM_PROPERTY);
// getting all the groups of the user for the current course
$group_memberships = GroupManager :: get_group_ids($array_course_info["db_name"], api_get_user_id());
$group_memberships = GroupManager :: get_group_ids($array_course_info["real_id"], api_get_user_id());
$user_course_status = CourseManager::get_user_in_course_status(api_get_user_id(),$array_course_info["code"]);

@ -145,12 +145,14 @@ class Agenda {
* @param int course id *integer* not the course code
*
*/
function get_events($start, $end, $user_id, $course_id = null) {
switch($this->type) {
function get_events($start, $end, $user_id, $course_id = null) {
switch ($this->type) {
case 'admin':
$this->get_platform_events($start, $end);
break;
case 'course':
$course_info = api_get_course_info_by_id($course_id);
$this->get_course_events($start, $end, $course_info);
break;
@ -286,40 +288,49 @@ class Agenda {
}
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());
$course_id = $course_info['real_id'];
$group_memberships = GroupManager::get_group_ids($course_id, api_get_user_id());
$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']);
$tlb_course_agenda = Database::get_course_table(TABLE_AGENDA);
$tbl_property = Database::get_course_table(TABLE_ITEM_PROPERTY);
$user_id = api_get_user_id();
if (is_array($group_memberships) && count($group_memberships)>0) {
$sql = "SELECT 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 ".$show_all_current."
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'
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
";
} else {
if (api_get_user_id()) {
$sql="SELECT 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 ".$show_all_current."
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 ip.visibility='1' AND
agenda.c_id = $course_id AND
ip.c_id = $course_id
";
} else {
$sql="SELECT 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 ".$show_all_current."
WHERE agenda.id = ip.ref
AND ip.tool='".TOOL_CALENDAR_EVENT."'
AND ip.to_group_id='0'
AND ip.visibility='1'
AND ip.visibility='1' AND
agenda.c_id = $course_id AND
ip.c_id = $course_id
";
}
}
$result = Database::query($sql);
$events = array();
if (Database::num_rows($result)) {

@ -21,7 +21,7 @@ $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/qtip2/jquery.qtip.min.css');
$tpl = new Template();
$tpl = new Template(get_lang('Agenda'));
$type = isset($_REQUEST['type']) && in_array($_REQUEST['type'], array('personal', 'course', 'admin')) ? $_REQUEST['type'] : 'personal';
if (api_is_platform_admin() && $type == 'admin') {
@ -49,21 +49,31 @@ $days = api_get_week_days_long();
$months = api_get_months_long();
$months_short = api_get_months_short();
$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'))));
//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'))));
//Calendar Type : course, admin, personal
$tpl->assign('type', $type);
//Calendar type label
$tpl->assign('type_label', get_lang($type.'Calendar'));
//Current user can add event?
$tpl->assign('can_add_events', $can_add_events);
//Setting AJAX caller
$agenda_ajax_url = api_get_path(WEB_AJAX_PATH).'agenda.ajax.php?type='.$type.'&';
$tpl->assign('web_agenda_ajax_url', $agenda_ajax_url);
//Loading Agenda template
$content = $tpl->fetch('default/agenda/month.tpl');
$tpl->assign('content', $content);
//Loading main Chamilo 1 col template
$template_file = $tpl->get_template('layout/layout_1_col.tpl');
$tpl->display($template_file);
$tpl->display($template_file);

@ -32,10 +32,10 @@ function get_myagendaitems($user_id, $courses_dbs, $month, $year) {
// get agenda-items for every course
foreach ($courses_dbs as $key => $array_course_info) {
//databases of the courses
$TABLEAGENDA = Database :: get_course_table(TABLE_AGENDA, $array_course_info["db_name"]);
$TABLE_ITEMPROPERTY = Database :: get_course_table(TABLE_ITEM_PROPERTY, $array_course_info["db_name"]);
$TABLEAGENDA = Database :: get_course_table(TABLE_AGENDA);
$TABLE_ITEMPROPERTY = Database :: get_course_table(TABLE_ITEM_PROPERTY);
$group_memberships = GroupManager :: get_group_ids($array_course_info["db_name"], $user_id);
$group_memberships = GroupManager :: get_group_ids($array_course_info["real_id"], $user_id);
$course_user_status = CourseManager::get_user_in_course_status($user_id, $array_course_info["code"]);
// if the user is administrator of that course we show all the agenda items
if ($course_user_status == '1') {

@ -3745,28 +3745,6 @@ form div.error input, form div.error textarea {
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;
}
.tag {
background-color: #D3E6EF;
border-radius: 3px 3px 3px 3px;
@ -3777,3 +3755,40 @@ form div.error input, form div.error textarea {
margin: 0 10px 5px 0;
padding: 0.4em 0.6em;
}
.label_tag {
/* padding: 1px 3px 2px; */
padding:5px;
background-color: #bfbfbf;
font-size: 9.75px;
font-weight: bold;
color: #ffffff;
text-transform: uppercase;
-webkit-border-radius: 3px;
-moz-border-radius: 3px;
border-radius: 3px;
}
.label_tag.personal_event {
background:#3366CC;
}
.label_tag.admin_event {
background:red;
}
.label_tag.course_event {
background:#458B00;
}
.label_tag.important {
background-color: #c43c35;
}
.label_tag.warning {
background-color: #f89406;
}
.label_tag.success {
background-color: #46a546;
}
.label_tag.notice {
background-color: #62cffc;
}

@ -154,7 +154,7 @@ $forum_list = get_forums();
// The groups of the user.
$groups_of_user = array();
$groups_of_user = GroupManager::get_group_ids($_course['dbName'], $_user['user_id']);
$groups_of_user = GroupManager::get_group_ids($_course['real_id'], $_user['user_id']);
// All groups in the course (and sorting them as the id of the group = the key of the array).
if (!api_is_anonymous()) {
$all_groups = GroupManager::get_group_list();

@ -157,7 +157,7 @@ if ($action_forums != 'add') {
// The groups of the user.
$groups_of_user = array();
$groups_of_user = GroupManager::get_group_ids($_course['dbName'], $_user['user_id']);
$groups_of_user = GroupManager::get_group_ids($_course['real_id'], $_user['user_id']);
// All groups in the course (and sorting them as the id of the group = the key of the array.
$all_groups = GroupManager::get_group_list();
if (is_array($all_groups)) {

@ -1093,7 +1093,7 @@ class Display {
" ORDER BY tet.lastedit_date";
$res = Database::query($sql);
// Get the group_id's with user membership.
$group_ids = GroupManager :: get_group_ids($course_database, $user_id);
$group_ids = GroupManager :: get_group_ids($my_course['real_id'], $user_id);
$group_ids[] = 0; //add group 'everyone'
$notifications = array();
// Filter all last edits of all tools of the course

@ -1311,16 +1311,18 @@ class GroupManager {
/**
* Get all group's from a given course in which a given user is unsubscribed
* @author Patrick Cool
* @param string $course_db: the database of the course you want to
* @param int course id
* retrieve the groups for
* @param integer $user_id: the ID of the user you want to know all its
* group memberships
*/
public static function get_group_ids ($course_db, $user_id) {
public static function get_group_ids ($course_id, $user_id) {
$groups = array();
$tbl_group = Database::get_course_table(TABLE_GROUP_USER,$course_db);
$user_id = Database::escape_string($user_id);
$sql = "SELECT group_id FROM $tbl_group WHERE user_id = '$user_id'";
$tbl_group = Database::get_course_table(TABLE_GROUP_USER);
$user_id = intval($user_id);
$course_id = intval($course_id);
$sql = "SELECT group_id FROM $tbl_group WHERE c_id = $course_id AND user_id = '$user_id'";
$groupres = Database::query($sql);
// uncommenting causes a bug in Agenda AND announcements because there we check if the return value of this function is an array or not

@ -1372,7 +1372,7 @@ class Tracking {
$tbl_item_property = Database :: get_course_table(TABLE_ITEM_PROPERTY);
$tbl_student_publication = Database :: get_course_table(TABLE_STUDENT_PUBLICATION);
$course_id = $course_info['real_id'];
$course_id = $a_course['real_id'];
$condition_user = "";
if (is_array($student_id)) {

@ -56,7 +56,7 @@ $current_user_permissions=get_permissions('user',$user_id);
// RETRIEVING THE PERMISSIONS OF THE GROUPS OF THE USER
// ------------------------------------------------------------------
$groups_of_user=array();
$groups_of_user=GroupManager::get_group_ids($_course['db_name'],$user_id);
$groups_of_user=GroupManager::get_group_ids($_course['real_id'],$user_id);
foreach ($groups_of_user as $group)
{
$this_group_permissions=get_permissions('group',$group);

@ -46,9 +46,9 @@ $(document).ready(function() {
} else {
$('#start_date').html(start.toDateString());
}
$('#color_calendar').addClass('background_color_{$type}');
$('#color_calendar').html('{$type_label}');
$('#color_calendar').addClass('label_tag');
$('#color_calendar').addClass('{$type}_event');
$("#dialog-form").dialog("open");
@ -86,16 +86,17 @@ $(document).ready(function() {
},
eventClick: function(calEvent, jsEvent, view) {
if (calEvent.editable) {
if (calEvent.editable) {
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);
}
$('#color_calendar').addClass('background_color_{$type}');
$('#color_calendar').html('{$type_label}');
$('#color_calendar').addClass('label_tag');
$('#color_calendar').addClass('{$type}_event');
$('#start_date').html(calEvent.start.getDate() +"/"+ calEvent.start.getMonth() +"/"+calEvent.start.getFullYear());
@ -181,7 +182,7 @@ $(document).ready(function() {
<label for="date">{"Agenda"|get_lang}</label>
</div>
<div class="formw">
<span id="color_calendar" style="width:100px;"></span>
<div id="color_calendar" style="width:100px;"></div>
</div>
</div>
<div class="row">

@ -98,7 +98,7 @@ class WSCMAnnouncements extends WSCM {
$tbl_announcement = Database::get_course_table(TABLE_ANNOUNCEMENT, $course_db);
$maximum = '12';
$group_memberships=GroupManager::get_group_ids($course_db, $user_id);
$group_memberships=GroupManager::get_group_ids($course_info['real_id'], $user_id);
if (api_get_group_id() == 0) {
$cond_user_id = " AND ( ip.to_user_id='".$user_id."'" .

Loading…
Cancel
Save