Skip to content

Commit

Permalink
Prevent make a tutor from a invitee
Browse files Browse the repository at this point in the history
  • Loading branch information
jloguercio committed Mar 4, 2016
1 parent 961375b commit 682e6d4
Show file tree
Hide file tree
Showing 3 changed files with 41 additions and 43 deletions.
4 changes: 2 additions & 2 deletions main/group/member_settings.php
Expand Up @@ -136,8 +136,8 @@ function check_group_members($value)
if (!empty($complete_user_list)) {
usort($complete_user_list, 'sort_users');
foreach ($complete_user_list as $index => $user) {
//prevent invitee users add to groups - see #8091
if ($user['status'] != 20) {
//prevent invitee users add to groups or tutors - see #8091
if ($user['status'] != INVITEE) {
$officialCode = !empty($user['official_code']) ? ' - '.$user['official_code'] : null;

$groups = $userGroup->getUserGroupListByUser($user['user_id']);
Expand Down
38 changes: 21 additions & 17 deletions main/group/tutor_settings.php
Expand Up @@ -128,27 +128,31 @@ function sort_users($user_a, $user_b)
usort($complete_user_list, 'sort_users');

foreach ($complete_user_list as $index => $user) {
$officialCode = !empty($user['official_code']) ? ' - '.$user['official_code'] : null;
$groups = $userGroup->getUserGroupListByUser($user['user_id']);
$groupNameListToString = '';
if (!empty($groups)) {
$groupNameList = array_column($groups, 'name');
$groupNameListToString = ' - ['.implode(', ', $groupNameList).']';
}

$name = api_get_person_name(
$user['firstname'],
$user['lastname']
).' ('.$user['username'].')'.$officialCode;
//prevent invitee users add to groups or tutors - see #8091
if ($user['status'] != INVITEE) {
$officialCode = !empty($user['official_code']) ? ' - '.$user['official_code'] : null;

$groups = $userGroup->getUserGroupListByUser($user['user_id']);
$groupNameListToString = '';
if (!empty($groups)) {
$groupNameList = array_column($groups, 'name');
$groupNameListToString = ' - ['.implode(', ', $groupNameList).']';
}

if ($orderUserListByOfficialCode === 'true') {
$officialCode = !empty($user['official_code']) ? $user['official_code']." - " : '? - ';
$name = $officialCode." ".api_get_person_name(
$name = api_get_person_name(
$user['firstname'],
$user['lastname']
).' ('.$user['username'].')';
).' ('.$user['username'].')'.$officialCode;

if ($orderUserListByOfficialCode === 'true') {
$officialCode = !empty($user['official_code']) ? $user['official_code']." - " : '? - ';
$name = $officialCode." ".api_get_person_name(
$user['firstname'],
$user['lastname']
).' ('.$user['username'].')';
}
$possible_users[$user['user_id']] = $name.$groupNameListToString;
}
$possible_users[$user['user_id']] = $name.$groupNameListToString;
}
}

Expand Down
42 changes: 18 additions & 24 deletions main/user/user.php
Expand Up @@ -74,31 +74,19 @@
case 'set_tutor':
$userId = isset($_GET['user_id']) ? intval($_GET['user_id']) : null;
$isTutor = isset($_GET['is_tutor']) ? intval($_GET['is_tutor']) : 0;
$userInfo = api_get_user_info($userId);

if (!empty($userId)) {
if ($sessionId) {
/*$res = SessionManager::set_coach_to_course_session(
$userId,
$sessionId,
$courseCode,
true
);*/
} else {
/*if (!empty($_POST['promoteCourseAdmin']) && $_POST['promoteCourseAdmin']){
$userProperties['status'] = 1;
} else{
$userProperties['status'] = 5;
if (!$sessionId) {
if ($userInfo['status'] != INVITEE) {
CourseManager::updateUserCourseTutor(
$userId,
$courseId,
$isTutor
);
} else {
Display::addFlash(Display::return_message(get_lang('InviteesCantBeTutors'), 'error'));
}
if (!empty($_POST['promoteTutor']) && $_POST['promoteTutor']){
$userProperties['tutor'] = 1;
} else{
$userProperties['tutor'] = 0;
}*/

CourseManager::updateUserCourseTutor(
$userId,
$courseId,
$isTutor
);
}
}
break;
Expand Down Expand Up @@ -774,6 +762,8 @@ function modify_filter($user_id, $row, $data)
global $is_allowed_to_track, $charset;

$user_id = $data[0];
$userInfo = api_get_user_info($user_id);
$isInvitee = $userInfo['status'] == INVITEE ? true : false;
$course_info = $_course = api_get_course_info();
$current_user_id = api_get_user_id();
$sessionId = api_get_session_id();
Expand Down Expand Up @@ -805,7 +795,11 @@ function modify_filter($user_id, $row, $data)
$text = get_lang('SetTutor');
}

$disabled = '';
if ($isInvitee) {
$disabled = 'disabled';
} else {
$disabled = '';
}

if ($data['user_status_in_course'] == STUDENT) {

Expand Down

0 comments on commit 682e6d4

Please sign in to comment.