- Posts: 30
Myevents displays same events to everyone multiple times
- David Laverick
- Topic Author
- Offline
- Junior Member
-
Less
More
11 years 7 months ago #1
by David Laverick
Myevents displays same events to everyone multiple times was created by David Laverick
Hi Guys,
I'm having problems with the userevents view. Events specified for a specific group in a specific course are being shown multiples times, once for every course the user is enrolled into and for all group members. Basically the filtering isn't working at all. Our versions are as follows:
Joomdle 0.95
Joomla 3.3.3
Moodle 2.7
Jomsocial 3.2.1.3
I'm trying to find the piece of code responsible for it to see if I can see the problem. Can anyone give me a place to start looking?
Thanks
Dave
I'm having problems with the userevents view. Events specified for a specific group in a specific course are being shown multiples times, once for every course the user is enrolled into and for all group members. Basically the filtering isn't working at all. Our versions are as follows:
Joomdle 0.95
Joomla 3.3.3
Moodle 2.7
Jomsocial 3.2.1.3
I'm trying to find the piece of code responsible for it to see if I can see the problem. Can anyone give me a place to start looking?
Thanks
Dave
Please Log in or Create an account to join the conversation.
- Antonio Durán
-
- Offline
- Moderator
-
Less
More
- Posts: 7902
11 years 7 months ago #2
by Antonio Durán
Replied by Antonio Durán on topic Myevents displays same events to everyone multiple times
Thanks for the bug report. I tested and can confirm the problem.
To fix it, you can replace these 2 functions in moodle/auth/joomdle/auth.php:
And:
It seems with those changes problem is solved.
To fix it, you can replace these 2 functions in moodle/auth/joomdle/auth.php:
Code:
function get_upcoming_events ($id, $username = '')
{
global $CFG;
$id = addslashes ($id);
$courseshown = $id;
$filtercourse = array($courseshown => $id);
$groupeventsfrom = array($courseshown => 1);
$true = true;
if ($CFG->version >= 2011070100)
{
list($courses, $group, $user) = calendar_set_filters($filtercourse, $true);
$courses = array ($id => $id);
if ($username != '')
{
// Show only events for groups where user is a member
$groups = groups_get_all_groups($id);
$gs = array ();
foreach ($groups as $group)
{
$found = false;
// Check is user is a member of the group
$members = $this->get_group_members ($group->id);
foreach ($members as $member)
{
if ($member['username'] == $username)
{
$found = true;
break;
}
}
if ($found)
$gs[$group->id] = $group->id;
}
}
$events = calendar_get_upcoming($courses, $gs, true,
CALENDAR_DEFAULT_UPCOMING_LOOKAHEAD,
CALENDAR_DEFAULT_UPCOMING_MAXEVENTS);
}
else
{
calendar_set_filters($courses, $group, $user, $filtercourse, $groupeventsfrom, true);
$events = calendar_get_upcoming($courses, $group, $user,
CALENDAR_UPCOMING_DAYS,
CALENDAR_UPCOMING_MAXEVENTS);
}
$data = array ();
foreach ($events as $r)
{
$e['name'] = $r->name;
$e['timestart'] = $r->timestart;
$e['courseid'] = $r->courseid;
$data[$i] = $e;
$i++;
}
return $data;
}
And:
Code:
function get_my_events ($username)
{
global $CFG, $DB;
$username = utf8_decode ($username);
$username = strtolower ($username);
$user = get_complete_user_data ('username', $username);
if (!$user)
return array();
$courses = enrol_get_users_courses ($user->id, true);
$news = array ();
foreach ($courses as $c)
{
$course_news['remoteid'] = $c->id;
$course_news['fullname'] = $c->fullname;
$course_news['events'] = $this->get_upcoming_events ($c->id, $username);
$news[] = $course_news;
}
return $news;
}
It seems with those changes problem is solved.
Please Log in or Create an account to join the conversation.
- David Laverick
- Topic Author
- Offline
- Junior Member
-
Less
More
- Posts: 30
11 years 7 months ago #3
by David Laverick
Replied by David Laverick on topic Myevents displays same events to everyone multiple times
Hi Antonio,
Big Big thank you for that. Very quick fix - worked first time and saved me a lot of digging.
Dave
Big Big thank you for that. Very quick fix - worked first time and saved me a lot of digging.
Dave
Please Log in or Create an account to join the conversation.