api_get_path(WEB_CODE_PATH).'work/work.php?'.api_get_cidreq(),
'name' => get_lang('StudentPublications'),
];
$interbreadcrumb[] = [
'url' => api_get_path(WEB_CODE_PATH).'work/work_list_all.php?'.api_get_cidreq().'&id='.$workId,
'name' => $my_folder_data['title'],
];
$interbreadcrumb[] = ['url' => '#', 'name' => get_lang('AddUsers')];
switch ($action) {
case 'add':
$data = getUserToWork($userId, $workId, api_get_course_int_id());
if (empty($data)) {
addUserToWork($userId, $workId, api_get_course_int_id());
}
$url = api_get_path(WEB_CODE_PATH).'work/add_user.php?id='.$workId.'&'.api_get_cidreq();
header('Location: '.$url);
exit;
break;
case 'delete':
if (!empty($workId) && !empty($userId)) {
deleteUserToWork($userId, $workId, api_get_course_int_id());
$url = api_get_path(WEB_CODE_PATH).'work/add_user.php?id='.$workId.'&'.api_get_cidreq();
header('Location: '.$url);
exit;
}
break;
}
Display :: display_header(null);
$items = getAllUserToWork($workId, api_get_course_int_id());
$usersAdded = [];
if (!empty($items)) {
echo Display::page_subheader(get_lang('UsersAdded'));
echo '
';
foreach ($items as $data) {
$myUserId = $data['user_id'];
$usersAdded[] = $myUserId;
$userInfo = api_get_user_info($myUserId);
$url = api_get_path(WEB_CODE_PATH).'work/add_user.php?action=delete&id='.$workId.'&user_id='.$myUserId;
$link = Display::url(
' '.get_lang('Delete'),
$url,
['class' => 'btn btn-danger btn-sm']
);
echo '- '.
$userInfo['complete_name_with_username'].'
'.$link.'
';
}
echo '
';
}
if (empty($sessionId)) {
$status = STUDENT;
} else {
$status = 0;
}
$userList = CourseManager::get_user_list_from_course_code(
$courseInfo['code'],
$sessionId,
null,
null,
$status
);
$userToAddList = [];
foreach ($userList as $user) {
if (!in_array($user['user_id'], $usersAdded)) {
$userToAddList[] = $user;
}
}
if (!empty($userToAddList)) {
echo Display::page_subheader(get_lang('UsersToAdd'));
echo '';
foreach ($userToAddList as $user) {
$userName = api_get_person_name($user['firstname'], $user['lastname']).' ('.$user['username'].') ';
$url = api_get_path(WEB_CODE_PATH).'work/add_user.php?action=add&id='.$workId.'&user_id='.$user['user_id'];
$link = Display::url(
' '.get_lang('Add'),
$url,
['class' => 'btn btn-primary btn-sm']
);
echo '- '.$userName.'
'.$link.'
';
}
echo '
';
} else {
echo Display::return_message(get_lang('NoUsersToAdd'), 'warning');
}
echo '
';
Display::display_footer();