Skip to content

Commit

Permalink
Add group users to company reports - refs BT#9441
Browse files Browse the repository at this point in the history
  • Loading branch information
AngelFQC committed Feb 27, 2015
1 parent ea6e20a commit 6d34c77
Showing 1 changed file with 30 additions and 2 deletions.
32 changes: 30 additions & 2 deletions main/inc/ajax/model.ajax.php
Expand Up @@ -145,6 +145,7 @@ function getWhereClause($col, $oper, $val)
switch ($action) {
case 'get_user_course_report':
case 'get_user_course_report_resumed':
$userId = api_get_user_id();
if (!(api_is_platform_admin(false, true))) {
//exit;
}
Expand Down Expand Up @@ -187,10 +188,37 @@ function getWhereClause($col, $oper, $val)
exit;
}
} else if(api_is_student_boss()) {
$users = UserManager::getUsersFollowedByStudentBoss(api_get_user_id());
$users = UserManager::getUsersFollowedByStudentBoss($userId);

$userIdList = array_keys($users);
}

$groups = GroupPortalManager::get_groups_by_user(api_get_user_id(), GROUP_USER_PERMISSION_ADMIN);

$groupsId = array_keys($groups);

if (is_array($groupsId)) {
foreach ($groupsId as $groupId) {
$groupUsers = GroupPortalManager::get_users_by_group($groupId);

if (!is_array($groupUsers)) {
continue;
}

foreach ($groupUsers as $memberId => $member) {
if ($member['user_id'] == $userId ) {
continue;
}

$userIdList[] = intval($member['user_id']);
}
}
}

if (is_array($userIdList)) {
$userIdList = array_unique($userIdList);
}

if ($action == 'get_user_course_report') {
$count = CourseManager::get_count_user_list_from_course_code(false, null, $courseCodeList, $userIdList);
} else {
Expand Down

0 comments on commit 6d34c77

Please sign in to comment.