Bug #5720
Events en course calendar dissapearing
Description
From a few weeks ago we noticed in our Chamilo 1.9.2 platform that some events in some courses were dissapearing.
Today I found the answer to this problem.
When you delete an event from your course agenda, in the code the c_id reference is not specified in the sql query, so, if you delete an event with id=1, all the events from all courses with the event id=1 are deleted. It also happens when you edit an event.
To solve this I changed the following:
File: main/calendar/agenda.lib.php
Line 187, code should be:
case 'course':
$id_curso=api_get_course_int_id();
$attributes['title'] = $title;
$attributes['content'] = $content;
$attributes['start_date'] = $start;
$attributes['end_date'] = $end;
//Database::update($this->tbl_course_agenda, $attributes, array('id = ?' => $id));
Database::update($this->tbl_course_agenda, $attributes, array('id = ? AND c_id = ?' =>array($id,$id_curso)));
break;
Line 212, code should be:
case 'course':
$id_curso=api_get_course_int_id();
Database::delete($this->tbl_course_agenda, array('id = ? AND c_id = ?' =>array($id,$id_curso)));
//Database::delete($this->tbl_course_agenda, array('id = ?' =>$id));
break;
I was going crazy with this problem, I hope it helps you :)
Associated revisions
History
Updated by Jose Manuel Abuin Mosquera over 8 years ago
- Target version set to 1.9.4
- % Done changed from 60 to 80
Updated by Julio Montoya over 8 years ago
- Status changed from New to Needs more info
Hello Jose,
Thanks for reporting and fixing the bug, the patch was added in the repo
Updated by Yannick Warnier about 8 years ago
- Status changed from Needs testing to Bug resolved
- % Done changed from 80 to 100
I'm approving it, but it would be nice to consider returning values that help identify the problem. For example, in this case, return "false" when course_id is not defined, because we can't do anything without it anyway...
Adding c_id to query see #5720 fix provided by Jose Abuin