diff --git a/main/user/add_users_to_session.php b/main/user/add_users_to_session.php
index f1f7060fee..0dfc6f5303 100644
--- a/main/user/add_users_to_session.php
+++ b/main/user/add_users_to_session.php
@@ -41,7 +41,7 @@ $tool_name = get_lang('SubscribeUsersToSession');
$add_type = 'unique';
-if(isset($_REQUEST['add_type']) && $_REQUEST['add_type']!=''){
+if (isset($_REQUEST['add_type']) && $_REQUEST['add_type']!='') {
$add_type = Security::remove_XSS($_REQUEST['add_type']);
}
@@ -60,7 +60,8 @@ if (is_array($extra_field_list)) {
}
}
-function search_users($needle, $type) {
+function search_users($needle, $type)
+{
global $tbl_user,$tbl_session_rel_user,$id_session;
$xajax_response = new XajaxResponse();
$return = '';
@@ -82,22 +83,23 @@ function search_users($needle, $type) {
$cond_user_id = '';
//Only for single & multiple
- if (in_array($type, array('single','multiple')))
- if (!empty($id_session)) {
- $id_session = intval($id_session);
- // check id_user from session_rel_user table
- $sql = 'SELECT id_user FROM '.$tbl_session_rel_user.' WHERE id_session ="'.$id_session.'" AND relation_type<>'.SESSION_RELATION_TYPE_RRHH.' ';
- $res = Database::query($sql);
- $user_ids = array();
- if (Database::num_rows($res) > 0) {
- while ($row = Database::fetch_row($res)) {
- $user_ids[] = (int)$row[0];
- }
- }
- if (count($user_ids) > 0) {
- $cond_user_id = ' AND user.user_id NOT IN('.implode(",",$user_ids).')';
- }
- }
+ if (in_array($type, array('single','multiple'))) {
+ if (!empty($id_session)) {
+ $id_session = intval($id_session);
+ // check id_user from session_rel_user table
+ $sql = 'SELECT id_user FROM '.$tbl_session_rel_user.' WHERE id_session ="'.$id_session.'" AND relation_type<>'.SESSION_RELATION_TYPE_RRHH.' ';
+ $res = Database::query($sql);
+ $user_ids = array();
+ if (Database::num_rows($res) > 0) {
+ while ($row = Database::fetch_row($res)) {
+ $user_ids[] = (int)$row[0];
+ }
+ }
+ if (count($user_ids) > 0) {
+ $cond_user_id = ' AND user.user_id NOT IN('.implode(",",$user_ids).')';
+ }
+ }
+ }
switch($type) {
case 'single':
@@ -124,7 +126,7 @@ function search_users($needle, $type) {
$tbl_user_rel_access_url= Database::get_main_table(TABLE_MAIN_ACCESS_URL_REL_USER);
$access_url_id = api_get_current_access_url_id();
if ($access_url_id != -1) {
- switch($type) {
+ switch ($type) {
case 'single':
$sql = 'SELECT user.user_id, username, lastname, firstname FROM '.$tbl_user.' user
INNER JOIN '.$tbl_user_rel_access_url.' url_user ON (url_user.user_id=user.user_id)
@@ -531,7 +533,7 @@ if (!empty($errorMsg)) {
'.get_lang('FinishSessionCreation').'';
} else {
//@todo see that the call to "valide()" doesn't duplicate the onsubmit of the form (necessary to avoid delete on "enter" key pressed)
@@ -560,10 +562,11 @@ if (!empty($errorMsg)) {