"user.php", "name" => get_lang("ToolUser"));
if (isset($_GET['keyword']) && $_GET['keyword']) {
$interbreadcrumb[] = array ("url" => "subscribe_user.php?type=".Security::remove_XSS($_GET['type']), "name" => $tool_name);
$tool_name = get_lang('SearchResults');
}
Display :: display_header($tool_name, "User");
// Build search-form
echo '
';
$actions = null;
if (isset($_GET['keyword'])) {
$actions .= '
'.Display::return_icon('clean_group.gif').' '.get_lang('ClearSearchResults').'';
}
if (isset($_GET['subscribe_user_filter_value']) AND !empty($_GET['subscribe_user_filter_value'])) {
$actions .= '
'.Display::return_icon('clean_group.gif').' '.get_lang('ClearFilterResults').'';
}
if (api_get_setting('ProfilingFilterAddingUsers') == 'true') {
display_extra_profile_fields_filter($type);
}
// Build search-form
$form = new FormValidator('search_user', 'get', '', '', null, false);
$renderer = $form->defaultRenderer();
$renderer->setElementTemplate('
{element} ');
$form->add_textfield('keyword', '', false);
$form->addElement('hidden', 'type', $type);
$form->addElement('style_submit_button', 'submit', get_lang('SearchButton'), 'class="search"');
$form->addElement('static', 'additionalactions', null, $actions);
$form->display();
echo '
';
/*
MAIN SECTION
*/
$current_session_id = api_get_session_id();
$list_register_user='';
$list_not_register_user='';
if (isset ($_REQUEST['register'])) {
if (isset($_REQUEST['type']) && $_REQUEST['type']=='teacher') {
if (!empty($current_session_id)) {
$result_simple_sub = SessionManager::set_coach_to_course_session(intval($_REQUEST['user_id']), $current_session_id, $_course['sysCode']);
} else {
$result_simple_sub = CourseManager :: subscribe_user(intval($_REQUEST['user_id']), $_course['sysCode'],COURSEMANAGER);
}
} else {
$result_simple_sub=CourseManager :: subscribe_user(intval($_REQUEST['user_id']), $_course['sysCode']);
}
$user_id_temp=$_SESSION['session_user_id'];
if (is_array($user_id_temp)) {
$counter = count($user_id_temp);
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'));
} else {
Display::display_error_message($_SESSION['session_user_name'][$j].' '.get_lang('NotAddedToCourse'));
}
}
}
unset($_SESSION['session_user_id']);
unset($_SESSION['session_user_name']);
}
}
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(isset($_REQUEST['type']) && $_REQUEST['type']=='teacher') {
if (!empty($current_session_id)) {
$is_suscribe[] = SessionManager::set_coach_to_course_session($user_id, $current_session_id, $_course['sysCode']);
} else {
$is_suscribe[] = CourseManager::subscribe_user($user_id, $_course['sysCode'],COURSEMANAGER);
}
} else {
$is_suscribe[]=CourseManager::subscribe_user($user_id, $_course['sysCode']);
}
$is_suscribe_user_id[]=$user_id;
}
}
$user_id_temp=$_SESSION['session_user_id'];
$user_name_temp=$_SESSION['session_user_name'];
unset($_SESSION['session_user_id']);
unset($_SESSION['session_user_name']);
$counter=0;
$is_suscribe_counter=count($is_suscribe_user_id);
$list_register_user='';
//if ($$is_suscribe_counter!=1) {
for ($i=0; $i<$is_suscribe_counter;$i++) {
for ($j=0; $j