Merge remote-tracking branch 'origin/1.10.x' into 1.10.x

1.10.x
Yannick Warnier 9 years ago
commit ae742fd742
  1. 7
      main/group/group.php
  2. 10
      main/inc/lib/usermanager.lib.php
  3. 186
      main/user/subscribe_user.php
  4. 94
      main/user/user.php

@ -147,8 +147,11 @@ if (api_is_allowed_to_edit(false, true)) {
echo '<div class="actions">';
if (api_is_allowed_to_edit(false, true)) {
echo '<a href="group_creation.php?'.api_get_cidreq().'">'.
Display::return_icon('new_group.png', get_lang('NewGroupCreate'), '', ICON_SIZE_MEDIUM).'</a>';
Display::return_icon('add.png', get_lang('NewGroupCreate'), '', ICON_SIZE_MEDIUM).'</a>';
echo GroupManager::getSearchForm();
if (api_get_setting('allow_group_categories') == 'true') {
echo '<a href="group_category.php?'.api_get_cidreq().'&action=add_category">'.
@ -172,8 +175,6 @@ if (api_is_allowed_to_edit(false, true)) {
echo '<a href="group_overview.php?'.api_get_cidreq().'">'.
Display::return_icon('group_summary.png', get_lang('GroupOverview'), '', ICON_SIZE_MEDIUM).'</a>';
echo GroupManager::getSearchForm();
}
$group_cats = GroupManager::get_categories(api_get_course_id());

@ -5076,17 +5076,21 @@ SQL;
$headers = [
[
'url' => $userPath.'user.php?'.api_get_cidreq(),
'content' => get_lang('Users'),
'url' => $userPath.'user.php?'.api_get_cidreq().'&type='.STUDENT,
'content' => get_lang('Students'),
],
[
'url' => $userPath.'user.php?'.api_get_cidreq().'&type='.COURSEMANAGER,
'content' => get_lang('Teachers'),
],
/*[
'url' => $userPath.'subscribe_user.php?'.api_get_cidreq(),
'content' => get_lang('Students'),
],
[
'url' => $userPath.'subscribe_user.php?type=teacher&'.api_get_cidreq(),
'content' => get_lang('Teachers'),
],
],*/
[
'url' => api_get_path(WEB_CODE_PATH).'group/group.php?'.api_get_cidreq(),
'content' => get_lang('Groups'),

@ -26,76 +26,53 @@ if (!api_is_allowed_to_edit()) {
}
$tool_name = get_lang("SubscribeUserToCourse");
$type = isset($_REQUEST['type']) ? Security::remove_XSS($_REQUEST['type']) : null;
$type = isset($_REQUEST['type']) ? intval($_REQUEST['type']) : STUDENT;
$keyword = isset($_REQUEST['keyword']) ? Security::remove_XSS($_REQUEST['keyword']) : null;
if ($type == 'teacher') {
$courseInfo = api_get_course_info();
if ($type == COURSEMANAGER) {
$tool_name = get_lang("SubscribeUserToCourseAsTeacher");
}
//extra entries in breadcrumb
$interbreadcrumb[] = array ("url" => "user.php", "name" => get_lang("ToolUser"));
$interbreadcrumb[] = array(
"url" => "user.php?".api_get_cidreq(),
"name" => get_lang("ToolUser"),
);
if ($keyword) {
$interbreadcrumb[] = array ("url" => "subscribe_user.php?type=".$type, "name" => $tool_name);
$interbreadcrumb[] = array(
"url" => "subscribe_user.php?type=".$type.'&'.api_get_cidreq(),
"name" => $tool_name,
);
$tool_name = get_lang('SearchResults');
}
Display :: display_header($tool_name, "User");
// Build search-form
echo '<div class="actions">';
$actions = null;
if (isset($keyword)) {
$actions .= '<a href="subscribe_user.php?type='.$type.'">'.Display::return_icon('clean_group.gif').' '.get_lang('ClearSearchResults').'</a>';
}
if (isset($_GET['subscribe_user_filter_value']) AND !empty($_GET['subscribe_user_filter_value'])) {
$actions .= '<a href="subscribe_user.php?type='.$type.'">'.Display::return_icon('clean_group.gif').' '.get_lang('ClearFilterResults').'</a>';
}
if (api_get_setting('ProfilingFilterAddingUsers') == 'true') {
display_extra_profile_fields_filter();
}
// Build search-form
$form = new FormValidator('search_user', 'get', '', '', null, false);
$renderer = $form->defaultRenderer();
$renderer->setCustomElementTemplate('<span>{element}</span> ');
$form->addText('keyword', '', false);
$form->addElement('hidden', 'type', $type);
$form->addButtonSearch(get_lang('Search'));
$form->addElement('static', 'additionalactions', null, $actions);
$form->display();
echo '</div>';
$option = $type == 'teacher' ? 3 : 2;
echo UserManager::getUserSubscriptionTab($option);
/*
MAIN SECTION
*/
$current_session_id = api_get_session_id();
$list_register_user='';
$list_not_register_user='';
if (isset($_REQUEST['register'])) {
if ($type =='teacher') {
if ($type == COURSEMANAGER) {
if (!empty($current_session_id)) {
$result_simple_sub = SessionManager::set_coach_to_course_session(
$_REQUEST['user_id'],
$current_session_id,
$_course['code']
$courseInfo['code']
);
} else {
$result_simple_sub = CourseManager:: subscribe_user(
$_REQUEST['user_id'],
$_course['code'],
$courseInfo['code'],
COURSEMANAGER
);
}
} else {
$result_simple_sub = CourseManager :: subscribe_user($_REQUEST['user_id'], $_course['code']);
$result_simple_sub = CourseManager:: subscribe_user(
$_REQUEST['user_id'],
$courseInfo['code']
);
}
$user_id_temp = $_SESSION['session_user_id'];
@ -105,9 +82,9 @@ if (isset($_REQUEST['register'])) {
for ($j=0; $j<$counter;$j++) {
if ($user_id_temp[$j]==$_GET['user_id']) {
if ($result_simple_sub) {
Display::display_confirmation_message($_SESSION['session_user_name'][$j].' '.get_lang('AddedToCourse'));
Display::addFlash(Display::return_message($_SESSION['session_user_name'][$j].' '.get_lang('AddedToCourse')));
} else {
Display::display_error_message($_SESSION['session_user_name'][$j].' '.get_lang('NotAddedToCourse'));
Display::addFlash(Display::return_message($_SESSION['session_user_name'][$j].' '.get_lang('NotAddedToCourse'), 'error'));
}
}
@ -115,33 +92,44 @@ if (isset($_REQUEST['register'])) {
unset($_SESSION['session_user_id']);
unset($_SESSION['session_user_name']);
}
header('Location:'.api_get_path(WEB_CODE_PATH).'user/user.php?'.api_get_cidreq().'&type='.$type);
exit;
}
if (isset ($_POST['action'])) {
switch ($_POST['action']) {
case 'subscribe':
if (is_array($_POST['user'])) {
foreach ($_POST['user'] as $index => $user_id) {
$user_id=intval($user_id);
if ($type =='teacher') {
if (!empty($current_session_id)) {
$is_suscribe[] = SessionManager::set_coach_to_course_session(
if (isset($_POST['action'])) {
switch($_POST['action']) {
case 'subscribe':
if (is_array($_POST['user'])) {
foreach ($_POST['user'] as $index => $user_id) {
$user_id=intval($user_id);
if ($type == COURSEMANAGER) {
if (!empty($current_session_id)) {
$is_suscribe[] = SessionManager::set_coach_to_course_session(
$user_id,
$current_session_id,
$_course['sysCode']
$courseInfo['code']
);
} else {
$is_suscribe[] = CourseManager::subscribe_user($user_id, $_course['code'],COURSEMANAGER);
}
} else {
$is_suscribe[] = CourseManager::subscribe_user($user_id, $_course['code']);
}
} else {
$is_suscribe[] = CourseManager::subscribe_user(
$user_id,
$courseInfo['code'],
COURSEMANAGER
);
}
} else {
$is_suscribe[] = CourseManager::subscribe_user(
$user_id,
$courseInfo['code']
);
}
$is_suscribe_user_id[] = $user_id;
}
}
}
}
$user_id_temp=$_SESSION['session_user_id'];
$user_name_temp=$_SESSION['session_user_name'];
$user_id_temp = $_SESSION['session_user_id'];
$user_name_temp = $_SESSION['session_user_name'];
unset($_SESSION['session_user_id']);
unset($_SESSION['session_user_name']);
@ -167,17 +155,20 @@ if (isset ($_POST['action'])) {
if (!empty($list_register_user)) {
if ($is_suscribe_counter==1) {
$register_user_message=$temp_unique_user.' '.get_lang('AddedToCourse');
Display::display_confirmation_message($register_user_message,false);
Display::addFlash(Display::return_message($register_user_message));
} else {
$register_user_message='<br />'.get_lang('UsersRegistered').'<br/><br />'.$list_register_user;
Display::display_confirmation_message($register_user_message,false);
Display::addFlash(Display::return_message($register_user_message, false));
}
}
if (!empty($list_not_register_user)) {
$not_register_user_message='<br />'.get_lang('UsersNotRegistered').'<br/><br /><br />'.$list_not_register_user;
Display::display_error_message($not_register_user_message,false);
Display::addFlash(Display::return_message($not_register_user_message, 'error'));
}
header('Location:'.api_get_path(WEB_CODE_PATH).'user/user.php?'.api_get_cidreq().'&type='.$type);
exit;
break;
}
}
@ -201,7 +192,7 @@ $table = new SortableTable(
($is_western_name_order xor $sort_by_first_name) ? 3 : 2
);
$parameters['keyword'] = $keyword;
$parameters['type'] = $type;
$parameters['type'] = COURSEMANAGER;
$table->set_additional_parameters($parameters);
$col = 0;
$table->set_header($col ++, '', false);
@ -229,6 +220,50 @@ if (!empty($_POST['keyword'])) {
echo '<br/>'.get_lang('SearchResultsFor').' <span style="font-style: italic ;"> '.$keyword_name.' </span><br>';
}
Display :: display_header($tool_name, "User");
// Build search-form
echo '<div class="actions">';
switch ($type) {
case STUDENT:
$url = api_get_path(WEB_CODE_PATH).'user/user.php?'.api_get_cidreq().'';
break;
case COURSEMANAGER:
$url = api_get_path(WEB_CODE_PATH).'user/user.php?'.api_get_cidreq().'&type='.COURSEMANAGER;
break;
}
echo Display::url(
Display::return_icon('back.png', get_lang('Back'), '', ICON_SIZE_MEDIUM),
$url
);
$actions = '';
if (isset($keyword)) {
$actions .= '<a href="subscribe_user.php?type='.$type.'&">'.
Display::return_icon('clean_group.gif').' '.get_lang('ClearSearchResults').'</a>';
}
if (isset($_GET['subscribe_user_filter_value']) AND !empty($_GET['subscribe_user_filter_value'])) {
$actions .= '<a href="subscribe_user.php?type='.$type.'">'.
Display::return_icon('clean_group.gif').' '.get_lang('ClearFilterResults').'</a>';
}
if (api_get_setting('ProfilingFilterAddingUsers') == 'true') {
display_extra_profile_fields_filter();
}
// Build search-form
$form = new FormValidator('search_user', 'get', '', '', null, FormValidator::LAYOUT_INLINE);
$form->addText('keyword', '', false);
$form->addElement('hidden', 'type', $type);
$form->addButtonSearch(get_lang('Search'));
$form->addElement('static', 'additionalactions', null, $actions);
$form->display();
echo '</div>';
$option = $type == COURSEMANAGER ? 2 : 1;
echo UserManager::getUserSubscriptionTab($option);
// Display table
$table->display();
@ -241,8 +276,6 @@ Display::display_footer();
*/
function get_number_of_users()
{
global $_configuration;
// Database table definition
$user_table = Database::get_main_table(TABLE_MAIN_USER);
$course_user_table = Database::get_main_table(TABLE_MAIN_COURSE_USER);
@ -419,8 +452,6 @@ function get_number_of_users()
*/
function get_user_data($from, $number_of_items, $column, $direction)
{
global $_configuration;
$url_access_id = api_get_current_access_url_id();
$course_code = api_get_course_id();
$session_id = api_get_session_id();
@ -459,8 +490,7 @@ function get_user_data($from, $number_of_items, $column, $direction)
u.active AS col4,
u.user_id AS col5";
}
if (isset($_REQUEST['type']) && $_REQUEST['type'] == 'teacher') {
if (isset($_REQUEST['type']) && $_REQUEST['type'] == COURSEMANAGER) {
// adding a teacher through a session
if (!empty($session_id)) {
$sql = "SELECT $select_fields
@ -728,10 +758,10 @@ function email_filter($email) {
* @return string Some HTML-code
*/
function reg_filter($user_id) {
if (isset($_REQUEST['type']) && $_REQUEST['type'] == 'teacher') {
$type = 'teacher';
if (isset($_REQUEST['type']) && $_REQUEST['type'] == COURSEMANAGER) {
$type = COURSEMANAGER;
} else {
$type = 'student';
$type = STUDENT;
}
$result = '<a class="btn btn-small btn-primary" href="'.api_get_self().'?register=yes&type='.$type.'&user_id='.$user_id.'">'.get_lang("reg").'</a>';
return $result;
@ -787,8 +817,6 @@ function search_additional_profile_fields($keyword)
$table_user_field_values = Database::get_main_table(TABLE_EXTRA_FIELD_VALUES);
$tableExtraField = Database::get_main_table(TABLE_EXTRA_FIELD);
$table_user = Database::get_main_table(TABLE_MAIN_USER);
$table_course_user = Database :: get_main_table(TABLE_MAIN_COURSE_USER);
$table_session_course_user = Database::get_main_table(TABLE_MAIN_SESSION_COURSE_USER);
// getting the field option text that match this keyword (for radio buttons and checkboxes)
$sql = "SELECT * FROM $table_user_field_options

@ -19,8 +19,6 @@ $this_section = SECTION_COURSES;
// notice for unauthorized people.
api_protect_course_script(true);
global $_configuration;
if (!api_is_platform_admin(true)) {
if (!api_is_course_admin() && !api_is_coach()) {
if (api_get_course_setting('allow_user_view_user_list') == 0) {
@ -534,14 +532,13 @@ function searchUserKeyword($firstname, $lastname, $username, $official_code, $ke
*/
function get_user_data($from, $number_of_items, $column, $direction)
{
global $origin;
global $is_western_name_order;
global $extraFields;
$type = isset($_REQUEST['type']) ? intval($_REQUEST['type']) : STUDENT;
$course_info = api_get_course_info();
$sessionId = api_get_session_id();
$course_code = $course_info['code'];
$a_users = array();
// limit
@ -585,12 +582,22 @@ function get_user_data($from, $number_of_items, $column, $direction)
$active = isset($_GET['active']) ? $_GET['active'] : null;
if (empty($sessionId)) {
$status = $type;
} else {
if ($type == COURSEMANAGER) {
$status = 2;
} else {
$status = 0;
}
}
$a_course_users = CourseManager :: get_user_list_from_course_code(
$course_code,
$sessionId,
$limit,
$order_by,
null,
$status,
null,
false,
false,
@ -746,17 +753,18 @@ function active_filter($active, $urlParams, $row)
*/
function modify_filter($user_id, $row, $data)
{
global $origin, $is_allowed_to_track, $charset;
global $is_allowed_to_track, $charset;
$user_id = $data[0];
$course_info = $_course = api_get_course_info();
$current_user_id = api_get_user_id();
$sessionId = api_get_session_id();
$type = isset($_REQUEST['type']) ? intval($_REQUEST['type']) : STUDENT;
$result = "";
if ($is_allowed_to_track) {
$result .= '<a href="../mySpace/myStudents.php?'.api_get_cidreq().'&student='.$user_id.'&amp;details=true&amp;course='.$_course['id'].'&amp;origin=user_course&amp;id_session='.api_get_session_id().'" title="'.get_lang('Tracking').'" >
$result .= '<a href="../mySpace/myStudents.php?'.api_get_cidreq().'&student='.$user_id.'&details=true&course='.$_course['id'].'&origin=user_course&id_session='.api_get_session_id().'" title="'.get_lang('Tracking').'" >
<img border="0" alt="'.get_lang('Tracking').'" src="../img/icons/22/stats.png" />
</a>';
}
@ -764,7 +772,7 @@ function modify_filter($user_id, $row, $data)
// If platform admin, show the login_as icon (this drastically shortens
// time taken by support to test things out)
if (api_is_platform_admin()) {
$result .= ' <a href="'.api_get_path(WEB_CODE_PATH).'admin/user_list.php?action=login_as&amp;user_id='.$user_id.'&amp;sec_token='.$_SESSION['sec_token'].'">'.
$result .= ' <a href="'.api_get_path(WEB_CODE_PATH).'admin/user_list.php?action=login_as&user_id='.$user_id.'&sec_token='.$_SESSION['sec_token'].'">'.
Display::return_icon('login_as.gif', get_lang('LoginAs')).'</a>&nbsp;&nbsp;';
}
@ -781,20 +789,22 @@ function modify_filter($user_id, $row, $data)
$disabled = '';
if ($data['user_status_in_course'] == COURSEMANAGER) {
$disabled = 'disabled';
if ($data['user_status_in_course'] == STUDENT) {
$result .= Display::url(
$text,
'user.php?'.api_get_cidreq(
).'&action=set_tutor&is_tutor='.$isTutor.'&user_id='.$user_id.'&type='.$type,
array('class' => 'btn btn-default '.$disabled)
).'&nbsp;';
}
$result .= Display::url(
$text,
'user.php?'.api_get_cidreq().'&action=set_tutor&is_tutor='.$isTutor.'&user_id='.$user_id,
array('class' => 'btn btn-default '.$disabled)
).'&nbsp;';
}
// edit
if (api_get_setting('allow_user_course_subscription_by_course_admin') == 'true' or api_is_platform_admin()) {
// unregister
if ($user_id != $current_user_id || api_is_platform_admin()) {
$result .= '<a class="btn btn-small btn-danger" href="'.api_get_self().'?'.api_get_cidreq().'&unregister=yes&amp;user_id='.$user_id.'" title="'.get_lang('Unreg').' " onclick="javascript:if(!confirm(\''.addslashes(api_htmlentities(get_lang('ConfirmYourChoice'),ENT_QUOTES,$charset)).'\')) return false;">'.get_lang('Unreg').'</a>&nbsp;';
$result .= '<a class="btn btn-small btn-danger" href="'.api_get_self().'?'.api_get_cidreq().'&type='.$type.'&unregister=yes&user_id='.$user_id.'" title="'.get_lang('Unreg').' " onclick="javascript:if(!confirm(\''.addslashes(api_htmlentities(get_lang('ConfirmYourChoice'),ENT_QUOTES,$charset)).'\')) return false;">'.
get_lang('Unreg').'</a>&nbsp;';
} else {
//$result .= Display::return_icon('unsubscribe_course_na.png', get_lang('Unreg'),'',ICON_SIZE_SMALL).'</a>&nbsp;';
}
@ -803,7 +813,8 @@ function modify_filter($user_id, $row, $data)
// Show buttons for unsubscribe
if ($course_info['unsubscribe'] == 1) {
if ($user_id == $current_user_id) {
$result .= '<a class="btn btn-small btn-danger" href="'.api_get_self().'?'.api_get_cidreq().'&unregister=yes&amp;user_id='.$user_id.'" title="'.get_lang('Unreg').' " onclick="javascript:if(!confirm(\''.addslashes(api_htmlentities(get_lang('ConfirmYourChoice'),ENT_QUOTES,$charset)).'\')) return false;">'.get_lang('Unreg').'</a>&nbsp;';
$result .= '<a class="btn btn-small btn-danger" href="'.api_get_self().'?'.api_get_cidreq().'&type='.$type.'&unregister=yes&user_id='.$user_id.'" title="'.get_lang('Unreg').' " onclick="javascript:if(!confirm(\''.addslashes(api_htmlentities(get_lang('ConfirmYourChoice'),ENT_QUOTES,$charset)).'\')) return false;">'.
get_lang('Unreg').'</a>&nbsp;';
}
}
}
@ -890,14 +901,16 @@ if (api_is_allowed_to_edit(null, true)) {
}
}
/* Header */
if (isset($origin) && $origin == 'learnpath') {
Display::display_reduced_header();
} else {
if (isset($_GET['keyword']) && !empty($_GET['keyword'])) {
$interbreadcrumb[] = array ("url" => "user.php", "name" => get_lang("Users"));
$interbreadcrumb[] = array(
"url" => "user.php?".api_get_cidreq(),
"name" => get_lang("Users"),
);
$tool_name = get_lang('SearchResults');
} else {
$tool_name = get_lang('Users');
@ -912,12 +925,38 @@ $is_allowed_to_track = ($is_courseAdmin || $is_courseTutor);
// Tool introduction
Display::display_introduction_section(TOOL_USER, 'left');
$actions = '';
$type = isset($_REQUEST['type']) ? intval($_REQUEST['type']) : STUDENT;
$selectedTab = 1;
if (api_is_allowed_to_edit(null, true)) {
echo '<div class="actions">';
$actions .= '<a href="user.php?'.api_get_cidreq().'&action=export&amp;type=csv">'.
switch ($type) {
case STUDENT:
$selectedTab = 1;
$url = api_get_path(WEB_CODE_PATH).'user/subscribe_user.php?'.api_get_cidreq().'';
break;
case COURSEMANAGER:
$selectedTab = 2;
$url = api_get_path(WEB_CODE_PATH).'user/subscribe_user.php?'.api_get_cidreq().'&type='.COURSEMANAGER;
break;
}
echo Display::url(
Display::return_icon('add.png', get_lang('Add'), '', ICON_SIZE_MEDIUM),
$url
);
// Build search-form
$form = new FormValidator('search_user', 'get', '', '', null, FormValidator::LAYOUT_INLINE);
$form->addText('keyword', '', false);
$form->addButtonSearch(get_lang('SearchButton'));
$form->display();
$actions .= '<a href="user.php?'.api_get_cidreq().'&action=export&type=csv">'.
Display::return_icon('export_csv.png', get_lang('ExportAsCSV'),'',ICON_SIZE_MEDIUM).'</a> ';
$actions .= '<a href="user.php?'.api_get_cidreq().'&action=export&amp;type=xls">'.
$actions .= '<a href="user.php?'.api_get_cidreq().'&action=export&type=xls">'.
Display::return_icon('export_excel.png', get_lang('ExportAsXLS'),'',ICON_SIZE_MEDIUM).'</a> ';
if (api_get_setting('allow_user_course_subscription_by_course_admin') == 'true' ||
@ -929,24 +968,19 @@ if (api_is_allowed_to_edit(null, true)) {
$actions .= '<a href="user.php?'.api_get_cidreq().'&action=export&type=pdf">'.
Display::return_icon('pdf.png', get_lang('ExportToPDF'),'',ICON_SIZE_MEDIUM).'</a> ';
/*$actions .= "<a href=\"../group/group.php?".api_get_cidreq()."\">".
Display::return_icon('group.png', get_lang("GroupUserManagement"),'',ICON_SIZE_MEDIUM)."</a>";*/
$allowTutors = api_get_setting('allow_tutors_to_assign_students_to_session');
if (api_is_allowed_to_edit() && $allowTutors == 'true') {
$actions .= ' <a class="btn btn-default" href="session_list.php?'.api_get_cidreq().'">'.get_lang('Sessions').'</a>';
$actions .= ' <a class="btn btn-default" href="session_list.php?'.api_get_cidreq().'">'.
get_lang('Sessions').'</a>';
}
// Build search-form
$form = new FormValidator('search_user', 'get', '', '', null, FormValidator::LAYOUT_INLINE);
$form->addText('keyword', '', false);
$form->addButtonSearch(get_lang('SearchButton'));
$form->display();
echo $actions;
echo '</div>';
}
echo UserManager::getUserSubscriptionTab(1);
echo UserManager::getUserSubscriptionTab($selectedTab);
if (isset($message)) {
Display::display_confirmation_message($message);

Loading…
Cancel
Save