function _opigno_course_students_info in Opigno 7
File
- ./
opigno.module, line 782 - Contains all hook_implementations and module specific API.
Code
function _opigno_course_students_info($node) {
$node_id = $node->nid;
$group_members = opigno_get_users_in_group($node_id);
$students_number = 0;
foreach ($group_members as $member) {
$user = user_load($member->uid);
$user_roles = og_get_user_roles('node', $node_id, $user->uid, FALSE);
foreach ($user_roles as $roleid => $rolename) {
if ($roleid == 5 && sizeof($user_roles) == 1) {
$students_number++;
}
}
}
return array(
'places' => $node->field_course_places[LANGUAGE_NONE][0]['value'],
'available_places' => $node->field_course_places[LANGUAGE_NONE][0]['value'] - $students_number,
'students' => $students_number,
);
}